Beispiel #1
0
func newLoginScreen() *loginScreen {
	ls := &loginScreen{
		scene: scene.New(false),
	}
	if clientToken.Value() == "" {
		data := make([]byte, 16)
		crand.Read(data)
		clientToken.SetValue(hex.EncodeToString(data))
	}

	ls.logo.init(ls.scene)

	ls.LoginBtn, ls.LoginTxt = newButtonText("Login", 0, 100, 400, 40)
	ls.scene.AddDrawable(ls.LoginBtn.Attach(ui.Middle, ui.Center))
	ls.scene.AddDrawable(ls.LoginTxt)
	ls.LoginBtn.AddClick(ls.Login)

	ls.LoginError = ui.NewText("", 0, 150, 255, 50, 50).Attach(ui.Middle, ui.Center)
	ls.scene.AddDrawable(ls.LoginError)

	{
		ls.User = ui.NewTextBox(0, -20, 400, 40).Attach(ui.Middle, ui.Center)
		ls.scene.AddDrawable(ls.User)
		label := ui.NewText("Username/Email:", 0, -18, 255, 255, 255)
		label.AttachTo(ls.User)
		ls.scene.AddDrawable(label)
	}

	{
		ls.Pass = ui.NewTextBox(0, 40, 400, 40).Attach(ui.Middle, ui.Center)
		ls.Pass.SubmitFunc = ls.Login
		ls.Pass.SetPassword(true)
		ls.scene.AddDrawable(ls.Pass)
		label := ui.NewText("Password:", 0, -18, 255, 255, 255)
		label.AttachTo(ls.Pass)
		ls.scene.AddDrawable(label)
	}

	uiFooter(ls.scene)

	ls.scene.Show()
	if getProfile().IsComplete() {
		ls.refresh()
	}

	return ls
}
Beispiel #2
0
func newEditServer(index int) *editServer {
	se := &editServer{
		scene: scene.New(true),
		index: index,
	}

	se.logo.init(se.scene)

	uiFooter(se.scene)

	done, txt := newButtonText("Done", 110, 100, 200, 40)
	se.scene.AddDrawable(done.Attach(ui.Center, ui.Middle))
	se.scene.AddDrawable(txt)
	done.AddClick(func() {
		se.save()
	})

	cancel, txt := newButtonText("Cancel", -110, 100, 200, 40)
	se.scene.AddDrawable(cancel.Attach(ui.Center, ui.Middle))
	se.scene.AddDrawable(txt)
	cancel.AddClick(func() {
		setScreen(newServerList())
	})

	se.name = ui.NewTextBox(0, -20, 400, 40)
	se.scene.AddDrawable(se.name.Attach(ui.Middle, ui.Center))
	label := ui.NewText("Name:", 0, -18, 255, 255, 255).Attach(ui.Top, ui.Left)
	label.AttachTo(se.name)
	se.scene.AddDrawable(label)

	se.address = ui.NewTextBox(0, 40, 400, 40)
	se.scene.AddDrawable(se.address.Attach(ui.Middle, ui.Center))
	label = ui.NewText("Address:", 0, -18, 255, 255, 255).Attach(ui.Top, ui.Left)
	label.AttachTo(se.address)
	se.scene.AddDrawable(label)

	if index != -1 {
		server := Config.Servers[index]
		se.name.Update(server.Name)
		se.address.Update(server.Address)
	}

	return se
}