Modding:Options: Difference between revisions

533 bytes added ,  06:37, 30 July 2023
Add image of example settings; reorganize Options.xml attributes into a table
(Add initial version of page with description of Options.xml)
 
(Add image of example settings; reorganize Options.xml attributes into a table)
Line 1: Line 1:
[[Category:Modding]]{{Modding Info}}
[[Category:Script Modding]]
{{Modding Info}}{{Modding Topic Prerequisites | Modding:C Sharp Scripting}}


==Adding new options==
==Adding new options==
Line 16: Line 17:
</options>
</options>
</syntaxhighlight>
</syntaxhighlight>
This produces a new section in the options menu, which appears as follows:
[[Image:Modding-Options example.png|center|600px|alt=Example of custom settings added to the Options menu by a mod. This settings menu includes three new options: a checkbox for "Enable Foo", a combo selector for "Foo, Bar, or Baz?", and a slider labeled "Amount of foo to use".]]


The <code><option>...</option></code> XML tag defines a new setting in <code>Options.xml</code>. This tag can have the following attributes:
The <code><option>...</option></code> XML tag defines a new setting in <code>Options.xml</code>. This tag can have the following attributes:


* <code>ID</code>: a unique ID corresponding to the option. This ID is referred to in the code when retrieving the value of the configured setting.
{| class="wikitable" style="min-width: 50%;"
* <code>DisplayText</code>: the text that should be displayed alongside the option in the settings menu.
! Tag
* <code>Category</code>: the area under which the option appears in the settings menu. In general, all of your options should go under a single custom category for your mod.
! Meaning
* <code>Type</code>: affects the widget that is rendered for the option, and the values that it can take on. There are multiple types available, including <code>Checkbox</code>, <code>Slider</code>, <code>Button</code>, <code>Combo</code>, and <code>BigCombo</code>. Each of these types has custom attributes that are specific to them; refer to the base game's <code>Options.xml</code> for a reference.
|-
* <code>Default</code>: the default value that the option should be set to, before any user configuration.
| <code>ID</code>
* <code>SearchKeywords</code>: additional keywords that players can use to find an option in the settings menu.
| A unique ID corresponding to the option. This ID is referred to in the code when retrieving the value of the configured setting.
|-
| <code>DisplayText</code>
| The text that should be displayed alongside the option in the settings menu.
|-
| <code>Category</code>
| The area under which the option appears in the settings menu. In general, all of your options should go under a single custom category for your mod.
|-
| <code>Type</code>
| Affects the widget that is rendered for the option, and the values that it can take on. There are multiple types available, including <code>Checkbox</code>, <code>Slider</code>, <code>Button</code>, <code>Combo</code>, and <code>BigCombo</code>. Each of these types has custom attributes that are specific to them; refer to the base game's <code>Options.xml</code> for a reference.
|-
| <code>Default</code>
| The default value that the option should be set to, before any user configuration.
|-
| <code>SearchKeywords</code>
| Additional keywords that players can use to find an option in the settings menu.
|}


==Using configured options in code==
==Using configured options in code==
{{Modding Navbox}}