Start work on menu interactivity.

With this commit, we get a ui.Interface and ui.Widget type. The
interface monitors hover and mouse click state and tells the widgets
about them; the widgets execute code specified by the application when
events occur.

Next step: have wh40k load the main menu and play sound, etc.
This commit is contained in:
2020-03-22 02:58:52 +00:00
parent bcaf3d9b58
commit bfe9fbdf7d
12 changed files with 440 additions and 194 deletions

View File

@@ -69,7 +69,7 @@ func main() {
lastState: state,
}
win, err := ui.NewWindow("View Map " + *gameMap)
win, err := ui.NewWindow(env, "View Map "+*gameMap)
if err != nil {
log.Fatal("Couldn't create window: %v", err)
}
@@ -86,12 +86,12 @@ func main() {
win.OnKeyUp(ebiten.Key1+ebiten.Key(i), env.setZIdx(i+1))
}
if err := win.Run(env.Update, env.Draw); err != nil {
if err := win.Run(); err != nil {
log.Fatal(err)
}
}
func (e *env) Update() error {
func (e *env) Update(screenX, screenY int) error {
if e.step == 0 || e.lastState != e.state {
log.Printf("zoom=%.2f zIdx=%v camPos=%#v", e.state.zoom, e.state.zIdx, e.state.origin)
}