ARM: Anomaly Radial Menu - Aoldri/anomaly-addon-deps GitHub Wiki

Anomaly Radial Menu

This is a dynamic and reusable radial menu. The UIRadialMenu class handles all of the GUI drawing while the OptionData class is used to add.. options to the menu.

Like any .lua script, every class, method, and variable is accessed through the arm.script, so they will need to be prepended with arm. in your own script.

See arm_example.script for an example of using this.

OptionData

This is the primary way to add options to the radial menu.

Example:

---@class OptionData
local option1 = arm.OptionData("option1", function(state)
    return("ui_new_game_btn_bandit_h") -- static texture
end)
-- Colour
option1:SetColour(function (state)
    return arm.get_stateful_colour(state) -- stateful colour
end)
-- Text
option1:SetText({title = "Bandit",
                    description = "Does nothing :)"})

__init(callback_id, texture)

Constructor for creating an instance of OptionData.

Takes and requires two parameters:

  • callback_id: string
  • texture: string|function

If you want, texture can be omitted and later set with SetTexture(). Either way, the texture must be set before calling DrawOptions() on the menu.

SetTexture

Sets the texture of the option.

Requires one parameter:

  • texture: string|function

This can be a static texture (i.e. string), or change dynamically according to the option state (i.e. function). arm.script supplies its own function for the latter: get_stateful_texture(texture).

SetText

Sets the text of the option.

Requires one parameter:

  • text: string|table

This can be a single string for the title, or a table containing both title and description.

SetColour(colour)

Sets the colour of the option.

Requires one parameter:

  • colour: number|function

The actual number should be created through the GetARGB() method. By default, an option's colour is 255,255,255,255.

This is useful for static textures, so that transparency is used to indicate the hover/disabled states. arm.script supplies its own function for the latter: get_stateful_colour(state).

SetState(state)

Sets the state of the option.

Requires one parameter:

  • state: States

This is useful for forcing the disabled or highlighted states..

UIRadialMenu

The Radial Menu class, which handles drawing UI elements.

Examples:

---@class UIRadialMenu
GUI = arm.UIRadialMenu()

GUI:RegisterCallback("option1", function(flags)
        printf("> Selected: Bandit option!")
    end)

GUI:DrawOptions()

AddOption(option_data)

Adds an option to the menu.

Requires one parameter:

  • option_data: OptionData

RegisterCallback(callback_id, function)

This registers a function to be called when a option is selected.

Requires two parameters:

  • callback_id: string
  • function: function(flags)

The function has the parameter flags that can be changed to affect the menu:

  • flags.close_gui: If true, close the gui

DrawOptions()

Draws the options added through AddOption(). Options are drawn in order of when they were added.

Must be called before the menu is used proper (e.g. using Show())