Skip to content

Game.UI.Menu.MenuHelpers

Assembly:
Game (inferred)

Namespace:
Game.UI.Menu

Type:
public static class

Base:
System.Object

Summary:
Utility helpers used by the game's UI menu code. Provides constants and helpers for save-game preview sizing and default assets, interrogation of available cloud storage targets, and methods to populate UI bindings with asset metadata. Also contains a nested helper type SaveGamePreviewSettings which encapsulates settings used to build or serialize a save-game preview (stylized rendering, radius, and an optional overlay image).


Fields

  • private static Colossal.Logging.ILog log
    Logger instance (initialized with LogManager.GetLogger("SceneFlow")). Used to report warnings and errors that occur while scanning or processing assets.

  • public const int kPreviewWidth
    Constant preview width used by the UI (680).

  • public const int kPreviewHeight
    Constant preview height used by the UI (383).

Properties

  • public static TextureAsset defaultPreview { get; }
    Provides the default preview TextureAsset used when a save-game preview is not available. This is resolved from AssetDatabase.game using the embedded asset GUID ("cc1e5421d5a16f15bbd580cffdbee7d4").

  • public static TextureAsset defaultThumbnail { get; }
    Provides the default thumbnail TextureAsset used when a save-game thumbnail is not available. Resolved from AssetDatabase.game using the embedded asset GUID ("735aa687f0dd7cda5e7d1aa4c4987b26").

  • public static bool hasPreviouslySavedGame { get; }
    A convenience boolean that checks the GameManager's userState for a lastSaveGameMetadata and returns whether it represents a valid save game.

Constructors

  • (static class — no constructors)
    MenuHelpers is declared static and therefore has no public instance constructors. Its members are accessed statically.

Methods

  • public static SaveGameMetadata GetLastModifiedSave()
    Scans all SaveGameMetadata assets in the global asset database and returns the SaveGameMetadata whose target.lastModified timestamp is the most recent. Returns null if none found. Useful for pre-selecting or displaying the most recently modified save.

  • public static void UpdateMeta<T>(ValueBinding<List<T>> binding, Func<Metadata<T>, bool> filter = null) where T : IContentPrerequisite
    Populates the provided ValueBinding> with the targets of Metadata assets found in the global asset database. If an optional filter is provided, only assets for which filter(metadata) returns true are added. Clears the existing list, adds matches, and triggers the binding update. Exceptions thrown while inspecting assets are caught and logged (using the class logger) so a single bad asset won't break the whole update.

  • public static List<string> GetAvailableCloudTargets()
    Returns a list of human-readable names for available remote storage targets (cloud providers and local) fetched from AssetDatabase.global.GetAvailableRemoteStorages(). Handy for populating a dropdown of storage targets in the UI.

  • public static (string name, ILocalAssetDatabase db) GetSanitizedCloudTarget(string cloudTarget)
    Given a desired cloud target name, returns a matching (name, db) tuple from the available remote storages. If an exact match is not found, but a remote storage named "Local" exists, returns the Local storage as a fallback. If neither match nor Local exist, returns the default empty tuple. This ensures callers always receive a usable storage target when possible.

  • Nested type: SaveGamePreviewSettings

  • public SaveGamePreviewSettings()
    Constructor — initializes an instance and calls SetDefaults().

  • public void SetDefaults()
    Resets all preview settings to defaults: stylized = false, stylizedRadius = 0f, overlayImage = null.

  • public void FromUri(UrlQuery query)
    Populates settings from a UrlQuery (query parameters). Reads "stylized" (bool), "stylizedRadius" (float), and attempts to read an asset "overlayImage" as TextureAsset via query.ReadAsset(). If present, sets the corresponding properties.

  • public string ToUri()
    Serializes the current settings into a query string fragment like "stylized=True&stylizedRadius=0.5&overlayImage={guid}". Uses overlayImage?.id.guid to include the asset GUID when present.

Usage Example

// Construct and use SaveGamePreviewSettings
var settings = new MenuHelpers.SaveGamePreviewSettings();
settings.SetDefaults();
settings.stylized = true;
settings.stylizedRadius = 120f;

// Serialize to a query string to store or share the preview settings
string uri = settings.ToUri();

// Example: update a UI binding with all available District styles (T is an example type)
ValueBinding<List<SomeAssetType>> binding = ...; // obtained from UI binding system
MenuHelpers.UpdateMeta(binding, metadata => metadata.target.IsApplicableToCurrentGameMode());