-
Notifications
You must be signed in to change notification settings - Fork 1
Function Documentation
Used to create a new RadialMouseMenu object.
new() takes constructor arguments, which are fed to init(). In other words, you should always add arguments for your custom RadialMouseMenu object when constructing it, unless you want to use purely default appearance settings.
Multiple RadialMouseMenu objects can be created with this method, and are stored and controlled separately, as separate instances; however, due to the nature of the control/input scheme, only one should ever be active (visible + interact-able) at any given time.
Describes parameters with which to construct this RadialMouseMenu object.
Used as a "setter"- in case of delayed menu creation, this callback function is called when the menu is successfully completed.
Example:
local items = {
{
name = "use ladder",
icon = {
texture = tweak_data.hud_icons.pd2_ladder.texture,
texture_rect = tweak_data.hud_icons.pd2_ladder.texture_rect,
layer = 3,
w = 16,
h = 16,
alpha = 0.7,
color = Color.purple
},
stays_open = true,
callback = callback(Console,Console,"cmd_say","ladder? i 'ardly even know 'er!")
},
{
name = "drink soda",
icon = {
texture = tweak_data.hud_icons.equipment_soda.texture,
texture_rect = tweak_data.hud_icons.equipment_soda.texture_rect,
layer = 3,
w = 16,
h = 16,
alpha = 0.7,
color = Color(0.9,0.1,0.1)
},
stays_open = true,
callback = callback(Console,Console,"cmd_say","refreshing!")
}
}
local params = {
name = "1",
radius = 200,
items = items
}
myNewRMenu = RadialMouseMenu:new(params)
Please refer to the [Basic Tutorial] for an example and explanation of using the callback parameter in case of delayed menu creation.
Activates and visually displays the calling RadialMouseMenu object. This will lock mouse and keyboard input until this menu object is closed. (The notable exception is that BLT Keybinds will continue to run, as they operate on a different level from the rest of the game's input.)
De-activates and visually hides the calling RadialMouseMenu object.
This will release mouse and keyboard input.
Hide() is called by default when any item in the RadialMouseMenu object is clicked on, unless that item has the value stays_open set to true.
If state is nil, then the menu's visibility is inverted.
If state is not nil, the menu's visibility is set to that value.
Either way, Show() or Hide() is called accordingly.
Returns boolean: _active
Used to determine whether or not the calling RadialMouseMenu object is currently visible and intercepting keyboard/mouse input.
Argument data: type table. See [Basic Tutorial] for a more detailed example.
Used to create an individual selectable option for your RadialMouseMenu object.
As items in RadialMouseMenu use several Panel type UI objects, it is recommended to use this if you want greater control over what is displayed for your menu, and how it is displayed (eg. any uncommon panel options such as render templates, or even simple things like color).
Please note that name, x, and y values are calculated independently by RadialMouseMenu, so you should not bother adding them for individual elements inside your item, other than your item's main name itself.
If false or nil, the menu's items will be refreshed again via populate_items(). Else, populate_items() will not be called. It is recommended to use skip_refresh if you are adding multiple items at a time, and allowing refresh on the last item in your menu.
Argument data: type table. See [Basic Tutorial] for a more detailed example.
Where add_item() is used for the thorough and absolute description of an item, create_item() should be used when you want an item with mostly default values (size, width, alpha, layer), but with some custom values of your own.
Newly created items are automatically added to the RadialMouseMenu object; no value is returned.
create_item() operates on a "whitelist" basis: that is, only certain parameters from your data argument are allowed; the rest are discarded. If you are a more advanced Lua user, you should use add_item().
If false or nil, the menu's items will be refreshed again via populate_items(). Else, populate_items() will not be called. It is recommended to use skip_refresh if you are adding multiple items at a time, and allowing refresh on the last item in your menu.
Returns the item data (table) of the indicated index.
Returns the name of the menu, as provided in the constructor.
Removes all items' UI Panels from your RadialMouseMenu object. However, your items' original data is untouched. This is useful if you need to dynamically change individual attributes of an item after the menu is loaded or used, and update your menu object.
Removes all items' UI panels from your RadialMouseMenu object, as well as removing all of the selectable items within that object.
Reads the item data within your RadialMouseMenu object and creates and aligns its UI objects accordingly.
This is called once automatically, during init(). If you need to make changes to your RadialMouseMenu object after you have created it, you will need to call this function again in order for any visual changes to take place. In such a case, it is recommended to use clear_items() beforehand.