|
|
|
Requires patches:
exclusivehudmodules
guicvarutils
hudscale
Overview
- udmenus are defined using cvars following a specific naming convention.
- udmenus are invoked using the udmenu console command.
- Only one udmenu may be displayed at a time (in fact, there is only one),
however you can fake hierarchical menus with simple scripting.
Text in <brackets> represent something you are expected to fill in. Do not
include the brackets.
Invoking udmenus
udmenus are invoked with the client console command:
udmenu <MENUNAME>
Where MENUNAME is the name of a menu defined as described below.
This can be bound to a key, like any other console command, using:
bind X "udmenu blah"
If the name is missing, or the specified menu is not valid, any open udmenus
are dismissed
If the named menu is already open, it is dismissed.
If any other menu-like things (the fireteam menu, quickchat, weapon select
menu etc) are open, they will be dismissed if a udmenu is invoked. Likewise,
if any of these things are invoked while a udmenu is active, the udmenu will
be dismissed. If you want to be able to select weapons while a udmenu is
open, you must set g_weaponSwitchTimout to 0. If you do not do this, the
weapon menu is brought up when you press a weapon key.
Defining udmenus
Cvars describing a menu are named starting with "udmenu_<MENUNAME>_"
A menu with name MENUNAME is defined by if it has a 1st item.
A menu has as many items as are defined sequentially starting from 1. If you
define items 1, 2 and 4, only 1 and 2 will be displayed. If you only define 4,
the menu will be empty.
Menu items are defined by cvars named as follows:
udmenu_<MENUNAME>_<N> "<NAME>:<COMMANDS>"
N is an integer from 1 through 12, specifying the item number.
NAME is an optional string of plain text to be displayed for that menu item
It must not include a ":". It may include color escapes, although yellow should
be avoided if you use default items (described later)
If NAME is empty:
- The ":" may be omitted unless the command needs to contain one.
- The command text is used for the name, truncated if necessary.
COMMANDS is a required string of console commands. For complex actions, the
command can include ; exec $foo vstr and so on.
A menu can invoke another menu by using the udmenu command in an item.
Invoking the currently active menu will update it to reflect any changes to
it's cvars.
A minimal menu is defined with a single cvar, specifying it's first item.
example:
set udmenu_mymenu_1 "addchatline 'hello world'"
bind x "udmenu mymenu"
Several additional cvars can be used to configure a menu:
udmenu_<MENUNAME>_title "<TITLE>"
TITLE is string of text specifying a title for the menu.
If no title is specified, none is displayed, and slightly less screen space is
required to display the menu. The title may include color escapes.
udmenu_<MENUNAME>_default "<N>"
N is an item number which sets the default item for that menu.
The default item is highlighted in yellow.
If the users presses their _menuAccept bind, the default items commands are
executed. The default (0) means there is no default item.
You can arrange for a menu to remember it's most recently used item, or cycle
through it's items by setting this cvar in each items commands.
NOTE:
Due to limitations in ETQW, you must create a cvar with seta in order to be
able to change it when playing online with cheats disabled. Unless you need to
change it on the fly, I do not suggest using seta on your udmenu items, as they
will clutter up your cfgs and potentially leave unexpected items in your menus.
udmenu_<MENUNAME>_cancel "<COMMANDS>"
COMMANDS is a string of commands like the command portion of a menu item.
These commands are executed when the user uses their _menuCancel (usually
escape) bind in the menu. This can be used to implement menus that go "back"
by using "udmenu <previous menu>". Using other commands is likely to lead to
confusion.
The default is empty string, which causes the menu to be dismissed when
_menuCancel is pressed.
NOTE:
The _cancel command is not invoked if you cancel the udmenu by any other means,
such as invoking udmenu without a menu name.
udmenu_<MENUNAME>_keys "<KEYS>"
KEYS is one of the following strings: NUM KP FUNC
This defines defines which keys are used to select the menu items.
NUM uses number keys from 1 through 0 are to select items 1-10, and "-" and
"+" (usually the same key as "=") respectively for 11 and 12. The key and
character for the last to may vary depending on your keyboard or language
settings. The number or character is displayed in the menu.
FUNC uses the functions keys, F1 through F12. These are displayed with F
followed by the number.
KP uses the numeric keypad starting at 0 (INS) through 9 to select items 1-10,
and uses KP_SLASH and KP_STAR respectively for items 11 and 12. These are
displayed in the menu with a K followed by the number or character.
The default (empty string) is equivalent to NUM, as is any invalid string.
udmenus and bind contexts
The udmenu finds the keys to use for _menuAccept and _menuCancel in the "menu"
context. However, it does not set the current context. This means that any
keys not actually used by a menu item or _menuAccept or _menuCancel will do
whatever is specified by your current game context. For example, a FUNC udmenu
with 2 items will only intercept F1 and F2. All the other F keys will have
whatever function they normally would in game.
Examples
udbrigthmenu.cfg
A simple 4 level brightness menu.
udbrightmenu2.cfg
Slightly more advanced version, using _default to cycle through the items.
udbotchatmenu.cfg
Some bot chats
udclassmenu.cfg
A complete team/class/weapon selector, using _cancel to implement
hierarchical menus and _default to remember previously selected items.
This consists of
A team menu:
Contains items for the strogg and gdf class menus and a spectator item.
A class menu for each team:
Contains a weapon menu for each class, and an item for the team menu. These
menus remember the most recently selected class as their default.
Weapon menus for each class:
Contains items the weapons available to the class.
Escaping from the weapon menu takes you back to the class menu.
Selecting a weapon sets your class and team.
The KP_PLUS key is used to invoke the menu.
- If you are spectator, this brings up the team menu.
- If you are on a team, the class menu for that team is brought up.
- The _escape cvars are manipulated to take you "back" to the correct place
depending on your current team.
NOTE:
switching teams by another means cause this to get out of sync
History
- 2 - use hudscale (011)
- 1 - initial release (010)
back to index