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:
@@ -51,11 +51,6 @@ func main() {
|
||||
log.Fatalf("Couldn't load set %s: %v", *setName, err)
|
||||
}
|
||||
|
||||
win, err := ui.NewWindow("View Set: " + *setName)
|
||||
if err != nil {
|
||||
log.Fatal("Couldn't create window: %v", err)
|
||||
}
|
||||
|
||||
state := state{zoom: 8.0}
|
||||
env := &env{
|
||||
set: set,
|
||||
@@ -63,6 +58,11 @@ func main() {
|
||||
lastState: state,
|
||||
}
|
||||
|
||||
win, err := ui.NewWindow(env, "View Set: "+*setName)
|
||||
if err != nil {
|
||||
log.Fatal("Couldn't create window: %v", err)
|
||||
}
|
||||
|
||||
win.OnKeyUp(ebiten.KeyLeft, env.changeObjIdx(-1))
|
||||
win.OnKeyUp(ebiten.KeyRight, env.changeObjIdx(+1))
|
||||
|
||||
@@ -72,12 +72,12 @@ func main() {
|
||||
win.OnMouseWheel(env.changeZoom)
|
||||
|
||||
// Main thread now belongs to ebiten
|
||||
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 {
|
||||
curObj, err := e.curObject()
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user