Modding:Options: Difference between revisions
Kernelmethod (talk | contribs) m Make the Options class static in the provided example |
Kernelmethod (talk | contribs) m Improvements to the code examples |
||
Line 4: | Line 4: | ||
==Adding new options== | ==Adding new options== | ||
In some cases it may be desirable to add tunable settings to your mod | In some cases it may be desirable to add tunable settings to your mod to allow players to configure it to their liking. In these cases, you can piggyback off of Qud's built in options menu by merging your own settings into <code>Options.xml</code>. | ||
Here's an example of a custom <code>Options.xml</code>: | Here's an example of a custom <code>Options.xml</code>: | ||
Line 12: | Line 12: | ||
<options> | <options> | ||
<option ID="Option_MyName_MyMod_EnableFoo" DisplayText="Enable Foo" | <option ID="Option_MyName_MyMod_EnableFoo" DisplayText="Enable Foo" | ||
Category="Mods: MyMod" Type="Checkbox" Default="Yes" | Category="Mods: MyMod" Type="Checkbox" Default="Yes" /> | ||
<option ID="Option_MyName_MyMod_FooSelector" DisplayText="Foo, Bar, or Baz?" | <option ID="Option_MyName_MyMod_FooSelector" DisplayText="Foo, Bar, or Baz?" | ||
Category="Mods: MyMod" Type="Combo" Default="Foo" | Category="Mods: MyMod" Type="Combo" Default="Foo" /> | ||
</options> | </options> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 22: | Line 22: | ||
[[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".]] | [[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 | The <code><option/></code> XML tag defines a new setting in <code>Options.xml</code>. This tag can have the following attributes: | ||
{| class="wikitable" style="min-width: 50%;" | {| class="wikitable" style="min-width: 50%;" | ||
Line 66: | Line 66: | ||
public static class Options { | public static class Options { | ||
private static string GetOption(string ID, string Default = "") { | private static string GetOption(string ID, string Default = "") { | ||
return XRL.UI.Options.GetOption(ID, Default); | return XRL.UI.Options.GetOption(ID, Default: Default); | ||
} | } | ||