Modding:Options

Revision as of 06:28, 30 July 2023 by Kernelmethod (talk | contribs) (Add initial version of page with description of Options.xml)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page is about modding. See the modding overview for an abstract on modding.

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>

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

  • 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