This widget automatically nests large buildmenus for builders (not factories; use the buildbars widget for that). It's not perfect, but I think I'm done adding features for the time being, so here it is.
Changelog:
v1.4
Hopefully fixed tooltip background for real.
v1.2
Hack to get around broken gl.GetTextWidth. Tooltips should have properly-sized backgrounds now.
v1.0
After using it a few games, it seems to be stable.
Now starts in Econ category.
v0.17
Fixed frames for non-nested menus.
v0.16
Now remembers your previously selected category.
v0.15
No longer presses keys when hidden.
v0.14
Added uselists command to toggle the use of display lists. For some reason keyboard + display lists causes icons to appear all white.
v0.13
First forum release.
Features:
- Automatically divides buildoptions into nine categories: Econ, Fac, Aux, Def, Strat, Fort, Sensor, Mobile, and Misc.
- You can move it by dragging it when no builders are selected. You can also use /luaui nested_buildmenu_[command] to customize it: size for size (default 64), cols for number of columns (default 3), cancelonly (default false) to toggle whether to return to the main menu automatically after selecting a buildoption, and uselists (default false) to toggle whether display lists are used (better performance, but susceptible to a bug--see below).
- You can bind /luaui nested_buildmenu_press [number] to press buildmenu icons using the keyboard. It is numbered like a telephone (at least an American telephone; I'm not sure if any other countries use a different convention), starting at 1 and going left to right, top to bottom.
- Highlighting and tooltips at mouse pointer with the name, description, and cost of the buildoption.
- Optional frames (only works if buildicons are transparent at edges). Put your frame textures in LuaUI/Images/nested_buildmenu/frame_[category].png. You must also have a frame_Cancel.png in that category if you want frames.
- Although originally designed for CA, it works with all mods (granted, generally only *As have enough buildoptions for this to be much of a benefit.
- If there are 12 or less buildoptions it displays them directly; if a category only has one buildoption it is displayed on the main menu directly; if a category has no build options the label is blacked out.
Caveats:
- Known Issue: Sometimes the icons get drawn as blank white. Trying to track this down. Strangely it only happens when the keyboard is used to press icons and display lists are in use. Even stranger, it stays wrong even if you disable display lists while Spring is running, or disable and reenable the widget (changing the option and restarting Spring works though). Either there is a serious flaw in my GL knowledge, or my computer is being stupid.
- You can make suggestions, but don't count on me implementing them. In fact, I probably will not, as serving GUI requests is generally a good way of spending a lot of time without satisfying many people. Sorry :p
- It is very possible that the widget is still buggy.
If you want frames you can use CA's frames: http://trac.caspring.org/browser/trunk/ ... _buildmenu
What to put in uikeys.txt to bind the first 9 icons to the numpad:
Code: Select all
bind numpad7 luaui nested_buildmenu_press 1
bind numpad8 luaui nested_buildmenu_press 2
bind numpad9 luaui nested_buildmenu_press 3
bind numpad4 luaui nested_buildmenu_press 4
bind numpad5 luaui nested_buildmenu_press 5
bind numpad6 luaui nested_buildmenu_press 6
bind numpad1 luaui nested_buildmenu_press 7
bind numpad2 luaui nested_buildmenu_press 8
bind numpad3 luaui nested_buildmenu_press 9
As with all of my widgets, several of the major config variables are at the top.
Sorting is done automatically using unit tags, so it should do something reasonable in most mods.
While the names of the categories are hardcoded, the number is not--you can edit BUILD_CATEGORIES (which defines the names) without fear, although you will have to edit SetupBuildCategories() for the automatic sorting to actually use it.
Units with customparams.buildcategory will use that as their build category. (Although if the buildcategory is not in BUILD_CATEGORIES this will probably cause a crash... I should fix that.)
Units are ranked by cost, then by (human) name. Units with customparams.sortname will use that instead of their human name.