Game.Settings.QualitySetting
Assembly:
Namespace: Game.Settings
Type: abstract class
Base: Setting
Summary:
QualitySetting is an abstract base class for game quality options in Cities: Skylines 2. It defines a nested Level enum that describes standardized quality presets (Disabled, VeryLow, Low, Medium, High, Colossal, Custom) and exposes an API for getting/setting the current preset, enumerating available presets for a specific quality type, converting presets into UI dropdown items, and transferring/initializing values between settings. Implementations should provide concrete behavior for the abstract members (GetLevel, SetLevel, TransferValuesFrom, EnumerateAvailableLevels, GetMockName). The class also contains logic to determine whether the UI option should be disabled (either because the preset is Disabled or because the whole option is fully disabled via disableSetting).
Fields
public enum Level
Represents quality levels/presets supported by the setting:- Disabled
- VeryLow
- Low
- Medium
- High
- Colossal
-
Custom
-
public bool disableSetting { get; set; }
Marked with attributes: [Exclude], [IgnoreEquals], [SettingsUIHidden]. This property, when true, forces the option to be treated as fully disabled (IsOptionFullyDisabled returns true). The attributes indicate this property is excluded from certain serialization/comparison/UI flows.
Properties
- (The class exposes only the disableSetting auto-property above. Concrete subclasses will typically expose other properties specific to the particular quality being configured.)
Constructors
public QualitySetting()
No explicit constructor is defined in-source; the class relies on the default parameterless constructor. Subclasses should call base as needed.
Methods
-
public abstract Level GetLevel()
Return the current quality Level for this setting. Implementations must provide logic to map their current internal values to one of the Level enum values (including Level.Custom when values do not match a preset). -
public abstract void SetLevel(Level quality, bool apply = true)
Apply the given preset level to this setting. The apply flag indicates whether to immediately apply changes or only stage them (implementation-defined behavior). -
public abstract void TransferValuesFrom(QualitySetting setting)
Copy/transfer values from another QualitySetting instance of the same concrete type. Used for migrating or syncing settings. -
public abstract IEnumerable<Level> EnumerateAvailableLevels()
Return the set of Level presets supported by this particular setting. The returned sequence is used to build UI lists (GetQualityValues). Typical implementations return a subset/all of the Level enum entries; may include Level.Custom in some cases. -
public abstract string GetMockName(Level level)
Return a short display name (mock name) for the given Level. Used when composing a UI displayName for dropdown entries. -
public override void SetDefaults()
Base implementation is empty. Subclasses should override to initialize default values for the specific quality setting. -
public DropdownItem<int>[] GetQualityValues()
Build and return an array of DropdownItemrepresenting available quality levels for the UI. Behavior: - Calls EnumerateAvailableLevels() and converts to array.
- For each Level, constructs a DropdownItem
: - displayName = "Options." + level.GetType().Name.ToUpperInvariant() + "[" + GetMockName(level) + "]"
- value = (int)level
- disabled = true when level == Level.Custom (so Custom entries are not selectable in the dropdown)
-
Returns the items as an array. Note: DropdownItem
comes from Game.UI.Widgets. -
internal virtual void AddToPageData(AutomaticSettings.SettingPageData pageData)
Default implementation calls AutomaticSettings.FillSettingsPage(pageData, this). Allows the setting to be added to an automatic settings page; can be overridden for custom behavior. -
public virtual bool IsOptionsDisabled()
Return true if the option should be considered disabled in the options UI. Default behavior: - If IsOptionFullyDisabled() returns true, returns true.
-
Otherwise returns GetLevel() == Level.Disabled.
-
public virtual bool IsOptionFullyDisabled()
Return the value of disableSetting. Can be overridden by subclasses if there is more complex logic to determine a fully disabled state.
Usage Example
// Example concrete implementation of a quality setting
[Preserve]
public class TextureQualitySetting : QualitySetting
{
private Level current = Level.Medium;
public override Level GetLevel()
{
return current;
}
public override void SetLevel(Level quality, bool apply = true)
{
current = quality;
if (apply)
{
// apply changes immediately (implementation-specific)
}
}
public override void TransferValuesFrom(QualitySetting setting)
{
if (setting is TextureQualitySetting s)
{
current = s.current;
}
}
public override IEnumerable<Level> EnumerateAvailableLevels()
{
return new[] { Level.VeryLow, Level.Low, Level.Medium, Level.High, Level.Colossal, Level.Custom };
}
public override string GetMockName(Level level)
{
// Provide short display names used by the UI dropdown label
return level.ToString();
}
public override void SetDefaults()
{
current = Level.Medium;
}
}
Notes and implementation hints: - GetQualityValues() constructs displayName strings in the format "Options.[TYPE][mockName]". Ensure GetMockName returns concise, localized-friendly text if localization is required. - Level.Custom is emitted but marked disabled in the dropdown by default; concrete implementations can override this behavior if custom selection should be allowed. - Attributes on disableSetting ([Exclude], [IgnoreEquals], [SettingsUIHidden]) indicate it is excluded from certain serialization, equality checks and hidden from automatic settings UI; respect these in serialization and UI code.