-
Notifications
You must be signed in to change notification settings - Fork 2
Options Menu
The GooeeSettings class is an integral part of the Gooee UI framework, designed to facilitate the creation of in-game options menus in Cities Skylines 2 mods. This documentation provides a step-by-step guide on implementing the GooeeSettings class along with XML markup to create a customized settings interface for your mod.
These settings automatically get saved into the games storage.
Begin by extending the GooeeSettings class. This custom class will hold the settings for your mod. Below is an example implementation:
public class ExampleSettings : GooeeSettings
{
[SettingsUIHidden]
protected override string UIResource => "MyAssembly.Resources.settings.xml";
public bool Test { get; set; }
public bool AVal { get; set; }
public bool BVal { get; set; }
public bool CVal { get; set; }
public ExampleSettings()
{
}
public override void SetDefaults()
{
Test = true;
}
}The XML file is crucial as it defines the UI layout for your settings. Each setting in the C# model corresponds to an element in the XML. Here's an example markup:
<?xml version="1.0" encoding="utf-8" ?>
<settings>
<group title="General">
<description>VersionNumber</description>
<field title="Test">
<checkbox isChecked="Test" />
<button>ShowChangeLog</button>
</field>
</group>
<group title="Another">
<field title="AVal">
<checkbox isChecked="AVal" />
</field>
</group>
<tab title="Misc">
<group title="Two">
<field title="BVal">
<checkbox isChecked="BVal" />
</field>
</group>
<group title="Five">
<field title="CVal">
<checkbox isChecked="CVal" />
</field>
</group>
</tab>
</settings>-
<settings>: The root element. -
<group>: Defines a group of settings. -
<tab>: Organizes groups into tabs. -
<field>: Represents an individual setting. -
<checkbox>: A checkbox element,isCheckedbinds to a boolean property in the C# model. -
<button>: A button element, can trigger actions or events.
Ensure that the properties in your C# class match the isChecked attributes in the XML. For example, the Test property in the C# class corresponds to the <checkbox isChecked="Test" /> element in the XML.
You need to also edit your plugin definition to include IGooeeSettings and the new Settings property:
[ControllerTypes(typeof(ExampleController))]
[GooeeSettingsMenu(typeof(ExampleSettings))]
public class ExamplePlugin : IGooeePluginWithControllers, IGooeeSettings
{
public string Name => "Example";
public string ScriptResource => "MyAssembly.Resources.ui.js";
public IController[] Controllers { get; set; }
public GooeeSettings Settings { get; set; }
}As this is an experimental feature, thorough testing is crucial. Check the integration of the settings within the game and ensure that the UI behaves as expected. Report any bugs or issues for further development and refinement.
- The XML file must be correctly referenced in the
UIResourceproperty and MUST be an embedded resource in your assembly. - Ensure that the XML structure correctly represents the intended layout and functionality of your settings menu.
- This framework is in the experimental phase; some features might not be fully implemented.
By following these steps, you can effectively implement the GooeeSettings class in your Cities Skylines 2 mod. This will enable you to create a dynamic and user-friendly settings interface, enhancing the overall experience of your mod. Keep an eye on updates and community feedback for continuous improvement of the framework.