MCM API Reference - lmstearn/skyui GitHub Wiki
Version 2.0
Overview
Properties
Events
- OnConfigInit
- OnConfigRegister
- OnConfigOpen
- OnConfigClose
- OnPageReset
- OnOptionHighlight
- OnOptionDefault
- OnOptionSelect
- OnOptionSliderOpen, OnOptionSliderAccept
- OnOptionMenuOpen, OnOptionMenuAccept
- OnOptionColorOpen, OnOptionColorAccept
- OnOptionKeyMapChange
- OnHighlightST
- OnDefaultST
- OnSelectST
- OnSliderOpenST, OnSliderAcceptST
- OnMenuOpenST, OnMenuAcceptST
- OnColorOpenST, OnColorAcceptST
- OnKeyMapChangeST
Functions
- SetCursorPosition
- SetCursorFillMode
- AddEmptyOption, AddHeaderOption, AddTextOption, AddToggleOption, AddSliderOption, AddMenuOption, AddColorOption, AddKeyMapOption
- LoadCustomContent, UnloadCustomContent
- SetOptionFlags
- SetTextOptionValue, SetToggleOptionValue, SetSliderOptionValue, SetMenuOptionValue, SetColorOptionValue, SetKeyMapOptionValue
- ShowMessage
- ForcePageReset
- SetSliderDialogStartValue, SetSliderDialogDefaultValue, SetSliderDialogRange, SetSliderDialogInterval
- AddTextOptionST, AddToggleOptionST, AddSliderOptionST, AddMenuOptionST, AddColorOptionST, AddKeyMapOptionST
- SetOptionFlagsST
- SetTextOptionValueST, SetToggleOptionValueST, SetSliderOptionValueST, SetMenuOptionValueST, SetColorOptionValueST, SetKeyMapOptionValueST
Properties
string ModName
The name of your mod as it appears in the list on the left side of the control panel.
Usage:
Set this in script properties panel in the Creation Kit, or in the script itself.
string[] Pages
The names of your sub-pages that appear after your mod has been selected.
Usage:
Set these in the script properties in the Creation Kit, or in the script itself.
string CurrentPage
Holds the name of the page that's currently active. Read only.
Usage:
Use this to get the active page name in events that aren't passed the page name as an argument.
Events
OnConfigInit()
Called when the config menu is initialized.
OnConfigRegister()
Called when the config menu registered successfully.
OnConfigOpen()
Called when the config menu is opened.
OnConfigClose()
Called when the config menu is closed.
OnVersionUpdate(int version)
Called when a version update of this script has been detected.
Parameters:
- version - The new version.
OnPageReset(string page)
Called when a new page is selected, including the initial empty page.
Parameters:
- page - The name of the the current page, or "" if no page is selected.
Usage:
Position the cursor and add options to the current page. Each added option is assigned a unique option ID.
OnOptionHighlight(int option)
Called when highlighting an option.
Parameters:
- option - The option ID.
Usage:
Use SetInfoText to show information about the currently highlighted option.
OnOptionDefault(int option)
Called when resetting an option to its default value.
Parameters:
- option - The option ID.
Usage:
Reset any internal state of the selected option to its default value, then use the option setters to apply the changes to the active page.
OnOptionSelect(int option)
Called when a non-interactive option has been selected.
Parameters:
- option - The option ID.
Usage:
Modify the internal state of the selected option then use the option setters to apply the changes to the active page.
OnOptionSliderOpen(int option)
Called when a slider option has been selected.
Parameters:
- option - The option ID.
Usage:
Set the slider parameters for the selected option.
OnOptionSliderAccept(int option, float value)
Called when a new slider value has been accepted.
Parameters:
- option - The option ID.
- value - The accepted value.
Usage:
Modify the internal state of the selcted option, then use the option setters to apply the changes to the active page.
OnOptionMenuOpen(int option)
Called when a menu option has been selected.
Parameters:
- option - The option ID.
Usage:
Set the menu parameters for the selected option.
OnOptionMenuAccept(int option, int index)
Called when a menu entry has been accepted.
Parameters:
- option - The option ID.
- index - The index of the accepted menu entry.
Usage:
Modify the internal state of the selected option, then use the option setters to apply the changes to the active page.
OnOptionColorOpen(int option)
Called when a color option has been selected.
Parameters:
- option - The option ID.
Usage:
Set the color swatch parameter for the selected option.
OnOptionColorAccept(int option, int color)
Called when a new color has been accepted.
Parameters:
- option - The option ID.
- color - The accepted color (0xRRGGBB).
Usage:
Modify the internal state of the selected option, then use the option setters to apply the changes to the active page.
OnOptionKeyMapChange(int option, int keyCode, string conflictControl, string conflictName)
Called when a key has been remapped.
Parameters:
- option - The option ID.
- keyCode - The new keycode.
- conflictControl - The conflicting control if the keycode was already in use; "" otherwise.
- conflictName - ModName of the conflicting mod; "" if there was no conflict or if conflicting with a vanilla control.
Usage:
Modify the internal state of the selected option, then use the option setters to apply the changes to the active page.
It's up to you to react to any conflicts by checking conflictControl
and conflictName
.
OnHighlightST()
Called when highlighting a state option.
Since version 2.0.
OnDefaultST()
Called when resetting a state option to its default value.
Since version 2.0.
OnSelectST()
Called when a non-interactive state option has been selected.
Since version 2.0.
OnSliderOpenST()
Called when a slider state option has been selected.
Since version 2.0.
OnSliderAcceptST()
Called when a new slider state value has been accepted.
Since version 2.0.
OnMenuOpenST()
Called when a menu state option has been selected.
Since version 2.0.
OnMenuAcceptST()
Called when a menu entry has been accepted for this state option.
Since version 2.0.
OnColorOpenST()
Called when a color state option has been selected.
Since version 2.0.
OnColorAcceptST()
Called when a new color has been accepted for this state option.
Since version 2.0.
OnKeyMapChangeST()
Called when a key has been remapped for this state option.
Since version 2.0.
Functions
int GetVersion()
Returns the static version of this script. Not to be mistaken for the mod version.
Override this function to return the current revision of your script if you want to use the built-in updating mechanism.
If an update has been detected, OnVersionUpdate is executed.
Return value:
The static version of this script.
string GetCustomControl(int keyCode)
Returns the control mapped to the given keycode.
Override this function to check the given keycode against any custom controls you're using in your config menu. This enables other mods to react to keymap conflicts.
Parameters:
- keyCode - The checked keycode.
Return value:
The name of the mapped control, or "" if the keycode was unmapped.
SetTitleText(string text)
Sets the title text of the control panel.
If the title is not set with this function, it defaults to the name of the current page, or the mod name if no pages are defined.
Parameters:
- text - The new title text.
SetInfoText(string text)
Sets the text for the info text field below the option panel.
Parameters:
- text - The new info text. Supports multi-line; use \n to start a new line.
Context:
SetCursorPosition(int position)
Sets the position of the cursor used for the option setters.
The options are displayed in a grid with 2 columns and 64 rows, with a total of 128 cells. They are indexed 0 to 127, left-to-right, top-to-bottom.
Default cursor position is 0 (top-left).
Parameters:
- position - The new cursor position.
Examples:
- top-right:
SetCursorPosition(1)
- bottom-left:
SetCursorPosition(126)
- bottom-right:
SetCursorPosition(127)
Context:
SetCursorFillMode(int fillMode)
Sets the fill direction of the cursor used for the option setters.
Accepted values are LEFT_TO_RIGHT
and TOP_TO_BOTTOM
.
For LEFT_TO_RIGHT
, the fill order is n, n+1, n+2, ..., i.e. fill up the current row, then move to the next one.
For TOP_TO_BOTTOM
, the fill order is n, n+2, n+4, ..., i.e. fill the next entry in the current column.
Parameters:
- fillMode - The new fill mode.
Context:
int AddEmptyOption()
Adds an empty option, which can be used for padding instead of manually re-positioning the cursor.
Return value:
The option ID.
Context:
int AddHeaderOption(string text, int flags = 0)
Adds a header option to group several options together.
Parameters:
- text - The header text.
- flags (optional) - See SetOptionFlags.
Return value:
The option ID.
Context:
int AddTextOption(string text, string value, int flags = 0)
Adds a generic text/value option.
Parameters:
- text - The option text.
- value - The option value.
- flags (optional) - See SetOptionFlags.
Return value:
The option ID.
Context:
int AddToggleOption(string text, bool checked, int flags = 0)
Adds a check box option that can be toggled on and off.
Parameters:
- text - The option text.
- checked - The initial state of the check box.
- flags (optional) - See SetOptionFlags.
Return value:
The option ID.
Context:
int AddSliderOption(string text, float value, string formatString = "{0}", int flags = 0)
Adds an option that opens a slider dialog when selected.
Parameters:
- text - The option text.
- value - The initial value of the slider.
- formatString (optional) - If a non-empty format string is passed, it will be used to format the value instead of just displaying a raw number.
{N}
in the format string is substited for the value rounded to N decimal places. - flags (optional) - See SetOptionFlags.
Additional slider parameters are set in OnOptionSliderOpen when the slider is opened.
Return value:
The option ID.
Examples:
AddSliderOption("Frequency", 1.234, "Every {2} hours")
=> "Every 1.23 hours"AddSliderOption("Rounded", 1.234, "{0}")
=> "1"
Context:
int AddMenuOption(string text, string value, int flags = 0)
Adds an option that opens a menu dialog when selected.
Parameters:
- text - The option text.
- value - The initial displayed option value.
- flags (optional) - See SetOptionFlags.
The menu parameters are set in OnOptionMenuOpen when the dialog is opened.
Return value:
The option ID.
Context:
int AddColorOption(string text, int color, int flags = 0)
Adds an option that opens a color swatch dialog when selected.
Parameters:
- text - The option text.
- color - The initial color value (0xRRGGBB).
- flags (optional) - See SetOptionFlags.
The color swatch parameters are set in OnOptionColorOpen when the dialog is opened.
Return value:
The option ID.
Context:
int AddKeyMapOption(string text, int keyCode, int flags = 0)
Adds a key mapping option.
Parameters:
- text - The option text.
- keyCode - The initial SKSE keycode. Will be shown as an image depicting the button.
- flags (optional) - See SetOptionFlags.
Return value:
The option ID.
Context:
LoadCustomContent(string source, float x = 0.0, float y = 0.0)
Loads an external file.
Once custom content has been loaded, it's shown in the option panel and the option list is hidden.
To clear the custom content and show the option list again, use UnloadCustomContent.
Parameters:
- source - The path to the loaded file relative to Data/Interface/. Supported formats are .swf, for animated/interactive content, and .dds for images.
- x (optional) - The horizontal offset relative to the top-left corner of the option panel.
- y (optional) - The vertical offset relative to the top-left corner of the option panel.
Context:
UnloadCustomContent()
Clears any custom content and re-enables the original option list.
Has to be called manually after LoadCustomContent was used.
Context:
SetTextOptionValue(int option, string value, bool noUpdate = false)
Parameters:
- option - The option ID.
- value - The new option value.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
Context:
OnOptionSelect, OnOptionDefault
SetToggleOptionValue(int option, bool checked, bool noUpdate = false)
Parameters:
- option - The option ID.
- checked - The new check box state.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
Context:
OnOptionSelect, OnOptionDefault
SetSliderOptionValue(int option, float value, string formatString = "{0}", bool noUpdate = false)
Parameters:
- option - The option ID.
- value - The new option value.
- formatString (optional) - The new format string.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
Context:
OnOptionSliderAccept, OnOptionDefault
SetMenuOptionValue(int option, string value, bool noUpdate = false)
Parameters:
- option - The option ID.
- value - The new option value.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
Context:
OnOptionMenuAccept, OnOptionDefault
SetColorOptionValue(int option, int color, bool noUpdate = false)
Parameters:
- option - The option ID.
- color - The new color (0xRRGGBB).
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
Context:
OnOptionColorAccept, OnOptionDefault
SetKeyMapOptionValue(int option, int keyCode, bool noUpdate = false)
Parameters:
- option - The option ID.
- keyCode - The new keycode.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
Context:
OnOptionKeyMapChange, OnOptionDefault
SetOptionFlags(int option, int flags, bool noUpdate = false)
Sets the option flags.
Accepted flags are
OPTION_FLAG_NONE
, to clear the flags;OPTION_FLAG_DISABLED
, to grey out and disable the option.OPTION_FLAG_HIDDEN
, to hide an option. It'll behave like an empty option.OPTION_FLAG_WITH_UNMAP
, to enable the unmap button for keymap options.
Parameters:
- option - The option ID.
- flags - The new option flags.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
Examples:
SetOptionFlags(x, OPTION_FLAG_DISABLED)
to disable an option.SetOptionFlags(x, OPTION_FLAG_NONE)
to re-enable it.
Context:
OnOptionSelect, OnOptionSliderAccept, OnOptionMenuAccept, OnOptionColorAccept, OnOptionKeyMapChange, OnOptionDefault
SetSliderDialogStartValue(float value)
Parameters:
- value - The starting value of the slider, which should be set to the current value.
Context:
SetSliderDialogDefaultValue(float value)
Parameters:
- value - The default value of the slider.
Context:
SetSliderDialogRange(float minValue, float maxValue)
Parameters:
- minValue - The smallest valid slider value.
- maxValue - The largest valid slider value.
Context:
SetSliderDialogInterval(float value)
Parameters:
- value - The stepping interval for changing slider values.
Context:
SetMenuDialogStartIndex(int value)
Parameters:
- value - The index of the initially selected menu entry.
Context:
SetMenuDialogDefaultIndex(int value)
Parameters:
- value - The index of the default menu entry.
Context:
SetMenuDialogOptions(string[] options)
Parameters:
- options - The list entries for the menu dialog.
Context:
SetColorDialogStartColor(int color)
Parameters:
- color - The intially selected color (0xRRGGBB).
Context:
SetColorDialogDefaultColor(int color)
Parameters:
- value - The default color (0xRRGGBB).
Context:
ShowMessage(string message, bool withCancel = true, ...)
Shows a message dialog.
This function works similar to Message.Show
, so it will pause the script and wait until the user closed the dialog. The return value indicates whether the dialog was accepted or canceled.
Parameters:
- message - The message string. Use \n for line breaks.
- withCancel (optional) - Show accept and cancel options. Otherwise, only the accept button is visible.
- acceptLabel (optional) - The text label used for the accept button. Default is localized
Accept
. - cancelLabel (optional) - The text label used for the cancel button. Default is localized
Cancel
.
Return value:
true
if the user accepted the dialog, false
if it was canceled.
Context:
OnOptionSelect, OnOptionSliderAccept, OnOptionMenuAccept, OnOptionColorAccept, OnOptionKeyMapChange, OnOptionDefault
ForcePageReset()
Forces OnPageReset to be executed again after the current event has completed.
Context:
OnOptionSelect, OnOptionSliderAccept, OnOptionMenuAccept, OnOptionColorAccept, OnOptionKeyMapChange, OnOptionDefault
AddTextOptionST(string stateName, string text, string value, int flags = 0)
Adds a generic text/value state option.
Parameters:
- stateName - The state option name.
- text - The option text.
- value - The option value.
- flags (optional) - See SetOptionFlags.
Context:
Since version 2.0.
AddToggleOptionST(string stateName, string text, bool checked, int flags = 0)
Adds a check box state option that can be toggled on and off.
Parameters:
- stateName - The state option name.
- text - The option text.
- checked - The initial state of the check box.
- flags (optional) - See SetOptionFlags.
Context:
Since version 2.0.
AddSliderOptionST(string stateName, string text, float value, string formatString = "{0}", int flags = 0)
Adds a state option that opens a slider dialog when selected.
Parameters:
- stateName - The state option name.
- text - The option text.
- value - The initial value of the slider.
- formatString (optional) - If a non-empty format string is passed, it will be used to format the value instead of just displaying a raw number.
{N}
in the format string is substited for the value rounded to N decimal places. - flags (optional) - See SetOptionFlags.
Additional slider parameters are set in OnOptionSliderOpen when the slider is opened.
Context:
Since version 2.0.
AddMenuOptionST(string stateName, string text, string value, int flags = 0)
Adds a state option that opens a menu dialog when selected.
Parameters:
- stateName - The state option name.
- text - The option text.
- value - The initial displayed option value.
- flags (optional) - See SetOptionFlags.
The menu parameters are set in OnOptionMenuOpen when the dialog is opened.
Context:
Since version 2.0.
AddColorOptionST(string stateName, string text, int color, int flags = 0)
Adds a state option that opens a color swatch dialog when selected.
Parameters:
- stateName - The state option name.
- text - The option text.
- color - The initial color value (0xRRGGBB).
- flags (optional) - See SetOptionFlags.
The color swatch parameters are set in OnOptionColorOpen when the dialog is opened.
Context:
Since version 2.0.
AddKeyMapOptionST(string stateName, string text, int keyCode, int flags = 0)
Adds a key mapping state option.
Parameters:
- stateName - The state option name.
- text - The option text.
- keyCode - The initial SKSE keycode. Will be shown as an image depicting the button.
- flags (optional) - See SetOptionFlags.
Context:
Since version 2.0.
SetOptionFlagsST(int flags, bool noUpdate = false, string stateName = "")
Sets the option flags of a state option.
Parameters:
- flags - The new option flags. See SetOptionFlags.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
- stateName (optional) - Name of the state option. Default is the current state option.
Context:
OnSelectST, OnSliderAcceptST, OnMenuAcceptST, OnColorAcceptST, OnKeyMapChangeST, OnDefaultST
SetTextOptionValueST(string value, bool noUpdate = false, string stateName = "")
Parameters:
- value - The new option value.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
- stateName (optional) - Name of the state option. Default is the current state option.
Context:
Since version 2.0.
SetToggleOptionValueST(bool checked, bool noUpdate = false, string stateName = "")
Parameters:
- checked - The new check box state.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
- stateName (optional) - Name of the state option. Default is the current state option.
Context:
Since version 2.0.
SetSliderOptionValueST(float value, string formatString = "{0}", bool noUpdate = false, string stateName = "")
Parameters:
- value - The new option value.
- formatString (optional) - The new format string.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
- stateName (optional) - Name of the state option. Default is the current state option.
Context:
Since version 2.0.
SetMenuOptionValueST(string value, bool noUpdate = false, string stateName = "")
Parameters:
- value - The new option value.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
- stateName (optional) - Name of the state option. Default is the current state option.
Context:
Since version 2.0.
SetColorOptionValueST(int color, bool noUpdate = false, string stateName = "")
Parameters:
- color - The new color (0xRRGGBB).
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
- stateName (optional) - Name of the state option. Default is the current state option.
Context:
Since version 2.0.
SetKeyMapOptionValueST(int keyCode, bool noUpdate = false, string stateName = "")
Parameters:
- keyCode - The new keycode.
- noUpdate (optional) - If true, the option display is not immediately updated, so several setter calls can be grouped together.
- stateName (optional) - Name of the state option. Default is the current state option.