The Float Sub-Menus Mod adds support for sub-menus in float menus, providing enhanced menu organization options for mod developers.
Update: The Float Sub-Menus Mod now includes a search field and divider bar for float menus.
This mod is designed as a library mod, allowing any mod developer to add sub-menus to their float menus.
Float Sub-Menus Mod Features
For Players
You only need this mod if another mod has a dependency on it.
If You Get Errors
If an error in the log mentions FloatMenu, FloatMenuOption, or FloatMenuMakerMap, it is not related to this mod, as those are from vanilla. Only if the error mentions FloatSubMenu, FloatMenuSearch, or FloatMenuFilter does it relate to this mod.
For Mod Developers
Sub-Menus
Add an instance of the FloatSubMenu class to the list of FloatMenuOptions when creating a FloatMenu, and that option will open a sub-menu when the mouse enters it. Sub-menus can also be nested by adding them to the list of options for another FloatSubMenu.
Search Field
To add a quick search field that filters menu items by label, add an instance of the FloatMenuSearch class to the list of FloatMenuOptions when creating a FloatMenu. The constructor takes a boolean: `true` for a tree search down into any sub-menus, and `false` for filtering only items at the same level.
Menu Divider
To add menu dividers, add an instance of the FloatMenuDivider class to the list of FloatMenuOptions. The constructor takes an optional label string.
*If you use this mod, please leave a comment – I’d love to see what you do with it!*
Compatibility notes
The FloatSubMenu class includes static factory methods that create either a FloatSubMenu or a standard FloatMenuOption, depending on whether incompatible mods are loaded.
Vanilla UI Expanded
Currently, Float Sub-Menus do not work seamlessly with **Vanilla UI Expanded** in version 1.3. Code contributions have been submitted to VUIE, and future updates are expected to include this compatibility fix, which should also ensure functionality in RimWorld 1.4.
In version 1.3, mod developers may detect if VUIE is active and default to opening a second menu instead. For version 1.4, there should be no compatibility issues. Using the factory methods provides this fallback behavior.
Achtung!
Achtung rewrites the float menu shown when right-clicking on the map in an incompatible way with Float Sub-Menus. It remains compatible in other menus.
To add menu items to the map right-click menu, detect if Achtung! is active and default to opening a second menu if so. Using the CompatMMMCreate variants of the factory methods provides this fallback behavior.
RimWorld 1.4
The constructors of the FloatMenuOption class have changed in RimWorld 1.4. The Float Sub-Menus Mod has been adapted to support both versions 1.3 and 1.4, with compatibility adjustments that allow for consistent use across both versions.
Source
Source code is available at Github under a BSD license. Feel free to use the source code directly, though compatibility issues with VUIE will remain unresolved unless updated within VUIE itself.