RimWorld

RimWorld

567 ratings
Float Sub-Menus
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.3, 1.4, 1.5
File Size
Posted
Updated
949.574 KB
Sep 17, 2022 @ 2:37am
May 3, 2024 @ 5:23pm
13 Change Notes ( view )

Subscribe to download
Float Sub-Menus

Description
Adds support for having sub-menus in float menus.
Update: Now also includes a search field and divider bar for float menus.

This is intended as a library mod, allowing any mod developer to add sub-menus to their float menus.

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, that does not mean that it is related to this mod. They are from vanilla, and you need to look further down in the error message. Only it the error mentions FloatSubMenu, FloatMenuSearch or FloatMenuFilter does it point to having anything to do with this mod.

For mod developers
Sub menus
Add an instance of the FloatSubMenu class in the list of FloatMenuOptions when creating a FloatMenu, and that option will open up a sub-menu when the mouse enters it. They can also be nested, by adding it to the list of options for another FloatSubMenu.

Search field
To add a quick search field that filters the menu items on the label, add an instance of the FloatMenuSearch class in the list of FloatMenuOptions when creating a FloatMenu. The constructor takes a bool, with true meaning that it does a tree search down into any sub-menus and false meaning that it only filters based on items at the same level.

Menu divider
To add menu dividers, add an instance of the FloatMenuDivider class in the list of FloatMenuOptions. The constructor takes an optional label string.

If you use the mod, please drop a comment - I would love to see what you have done with it. :)

Compatibility
The FloatSubMenu class has static factory methods that create either a FloatSubMenu or a normal FloatMenuOption that opens the sub menu when selected, depending on if any incompatible mods are loaded.
Use the CompatMMMCreate when adding sub-menus to the menu created by FloatMenuMakerMap, and CompatCreate otherwise.

Vanilla UI Expanded
Currently does not play nice with Vanilla UI Expanded in 1.3. I have contributed code to VUIE, and the maintainer has said they will incorporate it in their next update. Unfortunately that update will take a while. Since it won't be updated to 1.4 before that, it should be fairly future-proof to use this mod in 1.4.
The specific issues are that using dialog for menus does not work for menus using sub-menus, and the menu option to switch to dialog mode can appear multiple times in sub-menus.

For 1.3, I for now suggest detecting if VUIE is active, and falling back to opening a second menu instead if it is.
For 1.4, there should not be a problem.
Using the factory methods gives this behavior.

Achtung!
Achtung rewites the float menu shown when right-clicking on something on the map in a way that is not compatible with Float Sub-Menus. It should be compatible when used in other menus, though.

When adding menu items to the map right-click menu (the one generated by FloatMenuMakerMap), I suggest detecting if Achtung! is active, and falling back to opening a second menu instead if it is.
Using the (CompatMMMCreate variants of) the factory methods gives this behavior.

RimWorld 1.4
The constructors of the FloatMenuOption class have changed a little in 1.4. I have tried to make it compatible in way that lets the same source code using FloatSubMenu work for both 1.3 & 1.4. The arguments that were added in 1.4 can be passed in the 1.3 version, but will not have any effect.

Source
Source code at Github[github.com]
It is under a BSD license, so feel free to grab the source code if you prefer that to adding a dependency. Do note that if you do that, the compatibility issues with VUIE will not be resolved for you as it stands now. I could not figure out a way to make them compatible from my end that did not require invasive patching into VUIE. The plan is instead to contribute code to VUIE to add compatibility with this mod from there.
33 Comments
Kathanon  [author] Apr 6 @ 1:19am 
Thank you.
Kathanon  [author] Apr 3 @ 4:41am 
What was the other mod?
Snuggy Apr 3 @ 12:43am 
Yeah I posted it on both because I wasn't sure:)
Kathanon  [author] Apr 2 @ 12:23pm 
I think you are mistaken about which mod does that. This one is basically a UI library for other mods.
Snuggy Apr 1 @ 11:35pm 
This mod seems to be able to let you build things you do not have researched if other items in the category are normally behind the inital item.

For example, if you start out as a tribe and you can only build slab beds, instead of it just showing "slab bed" and no sub menu item, it show normal beds and then when you click on it to select what you want to build it offers only slab bed.

However if you just dont click slab bed and click to build, you will be able to build normal beds.

Hopefully i made that explanation as straightforward as possible. Ty and love the mod.
Stalinator9000 Mar 25 @ 7:51am 
Normally I am more of a dom-menu kinda guy but for this I can make an exception.
룰루랄라 Mar 16 @ 7:37am 
I never would've guessed it was you!
룰루랄라 Mar 16 @ 7:01am 
I discovered that there's a mod called "More Gene Information" that actually uses this mod.
Translated into Chat GPT, there may be some strange expressions.
Kathanon  [author] Jul 24, 2024 @ 8:51pm 
A bunch of my mods, and I have no idea if anyone else has used it in their mods.