Skip to content

Game.PSI.PdxSdk.Launcher

Assembly: Game
Namespace: Game.PSI.PdxSdk

Type: static class

Base: System.Object

Summary:
Utility launcher helper used by the game's UI/launcher to save and delete metadata about the last played save (the "continue" game). It formats localized display strings (population, money), assembles a small metadata object (title, description, ISO timestamp, game version) and writes it as JSON to a well-known file in the user data path (continue_game.json). Errors during save are caught and logged. The class contains two nested helper types: LocaleID (localization key constants) and SaveInfoData (shape of the serialized metadata).


Fields

  • private const string kLastSaveInfoFileName = "continue_game.json"
    Helper constant holding the filename used for the saved metadata file.

  • private static readonly string kLastSaveInfoPath
    Absolute path (EnvPath.kUserDataPath + "/continue_game.json") where the metadata JSON is written. Initialized at class load time.

  • (Nested type) internal static class LocaleID
    Contains localization key constants used by the class: kPopulation / kPopulationID, kMoney / kMoneyID, kMoneyValue / kMoneyValueID, kUnlimitedMoney / kUnlimitedMoneyID. These keys are used with the game's localization manager to produce localized labels and values (e.g., "Population", "Money", "Unlimited", money formatting template).

  • (Nested type) private class SaveInfoData
    Simple DTO used for JSON serialization. Fields: title, desc, date, rawGameVersion. Instances are serialized via Colossal.Json.JSON.Dump.

Properties

  • None. This is a static helper class with no exposed properties.

Constructors

  • None (static class). The type has no public or instance constructors.

Methods

  • private static string LocalizedString(string id, string def)
    Fetches a localized string from GameManager.instance.localizationManager.activeDictionary using the given id. If the id is not present, returns the supplied default string. Used to produce user-facing labels and templates.

  • private static string FormatMoney(int money, bool unlimitedMoney)
    Returns a localized, display-ready string for the save's money value. If unlimitedMoney is true, returns the localized "Unlimited" label. Otherwise formats using the game's money template (attempting to use localization key "Common.VALUE_MONEY" with fallback "{0}ยข{1}"); it handles sign and uses math.sign to decide prefix.

  • public static void SaveLastSaveMetadata(SaveInfo saveInfo)
    Creates a SaveInfoData instance populated from the supplied SaveInfo (cityName, population, money, options, lastModified, etc.), builds a short description string (localized "Population" and "Money" labels + formatted money value), sets the ISO timestamp (ToString("s")), and writes JSON to kLastSaveInfoPath using JSON.Dump. Exceptions are caught and logged with UnityEngine.Debug.LogException.

  • public static void DeleteLastSaveMetadata()
    Deletes the continue_game.json file at kLastSaveInfoPath if it exists. No exception handling is performed here (File.Exists check precedes deletion).

Usage Example

// Example: save metadata for a SaveInfo before returning to main menu
// Assumes `saveInfo` is a valid Game.SaveInfo instance available in context.

Game.PSI.PdxSdk.Launcher.SaveLastSaveMetadata(saveInfo);

// Example: delete the saved metadata (e.g., when no continue should be shown)
Game.PSI.PdxSdk.Launcher.DeleteLastSaveMetadata();