Skip to content

Game.Settings.ModdingSettings

Assembly:
Namespace: Game.Settings

Type: class

Base: Setting

Summary:
ModdingSettings is a Setting-derived class that implements the in-game Settings UI for the modding toolchain in Cities: Skylines 2. It exposes actions to install, uninstall, repair and update the modding toolchain, developer-only controls for inspecting and updating environment variables, a download directory setting, and dynamically generates UI entries for each toolchain dependency managed by the ToolchainDeployment. The class also contains UI-related attribute metadata (groups, order, page warning) used by the automatic settings system.


Fields

  • public const string kName
    Defines the settings page name key ("Modding").

  • public const string kDisclaimer
    Group name constant for the disclaimer UI section.

  • public const string kMain
    Group name constant for the main UI section.

  • public const string kDependencies
    Group name constant for the dependencies UI section.

Properties

  • public bool isInstalled { get; set; }
    Tracks whether the modding toolchain is considered installed. Updated by successful install/repair/update/uninstall actions.

  • public bool installModdingToolchain { set }
    Write-only property exposed as a button in the UI. Setting it triggers ToolchainDeployment.RunWithUI(DeploymentAction.Install, ...) and sets isInstalled = true when the operation reports success.

  • public bool uninstallModdingToolchain { set }
    Write-only property exposed as a button. Setting it triggers ToolchainDeployment.RunWithUI(DeploymentAction.Uninstall, ...) and sets isInstalled = false on success.

  • public bool repairModdingToolchain { set }
    Write-only property exposed as a button. Setting it triggers ToolchainDeployment.RunWithUI(DeploymentAction.Repair, ...) and sets isInstalled = true on success.

  • public bool updateModdingToolchain { set }
    Write-only property exposed as a button. Setting it triggers ToolchainDeployment.RunWithUI(DeploymentAction.Update, ...) and sets isInstalled = true on success.

  • public bool showEnvVars { set }
    Developer-only write-only property (button) that collects current user-scoped environment variables defined by IToolchainDependency.envVars and shows them in a MessageDialog via the UI.

  • public bool showCurrentValues { set }
    Developer-only write-only property (button) that shows the "intended" environment variable values (the values from IToolchainDependency.envVars) in a MessageDialog.

  • public bool updateEnvVars { set }
    Developer-only write-only property (button) that writes the intended env var keys into the user environment (via ToolchainDependencyManager.UserEnvironmentVariableManager.SetEnvVars) and triggers an asynchronous refresh of the dependency manager state.

  • public bool removeEnvVars { set }
    Developer-only write-only property (button) that removes environment variables managed by the toolchain dependency manager and triggers an asynchronous refresh of the dependency manager state.

  • private bool disableEnvVarUpdate { get }
    Private computed property that returns !isInstalled. Used to hide/disable env var-related UI when the toolchain is not installed.

  • public string downloadDirectory { get; set; }
    Directory picker exposed in the UI for selecting a download/installation path. Default value is EnvPath.kTempDataPath. Hidden when the toolchain is already installed.

  • public bool isActionDisabled { get }
    Read-only computed property that indicates whether toolchain actions are currently disabled. Returns true when the dependency manager's cached state status is not ModdingToolStatus.Idle.

  • public bool canNotBeInstalled { get }
    Read-only computed property used for UI hiding; true when the cached deployment state is not NotInstalled (i.e., already installed or in another state).

  • public bool canNotBeUninstalled { get }
    Read-only computed property used for UI hiding; true when the cached deployment state is NotInstalled.

  • public bool canNotBeRepaired { get }
    Read-only computed property used for UI hiding; true unless the cached state equals Invalid.

  • public bool canNotBeUpdated { get }
    Read-only computed property used for UI hiding; true unless the cached state equals Outdated.

  • public bool noNeedDownloadPath { get }
    Read-only computed property used to hide the downloadDirectory picker when the deployment state is Installed.

  • public bool showWarning { get }
    Computed property used for the page warning attribute. Returns true when the toolchain is installed and either in Invalid or Outdated state (shows a warning if repair/update is suggested).

Constructors

  • public ModdingSettings()
    Implicit default constructor. No special construction logic defined in source; initialization relies on property defaults and the automatic settings infrastructure.

Methods

  • public override void SetDefaults() : System.Void
    Overrides Setting.SetDefaults. Currently empty — no default value setup performed here.

  • public override AutomaticSettings.SettingPageData GetPageData(string id, bool addPrefix)
    Builds the AutomaticSettings.SettingPageData for this settings page. Responsibilities:

  • Adds the "Disclaimer", "Main" and "Dependencies" groups and populates them.
  • Creates a multiline disclaimer text item.
  • Inserts a ModdingToolchainSettingItem for the main toolchain dependency (ToolchainDependencyManager.m_MainDependency).
  • Iterates ToolchainDeployment.dependencyManager and adds an item per dependency by calling GetItem.
  • Configures per-item attributes, display names and visibility/disable actions used by the settings UI.

  • private ModdingToolchainSettingItem GetItem(IToolchainDependency dependency, AutomaticSettings.SettingPageData pageData)
    Creates a ModdingToolchainSettingItem for a single IToolchainDependency. Specific behaviors:

  • Wraps the dependency in an AutomaticSettings.ManualProperty getter for read-only display.
  • Adds per-dependency action buttons (Install/Uninstall/Repair/Update) where applicable; each action button is wired to run ToolchainDeployment.RunWithUI(action, new List{dependency}).
  • Adds a directory picker item if the dependency can change its installation directory (and hides it if installed).
  • If the dependency is a CombinedDependency, it recursively adds children for each sub-dependency.
  • Sets description and valueVersionAction to allow the UI to detect changes.

Usage Example

// Example: Programmatically trigger UI actions from code.
// Note: In-game UI usually invokes these via AutomaticSettings; setting the properties below
// runs the actions defined in the property setters.

var settings = new ModdingSettings();

// Show current user environment variables used by the toolchain:
settings.showEnvVars = true;

// Request installation of the modding toolchain (runs the UI deployment flow):
settings.installModdingToolchain = true;

// Change download directory (if visible in UI and applicable):
settings.downloadDirectory = @"C:\ModdingDownloads";

Additional notes: - The class uses several SettingsUI-related attributes (FileLocation, SettingsUIShowGroupName, SettingsUIGroupOrder, SettingsUIPageWarning) to control how it appears in the game's automatic settings UI. - Toolchain operations are routed through ToolchainDeployment and ToolchainDependencyManager; these manage state and present RunWithUI flows that display progress dialogs and success/failure results.