From 532235ef10525a8d2997a512b0b0acb408db2fb8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 4 Nov 2016 16:12:09 -0400 Subject: format & document constants --- src/StardewModdingAPI/Constants.cs | 57 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'src/StardewModdingAPI') diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs index c6aa40f5..b9501ad8 100644 --- a/src/StardewModdingAPI/Constants.cs +++ b/src/StardewModdingAPI/Constants.cs @@ -5,56 +5,59 @@ using StardewValley; namespace StardewModdingAPI { - /// - /// Static class containing readonly values. - /// + /// Contains SMAPI's constants and assumptions. public static class Constants { + /********* + ** Properties + *********/ + /// The directory name containing the current save's data (if a save is loaded). + private static string RawSaveFolderName => Constants.PlayerNull ? string.Empty : $"{Game1.player.name.RemoveNumerics()}_{Game1.uniqueIDForThisGame}"; + + /// The directory path containing the current save's data (if a save is loaded). + private static string RawSavePath => Constants.PlayerNull ? string.Empty : Path.Combine(Constants.SavesPath, Constants.RawSaveFolderName); + + + /********* + ** Accessors + *********/ /// SMAPI's current semantic version. public static readonly Version Version = new Version(1, 0, 0, $"alpha-{DateTime.UtcNow.ToString("yyyyMMddHHmm")}"); /// The GitHub repository to check for updates. public const string GitHubRepository = "cjsu/SMAPI"; - /// - /// Not quite "constant", but it makes more sense for it to be here, at least for now - /// + /// The number of mods currently loaded by SMAPI. public static int ModsLoaded = 0; - /// - /// Stardew Valley's roaming app data location. - /// %AppData%//StardewValley - /// + /// The directory path containing Stardew Valley's app data. public static string DataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley"); - public static string SavesPath => Path.Combine(DataPath, "Saves"); + /// The directory path where all saves are stored. + public static string SavesPath => Path.Combine(Constants.DataPath, "Saves"); - private static string saveFolderName => PlayerNull ? string.Empty : Game1.player.name.RemoveNumerics() + "_" + Game1.uniqueIDForThisGame; - public static string SaveFolderName => CurrentSavePathExists ? saveFolderName : ""; + /// Whether the directory containing the current save's data exists on disk. + public static bool CurrentSavePathExists => Directory.Exists(Constants.RawSavePath); - private static string currentSavePath => PlayerNull ? string.Empty : Path.Combine(SavesPath, saveFolderName); - public static string CurrentSavePath => CurrentSavePathExists ? currentSavePath : ""; + /// The directory name containing the current save's data (if a save is loaded and the directory exists). + public static string SaveFolderName => Constants.CurrentSavePathExists ? Constants.RawSaveFolderName : ""; - public static bool CurrentSavePathExists => Directory.Exists(currentSavePath); + /// The directory path containing the current save's data (if a save is loaded and the directory exists). + public static string CurrentSavePath => Constants.CurrentSavePathExists ? Constants.RawSavePath : ""; + /// Whether a player save has been loaded. public static bool PlayerNull => !Game1.hasLoadedGame || Game1.player == null || string.IsNullOrEmpty(Game1.player.name); - /// - /// Execution path to execute the code. - /// + /// The path to the current assembly being executing. public static string ExecutionPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - /// - /// Title for the API console - /// + /// The title of the SMAPI console window. public static string ConsoleTitle => $"Stardew Modding API Console - Version {Constants.Version} - Mods Loaded: {Constants.ModsLoaded}"; - /// - /// Path for log files to be output to. - /// %LocalAppData%//StardewValley//ErrorLogs - /// + /// The directory path in which error logs should be stored. public static string LogDir => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "ErrorLogs"); - public static string LogPath => Path.Combine(LogDir, "MODDED_ProgramLog.Log_LATEST.txt"); + /// The file path to the error log where the latest output should be saved. + public static string LogPath => Path.Combine(Constants.LogDir, "MODDED_ProgramLog.Log_LATEST.txt"); } } \ No newline at end of file -- cgit