[b]Adds support for having sub-menus in float menus.[/b]
Also includes a search field, divider bar, and some other useful elements 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.
Compatibility
No known incompatibilities.
If you get errors
If an error in the log mentions [i]FloatMenu[/i], [i]FloatMenuOption[/i] or [i]FloatMenuMakerMap[/i], that does [b]not[/b] 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 [i]Float[b]Sub[/b]Menu[/i], [i]FloatMenu[b]Search[/b][/i] or [i]FloatMenu[b]Filter[/b][/i] does it point to having anything to do with this mod.
For mod developers
Dependency vs Copying DLL
I urge you to add a dependency to this mod rather than copying the DLL into your own mod, as copying can cause issues when using several mods that have copied different versions of the DLL. I am careful not to break backwards compatibility.
If you despite this choose to copy the DLL, [i]please[/i] add kathanon.FloatSubMenu to the loadAfter element of your About.xml. This will avoid any such problems as long this mod is in the mod list, by making sure that the copied DLL is only used if this mod is not present.
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.
[i]If you use the mod, please drop a comment - I would love to see what you have done with it.[/i] :)
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 CompatMMMCreate when adding sub-menus to the menu created by FloatMenuMakerMap, and CompatCreate otherwise.
[b]Achtung![/b]
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
[url=https://steamcommunity.com/linkfilter/?u=https%3A%2F%2Fgithub.com%2Fkathanon%2FRimWorld-FloatSubMenu]Source code at Github[/url][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.