RimWorld

RimWorld

683 ratings
Float Sub-Menus
2
2
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.3, 1.4, 1.5, 1.6
File Size
Posted
Updated
1.031 MB
17 Sep, 2022 @ 2:37am
20 Jul @ 4:28pm
16 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 if 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 known incompatible mods are loaded.
Use the CompatMMMCreate when adding sub-menus to the menu created by FloatMenuMakerMap, and CompatCreate otherwise.

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.

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. I am working on expanding this into a general UI library, so there are already more than the float menus, and I am actively adding more.
50 Comments
kongkim 11 Aug @ 3:50pm 
Okay, thx, and sorry, it's always just annoying doing bug hunt :)
Kathanon  [author] 11 Aug @ 3:47pm 
Please read the "If you get errors" part of the description above.
kongkim 11 Aug @ 3:44pm 
Yah, maybe its not this mod at all.

I know its a long mod list.
https://gist.github.com/HugsLibRecordKeeper/de3e28726a90f00e1f924cc44c37121b

But i get some errors at the end, about MaterialSubMenu.Patcher and this is the only mod that i have about Sub-Menu.
But again it may be another mod that patch something.
It just happens every time i try to build some walls.
Kathanon  [author] 11 Aug @ 3:40pm 
I think you have misunderstood what that mod does. It only adds the count to the popups when you choose the material for a building that can be built out of different things, like a wall.
kongkim 11 Aug @ 3:36pm 
Ohh mabe i was too fast then, still bug hunting. just have a lot of sub menus what do not show the Material Count.
Kathanon  [author] 11 Aug @ 3:33pm 
Looks to me like it works fine. What is the problem?
kongkim 11 Aug @ 3:01pm 
Is it possible to make this work with Show Buildable Material Count?

https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=3245101540
Kathanon  [author] 9 Aug @ 12:24am 
No
Jet 8 Aug @ 5:27pm 
https://gist.github.com/HugsLibRecordKeeper/ae5556afa4723aff6ffaba27ccbca700

XML error: 0.5~0.9 doesn't correspond to any field in type FloatRange. Context: <visualSizeRange><max>1.00</max>0.5~0.9</visualSizeRange>
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Log.Error_Patch1 (string)
Verse.XmlToObjectUtils:DoFieldSearch (System.Type,System.Xml.XmlNode,System.Xml.XmlNode)
Verse.DirectXmlToObjectNew:ResolveFieldForNode (System.Type,System.Xml.XmlNode,System.Xml.XmlNode)

is this from the mod?
Kathanon  [author] 12 Jul @ 8:24am 
Update:
- Fixed "FloatSubMenu is a namespace but is used as a type" error on building dependent mod.