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 Jan 23, 2021
2 parents 5953fc3 + 733750f commit d0dc3ea
Show file tree
Hide file tree
Showing 105 changed files with 1,513 additions and 414 deletions.
12 changes: 10 additions & 2 deletions build/common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!--set properties -->
<PropertyGroup>
<Version>3.8.4</Version>
<Version>3.9.0</Version>
<Product>SMAPI</Product>

<LangVersion>latest</LangVersion>
Expand Down Expand Up @@ -37,16 +37,24 @@
<Copy SourceFiles="$(TargetDir)\TMXTile.dll" DestinationFolder="$(GamePath)\smapi-internal" />
<Copy SourceFiles="@(TranslationFiles)" DestinationFolder="$(GamePath)\smapi-internal\i18n" />
</Target>
<Target Name="CopyDefaultMods" Condition="'$(MSBuildProjectName)' == 'SMAPI.Mods.ConsoleCommands' OR '$(MSBuildProjectName)' == 'SMAPI.Mods.SaveBackup'">

<Target Name="CopyDefaultMods" Condition="'$(MSBuildProjectName)' == 'SMAPI.Mods.ConsoleCommands' OR '$(MSBuildProjectName)' == 'SMAPI.Mods.ErrorHandler' OR '$(MSBuildProjectName)' == 'SMAPI.Mods.SaveBackup'">
<ItemGroup>
<TranslationFiles Include="$(TargetDir)\i18n\*.json" />
</ItemGroup>

<Copy SourceFiles="$(TargetDir)\$(TargetName).dll" DestinationFolder="$(GamePath)\Mods\$(AssemblyName)" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).pdb" DestinationFolder="$(GamePath)\Mods\$(AssemblyName)" Condition="Exists('$(TargetDir)\$(TargetName).pdb')" />
<Copy SourceFiles="$(TargetDir)\manifest.json" DestinationFolder="$(GamePath)\Mods\$(AssemblyName)" />
<Copy SourceFiles="@(TranslationFiles)" DestinationFolder="$(GamePath)\Mods\$(AssemblyName)\i18n" />
</Target>

<Target Name="CopyToolkit" Condition="'$(MSBuildProjectName)' == 'SMAPI.Toolkit' AND $(TargetFramework) == 'net4.5'" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll" DestinationFolder="$(GamePath)\smapi-internal" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).pdb" DestinationFolder="$(GamePath)\smapi-internal" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).xml" DestinationFolder="$(GamePath)\smapi-internal" />
</Target>

<Target Name="CopyToolkitCoreInterfaces" Condition="'$(MSBuildProjectName)' == 'SMAPI.Toolkit.CoreInterfaces' AND $(TargetFramework) == 'net4.5'" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll" DestinationFolder="$(GamePath)\smapi-internal" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).pdb" DestinationFolder="$(GamePath)\smapi-internal" />
Expand Down
18 changes: 10 additions & 8 deletions build/find-game-folder.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@
</When>
<When Condition="$(OS) == 'Windows_NT'">
<PropertyGroup>
<!-- registry paths -->
<GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\GOG.com\Games\1453375253', 'PATH', null, RegistryView.Registry32))</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150', 'InstallLocation', null, RegistryView.Registry64, RegistryView.Registry32))</GamePath>

<!-- derive from Steam library path -->
<_SteamLibraryPath>$([MSBuild]::GetRegistryValueFromView('HKEY_CURRENT_USER\SOFTWARE\Valve\Steam', 'SteamPath', null, RegistryView.Registry32))</_SteamLibraryPath>
<GamePath Condition="!Exists('$(GamePath)') AND '$(_SteamLibraryPath)' != ''">$(_SteamLibraryPath)\steamapps\common\Stardew Valley</GamePath>

<!-- default paths -->
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files\GalaxyClient\Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files\GOG Galaxy\Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files\GOG Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files\Steam\steamapps\common\Stardew Valley</GamePath>

<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GOG Galaxy\Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GOG Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley</GamePath>

<!-- registry paths -->
<GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\GOG.com\Games\1453375253', 'PATH', null, RegistryView.Registry32))</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150', 'InstallLocation', null, RegistryView.Registry64, RegistryView.Registry32))</GamePath>

<!-- derive from Steam library path -->
<_SteamLibraryPath>$([MSBuild]::GetRegistryValueFromView('HKEY_CURRENT_USER\SOFTWARE\Valve\Steam', 'SteamPath', null, RegistryView.Registry32))</_SteamLibraryPath>
<GamePath Condition="!Exists('$(GamePath)') AND '$(_SteamLibraryPath)' != ''">$(_SteamLibraryPath)\steamapps\common\Stardew Valley</GamePath>
</PropertyGroup>
</When>
</Choose>
Expand Down
6 changes: 6 additions & 0 deletions build/prepare-install-package.targets
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
<SmapiBin>$(BuildRootPath)\SMAPI\bin\$(Configuration)</SmapiBin>
<ToolkitBin>$(BuildRootPath)\SMAPI.Toolkit\bin\$(Configuration)\net4.5</ToolkitBin>
<ConsoleCommandsBin>$(BuildRootPath)\SMAPI.Mods.ConsoleCommands\bin\$(Configuration)</ConsoleCommandsBin>
<ErrorHandlerBin>$(BuildRootPath)\SMAPI.Mods.ErrorHandler\bin\$(Configuration)</ErrorHandlerBin>
<SaveBackupBin>$(BuildRootPath)\SMAPI.Mods.SaveBackup\bin\$(Configuration)</SaveBackupBin>

<PackagePath>$(OutRootPath)\SMAPI installer</PackagePath>
<PackageDevPath>$(OutRootPath)\SMAPI installer for developers</PackageDevPath>
</PropertyGroup>
<ItemGroup>
<TranslationFiles Include="$(SmapiBin)\i18n\*.json" />
<ErrorHandlerTranslationFiles Include="$(ErrorHandlerBin)\i18n\*.json" />
</ItemGroup>

<!-- reset package directory -->
Expand Down Expand Up @@ -64,6 +66,10 @@
<Copy SourceFiles="$(ConsoleCommandsBin)\ConsoleCommands.dll" DestinationFolder="$(PackagePath)\bundle\Mods\ConsoleCommands" />
<Copy SourceFiles="$(ConsoleCommandsBin)\ConsoleCommands.pdb" DestinationFolder="$(PackagePath)\bundle\Mods\ConsoleCommands" />
<Copy SourceFiles="$(ConsoleCommandsBin)\manifest.json" DestinationFolder="$(PackagePath)\bundle\Mods\ConsoleCommands" />
<Copy SourceFiles="$(ErrorHandlerBin)\ErrorHandler.dll" DestinationFolder="$(PackagePath)\bundle\Mods\ErrorHandler" />
<Copy SourceFiles="$(ErrorHandlerBin)\ErrorHandler.pdb" DestinationFolder="$(PackagePath)\bundle\Mods\ErrorHandler" />
<Copy SourceFiles="$(ErrorHandlerBin)\manifest.json" DestinationFolder="$(PackagePath)\bundle\Mods\ErrorHandler" />
<Copy SourceFiles="@(ErrorHandlerTranslationFiles)" DestinationFolder="$(PackagePath)\bundle\Mods\ErrorHandler\i18n" />
<Copy SourceFiles="$(SaveBackupBin)\SaveBackup.dll" DestinationFolder="$(PackagePath)\bundle\Mods\SaveBackup" />
<Copy SourceFiles="$(SaveBackupBin)\SaveBackup.pdb" DestinationFolder="$(PackagePath)\bundle\Mods\SaveBackup" />
<Copy SourceFiles="$(SaveBackupBin)\manifest.json" DestinationFolder="$(PackagePath)\bundle\Mods\SaveBackup" />
Expand Down
40 changes: 40 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,46 @@
* Migrated to Harmony 2.0 (see [_migrate to Harmony 2.0_](https://stardewvalleywiki.com/Modding:Migrate_to_Harmony_2.0) for more info).
-->

## 3.9
Released 22 January 2021 for Stardew Valley 1.5.4 or later.

* For players:
* Updated for Stardew Valley 1.5.4.
* Improved game detection in the installer:
* The installer now prefers paths registered by Steam or GOG Galaxy.
* The installer now detects default manual GOG installs.
* Added clearer error text for empty mod folders created by Vortex.
* Fixed the game's map changes not always reapplied correctly after mods change certain maps, which caused issues like the community center resetting to its non-repaired texture.
* Fixed compatibility for very old content packs which still load maps from `.xnb` files. These were broken by map loading changes in Stardew Valley 1.5, but SMAPI now corrects them automatically.
* Fixed some broken mods incorrectly listed as XNB mods under 'skipped mods'.

* For modders:
* Added new input APIs:
* Added an [API for multi-key bindings](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Input#KeybindList).
* Added a new [`Input.ButtonsChanged` event](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Events#Input.ButtonsChanged).
* Added a `buttonState.IsDown()` extension.
* Added a `helper.Input.SuppressActiveKeybinds` method to suppress the active buttons in a keybind list.
* Improved multiplayer APIs:
* `PerScreen<T>` now lets you get/set the value for any screen, get all active values, or clear all values.
* Peer data from the multiplayer API/events now includes `IsSplitScreen` and `ScreenID` fields.
* Fixed network messages through the multiplayer API being sent to players who don't have SMAPI installed in some cases.
* Improved asset propagation:
* Updated map propagation for the changes in Stardew Valley 1.5.4.
* Added propagation for some `Strings\StringsFromCSFiles` keys (mainly short day names).
* Fixed quarry bridge not fixed if the mountain map was reloaded.
* Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This prevents older mods from loading, but bypasses a Visual Studio crash when debugging.
* Game errors shown in the chatbox are now logged.
* Moved vanilla error-handling into a new Error Handler mod. This simplifies the core SMAPI logic, and lets users disable it if needed.

* For the Console Commands mod:
* Removed the `inf` option for `player_sethealth`, `player_setmoney`, and `player_setstamina`. You can use mods like [CJB Cheats Menu](https://www.nexusmods.com/stardewvalley/mods/4) instead for that.

* For the Error Handler mod:
* Added a detailed message for the _Input string was not in a correct format_ error when the game fails to parse an item text description.

* For the web UI:
* Fixed JSON validator incorrectly marking some manifest update keys as invalid.

## 3.8.4
Released 15 January 2021 for Stardew Valley 1.5.3 or later.

Expand Down
3 changes: 2 additions & 1 deletion src/SMAPI.Installer/InteractiveInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ internal class InteractiveInstaller
/// <summary>The mod IDs which the installer should allow as bundled mods.</summary>
private readonly string[] BundledModIDs = {
"SMAPI.SaveBackup",
"SMAPI.ConsoleCommands"
"SMAPI.ConsoleCommands",
"SMAPI.ErrorHandler"
};

/// <summary>Get the absolute file or folder paths to remove when uninstalling SMAPI.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
{
/// <summary>The base implementation for a trainer command.</summary>
internal abstract class TrainerCommand : ITrainerCommand
/// <summary>The base implementation for a console command.</summary>
internal abstract class ConsoleCommand : IConsoleCommand
{
/*********
** Accessors
Expand Down Expand Up @@ -50,7 +50,7 @@ public virtual void OnButtonPressed(IMonitor monitor, SButton button) { }
/// <param name="description">The command description.</param>
/// <param name="mayNeedInput">Whether the command may need to perform logic when the player presses a button.</param>
/// <param name="mayNeedUpdate">Whether the command may need to perform logic when the game updates.</param>
protected TrainerCommand(string name, string description, bool mayNeedInput = false, bool mayNeedUpdate = false)
protected ConsoleCommand(string name, string description, bool mayNeedInput = false, bool mayNeedUpdate = false)
{
this.Name = name;
this.Description = description;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
{
/// <summary>A console command to register.</summary>
internal interface ITrainerCommand
internal interface IConsoleCommand
{
/*********
** Accessors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which runs one of the game's save migrations.</summary>
internal class ApplySaveFixCommand : TrainerCommand
internal class ApplySaveFixCommand : ConsoleCommand
{
/*********
** Public methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which sends a debug command to the game.</summary>
internal class DebugCommand : TrainerCommand
internal class DebugCommand : ConsoleCommand
{
/*********
** Public methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which shows the data files.</summary>
internal class ShowDataFilesCommand : TrainerCommand
internal class ShowDataFilesCommand : ConsoleCommand
{
/*********
** Public methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which shows the game files.</summary>
internal class ShowGameFilesCommand : TrainerCommand
internal class ShowGameFilesCommand : ConsoleCommand
{
/*********
** Public methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which logs the keys being pressed for 30 seconds once enabled.</summary>
internal class TestInputCommand : TrainerCommand
internal class TestInputCommand : ConsoleCommand
{
/*********
** Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which adds an item to the player inventory.</summary>
internal class AddCommand : TrainerCommand
internal class AddCommand : ConsoleCommand
{
/*********
** Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which list item types.</summary>
internal class ListItemTypesCommand : TrainerCommand
internal class ListItemTypesCommand : ConsoleCommand
{
/*********
** Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which list items available to spawn.</summary>
internal class ListItemsCommand : TrainerCommand
internal class ListItemsCommand : ConsoleCommand
{
/*********
** Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the color of a player feature.</summary>
internal class SetColorCommand : TrainerCommand
internal class SetColorCommand : ConsoleCommand
{
/*********
** Public methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's current health.</summary>
internal class SetHealthCommand : TrainerCommand
internal class SetHealthCommand : ConsoleCommand
{
/*********
** Fields
*********/
/// <summary>Whether to keep the player's health at its maximum.</summary>
private bool InfiniteHealth;


/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public SetHealthCommand()
: base("player_sethealth", "Sets the player's health.\n\nUsage: player_sethealth [value]\n- value: an integer amount, or 'inf' for infinite health.", mayNeedUpdate: true) { }
: base("player_sethealth", "Sets the player's health.\n\nUsage: player_sethealth [value]\n- value: an integer amount.") { }

/// <summary>Handle the command.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
Expand All @@ -29,36 +22,19 @@ public override void Handle(IMonitor monitor, string command, ArgumentParser arg
// no-argument mode
if (!args.Any())
{
monitor.Log($"You currently have {(this.InfiniteHealth ? "infinite" : Game1.player.health.ToString())} health. Specify a value to change it.", LogLevel.Info);
monitor.Log($"You currently have {Game1.player.health} health. Specify a value to change it.", LogLevel.Info);
return;
}

// handle
string amountStr = args[0];
if (amountStr == "inf")
if (int.TryParse(amountStr, out int amount))
{
this.InfiniteHealth = true;
monitor.Log("OK, you now have infinite health.", LogLevel.Info);
Game1.player.health = amount;
monitor.Log($"OK, you now have {Game1.player.health} health.", LogLevel.Info);
}
else
{
this.InfiniteHealth = false;
if (int.TryParse(amountStr, out int amount))
{
Game1.player.health = amount;
monitor.Log($"OK, you now have {Game1.player.health} health.", LogLevel.Info);
}
else
this.LogArgumentNotInt(monitor);
}
}

/// <summary>Perform any logic needed on update tick.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
public override void OnUpdated(IMonitor monitor)
{
if (this.InfiniteHealth && Context.IsWorldReady)
Game1.player.health = Game1.player.maxHealth;
this.LogArgumentNotInt(monitor);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's current immunity.</summary>
internal class SetImmunityCommand : TrainerCommand
internal class SetImmunityCommand : ConsoleCommand
{
/*********
** Public methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's maximum health.</summary>
internal class SetMaxHealthCommand : TrainerCommand
internal class SetMaxHealthCommand : ConsoleCommand
{
/*********
** Public methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's maximum stamina.</summary>
internal class SetMaxStaminaCommand : TrainerCommand
internal class SetMaxStaminaCommand : ConsoleCommand
{
/*********
** Public methods
Expand Down
Loading

0 comments on commit d0dc3ea

Please sign in to comment.