Window Focus Bugfixes

* Fix the Doodad Dropper and Registration windows not stealing the focus
  when they are opened via menu bars.
* Bugfixes in gamepad support: stop at the first controller found,
  Draw() to handle controllers going away and hide the mouse cursor
This commit is contained in:
Noah 2022-02-19 20:20:58 -08:00
parent 4de0126b19
commit 0fc046250e
5 changed files with 7 additions and 4 deletions

View File

@ -427,7 +427,7 @@ func (s *EditorScene) Loop(d *Doodle, ev *event.State) error {
s.UI.Canvas.Tool = drawtool.EraserTool s.UI.Canvas.Tool = drawtool.EraserTool
s.UI.activeTool = s.UI.Canvas.Tool.String() s.UI.activeTool = s.UI.Canvas.Tool.String()
} else if keybind.DoodadDropper(ev) { } else if keybind.DoodadDropper(ev) {
s.UI.doodadWindow.Show() s.UI.OpenDoodadDropper()
} }
s.UI.Loop(ev) s.UI.Loop(ev)

View File

@ -246,7 +246,7 @@ func (u *EditorUI) SetupMenuBar(d *Doodle) *ui.MenuBar {
if u.Scene.DrawingType == enum.LevelDrawing { if u.Scene.DrawingType == enum.LevelDrawing {
toolMenu.AddItemAccel("Doodads", "q", func() { toolMenu.AddItemAccel("Doodads", "q", func() {
log.Info("Open the DoodadDropper") log.Info("Open the DoodadDropper")
u.doodadWindow.Show() u.OpenDoodadDropper()
}) })
toolMenu.AddItem("Link Tool", func() { toolMenu.AddItem("Link Tool", func() {
u.Canvas.Tool = drawtool.LinkTool u.Canvas.Tool = drawtool.LinkTool
@ -267,6 +267,7 @@ func (u *EditorUI) SetupMenuBar(d *Doodle) *ui.MenuBar {
} }
helpMenu.AddItem(registerText, func() { helpMenu.AddItem(registerText, func() {
u.licenseWindow.Show() u.licenseWindow.Show()
u.Supervisor.FocusWindow(u.licenseWindow)
}) })
menu.Supervise(u.Supervisor) menu.Supervise(u.Supervisor)

View File

@ -46,6 +46,7 @@ func (u *EditorUI) OpenDoodadDropper() {
// NOTE: most places in the code call this directly, nice // NOTE: most places in the code call this directly, nice
// and simple window :) but OpenDoodadDropper() added for consistency. // and simple window :) but OpenDoodadDropper() added for consistency.
u.doodadWindow.Show() u.doodadWindow.Show()
u.Supervisor.FocusWindow(u.doodadWindow)
} }
// OpenPublishWindow opens the Publisher window. // OpenPublishWindow opens the Publisher window.

View File

@ -110,7 +110,7 @@ func (u *EditorUI) SetupToolbar(d *Doodle) *ui.Frame {
Style: &balance.ButtonBabyBlue, Style: &balance.ButtonBabyBlue,
Click: func() { Click: func() {
u.Canvas.Tool = drawtool.ActorTool u.Canvas.Tool = drawtool.ActorTool
u.doodadWindow.Show() u.OpenDoodadDropper()
d.Flash("Actor Tool selected. Drag a Doodad from the drawer into your level.") d.Flash("Actor Tool selected. Drag a Doodad from the drawer into your level.")
}, },
}, },

View File

@ -126,6 +126,7 @@ func Loop(ev *event.State) {
for idx, ctrl := range ev.Controllers { for idx, ctrl := range ev.Controllers {
SetControllerIndex(idx) SetControllerIndex(idx)
log.Info("gamepad: using controller #%d (%s) as Player 1", idx, ctrl) log.Info("gamepad: using controller #%d (%s) as Player 1", idx, ctrl)
break
} }
} else { } else {
return return
@ -377,7 +378,7 @@ func Loop(ev *event.State) {
// Draw the cursor on screen if the game controller is emulating a mouse. // Draw the cursor on screen if the game controller is emulating a mouse.
func Draw(e render.Engine) { func Draw(e render.Engine) {
if p1mode != MouseMode || !cursorVisible { if playerOne == nil || p1mode != MouseMode || !cursorVisible {
return return
} }