update for load-game changes in 1.6.9 build 24277

This commit is contained in:
Jesse Plamondon-Willard
2024-10-02 19:02:33 -04:00
parent e2d3ffb4d6
commit d9a46f64be
3 changed files with 22 additions and 9 deletions
+3
View File
@@ -67,6 +67,9 @@ namespace StardewModdingAPI
/// <summary>The minimum supported version of Stardew Valley.</summary>
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.6.9");
/// <summary>The minimum supported Stardew Valley build number, or <c>null</c> for any build of <see cref="MinimumGameVersion"/>.</summary>
public static int? MinimumGameBuild { get; } = 24277;
/// <summary>The maximum supported version of Stardew Valley, if any.</summary>
public static ISemanticVersion? MaximumGameVersion { get; } = null;
+8 -5
View File
@@ -665,14 +665,15 @@ namespace StardewModdingAPI.Framework
if (Game1.currentLoader != null)
{
this.Monitor.Log("Game loader synchronizing...", Monitor.ContextLogLevel);
Game1.game1.UpdateTitleScreen(Game1.currentGameTime); // run game logic to change music on load, etc
// ReSharper disable once ConstantConditionalAccessQualifier -- may become null within the loop
while (Game1.currentLoader?.MoveNext() == true)
while (true)
{
Game1.game1.UpdateTitleScreenDuringLoadingMode();
SCore.ProcessTicksElapsed++;
// raise load stage changed
switch (Game1.currentLoader.Current)
int? step = Game1.currentLoader?.Current;
switch (step)
{
case 20 when (!saveParsed && SaveGame.loaded != null):
saveParsed = true;
@@ -692,9 +693,11 @@ namespace StardewModdingAPI.Framework
this.OnLoadStageChanged(LoadStage.Preloaded);
break;
}
if (step is null)
break; // done
}
Game1.currentLoader = null;
this.Monitor.Log("Game loader done.", Monitor.ContextLogLevel);
}
+11 -4
View File
@@ -8,6 +8,7 @@ using System.Threading;
using StardewModdingAPI.Framework;
using StardewModdingAPI.Toolkit.Serialization.Models;
using StardewModdingAPI.Toolkit.Utilities;
using StardewValley;
namespace StardewModdingAPI
{
@@ -123,16 +124,22 @@ namespace StardewModdingAPI
}
}
/// <summary>Assert that the game version is within <see cref="Constants.MinimumGameVersion"/> and <see cref="Constants.MaximumGameVersion"/>.</summary>
/// <summary>Assert that the game version is within <see cref="Constants.MinimumGameVersion"/>, <see cref="Constants.MinimumGameBuild"/>, and <see cref="Constants.MaximumGameVersion"/>.</summary>
private static void AssertGameVersion()
{
// min version
if (Constants.GameVersion.IsOlderThan(Constants.MinimumGameVersion))
int? minBuild = Constants.MinimumGameBuild;
if (Constants.GameVersion.IsOlderThan(Constants.MinimumGameVersion) || (minBuild.HasValue && Game1.versionBuildNumber < minBuild))
{
ISemanticVersion? suggestedApiVersion = Constants.GetCompatibleApiVersion(Constants.GameVersion);
string errorPhrase = minBuild.HasValue && Constants.GameVersion.CompareTo(Constants.MinimumGameVersion) == 0
? $"You're running Stardew Valley {Constants.GameVersion} build {Game1.versionBuildNumber}, but the oldest supported version is build {minBuild}."
: $"You're running Stardew Valley {Constants.GameVersion}, but the oldest supported version is {Constants.MinimumGameVersion}.";
Program.PrintErrorAndExit(suggestedApiVersion != null
? $"Oops! You're running Stardew Valley {Constants.GameVersion}, but the oldest supported version is {Constants.MinimumGameVersion}. You can install SMAPI {suggestedApiVersion} instead to fix this error, or update your game to the latest version."
: $"Oops! You're running Stardew Valley {Constants.GameVersion}, but the oldest supported version is {Constants.MinimumGameVersion}. Please update your game before using SMAPI."
? $"Oops! {errorPhrase} You can install SMAPI {suggestedApiVersion} instead to fix this error, or update your game to the latest version."
: $"Oops! {errorPhrase} Please update your game before using SMAPI."
);
}