blob: b9501ad83492ba01d26c0f31145feb824a6a8209 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
using System;
using System.IO;
using System.Reflection;
using StardewValley;
namespace StardewModdingAPI
{
/// <summary>Contains SMAPI's constants and assumptions.</summary>
public static class Constants
{
/*********
** Properties
*********/
/// <summary>The directory name containing the current save's data (if a save is loaded).</summary>
private static string RawSaveFolderName => Constants.PlayerNull ? string.Empty : $"{Game1.player.name.RemoveNumerics()}_{Game1.uniqueIDForThisGame}";
/// <summary>The directory path containing the current save's data (if a save is loaded).</summary>
private static string RawSavePath => Constants.PlayerNull ? string.Empty : Path.Combine(Constants.SavesPath, Constants.RawSaveFolderName);
/*********
** Accessors
*********/
/// <summary>SMAPI's current semantic version.</summary>
public static readonly Version Version = new Version(1, 0, 0, $"alpha-{DateTime.UtcNow.ToString("yyyyMMddHHmm")}");
/// <summary>The GitHub repository to check for updates.</summary>
public const string GitHubRepository = "cjsu/SMAPI";
/// <summary>The number of mods currently loaded by SMAPI.</summary>
public static int ModsLoaded = 0;
/// <summary>The directory path containing Stardew Valley's app data.</summary>
public static string DataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley");
/// <summary>The directory path where all saves are stored.</summary>
public static string SavesPath => Path.Combine(Constants.DataPath, "Saves");
/// <summary>Whether the directory containing the current save's data exists on disk.</summary>
public static bool CurrentSavePathExists => Directory.Exists(Constants.RawSavePath);
/// <summary>The directory name containing the current save's data (if a save is loaded and the directory exists).</summary>
public static string SaveFolderName => Constants.CurrentSavePathExists ? Constants.RawSaveFolderName : "";
/// <summary>The directory path containing the current save's data (if a save is loaded and the directory exists).</summary>
public static string CurrentSavePath => Constants.CurrentSavePathExists ? Constants.RawSavePath : "";
/// <summary>Whether a player save has been loaded.</summary>
public static bool PlayerNull => !Game1.hasLoadedGame || Game1.player == null || string.IsNullOrEmpty(Game1.player.name);
/// <summary>The path to the current assembly being executing.</summary>
public static string ExecutionPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
/// <summary>The title of the SMAPI console window.</summary>
public static string ConsoleTitle => $"Stardew Modding API Console - Version {Constants.Version} - Mods Loaded: {Constants.ModsLoaded}";
/// <summary>The directory path in which error logs should be stored.</summary>
public static string LogDir => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "ErrorLogs");
/// <summary>The file path to the error log where the latest output should be saved.</summary>
public static string LogPath => Path.Combine(Constants.LogDir, "MODDED_ProgramLog.Log_LATEST.txt");
}
}
|