Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modern menu #701

Merged
merged 73 commits into from
Oct 3, 2024
Merged

Modern menu #701

merged 73 commits into from
Oct 3, 2024

Conversation

Malkierian
Copy link
Contributor

@Malkierian Malkierian commented Jun 20, 2024

This adds a new, more modern-styled menu to use instead of the menubar. The goal was to have it extensible, easier to navigate, and capable of holding a lot more enhancements. I think I accomplished that.

  • 3 buttons on the menu header for touch use (when porting to mobile platforms, for instance) for closing the menu, restarting the game, and quitting the program.
  • Virtually full size flexibility. Designed around 1280x800, but still functional down to around 400x200.
  • All normally extra windows start docked in the menu (for ease of use), but can be popped out to their normal windows.
  • The menu itself can be popped out instead of being an overlay, and as such can be docked (could use some refinement, though).
  • [Esc] is now the key used to bring it up instead of F1.
  • Menu retains its section and subsection selections, meaning you can open and close the menu to toggle an option quickly.
  • Menu retains its popped size and position when popped back in.

This also reimplements the gamepad navigation toggle from SoH (which works better in the new menu than on the menubar by several orders of magnitutde), and includes a new enhancement that forces the cursor to be visible even in full screen without the menu or menubar open.

Thanks to @Caladius, this also comes with a search function. It's setup to search widget names and tooltips, and displays each option's location in the rest of the menus.

Note to other devs: the LUS changes will need a bit of tweaking before being made a PR, so that it's not relying on 2ship settings and CVars directly, but is configurable and abstract.

image
image
image

Build Artifacts

@retropieuser
Copy link

This is fantastic work, I can finally play things like 2s2h (and hopefully soon soh) on my TV without needing a mouse and keyboard! Thanks for a great job on this

One small tidbit, right now when you have the menu open, pressing gamepad_back only hides the menu while the toggle btn is pressed down, when you let go the menu reappears. To close the menu you have to select the button on the GUI.

Can this be changed so when you press the toggle btn in the menu it closes it please?

@Malkierian
Copy link
Contributor Author

Malkierian commented Jul 10, 2024

It was specifically designed to do that, just like the menubar before it. I'm not experiencing what you're describing. In fact, if I hold the toggle button, it rapidly shows and hides it over and over again.

@retropieuser
Copy link

Ah yes maybe I didn't explain it well. if I hold the toggle button it rapidly turns off and on.

In terms of a user case though and what they're likely to do, just two suggestions:-

You could disable the toggle button when the menu is visible and re-enabling it when the menu isn't visible? So pressing it once brings up the menu and then you need to select close Menu inside the GUI?

Or you could have the toggle button always able to switch the menu from visible to invisible with a slight wait for presses so it doesn't happen too fast?

Just food for thought anyway. It's an awesome job all the same and thank you for working on it

Malkierian and others added 19 commits September 8, 2024 16:21
Basic audio section done. Needs subdividing for sane widget widths.
Add graphics settings to menu.
Parameterized menu height.
Tried to add button option for sidebar entries.
Sidebar window button still broken (can't reference window variables properly, not drawing in the right place).
Menu now pops out with a checkbox in Developer Tools.
Menu sizing works for smaller game sizes.
Popout docking disabled.
Port bool added for disallowing popout regardless of cvar.
Menu popout complete.
Menu popout position/size is retained when popped in.
Apply HUD editor changes, draw contents in menu if window is closed.
All child sizes properly calculated.
SidebarEntry drawing separated into its own custom element.
Header now dynamically sized and shows scrollbar when necessary.
Prevent menu from covering other windows (always in back).
…ept.

Change reset icon to FA_ICON_UNDO (single arrow) and quit icon to FA_ICON_POWER_OFF.
Add button to close menu button tooltip, add parentheses to button for reset tooltip.
Copy link
Contributor

@Archez Archez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok just a few more things (mainly around the new changes and some warning fixes)

mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
…en necessary. Check for `valuePointer` being nullptr, and preventing widget drawing with a debug assert and error log entry.

Remove all `has_variant` calls and wrap entire widget type switch in `SearchMenuGetItem` with a try/catch on `std::bad_variant_access` with another error log and debug assert.
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
mm/2s2h/BenGui/SearchableMenuItems.h Outdated Show resolved Hide resolved
Copy link
Contributor

@Archez Archez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience with the reviewing, I feel good with where this PR is at now. Once in, I'm sure we will get good feedback on further improvements we can make.

@garrettjoecox
Copy link
Contributor

garrettjoecox commented Sep 23, 2024

Idk what setting I had set, but I couldn't interact with the new menu until I deleted my JSON/Imgui.init files. Probably want to figure out what setting that is before we have to deal with it in support. Unable to reproduce unfortunately

Blocking:

  • There seems to be some weirdness regarding whether or not the menu shows up when you press your controller's dedicated button. When I open up the game, my controller's menu button doesn't do anything. If I then click ESC on my keyboard to open the menu, then "grab focus" with my controller by moving the dpad, and then navigate to and close the menu with the "Close Menu" button in the UI, my controller seems to retain focus, and then the menu button on my controller works to re-open the menu. Additionally, regardless of if the menu has focus or not, when it is open and I try to close it using my controller's menu button, it closes and re-opens.

Not blocking:

  • The icons within buttons are not vertically centered. I think this might have been an issue before, but with the larger font size it seems more exaggerated.
  • Volume sliders on audio page are wrong format
  • Some things in the wrong section or missing, eg 2 options under "time savers > dialog" don't belong, and warp point developer tool is missing
  • I know this is obvious, but the navigation buttons & search should use our themed widgets
  • We should just get rid of the "Press f1" popup all together, pressing your menu button or escape seems intuitive enough
  • When the search page is opened, the input should be auto focused
  • Menu.cpp/.h should both be under the BenGui/ folder
  • Not sure how I feel yet about the pattern in which we define menu items. Probably won't know how I feel until I have to work with it for a while.

What is the plan for the old Navbar? It's going to get annoying real quick to have to add UI stuff in two places

Pull values of those over from menubar.
Add documentation on `widgetOptions` for those and others added for previous review changes.
Move Fast Magic Arrow and Instant Fin Recall to Gameplay section.
@Malkierian
Copy link
Contributor Author

Malkierian commented Sep 23, 2024

For the major problem, it's going to require some investigation. As usual, what I was developing on, WASAPI, has no issues with the way things are. Those issues only show up with SDL as the window manager, and the fact that they're handled differently between the two annoys me to no end, but that's where they end up manifesting.

For the non-blocking stuff:

  1. I'm not even sure how to make that center. The problem seems to be that FA renders the icons at the text line floor, and I don't know if there's a way to change that.
  2. Easily enough handled.
  3. Yeah, the dialog things were supposed to go in Gameplay, I think. Not sure how that happened. And I knew I'd be missing some things XD
  4. The nav buttons are easy enough, but I don't think the search widget has a themed widget variant
  5. I can see the the prompt skip default to on, once we decide to yeet the navbar. The only reason it isn't is because I didn't know whether to yeet that in this PR or not. I figured people would want to have the option of it while getting used to the new menu.
  6. I'm really not sure how to give the search bar focus only on first draw when changing to the search tab...
  7. Also easily done
  8. Any suggestions for improvement in that flow will always be welcome. It's already gone through 4 or 5 iterations between what I originally did and what Cal did for the search menu, and then what I did to further extend what he did. This is very much still WIP, it's just functional so that more people can test it.

mckinlee pushed a commit to mckinlee/2ship2harkinian that referenced this pull request Sep 23, 2024
Make "Press F1" prompt show only when a menu isn't registered.
mckinlee added a commit to mckinlee/2ship2harkinian that referenced this pull request Sep 24, 2024
Copy link
Contributor

@garrettjoecox garrettjoecox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make an issue to track and detail the SDL thing

garrettjoecox and others added 2 commits September 23, 2024 21:30
…gs. Dynamically adds or removes the sidebar entry, and header search is toggled inversely.
@Malkierian
Copy link
Contributor Author

Let's make an issue to track and detail the SDL thing

Handled in Kenix3/libultraship#677

…close. Couldn't handle Alt+F4 without a hook I didn't want to add.

Remove unneeded commented code.
@Archez Archez mentioned this pull request Sep 26, 2024
31 tasks
@Archez Archez merged commit 71c2c94 into HarbourMasters:develop Oct 3, 2024
5 checks passed
@Malkierian Malkierian deleted the modern-menu branch October 3, 2024 04:29
mckinlee pushed a commit to mckinlee/2ship2harkinian that referenced this pull request Oct 4, 2024
* Start the framework.

* Start header bar.

* Header buttons now toggle. Sections show accordingly.
Basic audio section done. Needs subdividing for sane widget widths.

* Add fonts and multiple sizes.
Add graphics settings to menu.

* Finalized fonts, more sizes.

* Modularized the menu structure. Has an errant EndChild somewhere.

* Finished first step modularization.
Parameterized menu height.

* Some adaptive menu size.

* Moved all enhancements over and organized.
Tried to add button option for sidebar entries.

* Finished Enhancements Menu.
Sidebar window button still broken (can't reference window variables properly, not drawing in the right place).

* Developer Tools header started.
Menu now pops out with a checkbox in Developer Tools.
Menu sizing works for smaller game sizes.
Popout docking disabled.
Port bool added for disallowing popout regardless of cvar.

* Better auto-sizing. Columns collapse to 1 below 800 window width, and scroll.

* Move inside of HudEditorWindow::DrawElement to DrawContents, and call DrawContents from DrawElement.

* Menu resizability complete.
Menu popout complete.
Menu popout position/size is retained when popped in.
Apply HUD editor changes, draw contents in menu if window is closed.
All child sizes properly calculated.
SidebarEntry drawing separated into its own custom element.

* Split header entries into separate widget.
Header now dynamically sized and shows scrollbar when necessary.

* Modify EventLog to be drawable with the DrawContents setup.
Prevent menu from covering other windows (always in back).

* Add reset, close menu, and quit buttons to the header.

* Fix reset and quit button placement.

* Swap Actor Viewer, Collision Viewer, Save Editor to DrawContents concept.
Change reset icon to FA_ICON_UNDO (single arrow) and quit icon to FA_ICON_POWER_OFF.
Add button to close menu button tooltip, add parentheses to button for reset tooltip.

* Custom InputEditorWindow to work with menu.
Fix LUS references in Menu.cpp for Window backend changes.
Implement gamepad navigation and forced cursor visibility checkboxes.
Toggle cursor visibility according to menu status and forced visibility CVar.

* clang-format

* Swap std for fmt (runner build error).
Ensure cursor visibility is restored if started in full screen with the menu open.

* Oops, still had #include <format>

* Swap to LUS GetMenu() functionality.
Add option to hide "F1 to open enhancements menu" text at startup if menus aren't open.

* Remove last vestiges of pre-LUS-menu functionality.

* cleanup

* Adapt to GuiElement, GuiWindow changes on the menu support PR.

* LUS PR bump.
Adapt to cursor visibility changes in LUS.
Adapt to menu toggle changes in LUS.
Fix input editor not hiding in menu when popped out.

* Add new enhancements and cheats to Modern Menu from rebase.

* clang

* Apply Graphics Menu Lag Fix to Menu structure.

* Remove unnecessary window children to simplify controller navigation.

* clang

* Add `UpdateWindowBackendObjects()` call to backend combobox.

* Rebase to latest develop. Remove redundant window backend stuff that exists now in BenMenuBar.

* Search Enhancement (#2)

* 90% complete, Commit for review.

* Updated remaining Menu Entries, Reverted Backends and other Window Buttons for now.

Motion Blur copied to Search Menu.

* Did I mention I dislike this clang thing? lol

* Updating MotionBlur options and reverting soem things.

* Integrates .disabled and .disabledTooltip to the constructors. Allows for multiple qualifications to be checked against for disabling widgets and for setting the tooltip accordingly.

* Updated Disabled Reasoning

* Better Disabled State registration system

* Clean up from testing

* Expand WidgetOptions to be able to handle string and float values. bool and uint32_t are handled through int32_t.
Numerous renames.
Added several data structures to allow for dynamic updating of CVars for DisableOptions, as well as dynamic evaluation of status with enumerated conditions (less than, greater than, equal to).
Added menuThemeIndex variable to store state of menu theme selection instead of having all the individual calls to CVarGetInteger for it. Updated once per frame.

* Changed color vector to map with enum as key and UIWidget::Colors as the value.
More renames.
Moved float slider values into case block.

* Add Color_RGB8 and Color_RGBA8 to CVarVariant in preparation for adding color widgets to menu item system.
Not happy it required comparison operator overrides, but it is what it is.

* Changed disable conditions to lambdas.

* Convert Stats and Collision Viewer to menu item system.
Swap out DisableOption vector for activeDisables and a lambda function for evaluating disabled and hidden. Set the precedent to still use the DisableInfo system.

* Add DisableOption for both camera settings being off.
Put Debug Camera in Free Look column, disable common widgets for both cameras, hide widgets specific to either if off.

* Moved more widgets to MenuItem system. Some need proper initialization routines because of Ship::Context references.

* Convert menu items to nested vector setup.
Remove MenuItem enum.
Add menu item location display to search results.

* Partial removal of SidebarEntryIndex enum.

* Finish removing SidebarEntryIndex.
Rework drawing code to handle the change back to direct vector access.
Add tooltips to search.

* Fix Graphics enhancements section title.

* Copy added menu items to modern menu system.

* clang

* Add some documentation for the menu system components.

* Revert change to std::map

* `size_t` because GCC has to be happy

* Fixed HUD Editor Widescreen mode not displaying the sliders properly.
Changed all windows to full-section-width display.

* Revert changes to MotionBlur.cpp

* Add non-CVar variants of checkbox, combobox, and the sliders.
Fix motion blur functionality with new non-CVar widgets.

* Add non-CVar variants of checkbox, combobox, and the sliders.
Fix motion blur functionality with those non-CVar widgets.
Add size and labelPosition to widgetOptions, implemented on button and checkbox/combobox/sliders.
Change window popout buttons to inline size type.

* Rename SearchMenu.h to SearchableMenuItems.h and move to BenGui folder.

* Forgot to change the include XD

* Change `modifierFunc` to `preFunc`, updated documentation for that and including `postFunc`.

* Modify code to require variable for non-CVar widget initialization when necessary. Check for `valuePointer` being nullptr, and preventing widget drawing with a debug assert and error log entry.
Remove all `has_variant` calls and wrap entire widget type switch in `SearchMenuGetItem` with a try/catch on `std::bad_variant_access` with another error log and debug assert.

* More review changes.

* Implement `isPercentage`, `format`, and `showButtons` for sliders.
Pull values of those over from menubar.
Add documentation on `widgetOptions` for those and others added for previous review changes.
Move Fast Magic Arrow and Instant Fin Recall to Gameplay section.

* Modify header and sidebar "buttons" to match theming of regular buttons.

* Add precision clamping to SliderFloat value. At least 1.0 seems to be consistent at "100%".
Change IR slider to be percentage.

* Mention weirdness with SDL and pad menu button in controller nav tooltip.

* Move Menu files to 2s2h/BenGui.

* Add Warp Points to Developer Tools.
Make "Press F1" prompt show only when a menu isn't registered.

* clang

* Make search input take focus when search menu is open.

* Forgot include.

* Global search (HarbourMasters#3)

* Restore Sidebar search entry, but lock it behind a checkbox in Settings. Dynamically adds or removes the sidebar entry, and header search is toggled inversely.

* Make menu toggle its visibility when using the button in the menu to close. Couldn't handle Alt+F4 without a hook I didn't want to add.
Remove unneeded commented code.

---------

Co-authored-by: Caladius <[email protected]>
Co-authored-by: Garrett Cox <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants