Skip to content

Expand documentation on building UI to explain helper functions in more detail #338

Open
Steamodded/Wiki
#1
@Pheubel

Description

@Pheubel

The current documentation on how to use the helper functions is fairly vague and requires reading code to understand and use correctly.

In order to improve on the documentation, it should be explained how the table of arguments and the callback argument table are composed.

example create_option_cycle(args)

Creates a selection box that can be cycled through to select a specific option, this element is similar to the one used to select the game's speed.

image

Example usage:

create_option_cycle({
    options = {
        "foo",
        "bar"
    },
    opt_callback = "my_option_cycle"
})

argument table documentation

key type description
label string The text to display in the main cycle box
id ? ?
colour table The colour of the cycle box and buttons, defaults to G.C.RED (FE5F55).
options table The options to display in the options cycle, defaults to { 'Option 1', 'Option 2' }.
current_option int The index of the currently selected option, defaults to 1.
no_pips bool Determines if the pips are displayed on the option cycle, provided there is enough space. If left out, it will attempt to put pips in the option cycle.
opt_callback string The name of the function in G.FUNCS to be called, it will pass along a table of callback arguments. If left empty, no function will be called.
scale number The scale of the option cycle, defaults to 1.
ref_table table ?
ref_value any ?
w number Determines the minimum width of of the main cycle element (before scaling), defaults to 2.5.
h number Determines the minimum height of of the main cycle element (before scaling), defaults to 0.8.
text_scale number Determines how big the text will be scaled, defaults to 0.5.
focus_args table ?
info table The lines of text to display under the option cycle.
mid table Overrides the middle section of the options cycle and replaces it with a custom UI node. If left empty, the default cycle box will be used instead.
cycle_shoulders bool ? (suggests that it has to do with the buttons next to the main cycle box, but saw no difference when toggled.)
on_demand_tooltip table Adds a tooltip when the main cycle boc is hovered over. See tooltip for structure information.

callback argument table documentation

key type description
from_val string The value of the previously selected option.
to_val string The value of the selected option.
from_key int The index of the previously selected option.
to_key int The index of the selected option.
cycle_config table The reference table containing the node information of the option cycle that invoked the callback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions