边缘世界 RimWorld

边缘世界 RimWorld

717 个评价
Float Sub-Menus
2
2
   
奖励
收藏
已收藏
取消收藏
Mod, 1.3, 1.4, 1.5, 1.6
文件大小
发表于
更新日期
1.031 MB
2022 年 9 月 17 日 上午 2:37
7 月 20 日 下午 4:28
16 项改动说明 ( 查看 )

订阅以下载
Float Sub-Menus

描述
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.

Compatibility
No known incompatibilities.

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 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.
52 条留言
Kathanon  [作者] 9 月 16 日 下午 10:38 
I have. That has nothing to do with this mod. Good luck with your problem, and sorry I can't help you.
Nik.rul 9 月 16 日 下午 10:10 
Created a issue on GitHub, please take a look. :machiko:
kongkim 8 月 11 日 下午 3:50 
Okay, thx, and sorry, it's always just annoying doing bug hunt :)
Kathanon  [作者] 8 月 11 日 下午 3:47 
Please read the "If you get errors" part of the description above.
kongkim 8 月 11 日 下午 3:44 
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  [作者] 8 月 11 日 下午 3:40 
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 8 月 11 日 下午 3:36 
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  [作者] 8 月 11 日 下午 3:33 
Looks to me like it works fine. What is the problem?
kongkim 8 月 11 日 下午 3:01 
Is it possible to make this work with Show Buildable Material Count?

https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=3245101540
Kathanon  [作者] 8 月 9 日 上午 12:24 
No