Modding:Options

Revision as of 06:37, 30 July 2023 by Kernelmethod (talk | contribs) (Add image of example settings; reorganize Options.xml attributes into a table)
This page is about modding. See the modding overview for an abstract on modding.
For best results, it's recommended to have read the following topics before this one:

Adding new options

In some cases it may be desirable to add tunable settings to your mod, to allow players to pick options to their liking. In these cases, you can piggyback off of Qud's built in Options menu by merging your own settings into Options.xml.

Here's an example of a custom Options.xml:

<?xml version="1.0" encoding="utf-8" ?>
<options>
  <option ID="Option_MyName_MyMod_EnableFoo" DisplayText="Enable Foo"
    Category="Mods: MyMod" Type="Checkbox" Default="Yes"></option>
  <option ID="Option_MyName_MyMod_FooSelector" DisplayText="Foo, Bar, or Baz?"
    Category="Mods: MyMod" Type="Combo" Default="Foo"></option>
</options>

This produces a new section in the options menu, which appears as follows:

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

Tag Meaning
ID A unique ID corresponding to the option. This ID is referred to in the code when retrieving the value of the configured setting.
DisplayText The text that should be displayed alongside the option in the settings menu.
Category 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.
Type Affects the widget that is rendered for the option, and the values that it can take on. There are multiple types available, including Checkbox, Slider, Button, Combo, and BigCombo. Each of these types has custom attributes that are specific to them; refer to the base game's Options.xml for a reference.
Default The default value that the option should be set to, before any user configuration.
SearchKeywords Additional keywords that players can use to find an option in the settings menu.

Using configured options in code