Class mct_section
Section Object
Methods
mct_section:new (key, mod) | For internal use only. |
mct_section:get_ordered_options () | Get the ordered keys of all options in this section, based on the sort-order-function determined by mct_section:set_option_sort_function. |
mct_section:set_option_at_index (option_key, x, y) | Set an option key at a specific index, for the mct_section:get_ordered_options function. |
mct_section:sort_options () | Call the internal .sortorder_function, determined by mct_section:set_option_sort_function -- @local |
mct_section:sort_options_by_localised_text () | One of the default sort-option functions. |
mct_section:sort_options_by_key () | One of the default sort-option function. |
mct_section:sort_options_by_index () | One of the default sort-option functions. |
mct_section:set_option_sort_function (sort_func) | Set the option-sort-function for this section's options. |
mct_section:clear_uics () | Clears the UICs saved in this section to prevent wild crashes or whatever. |
mct_section:add_dummy_row (uic) | Saves the dummy rows (every 3 options in the UI is a dummyrow) in the mctsection. |
mct_section:uic_visibility_change (event_free) | The UI trigger for the section opening or closing. |
mct_section:add_section_visibility_change_callback (callback) | Add a callback to be triggered after mct_section:uic_visibility_change is called. |
mct_section:process_callback () | Trigger the callback from mct_section:add_section_visibility_change_callback -- @local |
mct_section:get_dummy_rows () | Get the dummy rows for the options in this section. |
mct_section:get_key () | Get the key for this section. |
mct_section:get_mod () | Get the mct_mod that owns this section. |
mct_section:get_localised_text () | Get the header text for this section. |
mct_section:is_visible () | Grab whether this mct_section is set to be visible or not - whether it's "opened" or "closed" -- Works to read the UI, as well. |
mct_section:set_visibility (is_visible) | Set the visibility for the mct_section. |
mct_section:set_localised_text (text, is_localised) | Set the title for this section. |
mct_section:assign_option (option_obj) | Assign an option to this section. |
mct_section:get_options () | Return all the options assigned to the mct_section. |
Methods
- mct_section:new (key, mod)
-
For internal use only. Use mct_mod:add_new_section.
-- @tparam string key The key to identify the new mctsection.
-- @tparam mctmod mod The mct_mod this section is a member of.
Parameters:
- key
- mod
- mct_section:get_ordered_options ()
- Get the ordered keys of all options in this section, based on the sort-order-function determined by mct_section:set_option_sort_function. -- @treturn {string,...} orderedoptions An array of the ordered option keys, [1] is the first key, [2] is the second, so on. -- @treturn number numtotal The total number of options in this section, for UI creation.
- mct_section:set_option_at_index (option_key, x, y)
-
Set an option key at a specific index, for the mct_section:get_ordered_options function.
-- Don't call this directly - use mct_section:set_option_sort_function
-- @tparam string option_key The option key being placed at the index.
-- @tparam number x The x-value for the option. Somewhere between 1(left) and 3(right)
-- @tparam number y The y-value for the option. 1 is the top row, etc.
Parameters:
- option_key
- x
- y
- mct_section:sort_options ()
- Call the internal .sortorder_function, determined by mct_section:set_option_sort_function -- @local
- mct_section:sort_options_by_localised_text ()
- One of the default sort-option functions. Sort the options by their localised text - from "A Cool Option" to "Zoidberg Goes Woop Woop Woop"
- mct_section:sort_options_by_key ()
- One of the default sort-option function. -- Sort the options by their option key - from "!myoption" to "zzzmy_option"
- mct_section:sort_options_by_index ()
-
One of the default sort-option functions.
-- Sort the options by the order in which they were added in the
mct/settings/?.lua
file. - mct_section:set_option_sort_function (sort_func)
-
Set the option-sort-function for this section's options.
-- You can pass "key_sort" for mct_section:sort_options_by_key
-- You can pass "index_sort" for mct_section:sort_options_by_index
-- You can pass "text_sort" for mct_section:sort_options_by_localised_text
-- You can also pass a full function, for example:
-- mctsection:setoptionsortfunction(
-- function()
-- local orderedoptions = {}
-- local options = mctsection:getoptions()
-- for optionkey, optionobj in pairs(options) do
-- orderedoptions[#orderedoptions+1] = optionkey
-- end
--
-- -- alphabetically sort the options
-- table.sort(orderedoptions)
--
-- -- reverse the order
-- table.sort(orderedoptions, function(a,b) return a > b end)
-- end
-- )
-- @tparam function|string sort_func The sort function provided. Either use one of the two strings above, or a custom function like the above example.
Parameters:
- sort_func
- mct_section:clear_uics ()
- Clears the UICs saved in this section to prevent wild crashes or whatever. -- @local
- mct_section:add_dummy_row (uic)
-
Saves the dummy rows (every 3 options in the UI is a dummyrow) in the mctsection.
-- @local
Parameters:
- uic
- mct_section:uic_visibility_change (event_free)
-
The UI trigger for the section opening or closing.
-- Internal use only. Use mct_section:set_visibility if you want to manually change the visibility elsewhere.
-- @tparam boolean event_free Whether to trigger the "MctSectionVisibilityChanged" event. True is sent when the section is first created.
Parameters:
- event_free
- mct_section:add_section_visibility_change_callback (callback)
-
Add a callback to be triggered after mct_section:uic_visibility_change is called.
-- @tparam function callback The callback to trigger when the visibility is changed.
Parameters:
- callback
- mct_section:process_callback ()
- Trigger the callback from mct_section:add_section_visibility_change_callback -- @local
- mct_section:get_dummy_rows ()
- Get the dummy rows for the options in this section. -- Not really needed outside. -- @local
- mct_section:get_key ()
- Get the key for this section. -- @treturn string The key for this section.
- mct_section:get_mod ()
- Get the mct_mod that owns this section. -- @treturn mctmod The owning mctmod for this section.
- mct_section:get_localised_text ()
- Get the header text for this section. -- Either mct[mctmodkey][sectionkey]section_text, in a .loc file, -- or the text provided using mct_section:set_localised_text -- @treturn string The localised text for this section, used as the title.
- mct_section:is_visible ()
- Grab whether this mctsection is set to be visible or not - whether it's "opened" or "closed" -- Works to read the UI, as well. -- @treturn boolean Whether the mctsection is currently visible, or whether the mct_section will be visible when it's next created.
- mct_section:set_visibility (is_visible)
-
Set the visibility for the mct_section.
-- This works while the UI currently exists, or to set its visibility next time the panel is opened.
-- Triggers mct_section:uic_visibility_change automatically.
-- @tparam boolean is_visible True for open, false for closed.
Parameters:
- is_visible
- mct_section:set_localised_text (text, is_localised)
-
Set the title for this section.
-- Works the same as always - you can pass hard text, ie. mctsection:setlocalisedtext("My Section")
-- or a localised key, ie. mctsection:setlocalisedtext("mysectionlockey", true)
-- @tparam string text The localised text for this mctsection title. Either hard text, or a loc key.
-- @tparam boolean is_localised If setting a loc key as the localised text, set this to true.
Parameters:
- text
- is_localised
- mct_section:assign_option (option_obj)
-
Assign an option to this section.
-- Automatically called through mct_option:set_assigned_section.
-- @tparam mctoption optionobj The option object to assign into this section.
Parameters:
- option_obj
- mct_section:get_options ()
- Return all the options assigned to the mctsection. -- @treturn {[string]=mctobject,...} The table of all the options in this mct_section.