smcameron / space-nerds-in-space

Multi-player spaceship bridge simulator game. Captain your starship through adventures with your friends. See https://smcameron.github.io/space-nerds-in-space
GNU General Public License v2.0
729 stars 73 forks source link

Pull down menu on demon screen doesn't work when console is active #311

Closed smcameron closed 2 years ago

smcameron commented 2 years ago

If you activate the console on the demon screen, you can no longer select items on the pull down menus. The menus activate and are visible, but you can't select anything. This is probably due to the order things are added to the ui element list. If the console is added after, it will intercept the mouse clicks and steal them from the menu (at least that's my current theory).

smcameron commented 2 years ago

Ok. We've got a problem. Made the following (uncommitted) change:

-       ui_add_text_window(demon_ui.console, DISPLAYMODE_DEMON);
-       ui_add_pull_down_menu(demon_ui.menu, DISPLAYMODE_DEMON); /* needs to be last */
+       ui_add_pull_down_menu(demon_ui.menu, DISPLAYMODE_DEMON);
+       ui_add_text_window(demon_ui.console, DISPLAYMODE_DEMON); /* needs to be last */

That is, I swapped the order that the console and the pull down menu were added to ui element list. See that "needs to be last" comment that was on the pull down menu? The reason it needed to be last is so that the pull down menu would get drawn last -- over the top of the console, and everything else. This change causes the pull down menu to be drawn underneath the console -- though it does allow things on the menu to actually be selected. The mouse events get eaten by the first element encountered in the ui list which contains the current mouse position. So, now I think the bug is, the mouse events should be given instead to the last element in the ui list containing the mouse coords.

smcameron commented 2 years ago

Ok, should be fixed by