WIP registration form

trunk
vilmibm 2022-07-10 01:10:02 -05:00
parent 9bdbc9d658
commit d96f00c89b
2 changed files with 27 additions and 1 deletions

View File

@ -133,7 +133,9 @@ func _main() error {
AddItem("jack in", "connect using an existing account", '1', func() { AddItem("jack in", "connect using an existing account", '1', func() {
pages.SwitchToPage("game") pages.SwitchToPage("game")
}). }).
AddItem("rez a toon", "create a new account", '2', nil). AddItem("rez a toon", "create a new account", '2', func() {
pages.SwitchToPage("register")
}).
AddItem("open the hood", "client configuration", '3', nil). AddItem("open the hood", "client configuration", '3', nil).
AddItem("get outta here", "quit the client", '4', func() { AddItem("get outta here", "quit the client", '4', func() {
app.Stop() app.Stop()
@ -141,6 +143,29 @@ func _main() error {
pages.AddPage("main", mainPage, true, false) pages.AddPage("main", mainPage, true, false)
unfi := tview.NewInputField().SetLabel("account name")
pwfi := tview.NewInputField().SetLabel("password").SetMaskCharacter('~')
registerPage := tview.NewForm().AddFormItem(unfi).AddFormItem(pwfi).
SetCancelFunc(func() {
pages.SwitchToPage("main")
})
submitFunc := func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
cs.Client.Register(ctx, &proto.AuthInfo{
Username: unfi.GetText(),
Password: pwfi.GetText(),
})
}
registerPage.AddButton("gimme that shit", submitFunc)
registerPage.AddButton("nah get outta here", func() {
pages.SwitchToPage("main")
})
pages.AddPage("register", registerPage, true, false)
msgView := tview.NewTextView().SetScrollable(true).SetWrap(true).SetWordWrap(true) msgView := tview.NewTextView().SetScrollable(true).SetWrap(true).SetWordWrap(true)
cs.messagesView = msgView cs.messagesView = msgView

View File

@ -83,6 +83,7 @@ func (s *gameWorldServer) Messages(si *proto.SessionInfo, stream proto.GameWorld
} }
func (s *gameWorldServer) Register(ctx context.Context, auth *proto.AuthInfo) (*proto.SessionInfo, error) { func (s *gameWorldServer) Register(ctx context.Context, auth *proto.AuthInfo) (*proto.SessionInfo, error) {
log.Printf("COOL HI HELLO %s %s", auth.Username, auth.Password)
// TODO // TODO
return nil, nil return nil, nil
} }