Skip to content

Commit 72c87bf

Browse files
authored
Merge pull request #45 from Denifia/develop
Update for Stardew Valley 1.3.36 and SMAPI 3.0, internal refactoring
2 parents 5b72873 + 7155076 commit 72c87bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+479
-726
lines changed

BuyRecipes/BuyRecipes.cs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
using Denifia.Stardew.BuyRecipes.Domain;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Denifia.Stardew.BuyRecipes.Domain;
25
using Denifia.Stardew.BuyRecipes.Framework;
36
using StardewModdingAPI;
47
using StardewModdingAPI.Events;
58
using StardewValley;
6-
using System;
7-
using System.Collections.Generic;
8-
using System.Linq;
99

1010
namespace Denifia.Stardew.BuyRecipes
1111
{
12+
/// <summary>The mod entry class.</summary>
1213
public class BuyRecipes : Mod
1314
{
1415
private bool _savedGameLoaded = false;
1516
private List<CookingRecipe> _cookingRecipes;
1617
private List<CookingRecipe> _thisWeeksRecipes;
1718
private int _seed;
18-
19+
1920
public static List<IRecipeAquisitionConditions> RecipeAquisitionConditions;
2021

22+
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
23+
/// <param name="helper">Provides simplified APIs for writing mods.</param>
2124
public override void Entry(IModHelper helper)
2225
{
23-
SaveEvents.AfterLoad += SaveEvents_AfterLoad;
24-
SaveEvents.AfterReturnToTitle += SaveEvents_AfterReturnToTitle;
25-
TimeEvents.AfterDayStarted += TimeEvents_AfterDayStarted;
26+
helper.Events.GameLoop.SaveLoaded += OnSaveLoaded;
27+
helper.Events.GameLoop.ReturnedToTitle += OnReturnedToTitle;
28+
helper.Events.GameLoop.DayStarted += OnDayStarted;
2629

2730
RecipeAquisitionConditions = new List<IRecipeAquisitionConditions>()
2831
{
@@ -32,14 +35,14 @@ public override void Entry(IModHelper helper)
3235
};
3336

3437
helper.ConsoleCommands
35-
.Add("buyrecipe", $"Buy a recipe. \n\nUsage: buyrecipe \"<name of recipe>\" \n\nNote: This is case sensitive!", HandleCommand)
36-
.Add("showrecipes", $"Lists this weeks available recipes. \n\nUsage: showrecipes", HandleCommand);
38+
.Add("buyrecipe", "Buy a recipe. \n\nUsage: buyrecipe \"<name of recipe>\" \n\nNote: This is case sensitive!", HandleCommand)
39+
.Add("showrecipes", "Lists this weeks available recipes. \n\nUsage: showrecipes", HandleCommand);
3740
//.Add("buyallrecipes", $"Temporary. \n\nUsage: buyallrecipes", HandleCommand);
3841
}
3942

4043
private void HandleCommand(string command, string[] args)
4144
{
42-
args = new List<string>() { string.Join(" ", args) }.ToArray();
45+
args = new List<string> { string.Join(" ", args) }.ToArray();
4346

4447
if (!_savedGameLoaded)
4548
{
@@ -116,21 +119,30 @@ private void BuyRecipe(string[] args, bool checkInWeeklyRecipes = true)
116119
}
117120
}
118121

119-
private void SaveEvents_AfterReturnToTitle(object sender, EventArgs e)
122+
/// <summary>Raised after the game returns to the title screen.</summary>
123+
/// <param name="sender">The event sender.</param>
124+
/// <param name="e">The event arguments.</param>
125+
private void OnReturnedToTitle(object sender, ReturnedToTitleEventArgs e)
120126
{
121127
_savedGameLoaded = false;
122128
_cookingRecipes = null;
123129
_thisWeeksRecipes = null;
124130
}
125-
126-
private void SaveEvents_AfterLoad(object sender, EventArgs e)
131+
132+
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
133+
/// <param name="sender">The event sender.</param>
134+
/// <param name="e">The event arguments.</param>
135+
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
127136
{
128137
_savedGameLoaded = true;
129138
DiscoverRecipes();
130139
GenerateWeeklyRecipes();
131140
}
132141

133-
private void TimeEvents_AfterDayStarted(object sender, EventArgs e)
142+
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
143+
/// <param name="sender">The event sender.</param>
144+
/// <param name="e">The event arguments.</param>
145+
private void OnDayStarted(object sender, DayStartedEventArgs e)
134146
{
135147
GenerateWeeklyRecipes();
136148
}
@@ -190,7 +202,6 @@ private void ShowWeeklyRecipes()
190202

191203
private void DiscoverRecipes()
192204
{
193-
var knownRecipes = Game1.player.cookingRecipes.Keys;
194205
_cookingRecipes = new List<CookingRecipe>();
195206
foreach (var recipe in CraftingRecipe.cookingRecipes)
196207
{
@@ -201,8 +212,6 @@ private void DiscoverRecipes()
201212
}
202213
_cookingRecipes.Add(cookingRecipe);
203214
}
204-
205-
var unknownRecipeCount = _cookingRecipes.Where(x => !x.IsKnown).Count();
206215
}
207216

208217
private void LogUsageError(string error, string command)

BuyRecipes/BuyRecipes.csproj

Lines changed: 9 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,14 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
43
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{7DACA8E6-D69F-43BB-8442-CDB25F7C863B}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>Denifia.Stardew.BuyRecipes</RootNamespace>
114
<AssemblyName>Denifia.Stardew.BuyRecipes</AssemblyName>
12-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<DeployModFolderName>$(MSBuildProjectName)</DeployModFolderName>
15-
<NuGetPackageImportStamp>
16-
</NuGetPackageImportStamp>
17-
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19-
<DebugSymbols>true</DebugSymbols>
20-
<DebugType>full</DebugType>
21-
<Optimize>false</Optimize>
22-
<OutputPath>bin\Debug\</OutputPath>
23-
<DefineConstants>DEBUG;TRACE</DefineConstants>
24-
<ErrorReport>prompt</ErrorReport>
25-
<WarningLevel>4</WarningLevel>
26-
<PlatformTarget>x86</PlatformTarget>
27-
</PropertyGroup>
28-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29-
<DebugType>pdbonly</DebugType>
30-
<Optimize>true</Optimize>
31-
<OutputPath>bin\Release\</OutputPath>
32-
<DefineConstants>TRACE</DefineConstants>
33-
<ErrorReport>prompt</ErrorReport>
34-
<WarningLevel>4</WarningLevel>
5+
<RootNamespace>Denifia.Stardew.BuyRecipes</RootNamespace>
6+
<Version>2.0.1</Version>
7+
<TargetFramework>net452</TargetFramework>
358
</PropertyGroup>
9+
3610
<ItemGroup>
37-
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
38-
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
39-
</Reference>
40-
<Reference Include="System" />
41-
<Reference Include="System.Xml" />
42-
</ItemGroup>
43-
<ItemGroup>
44-
<Compile Include="BuyRecipes.cs" />
45-
<Compile Include="Domain\BaseRecipeAquisition.cs" />
46-
<Compile Include="Domain\CookingRecipe.cs" />
47-
<Compile Include="Domain\DefaultRecipeAquisition.cs" />
48-
<Compile Include="Domain\FriendBasedRecipeAquisition.cs" />
49-
<Compile Include="Domain\GameDateTime.cs" />
50-
<Compile Include="Domain\GameItem.cs" />
51-
<Compile Include="Domain\GameItemWithQuantity.cs" />
52-
<Compile Include="Domain\IRecipeAquisitionConditions.cs" />
53-
<Compile Include="Domain\LevelBasedRecipeAquisition.cs" />
54-
<Compile Include="Domain\SkillBasedRecipeAquisition.cs" />
55-
<Compile Include="Framework\AquisitionFactory.cs" />
56-
<Compile Include="Framework\ModConstants.cs" />
57-
<Compile Include="Framework\ModHelper.cs" />
58-
<Compile Include="ModConfig.cs" />
59-
<Compile Include="Properties\AssemblyInfo.cs" />
60-
</ItemGroup>
61-
<ItemGroup>
62-
<None Include="config.json">
63-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
64-
</None>
65-
<None Include="manifest.json">
66-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
67-
</None>
68-
<None Include="nexusmods.md" />
69-
<None Include="packages.config" />
70-
<None Include="readme.md" />
71-
<None Include="release-notes.md" />
72-
</ItemGroup>
73-
<ItemGroup>
74-
<Analyzer Include="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
11+
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="3.0.0-beta.4" />
7512
</ItemGroup>
76-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
77-
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
78-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
79-
<PropertyGroup>
80-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
81-
</PropertyGroup>
82-
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
83-
</Target>
84-
</Project>
13+
14+
</Project>

BuyRecipes/Domain/CookingRecipe.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Denifia.Stardew.BuyRecipes.Framework;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Linq;
4+
using Denifia.Stardew.BuyRecipes.Framework;
55

66
namespace Denifia.Stardew.BuyRecipes.Domain
77
{

BuyRecipes/Domain/DefaultRecipeAquisition.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Text;
2-
using System.Threading.Tasks;
3-
4-
namespace Denifia.Stardew.BuyRecipes.Domain
1+
namespace Denifia.Stardew.BuyRecipes.Domain
52
{
63
public class DefaultRecipeAquisition : BaseRecipeAquisition, IRecipeAquisitionConditions
74
{

BuyRecipes/Domain/GameDateTime.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using StardewValley;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
1+
using System;
72

83
namespace Denifia.Stardew.BuyRecipes.Domain
94
{
@@ -45,8 +40,6 @@ private int SeasonAsInt(string season)
4540
case "winter":
4641
seasonInt = 4;
4742
break;
48-
default:
49-
break;
5043
}
5144
return seasonInt;
5245
}

BuyRecipes/Framework/AquisitionFactory.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

BuyRecipes/Framework/ModConstants.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

BuyRecipes/Framework/ModHelper.cs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using Denifia.Stardew.BuyRecipes.Domain;
2-
using StardewModdingAPI;
1+
using System.Collections.Generic;
2+
using Denifia.Stardew.BuyRecipes.Domain;
33
using StardewValley;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
94

105
namespace Denifia.Stardew.BuyRecipes.Framework
116
{
@@ -41,26 +36,5 @@ public static string GetMoneyAsString(int money)
4136
{
4237
return $"G{money.ToString("#,##0")}";
4338
}
44-
45-
public static void HandleError(IMod mod, Exception ex, string verb)
46-
{
47-
mod.Monitor.Log($"Something went wrong {verb}:\n{ex}", LogLevel.Error);
48-
ModHelper.ShowErrorMessage($"Huh. Something went wrong {verb}. The error log has the technical details.");
49-
}
50-
51-
/// <summary>Show an informational message to the player.</summary>
52-
/// <param name="message">The message to show.</param>
53-
/// <param name="duration">The number of milliseconds during which to keep the message on the screen before it fades (or <c>null</c> for the default time).</param>
54-
public static void ShowInfoMessage(string message, int? duration = null)
55-
{
56-
Game1.addHUDMessage(new HUDMessage(message, 3) { noIcon = true, timeLeft = duration ?? HUDMessage.defaultTime });
57-
}
58-
59-
/// <summary>Show an error message to the player.</summary>
60-
/// <param name="message">The message to show.</param>
61-
public static void ShowErrorMessage(string message)
62-
{
63-
Game1.addHUDMessage(new HUDMessage(message, 3));
64-
}
6539
}
6640
}

BuyRecipes/ModConfig.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
{
33
public class ModConfig
44
{
5-
public bool Debug { get; set; }
65
}
76
}

BuyRecipes/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)