Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed Apr 18, 2024
2 parents 8fda772 + a16d70a commit a284d86
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 139 deletions.
2 changes: 1 addition & 1 deletion build/common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repo. It imports the other MSBuild files as needed.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--set general build properties -->
<Version>4.0.6</Version>
<Version>4.0.7</Version>
<Product>SMAPI</Product>
<LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
Expand Down
19 changes: 17 additions & 2 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
[README](README.md)

# Release notes
## 4.0.7
Released 18 April 2024 for Stardew Valley 1.6.4 or later.

* For players:
* Updated for Stardew Valley 1.6.4. **This drops compatibility with Stardew Valley 1.6.0–1.6.3.**
* The installer now lists detected game folders with an incompatible version to simplify troubleshooting.
* When the installer asks for a game folder path, entering an incorrect path to a file inside it will now still select the folder.
* Fixed installer not detecting 1.6 compatibility branch.

* For the web UI:
* Updated `manifest.json` JSON schema for the new `MinimumGameVersion` field (thanks to KhloeLeclair!).

* For external tool authors:
* In the SMAPI toolkit, added a new `GetGameFoldersIncludingInvalid()` method to get all detected game folders and their validity type.

## 4.0.6
Released 07 April 2024 for Stardew Valley 1.6.0 or later.

* For player:
* For players:
* The SMAPI log file now includes installed mod IDs, to help with troubleshooting (thanks to DecidedlyHuman!).

* For mod authors:
Expand All @@ -14,7 +29,7 @@ Released 07 April 2024 for Stardew Valley 1.6.0 or later.
Released 06 April 2024 for Stardew Valley 1.6.0 or later.

* For players:
* The installer now deletes obsolete files from very old SMAPI versions again.
* The installer now deletes obsolete files from very old SMAPI versions again. (This was removed in SMAPI 4.0, but many players still had very old versions.)
* The installer now deletes Error Handler automatically if it's at the default path.
* Fixed mods sometimes not applying logic inside new buildings.
* Minor optimizations.
Expand Down
7 changes: 0 additions & 7 deletions src/SMAPI.Installer/Framework/InstallerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ public ISemanticVersion GetInstallerVersion()
return new SemanticVersion(raw);
}

/// <summary>Get whether a folder seems to contain the game files.</summary>
/// <param name="dir">The folder to check.</param>
public bool LooksLikeGameFolder(DirectoryInfo dir)
{
return this.GameScanner.LooksLikeGameFolder(dir);
}

/// <summary>Get whether a folder seems to contain the game, and which version it contains if so.</summary>
/// <param name="dir">The folder to check.</param>
public GameFolderType GetGameFolderType(DirectoryInfo dir)
Expand Down
113 changes: 66 additions & 47 deletions src/SMAPI.Installer/InteractiveInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,48 +695,50 @@ private string InteractivelyChoose(string message, string[] options, string inde
return null;
}

switch (context.GetGameFolderType(dir))
GameFolderType type = context.GetGameFolderType(dir);
switch (type)
{
case GameFolderType.Valid:
return dir;

case GameFolderType.Legacy154OrEarlier:
this.PrintWarning($"{errorPrefix} that directory seems to have Stardew Valley 1.5.4 or earlier.");
this.PrintWarning("Please update your game to the latest version to use SMAPI.");
return null;

case GameFolderType.LegacyCompatibilityBranch:
this.PrintWarning($"{errorPrefix} that directory seems to have the Stardew Valley legacy 'compatibility' branch.");
this.PrintWarning("Unfortunately SMAPI is only compatible with the modern version of the game.");
this.PrintWarning("Please update your game to the main branch to use SMAPI.");
return null;

case GameFolderType.NoGameFound:
this.PrintWarning($"{errorPrefix} that directory doesn't contain a Stardew Valley executable.");
return null;

default:
this.PrintWarning($"{errorPrefix} that directory doesn't seem to contain a valid game install.");
foreach (string message in this.GetInvalidFolderWarning(type))
this.PrintWarning(message);
return null;
}
}

// get valid install paths & log invalid ones
List<DirectoryInfo> defaultPaths = new();
foreach ((DirectoryInfo dir, GameFolderType type) in this.DetectGameFolders(toolkit, context))
{
if (type is GameFolderType.Valid)
{
defaultPaths.Add(dir);
continue;
}

this.PrintDebug($"Ignored game folder: {dir.FullName}");
foreach (string message in this.GetInvalidFolderWarning(type))
this.PrintDebug(message);
this.PrintDebug("\n");
}

// let user choose detected path
DirectoryInfo[] defaultPaths = this.DetectGameFolders(toolkit, context).ToArray();
if (defaultPaths.Any())
{
this.PrintInfo("Where do you want to add or remove SMAPI?");
Console.WriteLine();
for (int i = 0; i < defaultPaths.Length; i++)
for (int i = 0; i < defaultPaths.Count; i++)
this.PrintInfo($"[{i + 1}] {defaultPaths[i].FullName}");
this.PrintInfo($"[{defaultPaths.Length + 1}] Enter a custom game path.");
this.PrintInfo($"[{defaultPaths.Count + 1}] Enter a custom game path.");
Console.WriteLine();

string[] validOptions = Enumerable.Range(1, defaultPaths.Length + 1).Select(p => p.ToString(CultureInfo.InvariantCulture)).ToArray();
string[] validOptions = Enumerable.Range(1, defaultPaths.Count + 1).Select(p => p.ToString(CultureInfo.InvariantCulture)).ToArray();
string choice = this.InteractivelyChoose("Type the number next to your choice, then press enter.", validOptions);
int index = int.Parse(choice, CultureInfo.InvariantCulture) - 1;

if (index < defaultPaths.Length)
if (index < defaultPaths.Count)
return defaultPaths[index];
}
else
Expand Down Expand Up @@ -766,9 +768,9 @@ private string InteractivelyChoose(string message, string[] options, string inde
}

// get directory
if (File.Exists(path))
path = Path.GetDirectoryName(path)!;
DirectoryInfo directory = new(path);
if (!directory.Exists && (path.EndsWith(".dll") || path.EndsWith(".exe") || File.Exists(path)) && directory.Parent is { Exists: true })
directory = directory.Parent;

// validate path
if (!directory.Exists)
Expand All @@ -777,29 +779,16 @@ private string InteractivelyChoose(string message, string[] options, string inde
continue;
}

switch (context.GetGameFolderType(directory))
GameFolderType type = context.GetGameFolderType(directory);
switch (type)
{
case GameFolderType.Valid:
this.PrintInfo(" OK!");
return directory;

case GameFolderType.Legacy154OrEarlier:
this.PrintWarning("That directory seems to have Stardew Valley 1.5.4 or earlier.");
this.PrintWarning("Please update your game to the latest version to use SMAPI.");
continue;

case GameFolderType.LegacyCompatibilityBranch:
this.PrintWarning("That directory seems to have the Stardew Valley legacy 'compatibility' branch.");
this.PrintWarning("Unfortunately SMAPI is only compatible with the modern version of the game.");
this.PrintWarning("Please update your game to the main branch to use SMAPI.");
continue;

case GameFolderType.NoGameFound:
this.PrintWarning("That directory doesn't contain a Stardew Valley executable.");
continue;

default:
this.PrintWarning("That directory doesn't seem to contain a valid game install.");
foreach (string message in this.GetInvalidFolderWarning(type))
this.PrintWarning(message);
continue;
}
}
Expand All @@ -808,7 +797,7 @@ private string InteractivelyChoose(string message, string[] options, string inde
/// <summary>Get the possible game paths to update.</summary>
/// <param name="toolkit">The mod toolkit.</param>
/// <param name="context">The installer context.</param>
private IEnumerable<DirectoryInfo> DetectGameFolders(ModToolkit toolkit, InstallerContext context)
private IEnumerable<(DirectoryInfo, GameFolderType)> DetectGameFolders(ModToolkit toolkit, InstallerContext context)
{
HashSet<string> foundPaths = new HashSet<string>();

Expand All @@ -817,10 +806,10 @@ private IEnumerable<DirectoryInfo> DetectGameFolders(ModToolkit toolkit, Install
DirectoryInfo? curPath = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;
while (curPath?.Parent != null) // must be in a folder (not at the root)
{
if (context.LooksLikeGameFolder(curPath))
if (context.GetGameFolderType(curPath) == GameFolderType.Valid)
{
foundPaths.Add(curPath.FullName);
yield return curPath;
yield return (curPath, GameFolderType.Valid);
break;
}

Expand All @@ -829,10 +818,40 @@ private IEnumerable<DirectoryInfo> DetectGameFolders(ModToolkit toolkit, Install
}

// game paths detected by toolkit
foreach (DirectoryInfo dir in toolkit.GetGameFolders())
foreach ((DirectoryInfo, GameFolderType) pair in toolkit.GetGameFoldersIncludingInvalid())
{
if (foundPaths.Add(pair.Item1.FullName))
yield return pair;
}
}

private string[] GetInvalidFolderWarning(GameFolderType type)
{
switch (type)
{
if (foundPaths.Add(dir.FullName))
yield return dir;
case GameFolderType.Valid:
return new[] { "OK!" }; // should never happen

case GameFolderType.LegacyVersion:
return new[]
{
"That directory seems to have Stardew Valley 1.5.6 or earlier.",
"Please update your game to the latest version to use SMAPI."
};

case GameFolderType.LegacyCompatibilityBranch:
return new[]
{
"That directory seems to have the Stardew Valley legacy 'compatibility' branch.",
"Unfortunately SMAPI is only compatible with the modern version of the game.",
"Please update your game to the main branch to use SMAPI."
};

case GameFolderType.NoGameFound:
return new[] { "That directory doesn't contain a Stardew Valley executable." };

default:
return new[] { "That directory doesn't seem to contain a valid game install." };
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ConsoleCommands/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Console Commands",
"Author": "SMAPI",
"Version": "4.0.6",
"Version": "4.0.7",
"Description": "Adds SMAPI console commands that let you manipulate the game.",
"UniqueID": "SMAPI.ConsoleCommands",
"EntryDll": "ConsoleCommands.dll",
"MinimumApiVersion": "4.0.6"
"MinimumApiVersion": "4.0.7"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.SaveBackup/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Save Backup",
"Author": "SMAPI",
"Version": "4.0.6",
"Version": "4.0.7",
"Description": "Automatically backs up all your saves once per day into its folder.",
"UniqueID": "SMAPI.SaveBackup",
"EntryDll": "SaveBackup.dll",
"MinimumApiVersion": "4.0.6"
"MinimumApiVersion": "4.0.7"
}
6 changes: 3 additions & 3 deletions src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public enum GameFolderType
/// <summary>The folder doesn't contain Stardew Valley.</summary>
NoGameFound,

/// <summary>The folder contains Stardew Valley 1.5.4 or earlier. This version uses XNA Framework and 32-bit .NET Framework 4.5.2 on Windows and Mono on Linux/macOS, and isn't compatible with current versions of SMAPI.</summary>
Legacy154OrEarlier,
/// <summary>The folder contains Stardew Valley 1.5.6 or earlier, which isn't compatible with current versions of SMAPI.</summary>
LegacyVersion,

/// <summary>The folder contains Stardew Valley from the game's legacy compatibility branch, which backports newer changes to the <see cref="Legacy154OrEarlier"/> format.</summary>
/// <summary>The folder contains Stardew Valley from the game's legacy compatibility branch, which backports newer changes to the <see cref="LegacyVersion"/> format.</summary>
LegacyCompatibilityBranch,

/// <summary>The folder seems to contain Stardew Valley files, but they failed to load for unknown reasons (e.g. corrupted executable).</summary>
Expand Down
Loading

0 comments on commit a284d86

Please sign in to comment.