diff --git a/gui.go b/gui.go index 7409b54..fe5dbb6 100644 --- a/gui.go +++ b/gui.go @@ -3905,12 +3905,14 @@ type Tooltip struct { SpawnStart Point Displaying bool Text string + Visible bool } func NewTooltip(text string) *Tooltip { tt := &Tooltip{ - Button: NewIconButton(0, 0, &sdl.Rect{240, 352, 32, 32}, globals.GUITexture, false, nil), - Text: text, + Button: NewIconButton(0, 0, &sdl.Rect{240, 352, 32, 32}, globals.GUITexture, false, nil), + Text: text, + Visible: true, } tt.Button.Tint = ColorWhite tt.Button.OnPressed = func() { @@ -3921,6 +3923,9 @@ func NewTooltip(text string) *Tooltip { } func (tt *Tooltip) Update() { + if !tt.Visible { + return + } tt.Button.Update() if globals.Mouse.Button(sdl.BUTTON_LEFT).Pressed() && !globals.Mouse.RawPosition().Inside(tt.Button.Rect) { tt.Displaying = false @@ -3932,6 +3937,9 @@ func (tt *Tooltip) Update() { } func (tt *Tooltip) Draw() { + if !tt.Visible { + return + } tt.Button.Draw() } diff --git a/main.go b/main.go index 10e0d41..694dea8 100644 --- a/main.go +++ b/main.go @@ -2351,6 +2351,21 @@ of images can be.`)) input.OnUpdate = func() { + for _, a := range globals.Keybindings.ShortcutsInOrder { + shortcut := input.FindElement("keyConflict-"+a.Name, false).(*Tooltip) + shortcut.Visible = false + shortcut.Text = "The following shortcuts share key combos:\n" + for _, b := range globals.Keybindings.ShortcutsInOrder { + if a == b { + continue + } + if a.KeysToString() == b.KeysToString() { + shortcut.Visible = true + shortcut.Text += "\n + " + b.Name + } + } + } + globals.Keybindings.On = false if rebindingKey != nil { @@ -2503,6 +2518,9 @@ where the cursor is over the window.`)) row = input.AddRow(AlignCenter) row.AlternateBGColor = true + tooltip := NewTooltip("The following shortcuts share key combos:") + row.Add("keyConflict-"+shortcut.Name, tooltip) + shortcutName := NewLabel(shortcut.Name, nil, false, AlignLeft) row.Add("key-"+shortcut.Name, shortcutName) @@ -2525,7 +2543,9 @@ where the cursor is over the window.`)) row.Add(shortcut.Name+"-d", button) - row.ExpandElementSet.SelectAll() + row.ExpandElementSet.Select(shortcutName, redefineButton, button) + + // row.ExpandElementSet.SelectAll() } about := settings.AddPage("about")