From 001cab1aba46708596903b0011aa29ae53dcc389 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 6 Jan 2019 02:21:06 -0500 Subject: [PATCH] update for SMAPI 3.0 --- GeneralMods/AdvancedSaveBackup/SaveBackup.cs | 8 +- GeneralMods/AdvancedSaveBackup/manifest.json | 2 +- GeneralMods/AutoSpeed/AutoSpeed.cs | 9 +- GeneralMods/AutoSpeed/manifest.json | 2 +- .../BillboardAnywhere/BillboardAnywhere.cs | 10 +- .../BillboardAnywhere/Framework/ModConfig.cs | 4 +- GeneralMods/BillboardAnywhere/manifest.json | 2 +- GeneralMods/BuildEndurance/BuildEndurance.cs | 40 ++--- GeneralMods/BuildEndurance/manifest.json | 2 +- GeneralMods/BuildHealth/BuildHealth.cs | 40 ++--- GeneralMods/BuildHealth/manifest.json | 2 +- .../BuyBackCollectables.cs | 10 +- .../Framework/ModConfig.cs | 4 +- GeneralMods/BuyBackCollectables/manifest.json | 2 +- GeneralMods/CustomNPCFramework/Class1.cs | 38 ++--- GeneralMods/CustomNPCFramework/manifest.json | 6 +- .../DailyQuestAnywhere/DailyQuestAnywhere.cs | 36 ++-- .../DailyQuestAnywhere/Framework/ModConfig.cs | 4 +- GeneralMods/DailyQuestAnywhere/manifest.json | 2 +- GeneralMods/Fall28SnowDay/Fall28SnowDay.cs | 9 +- GeneralMods/Fall28SnowDay/manifest.json | 2 +- GeneralMods/FarmersMarketStall/Class1.cs | 15 +- GeneralMods/FarmersMarketStall/manifest.json | 4 +- .../HappyBirthday/Framework/ModConfig.cs | 4 +- GeneralMods/HappyBirthday/HappyBirthday.cs | 156 +++++++++--------- GeneralMods/HappyBirthday/manifest.json | 2 +- GeneralMods/MapEvents/EventSystem.cs | 16 +- GeneralMods/MapEvents/manifest.json | 4 +- GeneralMods/MoreRain/MoreRain.cs | 16 +- GeneralMods/MoreRain/manifest.json | 2 +- .../MuseumRearranger/Framework/ModConfig.cs | 6 +- .../MuseumRearranger/MuseumRearranger.cs | 12 +- GeneralMods/MuseumRearranger/manifest.json | 2 +- .../NightOwl/Framework/NightFishing.cs | 12 +- GeneralMods/NightOwl/NightOwl.cs | 77 ++++----- GeneralMods/NightOwl/manifest.json | 2 +- GeneralMods/NoMorePets/NoMorePets.cs | 9 +- GeneralMods/NoMorePets/manifest.json | 2 +- GeneralMods/Revitalize/manifest.json | 2 +- .../SaveAnywhere/Framework/ModConfig.cs | 4 +- GeneralMods/SaveAnywhere/SaveAnywhere.cs | 42 ++--- GeneralMods/SaveAnywhere/manifest.json | 2 +- GeneralMods/SimpleSoundManager/manifest.json | 2 +- .../StardewSymphonyRemastered/Config.cs | 4 +- .../StardewSymphony.cs | 115 +++++++------ .../StardewSymphonyRemastered/manifest.json | 2 +- GeneralMods/StardustCore/manifest.json | 2 +- GeneralMods/SundropMapEvents/Class1.cs | 9 +- GeneralMods/SundropMapEvents/manifest.json | 4 +- GeneralMods/TimeFreeze/TimeFreeze.cs | 12 +- GeneralMods/TimeFreeze/manifest.json | 2 +- .../Vocalization/Vocalization/Vocalization.cs | 51 +++--- .../Vocalization/Vocalization/manifest.json | 2 +- 53 files changed, 411 insertions(+), 419 deletions(-) diff --git a/GeneralMods/AdvancedSaveBackup/SaveBackup.cs b/GeneralMods/AdvancedSaveBackup/SaveBackup.cs index fb19a21e..f8156a55 100644 --- a/GeneralMods/AdvancedSaveBackup/SaveBackup.cs +++ b/GeneralMods/AdvancedSaveBackup/SaveBackup.cs @@ -41,17 +41,17 @@ namespace Omegasis.SaveBackup this.BackupSaves(SaveBackup.PrePlayBackupsPath); - SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; + helper.Events.GameLoop.Saving += this.OnSaving; } /********* ** Private methods *********/ - /// The method invoked before the save is updated. + /// Raised before the game begins writes data to the save file (except the initial save creation). /// The event sender. - /// The event data. - private void SaveEvents_BeforeSave(object sender, EventArgs e) + /// The event arguments. + private void OnSaving(object sender, SavingEventArgs e) { this.BackupSaves(SaveBackup.NightlyBackupsPath); } diff --git a/GeneralMods/AdvancedSaveBackup/manifest.json b/GeneralMods/AdvancedSaveBackup/manifest.json index 8db3680c..bb113ace 100644 --- a/GeneralMods/AdvancedSaveBackup/manifest.json +++ b/GeneralMods/AdvancedSaveBackup/manifest.json @@ -5,6 +5,6 @@ "Description": "Backs up your save files when loading SMAPI and every in game night when saving.", "UniqueID": "Omegasis.AdvancedSaveBackup", "EntryDll": "AdvancedSaveBackup.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:435" ] } diff --git a/GeneralMods/AutoSpeed/AutoSpeed.cs b/GeneralMods/AutoSpeed/AutoSpeed.cs index 80d44cdb..f4fa9e49 100644 --- a/GeneralMods/AutoSpeed/AutoSpeed.cs +++ b/GeneralMods/AutoSpeed/AutoSpeed.cs @@ -1,4 +1,3 @@ -using System; using Omegasis.AutoSpeed.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; @@ -23,7 +22,7 @@ namespace Omegasis.AutoSpeed /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - GameEvents.UpdateTick += this.GameEvents_UpdateTick; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; this.Config = helper.ReadConfig(); } @@ -31,10 +30,10 @@ namespace Omegasis.AutoSpeed /********* ** Private methods *********/ - /// The method invoked when the game updates (roughly 60 times per second). + /// Raised after the game state is updated (≈60 times per second). /// The event sender. - /// The event data. - private void GameEvents_UpdateTick(object sender, EventArgs e) + /// The event arguments. + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { if (Context.IsPlayerFree) Game1.player.addedSpeed = this.Config.Speed; diff --git a/GeneralMods/AutoSpeed/manifest.json b/GeneralMods/AutoSpeed/manifest.json index 39a0695d..acc444d5 100644 --- a/GeneralMods/AutoSpeed/manifest.json +++ b/GeneralMods/AutoSpeed/manifest.json @@ -5,6 +5,6 @@ "Description": "Got to go fast!", "UniqueID": "Omegasis.AutoSpeed", "EntryDll": "AutoSpeed.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:443" ] } diff --git a/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs b/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs index e09dadda..4282b082 100644 --- a/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs +++ b/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs @@ -25,20 +25,20 @@ namespace Omegasis.BillboardAnywhere { this.Config = helper.ReadConfig(); - ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + helper.Events.Input.ButtonPressed += this.OnButtonPressed; } /********* ** Private methods *********/ - /// The method invoked when the presses a keyboard button. + /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. - /// The event data. - public void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + /// The event arguments. + public void OnButtonPressed(object sender, ButtonPressedEventArgs e) { // load menu if key pressed - if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding) + if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding) Game1.activeClickableMenu = new Billboard(); } } diff --git a/GeneralMods/BillboardAnywhere/Framework/ModConfig.cs b/GeneralMods/BillboardAnywhere/Framework/ModConfig.cs index ec6f3b5c..8f16e667 100644 --- a/GeneralMods/BillboardAnywhere/Framework/ModConfig.cs +++ b/GeneralMods/BillboardAnywhere/Framework/ModConfig.cs @@ -1,9 +1,11 @@ +using StardewModdingAPI; + namespace Omegasis.BillboardAnywhere.Framework { /// The mod configuration. internal class ModConfig { /// The key which shows the billboard menu. - public string KeyBinding { get; set; } = "B"; + public SButton KeyBinding { get; set; } = SButton.B; } } diff --git a/GeneralMods/BillboardAnywhere/manifest.json b/GeneralMods/BillboardAnywhere/manifest.json index c35ec23e..5685e1ec 100644 --- a/GeneralMods/BillboardAnywhere/manifest.json +++ b/GeneralMods/BillboardAnywhere/manifest.json @@ -5,6 +5,6 @@ "Description": "Lets you view the billboard from anywhere.", "UniqueID": "Omegasis.BillboardAnywhere", "EntryDll": "BillboardAnywhere.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:492" ] } diff --git a/GeneralMods/BuildEndurance/BuildEndurance.cs b/GeneralMods/BuildEndurance/BuildEndurance.cs index ca94483d..dc3f0ab6 100644 --- a/GeneralMods/BuildEndurance/BuildEndurance.cs +++ b/GeneralMods/BuildEndurance/BuildEndurance.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using Omegasis.BuildEndurance.Framework; using StardewModdingAPI; @@ -47,10 +46,9 @@ namespace Omegasis.BuildEndurance { this.Config = helper.ReadConfig(); - GameEvents.UpdateTick += this.GameEvents_UpdateTick; - GameEvents.OneSecondTick += this.GameEvents_OneSecondTick; - SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; - SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; + helper.Events.GameLoop.Saving += this.OnSaving; this.ModHelper = this.Helper; this.ModMonitor = this.Monitor; @@ -60,24 +58,18 @@ namespace Omegasis.BuildEndurance /********* ** Private methods *********/ - /// The method invoked once per second during a game update. + /// Raised after the game state is updated (≈60 times per second). /// The event sender. - /// The event data. - private void GameEvents_OneSecondTick(object sender, EventArgs e) - { - // nerf how quickly tool xp is gained (I hope) - if (this.HasRecentToolExp) - this.HasRecentToolExp = false; - } - - /// The method invoked when the game updates (roughly 60 times per second). - /// The event sender. - /// The event data. - private void GameEvents_UpdateTick(object sender, EventArgs e) + /// The event arguments. + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { if (!Context.IsWorldReady) return; + // nerf how quickly tool xp is gained (I hope) + if (e.IsOneSecond && this.HasRecentToolExp) + this.HasRecentToolExp = false; + // give XP when player finishes eating if (Game1.player.isEating) this.WasEating = true; @@ -112,10 +104,10 @@ namespace Omegasis.BuildEndurance } } - /// The method invoked after the player loads a save. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. - /// The event data. - private void SaveEvents_AfterLoad(object sender, EventArgs e) + /// The event arguments. + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { // reset state this.WasExhausted = false; @@ -150,10 +142,10 @@ namespace Omegasis.BuildEndurance } } - /// The method invoked just before the game is saved. + /// Raised before the game begins writes data to the save file (except the initial save creation). /// The event sender. - /// The event data. - private void SaveEvents_BeforeSave(object sender, EventArgs e) + /// The event arguments. + private void OnSaving(object sender, SavingEventArgs e) { // reset data this.WasExhausted = false; diff --git a/GeneralMods/BuildEndurance/manifest.json b/GeneralMods/BuildEndurance/manifest.json index 3b75abd3..965d6449 100644 --- a/GeneralMods/BuildEndurance/manifest.json +++ b/GeneralMods/BuildEndurance/manifest.json @@ -5,6 +5,6 @@ "Description": "Increase your health as you play.", "UniqueID": "Omegasis.BuildEndurance", "EntryDll": "BuildEndurance.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:445" ] } diff --git a/GeneralMods/BuildHealth/BuildHealth.cs b/GeneralMods/BuildHealth/BuildHealth.cs index 4e994332..deaaed92 100644 --- a/GeneralMods/BuildHealth/BuildHealth.cs +++ b/GeneralMods/BuildHealth/BuildHealth.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using Omegasis.BuildHealth.Framework; using StardewModdingAPI; @@ -42,10 +41,9 @@ namespace Omegasis.BuildHealth /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - GameEvents.UpdateTick += this.GameEvents_UpdateTick; - GameEvents.OneSecondTick += this.GameEvents_OneSecondTick; - TimeEvents.AfterDayStarted += this.SaveEvents_BeforeSave; - SaveEvents.AfterLoad += this.SaveEvents_AfterLoaded; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; + helper.Events.GameLoop.DayStarted += this.OnDayStarted; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; this.Config = helper.ReadConfig(); } @@ -54,24 +52,18 @@ namespace Omegasis.BuildHealth /********* ** Private methods *********/ - /// The method invoked once per second during a game update. + /// Raised after the game state is updated (≈60 times per second). /// The event sender. - /// The event data. - private void GameEvents_OneSecondTick(object sender, EventArgs e) - { - // nerf how quickly tool xp is gained (I hope) - if (this.HasRecentToolExp) - this.HasRecentToolExp = false; - } - - /// The method invoked when the game updates (roughly 60 times per second). - /// The event sender. - /// The event data. - private void GameEvents_UpdateTick(object sender, EventArgs e) + /// The event arguments. + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { if (!Context.IsWorldReady) return; + // nerf how quickly tool xp is gained (I hope) + if (e.IsOneSecond && this.HasRecentToolExp) + this.HasRecentToolExp = false; + // give XP when player finishes eating if (Game1.player.isEating) this.WasEating = true; @@ -106,10 +98,10 @@ namespace Omegasis.BuildHealth } } - /// The method invoked after the player loads a save. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. - /// The event data. - private void SaveEvents_AfterLoaded(object sender, EventArgs e) + /// The event arguments. + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { // reset state this.HasRecentToolExp = false; @@ -140,10 +132,10 @@ namespace Omegasis.BuildHealth Game1.player.maxHealth = this.PlayerData.BaseHealthBonus + this.PlayerData.CurrentLevelHealthBonus + this.PlayerData.OriginalMaxHealth; } - /// The method invoked just before the game saves. + /// Raised after the game begins a new day (including when the player loads a save). /// The event sender. - /// The event data. - private void SaveEvents_BeforeSave(object sender, EventArgs e) + /// The event arguments. + private void OnDayStarted(object sender, DayStartedEventArgs e) { // reset data this.LastHealth = Game1.player.maxHealth; diff --git a/GeneralMods/BuildHealth/manifest.json b/GeneralMods/BuildHealth/manifest.json index 808dd39d..f68687dd 100644 --- a/GeneralMods/BuildHealth/manifest.json +++ b/GeneralMods/BuildHealth/manifest.json @@ -5,6 +5,6 @@ "Description": "Increase your health as you play.", "UniqueID": "Omegasis.BuildHealth", "EntryDll": "BuildHealth.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:446" ] } diff --git a/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs b/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs index 2493af01..117f6c72 100644 --- a/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs +++ b/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs @@ -24,19 +24,19 @@ namespace Omegasis.BuyBackCollectables { this.Config = helper.ReadConfig(); - ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + helper.Events.Input.ButtonPressed += this.OnButtonPressed; } /********* ** Private methods *********/ - /// The method invoked when the presses a keyboard button. + /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. - /// The event data. - public void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + /// The event arguments. + private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { - if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding) + if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding) Game1.activeClickableMenu = new BuyBackMenu(this.Config.CostMultiplier); } } diff --git a/GeneralMods/BuyBackCollectables/Framework/ModConfig.cs b/GeneralMods/BuyBackCollectables/Framework/ModConfig.cs index c1299949..27288986 100644 --- a/GeneralMods/BuyBackCollectables/Framework/ModConfig.cs +++ b/GeneralMods/BuyBackCollectables/Framework/ModConfig.cs @@ -1,10 +1,12 @@ +using StardewModdingAPI; + namespace Omegasis.BuyBackCollectables.Framework { /// The mod configuration. internal class ModConfig { /// The key which shows the menu. - public string KeyBinding { get; set; } = "B"; + public SButton KeyBinding { get; set; } = SButton.B; /// The multiplier applied to the cost of buying back a collectable. public double CostMultiplier { get; set; } = 3.0; diff --git a/GeneralMods/BuyBackCollectables/manifest.json b/GeneralMods/BuyBackCollectables/manifest.json index a420d9ca..c4349ae3 100644 --- a/GeneralMods/BuyBackCollectables/manifest.json +++ b/GeneralMods/BuyBackCollectables/manifest.json @@ -5,6 +5,6 @@ "Description": "Lets you buy back any obtained collectable.", "UniqueID": "Omegasis.BuyBackCollectables", "EntryDll": "BuyBackCollectables.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:507" ] } diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 0e9892fb..bbb7091e 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -9,6 +9,7 @@ using CustomNPCFramework.Framework.NPCS; using CustomNPCFramework.Framework.Utilities; using Microsoft.Xna.Framework; using StardewModdingAPI; +using StardewModdingAPI.Events; using StardewValley; namespace CustomNPCFramework @@ -64,13 +65,10 @@ namespace CustomNPCFramework ModMonitor = this.Monitor; Manifest = this.ModManifest; - StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_LoadChar; - - StardewModdingAPI.Events.SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; - StardewModdingAPI.Events.SaveEvents.AfterSave += this.SaveEvents_AfterSave; - - StardewModdingAPI.Events.PlayerEvents.Warped += this.LocationEvents_CurrentLocationChanged; - StardewModdingAPI.Events.GameEvents.UpdateTick += this.GameEvents_UpdateTick; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; + helper.Events.GameLoop.Saving += this.OnSaving; + helper.Events.GameLoop.Saved += this.OnSaved; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; npcTracker = new NpcTracker(); assetPool = new AssetPool(); var assetManager = new AssetManager(); @@ -87,27 +85,30 @@ namespace CustomNPCFramework assetPool.getAssetManager("testNPC").addPathCreateDirectory(new KeyValuePair("characters", relativePath)); } - /// A function that is called when the game finishes saving. + /// Raised after the game finishes writing data to the save file (except the initial save creation). /// The event sender. /// The event arguments. - private void SaveEvents_AfterSave(object sender, EventArgs e) + private void OnSaved(object sender, SavedEventArgs e) { npcTracker.afterSave(); } - /// A function that is called when the game is about to load. Used to clean up all the npcs from the game world to prevent it from crashing. + /// Raised before the game begins writes data to the save file (except the initial save creation). /// The event sender. /// The event arguments. - private void SaveEvents_BeforeSave(object sender, EventArgs e) + private void OnSaving(object sender, SavingEventArgs e) { + // clean up all the npcs from the game world to prevent it from crashing npcTracker.cleanUpBeforeSave(); } - /// Called upon 60 times a second. For testing purposes only. Will remove in future release. + /// Raised after the game state is updated (≈60 times per second). /// The event sender. /// The event arguments. - private void GameEvents_UpdateTick(object sender, EventArgs e) + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { + // TODO For testing purposes only. Will remove in future release. + /* if (Game1.player.currentLocation == null) return; if (Game1.activeClickableMenu != null) return; @@ -124,16 +125,13 @@ namespace CustomNPCFramework */ } - /// Called when the player's location changes. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. /// The event arguments. - private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsPlayerWarped e) { } - - /// Used to spawn a custom npc just as an example. Don't keep this code. GENERATE NPC AND CALL THE CODE - /// The event sender. - /// The event arguments. - private void SaveEvents_LoadChar(object sender, EventArgs e) + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { + // TODO Used to spawn a custom npc just as an example. Don't keep this code. GENERATE NPC AND CALL THE CODE + ExtendedNpc myNpc3 = assetPool.generateNPC(Genders.female, 0, 1, new StandardColorCollection(null, null, Color.Blue, null, Color.Yellow, null)); MerchantNpc merch = new MerchantNpc(new List() { diff --git a/GeneralMods/CustomNPCFramework/manifest.json b/GeneralMods/CustomNPCFramework/manifest.json index 14861572..6b916b5b 100644 --- a/GeneralMods/CustomNPCFramework/manifest.json +++ b/GeneralMods/CustomNPCFramework/manifest.json @@ -1,11 +1,11 @@ { - "Name": "CustomNPCFramework", + "Name": "Custom NPC Framework", "Author": "Alpha_Omegasis", "Version": "0.1.0", - "Description": "A system to add custom npcs to Stardew.", + "Description": "A system to add custom NPCs to Stardew.", "UniqueID": "Omegasis.CustomNPCFramework", "EntryDll": "CustomNPCFramework.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [], "Dependencies": [ { "UniqueID": "Omegasis.StardustCore" } diff --git a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs index e8e4fe99..7bf2349f 100644 --- a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs +++ b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs @@ -32,43 +32,43 @@ namespace Omegasis.DailyQuestAnywhere { this.Config = helper.ReadConfig(); - ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; - SaveEvents.AfterSave += this.SaveEvents_AfterSave; + helper.Events.Input.ButtonPressed += this.OnButtonPressed; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; } /********* ** Private methods *********/ - /// The method invoked when the presses a keyboard button. + /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. - /// The event data. - private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + /// The event arguments. + private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { - if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding) + if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding) + { if (!Game1.player.hasDailyQuest()) { if (this.dailyQuest == null) - { this.dailyQuest = this.generateDailyQuest(); - } Game1.questOfTheDay = this.dailyQuest; Game1.activeClickableMenu = new Billboard(true); } + } } - /// Makes my daily quest referene null so we can't just keep getting a new reference. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. - /// The event data. - private void SaveEvents_AfterSave(object sender, System.EventArgs e) + /// The event arguments. + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { - this.dailyQuest = null; //Nullify my quest reference. + // makes daily quest null so we can't just keep getting a new reference + this.dailyQuest = null; } /// Generate a daily quest for sure. public Quest generateDailyQuest() { - Random chanceRandom = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed); int chance = chanceRandom.Next(0, 101); float actualChance = chance / 100; @@ -85,15 +85,15 @@ namespace Omegasis.DailyQuestAnywhere case 1: return new FishingQuest(); case 2: - return new StardewValley.Quests.CraftingQuest(); + return new CraftingQuest(); case 3: - return new StardewValley.Quests.ItemDeliveryQuest(); + return new ItemDeliveryQuest(); case 4: - return new StardewValley.Quests.ItemHarvestQuest(); + return new ItemHarvestQuest(); case 5: - return new StardewValley.Quests.ResourceCollectionQuest(); + return new ResourceCollectionQuest(); case 6: - return new StardewValley.Quests.SlayMonsterQuest(); + return new SlayMonsterQuest(); } } return null; //This should never happen. diff --git a/GeneralMods/DailyQuestAnywhere/Framework/ModConfig.cs b/GeneralMods/DailyQuestAnywhere/Framework/ModConfig.cs index a88ee0fe..9190d89f 100644 --- a/GeneralMods/DailyQuestAnywhere/Framework/ModConfig.cs +++ b/GeneralMods/DailyQuestAnywhere/Framework/ModConfig.cs @@ -1,10 +1,12 @@ +using StardewModdingAPI; + namespace Omegasis.DailyQuestAnywhere.Framework { /// The mod configuration. internal class ModConfig { /// The key which shows the menu. - public string KeyBinding { get; set; } = "H"; + public SButton KeyBinding { get; set; } = SButton.H; /// The chance for a daily quest to actually happen. public float chanceForDailyQuest { get; set; } = .75f; diff --git a/GeneralMods/DailyQuestAnywhere/manifest.json b/GeneralMods/DailyQuestAnywhere/manifest.json index 319acf00..f573351b 100644 --- a/GeneralMods/DailyQuestAnywhere/manifest.json +++ b/GeneralMods/DailyQuestAnywhere/manifest.json @@ -5,6 +5,6 @@ "Description": "Open the daily quest board from anywhere in the game.", "UniqueID": "Omegasis.DailyQuestAnywhere", "EntryDll": "DailyQuestAnywhere.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:513" ] } diff --git a/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs b/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs index 00b042d6..14b3e63a 100644 --- a/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs +++ b/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs @@ -1,4 +1,3 @@ -using System; using StardewModdingAPI; using StardewModdingAPI.Events; using StardewValley; @@ -15,17 +14,17 @@ namespace Omegasis.Fall28SnowDay /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; + helper.Events.GameLoop.Saving += this.OnSaving; } /********* ** Private methods *********/ - /// The method invoked just before the game saves. + /// Raised before the game begins writes data to the save file (except the initial save creation). /// The event sender. - /// The event data. - public void SaveEvents_BeforeSave(object sender, EventArgs e) + /// The event arguments. + public void OnSaving(object sender, SavingEventArgs e) { if (Game1.IsFall && Game1.dayOfMonth == 27) Game1.weatherForTomorrow = Game1.weather_snow; diff --git a/GeneralMods/Fall28SnowDay/manifest.json b/GeneralMods/Fall28SnowDay/manifest.json index 5681c600..35210825 100644 --- a/GeneralMods/Fall28SnowDay/manifest.json +++ b/GeneralMods/Fall28SnowDay/manifest.json @@ -5,6 +5,6 @@ "Description": "Makes it snow on Fall 28, which makes a good explanation for all the snow on the next day.", "UniqueID": "Omegasis.Fall28SnowDay", "EntryDll": "Fall28SnowDay.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:486" ] } diff --git a/GeneralMods/FarmersMarketStall/Class1.cs b/GeneralMods/FarmersMarketStall/Class1.cs index 6d4e3138..1c08ebd9 100644 --- a/GeneralMods/FarmersMarketStall/Class1.cs +++ b/GeneralMods/FarmersMarketStall/Class1.cs @@ -3,6 +3,7 @@ using EventSystem.Framework.FunctionEvents; using FarmersMarketStall.Framework.MapEvents; using Microsoft.Xna.Framework; using StardewModdingAPI; +using StardewModdingAPI.Events; using StardewValley; namespace FarmersMarketStall @@ -29,17 +30,23 @@ namespace FarmersMarketStall ModHelper = this.Helper; ModMonitor = this.Monitor; - StardewModdingAPI.Events.SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; - StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + helper.Events.GameLoop.Saving += this.OnSaving; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; marketStall = new Framework.MarketStall(); } - private void SaveEvents_AfterLoad(object sender, EventArgs e) + /// Raised after the player loads a save slot and the world is initialised. + /// The event sender. + /// The event arguments. + private void OnSaveLoaded(object sender, EventArgs e) { EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new ShopInteractionEvent("FarmersMarketStall", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new MouseButtonEvents(null, true), new MouseEntryLeaveEvent(null, null))); } - private void SaveEvents_BeforeSave(object sender, EventArgs e) + /// Raised before the game begins writes data to the save file (except the initial save creation). + /// The event sender. + /// The event arguments. + private void OnSaving(object sender, SavingEventArgs e) { if (marketStall.stock.Count > 0) { diff --git a/GeneralMods/FarmersMarketStall/manifest.json b/GeneralMods/FarmersMarketStall/manifest.json index 6cf9b432..be2231a3 100644 --- a/GeneralMods/FarmersMarketStall/manifest.json +++ b/GeneralMods/FarmersMarketStall/manifest.json @@ -1,11 +1,11 @@ { - "Name": "FarmersMarketStall", + "Name": "Farmers Market Stall", "Author": "Alpha_Omegasis", "Version": "0.1.0", "Description": "A system to add a farmers market stall to Sundrop.", "UniqueID": "SunDrop.SunDropMapEvents.FarmersMarketStall", "EntryDll": "FarmersMarketStall.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [], "Dependencies": [ { "UniqueID": "Omegasis.EventSystem" } diff --git a/GeneralMods/HappyBirthday/Framework/ModConfig.cs b/GeneralMods/HappyBirthday/Framework/ModConfig.cs index 87d56ad5..a4d9b010 100644 --- a/GeneralMods/HappyBirthday/Framework/ModConfig.cs +++ b/GeneralMods/HappyBirthday/Framework/ModConfig.cs @@ -1,10 +1,12 @@ +using StardewModdingAPI; + namespace Omegasis.HappyBirthday.Framework { /// The mod configuration. public class ModConfig { /// The key which shows the menu. - public string KeyBinding { get; set; } = "O"; + public SButton KeyBinding { get; set; } = SButton.O; /// The minimum amount of friendship needed to get a birthday gift. public int minNeutralFriendshipGiftLevel = 3; diff --git a/GeneralMods/HappyBirthday/HappyBirthday.cs b/GeneralMods/HappyBirthday/HappyBirthday.cs index 628acc30..bebe719a 100644 --- a/GeneralMods/HappyBirthday/HappyBirthday.cs +++ b/GeneralMods/HappyBirthday/HappyBirthday.cs @@ -76,16 +76,15 @@ namespace Omegasis.HappyBirthday //helper.Content.AssetLoaders.Add(new PossibleGifts()); Config = helper.ReadConfig(); - TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted; - GameEvents.UpdateTick += this.GameEvents_UpdateTick; - SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; - SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; - ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; - MenuEvents.MenuChanged += this.MenuEvents_MenuChanged; - MenuEvents.MenuClosed += this.MenuEvents_MenuClosed; + helper.Events.GameLoop.DayStarted += this.OnDayStarted; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; + helper.Events.GameLoop.Saving += this.OnSaving; + helper.Events.Input.ButtonPressed += this.OnButtonPressed; + helper.Events.Display.MenuChanged += this.OnMenuChanged; - GraphicsEvents.OnPostRenderGuiEvent += this.GraphicsEvents_OnPostRenderGuiEvent; - StardewModdingAPI.Events.GraphicsEvents.OnPostRenderHudEvent += this.GraphicsEvents_OnPostRenderHudEvent; + helper.Events.Display.RenderedActiveMenu += this.OnRenderedActiveMenu; + helper.Events.Display.RenderedHud += this.OnRenderedHud; //MultiplayerSupport.initializeMultiplayerSupport(); ModHelper = this.Helper; ModMonitor = this.Monitor; @@ -113,13 +112,9 @@ namespace Omegasis.HappyBirthday /// A helper which encapsulates metadata about an asset and enables changes to it. public void Edit(IAssetData asset) { - asset - .AsDictionary() - .Set("birthdayMom", "Dear @,^ Happy birthday sweetheart. It's been amazing watching you grow into the kind, hard working person that I've always dreamed that you would become. I hope you continue to make many more fond memories with the ones you love. ^ Love, Mom ^ P.S. Here's a little something that I made for you. %item object 221 1 %%"); - - asset - .AsDictionary() - .Set("birthdayDad", "Dear @,^ Happy birthday kiddo. It's been a little quiet around here on your birthday since you aren't around, but your mother and I know that you are making both your grandpa and us proud. We both know that living on your own can be tough but we believe in you one hundred percent, just keep following your dreams.^ Love, Dad ^ P.S. Here's some spending money to help you out on the farm. Good luck! %item money 5000 5001 %%"); + IDictionary data = asset.AsDictionary().Data; + data["birthdayMom"] = "Dear @,^ Happy birthday sweetheart. It's been amazing watching you grow into the kind, hard working person that I've always dreamed that you would become. I hope you continue to make many more fond memories with the ones you love. ^ Love, Mom ^ P.S. Here's a little something that I made for you. %item object 221 1 %%"; + data["birthdayDad"] = "Dear @,^ Happy birthday kiddo. It's been a little quiet around here on your birthday since you aren't around, but your mother and I know that you are making both your grandpa and us proud. We both know that living on your own can be tough but we believe in you one hundred percent, just keep following your dreams.^ Love, Dad ^ P.S. Here's some spending money to help you out on the farm. Good luck! %item money 5000 5001 %%"; } @@ -161,33 +156,25 @@ namespace Omegasis.HappyBirthday } } - /// Used to check when a menu is closed. + /// Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen. /// The event sender. /// The event arguments. - private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e) + private void OnRenderedHud(object sender, RenderedHudEventArgs e) { - this.isDailyQuestBoard = false; - } + if (Game1.activeClickableMenu == null || this.PlayerData?.BirthdaySeason?.ToLower() != Game1.currentSeason.ToLower()) + return; - /// Used to properly display hovertext for all events happening on a calendar day. - /// The event sender. - /// The event arguments. - private void GraphicsEvents_OnPostRenderHudEvent(object sender, EventArgs e) - { - if (Game1.activeClickableMenu == null) return; - if (this.PlayerData?.BirthdaySeason == null) return; - if (this.PlayerData.BirthdaySeason.ToLower() != Game1.currentSeason.ToLower()) return; - if (Game1.activeClickableMenu is Billboard) + if (Game1.activeClickableMenu is Billboard billboard) { - if (this.isDailyQuestBoard) return; - if ((Game1.activeClickableMenu as Billboard).calendarDays == null) return; + if (this.isDailyQuestBoard || billboard.calendarDays == null) + return; //Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 230 + (index - 1) / 7 * 32 * 4), 1f, 4f, 2, Game1.player); string hoverText = ""; List texts = new List(); - foreach (var clicky in ((Billboard)Game1.activeClickableMenu).calendarDays) + foreach (var clicky in billboard.calendarDays) { if (clicky.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { @@ -213,10 +200,10 @@ namespace Omegasis.HappyBirthday } } - /// Used to show the farmer's portrait on the billboard menu. + /// When a menu is open ( isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen. /// The event sender. /// The event arguments. - private void GraphicsEvents_OnPostRenderGuiEvent(object sender, EventArgs e) + private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e) { if (Game1.activeClickableMenu == null || this.isDailyQuestBoard) return; @@ -246,72 +233,77 @@ namespace Omegasis.HappyBirthday } } - /// Functionality to display the player's birthday on the billboard. + /// Raised after a game menu is opened, closed, or replaced. /// The event sender. /// The event arguments. - private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e) + private void OnMenuChanged(object sender, MenuChangedEventArgs e) { - if (Game1.activeClickableMenu == null) + switch (e.NewMenu) { - this.isDailyQuestBoard = false; - return; - } - if (Game1.activeClickableMenu is Billboard) - { - this.isDailyQuestBoard = ModHelper.Reflection.GetField((Game1.activeClickableMenu as Billboard), "dailyQuestBoard", true).GetValue(); - if (this.isDailyQuestBoard) return; + case null: + this.isDailyQuestBoard = false; + return; - Texture2D text = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1); - Color[] col = new Color[1]; - col[0] = new Color(0, 0, 0, 1); - text.SetData(col); - //players birthday position rect=new .... - - if (!string.IsNullOrEmpty(this.PlayerData.BirthdaySeason)) - { - if (this.PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower()) + case Billboard billboard: { - int index = this.PlayerData.BirthdayDay; - Rectangle birthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124); - (Game1.activeClickableMenu as Billboard).calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", Game1.player.name + "'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false)); - } - } + this.isDailyQuestBoard = ModHelper.Reflection.GetField((Game1.activeClickableMenu as Billboard), "dailyQuestBoard", true).GetValue(); + if (this.isDailyQuestBoard) + return; - foreach (var pair in this.othersBirthdays) - { - if (pair.Value.BirthdaySeason != Game1.currentSeason.ToLower()) continue; - int index = pair.Value.BirthdayDay; - Rectangle otherBirthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124); - (Game1.activeClickableMenu as Billboard).calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", Game1.getFarmer(pair.Key).name + "'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false)); - } + Texture2D text = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1); + Color[] col = new Color[1]; + col[0] = new Color(0, 0, 0, 1); + text.SetData(col); + //players birthday position rect=new .... + + if (!string.IsNullOrEmpty(this.PlayerData.BirthdaySeason)) + { + if (this.PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower()) + { + int index = this.PlayerData.BirthdayDay; + Rectangle birthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124); + billboard.calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", $"{Game1.player.Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false)); + } + } + + foreach (var pair in this.othersBirthdays) + { + if (pair.Value.BirthdaySeason != Game1.currentSeason.ToLower()) continue; + int index = pair.Value.BirthdayDay; + Rectangle otherBirthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124); + billboard.calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", $"{Game1.getFarmer(pair.Key).Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false)); + } + + break; + } } } - /// The method invoked after a new day starts. + /// Raised after the game begins a new day (including when the player loads a save). /// The event sender. - /// The event data. - private void TimeEvents_AfterDayStarted(object sender, EventArgs e) + /// The event arguments. + private void OnDayStarted(object sender, DayStartedEventArgs e) { this.CheckedForBirthday = false; } - /// The method invoked when the presses a keyboard button. + /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. - /// The event data. - private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + /// The event arguments. + private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { // show birthday selection menu if (Game1.activeClickableMenu != null) return; - if (Context.IsPlayerFree && !this.HasChosenBirthday && e.KeyPressed.ToString() == Config.KeyBinding) + if (Context.IsPlayerFree && !this.HasChosenBirthday && e.Button == Config.KeyBinding) Game1.activeClickableMenu = new BirthdayMenu(this.PlayerData.BirthdaySeason, this.PlayerData.BirthdayDay, this.SetBirthday); } - /// The method invoked after the player loads a save. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. - /// The event data. - private void SaveEvents_AfterLoad(object sender, EventArgs e) + /// The event arguments. + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { - this.DataFilePath = Path.Combine("data", Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID + ".json"); + this.DataFilePath = Path.Combine("data", $"{Game1.player.Name}_{Game1.player.UniqueMultiplayerID}.json"); // reset state this.VillagerQueue = new List(); @@ -332,19 +324,19 @@ namespace Omegasis.HappyBirthday //this.Dialogue = new Dictionary(); } - /// The method invoked just before the game updates the saves. + /// Raised before the game begins writes data to the save file (except the initial save creation). /// The event sender. - /// The event data. - private void SaveEvents_BeforeSave(object sender, EventArgs e) + /// The event arguments. + private void OnSaving(object sender, SavingEventArgs e) { if (this.HasChosenBirthday) this.Helper.Data.WriteJsonFile(this.DataFilePath, this.PlayerData); } - /// The method invoked when the game updates (roughly 60 times per second). + /// Raised after the game state is updated (≈60 times per second). /// The event sender. - /// The event data. - private void GameEvents_UpdateTick(object sender, EventArgs e) + /// The event arguments. + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { if (!Context.IsWorldReady || Game1.eventUp || Game1.isFestival()) return; diff --git a/GeneralMods/HappyBirthday/manifest.json b/GeneralMods/HappyBirthday/manifest.json index eceefd57..ee2f7aa9 100644 --- a/GeneralMods/HappyBirthday/manifest.json +++ b/GeneralMods/HappyBirthday/manifest.json @@ -5,6 +5,6 @@ "Description": "Adds the farmer's birthday to the game.", "UniqueID": "Omegasis.HappyBirthday", "EntryDll": "HappyBirthday.dll", - "MinimumApiVersion": "2.9", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:520" ] } diff --git a/GeneralMods/MapEvents/EventSystem.cs b/GeneralMods/MapEvents/EventSystem.cs index 8b11646c..be7b2bfe 100644 --- a/GeneralMods/MapEvents/EventSystem.cs +++ b/GeneralMods/MapEvents/EventSystem.cs @@ -1,6 +1,6 @@ -using System; using EventSystem.Framework; using StardewModdingAPI; +using StardewModdingAPI.Events; namespace EventSystem { @@ -18,16 +18,22 @@ namespace EventSystem { ModHelper = this.Helper; ModMonitor = this.Monitor; - StardewModdingAPI.Events.GameEvents.UpdateTick += this.GameEvents_UpdateTick; - StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; } - private void SaveEvents_AfterLoad(object sender, EventArgs e) + /// Raised after the player loads a save slot and the world is initialised. + /// The event sender. + /// The event arguments. + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { eventManager = new EventManager(); } - private void GameEvents_UpdateTick(object sender, EventArgs e) + /// Raised after the game state is updated (≈60 times per second). + /// The event sender. + /// The event arguments. + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { eventManager?.update(); } diff --git a/GeneralMods/MapEvents/manifest.json b/GeneralMods/MapEvents/manifest.json index 4c72d707..d979dd05 100644 --- a/GeneralMods/MapEvents/manifest.json +++ b/GeneralMods/MapEvents/manifest.json @@ -1,10 +1,10 @@ { - "Name": "EventSystem", + "Name": "Event System", "Author": "Alpha_Omegasis", "Version": "0.1.0", "Description": "A system to manage different events that can happen on the map.", "UniqueID": "Omegasis.EventSystem", "EntryDll": "EventSystem.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [] } diff --git a/GeneralMods/MoreRain/MoreRain.cs b/GeneralMods/MoreRain/MoreRain.cs index d17e32ba..97ee2189 100644 --- a/GeneralMods/MoreRain/MoreRain.cs +++ b/GeneralMods/MoreRain/MoreRain.cs @@ -29,26 +29,26 @@ namespace Omegasis.MoreRain { this.Config = helper.ReadConfig(); - SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; - SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; + helper.Events.GameLoop.Saving += this.OnSaving; } /********* ** Private methods *********/ - /// The method invoked after the player loads a save. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. - /// The event data. - private void SaveEvents_AfterLoad(object sender, EventArgs e) + /// The event arguments. + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { this.HandleNewDay(); } - /// The method invoked before the game is saved. + /// Raised before the game begins writes data to the save file (except the initial save creation). /// The event sender. - /// The event data. - private void SaveEvents_BeforeSave(object sender, EventArgs e) + /// The event arguments. + private void OnSaving(object sender, SavingEventArgs e) { this.HandleNewDay(); } diff --git a/GeneralMods/MoreRain/manifest.json b/GeneralMods/MoreRain/manifest.json index 2923d02b..8bc0f494 100644 --- a/GeneralMods/MoreRain/manifest.json +++ b/GeneralMods/MoreRain/manifest.json @@ -5,6 +5,6 @@ "Description": "Change how much it rains in the game.", "UniqueID": "Omegasis.MoreRain", "EntryDll": "MoreRain.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:441" ] } diff --git a/GeneralMods/MuseumRearranger/Framework/ModConfig.cs b/GeneralMods/MuseumRearranger/Framework/ModConfig.cs index 923c969b..e020ccb7 100644 --- a/GeneralMods/MuseumRearranger/Framework/ModConfig.cs +++ b/GeneralMods/MuseumRearranger/Framework/ModConfig.cs @@ -1,12 +1,14 @@ +using StardewModdingAPI; + namespace Omegasis.MuseumRearranger.Framework { /// The mod configuration. internal class ModConfig { /// The key which shows the museum rearranging menu. - public string ShowMenuKey { get; set; } = "R"; + public SButton ShowMenuKey { get; set; } = SButton.R; /// The key which toggles the inventory box when the menu is open. - public string ToggleInventoryKey { get; set; } = "T"; + public SButton ToggleInventoryKey { get; set; } = SButton.T; } } diff --git a/GeneralMods/MuseumRearranger/MuseumRearranger.cs b/GeneralMods/MuseumRearranger/MuseumRearranger.cs index 8494f4ae..920965f0 100644 --- a/GeneralMods/MuseumRearranger/MuseumRearranger.cs +++ b/GeneralMods/MuseumRearranger/MuseumRearranger.cs @@ -28,23 +28,23 @@ namespace Omegasis.MuseumRearranger { this.Config = helper.ReadConfig(); - ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + helper.Events.Input.ButtonPressed += this.OnButtonPressed; } /********* ** Private methods *********/ - /// The method invoked when the presses a keyboard button. + /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. - /// The event data. - private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + /// The event arguments. + private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady) return; // open menu - if (e.KeyPressed.ToString() == this.Config.ShowMenuKey) + if (e.Button == this.Config.ShowMenuKey) { if (Game1.activeClickableMenu != null) return; @@ -55,7 +55,7 @@ namespace Omegasis.MuseumRearranger } // toggle inventory box - if (e.KeyPressed.ToString() == this.Config.ToggleInventoryKey) + if (e.Button == this.Config.ToggleInventoryKey) this.OpenMenu?.ToggleInventory(); } } diff --git a/GeneralMods/MuseumRearranger/manifest.json b/GeneralMods/MuseumRearranger/manifest.json index 8f28f6fe..7ed4041d 100644 --- a/GeneralMods/MuseumRearranger/manifest.json +++ b/GeneralMods/MuseumRearranger/manifest.json @@ -5,6 +5,6 @@ "Description": "Lets you rearrange the museum without needing to donate something.", "UniqueID": "Omegasis.MuseumRearranger", "EntryDll": "MuseumRearranger.dll", - "MinimumApiVersion": "2.3", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:428" ] } diff --git a/GeneralMods/NightOwl/Framework/NightFishing.cs b/GeneralMods/NightOwl/Framework/NightFishing.cs index 21b1f06c..ddb4c1a1 100644 --- a/GeneralMods/NightOwl/Framework/NightFishing.cs +++ b/GeneralMods/NightOwl/Framework/NightFishing.cs @@ -5,14 +5,18 @@ namespace Omegasis.NightOwl.Framework { class NightFishing : IAssetEditor { + /// Get whether this instance can edit the given asset. + /// Basic metadata about the asset being loaded. public bool CanEdit(IAssetInfo asset) { return asset.AssetNameEquals(@"Data\Fish"); } + /// Edit a matched asset. + /// A helper which encapsulates metadata about an asset and enables changes to it. public void Edit(IAssetData asset) { - Dictionary nightFish = new Dictionary // (T)(object) is a trick to cast anything to T if we know it's compatible + Dictionary nightFish = new Dictionary { [128] = "Pufferfish/80/floater/1/36/1200 1600/summer/sunny/690 .4 685 .1/4/.3/.5/0", [129] = "Anchovy/30/dart/1/16/600 3000/spring fall/both/682 .2/1/.25/.3/0", @@ -78,10 +82,10 @@ namespace Omegasis.NightOwl.Framework [799] = "Spook Fish/60/dart/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0", [800] = "Blobfish/75/floater/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0", }; + + IDictionary data = asset.AsDictionary().Data; foreach (KeyValuePair pair in nightFish) - { - asset.AsDictionary().Set(pair.Key, pair.Value); - } + data[pair.Key] = pair.Value; } } } diff --git a/GeneralMods/NightOwl/NightOwl.cs b/GeneralMods/NightOwl/NightOwl.cs index 05724888..72d3f35b 100644 --- a/GeneralMods/NightOwl/NightOwl.cs +++ b/GeneralMods/NightOwl/NightOwl.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using Microsoft.Xna.Framework; using Netcode; @@ -91,12 +90,11 @@ namespace Omegasis.NightOwl if (this.Config.UseInternalNightFishAssetEditor) this.Helper.Content.AssetEditors.Add(new NightFishing()); - TimeEvents.TimeOfDayChanged += this.TimeEvents_TimeOfDayChanged; - TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted; - SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; - SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; - GameEvents.FourthUpdateTick += this.GameEvents_FourthUpdateTick; - GameEvents.UpdateTick += this.GameEvents_UpdateTick; + helper.Events.GameLoop.TimeChanged += this.OnTimeChanged; + helper.Events.GameLoop.DayStarted += this.OnDayStarted; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; + helper.Events.GameLoop.Saving += this.OnSaving; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; this.shouldWarpHorse = false; } @@ -104,43 +102,40 @@ namespace Omegasis.NightOwl /********* ** Private methods *********/ - /// Updates the earthquake event. + /// Raised after the game state is updated (≈60 times per second). /// The event sender. - /// The event data. - private void GameEvents_UpdateTick(object sender, EventArgs e) + /// The event arguments. + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { this.eve?.tickUpdate(Game1.currentGameTime); - } - /// The method invoked every fourth game update (roughly 15 times per second). - /// The event sender. - /// The event data. - public void GameEvents_FourthUpdateTick(object sender, EventArgs e) - { - try + if (e.IsMultipleOf(4)) // ≈15 times per second { - // reset position after collapse - if (Context.IsWorldReady && this.JustStartedNewDay && this.Config.KeepPositionAfterCollapse) + try { - if (this.PreCollapseMap != null) - Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false); + // reset position after collapse + if (Context.IsWorldReady && this.JustStartedNewDay && this.Config.KeepPositionAfterCollapse) + { + if (this.PreCollapseMap != null) + Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false); - this.PreCollapseMap = null; - this.JustStartedNewDay = false; - this.JustCollapsed = false; + this.PreCollapseMap = null; + this.JustStartedNewDay = false; + this.JustCollapsed = false; + } + } + catch (Exception ex) + { + this.Monitor.Log(ex.ToString(), LogLevel.Error); + this.WriteErrorLog(); } } - catch (Exception ex) - { - this.Monitor.Log(ex.ToString(), LogLevel.Error); - this.WriteErrorLog(); - } } - /// The method invoked before the game saves. + /// Raised before the game begins writes data to the save file (except the initial save creation). /// The event sender. - /// The event data. - public void SaveEvents_BeforeSave(object sender, EventArgs e) + /// The event arguments. + public void OnSaving(object sender, SavingEventArgs e) { int collapseFee = 0; string[] passOutFees = Game1.player.mailbox @@ -156,20 +151,20 @@ namespace Omegasis.NightOwl Game1.player.money += collapseFee; } - /// The method invoked after the player loads a save. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. - /// The event data. - public void SaveEvents_AfterLoad(object sender, EventArgs e) + /// The event arguments. + public void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { this.IsUpLate = false; this.JustStartedNewDay = false; this.JustCollapsed = false; } - /// The method invoked when a new day starts. + /// Raised after the game begins a new day (including when the player loads a save). /// The event sender. - /// The event data. - public void TimeEvents_AfterDayStarted(object sender, EventArgs e) + /// The event arguments. + public void OnDayStarted(object sender, DayStartedEventArgs e) { try { @@ -252,10 +247,10 @@ namespace Omegasis.NightOwl this.Helper.Reflection.GetField(mountain, "railroadBlockRect").SetValue(Rectangle.Empty); } - /// The method invoked when changes. + /// Raised after the in-game clock time changes. /// The event sender. - /// The event data. - private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e) + /// The event arguments. + private void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (!Context.IsWorldReady) return; diff --git a/GeneralMods/NightOwl/manifest.json b/GeneralMods/NightOwl/manifest.json index 070c5081..b7a37179 100644 --- a/GeneralMods/NightOwl/manifest.json +++ b/GeneralMods/NightOwl/manifest.json @@ -5,6 +5,6 @@ "Description": "Lets you stay up all night.", "UniqueID": "Omegasis.NightOwl", "EntryDll": "NightOwl.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:433" ] } diff --git a/GeneralMods/NoMorePets/NoMorePets.cs b/GeneralMods/NoMorePets/NoMorePets.cs index 7b38c409..39a8add1 100644 --- a/GeneralMods/NoMorePets/NoMorePets.cs +++ b/GeneralMods/NoMorePets/NoMorePets.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; using StardewModdingAPI; using StardewModdingAPI.Events; @@ -17,17 +16,17 @@ namespace Omegasis.NoMorePets /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; } /********* ** Private methods *********/ - /// The method invoked after the player loads a save. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. - /// The event data. - public void SaveEvents_AfterLoad(object sender, EventArgs e) + /// The event arguments. + public void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { foreach (Pet pet in Game1.player.currentLocation.getCharacters().OfType().ToArray()) pet.currentLocation.characters.Remove(pet); diff --git a/GeneralMods/NoMorePets/manifest.json b/GeneralMods/NoMorePets/manifest.json index 4f44bd43..6c1a9aae 100644 --- a/GeneralMods/NoMorePets/manifest.json +++ b/GeneralMods/NoMorePets/manifest.json @@ -5,6 +5,6 @@ "Description": "Removes all pets from the game.", "UniqueID": "Omegasis.NoMorePets", "EntryDll": "NoMorePets.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:506" ] } diff --git a/GeneralMods/Revitalize/manifest.json b/GeneralMods/Revitalize/manifest.json index 9674ce58..8ce50f03 100644 --- a/GeneralMods/Revitalize/manifest.json +++ b/GeneralMods/Revitalize/manifest.json @@ -5,6 +5,6 @@ "Description": "A mod that attempts to add in a variety of new things to Stardew.", "UniqueID": "Omegasis.Revitalize", "EntryDll": "Revitalize.dll", - "MinimumApiVersion": "2.3", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [] } diff --git a/GeneralMods/SaveAnywhere/Framework/ModConfig.cs b/GeneralMods/SaveAnywhere/Framework/ModConfig.cs index e48269e3..a43b4f22 100644 --- a/GeneralMods/SaveAnywhere/Framework/ModConfig.cs +++ b/GeneralMods/SaveAnywhere/Framework/ModConfig.cs @@ -1,9 +1,11 @@ +using StardewModdingAPI; + namespace Omegasis.SaveAnywhere.Framework { /// The mod configuration. internal class ModConfig { /// The key which initiates a save. - public string SaveKey { get; set; } = "K"; + public SButton SaveKey { get; set; } = SButton.K; } } diff --git a/GeneralMods/SaveAnywhere/SaveAnywhere.cs b/GeneralMods/SaveAnywhere/SaveAnywhere.cs index 8908de45..126b99f4 100644 --- a/GeneralMods/SaveAnywhere/SaveAnywhere.cs +++ b/GeneralMods/SaveAnywhere/SaveAnywhere.cs @@ -53,11 +53,11 @@ namespace Omegasis.SaveAnywhere this.SaveManager = new SaveManager(this.Helper, this.Helper.Reflection, onLoaded: () => this.ShouldResetSchedules = true); - SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; - SaveEvents.AfterSave += this.SaveEvents_AfterSave; - ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; - GameEvents.UpdateTick += this.GameEvents_UpdateTick; - TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; + helper.Events.GameLoop.Saved += this.OnSaved; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; + helper.Events.GameLoop.DayStarted += this.OnDayStarted; + helper.Events.Input.ButtonPressed += this.OnButtonPressed; ModHelper = helper; ModMonitor = this.Monitor; @@ -68,10 +68,10 @@ namespace Omegasis.SaveAnywhere /********* ** Private methods *********/ - /// The method invoked after the player loads a save. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. - /// The event data. - private void SaveEvents_AfterLoad(object sender, EventArgs e) + /// The event arguments. + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { // reset state this.IsCustomSaving = false; @@ -81,10 +81,10 @@ namespace Omegasis.SaveAnywhere this.SaveManager.LoadData(); } - /// The method invoked after the player finishes saving. + /// Raised after the game finishes writing data to the save file (except the initial save creation). /// The event sender. - /// The event data. - private void SaveEvents_AfterSave(object sender, EventArgs e) + /// The event arguments. + private void OnSaved(object sender, SavedEventArgs e) { // clear custom data after a normal save (to avoid restoring old state) if (!this.IsCustomSaving) @@ -95,10 +95,10 @@ namespace Omegasis.SaveAnywhere } } - /// The method invoked when the game updates (roughly 60 times per second). + /// Raised after the game state is updated (≈60 times per second). /// The event sender. - /// The event data. - private void GameEvents_UpdateTick(object sender, EventArgs e) + /// The event arguments. + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { // let save manager run background logic if (Context.IsWorldReady) @@ -156,10 +156,10 @@ namespace Omegasis.SaveAnywhere Game1.player.currentLocation.characters.Add(monster); } - /// The method invoked after a new day starts. + /// Raised after the game begins a new day (including when the player loads a save). /// The event sender. - /// The event data. - private void TimeEvents_AfterDayStarted(object sender, EventArgs e) + /// The event arguments. + private void OnDayStarted(object sender, DayStartedEventArgs e) { // reload NPC schedules this.ShouldResetSchedules = true; @@ -173,16 +173,16 @@ namespace Omegasis.SaveAnywhere } } - /// The method invoked when the presses a keyboard button. + /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. - /// The event data. - private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + /// The event arguments. + private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsPlayerFree) return; // initiate save (if valid context) - if (e.KeyPressed.ToString() == this.Config.SaveKey) + if (e.Button == this.Config.SaveKey) { if (Game1.client == null) { diff --git a/GeneralMods/SaveAnywhere/manifest.json b/GeneralMods/SaveAnywhere/manifest.json index 9ff92a6a..ffd84748 100644 --- a/GeneralMods/SaveAnywhere/manifest.json +++ b/GeneralMods/SaveAnywhere/manifest.json @@ -5,7 +5,7 @@ "Description": "Lets you save almost anywhere.", "UniqueID": "Omegasis.SaveAnywhere", "EntryDll": "SaveAnywhere.dll", - "MinimumApiVersion": "2.4", + "MinimumApiVersion": "2.10.1", "Dependencies": [ ] } diff --git a/GeneralMods/SimpleSoundManager/manifest.json b/GeneralMods/SimpleSoundManager/manifest.json index a63ef698..bd16daeb 100644 --- a/GeneralMods/SimpleSoundManager/manifest.json +++ b/GeneralMods/SimpleSoundManager/manifest.json @@ -5,6 +5,6 @@ "Description": "A simple framework to play sounds from wave banks and wav files.", "UniqueID": "Omegasis.SimpleSoundManager", "EntryDll": "SimpleSoundManager.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:1410" ] } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Config.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Config.cs index 7342582c..76413128 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Config.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Config.cs @@ -1,3 +1,5 @@ +using StardewModdingAPI; + namespace StardewSymphonyRemastered { /// A class that handles all of the config files for this mod. @@ -13,7 +15,7 @@ namespace StardewSymphonyRemastered public int MaximumDelayBetweenSongsInMilliseconds { get; set; } = 60000; /// The key binding to open the menu music. - public string KeyBinding { get; set; } = "L"; + public SButton KeyBinding { get; set; } = SButton.L; /// Whether to write a JSON file for every possible option for a music pack. Use at your own risk! public bool WriteAllConfigMusicOptions { get; set; } = false; diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs index 5ea907d9..d9b8238b 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs @@ -1,5 +1,3 @@ -using System; -using System.IO; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI; @@ -47,19 +45,16 @@ namespace StardewSymphonyRemastered ModHelper = helper; ModMonitor = this.Monitor; Config = helper.ReadConfig(); - SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; - // EventArgsLocationsChanged += LocationEvents_CurrentLocationChanged; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; - PlayerEvents.Warped += this.PlayerEvents_Warped; - GameEvents.UpdateTick += this.GameEvents_UpdateTick; - ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; - SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; + helper.Events.Player.Warped += this.OnPlayerWarped; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; + helper.Events.Input.ButtonPressed += this.OnButtonPressed; + helper.Events.GameLoop.Saving += this.OnSaving; - MenuEvents.MenuChanged += this.MenuEvents_MenuChanged; - MenuEvents.MenuClosed += this.MenuEvents_MenuClosed; + helper.Events.Display.MenuChanged += this.OnMenuChanged; - GameEvents.FirstUpdateTick += this.GameEvents_FirstUpdateTick; - GameEvents.OneSecondTick += this.GameEvents_OneSecondTick; + helper.Events.GameLoop.GameLaunched += this.OnGameLaunched; musicManager = new MusicManager(); @@ -76,34 +71,31 @@ namespace StardewSymphonyRemastered this.LoadMusicPacks(); } - private void GameEvents_OneSecondTick(object sender, EventArgs e) - { - musicManager?.UpdateTimer(); - } - - /// Raised when the player changes locations. This should determine the next song to play. + /// Raised after a player warps to a new location. /// The event sender. /// The event arguments. - private void PlayerEvents_Warped(object sender, EventArgsPlayerWarped e) + private void OnPlayerWarped(object sender, WarpedEventArgs e) { - musicManager.selectMusic(SongSpecifics.getCurrentConditionalString()); - + if (e.IsLocalPlayer) + musicManager.selectMusic(SongSpecifics.getCurrentConditionalString()); } - /// Ran once all of teh entry methods are ran. This will ensure that all custom music from other mods has been properly loaded in. + /// Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations. /// The event sender. /// The event arguments. - private void GameEvents_FirstUpdateTick(object sender, EventArgs e) + private void OnGameLaunched(object sender, GameLaunchedEventArgs e) { + // Ran once all of the entry methods are ran. This will ensure that all custom music from other mods has been properly loaded in. + musicManager.initializeMenuMusic(); //Initialize menu music that has been added to SongSpecifics.menus from all other mods during their Entry function. musicManager.initializeFestivalMusic(); //Initialize festival music that has been added to SongSpecifics.menus from all other mods during their Entry function. musicManager.initializeEventMusic(); //Initialize event music that has been added to SongSpecifics.menus from all other mods during their Entry function. } - /// Events to occur after the game has loaded in. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. /// The event arguments. - private void SaveEvents_AfterLoad(object sender, EventArgs e) + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { //Locaion initialization MUST occur after load. Anything else can occur before. SongSpecifics.initializeLocationsList(); //Gets all Game locations once the player has loaded the game, and all buildings on the player's farm and adds them to a location list. @@ -123,67 +115,74 @@ namespace StardewSymphonyRemastered musicManager.selectMusic(SongSpecifics.getCurrentConditionalString()); } - - /// Choose new music when a menu is closed. + /// Raised after a game menu is opened, closed, or replaced. /// The event sender. /// The event arguments. - private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e) + private void OnMenuChanged(object sender, MenuChangedEventArgs e) { - if (menuChangedMusic) - musicManager.selectMusic(SongSpecifics.getCurrentConditionalString()); + // menu closed + if (e.NewMenu == null) + { + if (menuChangedMusic) + musicManager.selectMusic(SongSpecifics.getCurrentConditionalString()); + } + + // menu changed + else + musicManager.SelectMenuMusic(SongSpecifics.getCurrentConditionalString()); } - /// Choose new music when a menu is opened. + /// Raised before the game begins writes data to the save file (except the initial save creation). /// The event sender. /// The event arguments. - private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e) - { - //var ok = musicManager.currentMusicPack.getNameOfCurrentSong(); - musicManager.SelectMenuMusic(SongSpecifics.getCurrentConditionalString()); - } - - private void SaveEvents_BeforeSave(object sender, EventArgs e) + private void OnSaving(object sender, SavingEventArgs e) { // THIS IS WAY TO LONG to run. Better make it save individual lists when I am editing songs. foreach (var musicPack in musicManager.MusicPacks) musicPack.Value.SaveSettings(); } - /// Fires when a key is pressed to open the music selection menu. + /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. /// The event arguments. - private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { - if (e.KeyPressed.ToString() == Config.KeyBinding && Game1.activeClickableMenu == null) + if (e.Button == Config.KeyBinding && Game1.activeClickableMenu == null) Game1.activeClickableMenu = new Framework.Menus.MusicManagerMenu(Game1.viewport.Width, Game1.viewport.Height); } - /// Raised every frame. Mainly used just to initiate the music packs. Probably not needed. + /// Raised after the game state is updated (≈60 times per second). /// The event sender. /// The event arguments. - private void GameEvents_UpdateTick(object sender, EventArgs e) + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { - if (musicManager == null) return; + // update delay timer + if (e.IsOneSecond) + musicManager?.UpdateTimer(); - if (Config.DisableStardewMusic) + // initiate music packs + if (musicManager != null) { - if (Game1.currentSong != null) + if (Config.DisableStardewMusic) { - Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs - Game1.currentSong.Stop(AudioStopOptions.AsAuthored); - Game1.nextMusicTrack = ""; //same as above line + if (Game1.currentSong != null) + { + Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs + Game1.currentSong.Stop(AudioStopOptions.AsAuthored); + Game1.nextMusicTrack = ""; //same as above line + } } - } - else - { - if (musicManager.CurrentMusicPack == null) return; - if (Game1.currentSong != null && musicManager.CurrentMusicPack.IsPlaying()) + else { - //ModMonitor.Log("STOP THE MUSIC!!!"); - Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs - Game1.currentSong.Stop(AudioStopOptions.AsAuthored); - //Game1.nextMusicTrack = ""; //same as above line + if (musicManager.CurrentMusicPack == null) return; + if (Game1.currentSong != null && musicManager.CurrentMusicPack.IsPlaying()) + { + //ModMonitor.Log("STOP THE MUSIC!!!"); + Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs + Game1.currentSong.Stop(AudioStopOptions.AsAuthored); + //Game1.nextMusicTrack = ""; //same as above line + } } } } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json index 84679222..5218ccf9 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json @@ -5,7 +5,7 @@ "Description": "Adding more music to the game one beep at a time. Now with streaming!", "UniqueID": "Omegasis.StardewSymphonyRemastered", "EntryDll": "StardewSymphonyRemastered.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:425" ], "Dependencies": [ { "UniqueID": "Omegasis.StardustCore" } diff --git a/GeneralMods/StardustCore/manifest.json b/GeneralMods/StardustCore/manifest.json index 48a12f4b..4010f9dc 100644 --- a/GeneralMods/StardustCore/manifest.json +++ b/GeneralMods/StardustCore/manifest.json @@ -5,6 +5,6 @@ "Description": "A core mod that allows for other mods of mine to be run.", "UniqueID": "Omegasis.StardustCore", "EntryDll": "StardustCore.dll", - "MinimumApiVersion": "2.3", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [] } diff --git a/GeneralMods/SundropMapEvents/Class1.cs b/GeneralMods/SundropMapEvents/Class1.cs index 65501e3a..1c700d26 100644 --- a/GeneralMods/SundropMapEvents/Class1.cs +++ b/GeneralMods/SundropMapEvents/Class1.cs @@ -1,9 +1,9 @@ -using System; using EventSystem.Framework.Events; using EventSystem.Framework.FunctionEvents; using EventSystem.Framework.Information; using Microsoft.Xna.Framework; using StardewModdingAPI; +using StardewModdingAPI.Events; using StardewValley; namespace SundropMapEvents { @@ -18,10 +18,13 @@ namespace SundropMapEvents { ModHelper = this.Helper; ModMonitor = this.Monitor; - StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; } - private void SaveEvents_AfterLoad(object sender, EventArgs e) + /// Raised after the player loads a save slot and the world is initialised. + /// The event sender. + /// The event arguments. + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false))); EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13), new MouseButtonEvents(null, null), new MouseEntryLeaveEvent(null, null), "Hello there!")); diff --git a/GeneralMods/SundropMapEvents/manifest.json b/GeneralMods/SundropMapEvents/manifest.json index c0e8d821..61822a3c 100644 --- a/GeneralMods/SundropMapEvents/manifest.json +++ b/GeneralMods/SundropMapEvents/manifest.json @@ -1,11 +1,11 @@ { - "Name": "SunDropMapEvents", + "Name": "SunDrop Map Events", "Author": "Alpha_Omegasis", "Version": "0.1.0", "Description": "A system to add events to the SunDropMod", "UniqueID": "SunDrop.MapEvents", "EntryDll": "SunDropMapEvents.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [], "Dependencies": [ { "UniqueID": "Omegasis.EventSystem" } diff --git a/GeneralMods/TimeFreeze/TimeFreeze.cs b/GeneralMods/TimeFreeze/TimeFreeze.cs index b712edd5..8e572bff 100644 --- a/GeneralMods/TimeFreeze/TimeFreeze.cs +++ b/GeneralMods/TimeFreeze/TimeFreeze.cs @@ -1,4 +1,3 @@ -using System; using Omegasis.TimeFreeze.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; @@ -16,8 +15,6 @@ namespace Omegasis.TimeFreeze /// The mod configuration. private ModConfig Config; - public int oldInterval; - /********* ** Public methods @@ -28,18 +25,17 @@ namespace Omegasis.TimeFreeze { this.Config = helper.ReadConfig(); - GameEvents.UpdateTick += this.GameEvents_UpdateTick; - //oldInterval = 7; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; } /********* ** Private methods *********/ - /// The method invoked when the game updates (roughly 60 times per second). + /// Raised after the game state is updated (≈60 times per second). /// The event sender. - /// The event data. - private void GameEvents_UpdateTick(object sender, EventArgs e) + /// The event arguments. + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { if (!Context.IsWorldReady) return; diff --git a/GeneralMods/TimeFreeze/manifest.json b/GeneralMods/TimeFreeze/manifest.json index f96a7755..e2876405 100644 --- a/GeneralMods/TimeFreeze/manifest.json +++ b/GeneralMods/TimeFreeze/manifest.json @@ -5,6 +5,6 @@ "Description": "Emulates old Harvest Moon-style games where time is frozen inside.", "UniqueID": "Omegasis.TimeFreeze", "EntryDll": "TimeFreeze.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:973" ] } diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.cs b/GeneralMods/Vocalization/Vocalization/Vocalization.cs index db3fd619..40832064 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.cs +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.cs @@ -213,10 +213,9 @@ namespace Vocalization /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; - GameEvents.UpdateTick += this.GameEvents_UpdateTick; - MenuEvents.MenuClosed += this.MenuEvents_MenuClosed; - MenuEvents.MenuChanged += this.MenuEvents_MenuChanged; + helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; + helper.Events.Display.MenuChanged += this.MenuEvents_MenuChanged; ModMonitor = this.Monitor; ModHelper = this.Helper; Manifest = this.ModManifest; @@ -238,33 +237,30 @@ namespace Vocalization } - private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e) + /// Raised after a game menu is opened, closed, or replaced. + /// The event sender. + /// The event arguments. + private void MenuEvents_MenuChanged(object sender, MenuChangedEventArgs e) { - if (Game1.activeClickableMenu is ModularGameMenu) + //Clean out my previous dialogue when I close any sort of menu. + if (e.NewMenu == null) + { + try + { + soundManager.stopAllSounds(); + } + catch { } + previousDialogue = ""; + } + + else if (Game1.activeClickableMenu is ModularGameMenu) this.npcPortraitHack(); } - /// Runs whenever any onscreen menu is closed. + /// Raised after the player loads a save slot and the world is initialised. /// The event sender. /// The event arguments. - private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e) - { - //Clean out my previous dialogue when I close any sort of menu. - try - { - soundManager.stopAllSounds(); - previousDialogue = ""; - } - catch - { - previousDialogue = ""; - } - } - - /// Runs after the game is loaded to initialize all of the mod's files. - /// The event sender. - /// The event arguments. - private void SaveEvents_AfterLoad(object sender, EventArgs e) + private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { this.initialzeModualGameMenuHack(); this.initialzeDirectories(); @@ -366,10 +362,11 @@ namespace Vocalization */ return field.GetValue(instance); } - /// Runs every game tick to check if the player is talking to an npc. + + /// Raised after the game state is updated (≈60 times per second). /// The event sender. /// The event arguments. - private void GameEvents_UpdateTick(object sender, EventArgs e) + private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { soundManager.update(); if (Game1.player != null) diff --git a/GeneralMods/Vocalization/Vocalization/manifest.json b/GeneralMods/Vocalization/Vocalization/manifest.json index e343f73a..2656490d 100644 --- a/GeneralMods/Vocalization/Vocalization/manifest.json +++ b/GeneralMods/Vocalization/Vocalization/manifest.json @@ -5,7 +5,7 @@ "Description": "A mod that brings voice acting to Stardew Valley.", "UniqueID": "Omegasis.Vocalization", "EntryDll": "Vocalization.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [], "Dependencies": [ { "UniqueID": "Omegasis.SimpleSoundManager" },