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:
@@ -71,7 +71,7 @@ func main() {
|
||||
}
|
||||
env := &env{gameMap: gameMap, set: mapSet, state: state, lastState: state}
|
||||
|
||||
win, err := ui.NewWindow("View Map " + *mapFile)
|
||||
win, err := ui.NewWindow(env, "View Map "+*mapFile)
|
||||
if err != nil {
|
||||
log.Fatal("Couldn't create window: %v", err)
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func main() {
|
||||
|
||||
win.OnMouseWheel(env.changeZoom)
|
||||
|
||||
if err := win.Run(env.Update, env.Draw); err != nil {
|
||||
if err := win.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func (e *env) changeZoom(_, y float64) {
|
||||
e.state.zoom *= math.Pow(1.2, y)
|
||||
}
|
||||
|
||||
func (e *env) Update() error {
|
||||
func (e *env) Update(screenX, screenY int) error {
|
||||
// TODO: show details of clicked-on cell in terminal
|
||||
|
||||
// Automatically cycle every 500ms when auto-update is on
|
||||
|
Reference in New Issue
Block a user