Skip to content

Commit

Permalink
Merge pull request #16 from Mushymato/main
Browse files Browse the repository at this point in the history
Remove MailFrameworkMod dependency, update drawHairAndAccesories for 1.6.14, plus some other refactoring
  • Loading branch information
greyivy authored Nov 23, 2024
2 parents f7565ec + 57b621f commit fd951dc
Show file tree
Hide file tree
Showing 16 changed files with 289 additions and 271 deletions.
12 changes: 1 addition & 11 deletions Ornithologists Guild.sln
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1703.8
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrnithologistsGuild", "OrnithologistsGuild\OrnithologistsGuild.csproj", "{CEF6B6C8-5644-4667-A031-196A395EEB3E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrnithologistsGuild.CP", "OrnithologistsGuild.CP\OrnithologistsGuild.CP.csproj", "{26BFD301-759D-4C15-954B-26EA70CA7019}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{259E4387-0EC9-480C-AF1B-25568BF7477F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{259E4387-0EC9-480C-AF1B-25568BF7477F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{259E4387-0EC9-480C-AF1B-25568BF7477F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{259E4387-0EC9-480C-AF1B-25568BF7477F}.Release|Any CPU.Build.0 = Release|Any CPU
{CEF6B6C8-5644-4667-A031-196A395EEB3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEF6B6C8-5644-4667-A031-196A395EEB3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEF6B6C8-5644-4667-A031-196A395EEB3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEF6B6C8-5644-4667-A031-196A395EEB3E}.Release|Any CPU.Build.0 = Release|Any CPU
{26BFD301-759D-4C15-954B-26EA70CA7019}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26BFD301-759D-4C15-954B-26EA70CA7019}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26BFD301-759D-4C15-954B-26EA70CA7019}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26BFD301-759D-4C15-954B-26EA70CA7019}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
24 changes: 0 additions & 24 deletions OrnithologistsGuild.CP/OrnithologistsGuild.CP.csproj

This file was deleted.

2 changes: 1 addition & 1 deletion OrnithologistsGuild.CP/i18n/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@
"map.OrnithologistsGuild.strings.29": "\"Dirty feeders and baths make sick birds!\" the document proclaims before prescribing a rigorous cleaning regimen. \"Clean every two weeks, no less!\"",
"event.OrnithologistsGuild_Kyle_SpellNSpeak.1": "~ H-E-L-L-O ~$6",
"event.OrnithologistsGuild_Kyle_SpellNSpeak.2": "~ MY NAME IS K-Y-L-E ~$7",
"event.OrnithologistsGuild_Kyle_SpellNSpeak.3": "*battery fizzling out*$10",
"event.OrnithologistsGuild_Kyle_SpellNSpeak.3": "*battery fizzling out*$10"
}
2 changes: 1 addition & 1 deletion OrnithologistsGuild.CP/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"UniqueID": "Ivy.OrnithologistsGuild",
"MinimumVersion": "1.9.2"
"MinimumVersion": "1.9.4"
}
],
"RequiredForEveryone": true,
Expand Down
85 changes: 84 additions & 1 deletion OrnithologistsGuild/Content/ContentManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley.GameData;

namespace OrnithologistsGuild.Content
{
Expand Down Expand Up @@ -29,7 +32,87 @@ private static void Content_AssetRequested(object sender, AssetRequestedEventArg
{
e.LoadFromModFile<Texture2D>("assets/binoculars.png", AssetLoadPriority.Low);
}
// mail & triggers
// this can be done in content patcher ofc, kept here for i18n key.
if (e.Name.IsEquivalentTo("Data/Mail"))
{
e.Edit(Edit_DataMail);
}
if (e.Name.IsEquivalentTo("Data/TriggerActions"))
{
e.Edit(Edit_DataTriggerActions);
}
}

private static void Edit_DataMail(IAssetData data)
{
var mail = data.AsDictionary<string, string>().Data;
// give lifelist
mail["Mods_Ivy_OrnithologistsGuild_Introduction"] = $"{I18n.Mail_Introduction()}%item id {Constants.LIFE_LIST_FQID} %% %item conversationTopic Ivy_OrnithologistGuild_Introduction 14 %% [#]{I18n.Mail_Introduction_Title()}";
// 1 bird identified, mixed seeds
mail["Mods_Ivy_OrnithologistsGuild_LifeList1"] = $"{I18n.Mail_LifeList1()}%item id (O)770 5 %% [#]{I18n.Mail_LifeList1_Title()}";
// 3 birds identified, corn
mail["Mods_Ivy_OrnithologistsGuild_LifeList3"] = $"{I18n.Mail_LifeList3()}%item id (O)270 5 %% [#]{I18n.Mail_LifeList3_Title()}";
// 5 birds identified, sunflower seeds
mail["Mods_Ivy_OrnithologistsGuild_LifeList5"] = $"{I18n.Mail_LifeList5()}%item id (O)431 5 %% [#]{I18n.Mail_LifeList5_Title()}";
// 7 birds identified, salmonberries
mail["Mods_Ivy_OrnithologistsGuild_LifeList7"] = $"{I18n.Mail_LifeList7()}%item id (O)296 5 %% [#]{I18n.Mail_LifeList7_Title()}";
// all bird identified, golden egg
mail["Mods_Ivy_OrnithologistsGuild_LifeListAll"] = $"{I18n.Mail_LifeListAll()}%item id (O)928 %% %item conversationTopic Ivy_OrnithologistGuild_LifeListAll 14 %% [#]{I18n.Mail_LifeListAll_Title()}";
}

private static void Edit_DataTriggerActions(IAssetData data)
{
string modId = ModEntry.Instance.ModManifest.UniqueID;
var tActs = data.GetData<List<TriggerActionData>>();
// send intro mail once, immediately on day start/mod install
tActs.Add(new()
{
Id = $"{modId}_Mail_Introduction",
Trigger = "DayStarted",
Condition = "DATE_RANGE spring 5 1",
Action = "AddMail Current Mods_Ivy_OrnithologistsGuild_Introduction Now",
// set MarkActionApplied=true to do this only once, this is the default value
//MarkActionApplied = true
});
// send identified count mails at end of day (for tomorrow), when goal is reached
tActs.Add(new()
{
Id = $"{modId}_Mail_LifeList1",
Trigger = "DayEnding",
Condition = "Ivy.OrnithologistsGuild_IDENTIFIED_AT_LEAST 1",
Action = "AddMail Current Mods_Ivy_OrnithologistsGuild_LifeList1",
});
tActs.Add(new()
{
Id = $"{modId}_Mail_LifeList3",
Trigger = "DayEnding",
Condition = "Ivy.OrnithologistsGuild_IDENTIFIED_AT_LEAST 3",
Action = "AddMail Current Mods_Ivy_OrnithologistsGuild_LifeList3",
});
tActs.Add(new()
{
Id = $"{modId}_Mail_LifeList5",
Trigger = "DayEnding",
Condition = "Ivy.OrnithologistsGuild_IDENTIFIED_AT_LEAST 5",
Action = "AddMail Current Mods_Ivy_OrnithologistsGuild_LifeList5",
});
tActs.Add(new()
{
Id = $"{modId}_Mail_LifeList7",
Trigger = "DayEnding",
Condition = "Ivy.OrnithologistsGuild_IDENTIFIED_AT_LEAST 7",
Action = "AddMail Current Mods_Ivy_OrnithologistsGuild_LifeList7",
});
tActs.Add(new()
{
Id = $"{modId}_Mail_LifeListAll",
Trigger = "DayEnding",
Condition = "Ivy.OrnithologistsGuild_IDENTIFIED_ALL",
Action = "AddMail Current Mods_Ivy_OrnithologistsGuild_LifeListAll",
});
}

}
}

52 changes: 52 additions & 0 deletions OrnithologistsGuild/Game/GameStateQueries.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using OrnithologistsGuild.Content;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Delegates;

namespace OrnithologistsGuild
{
/// <summary>
/// Add game state queries for use in conditions.
/// </summary>
public static class GameStateQueries
{
private static IMonitor Monitor;

public static void Initialize(string modId, IMonitor monitor)
{
Monitor = monitor;

GameStateQuery.Register($"{modId}_IDENTIFIED_AT_LEAST", IDENTIFIED_AT_LEAST);
GameStateQuery.Register($"{modId}_IDENTIFIED_ALL", IDENTIFIED_ALL);
}

/// <summary>
/// Check if the player has identified at least (>=) N birdies
/// Usage: Ivy.OrnithologistsGuild_IDENTIFIED_AT_LEAST \<N\>
/// /// </summary>
/// <param name="query">GSQ query, expected to have 2 items</param>
/// <param name="context">GSQ context, unused</param>
/// <returns></returns>
public static bool IDENTIFIED_AT_LEAST(string[] query, GameStateQueryContext context)
{
if (!ArgUtility.TryGetInt(query, 1, out int identify, out string error, "int identify"))
{
Monitor.Log(error, LogLevel.Error);
return false;
}
return (SaveDataManager.SaveData?.ForPlayer(Game1.player.UniqueMultiplayerID).LifeList.IdentifiedCount ?? 0) >= identify;
}

/// <summary>
/// Check if the player has identified at least (>=) N birdies
/// Usage: Ivy.OrnithologistsGuild_IDENTIFIED_ALL
/// /// </summary>
/// <param name="query">GSQ query, expected to have 2 items</param>
/// <param name="context">GSQ context, unused</param>
/// <returns></returns>
public static bool IDENTIFIED_ALL(string[] query, GameStateQueryContext context)
{
return (SaveDataManager.SaveData?.ForPlayer(Game1.player.UniqueMultiplayerID).LifeList.IdentifiedCount ?? 0) >= ContentPackManager.BirdieDefs.Count;
}
}
}
72 changes: 0 additions & 72 deletions OrnithologistsGuild/Game/Mail.cs

This file was deleted.

18 changes: 11 additions & 7 deletions OrnithologistsGuild/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Internal;

using StardewValley.Internal;

namespace OrnithologistsGuild
{
/// <summary>The mod entry point.</summary>
Expand All @@ -31,6 +31,7 @@ public override void Entry(IModHelper helper)
Helper.Events.Input.ButtonPressed += Input_ButtonPressed;

SaveDataManager.Initialize();
GameStateQueries.Initialize(ModManifest.UniqueID, Monitor);
}

private void Input_ButtonPressed(object sender, ButtonPressedEventArgs e)
Expand All @@ -51,10 +52,10 @@ private void GameLoop_SaveLoaded(object sender, SaveLoadedEventArgs e)
MigrateLegacyItems();

SaveDataManager.Load();
Mail.Initialize();
NestManager.Initialize();

if (ConfigManager.Config.LogMissingBiomes) {
if (ConfigManager.Config.LogMissingBiomes)
{
foreach (var location in StardewValley.Game1.locations)
{
var biomes = location.GetBiomes();
Expand All @@ -80,7 +81,8 @@ private void MigrateLegacyItems()
{ "(O)Ivy_OrnithologistsGuild_ProBinoculars", Constants.BINOCULARS_PRO_FQID }
};

StardewValley.Internal.ForEachItemHelper.ForEachItemInWorld(delegate (in ForEachItemContext ctx) {
StardewValley.Internal.ForEachItemHelper.ForEachItemInWorld(delegate (in ForEachItemContext ctx)
{

if (LegacyItemMigrations.TryGetValue(ctx.Item.QualifiedItemId, out var newQualifiedItemId))
{
Expand All @@ -95,7 +97,8 @@ private void MigrateLegacyItems()
try
{
ctx.RemoveItem();
} catch (Exception ex2)
}
catch (Exception ex2)
{
Monitor.Log($"Removing broken {ctx.Item.QualifiedItemId} failed. Please manually remove the broken item.\n{ex2}", LogLevel.Error);
}
Expand All @@ -117,7 +120,8 @@ private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
return Game1.player.currentLocation.GetBiomes();
});
// Player name for PowerUp e.g. `Ivy` -> `I-V-Y`
CP.RegisterToken(ModManifest, "PowerUpPlayerName", () => {
CP.RegisterToken(ModManifest, "PowerUpPlayerName", () =>
{
string[] GetValue(string playerName)
{
return new[] { string.Join('-', playerName.ToUpper().ToCharArray()) };
Expand Down
Loading

0 comments on commit fd951dc

Please sign in to comment.