Nested Buildmenu v1.4

Nested Buildmenu v1.4

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Nested Buildmenu v1.4

Post by Evil4Zerggin »

Nested Buildmenu

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.
Images:
Image

Image

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.
Get it from caspring here: http://trac.caspring.org/browser/trunk/ ... ldmenu.lua

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
Dev Notes
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.
Last edited by Evil4Zerggin on 22 Jan 2009, 09:24, edited 9 times in total.
User avatar
Hoi
Posts: 2917
Joined: 13 May 2008, 16:51

Re: Nested Buildmenu v0.15

Post by Hoi »

Win.
Ashnal
Posts: 104
Joined: 24 Jun 2008, 00:57

Re: Nested Buildmenu v0.15

Post by Ashnal »

This is really cool zerg.

I do think it should have an option to include build menus for factories, since some of us dislike build bar, and would like this to replace the engine build list.

Also, I would like some way to get the move menu box thing to disapear when builders and factories aren't selected like the current build menu.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Nested Buildmenu v0.15

Post by CarRepairer »

Yeah I hate buildbar.

Also I recommend you change the /luaui nested_buildmenu_press [number] to follow keypad layout instead of telephone layout, and then we can copypaste this into our keybindings instead, which looks a little less weird. But no biggie.

Code: Select all

bind numpad1 luaui nested_buildmenu_press 1
bind numpad2 luaui nested_buildmenu_press 2
bind numpad3 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 numpad7 luaui nested_buildmenu_press 7
bind numpad8 luaui nested_buildmenu_press 8
bind numpad9 luaui nested_buildmenu_press 9
Great work!
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: Nested Buildmenu v0.15

Post by Evil4Zerggin »

While it's unfortunate that the icon numbers don't match the keypad, there's a few reasons I did it this way. First, it matches the internal fill order. Second, the number of icons can go above 9 for a large category--if I used keypad order I would have to use negative icon numbers. Third, you can change the number of columns, in which case keypad order doesn't really work. (In this case it doesn't have the same number of columns as a telephone either, but it still has the benefit of following the internal fill order.)

I may integrate something with the functionality of buildbar, but not soon. I haven't actually used buildbar, only heard about it :s
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Nested Buildmenu v0.15

Post by CarRepairer »

I see now, that makes sense. Perhaps if we finally get IceUI working in CA then it can be customized in the same way as the standard buildmenu - set number of columns, move and resize however you choose.
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Nested Buildmenu v0.15

Post by Licho »

How do you plan to eventually integrate wtih normal buildmenu? Hide stuff displayed by nested menus from normal buildbar or totally replace it including commands?
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Nested Buildmenu v0.15

Post by Licho »

You can paste this car
bind Alt+q luaui nested_buildmenu_press 1
bind Alt+w luaui nested_buildmenu_press 2
bind Alt+e luaui nested_buildmenu_press 3
bind Alt+a luaui nested_buildmenu_press 4
bind Alt+s luaui nested_buildmenu_press 5
bind Alt+d luaui nested_buildmenu_press 6
bind Alt+z luaui nested_buildmenu_press 7
bind Alt+x luaui nested_buildmenu_press 8
bind Alt+c luaui nested_buildmenu_press 9
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: Nested Buildmenu v0.15

Post by Evil4Zerggin »

Licho wrote:How do you plan to eventually integrate wtih normal buildmenu? Hide stuff displayed by nested menus from normal buildbar or totally replace it including commands?
My current plan is to put all building commands (probably including factories) in one widget, and all other commands in another, and not use the default menu at all. However, this is long term and very subject to change/suggestions. No doubt I'll run into some misconception about how commands work too :p
Post Reply

Return to “Lua Scripts”