diff --git a/GeneralMods/AutoSpeed/AutoSpeed.cs b/GeneralMods/AutoSpeed/AutoSpeed.cs index ac89c8b3..bde35c77 100644 --- a/GeneralMods/AutoSpeed/AutoSpeed.cs +++ b/GeneralMods/AutoSpeed/AutoSpeed.cs @@ -1,74 +1,73 @@ using System; using System.IO; using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; namespace Omegasis.AutoSpeed { - + /// The mod entry point. public class AutoSpeed : Mod { - int speed_int = 5; + /********* + ** Properties + *********/ + /// The speed multiplier. + private int Speed = 5; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - //StardewModdingAPI.Events.GameEvents.UpdateTick += Events_UpdateTick; - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - var configLocation = Path.Combine(helper.DirectoryPath, "AutoSpeed_Data.txt"); + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + + string configLocation = Path.Combine(helper.DirectoryPath, "AutoSpeed_Data.txt"); if (!File.Exists(configLocation)) - { - speed_int = 1; - } - DataLoader(); - // MyWritter(); - Monitor.Log("AutoSpeed Initialization Completed",LogLevel.Info); + this.Speed = 1; + + this.LoadConfig(); + this.Monitor.Log("AutoSpeed Initialization Completed", LogLevel.Info); } + + /********* + ** Private methods + *********/ + /// 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) { - StardewValley.Game1.player.addedSpeed = speed_int; + Game1.player.addedSpeed = Speed; } - void DataLoader() + /// Load the configuration settings. + private void LoadConfig() { - //loads the data to the variables upon loading the game. - var mylocation = Path.Combine(Helper.DirectoryPath, "AutoSpeed_data.txt"); - if (!File.Exists(mylocation)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Monitor.Log("The config file for AutoSpeed was not found, guess I'll create it...",LogLevel.Warn); - MyWritter(); - } + string path = Path.Combine(this.Helper.DirectoryPath, "AutoSpeed_data.txt"); + if (!File.Exists(path)) + this.WriteConfig(); else { - string[] readtext = File.ReadAllLines(mylocation); - speed_int = Convert.ToInt32(readtext[3]); + string[] text = File.ReadAllLines(path); + this.Speed = Convert.ToInt32(text[3]); } } - - void MyWritter() + + /// Save the configuration settings. + void WriteConfig() { - //saves the BuildEndurance_data at the end of a new day; - var mylocation = Path.Combine(Helper.DirectoryPath, "AutoSpeed_data.txt"); - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation)) - { - Monitor.Log("The data file for AutoSpeed was not found, guess I'll create it when you sleep.",LogLevel.Info); - - mystring3[0] = "Player: AutoSpeed Config:"; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Player Added Speed:"; - mystring3[3] = speed_int.ToString(); - File.WriteAllLines(mylocation, mystring3); - } - else - { - mystring3[0] = "Player: AutoSpeed Config:"; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player Added Speed:"; - mystring3[3] = speed_int.ToString(); - - File.WriteAllLines(mylocation, mystring3); - } + string path = Path.Combine(this.Helper.DirectoryPath, "AutoSpeed_data.txt"); + string[] text = new string[20]; + text[0] = "Player: AutoSpeed Config:"; + text[1] = "===================================================================================="; + text[2] = "Player Added Speed:"; + text[3] = Speed.ToString(); + File.WriteAllLines(path, text); } - - } //end my function -} \ No newline at end of file + } +} diff --git a/GeneralMods/AutoSpeed/AutoSpeed.csproj b/GeneralMods/AutoSpeed/AutoSpeed.csproj index 26e14532..1c9aac56 100644 --- a/GeneralMods/AutoSpeed/AutoSpeed.csproj +++ b/GeneralMods/AutoSpeed/AutoSpeed.csproj @@ -34,6 +34,9 @@ + + Properties\GlobalAssemblyInfo.cs + diff --git a/GeneralMods/AutoSpeed/Properties/AssemblyInfo.cs b/GeneralMods/AutoSpeed/Properties/AssemblyInfo.cs index 82848cd7..60f65a00 100644 --- a/GeneralMods/AutoSpeed/Properties/AssemblyInfo.cs +++ b/GeneralMods/AutoSpeed/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("AutoSpeed")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("AutoSpeed")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("57e7d17e-c237-448b-a50f-cfb67f9bb146")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/AutoSpeed/README.md b/GeneralMods/AutoSpeed/README.md index 8100c10a..4610bbe4 100644 --- a/GeneralMods/AutoSpeed/README.md +++ b/GeneralMods/AutoSpeed/README.md @@ -1,20 +1,20 @@ -# AutoSpeed_Mod +**Auto Speed** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you move faster +without the need to enter commands in the console. +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. -Initial Post: 3/27/16 -Updated: v1.1.0 10/11/16 +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/443). +3. Run the game using SMAPI. -Compatability: -Windows -SDV 1.1 +## Usage +Launch the game with the mod installed to generate the config file, then edit the +`AutoSpeed_data.txt` to set the speed you want (higher values are faster). -Changelog: -1.1.0 --Updated to SDv 1.1 --Updated to SMAPI 0.40.0 1.1-3 +## Versions +1.0 +* Initial release. -Description: -This is a simple .dll mod for SMAPI which automatically changes the character's speed value referenced in AutoSpeed.txt. -This basically just bypasses having to type in the command everytime you load SMAPI. - -Install in by putting it into Stardew Valley/Mods/AutoSpeed! +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. diff --git a/GeneralMods/AutoSpeed/manifest.json b/GeneralMods/AutoSpeed/manifest.json index 1dd85526..7626445d 100644 --- a/GeneralMods/AutoSpeed/manifest.json +++ b/GeneralMods/AutoSpeed/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "AutoSpeed", "PerSaveConfigs": false, "EntryDll": "AutoSpeed.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs b/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs new file mode 100644 index 00000000..3c6523ef --- /dev/null +++ b/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs @@ -0,0 +1,88 @@ +using System; +using System.IO; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; +using StardewValley.Menus; + +namespace Omegasis.BillboardAnywhere +{ + /// The mod entry point. + public class BillboardAnywhere : Mod + { + /********* + ** Properties + *********/ + /// The key which shows the billboard menu. + private string KeyBinding = "B"; + + /// Whether the player loaded a save. + private bool IsGameLoaded; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + } + + + /********* + ** Private methods + *********/ + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + this.IsGameLoaded = true; + this.LoadConfig(); + } + + /// The method invoked when the presses a keyboard button. + /// The event sender. + /// The event data. + public void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + { + if (Game1.player == null || Game1.player.currentLocation == null || this.IsGameLoaded == false || Game1.activeClickableMenu != null) + return; + + // load menu if key pressed + if (e.KeyPressed.ToString() == this.KeyBinding) + Game1.activeClickableMenu = new Billboard(); + } + + /// Load the configuration settings. + void LoadConfig() + { + string path = Path.Combine(this.Helper.DirectoryPath, "Billboard_Anywhere_Config.txt"); + if (!File.Exists(path)) + { + this.KeyBinding = "B"; + this.WriteConfig(); + } + else + { + string[] text = File.ReadAllLines(path); + this.KeyBinding = Convert.ToString(text[3]); + } + } + + /// Save the configuration settings. + void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Billboard_Anywhere_Config.txt"); + string[] text = new string[20]; + text[0] = "Config: Billboard_Anywhere. Feel free to mess with these settings."; + text[1] = "===================================================================================="; + text[2] = "Key binding for opening the billboard anywhere. Press this key to do so"; + text[3] = this.KeyBinding; + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj b/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj index a28ab3bf..4023451c 100644 --- a/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj +++ b/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj @@ -34,7 +34,10 @@ - + + Properties\GlobalAssemblyInfo.cs + + @@ -42,7 +45,7 @@ - + diff --git a/GeneralMods/BillboardAnywhere/Class1.cs b/GeneralMods/BillboardAnywhere/Class1.cs deleted file mode 100644 index b9e95ddf..00000000 --- a/GeneralMods/BillboardAnywhere/Class1.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.IO; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.BillboardAnywhere -{ - public class Class1 : Mod - { - string key_binding = "B"; - - bool game_loaded = false; - - public override void Entry(IModHelper helper) - { - //set up all of my events here - StardewModdingAPI.Events.SaveEvents.AfterLoad += SecondPlayerEvents_LoadedGame; - StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; - } - - private void SecondPlayerEvents_LoadedGame(object sender, EventArgs e) - { - game_loaded = true; - DataLoader_Settings(); - } - - public void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) - { - if (Game1.player == null) return; - if (Game1.player.currentLocation == null) return; - if (game_loaded == false) return; - - if (e.KeyPressed.ToString() == key_binding) //if the key is pressed, load my cusom save function - { - if (Game1.activeClickableMenu != null) return; - my_menu(); - } - } - - void DataLoader_Settings() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "Billboard_Anywhere_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - // Console.WriteLine("Can't load custom save info since the file doesn't exist."); - key_binding = "B"; - MyWritter_Settings(); - } - - else - { - string[] readtext = File.ReadAllLines(mylocation3); - key_binding = Convert.ToString(readtext[3]); - } - } - - void MyWritter_Settings() - { - //write all of my info to a text file. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "Billboard_Anywhere_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("Billboard_Anywhere: The Billboard Anywhere Config doesn't exist. Creating it now."); - mystring3[0] = "Config: Billboard_Anywhere. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Key binding for opening the billboard anywhere. Press this key to do so"; - mystring3[3] = key_binding.ToString(); - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - mystring3[0] = "Config: Billboard_Anywhere Info. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Key binding for opening the billboard anywhere. Press this key to do so"; - mystring3[3] = key_binding.ToString(); - File.WriteAllLines(mylocation3, mystring3); - } - } - - void my_menu() - { - Game1.activeClickableMenu = new StardewValley.Menus.Billboard(); - } - - } -} -//end class \ No newline at end of file diff --git a/GeneralMods/BillboardAnywhere/Properties/AssemblyInfo.cs b/GeneralMods/BillboardAnywhere/Properties/AssemblyInfo.cs index be301328..ec9ded0e 100644 --- a/GeneralMods/BillboardAnywhere/Properties/AssemblyInfo.cs +++ b/GeneralMods/BillboardAnywhere/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("BillboardAnywhere")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BillboardAnywhere")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("07a9efaa-1759-49c8-8a82-49210047b975")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/BillboardAnywhere/README.md b/GeneralMods/BillboardAnywhere/README.md new file mode 100644 index 00000000..f6649f40 --- /dev/null +++ b/GeneralMods/BillboardAnywhere/README.md @@ -0,0 +1,20 @@ +**Billboard Anywhere** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you look at +the billboard anywhere in-game for easy access to upcoming events and birthdays. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/492). +3. Run the game using SMAPI. + +## Usage +Press `B` while in-game to show the billboard menu. Edit the `Billboard_Anywhere_Config.txt` file +to change the key. + +## Versions +1.0 +* Initial release. + +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. diff --git a/GeneralMods/BillboardAnywhere/Readme.txt b/GeneralMods/BillboardAnywhere/Readme.txt deleted file mode 100644 index a54b33ed..00000000 --- a/GeneralMods/BillboardAnywhere/Readme.txt +++ /dev/null @@ -1,12 +0,0 @@ -Billboard Anywhere 1.1.0 - -Posted 7/12/16 at 1:29 AM -Updated: 10/11/16 1:08AM - -Updates: -1.1.0 --Updated to SDV 1.1 - -Usage:See config - --A simple mod that allows the Billboard/Calendar to be shown anywhere by pressing the key defined in Billboard_Anywhere_Config.txt diff --git a/GeneralMods/BillboardAnywhere/manifest.json b/GeneralMods/BillboardAnywhere/manifest.json index bceffa3b..684fb28f 100644 --- a/GeneralMods/BillboardAnywhere/manifest.json +++ b/GeneralMods/BillboardAnywhere/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "7ad4f6f7-c3de-4729-a40f-7a11d2b2a358", "PerSaveConfigs": false, "EntryDll": "BillboardAnywhere.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/BuildEndurance/BuildEndurance.cs b/GeneralMods/BuildEndurance/BuildEndurance.cs new file mode 100644 index 00000000..4a7728af --- /dev/null +++ b/GeneralMods/BuildEndurance/BuildEndurance.cs @@ -0,0 +1,349 @@ +using System; +using System.IO; +using System.Text; +using Newtonsoft.Json; +using Omegasis.BuildEndurance.Framework; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +namespace Omegasis.BuildEndurance +{ + /// The mod entry point. + public class BuildEndurance : Mod + { + /********* + ** Properties + *********/ + /// The mod settings and player data. + private ModConfig Config; + + /// Whether the player has been exhausted today. + private bool WasExhausted; + + /// Whether the player has collapsed today. + private bool WasCollapsed; + + /// The XP points needed to reach the next endurance level. + private double ExpToNextLevel = 20; + + /// The player's current endurance XP points. + private double CurrentExp; + + /// The player's current endurance level. + private int CurrentLevel; + + /// The stamina points to add to the player's base stamina due to their current endurance level. + private int CurrentLevelStaminaBonus; + + /// The initial stamina bonus to apply regardless of the player's endurance level, from the config file. + private int BaseStaminaBonus; + + /// Whether to reset all changes by the mod to the default values (i.e. start over). + private bool ClearModEffects; + + /// The player's original stamina value, excluding mod effects. + private int OriginalStamina; + + /// Whether the player recently gained XP for tool use. + private bool HasRecentToolExp; + + /// Whether the player was eating last time we checked. + private bool WasEating; + + /// Whether the player has loaded a save. + private bool IsLoaded; + + /// The player's stamina last time they slept. + private int NightlyStamina; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + GameEvents.OneSecondTick += this.GameEvents_OneSecondTick; + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + + string configPath = Path.Combine(helper.DirectoryPath, "BuildEnduranceConfig.json"); + if (!File.Exists(configPath)) + { + this.Monitor.Log("Initial configuration file setup."); + this.Config = new ModConfig + { + CurrentLevel = 0, + MaxLevel = 100, + StaminaIncreasePerLevel = 1, + CurrentExp = 0, + ExpToNextLevel = 20, + ExpCurve = 1.15, + ExpForEating = 2, + ExpForSleeping = 10, + ExpForToolUse = 1, + BaseStaminaBonus = 0, + CurrentLevelStaminaBonus = 0, + ExpForExhaustion = 25, + ExpForCollapsing = 50 + }; + File.WriteAllBytes(configPath, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(this.Config))); + } + else + { + this.Config = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(File.ReadAllBytes(configPath))); + this.Monitor.Log("Found BuildEndurance config file."); + } + + this.Monitor.Log("BuildEndurance Initialization Completed"); + } + + /// The method invoked once per second during a game update. + /// The event sender. + /// The event data. + public 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. + public void GameEvents_UpdateTick(object sender, EventArgs e) + { + // give XP when player finishes eating + if (Game1.isEating) + this.WasEating = true; + else if (this.WasEating) + { + this.CurrentExp += this.Config.ExpForEating; + this.WasEating = false; + } + + // give XP when player uses tool + if (!this.HasRecentToolExp && Game1.player.usingTool) + { + this.CurrentExp += this.Config.ExpForToolUse; + this.HasRecentToolExp = true; + } + + // give XP when exhausted + if (!this.WasExhausted && Game1.player.exhausted) + { + this.CurrentExp += this.Config.ExpForExhaustion; + this.WasExhausted = true; + this.Monitor.Log("The player is exhausted"); + } + + // give XP when player stays up too late or collapses + if (!this.WasCollapsed && Game1.farmerShouldPassOut) + { + this.CurrentExp += this.Config.ExpForCollapsing; + this.WasCollapsed = true; + this.Monitor.Log("The player has collapsed!"); + } + } + + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + public void SaveEvents_AfterLoad(object sender, EventArgs e) + { + // initialise + this.LoadConfig(); + this.WriteConfig(); + this.IsLoaded = true; + + // grab initial stamina + var player = Game1.player; + if (this.OriginalStamina == 0) + this.OriginalStamina = player.MaxStamina; + + // set nightly stamina + player.MaxStamina = this.NightlyStamina; + if (this.NightlyStamina == 0) + player.MaxStamina = this.BaseStaminaBonus + this.CurrentLevelStaminaBonus + this.OriginalStamina; + + // reset if needed + if (this.ClearModEffects) + player.MaxStamina = this.OriginalStamina; + + // save config + this.LoadConfig(); + this.WriteConfig(); + } + + /// The method invoked when changes. + /// The event sender. + /// The event data. + public void TimeEvents_DayOfMonthChanged(object sender, EventArgs e) + { + // reset data + this.WasExhausted = false; + this.WasCollapsed = false; + if (!this.IsLoaded) + return; + + // update settings + this.Monitor.Log(this.CurrentExp.ToString()); + this.UpdateClearSetting(); + this.Monitor.Log(this.ClearModEffects.ToString()); + + var player = Game1.player; + this.CurrentExp += this.Config.ExpForSleeping; + if (this.OriginalStamina == 0) + this.OriginalStamina = player.MaxStamina; //grab the initial stamina value + + if (this.ClearModEffects) + { + this.LoadClearSettings(); + player.MaxStamina = this.OriginalStamina; + this.ExpToNextLevel = this.Config.ExpToNextLevel; + this.CurrentExp = this.Config.CurrentExp; + this.CurrentLevelStaminaBonus = 0; + this.OriginalStamina = player.MaxStamina; + this.BaseStaminaBonus = 0; + this.CurrentLevel = 0; + } + + if (!this.ClearModEffects && this.CurrentLevel < this.Config.MaxLevel) + { + while (this.CurrentExp >= this.ExpToNextLevel) + { + this.CurrentLevel += 1; + this.CurrentExp = this.CurrentExp - this.ExpToNextLevel; + this.ExpToNextLevel = (this.Config.ExpCurve * this.ExpToNextLevel); + player.MaxStamina += this.Config.StaminaIncreasePerLevel; + this.CurrentLevelStaminaBonus += this.Config.StaminaIncreasePerLevel; + + } + } + this.ClearModEffects = false; + this.NightlyStamina = Game1.player.maxStamina; + this.WriteConfig(); + } + + /// Update the settings needed for from the latest config file on disk. + void LoadClearSettings() + { + this.LoadConfig(); + this.WriteConfig(); + + if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) + Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); + + string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildEndurance_data_{Game1.player.name}.txt"); + if (!File.Exists(path)) + { + Console.WriteLine("Clear Data Loaded could not find the correct file."); + + this.ClearModEffects = false; + this.OriginalStamina = 0; + this.BaseStaminaBonus = 0; + } + else + { + string[] text = File.ReadAllLines(path); + this.BaseStaminaBonus = Convert.ToInt32(text[9]); + this.ClearModEffects = Convert.ToBoolean(text[14]); + this.OriginalStamina = Convert.ToInt32(text[16]); + } + } + + /// Update based on the latest config file on disk. + private void UpdateClearSetting() + { + if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) + Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); + + string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildEndurance_data_{Game1.player.name}.txt"); + if (!File.Exists(path)) + { + Console.WriteLine("Clear Data Loaded could not find the correct file."); + + this.ClearModEffects = false; + this.OriginalStamina = 0; + this.BaseStaminaBonus = 0; + } + else + { + string[] text = File.ReadAllLines(path); + this.ClearModEffects = Convert.ToBoolean(text[14]); + } + } + + /// Load the configuration settings. + void LoadConfig() + { + if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) + Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); + + string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildEndurance_data_{Game1.player.name}.txt"); + if (!File.Exists(path)) + { + this.ExpToNextLevel = this.Config.ExpToNextLevel; + this.CurrentExp = this.Config.CurrentExp; + this.CurrentLevel = this.Config.CurrentLevel; + this.BaseStaminaBonus = this.Config.BaseStaminaBonus; + this.CurrentLevelStaminaBonus = this.Config.CurrentLevelStaminaBonus; + this.ClearModEffects = false; + this.OriginalStamina = 0; + } + else + { + string[] text = File.ReadAllLines(path); + this.CurrentLevel = Convert.ToInt32(text[3]); + this.ExpToNextLevel = Convert.ToDouble(text[7]); + this.CurrentExp = Convert.ToDouble(text[5]); + this.BaseStaminaBonus = Convert.ToInt32(text[9]); + this.CurrentLevelStaminaBonus = Convert.ToInt32(text[11]); + this.ClearModEffects = Convert.ToBoolean(text[14]); + this.OriginalStamina = Convert.ToInt32(text[16]); + this.NightlyStamina = Convert.ToInt32(text[18]); + } + } + + /// Save the configuration settings. + void WriteConfig() + { + if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) + Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); + + string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildEndurance_data_{Game1.player.name}.txt"); + string[] text = new string[20]; + text[0] = "Player: Build Endurance Data. Modification can cause errors. Edit at your own risk."; + text[1] = "===================================================================================="; + + text[2] = "Player Current Level:"; + text[3] = this.CurrentLevel.ToString(); + + text[4] = "Player Current XP:"; + text[5] = this.CurrentExp.ToString(); + + text[6] = "Xp to next Level:"; + text[7] = this.ExpToNextLevel.ToString(); + + text[8] = "Initial Stam Bonus:"; + text[9] = this.BaseStaminaBonus.ToString(); + + text[10] = "Additional Stam Bonus:"; + text[11] = this.CurrentLevelStaminaBonus.ToString(); + + text[12] = "======================================================================================="; + text[13] = "RESET ALL MOD EFFECTS? This will effective start you back at square 1. Also good if you want to remove this mod."; + text[14] = this.ClearModEffects.ToString(); + text[15] = "OLD STAMINA AMOUNT: This is the initial value of the Player's Stamina before this mod took over."; + text[16] = this.OriginalStamina.ToString(); + + text[17] = "Nightly Stamina Value: This is the value of the player's stamina that was saved when the player slept."; + text[18] = this.NightlyStamina.ToString(); + + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/BuildEndurance/BuildEndurance.csproj b/GeneralMods/BuildEndurance/BuildEndurance.csproj index 2f10904f..16ff6c1a 100644 --- a/GeneralMods/BuildEndurance/BuildEndurance.csproj +++ b/GeneralMods/BuildEndurance/BuildEndurance.csproj @@ -32,17 +32,23 @@ ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + False - + + Properties\GlobalAssemblyInfo.cs + + + + diff --git a/GeneralMods/BuildEndurance/Class1.cs b/GeneralMods/BuildEndurance/Class1.cs deleted file mode 100644 index f8616ead..00000000 --- a/GeneralMods/BuildEndurance/Class1.cs +++ /dev/null @@ -1,480 +0,0 @@ -using System; -using System.IO; -using System.Text; -using Newtonsoft.Json; -using StardewModdingAPI; - -namespace Omegasis.BuildEndurance -{ - - public class BuildEndurance : Mod - { - static bool exhausted_check = false; - static bool collapse_check = false; - static double BuildEndurance_data_xp_nextlvl = 20; - static double BuildEndurance_data_xp_current = 0; - static int BuildEndurance_data_current_lvl = 0; - static int BuildEndurance_data_stam_bonus_acumulated = 0; - - static int BuildEndurance_data_ini_stam_bonus = 0; - - static bool BuildEndurance_data_clear_mod_effects = false; - - static int BuildEndurance_data_old_stamina = 0; - - static bool tool_cleaner = false; - - static bool fed = false; - - public Config ModConfig { get; set; } - - static bool upon_loading = false; - - - static int nightly_stamina_value = 0; - - - //Credit goes to Zoryn for pieces of this config generation that I kinda repurposed. - public override void Entry(IModHelper helper) - { - StardewModdingAPI.Events.GameEvents.UpdateTick += EatingCallBack; //sloppy again but it'll do. - - StardewModdingAPI.Events.GameEvents.OneSecondTick += Tool_Cleanup; - StardewModdingAPI.Events.GameEvents.UpdateTick += ToolCallBack; - StardewModdingAPI.Events.SaveEvents.AfterLoad += LoadingCallBack; - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += SleepCallback; - - StardewModdingAPI.Events.GameEvents.UpdateTick += Exhaustion_callback; - StardewModdingAPI.Events.GameEvents.UpdateTick += Collapse_Callback; - - - var configLocation = Path.Combine(helper.DirectoryPath, "BuildEnduranceConfig.json"); - if (!File.Exists(configLocation)) - { - Monitor.Log("Initial configuration file setup."); - ModConfig = new Config(); - - ModConfig.BuildEndurance_current_lvl = 0; - ModConfig.BuildEndurance_max_lvl = 100; - - ModConfig.BuildEndurance_stam_increase_upon_lvl_up = 1; - - ModConfig.BuildEndurance_xp_current = 0; - ModConfig.BuildEndurance_xp_nextlvl = 20; - ModConfig.BuildEndurance_xp_curve = 1.15; - - ModConfig.BuildEndurance_xp_eating = 2; - ModConfig.BuildEndurance_xp_sleeping = 10; - ModConfig.BuildEndurance_xp_tooluse = 1; - - ModConfig.BuildEndurance_ini_stam_boost = 0; - - ModConfig.BuildEndurance_stam_accumulated = 0; - - ModConfig.BuildEndurance_Exhaustion_XP = 25; - ModConfig.BuildEndurance_Pass_Out_XP = 50; - - - File.WriteAllBytes(configLocation, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ModConfig))); - } - else - { - ModConfig = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(File.ReadAllBytes(configLocation))); - Monitor.Log("Found BuildEndurance config file."); - } - - // DataLoader(); - // MyWritter(); //hopefully loading these after the game is loaded will prevent wierd issues. - - Monitor.Log("BuildEndurance Initialization Completed"); - } - - - public void ToolCallBack(object sender, EventArgs e) //ultra quick response for checking if a tool is used. - { - if (tool_cleaner == true) return; - - - if (StardewValley.Game1.player.usingTool == true) - { - // Console.WriteLine("Tool is being used"); - BuildEndurance_data_xp_current += ModConfig.BuildEndurance_xp_tooluse; - //BuildEndurance_data_xp_current += 1000; For testing purposes - // Log.Info(BuildEndurance_data_xp_current); - - tool_cleaner = true; - } - else return; - } - - public void Tool_Cleanup(object sender, EventArgs e) //nerfs how quickly xp is actually gained. I hope. - { - - if (tool_cleaner == true) tool_cleaner = false; - else return; - } - - public void EatingCallBack(object sender, EventArgs e) - { - - - if (StardewValley.Game1.isEating == true) - { - // Console.WriteLine("NOM NOM NOM"); - fed = true; - - //this code will run when the player eats an object. I.E. increases their eating skills. - } - //I'm going to assume they ate the food. - if ((StardewValley.Game1.isEating == false) && fed == true) - { - //Console.WriteLine("NOM NOM NOM22222222222"); - BuildEndurance_data_xp_current += ModConfig.BuildEndurance_xp_eating; - fed = false; - } - - - return; - } - - - public void Exhaustion_callback(object sender, EventArgs e) //if the player is exhausted add xp. - { - - if (exhausted_check == false) - { - if (StardewValley.Game1.player.exhausted) - { - BuildEndurance_data_xp_current += ModConfig.BuildEndurance_Exhaustion_XP; - exhausted_check = true; - Monitor.Log("The player is exhausted"); - } - } - - - } - - - - public void Collapse_Callback(object sender, EventArgs e) //if the player stays up too late add some xp. - { - if (collapse_check == false) - { - - if (StardewValley.Game1.farmerShouldPassOut == true) - { - - BuildEndurance_data_xp_current += ModConfig.BuildEndurance_Pass_Out_XP; - collapse_check = true; - Monitor.Log("The player has collapsed!"); - return; - } - } - } - - - public void LoadingCallBack(object sender, EventArgs e) - { - - DataLoader(); - MyWritter(); - upon_loading = true; - //runs when the player is loaded. - - var player = StardewValley.Game1.player; - - if (BuildEndurance_data_old_stamina == 0) - { - BuildEndurance_data_old_stamina = player.MaxStamina; //grab the initial stamina value - } - - - player.MaxStamina = nightly_stamina_value; - - if (nightly_stamina_value == 0) - { - player.MaxStamina = BuildEndurance_data_ini_stam_bonus + BuildEndurance_data_stam_bonus_acumulated + BuildEndurance_data_old_stamina; //incase the ini stam bonus is loaded in. - } - if (BuildEndurance_data_clear_mod_effects == true) - { - player.MaxStamina = BuildEndurance_data_old_stamina; - // Console.WriteLine("BuildEndurance Reset!"); - } - - DataLoader(); - MyWritter(); - } - - public void SleepCallback(object sender, EventArgs e) - { - //This will run when the character goes to sleep. It will increase their sleeping skill. - exhausted_check = false; - collapse_check = false; - if (upon_loading == true) - { - - //Log.Info("THIS IS MY NEW DAY CALL BACK XP version 1"); - Monitor.Log(BuildEndurance_data_xp_current.ToString()); - - Clear_Checker(); - Monitor.Log(BuildEndurance_data_clear_mod_effects.ToString()); - - var player = StardewValley.Game1.player; - - BuildEndurance_data_xp_current += ModConfig.BuildEndurance_xp_sleeping; - - if (BuildEndurance_data_old_stamina == 0) - { - BuildEndurance_data_old_stamina = player.MaxStamina; //grab the initial stamina value - } - - if (BuildEndurance_data_clear_mod_effects == true) - { - Clear_DataLoader(); - player.MaxStamina = BuildEndurance_data_old_stamina; - BuildEndurance_data_xp_nextlvl = ModConfig.BuildEndurance_xp_nextlvl; - BuildEndurance_data_xp_current = ModConfig.BuildEndurance_xp_current; - BuildEndurance_data_stam_bonus_acumulated = 0; - BuildEndurance_data_old_stamina = player.MaxStamina; - BuildEndurance_data_ini_stam_bonus = 0; - BuildEndurance_data_current_lvl = 0; - - //because this doesn't work propperly at first anyways. - // Console.WriteLine("BuildEndurance Reset!"); - } - - - if (BuildEndurance_data_clear_mod_effects == false) - { - if (BuildEndurance_data_current_lvl < ModConfig.BuildEndurance_max_lvl) - { - while (BuildEndurance_data_xp_current >= BuildEndurance_data_xp_nextlvl) - { - BuildEndurance_data_current_lvl += 1; - BuildEndurance_data_xp_current = BuildEndurance_data_xp_current - BuildEndurance_data_xp_nextlvl; - BuildEndurance_data_xp_nextlvl = (ModConfig.BuildEndurance_xp_curve * BuildEndurance_data_xp_nextlvl); - player.MaxStamina += ModConfig.BuildEndurance_stam_increase_upon_lvl_up; - BuildEndurance_data_stam_bonus_acumulated += ModConfig.BuildEndurance_stam_increase_upon_lvl_up; - - } - } - } - BuildEndurance_data_clear_mod_effects = false; - nightly_stamina_value = StardewValley.Game1.player.maxStamina; - MyWritter(); - } - //else Log.Info("Safely Loading."); - } - - - //Mod config data. - public class Config - { - public double BuildEndurance_xp_nextlvl { get; set; } - public double BuildEndurance_xp_current { get; set; } - public double BuildEndurance_xp_curve { get; set; } - - public int BuildEndurance_current_lvl { get; set; } - public int BuildEndurance_max_lvl { get; set; } - - public int BuildEndurance_stam_increase_upon_lvl_up { get; set; } - - public int BuildEndurance_xp_tooluse { get; set; } - public int BuildEndurance_xp_eating { get; set; } - public int BuildEndurance_xp_sleeping { get; set; } - - public int BuildEndurance_ini_stam_boost { get; set; } - - public int BuildEndurance_stam_accumulated { get; set; } - - public int BuildEndurance_Exhaustion_XP { get; set; } - public int BuildEndurance_Pass_Out_XP { get; set; } - - } - - - void Clear_DataLoader() - { - DataLoader(); - MyWritter(); - if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "PlayerData", "BuildEndurance_data_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Console.WriteLine("Clear Data Loaded could not find the correct file."); - - - BuildEndurance_data_clear_mod_effects = false; - BuildEndurance_data_old_stamina = 0; - BuildEndurance_data_ini_stam_bonus = 0; - //return; - } - - else - { - //loads the BuildEndurance_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation3); - BuildEndurance_data_ini_stam_bonus = Convert.ToInt32(readtext[9]); - BuildEndurance_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); - BuildEndurance_data_old_stamina = Convert.ToInt32(readtext[16]); - - } - } - - void Clear_Checker() - { - - //loads the data to the variables upon loading the game. - if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "PlayerData", "BuildEndurance_data_"); ; - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Console.WriteLine("Clear Data Loaded could not find the correct file."); - - - BuildEndurance_data_clear_mod_effects = false; - BuildEndurance_data_old_stamina = 0; - BuildEndurance_data_ini_stam_bonus = 0; - //return; - } - - else - { - //loads the BuildEndurance_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation3); - BuildEndurance_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); - - - } - } - - - - void DataLoader() - { - if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath,"PlayerData", "BuildEndurance_data_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Console.WriteLine("DataLoading"); - BuildEndurance_data_xp_nextlvl = ModConfig.BuildEndurance_xp_nextlvl; - BuildEndurance_data_xp_current = ModConfig.BuildEndurance_xp_current; - BuildEndurance_data_current_lvl = ModConfig.BuildEndurance_current_lvl; - BuildEndurance_data_ini_stam_bonus = ModConfig.BuildEndurance_ini_stam_boost; - BuildEndurance_data_stam_bonus_acumulated = ModConfig.BuildEndurance_stam_accumulated; - BuildEndurance_data_clear_mod_effects = false; - BuildEndurance_data_old_stamina = 0; - - } - - else - { - // Console.WriteLine("HEY THERE IM LOADING DATA"); - - //loads the BuildEndurance_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation3); - BuildEndurance_data_current_lvl = Convert.ToInt32(readtext[3]); - BuildEndurance_data_xp_nextlvl = Convert.ToDouble(readtext[7]); //these array locations refer to the lines in BuildEndurance_data.json - BuildEndurance_data_xp_current = Convert.ToDouble(readtext[5]); - BuildEndurance_data_ini_stam_bonus = Convert.ToInt32(readtext[9]); - BuildEndurance_data_stam_bonus_acumulated = Convert.ToInt32(readtext[11]); - BuildEndurance_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); - BuildEndurance_data_old_stamina = Convert.ToInt32(readtext[16]); - nightly_stamina_value = Convert.ToInt32(readtext[18]); //this should grab the nightly stamina values - } - } - - void MyWritter() - { - //saves the BuildEndurance_data at the end of a new day; - if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath,"PlayerData", "BuildEndurance_data_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Console.WriteLine("The data file for BuildEndurance was not found, guess I'll create it when you sleep."); - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player: Build Endurance Data. Modification can cause errors. Edit at your own risk."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player Current Level:"; - mystring3[3] = BuildEndurance_data_current_lvl.ToString(); - - mystring3[4] = "Player Current XP:"; - mystring3[5] = BuildEndurance_data_xp_current.ToString(); - - mystring3[6] = "Xp to next Level:"; - mystring3[7] = BuildEndurance_data_xp_nextlvl.ToString(); - - mystring3[8] = "Initial Stam Bonus:"; - mystring3[9] = BuildEndurance_data_ini_stam_bonus.ToString(); - - mystring3[10] = "Additional Stam Bonus:"; - mystring3[11] = BuildEndurance_data_stam_bonus_acumulated.ToString(); - - mystring3[12] = "======================================================================================="; - mystring3[13] = "RESET ALL MOD EFFECTS? This will effective start you back at square 1. Also good if you want to remove this mod."; - mystring3[14] = BuildEndurance_data_clear_mod_effects.ToString(); - mystring3[15] = "OLD STAMINA AMOUNT: This is the initial value of the Player's Stamina before this mod took over."; - mystring3[16] = BuildEndurance_data_old_stamina.ToString(); - - mystring3[17] = "Nightly Stamina Value: This is the value of the player's stamina that was saved when the player slept."; - mystring3[18] = nightly_stamina_value.ToString(); //this should save the player's stamina upon sleeping. - - - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - // Console.WriteLine("HEY IM SAVING DATA"); - - //write out the info to a text file at the end of a day. - mystring3[0] = "Player: Build Endurance Data. Modification can cause errors. Edit at your own risk."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player Current Level:"; - mystring3[3] = BuildEndurance_data_current_lvl.ToString(); - - mystring3[4] = "Player Current XP:"; - mystring3[5] = BuildEndurance_data_xp_current.ToString(); - - mystring3[6] = "Xp to next Level:"; - mystring3[7] = BuildEndurance_data_xp_nextlvl.ToString(); - - mystring3[8] = "Initial Stam Bonus:"; - mystring3[9] = BuildEndurance_data_ini_stam_bonus.ToString(); - - mystring3[10] = "Additional Stam Bonus:"; - mystring3[11] = BuildEndurance_data_stam_bonus_acumulated.ToString(); - - mystring3[12] = "======================================================================================="; - mystring3[13] = "RESET ALL MOD EFFECTS? This will effective start you back at square 1. Also good if you want to remove this mod."; - mystring3[14] = BuildEndurance_data_clear_mod_effects.ToString(); - mystring3[15] = "OLD STAMINA AMOUNT: This is the initial value of the Player's Stamina before this mod took over."; - mystring3[16] = BuildEndurance_data_old_stamina.ToString(); - - mystring3[17] = "Nightly Stamina Value: This is the value of the player's stamina that was saved when the player slept."; - mystring3[18] = nightly_stamina_value.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - } - - } //end my function -} \ No newline at end of file diff --git a/GeneralMods/BuildEndurance/Framework/ModConfig.cs b/GeneralMods/BuildEndurance/Framework/ModConfig.cs new file mode 100644 index 00000000..f2a12060 --- /dev/null +++ b/GeneralMods/BuildEndurance/Framework/ModConfig.cs @@ -0,0 +1,45 @@ +namespace Omegasis.BuildEndurance.Framework +{ + /// The mod settings and player data. + internal class ModConfig + { + /// The XP points needed to reach the next endurance level. + public double ExpToNextLevel { get; set; } + + /// The player's current endurance XP points. + public double CurrentExp { get; set; } + + /// The player's current endurance level. + public int CurrentLevel { get; set; } + + /// The initial stamina bonus to apply regardless of the player's endurance level. + public int BaseStaminaBonus { get; set; } + + /// The stamina points to add to the player's base stamina due to their current endurance level. + public int CurrentLevelStaminaBonus { get; set; } + + /// The multiplier for the experience points to need to reach an endurance level relative to the previous one. + public double ExpCurve { get; set; } + + /// The maximum endurance level the player can reach. + public int MaxLevel { get; set; } + + /// The amount of stamina the player should gain for each endurance level. + public int StaminaIncreasePerLevel { get; set; } + + /// The experience points to gain for using a tool. + public int ExpForToolUse { get; set; } + + /// The experience points to gain for eating or drinking. + public int ExpForEating { get; set; } + + /// The experience points to gain for sleeping. + public int ExpForSleeping { get; set; } + + /// The experience points to gain for reaching a state of exhaustion for the day. + public int ExpForExhaustion { get; set; } + + /// The experience points to gain for collapsing for the day. + public int ExpForCollapsing { get; set; } + } +} diff --git a/GeneralMods/BuildEndurance/Properties/AssemblyInfo.cs b/GeneralMods/BuildEndurance/Properties/AssemblyInfo.cs index 46480abd..313fcebd 100644 --- a/GeneralMods/BuildEndurance/Properties/AssemblyInfo.cs +++ b/GeneralMods/BuildEndurance/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("BuildEndurance")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BuildEndurance")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("84b4015d-2619-448c-8672-a3fc167f76ea")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/BuildEndurance/README.md b/GeneralMods/BuildEndurance/README.md new file mode 100644 index 00000000..36174664 --- /dev/null +++ b/GeneralMods/BuildEndurance/README.md @@ -0,0 +1,32 @@ +**Build Endurance** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you level up +your endurance to increase your max stamina as you play. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/445). +3. Run the game using SMAPI. + +**NOTE:** to undo the mod's changes to your player, edit the `PlayerData\BuildEndurance_data_*.txt` +file and change the "RESET ALL MOD EFFECTS?" field to `True`. + +## Usage +You'll automatically get XP for... + +* using tools; +* sleeping; +* eating or drinking; +* running out of stamina (becoming exhausted); +* passing out (either by working while exhausted or or staying up late). + +Get enough XP, and your endurance will level up. + +Edit `BuildEnduranceConfig.json` to configure the mod settings. + +## Versions +1.0 +* Initial release. + +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. diff --git a/GeneralMods/BuildEndurance/manifest.json b/GeneralMods/BuildEndurance/manifest.json index bc855f77..5683189d 100644 --- a/GeneralMods/BuildEndurance/manifest.json +++ b/GeneralMods/BuildEndurance/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "4be88c18-b6f3-49b0-ba96-f94b1a5be890", "PerSaveConfigs": false, "EntryDll": "BuildEndurance.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/BuildHealth/BuildHealth.cs b/GeneralMods/BuildHealth/BuildHealth.cs new file mode 100644 index 00000000..20f4efaf --- /dev/null +++ b/GeneralMods/BuildHealth/BuildHealth.cs @@ -0,0 +1,337 @@ +using System; +using System.IO; +using System.Text; +using Newtonsoft.Json; +using Omegasis.BuildHealth.Framework; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +namespace Omegasis.BuildHealth +{ + /// The mod entry point. + public class BuildHealth : Mod + { + /********* + ** Properties + *********/ + /// The mod settings and player data. + private ModConfig Config; + + /// The XP points needed to reach the next level. + private double ExpToNextLevel = 20; + + /// The player's current XP points. + private double CurrentExp; + + /// The player's current level. + private int CurrentLevel; + + /// The health points to add to the player's base health due to their current level. + private int CurrentLevelHealthBonus; + + /// The initial health bonus to apply regardless of the player's level, from the config file. + private int BaseHealthBonus; + + /// Whether to reset all changes by the mod to the default values (i.e. start over). + private bool ClearModEffects; + + /// The player's original max health value, excluding mod effects. + private int OriginalMaxHealth; + + /// Whether the player recently gained XP for tool use. + private bool HasRecentToolExp; + + /// Whether the player was eating last time we checked. + private bool WasEating; + + /// The player's health last time we checked it. + private int LastHealth; + + /// Whether the player has loaded a save. + private bool IsLoaded; + + /// Whether the player has collapsed today. + private bool WasCollapsed; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + GameEvents.OneSecondTick += this.GameEvents_OneSecondTick; + + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + SaveEvents.AfterLoad += this.SaveEvents_AfterLoaded; + + var configPath = Path.Combine(helper.DirectoryPath, "BuildHealthConfig.json"); + if (!File.Exists(configPath)) + { + this.Config = new ModConfig + { + CurrentLevel = 0, + MaxLevel = 100, + HealthIncreasePerLevel = 1, + CurrentExp = 0, + ExpToNextLevel = 20, + ExpCurve = 1.15, + ExpForEating = 2, + ExpForSleeping = 10, + ExpForToolUse = 1, + BaseHealthBonus = 0, + CurrentLevelHealthBonus = 0 + }; + File.WriteAllBytes(configPath, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(this.Config))); + } + else + { + this.Config = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(File.ReadAllBytes(configPath))); + this.Monitor.Log("Found BuildHealth config file."); + } + + this.Monitor.Log("BuildHealth Initialization Completed"); + } + + /// The method invoked once per second during a game update. + /// The event sender. + /// The event data. + public 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. + public void GameEvents_UpdateTick(object sender, EventArgs e) + { + // give XP when player finishes eating + if (Game1.isEating) + this.WasEating = true; + else if (this.WasEating) + { + this.CurrentExp += this.Config.ExpForEating; + this.WasEating = false; + } + + // give XP when player uses tool + if (!this.HasRecentToolExp && Game1.player.usingTool) + { + this.CurrentExp += this.Config.ExpForToolUse; + this.HasRecentToolExp = true; + } + + // give XP for taking damage + var player = Game1.player; + if (this.LastHealth > player.health) + { + this.CurrentExp += this.LastHealth - player.health; + this.LastHealth = player.health; + } + else if (this.LastHealth < player.health) + this.LastHealth = player.health; + + // give XP when player stays up too late or collapses + if (!this.WasCollapsed && Game1.farmerShouldPassOut) + { + this.CurrentExp += this.Config.ExpForCollapsing; + this.WasCollapsed = true; + this.Monitor.Log("The player has collapsed!"); + } + } + + /// The method invoked when changes. + /// The event sender. + /// The event data. + public void TimeEvents_DayOfMonthChanged(object sender, EventArgs e) + { + // reset data + this.LastHealth = Game1.player.maxHealth; + this.WasCollapsed = false; + if (!this.IsLoaded) + return; + + // update settings + this.UpdateClearSetting(); + + var player = StardewValley.Game1.player; + this.CurrentExp += this.Config.ExpForSleeping; + if (this.OriginalMaxHealth == 0) + this.OriginalMaxHealth = player.maxHealth; //grab the initial Health value + + if (this.ClearModEffects) + { + this.LoadClearSettings(); + //This will run when the character goes to sleep. It will increase their sleeping skill. + player.maxHealth = this.OriginalMaxHealth; + this.ExpToNextLevel = this.Config.ExpToNextLevel; + this.CurrentExp = this.Config.CurrentExp; + this.CurrentLevelHealthBonus = 0; + this.OriginalMaxHealth = player.maxHealth; + this.BaseHealthBonus = 0; + this.CurrentLevel = 0; + this.Monitor.Log("BuildHealth Reset!"); + } + + if (!this.ClearModEffects && this.CurrentLevel < this.Config.MaxLevel) + { + while (this.CurrentExp >= this.ExpToNextLevel) + { + this.CurrentLevel += 1; + this.CurrentExp = this.CurrentExp - this.ExpToNextLevel; + this.ExpToNextLevel = + (this.Config.ExpCurve * this.ExpToNextLevel); + player.maxHealth += this.Config.HealthIncreasePerLevel; + this.CurrentLevelHealthBonus += this.Config.HealthIncreasePerLevel; + } + } + this.ClearModEffects = false; + + this.WriteConfig(); + } + + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + public void SaveEvents_AfterLoaded(object sender, EventArgs e) + { + // initialise + this.LoadConfig(); + this.WriteConfig(); + this.IsLoaded = true; + + // grab initial health + var player = Game1.player; + if (this.OriginalMaxHealth == 0) + this.OriginalMaxHealth = player.maxHealth; + + // set max health + player.maxHealth = this.BaseHealthBonus + this.CurrentLevelHealthBonus + this.OriginalMaxHealth; + + // reset if needed + if (this.ClearModEffects) + { + player.maxHealth = this.OriginalMaxHealth; + this.Monitor.Log("BuildHealth Reset!"); + } + + // save config + this.LastHealth = Game1.player.maxHealth; + this.LoadConfig(); + this.WriteConfig(); + } + + /// Update the settings needed for from the latest config file on disk. + void LoadClearSettings() + { + if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) + Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); + + string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildHealth_data_{Game1.player.name}.txt"); + if (!File.Exists(path)) + { + this.ClearModEffects = false; + this.OriginalMaxHealth = 0; + this.BaseHealthBonus = 0; + } + else + { + string[] text = File.ReadAllLines(path); + this.BaseHealthBonus = Convert.ToInt32(text[9]); + this.ClearModEffects = Convert.ToBoolean(text[14]); + this.OriginalMaxHealth = Convert.ToInt32(text[16]); + } + } + + /// Update based on the latest config file on disk. + private void UpdateClearSetting() + { + if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) + Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); + + string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildHealth_data_{Game1.player.name}.txt"); + if (!File.Exists(path)) + { + this.ClearModEffects = false; + this.OriginalMaxHealth = 0; + this.BaseHealthBonus = 0; + } + else + { + string[] text = File.ReadAllLines(path); + this.ClearModEffects = Convert.ToBoolean(text[14]); + } + } + + /// Load the configuration settings. + private void LoadConfig() + { + if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) + Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); + + string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildHealth_data_{Game1.player.name}.txr"); + if (!File.Exists(path)) + { + this.ExpToNextLevel = this.Config.ExpToNextLevel; + this.CurrentExp = this.Config.CurrentExp; + this.CurrentLevel = this.Config.CurrentLevel; + this.BaseHealthBonus = this.Config.BaseHealthBonus; + this.CurrentLevelHealthBonus = this.Config.CurrentLevelHealthBonus; + this.ClearModEffects = false; + this.OriginalMaxHealth = 0; + } + else + { + string[] text = File.ReadAllLines(path); + this.CurrentLevel = Convert.ToInt32(text[3]); + this.ExpToNextLevel = Convert.ToDouble(text[7]); + this.CurrentExp = Convert.ToDouble(text[5]); + this.BaseHealthBonus = Convert.ToInt32(text[9]); + this.CurrentLevelHealthBonus = Convert.ToInt32(text[11]); + this.ClearModEffects = Convert.ToBoolean(text[14]); + this.OriginalMaxHealth = Convert.ToInt32(text[16]); + } + } + + /// Save the configuration settings. + private void WriteConfig() + { + if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) + Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); + + string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildHealth_data_{Game1.player.name}.txt"); + string[] text = new string[20]; + text[0] = "Player: Build Health Data. Modification can cause errors. Edit at your own risk."; + text[1] = "===================================================================================="; + + text[2] = "Player Current Level:"; + text[3] = this.CurrentLevel.ToString(); + + text[4] = "Player Current XP:"; + text[5] = this.CurrentExp.ToString(); + + text[6] = "Xp to next Level:"; + text[7] = this.ExpToNextLevel.ToString(); + + text[8] = "Initial Health Bonus:"; + text[9] = this.BaseHealthBonus.ToString(); + + text[10] = "Additional Health Bonus:"; + text[11] = this.CurrentLevelHealthBonus.ToString(); + + text[12] = "======================================================================================="; + text[13] = "RESET ALL MOD EFFECTS? This will effective start you back at square 1. Also good if you want to remove this mod."; + text[14] = this.ClearModEffects.ToString(); + text[15] = "OLD Health AMOUNT: This is the initial value of the Player's Health before this mod took over."; + text[16] = this.OriginalMaxHealth.ToString(); + + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/BuildHealth/BuildHealth.csproj b/GeneralMods/BuildHealth/BuildHealth.csproj index 7d6078aa..40c8afd8 100644 --- a/GeneralMods/BuildHealth/BuildHealth.csproj +++ b/GeneralMods/BuildHealth/BuildHealth.csproj @@ -32,18 +32,23 @@ ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + False - + + Properties\GlobalAssemblyInfo.cs + + + - + diff --git a/GeneralMods/BuildHealth/Class1.cs b/GeneralMods/BuildHealth/Class1.cs deleted file mode 100644 index 2c0bef28..00000000 --- a/GeneralMods/BuildHealth/Class1.cs +++ /dev/null @@ -1,462 +0,0 @@ -using System; -using System.IO; -using System.Text; -using Newtonsoft.Json; -using StardewModdingAPI; - -namespace Omegasis.BuildHealth -{ - - public class BuildHealth : Mod - { - public double BuildHealth_data_xp_nextlvl=20; - public double BuildHealth_data_xp_current=0; - - public int BuildHealth_data_current_lvl=0; - - public int BuildHealth_data_health_bonus_acumulated=0; - - public int BuildHealth_data_ini_health_bonus=0; - - public bool BuildHealth_data_clear_mod_effects = false; - - public int BuildHealth_data_old_health = 0; - - public bool tool_cleaner = false; - - public bool fed = false; - - - public int old_health; - - public int new_health; - - - - public Config ModConfig { get; set; } - - public static bool upon_loading = false; - - public bool collapse_check; - - //Credit goes to Zoryn for pieces of this config generation that I kinda repurposed. - public override void Entry(IModHelper helper) - { - - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += SleepCallback; - StardewModdingAPI.Events.GameEvents.UpdateTick += EatingCallBack; //sloppy again but it'll do. - - StardewModdingAPI.Events.GameEvents.OneSecondTick += Tool_Cleanup; - StardewModdingAPI.Events.GameEvents.UpdateTick += ToolCallBack; - StardewModdingAPI.Events.SaveEvents.AfterLoad += LoadingCallBack; - StardewModdingAPI.Events.GameEvents.UpdateTick += Collapse_Callback; - - StardewModdingAPI.Events.GameEvents.UpdateTick += damage_check; - - var configLocation = Path.Combine(helper.DirectoryPath, "BuildHealthConfig.json"); - if (!File.Exists(configLocation)) - { - Monitor.Log("The config file for BuildHealth was not found, guess I'll create it..."); - ModConfig = new Config(); - - ModConfig.BuildHealth_current_lvl = 0; - ModConfig.BuildHealth_max_lvl = 100; - - ModConfig.BuildHealth_Health_increase_upon_lvl_up = 1; - - ModConfig.BuildHealth_xp_current = 0; - ModConfig.BuildHealth_xp_nextlvl = 20; - ModConfig.BuildHealth_xp_curve = 1.15; - - ModConfig.BuildHealth_xp_eating = 2; - ModConfig.BuildHealth_xp_sleeping = 10; - ModConfig.BuildHealth_xp_tooluse = 1; - - ModConfig.BuildHealth_ini_Health_boost = 0; - - ModConfig.BuildHealth_Health_accumulated = 0; - - File.WriteAllBytes(configLocation, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ModConfig))); - } - else - { - ModConfig = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(File.ReadAllBytes(configLocation))); - Monitor.Log("Found BuildHealth config file."); - } - - // DataLoader(); - // MyWritter(); - Monitor.Log("BuildHealth Initialization Completed"); - } - - - - public void ToolCallBack(object sender, EventArgs e) //ultra quick response for checking if a tool is used. - { - if (tool_cleaner == true) return; - - - if (StardewValley.Game1.player.usingTool == true) - { - //Monitor.Log("Tool is being used"); - BuildHealth_data_xp_current += ModConfig.BuildHealth_xp_tooluse; - tool_cleaner = true; - } - else return; - } - - public void Tool_Cleanup(object sender, EventArgs e) //nerfs how quickly xp is actually gained. I hope. - { - - if (tool_cleaner == true) tool_cleaner = false; - else return; - } - - public void EatingCallBack(object sender, EventArgs e) - { - - - if (StardewValley.Game1.isEating == true) - { - // Monitor.Log("NOM NOM NOM"); - fed = true; - - //this code will run when the player eats an object. I.E. increases their eating skills. - } - //I'm going to assume they ate the food. - if ((StardewValley.Game1.isEating == false) && fed == true) - { - // Monitor.Log("NOM NOM NOM"); - BuildHealth_data_xp_current += ModConfig.BuildHealth_xp_eating; - fed = false; - } - - - return; - } - - - - public void damage_check(object sender, EventArgs e) - { - var player = StardewValley.Game1.player; - - if (old_health > player.health) - { - BuildHealth_data_xp_current += (old_health - player.health); - //Log.Info(old_health - player.health); - old_health = (player.health); - - } - if (old_health < player.health) - { - old_health = player.health; - } - - - - return; - } - - - - - public void SleepCallback(object sender, EventArgs e) - { - collapse_check = false; - if (upon_loading ==true){ - - Clear_Checker(); - - var player = StardewValley.Game1.player; - - BuildHealth_data_xp_current += ModConfig.BuildHealth_xp_sleeping; - - if (BuildHealth_data_old_health == 0) - { - BuildHealth_data_old_health = player.maxHealth; //grab the initial Health value - } - - if (BuildHealth_data_clear_mod_effects == true) - { - Clear_DataLoader(); - //This will run when the character goes to sleep. It will increase their sleeping skill. - player.maxHealth = BuildHealth_data_old_health; - BuildHealth_data_xp_nextlvl = ModConfig.BuildHealth_xp_nextlvl; - BuildHealth_data_xp_current = ModConfig.BuildHealth_xp_current; - BuildHealth_data_health_bonus_acumulated = 0; - BuildHealth_data_old_health = player.maxHealth; - BuildHealth_data_ini_health_bonus = 0; - BuildHealth_data_current_lvl = 0; - Monitor.Log("BuildHealth Reset!"); - } - - - if (BuildHealth_data_clear_mod_effects == false) - { - if (BuildHealth_data_current_lvl < ModConfig.BuildHealth_max_lvl) - { - while (BuildHealth_data_xp_current >= BuildHealth_data_xp_nextlvl) - { - BuildHealth_data_current_lvl += 1; - BuildHealth_data_xp_current = BuildHealth_data_xp_current - BuildHealth_data_xp_nextlvl; - BuildHealth_data_xp_nextlvl = (ModConfig.BuildHealth_xp_curve * BuildHealth_data_xp_nextlvl); - player.maxHealth += ModConfig.BuildHealth_Health_increase_upon_lvl_up; - BuildHealth_data_health_bonus_acumulated += ModConfig.BuildHealth_Health_increase_upon_lvl_up; - } - - - } - } - BuildHealth_data_clear_mod_effects = false; - - MyWritter(); - } - - old_health = StardewValley.Game1.player.maxHealth; - - - } - - - public void LoadingCallBack(object sender, EventArgs e) - { - DataLoader(); - MyWritter(); - upon_loading=true; - //runs when the player is loaded. - var player = StardewValley.Game1.player; - - if (BuildHealth_data_old_health == 0) - { - BuildHealth_data_old_health = player.maxHealth; //grab the initial health value - } - - player.maxHealth = BuildHealth_data_ini_health_bonus + BuildHealth_data_health_bonus_acumulated + BuildHealth_data_old_health; //incase the ini stam bonus is loaded in. - - if (BuildHealth_data_clear_mod_effects == true) - { - player.maxHealth = BuildHealth_data_old_health; - Monitor.Log("BuildHealth Reset!"); - } - - DataLoader(); - MyWritter(); - - old_health = StardewValley.Game1.player.maxHealth; - } - - - public void Collapse_Callback(object sender, EventArgs e) //if the player stays up too late add some xp. - { - if (collapse_check == false) - { - - if (StardewValley.Game1.farmerShouldPassOut == true) - { - - BuildHealth_data_xp_current += ModConfig.BuildHealth_Pass_Out_XP; - collapse_check = true; - Monitor.Log("The player has collapsed!"); - return; - } - } - } - - - //Mod config data. - public class Config - { - public double BuildHealth_xp_nextlvl { get; set; } - public double BuildHealth_xp_current { get; set; } - public double BuildHealth_xp_curve { get; set; } - - public int BuildHealth_current_lvl { get; set; } - public int BuildHealth_max_lvl { get; set; } - - public int BuildHealth_Health_increase_upon_lvl_up { get; set; } - - public int BuildHealth_xp_tooluse { get; set; } - public int BuildHealth_xp_eating { get; set; } - public int BuildHealth_xp_sleeping { get; set; } - - public int BuildHealth_ini_Health_boost { get; set; } - - public int BuildHealth_Health_accumulated { get; set; } - - public int BuildHealth_Pass_Out_XP { get; set; } - - } - - - void Clear_DataLoader() - { - if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "PlayerData", "BuildHealth_data_"); - string mylocation2 = mylocation+myname; - string mylocation3 = mylocation2+".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Monitor.Log("The config file for BuildHealth was not found, guess I'll create it..."); - - - BuildHealth_data_clear_mod_effects = false; - BuildHealth_data_old_health = 0; - BuildHealth_data_ini_health_bonus = 0; - } - - else - { - //loads the BuildHealth_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation3); - BuildHealth_data_ini_health_bonus = Convert.ToInt32(readtext[9]); - BuildHealth_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); - BuildHealth_data_old_health = Convert.ToInt32(readtext[16]); - - } - } - - void Clear_Checker() - { - //loads the data to the variables upon loading the game. - if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "PlayerData", "BuildHealth_data_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Monitor.Log("The config file for BuildHealth was not found, guess I'll create it..."); - - - BuildHealth_data_clear_mod_effects = false; - BuildHealth_data_old_health = 0; - BuildHealth_data_ini_health_bonus = 0; - } - - else - { - //loads the BuildHealth_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation3); - BuildHealth_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); - - } - } - - - void DataLoader() - { - if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "PlayerData", "BuildHealth_data_"); - string mylocation2 = mylocation+myname; - string mylocation3 = mylocation2+".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Monitor.Log("The config file for BuildHealth was not found, guess I'll create it..."); - BuildHealth_data_xp_nextlvl = ModConfig.BuildHealth_xp_nextlvl; - BuildHealth_data_xp_current = ModConfig.BuildHealth_xp_current; - BuildHealth_data_current_lvl = ModConfig.BuildHealth_current_lvl; - BuildHealth_data_ini_health_bonus = ModConfig.BuildHealth_ini_Health_boost; - BuildHealth_data_health_bonus_acumulated = ModConfig.BuildHealth_Health_accumulated; - BuildHealth_data_clear_mod_effects = false; - BuildHealth_data_old_health = 0; - - } - - else - { - // Monitor.Log("HEY THERE IM LOADING DATA"); - - //loads the BuildHealth_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation3); - BuildHealth_data_current_lvl = Convert.ToInt32(readtext[3]); - BuildHealth_data_xp_nextlvl = Convert.ToDouble(readtext[7]); //these array locations refer to the lines in BuildHealth_data.json - BuildHealth_data_xp_current = Convert.ToDouble(readtext[5]); - BuildHealth_data_ini_health_bonus = Convert.ToInt32(readtext[9]); - BuildHealth_data_health_bonus_acumulated = Convert.ToInt32(readtext[11]); - BuildHealth_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); - BuildHealth_data_old_health = Convert.ToInt32(readtext[16]); - - } - } - - void MyWritter() - { - if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData"))) Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData")); - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "PlayerData", "BuildHealth_data_"); - string mylocation2 = mylocation+myname; - string mylocation3 = mylocation2+".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("The data file for BuildHealth was not found, guess I'll create it when you sleep."); - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player: Build Health Data. Modification can cause errors. Edit at your own risk."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player Current Level:"; - mystring3[3] = BuildHealth_data_current_lvl.ToString(); - - mystring3[4] = "Player Current XP:"; - mystring3[5] = BuildHealth_data_xp_current.ToString(); - - mystring3[6] = "Xp to next Level:"; - mystring3[7] = BuildHealth_data_xp_nextlvl.ToString(); - - mystring3[8] = "Initial Health Bonus:"; - mystring3[9] = BuildHealth_data_ini_health_bonus.ToString(); - - mystring3[10] = "Additional Health Bonus:"; - mystring3[11] = BuildHealth_data_health_bonus_acumulated.ToString(); - - mystring3[12] = "======================================================================================="; - mystring3[13] = "RESET ALL MOD EFFECTS? This will effective start you back at square 1. Also good if you want to remove this mod."; - mystring3[14] = BuildHealth_data_clear_mod_effects.ToString(); - mystring3[15] = "OLD Health AMOUNT: This is the initial value of the Player's Health before this mod took over."; - mystring3[16] = BuildHealth_data_old_health.ToString(); - - - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - // Monitor.Log("HEY IM SAVING DATA"); - - //write out the info to a text file at the end of a day. - mystring3[0] = "Player: Build Health Data. Modification can cause errors. Edit at your own risk."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player Current Level:"; - mystring3[3] = BuildHealth_data_current_lvl.ToString(); - - mystring3[4] = "Player Current XP:"; - mystring3[5] = BuildHealth_data_xp_current.ToString(); - - mystring3[6] = "Xp to next Level:"; - mystring3[7] = BuildHealth_data_xp_nextlvl.ToString(); - - mystring3[8] = "Initial Health Bonus:"; - mystring3[9] = BuildHealth_data_ini_health_bonus.ToString(); - - mystring3[10] = "Additional Health Bonus:"; - mystring3[11] = BuildHealth_data_health_bonus_acumulated.ToString(); - - mystring3[12] = "======================================================================================="; - mystring3[13] = "RESET ALL MOD EFFECTS? This will effective start you back at square 1. Also good if you want to remove this mod."; - mystring3[14] = BuildHealth_data_clear_mod_effects.ToString(); - mystring3[15] = "OLD Health AMOUNT: This is the initial value of the Player's Health before this mod took over."; - mystring3[16] = BuildHealth_data_old_health.ToString(); - - - File.WriteAllLines(mylocation3, mystring3); - } - } - - } //end my function -} \ No newline at end of file diff --git a/GeneralMods/BuildHealth/Framework/ModConfig.cs b/GeneralMods/BuildHealth/Framework/ModConfig.cs new file mode 100644 index 00000000..7fb1cf14 --- /dev/null +++ b/GeneralMods/BuildHealth/Framework/ModConfig.cs @@ -0,0 +1,42 @@ +namespace Omegasis.BuildHealth.Framework +{ + /// The mod settings and player data. + internal class ModConfig + { + /// The XP points needed to reach the next level. + public double ExpToNextLevel { get; set; } + + /// The player's current XP points. + public double CurrentExp { get; set; } + + /// The player's current level. + public int CurrentLevel { get; set; } + + /// The initial health bonus to apply regardless of the player's level, from the config file. + public int BaseHealthBonus { get; set; } + + /// The health points to add to the player's base health due to their current level. + public int CurrentLevelHealthBonus { get; set; } + + /// The multiplier for the experience points to need to reach an endurance level relative to the previous one. + public double ExpCurve { get; set; } + + /// The maximum endurance level the player can reach. + public int MaxLevel { get; set; } + + /// The amount of stamina the player should gain for each endurance level. + public int HealthIncreasePerLevel { get; set; } + + /// The experience points to gain for using a tool. + public int ExpForToolUse { get; set; } + + /// The experience points to gain for eating or drinking. + public int ExpForEating { get; set; } + + /// The experience points to gain for sleeping. + public int ExpForSleeping { get; set; } + + /// The experience points to gain for collapsing for the day. + public int ExpForCollapsing { get; set; } + } +} diff --git a/GeneralMods/BuildHealth/Properties/AssemblyInfo.cs b/GeneralMods/BuildHealth/Properties/AssemblyInfo.cs index 42a73c25..d939e8da 100644 --- a/GeneralMods/BuildHealth/Properties/AssemblyInfo.cs +++ b/GeneralMods/BuildHealth/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("BuildHealth")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BuildHealth")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("99183bd6-6243-4ae6-b2d8-7cea915b1278")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/BuildHealth/ReadMe.md b/GeneralMods/BuildHealth/ReadMe.md index 79fdca6b..a0ade205 100644 --- a/GeneralMods/BuildHealth/ReadMe.md +++ b/GeneralMods/BuildHealth/ReadMe.md @@ -1,33 +1,33 @@ -[SMAPI]BuildEndurance -Initial Release 4/10/16 10:40 PM -Updated: 10/11/16 12:55 AM +**Build Health** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you level up +your endurance to increase your max health as you play. -Compatability: -Windows +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. -Updates: -1.1.0 10/11/16 12:55 AM --Updated to SDV 1.1 +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/445). +3. Run the game using SMAPI. -v1.0.0 4/10/16 10:40 PM PST +**NOTE:** to undo the mod's changes to your player, edit the `PlayerData\BuildEndurance_data_*.txt` +file and change the "RESET ALL MOD EFFECTS?" field to `True`. -Description --Fixed the glitch where eating and using tools would not net you xp. +## Usage +You'll automatically get XP for... -This is the BuildEndurance mod, which can increase your max health in a couple of different ways! As you partake in the tasks below, you gain xp points, and when you reach enough xp points, your max health will increase! +* using tools; +* sleeping; +* eating or drinking; +* taking damage; +* running out of stamina (becoming exhausted); +* passing out (either by working while exhausted or or staying up late). -Ways to increase maximum health: +Get enough XP, and your health will level up. -Use tools. +Edit `BuildHealthConfig.json` to configure the mod settings. -Eating Food. +## Versions +1.0 +* Initial release. -Sleeping! - -I'm up to a few more suggestions as well that can add to this list. - -All of the data can be set up/edited in BuildEndurance_Config.tx. If you want to increase/decrease any of the values such as the xp to level up, the maximum level, or even the amount of health you gain upon level up can be found here. - -All data values currently associated with the character can also be change around with BuildEndurance_data.txt - -NOTE! If at any time you want to remove/reverse the properties set by this mod, open up the BuildEndurance_data.txt file and set the value associated with resetting the mod data to true! This will revert the player's max health to the value initially stored when the mod was installed/ the value associate with old health. +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. diff --git a/GeneralMods/BuildHealth/manifest.json b/GeneralMods/BuildHealth/manifest.json index 568ac3f2..625f3023 100644 --- a/GeneralMods/BuildHealth/manifest.json +++ b/GeneralMods/BuildHealth/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "4be88c18-b6f3-49b0-ba96-f94b1a5be890", "PerSaveConfigs": false, "EntryDll": "BuildHealth.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs b/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs new file mode 100644 index 00000000..f46c8ae1 --- /dev/null +++ b/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs @@ -0,0 +1,96 @@ +using System; +using System.IO; +using Omegasis.BuyBackCollectables.Framework; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +namespace Omegasis.BuyBackCollectables +{ + /// The mod entry point. + public class BuyBackCollectables : Mod + { + /********* + ** Properties + *********/ + /// The key which shows the menu. + private string KeyBinding = "B"; + + /// The multiplier applied to the cost of buying back a collectable. + private double CostMultiplier = 3.0; + + /// Whether the player loaded a save. + private bool IsGameLoaded; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + } + + + /********* + ** Private methods + *********/ + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + public void SaveEvents_AfterLoad(object sender, EventArgs e) + { + this.IsGameLoaded = true; + this.LoadConfig(); + this.WriteConfig(); + } + + /// The method invoked when the presses a keyboard button. + /// The event sender. + /// The event data. + public void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + { + if (Game1.player == null || Game1.player.currentLocation == null || !this.IsGameLoaded || Game1.activeClickableMenu != null) + return; + + if (e.KeyPressed.ToString() == this.KeyBinding) + Game1.activeClickableMenu = new BuyBackMenu(this.CostMultiplier); + } + + /// Load the configuration settings. + private void LoadConfig() + { + //loads the data to the variables upon loading the game. + string path = Path.Combine(Helper.DirectoryPath, "BuyBack_Config.txt"); + if (!File.Exists(path)) + { + this.KeyBinding = "B"; + this.CostMultiplier = 3.0; + } + else + { + string[] text = File.ReadAllLines(path); + this.KeyBinding = Convert.ToString(text[3]); + this.CostMultiplier = Convert.ToDouble(text[5]); + } + } + + /// Save the configuration settings. + private void WriteConfig() + { + //write all of my info to a text file. + string path = Path.Combine(Helper.DirectoryPath, "BuyBack_Config.txt"); + string[] text = new string[20]; + text[0] = "Config: Buy Back Collections. Feel free to mess with these settings."; + text[1] = "===================================================================================="; + text[2] = "Key binding"; + text[3] = this.KeyBinding; + text[4] = "Collectables Multiplier Cost: Sell Value * value listed below"; + text[5] = this.CostMultiplier.ToString(); + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj b/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj index cc67c9d4..9832f159 100644 --- a/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj +++ b/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj @@ -34,17 +34,19 @@ - - + + Properties\GlobalAssemblyInfo.cs + + - + - + diff --git a/GeneralMods/BuyBackCollectables/Class1.cs b/GeneralMods/BuyBackCollectables/Class1.cs deleted file mode 100644 index f63114f0..00000000 --- a/GeneralMods/BuyBackCollectables/Class1.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using StardewModdingAPI; -using StardewValley; -using StardewValley.Menus; - -namespace Omegasis.BuyBackCollectables -{ - public class Class1 : Mod - { - string key_binding = "B"; - public static double cost = 3.0; - bool game_loaded = false; - - - public static List debugList; - - public override void Entry(IModHelper helper) - { - //set up all of my events here - StardewModdingAPI.Events.SaveEvents.AfterLoad+= PlayerEvents_LoadedGame; - StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; - StardewModdingAPI.Events.GameEvents.OneSecondTick += GameEvents_OneSecondTick; - debugList = new List(); - } - - private void GameEvents_OneSecondTick(object sender, EventArgs e) - { - if (debugList.Count == 0) return; - foreach(var v in debugList) - { - this.Monitor.Log(v); - } - debugList.Clear(); - } - - public void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) - { - if (Game1.player == null) return; - if (Game1.player.currentLocation == null) return; - if (game_loaded == false) return; - - if (e.KeyPressed.ToString() == key_binding) //if the key is pressed, load my cusom save function - { - if (Game1.activeClickableMenu != null) return; - else - { - Game1.activeClickableMenu = new UpdatedCollectionsPage(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2); - } - } - } - - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - game_loaded = true; - DataLoader_Settings(); - MyWritter_Settings(); - } - - void DataLoader_Settings() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "BuyBack_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - key_binding = "B"; - cost = 3.0; - } - - else - { - string[] readtext = File.ReadAllLines(mylocation3); - key_binding = Convert.ToString(readtext[3]); - cost = Convert.ToDouble(readtext[5]); - } - } - - void MyWritter_Settings() - { - //write all of my info to a text file. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "BuyBack_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("BuyBack Collections: Config not found. Creating it now."); - - mystring3[0] = "Config: Buy Back Collections. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Key binding"; - mystring3[3] = key_binding.ToString(); - mystring3[4] = "Collectables Multiplier Cost: Sell Value * value listed below"; - mystring3[5] = cost.ToString(); - File.WriteAllLines(mylocation3, mystring3); - } - else - { - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - mystring3[0] = "Config: Buy Back Collections. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Key binding"; - mystring3[3] = key_binding.ToString(); - mystring3[4] = "Collectables Multiplier Cost: Sell Value * value listed below"; - mystring3[5] = cost.ToString(); - File.WriteAllLines(mylocation3, mystring3); - } - } - - public void debugMessage(string s) - { - this.Monitor.Log(s); - } - - } -} -//end class \ No newline at end of file diff --git a/GeneralMods/BuyBackCollectables/Collections_Buy_Back.cs b/GeneralMods/BuyBackCollectables/Collections_Buy_Back.cs deleted file mode 100644 index 5fbbd2fb..00000000 --- a/GeneralMods/BuyBackCollectables/Collections_Buy_Back.cs +++ /dev/null @@ -1,445 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; -using StardewValley.Menus; -using Object = StardewValley.Object; - -namespace Omegasis.BuyBackCollectables -{ - public class Collections_Buy_Back : IClickableMenu - { - public const int organicsTab = 0; - - public const int fishTab = 1; - - public const int archaeologyTab = 2; - - public const int mineralsTab = 3; - - public const int cookingTab = 4; - - public const int achievementsTab = 5; - - public const int distanceFromMenuBottomBeforeNewPage = 128; - - public static int widthToMoveActiveTab = Game1.tileSize / 8; - - public string descriptionText = ""; - - public string hoverText = ""; - - public ClickableTextureComponent backButton; - - public ClickableTextureComponent forwardButton; - - public List sideTabs = new List(); - - public int currentTab; - - public int currentPage; - - public Dictionary>> collections = new Dictionary>>(); - - public int value; - - public Item new_item; - - public Collections_Buy_Back(int x, int y, int width, int height) : base(x, y, width, height, false) - { - this.sideTabs.Add(new ClickableTextureComponent("",new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4 + CollectionsPage.widthToMoveActiveTab, this.yPositionOnScreen + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), "", "Items Shipped (Farm & Forage)", Game1.mouseCursors, new Rectangle(640, 80, 16, 16), (float)Game1.pixelZoom)); - this.collections.Add(0, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("",new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 3, Game1.tileSize, Game1.tileSize), "", "Fish", Game1.mouseCursors, new Rectangle(640, 64, 16, 16), (float)Game1.pixelZoom)); - this.collections.Add(1, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("",new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 4, Game1.tileSize, Game1.tileSize), "", "Artifacts", Game1.mouseCursors, new Rectangle(656, 64, 16, 16), (float)Game1.pixelZoom)); - this.collections.Add(2, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("",new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 5, Game1.tileSize, Game1.tileSize), "", "Minerals", Game1.mouseCursors, new Rectangle(672, 64, 16, 16), (float)Game1.pixelZoom)); - this.collections.Add(3, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("",new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 6, Game1.tileSize, Game1.tileSize), "", "Cooking", Game1.mouseCursors, new Rectangle(688, 64, 16, 16), (float)Game1.pixelZoom)); - this.collections.Add(4, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("",new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 7, Game1.tileSize, Game1.tileSize), "", "Achievements", Game1.mouseCursors, new Rectangle(656, 80, 16, 16), (float)Game1.pixelZoom)); - this.collections.Add(5, new List>()); - Collections_Buy_Back.widthToMoveActiveTab = Game1.tileSize / 8; - this.backButton = new ClickableTextureComponent("",new Rectangle(this.xPositionOnScreen + Game1.tileSize * 3 / 4, this.yPositionOnScreen + height - 20 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(352, 495, 12, 11), (float)Game1.pixelZoom, false); - this.forwardButton = new ClickableTextureComponent("",new Rectangle(this.xPositionOnScreen + width - Game1.tileSize / 2 - 15 * Game1.pixelZoom, this.yPositionOnScreen + height - 20 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(365, 495, 12, 11), (float)Game1.pixelZoom, false); - int[] array = new int[this.sideTabs.Count()]; - int num = this.xPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearSideBorder; - int num2 = this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 4; - int num3 = 10; - foreach (KeyValuePair current in Game1.objectInformation) - { - string text = current.Value.Split(new char[] - { - '/' - })[3]; - bool flag = false; - int num4; - if (text.Contains("Arch")) - { - num4 = 2; - if (Game1.player.archaeologyFound.ContainsKey(current.Key)) - { - flag = true; - } - } - else if (text.Contains("Fish")) - { - if (current.Key >= 167 && current.Key < 173) - { - continue; - } - num4 = 1; - if (Game1.player.fishCaught.ContainsKey(current.Key)) - { - flag = true; - } - } - else if (text.Contains("Mineral") || text.Substring(text.Count() - 3).Equals("-2")) - { - num4 = 3; - if (Game1.player.mineralsFound.ContainsKey(current.Key)) - { - flag = true; - } - } - else if (text.Contains("Cooking") || text.Substring(text.Count() - 3).Equals("-7")) - { - num4 = 4; - if (Game1.player.recipesCooked.ContainsKey(current.Key)) - { - flag = true; - } - if (current.Key == 217 || current.Key == 772) - { - continue; - } - if (current.Key == 773) - { - continue; - } - } - else - { - if (!StardewValley.Object.isPotentialBasicShippedCategory(current.Key, text.Substring(text.Count() - 3))) - { - continue; - } - num4 = 0; - if (Game1.player.basicShipped.ContainsKey(current.Key)) - { - flag = true; - } - } - int x2 = num + array[num4] % num3 * (Game1.tileSize + 4); - int num5 = num2 + array[num4] / num3 * (Game1.tileSize + 4); - if (num5 > this.yPositionOnScreen + height - 128) - { - this.collections[num4].Add(new List()); - array[num4] = 0; - x2 = num; - num5 = num2; - } - if (this.collections[num4].Count>() == 0) - { - this.collections[num4].Add(new List()); - } - this.collections[num4].Last>().Add(new ClickableTextureComponent("",new Rectangle(x2, num5, Game1.tileSize, Game1.tileSize), current.Key + " " + flag, "", Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, current.Key, 16, 16), (float)Game1.pixelZoom, false)); - array[num4]++; - } - if (this.collections[5].Count>() == 0) - { - this.collections[5].Add(new List()); - } - foreach (KeyValuePair current2 in Game1.achievements) - { - bool flag2 = Game1.player.achievements.Contains(current2.Key); - string[] array2 = current2.Value.Split(new char[] - { - '^' - }); - if (flag2 || (array2[2].Equals("true") && (array2[3].Equals("-1") || this.farmerHasAchievements(array2[3])))) - { - int x3 = num + array[5] % num3 * (Game1.tileSize + 4); - int y2 = num2 + array[5] / num3 * (Game1.tileSize + 4); - this.collections[5][0].Add(new ClickableTextureComponent("",new Rectangle(x3, y2, Game1.tileSize, Game1.tileSize), current2.Key + " " + flag2, "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 25, -1, -1), 1f, false)); - array[5]++; - } - } - } - - public virtual bool farmerHasAchievements(string listOfAchievementNumbers) - { - string[] array = listOfAchievementNumbers.Split(new char[] - { - ' ' - }); - string[] array2 = array; - for (int i = 0; i < array2.Length; i++) - { - string text = array2[i]; - if (!Game1.player.achievements.Contains(Convert.ToInt32(text))) - { - return false; - } - } - return true; - } - - public override void receiveLeftClick(int x, int y, bool playSound = true) - { - for (int i = 0; i < this.sideTabs.Count; i++) - { - if (this.sideTabs[i].containsPoint(x, y) && this.currentTab != i) - { - Game1.playSound("smallSelect"); - ClickableTextureComponent expr_45_cp_0 = this.sideTabs[this.currentTab]; - expr_45_cp_0.bounds.X = expr_45_cp_0.bounds.X - CollectionsPage.widthToMoveActiveTab; - this.currentTab = i; - this.currentPage = 0; - ClickableTextureComponent expr_75_cp_0 = this.sideTabs[i]; - expr_75_cp_0.bounds.X = expr_75_cp_0.bounds.X + CollectionsPage.widthToMoveActiveTab; - } - } - if (this.currentPage > 0 && this.backButton.containsPoint(x, y)) - { - this.currentPage--; - Game1.playSound("shwip"); - this.backButton.scale = this.backButton.baseScale; - this.new_item = null; - } - if (this.currentPage < this.collections[this.currentTab].Count>() - 1 && this.forwardButton.containsPoint(x, y)) - { - this.currentPage++; - Game1.playSound("shwip"); - this.forwardButton.scale = this.forwardButton.baseScale; - this.new_item = null; - } - - - foreach (ClickableTextureComponent current2 in this.collections[this.currentTab][this.currentPage]) - { - if (current2.containsPoint(x, y)) - { - if (new_item != null) - { - if (Game1.player.money > new_item.salePrice() * Class1.cost) - { - Game1.player.money -= value; - Game1.player.addItemByMenuIfNecessary(new_item); - } - - } - } - } - - - - } - - public override void receiveRightClick(int x, int y, bool playSound = true) - { - if (new_item != null) - { - if (Game1.player.money > new_item.salePrice() * Class1.cost) - { - - Game1.player.money -= value; - Game1.player.addItemByMenuIfNecessary(new_item); - } - - } - } - - - public override void performHoverAction(int x, int y) - { - this.descriptionText = ""; - this.hoverText = ""; - this.value = -1; - - try { - foreach (ClickableTextureComponent current in this.sideTabs) - { - if (current.containsPoint(x, y)) - { - this.hoverText = current.hoverText; - return; - } - } - } - catch (Exception e) - { - Class1.debugList.Add(e.ToString()); - } - try { - foreach (ClickableTextureComponent current2 in this.collections[this.currentTab][this.currentPage]) - { - if (current2.containsPoint(x, y)) - { - current2.scale = Math.Min(current2.scale + 0.02f, current2.baseScale + 0.1f); - if (Convert.ToBoolean(current2.name.Split(new char[] - { - ' ' - })[1]) || this.currentTab == 5) - { - this.hoverText = this.createDescription(Convert.ToInt32(current2.name.Split(new char[] - { - ' ' - })[0])); - } - else - { - this.hoverText = "???"; - this.new_item = null; - } - } - else - { - current2.scale = Math.Max(current2.scale - 0.02f, current2.baseScale); - } - } - } - catch(Exception e) - { - Log.AsyncM(this.currentTab); - Log.AsyncM(this.currentPage); - Log.AsyncM(e); - } - this.forwardButton.tryHover(x, y, 0.5f); - this.backButton.tryHover(x, y, 0.5f); - } - - public virtual string createDescription(int index) - { - string text = ""; - if (this.currentTab == 5) - { - string[] array = Game1.achievements[index].Split(new char[] - { - '^' - }); - text = text + array[0] + Environment.NewLine + Environment.NewLine; - text += array[1]; - new_item = null; - } - else - { - string[] array2 = Game1.objectInformation[index].Split(new char[] - { - '/' - }); - - string text2 = text; - foreach(KeyValuePair meh in Game1.objectInformation) - { - string[] array3 = meh.Value.Split(new char[] - { - '/' - }); - if (array3[0] == array2[0]) - { - new_item = (Item)new Object(Convert.ToInt32(meh.Key), 1, false, -1, 0); - if (new_item.Name == "Stone" || new_item.Name=="stone") new_item = (Item)new Object(390, 1, false, -1, 0); - } - } - text = string.Concat(new string[] - { - text2, - array2[0], - Environment.NewLine, - Environment.NewLine, - Game1.parseText(array2[4], Game1.smallFont, Game1.tileSize * 4), - Environment.NewLine, - Environment.NewLine - }); - if (array2[3].Contains("Arch")) - { - text += (Game1.player.archaeologyFound.ContainsKey(index) ? ("Total Found: " + Game1.player.archaeologyFound[index][0]) : ""); - } - else if (array2[3].Contains("Cooking")) - { - text += (Game1.player.recipesCooked.ContainsKey(index) ? ("Times Cooked: " + Game1.player.recipesCooked[index]) : ""); - } - else if (array2[3].Contains("Fish")) - { - text = text + "Number Caught: " + (Game1.player.fishCaught.ContainsKey(index) ? Game1.player.fishCaught[index][0] : 0); - if (Game1.player.fishCaught.ContainsKey(index) && Game1.player.fishCaught[index][1] > 0) - { - object obj = text; - text = string.Concat(new object[] - { - obj, - Environment.NewLine, - "Biggest Catch: ", - Game1.player.fishCaught[index][1], - " in." - }); - } - } - else if (array2[3].Contains("Minerals") || array2[3].Substring(array2[3].Count() - 3).Equals("-2")) - { - text = text + "Number Found: " + (Game1.player.mineralsFound.ContainsKey(index) ? Game1.player.mineralsFound[index] : 0); - } - else - { - text = text + "Number Shipped: " + (Game1.player.basicShipped.ContainsKey(index) ? Game1.player.basicShipped[index] : 0); - } - this.value = Convert.ToInt32(array2[1]); - this.value =(int)(this.value * Class1.cost); - } - return text; - } - - public override void draw(SpriteBatch b) - { - - foreach (ClickableTextureComponent current in this.sideTabs) - { - current.draw(b); - } - if (this.currentPage > 0) - { - this.backButton.draw(b); - } - if (this.currentPage < this.collections[this.currentTab].Count>() - 1) - { - this.forwardButton.draw(b); - } - b.End(); - b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null); - try - { - foreach (ClickableTextureComponent current2 in this.collections[1][0]) - { - bool flag = Convert.ToBoolean(current2.name.Split(new char[] - { - ' ' - })[1]); - current2.draw(b, flag ? Color.White : (Color.Black * 0.2f), 0.86f); - if (this.currentTab == 5 && flag) - { - int num = new Random(Convert.ToInt32(current2.name.Split(new char[] - { - ' ' - })[0])).Next(12); - b.Draw(Game1.mouseCursors, new Vector2((float)(current2.bounds.X + 16 + Game1.tileSize / 4), (float)(current2.bounds.Y + 20 + Game1.tileSize / 4)), new Rectangle?(new Rectangle(256 + num % 6 * Game1.tileSize / 2, 128 + num / 6 * Game1.tileSize / 2, Game1.tileSize / 2, Game1.tileSize / 2)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 4), (float)(Game1.tileSize / 4)), current2.scale, SpriteEffects.None, 0.88f); - } - } - b.End(); - b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); - if (!this.hoverText.Equals("")) - { - IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, 0, 0, this.value, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null); - } - b.Draw(Game1.mouseCursors, new Vector2((float)Game1.getOldMouseX(), (float)Game1.getOldMouseY()), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, Game1.options.gamepadControls ? 44 : 0, 16, 16)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom + Game1.dialogueButtonScale / 150f, SpriteEffects.None, 1f); - } - catch(Exception e) - { - Log.AsyncY(e); - } - } - } -} diff --git a/GeneralMods/BuyBackCollectables/Framework/BuyBackMenu.cs b/GeneralMods/BuyBackCollectables/Framework/BuyBackMenu.cs new file mode 100644 index 00000000..717ddc84 --- /dev/null +++ b/GeneralMods/BuyBackCollectables/Framework/BuyBackMenu.cs @@ -0,0 +1,369 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewValley; +using StardewValley.Menus; +using Object = StardewValley.Object; + +namespace Omegasis.BuyBackCollectables.Framework +{ + /// The clickable menu which lets the player buy back collectables. + internal class BuyBackMenu : IClickableMenu + { + /********* + ** Properties + *********/ + /// The organics tab ID. + private const int OrganicsTab = 0; + + /// The fish tab ID. + private const int FishTab = 1; + + /// The archaeology tab ID. + private const int ArchaeologyTab = 2; + + /// The minerals tab ID. + private const int MineralsTab = 3; + + /// The cooking tab ID. + private const int CookingTab = 4; + + /// The achievements tab ID. + private const int AchievementsTab = 5; + + /// The offset to apply to the selected tab. + private readonly int WidthToMoveActiveTab = Game1.tileSize / 8; + + /// The multiplier applied to the cost of buying back a collectable. + private readonly double CostMultiplier; + + /// The back button. + private readonly ClickableTextureComponent BackButton; + + /// The forward button. + private readonly ClickableTextureComponent ForwardButton; + + /// The category tabs shown along the side. + private readonly List SideTabs = new List(); + + /// The text to display in a hover tooltip. + private string HoverText = ""; + + /// The selected tab. + private int CurrentTab; + + /// The selected page. + private int CurrentPage; + + /// The buttons to show for each tab. + private readonly Dictionary>> Collections = new Dictionary>>(); + + /// The cost to buy back the selected item. + private int Value; + + /// The selected item. + public Item NewItem; + + /// The cost to buy back the selected item. + public int NewItemValue; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The multiplier applied to the cost of buying back a collectable. + public BuyBackMenu(double costMultiplier) + : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2) + { + // initialise + this.CostMultiplier = costMultiplier; + + // create components + this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4 + this.WidthToMoveActiveTab, this.yPositionOnScreen + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Shipped"), Game1.mouseCursors, new Rectangle(640, 80, 16, 16), Game1.pixelZoom)); + this.Collections.Add(BuyBackMenu.OrganicsTab, new List>()); + this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 3, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Fish"), Game1.mouseCursors, new Rectangle(640, 64, 16, 16), Game1.pixelZoom)); + this.Collections.Add(BuyBackMenu.FishTab, new List>()); + this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 4, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Artifacts"), Game1.mouseCursors, new Rectangle(656, 64, 16, 16), Game1.pixelZoom)); + this.Collections.Add(BuyBackMenu.ArchaeologyTab, new List>()); + this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 5, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Minerals"), Game1.mouseCursors, new Rectangle(672, 64, 16, 16), Game1.pixelZoom)); + this.Collections.Add(BuyBackMenu.MineralsTab, new List>()); + this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 6, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Cooking"), Game1.mouseCursors, new Rectangle(688, 64, 16, 16), Game1.pixelZoom)); + this.Collections.Add(BuyBackMenu.CookingTab, new List>()); + this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 7, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Achievements"), Game1.mouseCursors, new Rectangle(656, 80, 16, 16), Game1.pixelZoom)); + this.Collections.Add(BuyBackMenu.AchievementsTab, new List>()); + this.BackButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 3 / 4, this.yPositionOnScreen + this.height - 20 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), Game1.pixelZoom); + this.ForwardButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2 - 15 * Game1.pixelZoom, this.yPositionOnScreen + this.height - 20 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), Game1.pixelZoom); + int[] array = new int[this.SideTabs.Count]; + int num = this.xPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearSideBorder; + int num2 = this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 4; + int num3 = 10; + foreach (KeyValuePair entry in Game1.objectInformation) + { + string fields = entry.Value.Split('/')[3]; + bool drawShadow = false; + int selectedTab; + if (fields.Contains("Arch")) + { + selectedTab = BuyBackMenu.ArchaeologyTab; + if (Game1.player.archaeologyFound.ContainsKey(entry.Key)) + drawShadow = true; + } + else if (fields.Contains("Fish")) + { + if (entry.Key >= 167 && entry.Key < 173) + continue; + selectedTab = BuyBackMenu.FishTab; + if (Game1.player.fishCaught.ContainsKey(entry.Key)) + drawShadow = true; + } + else if (fields.Contains("Mineral") || fields.Substring(fields.Length - 3).Equals("-2")) + { + selectedTab = BuyBackMenu.MineralsTab; + if (Game1.player.mineralsFound.ContainsKey(entry.Key)) + drawShadow = true; + } + else if (fields.Contains("Cooking") || fields.Substring(fields.Length - 3).Equals("-7")) + { + selectedTab = BuyBackMenu.CookingTab; + if (Game1.player.recipesCooked.ContainsKey(entry.Key)) + drawShadow = true; + if (entry.Key == 217 || entry.Key == 772 || entry.Key == 773) + continue; + } + else + { + if (!Object.isPotentialBasicShippedCategory(entry.Key, fields.Substring(fields.Length - 3))) + continue; + selectedTab = BuyBackMenu.OrganicsTab; + if (Game1.player.basicShipped.ContainsKey(entry.Key)) + drawShadow = true; + } + int x2 = num + array[selectedTab] % num3 * (Game1.tileSize + 4); + int num5 = num2 + array[selectedTab] / num3 * (Game1.tileSize + 4); + if (num5 > this.yPositionOnScreen + this.height - 128) + { + this.Collections[selectedTab].Add(new List()); + array[selectedTab] = 0; + x2 = num; + num5 = num2; + } + if (this.Collections[selectedTab].Count == 0) + this.Collections[selectedTab].Add(new List()); + this.Collections[selectedTab].Last().Add(new ClickableTextureComponent(entry.Key + " " + drawShadow, new Rectangle(x2, num5, Game1.tileSize, Game1.tileSize), null, "", Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, entry.Key, 16, 16), Game1.pixelZoom, drawShadow)); + array[selectedTab]++; + } + if (this.Collections[5].Count == 0) + this.Collections[5].Add(new List()); + foreach (KeyValuePair current2 in Game1.achievements) + { + bool flag = Game1.player.achievements.Contains(current2.Key); + string[] array2 = current2.Value.Split('^'); + if (flag || (array2[2].Equals("true") && (array2[3].Equals("-1") || this.FarmerHasAchievements(array2[3])))) + { + int x3 = num + array[5] % num3 * (Game1.tileSize + 4); + int y2 = num2 + array[5] / num3 * (Game1.tileSize + 4); + this.Collections[5][0].Add(new ClickableTextureComponent(current2.Key + " " + flag, new Rectangle(x3, y2, Game1.tileSize, Game1.tileSize), null, "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 25), 1f)); + array[5]++; + } + } + } + + + /********* + ** Private methods + *********/ + /// Get whether the farmer has the given achievements. + /// The achievement IDs as a space-separated list. + private bool FarmerHasAchievements(string listOfAchievementNumbers) + { + string[] array = listOfAchievementNumbers.Split(' '); + foreach (string text in array) + { + if (!Game1.player.achievements.Contains(Convert.ToInt32(text))) + return false; + } + return true; + } + + /// The method invoked when the player left-clicks on the menu. + /// The X-position of the cursor. + /// The Y-position of the cursor. + /// Whether to enable sound. + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + for (int i = 0; i < this.SideTabs.Count; i++) + { + if (this.SideTabs[i].containsPoint(x, y) && this.CurrentTab != i) + { + Game1.playSound("smallSelect"); + ClickableTextureComponent curTab = this.SideTabs[this.CurrentTab]; + curTab.bounds.X = curTab.bounds.X - this.WidthToMoveActiveTab; + this.CurrentTab = i; + this.CurrentPage = 0; + ClickableTextureComponent newTab = this.SideTabs[i]; + newTab.bounds.X = newTab.bounds.X + this.WidthToMoveActiveTab; + } + } + if (this.CurrentPage > 0 && this.BackButton.containsPoint(x, y)) + { + this.CurrentPage--; + Game1.playSound("shwip"); + this.BackButton.scale = this.BackButton.baseScale; + } + if (this.CurrentPage < this.Collections[this.CurrentTab].Count - 1 && this.ForwardButton.containsPoint(x, y)) + { + this.CurrentPage++; + Game1.playSound("shwip"); + this.ForwardButton.scale = this.ForwardButton.baseScale; + } + foreach (ClickableTextureComponent current2 in this.Collections[this.CurrentTab][this.CurrentPage]) + { + if (current2.containsPoint(x, y) && this.NewItem != null && Game1.player.money >= this.Value) + { + Game1.player.money -= this.Value; + Game1.player.addItemByMenuIfNecessary(this.NewItem); + } + } + } + + /// The method invoked when the player right-clicks on the lookup UI. + /// The X-position of the cursor. + /// The Y-position of the cursor. + /// Whether to enable sound. + public override void receiveRightClick(int x, int y, bool playSound = true) + { + if (this.NewItem != null && Game1.player.money >= this.Value) + { + Game1.player.money -= this.Value; + Game1.player.addItemByMenuIfNecessary(this.NewItem); + } + } + + /// The method invoked when the player hovers the cursor over the menu. + /// The X-position of the cursor. + /// The Y-position of the cursor. + public override void performHoverAction(int x, int y) + { + this.HoverText = ""; + this.Value = -1; + foreach (ClickableTextureComponent current in this.SideTabs) + { + if (current.containsPoint(x, y)) + { + this.HoverText = current.hoverText; + return; + } + } + foreach (ClickableTextureComponent current2 in this.Collections[this.CurrentTab][this.CurrentPage]) + { + if (current2.containsPoint(x, y)) + { + current2.scale = Math.Min(current2.scale + 0.02f, current2.baseScale + 0.1f); + if (Convert.ToBoolean(current2.name.Split(' ')[1]) || this.CurrentTab == 5) + this.HoverText = this.CreateDescription(Convert.ToInt32(current2.name.Split(' ')[0])); + else + this.HoverText = "???"; + } + else + { + current2.scale = Math.Max(current2.scale - 0.02f, current2.baseScale); + } + } + this.ForwardButton.tryHover(x, y, 0.5f); + this.BackButton.tryHover(x, y, 0.5f); + } + + /// Generate the item description for an item ID. + /// The item ID. + private string CreateDescription(int index) + { + string text = ""; + if (this.CurrentTab == 5) + { + string[] array = Game1.achievements[index].Split('^'); + text = text + array[0] + Environment.NewLine + Environment.NewLine; + text += array[1]; + this.NewItem = null; + } + else + { + string[] array2 = Game1.objectInformation[index].Split('/'); + foreach (KeyValuePair meh in Game1.objectInformation) + { + string[] array3 = meh.Value.Split('/'); + if (array3[0] == array2[0]) + { + this.NewItem = new Object(Convert.ToInt32(meh.Key), 1); + if (this.NewItem.Name == "Stone" || this.NewItem.Name == "stone") this.NewItem = new Object(390, 1); + } + } + text = string.Concat(text, array2[0], Environment.NewLine, Environment.NewLine, Game1.parseText(array2[4], Game1.smallFont, Game1.tileSize * 4), Environment.NewLine, Environment.NewLine); + if (array2[3].Contains("Arch")) + { + text += (Game1.player.archaeologyFound.ContainsKey(index) ? Game1.content.LoadString("Strings\\UI:Collections_Description_ArtifactsFound", Game1.player.archaeologyFound[index][0]) : ""); + } + else if (array2[3].Contains("Cooking")) + { + text += (Game1.player.recipesCooked.ContainsKey(index) ? Game1.content.LoadString("Strings\\UI:Collections_Description_RecipesCooked", Game1.player.recipesCooked[index]) : ""); + } + else if (array2[3].Contains("Fish")) + { + text += Game1.content.LoadString("Strings\\UI:Collections_Description_FishCaught", Game1.player.fishCaught.ContainsKey(index) ? Game1.player.fishCaught[index][0] : 0); + if (Game1.player.fishCaught.ContainsKey(index) && Game1.player.fishCaught[index][1] > 0) + { + text = text + Environment.NewLine + Game1.content.LoadString("Strings\\UI:Collections_Description_BiggestCatch", Game1.player.fishCaught[index][1]); + } + } + else if (array2[3].Contains("Minerals") || array2[3].Substring(array2[3].Length - 3).Equals("-2")) + { + text += Game1.content.LoadString("Strings\\UI:Collections_Description_MineralsFound", Game1.player.mineralsFound.ContainsKey(index) ? Game1.player.mineralsFound[index] : 0); + } + else + { + text += Game1.content.LoadString("Strings\\UI:Collections_Description_NumberShipped", Game1.player.basicShipped.ContainsKey(index) ? Game1.player.basicShipped[index] : 0); + } + this.Value = Convert.ToInt32(array2[1]); + this.Value = (int)(this.Value * this.CostMultiplier); + this.NewItemValue = this.Value; + } + return text; + } + + /// Draw the menu to the screen. + /// The sprite batch. + public override void draw(SpriteBatch b) + { + Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true); + + foreach (var tab in this.SideTabs) + tab.draw(b); + + if (this.CurrentPage > 0) + this.BackButton.draw(b); + if (this.CurrentPage < this.Collections[this.CurrentTab].Count - 1) + this.ForwardButton.draw(b); + b.End(); + b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null); + foreach (ClickableTextureComponent current in this.Collections[this.CurrentTab][this.CurrentPage]) + { + bool flag = Convert.ToBoolean(current.name.Split(' ')[1]); + current.draw(b, flag ? Color.White : (Color.Black * 0.2f), 0.86f); + if (this.CurrentTab == 5 & flag) + { + int num = new Random(Convert.ToInt32(current.name.Split(' ')[0])).Next(12); + b.Draw(Game1.mouseCursors, new Vector2(current.bounds.X + 16 + Game1.tileSize / 4, current.bounds.Y + 20 + Game1.tileSize / 4), new Rectangle(256 + num % 6 * Game1.tileSize / 2, 128 + num / 6 * Game1.tileSize / 2, Game1.tileSize / 2, Game1.tileSize / 2), Color.White, 0f, new Vector2(Game1.tileSize / 4, Game1.tileSize / 4), current.scale, SpriteEffects.None, 0.88f); + } + } + b.End(); + b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); + if (!this.HoverText.Equals("")) + IClickableMenu.drawHoverText(b, this.HoverText, Game1.smallFont, 0, 0, this.Value); + if (!Game1.options.hardwareCursor) + b.Draw(Game1.mouseCursors, new Vector2(Game1.getMouseX(), Game1.getMouseY()), Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 0, 16, 16), Color.White * Game1.mouseCursorTransparency, 0f, Vector2.Zero, Game1.pixelZoom + Game1.dialogueButtonScale / 150f, SpriteEffects.None, 1f); + + } + } +} diff --git a/GeneralMods/BuyBackCollectables/Properties/AssemblyInfo.cs b/GeneralMods/BuyBackCollectables/Properties/AssemblyInfo.cs index b2c46286..c3119773 100644 --- a/GeneralMods/BuyBackCollectables/Properties/AssemblyInfo.cs +++ b/GeneralMods/BuyBackCollectables/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("BuyBackCollectables")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BuyBackCollectables")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a19025c4-e194-4cad-b156-4ac00bdd2aa3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/BuyBackCollectables/README.md b/GeneralMods/BuyBackCollectables/README.md new file mode 100644 index 00000000..d01e5f55 --- /dev/null +++ b/GeneralMods/BuyBackCollectables/README.md @@ -0,0 +1,28 @@ +**Buy Back Collectables** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you buy +items from the collectables menu by pressing a key, at a configurable markup. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/507). +3. Run the game using SMAPI. + +## Usage +Press `B` to open the buy-collectibles menu. Edit `BuildHealthConfig.json` to change the key or the +price markup. + +## Versions +1.0: +* Initial release. + +1.0.1: +* Corrected price display to reflect markup. + +1.0.2: +* Fixed issues where unintended items were bought. + +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. +* Fixed mouse not appearing in menu. +* Fixed bug where you sometimes couldn't buy an item even if you had enough money. \ No newline at end of file diff --git a/GeneralMods/BuyBackCollectables/ReadMe.txt b/GeneralMods/BuyBackCollectables/ReadMe.txt deleted file mode 100644 index 12c14207..00000000 --- a/GeneralMods/BuyBackCollectables/ReadMe.txt +++ /dev/null @@ -1,33 +0,0 @@ -BuyBackCollectables - -Version:1.1.0 - -Published: 8/2/16 12:39 AM - -Updated: 10/32/16 10:38 PM - -Compatability: - -Stardew Valley 1.1.0 Windows - -SMAPI 0.40.0 1.1-3 - -Description: - -A simple mod that allows you to buy back any collectable that you have already shiped at 3 times the shipping price. (Configurable in the config file) - -Usage: Press B to open up the buy back menu. - -Update Info: -1.1.0 --Updated to SDV 1.1 --Fixed glitch where mouse would not show up on menu draw. --Fixed glitch where I used a bad math algorithm and you wouldn't be able to buy an item if you had enough money. - -1.0.2 - --Fixed some bugs where you would accidentally purchase some items when not intending to. - -1.0.1 - --Changed price display in buy back menu to propperly reflect buy back price. diff --git a/GeneralMods/BuyBackCollectables/UpdatedCollections.cs b/GeneralMods/BuyBackCollectables/UpdatedCollections.cs deleted file mode 100644 index 724470ae..00000000 --- a/GeneralMods/BuyBackCollectables/UpdatedCollections.cs +++ /dev/null @@ -1,429 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewValley; -using StardewValley.Menus; -using Object = StardewValley.Object; - -namespace Omegasis.BuyBackCollectables -{ - public class UpdatedCollectionsPage : IClickableMenu - { - public static int widthToMoveActiveTab = Game1.tileSize / 8; - - public const int organicsTab = 0; - - public const int fishTab = 1; - - public const int archaeologyTab = 2; - - public const int mineralsTab = 3; - - public const int cookingTab = 4; - - public const int achievementsTab = 5; - - public const int distanceFromMenuBottomBeforeNewPage = 128; - - private string descriptionText = ""; - - private string hoverText = ""; - - private ClickableTextureComponent backButton; - - private ClickableTextureComponent forwardButton; - - private List sideTabs = new List(); - - private int currentTab; - - private int currentPage; - - private Dictionary>> collections = new Dictionary>>(); - - private int value; - - public Item new_item; - public int newItemValue; - - public UpdatedCollectionsPage(int x, int y, int width, int height) : base(x, y, width, height, false) - { - this.sideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4 + UpdatedCollectionsPage.widthToMoveActiveTab, this.yPositionOnScreen + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Shipped", new object[0]), Game1.mouseCursors, new Rectangle(640, 80, 16, 16), (float)Game1.pixelZoom, false)); - this.collections.Add(0, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 3, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Fish", new object[0]), Game1.mouseCursors, new Rectangle(640, 64, 16, 16), (float)Game1.pixelZoom, false)); - this.collections.Add(1, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 4, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Artifacts", new object[0]), Game1.mouseCursors, new Rectangle(656, 64, 16, 16), (float)Game1.pixelZoom, false)); - this.collections.Add(2, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 5, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Minerals", new object[0]), Game1.mouseCursors, new Rectangle(672, 64, 16, 16), (float)Game1.pixelZoom, false)); - this.collections.Add(3, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 6, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Cooking", new object[0]), Game1.mouseCursors, new Rectangle(688, 64, 16, 16), (float)Game1.pixelZoom, false)); - this.collections.Add(4, new List>()); - this.sideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 7, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Achievements", new object[0]), Game1.mouseCursors, new Rectangle(656, 80, 16, 16), (float)Game1.pixelZoom, false)); - this.collections.Add(5, new List>()); - UpdatedCollectionsPage.widthToMoveActiveTab = Game1.tileSize / 8; - this.backButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 3 / 4, this.yPositionOnScreen + height - 20 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), (float)Game1.pixelZoom, false); - this.forwardButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + width - Game1.tileSize / 2 - 15 * Game1.pixelZoom, this.yPositionOnScreen + height - 20 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), (float)Game1.pixelZoom, false); - int[] array = new int[this.sideTabs.Count]; - int num = this.xPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearSideBorder; - int num2 = this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 4; - int num3 = 10; - foreach (KeyValuePair current in Game1.objectInformation) - { - string text = current.Value.Split(new char[] - { - '/' - })[3]; - bool drawShadow = false; - int num4; - if (text.Contains("Arch")) - { - num4 = 2; - if (Game1.player.archaeologyFound.ContainsKey(current.Key)) - { - drawShadow = true; - } - } - else if (text.Contains("Fish")) - { - if (current.Key >= 167 && current.Key < 173) - { - continue; - } - num4 = 1; - if (Game1.player.fishCaught.ContainsKey(current.Key)) - { - drawShadow = true; - } - } - else if (text.Contains("Mineral") || text.Substring(text.Length - 3).Equals("-2")) - { - num4 = 3; - if (Game1.player.mineralsFound.ContainsKey(current.Key)) - { - drawShadow = true; - } - } - else if (text.Contains("Cooking") || text.Substring(text.Length - 3).Equals("-7")) - { - num4 = 4; - if (Game1.player.recipesCooked.ContainsKey(current.Key)) - { - drawShadow = true; - } - if (current.Key == 217 || current.Key == 772) - { - continue; - } - if (current.Key == 773) - { - continue; - } - } - else - { - if (!StardewValley.Object.isPotentialBasicShippedCategory(current.Key, text.Substring(text.Length - 3))) - { - continue; - } - num4 = 0; - if (Game1.player.basicShipped.ContainsKey(current.Key)) - { - drawShadow = true; - } - } - int x2 = num + array[num4] % num3 * (Game1.tileSize + 4); - int num5 = num2 + array[num4] / num3 * (Game1.tileSize + 4); - if (num5 > this.yPositionOnScreen + height - 128) - { - this.collections[num4].Add(new List()); - array[num4] = 0; - x2 = num; - num5 = num2; - } - if (this.collections[num4].Count == 0) - { - this.collections[num4].Add(new List()); - } - this.collections[num4].Last>().Add(new ClickableTextureComponent(current.Key + " " + drawShadow.ToString(), new Rectangle(x2, num5, Game1.tileSize, Game1.tileSize), null, "", Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, current.Key, 16, 16), (float)Game1.pixelZoom, drawShadow)); - array[num4]++; - } - if (this.collections[5].Count == 0) - { - this.collections[5].Add(new List()); - } - foreach (KeyValuePair current2 in Game1.achievements) - { - bool flag = Game1.player.achievements.Contains(current2.Key); - string[] array2 = current2.Value.Split(new char[] - { - '^' - }); - if (flag || (array2[2].Equals("true") && (array2[3].Equals("-1") || this.farmerHasAchievements(array2[3])))) - { - int x3 = num + array[5] % num3 * (Game1.tileSize + 4); - int y2 = num2 + array[5] / num3 * (Game1.tileSize + 4); - this.collections[5][0].Add(new ClickableTextureComponent(current2.Key + " " + flag.ToString(), new Rectangle(x3, y2, Game1.tileSize, Game1.tileSize), null, "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 25, -1, -1), 1f, false)); - array[5]++; - } - } - } - - private bool farmerHasAchievements(string listOfAchievementNumbers) - { - string[] array = listOfAchievementNumbers.Split(new char[] - { - ' ' - }); - for (int i = 0; i < array.Length; i++) - { - string text = array[i]; - if (!Game1.player.achievements.Contains(Convert.ToInt32(text))) - { - return false; - } - } - return true; - } - - public override void receiveLeftClick(int x, int y, bool playSound = true) - { - for (int i = 0; i < this.sideTabs.Count; i++) - { - if (this.sideTabs[i].containsPoint(x, y) && this.currentTab != i) - { - Game1.playSound("smallSelect"); - ClickableTextureComponent expr_47_cp_0_cp_0 = this.sideTabs[this.currentTab]; - expr_47_cp_0_cp_0.bounds.X = expr_47_cp_0_cp_0.bounds.X - UpdatedCollectionsPage.widthToMoveActiveTab; - this.currentTab = i; - this.currentPage = 0; - ClickableTextureComponent expr_74_cp_0_cp_0 = this.sideTabs[i]; - expr_74_cp_0_cp_0.bounds.X = expr_74_cp_0_cp_0.bounds.X + UpdatedCollectionsPage.widthToMoveActiveTab; - } - } - if (this.currentPage > 0 && this.backButton.containsPoint(x, y)) - { - this.currentPage--; - Game1.playSound("shwip"); - this.backButton.scale = this.backButton.baseScale; - } - if (this.currentPage < this.collections[this.currentTab].Count - 1 && this.forwardButton.containsPoint(x, y)) - { - this.currentPage++; - Game1.playSound("shwip"); - this.forwardButton.scale = this.forwardButton.baseScale; - } - foreach (ClickableTextureComponent current2 in this.collections[this.currentTab][this.currentPage]) - { - if (current2.containsPoint(x, y)) - { - if (new_item != null) - { - if (Game1.player.money >= value) - { - Game1.player.money -= value; - Game1.player.addItemByMenuIfNecessary(new_item); - } - - } - } - } - } - - public override void receiveRightClick(int x, int y, bool playSound = true) - { - if (new_item != null) - { - if (Game1.player.money >= value) - { - - Game1.player.money -= value; - Game1.player.addItemByMenuIfNecessary(new_item); - } - - } - } - - public override void performHoverAction(int x, int y) - { - this.descriptionText = ""; - this.hoverText = ""; - this.value = -1; - foreach (ClickableTextureComponent current in this.sideTabs) - { - if (current.containsPoint(x, y)) - { - this.hoverText = current.hoverText; - return; - } - } - foreach (ClickableTextureComponent current2 in this.collections[this.currentTab][this.currentPage]) - { - if (current2.containsPoint(x, y)) - { - current2.scale = Math.Min(current2.scale + 0.02f, current2.baseScale + 0.1f); - if (Convert.ToBoolean(current2.name.Split(new char[] - { - ' ' - })[1]) || this.currentTab == 5) - { - this.hoverText = this.createDescription(Convert.ToInt32(current2.name.Split(new char[] - { - ' ' - })[0])); - } - else - { - this.hoverText = "???"; - } - } - else - { - current2.scale = Math.Max(current2.scale - 0.02f, current2.baseScale); - } - } - this.forwardButton.tryHover(x, y, 0.5f); - this.backButton.tryHover(x, y, 0.5f); - } - - public string createDescription(int index) - { - string text = ""; - if (this.currentTab == 5) - { - string[] array = Game1.achievements[index].Split(new char[] - { - '^' - }); - text = text + array[0] + Environment.NewLine + Environment.NewLine; - text += array[1]; - new_item = null; - } - else - { - string[] array2 = Game1.objectInformation[index].Split(new char[] - { - '/' - }); - foreach (KeyValuePair meh in Game1.objectInformation) - { - string[] array3 = meh.Value.Split(new char[] - { - '/' - }); - if (array3[0] == array2[0]) - { - new_item = (Item)new Object(Convert.ToInt32(meh.Key), 1, false, -1, 0); - if (new_item.Name == "Stone" || new_item.Name == "stone") new_item = (Item)new Object(390, 1, false, -1, 0); - } - } - text = string.Concat(new string[] - { - text, - array2[0], - Environment.NewLine, - Environment.NewLine, - Game1.parseText(array2[4], Game1.smallFont, Game1.tileSize * 4), - Environment.NewLine, - Environment.NewLine - }); - if (array2[3].Contains("Arch")) - { - text += (Game1.player.archaeologyFound.ContainsKey(index) ? Game1.content.LoadString("Strings\\UI:Collections_Description_ArtifactsFound", new object[] - { - Game1.player.archaeologyFound[index][0] - }) : ""); - } - else if (array2[3].Contains("Cooking")) - { - text += (Game1.player.recipesCooked.ContainsKey(index) ? Game1.content.LoadString("Strings\\UI:Collections_Description_RecipesCooked", new object[] - { - Game1.player.recipesCooked[index] - }) : ""); - } - else if (array2[3].Contains("Fish")) - { - text += Game1.content.LoadString("Strings\\UI:Collections_Description_FishCaught", new object[] - { - Game1.player.fishCaught.ContainsKey(index) ? Game1.player.fishCaught[index][0] : 0 - }); - if (Game1.player.fishCaught.ContainsKey(index) && Game1.player.fishCaught[index][1] > 0) - { - text = text + Environment.NewLine + Game1.content.LoadString("Strings\\UI:Collections_Description_BiggestCatch", new object[] - { - Game1.player.fishCaught[index][1] - }); - } - } - else if (array2[3].Contains("Minerals") || array2[3].Substring(array2[3].Length - 3).Equals("-2")) - { - text += Game1.content.LoadString("Strings\\UI:Collections_Description_MineralsFound", new object[] - { - Game1.player.mineralsFound.ContainsKey(index) ? Game1.player.mineralsFound[index] : 0 - }); - } - else - { - text += Game1.content.LoadString("Strings\\UI:Collections_Description_NumberShipped", new object[] - { - Game1.player.basicShipped.ContainsKey(index) ? Game1.player.basicShipped[index] : 0 - }); - } - this.value = Convert.ToInt32(array2[1]); - this.value = (int)(this.value * Class1.cost); - newItemValue = this.value; - } - return text; - } - - public override void draw(SpriteBatch b) - { - Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true, null, false); - using (List.Enumerator enumerator = this.sideTabs.GetEnumerator()) - { - while (enumerator.MoveNext()) - { - enumerator.Current.draw(b); - } - } - if (this.currentPage > 0) - { - this.backButton.draw(b); - } - if (this.currentPage < this.collections[this.currentTab].Count - 1) - { - this.forwardButton.draw(b); - } - b.End(); - b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null); - foreach (ClickableTextureComponent current in this.collections[this.currentTab][this.currentPage]) - { - bool flag = Convert.ToBoolean(current.name.Split(new char[] - { - ' ' - })[1]); - current.draw(b, flag ? Color.White : (Color.Black * 0.2f), 0.86f); - if (this.currentTab == 5 & flag) - { - int num = new Random(Convert.ToInt32(current.name.Split(new char[] - { - ' ' - })[0])).Next(12); - b.Draw(Game1.mouseCursors, new Vector2((float)(current.bounds.X + 16 + Game1.tileSize / 4), (float)(current.bounds.Y + 20 + Game1.tileSize / 4)), new Rectangle?(new Rectangle(256 + num % 6 * Game1.tileSize / 2, 128 + num / 6 * Game1.tileSize / 2, Game1.tileSize / 2, Game1.tileSize / 2)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 4), (float)(Game1.tileSize / 4)), current.scale, SpriteEffects.None, 0.88f); - } - } - b.End(); - b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); - if (!this.hoverText.Equals("")) - { - IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, 0, 0, this.value, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null); - } - if (!Game1.options.hardwareCursor) - { - b.Draw(Game1.mouseCursors, new Vector2((float)Game1.getMouseX(), (float)Game1.getMouseY()), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 0, 16, 16)), Color.White * Game1.mouseCursorTransparency, 0f, Vector2.Zero, (float)Game1.pixelZoom + Game1.dialogueButtonScale / 150f, SpriteEffects.None, 1f); - } - - } - } -} diff --git a/GeneralMods/BuyBackCollectables/manifest.json b/GeneralMods/BuyBackCollectables/manifest.json index 3fcf78f4..75dc7c6e 100644 --- a/GeneralMods/BuyBackCollectables/manifest.json +++ b/GeneralMods/BuyBackCollectables/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "BuyBackCollectables", "PerSaveConfigs": false, "EntryDll": "BuyBackCollectables.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/CustomShopsRedux/Class1.cs b/GeneralMods/CustomShopsRedux/Class1.cs deleted file mode 100644 index 597e9bed..00000000 --- a/GeneralMods/CustomShopsRedux/Class1.cs +++ /dev/null @@ -1,831 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.Xna.Framework; -using StardewModdingAPI; -using StardewValley; -using StardewValley.Menus; -using StardewValley.Objects; -using StardewValley.Tools; - -/* -TO DO: -Items -furniture -swords - -hats - -boots - -wallpapers - -carpets - -ring - -lamp- -craftables- -*/ -namespace Omegasis.CustomShopsRedux -{ - public class Class1 : Mod - { - public static IClickableMenu mymenu; - static int j = 0; - static Dictionary list_price = new Dictionary(); - - static string master_path; - List myoptions = new List(); - string key_binding = "U"; - - bool game_loaded = false; - - public override void Entry(params object[] objects) - { - //set up all of my events here - StardewModdingAPI.Events.PlayerEvents.LoadedGame += PlayerEvents_LoadedGame; - StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; - } - - - - public void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) - { - if (game_loaded == false) return; - - if (e.KeyPressed.ToString() == key_binding) //if the key is pressed, load my cusom save function - { - - my_key_call(); - - - } - //DataLoader_Settings(); //update the key if players changed it while playing. - - } - - public void PlayerEvents_LoadedGame(object sender, StardewModdingAPI.Events.EventArgsLoadedGameChanged e) - { - game_loaded = true; - DataLoader_Settings(); - MyWritter_Settings(); - } - - - - - void DataLoader_Settings() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(PathOnDisk, "Custom_Shop_Redux_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - master_path = PathOnDisk; - - Directory.CreateDirectory(Path.Combine(master_path, "Custom_Shops")); - - master_path = Path.Combine(master_path, "Custom_Shops"); - - - - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - // Console.WriteLine("Can't load custom save info since the file doesn't exist."); - - key_binding = "U"; - // Log.Info("KEY TIME"); - } - - else - { - // Console.WriteLine("HEY THERE IM LOADING DATA"); - string[] readtext = File.ReadAllLines(mylocation3); - key_binding = Convert.ToString(readtext[3]); - - - // Log.Info(key_binding); - // Log.Info(Convert.ToString(readtext[3])); - - } - } - - void MyWritter_Settings() - { - - //write all of my info to a text file. - string myname = StardewValley.Game1.player.name; - - string mylocation = Path.Combine(PathOnDisk, "Custom_Shop_Redux_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now."); - - mystring3[0] = "Config: Custom_Shop_Redux. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Key binding for saving anywhere. Press this key to save anywhere!"; - mystring3[3] = key_binding.ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - - } - - else - { - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now."); - - mystring3[0] = "Config: Custom_Shop_Redux. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Key binding for saving anywhere. Press this key to save anywhere!"; - mystring3[3] = key_binding.ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - } - } - - - - - public void my_key_call() - { - var modpath = new Class1(); - - - DirectoryInfo d = new DirectoryInfo(master_path);//Assuming Test is your Folder - Log.Info(d); - // System.Threading.Thread.Sleep(20000); - - FileInfo[] Files = d.GetFiles("*.txt"); //Getting Text files - string str = ""; - - if (Files.Length == 0) - { - Log.Error("No shop .txt information is found. You should create one."); - return; - - } - foreach (FileInfo file in Files) - { - str = file.Name; - // Log.Info(str); - - myoptions.Add(str); - } - - if (myoptions.Count == 0) - { - Log.Error("No shop .txt information is found. You should create one."); - return; - } - - StardewValley.Menus.ChooseFromListMenu mychoices = new StardewValley.Menus.ChooseFromListMenu(myoptions, new ChooseFromListMenu.actionOnChoosingListOption(shop_file_call), false); - - Game1.activeClickableMenu = mychoices; - - - - - - - - } - - - - static void shop_file_call(string s) - { - List list = new List(); - - - string mylocation = Path.Combine(master_path , s); - - /// Log.Info(mylocation); - - - string[] readtext = File.ReadAllLines(mylocation); - - var lineCount = File.ReadLines(mylocation).Count(); - - -// Log.Info(lineCount); - - if(s== "Custom_Shop_Redux_Config.txt") - { - Log.Info("Silly human. The config file is not a shop."); - return; - } - - int i = 4; - - int obj_id = 0; - bool is_recipe; - int price; - int quality; - - string obj_type; - - obj_type = Convert.ToString(readtext[i]); - i += 2; - - - - while (i < lineCount) - { - if (i >= lineCount) break; - if (obj_type == "") break; - if (readtext[i] == "") break; - - //read in a line for obj type here - Log.Info(i); - Log.Info(obj_type); - if (obj_type == "item" || obj_type == "Item" || obj_type == "Object" || obj_type == "object") - { - - obj_id = Convert.ToInt16(readtext[i]); - i += 2; - - Log.Info(i); - is_recipe = Convert.ToBoolean(readtext[i]); - i += 2; - Log.Info(i); - price = Convert.ToInt32(readtext[i]); - i += 2; - Log.Info(i); - - quality = Convert.ToInt32(readtext[i]); - // if (quality > 2) quality = 0; - - - if (price == -1) - { - StardewValley.Object myobj = new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality); - - // Log.Info("MYPRICE"); - // Log.Info(myobj.salePrice()); - price = myobj.salePrice(); - - } - - - // list.Add((Item)new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality)); - list_price.Add((Item)new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality), new int[2] {price, int.MaxValue}); - i += 3; - if (i >= lineCount) break; - } - if (obj_type == "Furniture" || obj_type == "furniture") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - - // list.Add((Item)new Furniture(obj_id, Vector2.Zero)); //ADD FUNCTIONALITY TO SHOP FILES TO TEST IF FURNITURE OR NOT. - list_price.Add((Item)new Furniture(obj_id, Vector2.Zero), new int[2] { price, int.MaxValue }); - i += 3; - if (i>= lineCount) break; - - - - - } - - if (obj_type == "Boots" || obj_type == "boots" || obj_type == "shoe" || obj_type == "Shoe") //just incase someone forgets it's called boots and they type shoe. - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price= Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Boots(obj_id),new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - - } - - if (obj_type == "WallPaper" || obj_type == "Wallpaper" || obj_type == "wallPaper" || obj_type == "wallpaper") //just incase someone forgets it's called boots and they type shoe. - { - if (i + 3 > lineCount) break; - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Wallpaper(obj_id, false), new int[2] { price, int.MaxValue }); //add in support for wallpapers and carpets - i += 3; - if (i >= lineCount) break; - - } - - if (obj_type == "Carpet" || obj_type == "carpet" || obj_type == "Floor" || obj_type == "floor" || obj_type == "Rug" || obj_type == "rug") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Wallpaper(obj_id, true), new int[2] { price, int.MaxValue }); //add in support for wallpapers and carpets - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Ring" || obj_type == "ring") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Ring(obj_id), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - } - if (obj_type == "Lamp" || obj_type == "lamp" || obj_type == "Torch" || obj_type == "torch" || obj_type == "Craftable" || obj_type == "craftable" || obj_type == "BigCraftable" || obj_type == "bigcraftable") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Torch(Vector2.Zero, obj_id, true), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Sword" || obj_type == "sword" || obj_type == "Weapon" || obj_type == "weapon") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new MeleeWeapon(obj_id), new int[2] { price, int.MaxValue }); - - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Hat" || obj_type == "hat" || obj_type == "Hats" || obj_type == "hats") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - // list_price.Add((Item)new Hat(obj_id), new int[2] { price, int.MaxValue }); - list_price.Add((Item)new Hat(obj_id), new int[2] - { - price, - int.MaxValue - }); - i += 3; - if (i >= lineCount) break; - } - - - //TODO: - //add in support for colored objects - //add in support for tools - Log.Success(i); - if (i >= lineCount) break; - else { - obj_type = Convert.ToString(readtext[i]); - i += 2; - } - } - - - //NEED TO TEST ALL DATA FILES TO SEE WHAT CAN AND CANT BE ADDED - //list.Add((Item)new StardewValley.Objects.ColoredObject(475,300, Color.Aqua)); - // Game1.activeClickableMenu = (IClickableMenu)new ShopMenu(list, 0, "Pierre"); - - - - - Game1.activeClickableMenu = (IClickableMenu)new ShopMenu(list_price, 0, "Pierre"); - - } //very basic shop call with choosable menu to iterate through. - - - public static void external_shop_file_call(string path, string fileName) - { - List list = new List(); - - - string mylocation = Path.Combine(path, fileName); - - /// Log.Info(mylocation); - - - string[] readtext = File.ReadAllLines(mylocation); - - var lineCount = File.ReadLines(mylocation).Count(); - - - // Log.Info(lineCount); - - int i = 4; - - int obj_id = 0; - bool is_recipe; - int price; - int quality; - - string obj_type; - - obj_type = Convert.ToString(readtext[i]); - i += 2; - - - - while (i < lineCount) - { - if (i >= lineCount) break; - if (obj_type == "") break; - if (readtext[i] == "") break; - - //read in a line for obj type here - Log.Info(i); - Log.Info(obj_type); - if (obj_type == "item" || obj_type == "Item" || obj_type == "Object" || obj_type == "object") - { - - obj_id = Convert.ToInt16(readtext[i]); - i += 2; - - Log.Info(i); - is_recipe = Convert.ToBoolean(readtext[i]); - i += 2; - Log.Info(i); - price = Convert.ToInt32(readtext[i]); - i += 2; - Log.Info(i); - - quality = Convert.ToInt32(readtext[i]); - // if (quality > 2) quality = 0; - - - if (price == -1) - { - StardewValley.Object myobj = new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality); - - // Log.Info("MYPRICE"); - // Log.Info(myobj.salePrice()); - price = myobj.salePrice(); - - } - - - // list.Add((Item)new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality)); - list_price.Add((Item)new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - } - if (obj_type == "Furniture" || obj_type == "furniture") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - - // list.Add((Item)new Furniture(obj_id, Vector2.Zero)); //ADD FUNCTIONALITY TO SHOP FILES TO TEST IF FURNITURE OR NOT. - list_price.Add((Item)new Furniture(obj_id, Vector2.Zero), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - - - - - } - - if (obj_type == "Boots" || obj_type == "boots" || obj_type == "shoe" || obj_type == "Shoe") //just incase someone forgets it's called boots and they type shoe. - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Boots(obj_id), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - - } - - if (obj_type == "WallPaper" || obj_type == "Wallpaper" || obj_type == "wallPaper" || obj_type == "wallpaper") //just incase someone forgets it's called boots and they type shoe. - { - if (i + 3 > lineCount) break; - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Wallpaper(obj_id, false), new int[2] { price, int.MaxValue }); //add in support for wallpapers and carpets - i += 3; - if (i >= lineCount) break; - - } - - if (obj_type == "Carpet" || obj_type == "carpet" || obj_type == "Floor" || obj_type == "floor" || obj_type == "Rug" || obj_type == "rug") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Wallpaper(obj_id, true), new int[2] { price, int.MaxValue }); //add in support for wallpapers and carpets - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Ring" || obj_type == "ring") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Ring(obj_id), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - } - if (obj_type == "Lamp" || obj_type == "lamp" || obj_type == "Torch" || obj_type == "torch" || obj_type == "Craftable" || obj_type == "craftable" || obj_type == "BigCraftable" || obj_type == "bigcraftable") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Torch(Vector2.Zero, obj_id, true), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Sword" || obj_type == "sword" || obj_type == "Weapon" || obj_type == "weapon") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new MeleeWeapon(obj_id), new int[2] { price, int.MaxValue }); - - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Hat" || obj_type == "hat" || obj_type == "Hats" || obj_type == "hats") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - // list_price.Add((Item)new Hat(obj_id), new int[2] { price, int.MaxValue }); - list_price.Add((Item)new Hat(obj_id), new int[2] - { - price, - int.MaxValue - }); - i += 3; - if (i >= lineCount) break; - } - - - //TODO: - //add in support for colored objects - //add in support for tools - Log.Success(i); - if (i >= lineCount) break; - else { - obj_type = Convert.ToString(readtext[i]); - i += 2; - } - } - - - //NEED TO TEST ALL DATA FILES TO SEE WHAT CAN AND CANT BE ADDED - //list.Add((Item)new StardewValley.Objects.ColoredObject(475,300, Color.Aqua)); - // Game1.activeClickableMenu = (IClickableMenu)new ShopMenu(list, 0, "Pierre"); - - - mymenu = (IClickableMenu)new ShopMenu(list_price, 0, "Pierre"); - - Game1.activeClickableMenu = mymenu; //(IClickableMenu)new ShopMenu(list_price, 0, "Pierre"); - - }//basic default of Pierre - - - public static void external_shop_file_call(string path, string fileName, string shopChat, NPC my_npc ) - { - - List list = new List(); - - - string mylocation = Path.Combine(path, fileName); - - /// Log.Info(mylocation); - - - string[] readtext = File.ReadAllLines(mylocation); - - var lineCount = File.ReadLines(mylocation).Count(); - - - // Log.Info(lineCount); - - int i = 4; - - int obj_id = 0; - bool is_recipe; - int price; - int quality; - - string obj_type; - - obj_type = Convert.ToString(readtext[i]); - i += 2; - - - - while (i < lineCount) - { - if (i >= lineCount) break; - if (obj_type == "") break; - if (readtext[i] == "") break; - - //read in a line for obj type here - Log.Info(i); - Log.Info(obj_type); - if (obj_type == "item" || obj_type == "Item" || obj_type == "Object" || obj_type == "object") - { - - obj_id = Convert.ToInt16(readtext[i]); - i += 2; - - Log.Info(i); - is_recipe = Convert.ToBoolean(readtext[i]); - i += 2; - Log.Info(i); - price = Convert.ToInt32(readtext[i]); - i += 2; - Log.Info(i); - - quality = Convert.ToInt32(readtext[i]); - // if (quality > 2) quality = 0; - - - if (price == -1) - { - StardewValley.Object myobj = new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality); - - // Log.Info("MYPRICE"); - // Log.Info(myobj.salePrice()); - price = myobj.salePrice(); - - } - - - // list.Add((Item)new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality)); - list_price.Add((Item)new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - } - if (obj_type == "Furniture" || obj_type == "furniture") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - - // list.Add((Item)new Furniture(obj_id, Vector2.Zero)); //ADD FUNCTIONALITY TO SHOP FILES TO TEST IF FURNITURE OR NOT. - list_price.Add((Item)new Furniture(obj_id, Vector2.Zero), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - - - - - } - - if (obj_type == "Boots" || obj_type == "boots" || obj_type == "shoe" || obj_type == "Shoe") //just incase someone forgets it's called boots and they type shoe. - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Boots(obj_id), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - - } - - if (obj_type == "WallPaper" || obj_type == "Wallpaper" || obj_type == "wallPaper" || obj_type == "wallpaper") //just incase someone forgets it's called boots and they type shoe. - { - if (i + 3 > lineCount) break; - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Wallpaper(obj_id, false), new int[2] { price, int.MaxValue }); //add in support for wallpapers and carpets - i += 3; - if (i >= lineCount) break; - - } - - if (obj_type == "Carpet" || obj_type == "carpet" || obj_type == "Floor" || obj_type == "floor" || obj_type == "Rug" || obj_type == "rug") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Wallpaper(obj_id, true), new int[2] { price, int.MaxValue }); //add in support for wallpapers and carpets - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Ring" || obj_type == "ring") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Objects.Ring(obj_id), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - } - if (obj_type == "Lamp" || obj_type == "lamp" || obj_type == "Torch" || obj_type == "torch" || obj_type == "Craftable" || obj_type == "craftable" || obj_type == "BigCraftable" || obj_type == "bigcraftable") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new StardewValley.Torch(Vector2.Zero, obj_id, true), new int[2] { price, int.MaxValue }); - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Sword" || obj_type == "sword" || obj_type == "Weapon" || obj_type == "weapon") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - list_price.Add((Item)new MeleeWeapon(obj_id), new int[2] { price, int.MaxValue }); - - i += 3; - if (i >= lineCount) break; - } - - if (obj_type == "Hat" || obj_type == "hat" || obj_type == "Hats" || obj_type == "hats") - { - obj_id = Convert.ToInt32(readtext[i]); - i += 2; - price = Convert.ToInt32(readtext[i]); - // list_price.Add((Item)new Hat(obj_id), new int[2] { price, int.MaxValue }); - list_price.Add((Item)new Hat(obj_id), new int[2] - { - price, - int.MaxValue - }); - i += 3; - if (i >= lineCount) break; - } - - - //TODO: - //add in support for colored objects - //add in support for tools - Log.Success(i); - if (i >= lineCount) break; - else { - obj_type = Convert.ToString(readtext[i]); - i += 2; - } - } - - - //NEED TO TEST ALL DATA FILES TO SEE WHAT CAN AND CANT BE ADDED - //list.Add((Item)new StardewValley.Objects.ColoredObject(475,300, Color.Aqua)); - // Game1.activeClickableMenu = (IClickableMenu)new ShopMenu(list, 0, "Pierre"); - - var shop_menu=new ShopMenu(list_price, 0, my_npc.name); - - shop_menu.potraitPersonDialogue = Game1.parseText(shopChat, Game1.dialogueFont, Game1.tileSize * 5 - Game1.pixelZoom * 4); - shop_menu.portraitPerson = my_npc; - - mymenu = shop_menu; - - - Game1.activeClickableMenu = mymenu; //(IClickableMenu)new ShopMenu(list_price, 0, "Pierre"); - - } //uses NPCS with new dialogue and portraits - - //example of a shop that I don't use. - public static List myshop() - { - List list = new List(); - list.Add((Item)new StardewValley.Object(478, int.MaxValue, false, -1, 0)); //int parentsheet index OR object_ID/int.MaxValue, bool is recipe, price, quality - list.Add((Item)new StardewValley.Object(486, int.MaxValue, false, -1, 0)); - list.Add((Item)new StardewValley.Object(494, int.MaxValue, false, -1, 0)); //Might be able to manipulate this code to give me recipes!!!! - list.Add((Item)new StardewValley.Object(495, int.MaxValue, false, 800, 0)); //price is *2 of value shown. -1 means inherit default value - switch (Game1.dayOfMonth % 7) - { - case 0: - list.Add((Item)new StardewValley.Object(233, int.MaxValue, false, -1, 0)); - break; - case 1: - list.Add((Item)new StardewValley.Object(88, int.MaxValue, false, -1, 0)); - break; - case 2: - list.Add((Item)new StardewValley.Object(90, int.MaxValue, false, -1, 0)); - break; - case 3: - list.Add((Item)new StardewValley.Object(749, int.MaxValue, false, 500, 0)); - break; - case 4: - list.Add((Item)new StardewValley.Object(466, int.MaxValue, false, -1, 0)); - break; - case 5: - list.Add((Item)new StardewValley.Object(340, int.MaxValue, false, -1, 0)); - break; - case 6: - list.Add((Item)new StardewValley.Object(371, int.MaxValue, false, 100, 0)); - break; - } - return list; - } - - - } -} -//end class \ No newline at end of file diff --git a/GeneralMods/CustomShopsRedux/CustomShopsRedux.cs b/GeneralMods/CustomShopsRedux/CustomShopsRedux.cs new file mode 100644 index 00000000..f0efc877 --- /dev/null +++ b/GeneralMods/CustomShopsRedux/CustomShopsRedux.cs @@ -0,0 +1,722 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.Xna.Framework; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; +using StardewValley.Menus; +using StardewValley.Objects; +using StardewValley.Tools; + +/* +TO DO: +Items +furniture +swords - +hats - +boots - +wallpapers - +carpets - +ring - +lamp- +craftables- +*/ +namespace Omegasis.CustomShopsRedux +{ + /// The mod entry point. + public class CustomShopsRedux : Mod + { + /********* + ** Properties + *********/ + /// The prices for the items to list. + private readonly Dictionary ListPrices = new Dictionary(); + + /// The folder path containing shop data files. + private string DataPath; + + /// The configured shop options. + private readonly List Options = new List(); + + /// The key which shows the menu. + private string KeyBinding = "U"; + + /// Whether the player loaded a save. + private bool IsGameLoaded; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// The mod arguments. + public override void Entry(params object[] args) + { + PlayerEvents.LoadedGame += this.PlayerEvents_LoadedGame; + ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + } + + + /********* + ** Private methods + *********/ + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void PlayerEvents_LoadedGame(object sender, EventArgsLoadedGameChanged e) + { + this.IsGameLoaded = true; + this.LoadConfig(); + this.WriteConfig(); + } + + /// The method invoked when the presses a keyboard button. + /// The event sender. + /// The event data. + private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + { + if (!this.IsGameLoaded) + return; + + if (e.KeyPressed.ToString() == this.KeyBinding) //if the key is pressed, load my cusom save function + { + this.OpenSelectFileMenu(); + } + } + + /// Load the configuration settings. + private void LoadConfig() + { + this.DataPath = Path.Combine(this.PathOnDisk, "Custom_Shops"); + Directory.CreateDirectory(this.DataPath); + + string path = Path.Combine(this.PathOnDisk, "Custom_Shop_Redux_Config.txt"); + if (!File.Exists(path)) + this.KeyBinding = "U"; + else + { + string[] text = File.ReadAllLines(path); + this.KeyBinding = Convert.ToString(text[3]); + } + } + + /// Save the configuration settings. + private void WriteConfig() + { + string path = Path.Combine(this.PathOnDisk, "Custom_Shop_Redux_Config.txt"); + string[] text = new string[20]; + text[0] = "Config: Custom_Shop_Redux. Feel free to mess with these settings."; + text[1] = "===================================================================================="; + + text[2] = "Key binding for saving anywhere. Press this key to save anywhere!"; + text[3] = this.KeyBinding; + + File.WriteAllLines(path, text); + } + + /// Open the menu which lets the player choose a file. + private void OpenSelectFileMenu() + { + // get mod folder + DirectoryInfo modFolder = new DirectoryInfo(this.DataPath); + Log.Info(modFolder); + + // get text files + FileInfo[] files = modFolder.GetFiles("*.txt"); + if (!files.Any()) + { + Log.Error("No shop .txt information is found. You should create one."); + return; + } + + // parse options + foreach (FileInfo file in files) + this.Options.Add(file.Name); + if (!this.Options.Any()) + { + Log.Error("No shop .txt information is found. You should create one."); + return; + } + + // load menu + Game1.activeClickableMenu = new ChooseFromListMenu(this.Options, this.OnChoiceSelected); + } + + /// The method called when the player chooses an option from the file list. + /// The selected file name. + private void OnChoiceSelected(string filename) + { + // read file data + string path = Path.Combine(this.DataPath, filename); + string[] text = File.ReadAllLines(path); + int lineCount = text.Length; + + // validate + if (filename == "Custom_Shop_Redux_Config.txt") + { + Log.Info("Silly human. The config file is not a shop."); + return; + } + + // parse data + string objType = Convert.ToString(text[4]); + int i = 6; + while (i < lineCount) + { + if (i >= lineCount || objType == "" || text[i] == "") break; + + //read in a line for obj type here + Log.Info(i); + Log.Info(objType); + int objID; + int price; + if (objType == "item" || objType == "Item" || objType == "Object" || objType == "object") + { + objID = Convert.ToInt16(text[i]); + i += 2; + + Log.Info(i); + bool isRecipe = Convert.ToBoolean(text[i]); + i += 2; + Log.Info(i); + price = Convert.ToInt32(text[i]); + i += 2; + Log.Info(i); + + int quality = Convert.ToInt32(text[i]); + + if (price == -1) + { + StardewValley.Object myobj = new StardewValley.Object(objID, int.MaxValue, isRecipe, price, quality); + price = myobj.salePrice(); + } + + this.ListPrices.Add(new StardewValley.Object(objID, int.MaxValue, isRecipe, price, quality), new[] { price, int.MaxValue }); + i += 3; + if (i >= lineCount) + break; + } + + if (objType == "Furniture" || objType == "furniture") + { + objID = Convert.ToInt32(text[i]); + i += 2; + price = Convert.ToInt32(text[i]); + + this.ListPrices.Add(new Furniture(objID, Vector2.Zero), new[] { price, int.MaxValue }); + i += 3; + if (i >= lineCount) + break; + } + + if (objType == "Boots" || objType == "boots" || objType == "shoe" || objType == "Shoe") //just incase someone forgets it's called boots and they type shoe. + { + objID = Convert.ToInt32(text[i]); + i += 2; + price = Convert.ToInt32(text[i]); + this.ListPrices.Add(new Boots(objID), new[] { price, int.MaxValue }); + i += 3; + if (i >= lineCount) + break; + } + + if (objType == "WallPaper" || objType == "Wallpaper" || objType == "wallPaper" || objType == "wallpaper") + { + if (i + 3 > lineCount) + break; + objID = Convert.ToInt32(text[i]); + i += 2; + price = Convert.ToInt32(text[i]); + this.ListPrices.Add(new Wallpaper(objID), new[] { price, int.MaxValue }); //add in support for wallpapers and carpets + i += 3; + if (i >= lineCount) + break; + + } + + if (objType == "Carpet" || objType == "carpet" || objType == "Floor" || objType == "floor" || objType == "Rug" || objType == "rug") + { + objID = Convert.ToInt32(text[i]); + i += 2; + price = Convert.ToInt32(text[i]); + this.ListPrices.Add(new Wallpaper(objID, true), new[] { price, int.MaxValue }); //add in support for wallpapers and carpets + i += 3; + if (i >= lineCount) + break; + } + + if (objType == "Ring" || objType == "ring") + { + objID = Convert.ToInt32(text[i]); + i += 2; + price = Convert.ToInt32(text[i]); + this.ListPrices.Add(new Ring(objID), new[] { price, int.MaxValue }); + i += 3; + if (i >= lineCount) + break; + } + + if (objType == "Lamp" || objType == "lamp" || objType == "Torch" || objType == "torch" || objType == "Craftable" || objType == "craftable" || objType == "BigCraftable" || objType == "bigcraftable") + { + objID = Convert.ToInt32(text[i]); + i += 2; + price = Convert.ToInt32(text[i]); + this.ListPrices.Add(new Torch(Vector2.Zero, objID, true), new[] { price, int.MaxValue }); + i += 3; + if (i >= lineCount) + break; + } + + if (objType == "Sword" || objType == "sword" || objType == "Weapon" || objType == "weapon") + { + objID = Convert.ToInt32(text[i]); + i += 2; + price = Convert.ToInt32(text[i]); + this.ListPrices.Add(new MeleeWeapon(objID), new[] { price, int.MaxValue }); + + i += 3; + if (i >= lineCount) + break; + } + + if (objType == "Hat" || objType == "hat" || objType == "Hats" || objType == "hats") + { + objID = Convert.ToInt32(text[i]); + i += 2; + price = Convert.ToInt32(text[i]); + this.ListPrices.Add(new Hat(objID), new[] { price, int.MaxValue }); + i += 3; + if (i >= lineCount) + break; + } + + //TODO: + //add in support for colored objects + //add in support for tools + Log.Success(i); + if (i >= lineCount) + break; + + objType = Convert.ToString(text[i]); + i += 2; + } + + //NEED TO TEST ALL DATA FILES TO SEE WHAT CAN AND CANT BE ADDED + //list.Add((Item)new StardewValley.Objects.ColoredObject(475,300, Color.Aqua)); + Game1.activeClickableMenu = new ShopMenu(this.ListPrices, 0, "Pierre"); + } + + //basic default of Pierre + //private void external_shop_file_call(string path, string fileName) + //{ + // List list = new List(); + + + // string mylocation = Path.Combine(path, fileName); + + // /// Log.Info(mylocation); + + + // string[] readtext = File.ReadAllLines(mylocation); + + // var lineCount = File.ReadLines(mylocation).Count(); + + + // // Log.Info(lineCount); + + // int i = 4; + + // int obj_id = 0; + // bool is_recipe; + // int price; + // int quality; + + // string obj_type; + + // obj_type = Convert.ToString(readtext[i]); + // i += 2; + + + + // while (i < lineCount) + // { + // if (i >= lineCount) break; + // if (obj_type == "") break; + // if (readtext[i] == "") break; + + // //read in a line for obj type here + // Log.Info(i); + // Log.Info(obj_type); + // if (obj_type == "item" || obj_type == "Item" || obj_type == "Object" || obj_type == "object") + // { + + // obj_id = Convert.ToInt16(readtext[i]); + // i += 2; + + // Log.Info(i); + // is_recipe = Convert.ToBoolean(readtext[i]); + // i += 2; + // Log.Info(i); + // price = Convert.ToInt32(readtext[i]); + // i += 2; + // Log.Info(i); + + // quality = Convert.ToInt32(readtext[i]); + // // if (quality > 2) quality = 0; + + + // if (price == -1) + // { + // StardewValley.Object myobj = new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality); + + // // Log.Info("MYPRICE"); + // // Log.Info(myobj.salePrice()); + // price = myobj.salePrice(); + + // } + + + // // list.Add((Item)new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality)); + // this.ListPrices.Add(new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + // if (obj_type == "Furniture" || obj_type == "furniture") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + + // // list.Add((Item)new Furniture(obj_id, Vector2.Zero)); //ADD FUNCTIONALITY TO SHOP FILES TO TEST IF FURNITURE OR NOT. + // this.ListPrices.Add(new Furniture(obj_id, Vector2.Zero), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + + // if (obj_type == "Boots" || obj_type == "boots" || obj_type == "shoe" || obj_type == "Shoe") //just incase someone forgets it's called boots and they type shoe. + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Boots(obj_id), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + + // } + + // if (obj_type == "WallPaper" || obj_type == "Wallpaper" || obj_type == "wallPaper" || obj_type == "wallpaper") //just incase someone forgets it's called boots and they type shoe. + // { + // if (i + 3 > lineCount) break; + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Wallpaper(obj_id, false), new[] { price, int.MaxValue }); //add in support for wallpapers and carpets + // i += 3; + // if (i >= lineCount) break; + + // } + + // if (obj_type == "Carpet" || obj_type == "carpet" || obj_type == "Floor" || obj_type == "floor" || obj_type == "Rug" || obj_type == "rug") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Wallpaper(obj_id, true), new[] { price, int.MaxValue }); //add in support for wallpapers and carpets + // i += 3; + // if (i >= lineCount) break; + // } + + // if (obj_type == "Ring" || obj_type == "ring") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Ring(obj_id), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + // if (obj_type == "Lamp" || obj_type == "lamp" || obj_type == "Torch" || obj_type == "torch" || obj_type == "Craftable" || obj_type == "craftable" || obj_type == "BigCraftable" || obj_type == "bigcraftable") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Torch(Vector2.Zero, obj_id, true), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + + // if (obj_type == "Sword" || obj_type == "sword" || obj_type == "Weapon" || obj_type == "weapon") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new MeleeWeapon(obj_id), new[] { price, int.MaxValue }); + + // i += 3; + // if (i >= lineCount) break; + // } + + // if (obj_type == "Hat" || obj_type == "hat" || obj_type == "Hats" || obj_type == "hats") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // // list_price.Add((Item)new Hat(obj_id), new[] { price, int.MaxValue }); + // this.ListPrices.Add(new Hat(obj_id), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + + + // //TODO: + // //add in support for colored objects + // //add in support for tools + // Log.Success(i); + // if (i >= lineCount) break; + // else + // { + // obj_type = Convert.ToString(readtext[i]); + // i += 2; + // } + // } + + + // //NEED TO TEST ALL DATA FILES TO SEE WHAT CAN AND CANT BE ADDED + // //list.Add((Item)new StardewValley.Objects.ColoredObject(475,300, Color.Aqua)); + // // Game1.activeClickableMenu = (IClickableMenu)new ShopMenu(list, 0, "Pierre"); + + // this.Menu = new ShopMenu(this.ListPrices, 0, "Pierre"); + // Game1.activeClickableMenu = this.Menu; + //} + + + //uses NPCS with new dialogue and portraits + //private void external_shop_file_call(string path, string fileName, string shopChat, NPC my_npc) + //{ + + // List list = new List(); + + + // string mylocation = Path.Combine(path, fileName); + + // /// Log.Info(mylocation); + + + // string[] readtext = File.ReadAllLines(mylocation); + + // var lineCount = File.ReadLines(mylocation).Count(); + + + // // Log.Info(lineCount); + + // int i = 4; + + // int obj_id = 0; + // bool is_recipe; + // int price; + // int quality; + + // string obj_type; + + // obj_type = Convert.ToString(readtext[i]); + // i += 2; + + + + // while (i < lineCount) + // { + // if (i >= lineCount) break; + // if (obj_type == "") break; + // if (readtext[i] == "") break; + + // //read in a line for obj type here + // Log.Info(i); + // Log.Info(obj_type); + // if (obj_type == "item" || obj_type == "Item" || obj_type == "Object" || obj_type == "object") + // { + + // obj_id = Convert.ToInt16(readtext[i]); + // i += 2; + + // Log.Info(i); + // is_recipe = Convert.ToBoolean(readtext[i]); + // i += 2; + // Log.Info(i); + // price = Convert.ToInt32(readtext[i]); + // i += 2; + // Log.Info(i); + + // quality = Convert.ToInt32(readtext[i]); + // // if (quality > 2) quality = 0; + + + // if (price == -1) + // { + // StardewValley.Object myobj = new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality); + + // // Log.Info("MYPRICE"); + // // Log.Info(myobj.salePrice()); + // price = myobj.salePrice(); + + // } + + + // // list.Add((Item)new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality)); + // this.ListPrices.Add(new StardewValley.Object(obj_id, int.MaxValue, is_recipe, price, quality), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + // if (obj_type == "Furniture" || obj_type == "furniture") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + + // // list.Add((Item)new Furniture(obj_id, Vector2.Zero)); //ADD FUNCTIONALITY TO SHOP FILES TO TEST IF FURNITURE OR NOT. + // this.ListPrices.Add(new Furniture(obj_id, Vector2.Zero), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + + + + + // } + + // if (obj_type == "Boots" || obj_type == "boots" || obj_type == "shoe" || obj_type == "Shoe") //just incase someone forgets it's called boots and they type shoe. + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Boots(obj_id), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + + // } + + // if (obj_type == "WallPaper" || obj_type == "Wallpaper" || obj_type == "wallPaper" || obj_type == "wallpaper") //just incase someone forgets it's called boots and they type shoe. + // { + // if (i + 3 > lineCount) break; + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Wallpaper(obj_id, false), new[] { price, int.MaxValue }); //add in support for wallpapers and carpets + // i += 3; + // if (i >= lineCount) break; + + // } + + // if (obj_type == "Carpet" || obj_type == "carpet" || obj_type == "Floor" || obj_type == "floor" || obj_type == "Rug" || obj_type == "rug") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Wallpaper(obj_id, true), new[] { price, int.MaxValue }); //add in support for wallpapers and carpets + // i += 3; + // if (i >= lineCount) break; + // } + + // if (obj_type == "Ring" || obj_type == "ring") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Ring(obj_id), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + // if (obj_type == "Lamp" || obj_type == "lamp" || obj_type == "Torch" || obj_type == "torch" || obj_type == "Craftable" || obj_type == "craftable" || obj_type == "BigCraftable" || obj_type == "bigcraftable") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new Torch(Vector2.Zero, obj_id, true), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + + // if (obj_type == "Sword" || obj_type == "sword" || obj_type == "Weapon" || obj_type == "weapon") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // this.ListPrices.Add(new MeleeWeapon(obj_id), new[] { price, int.MaxValue }); + + // i += 3; + // if (i >= lineCount) break; + // } + + // if (obj_type == "Hat" || obj_type == "hat" || obj_type == "Hats" || obj_type == "hats") + // { + // obj_id = Convert.ToInt32(readtext[i]); + // i += 2; + // price = Convert.ToInt32(readtext[i]); + // // list_price.Add((Item)new Hat(obj_id), new[] { price, int.MaxValue }); + // this.ListPrices.Add(new Hat(obj_id), new[] { price, int.MaxValue }); + // i += 3; + // if (i >= lineCount) break; + // } + + + // //TODO: + // //add in support for colored objects + // //add in support for tools + // Log.Success(i); + // if (i >= lineCount) break; + // else + // { + // obj_type = Convert.ToString(readtext[i]); + // i += 2; + // } + // } + + + // //NEED TO TEST ALL DATA FILES TO SEE WHAT CAN AND CANT BE ADDED + // //list.Add((Item)new StardewValley.Objects.ColoredObject(475,300, Color.Aqua)); + // // Game1.activeClickableMenu = (IClickableMenu)new ShopMenu(list, 0, "Pierre"); + + // this.Menu = new ShopMenu(this.ListPrices, 0, my_npc.name) + // { + // potraitPersonDialogue = Game1.parseText(shopChat, Game1.dialogueFont, Game1.tileSize * 5 - Game1.pixelZoom * 4), + // portraitPerson = my_npc + // }; + // Game1.activeClickableMenu = this.Menu; + //} + + //example of a shop that I don't use. + //private List MyShop() + //{ + // List list = new List(); + // list.Add(new StardewValley.Object(478, int.MaxValue, false, -1, 0)); //int parentsheet index OR object_ID/int.MaxValue, bool is recipe, price, quality + // list.Add(new StardewValley.Object(486, int.MaxValue, false, -1, 0)); + // list.Add(new StardewValley.Object(494, int.MaxValue, false, -1, 0)); //Might be able to manipulate this code to give me recipes!!!! + // list.Add(new StardewValley.Object(495, int.MaxValue, false, 800, 0)); //price is *2 of value shown. -1 means inherit default value + // switch (Game1.dayOfMonth % 7) + // { + // case 0: + // list.Add(new StardewValley.Object(233, int.MaxValue, false, -1, 0)); + // break; + // case 1: + // list.Add(new StardewValley.Object(88, int.MaxValue, false, -1, 0)); + // break; + // case 2: + // list.Add(new StardewValley.Object(90, int.MaxValue, false, -1, 0)); + // break; + // case 3: + // list.Add(new StardewValley.Object(749, int.MaxValue, false, 500, 0)); + // break; + // case 4: + // list.Add(new StardewValley.Object(466, int.MaxValue, false, -1, 0)); + // break; + // case 5: + // list.Add(new StardewValley.Object(340, int.MaxValue, false, -1, 0)); + // break; + // case 6: + // list.Add(new StardewValley.Object(371, int.MaxValue, false, 100, 0)); + // break; + // } + // return list; + //} + } +} diff --git a/GeneralMods/CustomShopsRedux/CustomShopsRedux.csproj b/GeneralMods/CustomShopsRedux/CustomShopsRedux.csproj index 34facdb9..0c6e63ed 100644 --- a/GeneralMods/CustomShopsRedux/CustomShopsRedux.csproj +++ b/GeneralMods/CustomShopsRedux/CustomShopsRedux.csproj @@ -34,20 +34,27 @@ - + + Properties\GlobalAssemblyInfo.cs + + - - - - - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + - + diff --git a/GeneralMods/CustomShopsRedux/Custom_Shop_Redux_Config.txt b/GeneralMods/CustomShopsRedux/Custom_Shop_Redux_Config.txt deleted file mode 100644 index b2071dd4..00000000 --- a/GeneralMods/CustomShopsRedux/Custom_Shop_Redux_Config.txt +++ /dev/null @@ -1,20 +0,0 @@ -Config: Custom_Shop_Redux. Feel free to mess with these settings. -==================================================================================== -Key binding for saving anywhere. Press this key to save anywhere! -U - - - - - - - - - - - - - - - - diff --git a/GeneralMods/CustomShopsRedux/Mod_readme.txt b/GeneralMods/CustomShopsRedux/Mod_readme.txt deleted file mode 100644 index 6213c689..00000000 --- a/GeneralMods/CustomShopsRedux/Mod_readme.txt +++ /dev/null @@ -1,14 +0,0 @@ -This is the custom shop mod! - -Basically making a custom shop is as simple as following the formatting in the pre-existsing custom_shops in a new text file. - -If you ever wish to call the mod without the menu in your own mod, simply call shop_file_call("myfilename.txt") in your Stardew Valley Mod. -(Make sure you add a reference to this mod.) - -The full call would look something like. - -Custom_Shop_Mod_Redux.Class1.shop_file_call("file.txt"); - -Where file.txt is the name of the shop info you wish to open. - -Make sure the formatting is correct otherwise you will get errors! \ No newline at end of file diff --git a/GeneralMods/CustomShopsRedux/Properties/AssemblyInfo.cs b/GeneralMods/CustomShopsRedux/Properties/AssemblyInfo.cs index 0339063d..78e6b138 100644 --- a/GeneralMods/CustomShopsRedux/Properties/AssemblyInfo.cs +++ b/GeneralMods/CustomShopsRedux/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("CustomShopsRedux")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("CustomShopsRedux")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("29f7de68-4c76-471e-86fb-873794802adc")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/CustomShopsRedux/ReadMe.md b/GeneralMods/CustomShopsRedux/ReadMe.md index 6e0aa0f5..09c9b129 100644 --- a/GeneralMods/CustomShopsRedux/ReadMe.md +++ b/GeneralMods/CustomShopsRedux/ReadMe.md @@ -1,80 +1,59 @@ -Custom_Shop_Mod_Redux_GUI v 1.2.0 +**Custom Shop Redux GUI** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you +create custom shops by editing text files. -For SDV 1.0.7 and SMAPI v0.40 +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. -Posted at 9:15 PM PST 5/8/16 +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install this mod from Nexus mods (not yet released). +3. Run the game using SMAPI. --Updated to be able to be called from other mods for NPC shop binding and soforth. +## Usage +Make a custom shop by copying & editing one of the included custom shop templates, or use the +[Custom Shops Creation Tool](https://myscccd-my.sharepoint.com/personal/0703280_my_scccd_edu/_layouts/15/guestaccess.aspx?guestaccesstoken=ZYxG9Cs8S0q%2bxCVV3fEnc8MI4SfVfe07919rhFUhRiA%3d&docid=0e51dae1da2eb43988f77f5c54ec3ee58) +(see [demo video](https://youtu.be/bSvNTZmgeZE)). --Fixed a bug where pressing the U key on the main menu causes the game to crash. +You can access the custom shops by pressing `U` in-game (configurable via `Custom_Shop_Redux_Config.txt`). -Good evening everyone. At this point I don't even know how I'm creating mods so quickly, but I think I'll strike while the iron is hot. Here is my third release of the day, the Custom Shops Mod Redux! +Supported item types: -The custom_shop_mod_redux is a second, much better attempt at adding custom shops into StardewValley! - -***Not to be confused with the custom_shop_mod which was it's predecessor and was based around the SMAPI console. - -Basically making a custom shop is as simple as following the formatting in the pre-existsing custom_shops in a new text file. (Or by using the super useful Custom Shop Creation Tool) - -You can access these custom shops by pressing a key. (The U key by default, which is configurable in the config file) - -I recommend that you use the Custom Shop Creation Tool that I created for everyone to create your custom shops. The link is down below. Took me a little bit of time to put together, but it works. - -Watch the new video to understand how it works. - -Have fun with this one! I hope to see all of the custom shops that you all put out! - -==================================================== -If you wish to call this mod in your own mod without the menu the code would be - -Custom_Shop_Mod_Redux.Class1.external_shop_file_call(path, filename); - -Where path is the directory path of the desired text file, and filename is the name of the file inside of the path directory. - -*Note that path will not include the file itself. The code will take care of that for you. - -This would be useful if you want a custom NPC to have a shop but you don't want to have to code in the shop yourself. -========================================================= -Some goals of mine with this mod: - -1. Get as many different types of items available for selling. (finished) - -2.Create a nice gui interface in Unity for creating custom shops so that modders don't have to deal with my icky formatting rules. The GUI will take care of that for modders. (finished) - -3.Make my code compatible with other mods for modders, so that they can call my shop_command_code and be able to open up a shop from text file with just path information, and file names. (This is next) - -4. Document the mod for future user use. -========================================================== -Types of Items this mod supports in shops. -1.Items (like normal inventory items) - -2.Furniture- (windows, tables, chairs, etc) - -3.swords- Swish, swish. - -4.Hats -Got to look cool - -5.Boots - Lace up for adventure. - -6.Wallpapers - Make your house look nice. - -7.Carpets/Flooring - Like animal crossing. - -8.Rings - As long as they aren't evil. - -9.Lamps - Light up the world. - -10.craftables* =*note that there was some....issues adding in craftable objects. They all act like torches when you interact with them. It's kind of hilarious and I don't think I'll change it anytime soon. You can still have objects like the furnace function like normal, by right clicking it with copper. In order to get the smelted copper bar however, you would have to destroy it, as would go for all machines that behave this way. Sorry. On the plus side your scarecrows can be on fire forever. +* inventory items; +* furniture (windows, tables, chairs, etc); +* swords (swish, swish); +* gats (got to look cool); +* boots (lace up for adventure); +* wallpapers (make your house look nice); +* carpets & flooring (like Animal Crossing); +* rings (as long as they aren't evil); +* lamps (light up the world); +* craftables (note that there are some... issues with craftables. They all act like torches when + you interact with them. It's kind of hilarious and I don't think I'll change it anytime soon. You + can still have objects like the furnace function like normal, by right-clicking it with copper. + In order to get the smelted copper bar however, you would have to destroy it, as would go for all + machines that behave this way. Sorry. On the plus side your scarecrows can be on fire forever.) -Link: -Get it Here! -Link for the Custom Shops Creation Tool.: -https://myscccd-my.sharepoint.com/personal/0703280_my_scccd_edu/_layouts/15/guestaccess.aspx?guestaccesstoken=ZYxG9Cs8S0q%2bxCVV3fEnc8MI4SfVfe07919rhFUhRiA%3d&docid=0e51dae1da2eb43988f77f5c54ec3ee58 +## Goals +* [x] Get as many different types of items available for selling. +* [x] Create a nice GUI for creating custom shops so that modders don't have to deal with my icky + formatting rules. The GUI will take care of that for modders. +* [x] Make my code compatible with other mods for modders, so that they can call my + shop_command_code and be able to open up a shop from text file with just path information, + and file names. -Also here is a video demonstrating how this mod works. +## Versions +1.0: +* Initial release. -https://youtu.be/bSvNTZmgeZE +1.0.1: +* Corrected price display to reflect markup. +1.0.2: +* Fixed issues where unintended items were bought. + +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. +* Fixed mouse not appearing in menu. +* Fixed bug where you sometimes couldn't buy an item even if you had enough money. \ No newline at end of file diff --git a/GeneralMods/CustomShopsRedux/manifest.json b/GeneralMods/CustomShopsRedux/manifest.json index 6b75feeb..2d8a6d2a 100644 --- a/GeneralMods/CustomShopsRedux/manifest.json +++ b/GeneralMods/CustomShopsRedux/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "4be88c18-b6f3-49b0-ba96-f94b1a5be890", "PerSaveConfigs": false, "EntryDll": "CustomShopsRedux.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/DailyQuestAnywhere/Class1.cs b/GeneralMods/DailyQuestAnywhere/Class1.cs deleted file mode 100644 index 4eac1113..00000000 --- a/GeneralMods/DailyQuestAnywhere/Class1.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.IO; -using StardewModdingAPI; -using StardewValley; - -/* -TO DO: - -*/ -namespace Omegasis.DailyQuestAnywhere -{ - public class Class1 : Mod - { - string key_binding = "H"; - - bool game_loaded = false; - - public override void Entry(IModHelper helper) - { - //set up all of my events here - StardewModdingAPI.Events.SaveEvents.AfterLoad += PlayerEvents_LoadedGame; - StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; - } - - - - public void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) - { - if (Game1.player == null) return; - if (Game1.player.currentLocation == null) return; - if (game_loaded == false) return; - - if (e.KeyPressed.ToString() == key_binding) //if the key is pressed, load my cusom save function - { - if (Game1.activeClickableMenu != null) return; - my_menu(); - } - //DataLoader_Settings(); //update the key if players changed it while playing. - } - - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - game_loaded = true; - DataLoader_Settings(); - MyWritter_Settings(); - } - - - - - void DataLoader_Settings() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "DailyQuest_Anywhere_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - // Console.WriteLine("Can't load custom save info since the file doesn't exist."); - - key_binding = "H"; - // Log.Info("KEY TIME"); - } - - else - { - // Console.WriteLine("HEY THERE IM LOADING DATA"); - string[] readtext = File.ReadAllLines(mylocation3); - key_binding = Convert.ToString(readtext[3]); - - - // Log.Info(key_binding); - // Log.Info(Convert.ToString(readtext[3])); - - } - } - - void MyWritter_Settings() - { - - //write all of my info to a text file. - string myname = StardewValley.Game1.player.name; - - string mylocation = Path.Combine(Helper.DirectoryPath, "DailyQuest_Anywhere_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("DailyQuest_Anywhere: The DailyQuest Anywhere Config doesn't exist. Creating it now."); - - mystring3[0] = "Config: DailyQuest_Anywhere Info. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Key binding for opening the billboard for quests anywhere. Press this key to do so"; - mystring3[3] = key_binding.ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - - } - - else - { - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Config: DailyQuest_Anywhere Info. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Key binding for opening the billboard for quests anywhere. Press this key to do so"; - mystring3[3] = key_binding.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - } - - - - - void my_menu() - { - - // Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); //This command is what allows the player to save anywhere as it calls the saving function. - - - Game1.activeClickableMenu = new StardewValley.Menus.Billboard(true); - } - - } -} -//end class \ No newline at end of file diff --git a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs new file mode 100644 index 00000000..a0ffc204 --- /dev/null +++ b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs @@ -0,0 +1,87 @@ +using System; +using System.IO; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; +using StardewValley.Menus; + +namespace Omegasis.DailyQuestAnywhere +{ + /// The mod entry point. + public class DailyQuestAnywhere : Mod + { + /********* + ** Properties + *********/ + /// The key which shows the menu. + private string KeyBinding = "H"; + + /// Whether the player loaded a save. + private bool IsGameLoaded; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + } + + + /********* + ** Private methods + *********/ + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + this.IsGameLoaded = true; + this.LoadConfig(); + this.WriteConfig(); + } + + /// The method invoked when the presses a keyboard button. + /// The event sender. + /// The event data. + private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + { + if (Game1.player == null || Game1.player.currentLocation == null || this.IsGameLoaded == false || Game1.activeClickableMenu != null) + return; + + if (e.KeyPressed.ToString() == this.KeyBinding) + Game1.activeClickableMenu = new Billboard(true); + } + + /// Load the configuration settings. + void LoadConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "DailyQuest_Anywhere_Config.txt"); + if (!File.Exists(path)) + this.KeyBinding = "H"; + else + { + string[] text = File.ReadAllLines(path); + this.KeyBinding = Convert.ToString(text[3]); + } + } + + /// Save the configuration settings. + void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "DailyQuest_Anywhere_Config.txt"); + string[] text = new string[20]; + text[0] = "Config: DailyQuest_Anywhere Info. Feel free to mess with these settings."; + text[1] = "===================================================================================="; + + text[2] = "Key binding for opening the billboard for quests anywhere. Press this key to do so"; + text[3] = this.KeyBinding; + + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj index e672453e..65963a04 100644 --- a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj +++ b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj @@ -34,7 +34,10 @@ - + + Properties\GlobalAssemblyInfo.cs + + @@ -42,7 +45,7 @@ - + diff --git a/GeneralMods/DailyQuestAnywhere/Properties/AssemblyInfo.cs b/GeneralMods/DailyQuestAnywhere/Properties/AssemblyInfo.cs index 2c5101a0..4b026daf 100644 --- a/GeneralMods/DailyQuestAnywhere/Properties/AssemblyInfo.cs +++ b/GeneralMods/DailyQuestAnywhere/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("DailyQuest Anywhere")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("DailyQuest Anywhere")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: AssemblyTitle("DailyQuestAnywhere")] [assembly: Guid("ac4b84f5-31e4-4a55-b13f-a5189c552343")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/DailyQuestAnywhere/README.md b/GeneralMods/DailyQuestAnywhere/README.md new file mode 100644 index 00000000..c719b2f8 --- /dev/null +++ b/GeneralMods/DailyQuestAnywhere/README.md @@ -0,0 +1,19 @@ +**Daily Quest Anywhere** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you open +the daily quest menu from anywhere in-game. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/513). +3. Run the game using SMAPI. + +## Usage +Press `H` to open the daily quest menu. Edit `DailyQuest_Anywhere_Config.txt` to change the key. + +## Versions +1.0: +* Initial release. + +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. diff --git a/GeneralMods/DailyQuestAnywhere/ReadMe.txt b/GeneralMods/DailyQuestAnywhere/ReadMe.txt deleted file mode 100644 index db5cdd2d..00000000 --- a/GeneralMods/DailyQuestAnywhere/ReadMe.txt +++ /dev/null @@ -1,25 +0,0 @@ -DailyQuest_Anywhere - -Version:1.1.0 - -Published: 8/14/16 12:50 PM - -Updated: 10/14/16 12:27 AM - -Compatability: - -Stardew Valley 1.1.0 Windows - -SMAPI 0.40.0 1.1-3 - -Description: - -A simple mod that allows you to open the daily quest menu from anywhere. - -Usage: Press H to open up the buy back menu. - -Update Info: -1.1.0 --Updated to SDV 1.1 -1.0.0 --Initial Release diff --git a/GeneralMods/DailyQuestAnywhere/manifest.json b/GeneralMods/DailyQuestAnywhere/manifest.json index 7d1f4afd..6c08cff4 100644 --- a/GeneralMods/DailyQuestAnywhere/manifest.json +++ b/GeneralMods/DailyQuestAnywhere/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "DailyQuest", "PerSaveConfigs": false, "EntryDll": "DailyQuestAnywhere.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/Fall28SnowDay/Class1.cs b/GeneralMods/Fall28SnowDay/Class1.cs deleted file mode 100644 index d736404e..00000000 --- a/GeneralMods/Fall28SnowDay/Class1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.Fall28SnowDay -{ - public class Class1:Mod - { - public override void Entry(IModHelper helper) - { - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged; - } - - public void TimeEvents_DayOfMonthChanged(object sender, StardewModdingAPI.Events.EventArgsIntChanged e) - { - if (StardewValley.Game1.dayOfMonth == 27 && Game1.IsFall == true) - { - // Log.Success("Weather checker now!!!"); - Game1.weatherForTomorrow = Game1.weather_snow; - } - } - } -} diff --git a/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs b/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs new file mode 100644 index 00000000..71a66016 --- /dev/null +++ b/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs @@ -0,0 +1,33 @@ +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +namespace Omegasis.Fall28SnowDay +{ + /// The mod entry point. + public class Fall28SnowDay : Mod + { + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + } + + + /********* + ** Private methods + *********/ + /// The method invoked when changes. + /// The event sender. + /// The event data. + public void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e) + { + if (Game1.dayOfMonth == 27 && Game1.IsFall) + Game1.weatherForTomorrow = Game1.weather_snow; + } + } +} diff --git a/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj b/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj index 7a7763b6..94da970f 100644 --- a/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj +++ b/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj @@ -34,7 +34,10 @@ - + + Properties\GlobalAssemblyInfo.cs + + @@ -42,7 +45,7 @@ - + diff --git a/GeneralMods/Fall28SnowDay/Properties/AssemblyInfo.cs b/GeneralMods/Fall28SnowDay/Properties/AssemblyInfo.cs index 7dc4e1d4..ff8922ac 100644 --- a/GeneralMods/Fall28SnowDay/Properties/AssemblyInfo.cs +++ b/GeneralMods/Fall28SnowDay/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("Fall28SnowDay")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Fall28SnowDay")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("1dbb583d-4a4f-4a46-8cc5-42017c93d292")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/Fall28SnowDay/README.md b/GeneralMods/Fall28SnowDay/README.md new file mode 100644 index 00000000..7fa8c3b9 --- /dev/null +++ b/GeneralMods/Fall28SnowDay/README.md @@ -0,0 +1,19 @@ +**Daily Quest Anywhere** is a [Stardew Valley](http://stardewvalley.net/) mod which makes snow fall +on the last day of fall, which would explain why the town is covered in snow on the next day. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/486). +3. Run the game using SMAPI. + +## Usage +It automatically snows on fall 28. + +## Versions +1.0: +* Initial release. + +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. diff --git a/GeneralMods/Fall28SnowDay/Readme.txt b/GeneralMods/Fall28SnowDay/Readme.txt deleted file mode 100644 index f5c910c9..00000000 --- a/GeneralMods/Fall28SnowDay/Readme.txt +++ /dev/null @@ -1,20 +0,0 @@ -Fall 28 Snow Day 1.1.0 - -Posted on 7/9/16 -Updated 10/21/16 12:26 AM - -Compatability: -SDV 1.1 -SMAPI 0.40.0 1.1-3 -Windows - -Descritption: - --Just a small mod that makes it snow on Fall 28th, which would explain why the town is covered in snow come the 1st of Winter. - -Updates: -1.1.0 --Updated to SDV 1.1 - -1.0.0 --Initial release. \ No newline at end of file diff --git a/GeneralMods/Fall28SnowDay/manifest.json b/GeneralMods/Fall28SnowDay/manifest.json index 651016ab..31ee6b47 100644 --- a/GeneralMods/Fall28SnowDay/manifest.json +++ b/GeneralMods/Fall28SnowDay/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "Fall28 Snow Day", "PerSaveConfigs": false, "EntryDll": "Fall28SnowDay.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/GlobalAssemblyInfo.cs b/GeneralMods/GlobalAssemblyInfo.cs new file mode 100644 index 00000000..5c97d967 --- /dev/null +++ b/GeneralMods/GlobalAssemblyInfo.cs @@ -0,0 +1,11 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] diff --git a/GeneralMods/HappyBirthday/Birthday_Menu.cs b/GeneralMods/HappyBirthday/Birthday_Menu.cs deleted file mode 100644 index 9d84354a..00000000 --- a/GeneralMods/HappyBirthday/Birthday_Menu.cs +++ /dev/null @@ -1,436 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using StardewValley; -using StardewValley.Menus; -using StardewValley.Minigames; - -namespace Omegasis.HappyBirthday -{ - public class Birthday_Menu : IClickableMenu - { - public const int colorPickerTimerDelay = 100; - - public List shirtOptions; - - public List hairStyleOptions; - - public List accessoryOptions; - - public int currentShirt; - - public int currentHair; - - public int currentAccessory; - - public int colorPickerTimer; - - public ColorPicker pantsColorPicker; - - public ColorPicker hairColorPicker; - - public ColorPicker eyeColorPicker; - - public List labels = new List(); - - - public List seasonButtons = new List(); - - public List seasonTitleButtons = new List(); - - public ClickableTextureComponent okButton; - - public ClickableTextureComponent skipIntroButton; - - // public ClickableTextureComponent randomButton; - - public TextBox nameBox; - - public TextBox farmnameBox; - - public TextBox favThingBox; - - public bool skipIntro; - - public bool wizardSource; - - public ColorPicker lastHeldColorPicker; - - public int timesRandom; - - public Birthday_Menu(bool wizardSource = false) : base(Game1.viewport.Width / 2 - (632 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2 - Game1.tileSize, 632 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2 + Game1.tileSize, false) - { - - this.wizardSource = wizardSource; - this.setUpPositions(); - Game1.player.faceDirection(2); - Game1.player.FarmerSprite.StopAnimation(); - } - - public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) - { - base.gameWindowSizeChanged(oldBounds, newBounds); - this.xPositionOnScreen = Game1.viewport.Width / 2 - (632 + IClickableMenu.borderWidth * 2) / 2; - this.yPositionOnScreen = Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2 - Game1.tileSize; - this.setUpPositions(); - } - - public virtual void setUpPositions() - { - this.labels.Clear(); - this.seasonButtons.Clear(); - this.okButton = new ClickableTextureComponent("OK", new Rectangle(this.xPositionOnScreen + this.width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize, this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 4, Game1.tileSize, Game1.tileSize), "", null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false); - - - - // this.randomButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.pixelZoom * 12, this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 14, Game1.pixelZoom * 10, Game1.pixelZoom * 10), "", "", Game1.mouseCursors, new Rectangle(381, 361, 10, 10), (float)Game1.pixelZoom); - int num = Game1.tileSize * 2; - //new ClickableComponent(new Rectangle(x2, y, Game1.tileSize * 3 / 4 - 4, Game1.tileSize * 3 / 4 - 4), string.Concat((object) (index * 5))) //allows you to make numbers into buttons: Taken from elevator menu - this.labels.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 + 8, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 8, 1, 1),"Birthday Season: "+ HappyBirthday.Class1.player_birthday_season)); - this.labels.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 + 8, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize, Game1.tileSize * 2, Game1.tileSize), "Birthday Date: " + HappyBirthday.Class1.player_birthday_date)); - this.seasonTitleButtons.Add(new ClickableTextureComponent("Spring", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 1 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + (int)(Game1.tileSize * 3.10) - Game1.tileSize / 4, Game1.tileSize*2, Game1.tileSize), "", "", Game1.mouseCursors, new Rectangle(188, 438, 32, 9), (float)Game1.pixelZoom, false)); - this.seasonTitleButtons.Add(new ClickableTextureComponent("Summer", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + (int)(Game1.tileSize * 3.10) - Game1.tileSize / 4, Game1.tileSize*2, Game1.tileSize), "", "", Game1.mouseCursors, new Rectangle(220, 438, 32, 8), (float)Game1.pixelZoom, false)); - this.seasonTitleButtons.Add(new ClickableTextureComponent("Fall", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + (int)(Game1.tileSize * 3.1) - Game1.tileSize / 4, Game1.tileSize*2, Game1.tileSize), "", "", Game1.mouseCursors, new Rectangle(188, 447, 32, 10), (float)Game1.pixelZoom, false)); - this.seasonTitleButtons.Add(new ClickableTextureComponent("Winter", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 7 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + (int)(Game1.tileSize * 3.1) - Game1.tileSize / 4, Game1.tileSize*2, Game1.tileSize), "", "", Game1.mouseCursors, new Rectangle(220, 448, 32, 8), (float)Game1.pixelZoom, false)); - - - this.seasonButtons.Add(new ClickableTextureComponent("1", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 1 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("2",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 2 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false )); - this.seasonButtons.Add(new ClickableTextureComponent("3",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(24, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("4",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 4 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(32, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("5",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(40, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("6",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 6 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(48, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("7",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 7 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(56, 16, 8, 12), (float)Game1.pixelZoom, false)); - - this.seasonButtons.Add(new ClickableTextureComponent("8",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 1 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(64, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("9",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 2 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(72, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("10",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize *2.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize /2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("10",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize/2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(0, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("11",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("11",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("12",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("12",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("13",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("13",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(24, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("14",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("14",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 7.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(32, 16, 8, 12), (float)Game1.pixelZoom, false)); - // this.seasonButtons.Add(new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 4 - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "11", "11", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(32, 16, 8, 12), (float)Game1.pixelZoom, false, false)); - - - this.seasonButtons.Add(new ClickableTextureComponent("15",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 0.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("15",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 1.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(40, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("16",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 1.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("16",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(48, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("17",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("17",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(56, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("18",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("18",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(64, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("19",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("19",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(72, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("20",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("20",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(0, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("21",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("21",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 7.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), (float)Game1.pixelZoom, false)); - - - this.seasonButtons.Add(new ClickableTextureComponent("22",new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 0.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("22", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 1.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("23", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 1.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("23", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(24, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("24", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("24", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(32, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("25", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("25", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(40, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("26", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("26", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(48, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("27", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("27", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(56, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("28", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), (float)Game1.pixelZoom, false)); - this.seasonButtons.Add(new ClickableTextureComponent("28", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 7.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(64, 16, 8, 12), (float)Game1.pixelZoom, false)); - num = Game1.tileSize * 4 + 8; - - } - - public virtual void optionButtonClick(string name) - { - if (name != null) - { - if (name == "Spring") - { - HappyBirthday.Class1.player_birthday_season = "spring"; - Game1.activeClickableMenu = new Birthday_Menu(); - } - else if (name == "Summer") - { - HappyBirthday.Class1.player_birthday_season = "summer"; - Game1.activeClickableMenu = new Birthday_Menu(); - } - else if (name == "Fall") - { - HappyBirthday.Class1.player_birthday_season = "fall"; - Game1.activeClickableMenu = new Birthday_Menu(); - } - else if (name == "Winter") - { - HappyBirthday.Class1.player_birthday_season = "winter"; - Game1.activeClickableMenu = new Birthday_Menu(); - } - - - else if (name == "OK" && (HappyBirthday.Class1.player_birthday_date >= 1 || HappyBirthday.Class1.player_birthday_date <= 28)) - { - - if (!this.canLeaveMenu()) - { - return; - } - //Game1.player.Name = this.nameBox.Text.Trim(); - // Game1.player.favoriteThing = this.favThingBox.Text.Trim(); - if (Game1.activeClickableMenu is TitleMenu) - { - // (Game1.activeClickableMenu as TitleMenu).createdNewCharacter(this.skipIntro); - } - else - { - Game1.exitActiveMenu(); - if (Game1.currentMinigame != null && Game1.currentMinigame is Intro) - { - (Game1.currentMinigame as Intro).doneCreatingCharacter(); - } - else if (this.wizardSource) - { - Game1.flashAlpha = 1f; - Game1.playSound("yoba"); - } - } - } - else - { - HappyBirthday.Class1.player_birthday_date = Convert.ToInt32(name); - Game1.activeClickableMenu = new Birthday_Menu(); - } - - } - Game1.playSound("coin"); - } - - public virtual void selectionClick(string name, int change) - { - if (name != null) - { - Game1.player.faceDirection((Game1.player.facingDirection - change + 4) % 4); - Game1.player.FarmerSprite.StopAnimation(); - Game1.player.completelyStopAnimatingOrDoingAction(); - Game1.playSound("pickUpItem"); - } - } - - public override void receiveLeftClick(int x, int y, bool playSound = true) - { - - foreach (ClickableComponent current2 in this.seasonButtons) - { - if (current2.containsPoint(x, y)) - { - this.optionButtonClick(current2.name); - current2.scale -= 0.5f; - current2.scale = Math.Max(3.5f, current2.scale); - } - } - foreach (ClickableComponent current2 in this.seasonTitleButtons) - { - if (current2.containsPoint(x, y)) - { - this.optionButtonClick(current2.name); - current2.scale -= 0.5f; - current2.scale = Math.Max(3.5f, current2.scale); - } - } - - if (this.okButton.containsPoint(x, y) && this.canLeaveMenu()) - { - this.optionButtonClick(this.okButton.name); - this.okButton.scale -= 0.25f; - this.okButton.scale = Math.Max(0.75f, this.okButton.scale); - } - - if (!this.wizardSource) - { - } - - - } - - public override void leftClickHeld(int x, int y) - { - - } - - public override void releaseLeftClick(int x, int y) - { - - } - - public override void receiveRightClick(int x, int y, bool playSound = true) - { - } - - public override void receiveKeyPress(Keys key) - { - - } - - public override void performHoverAction(int x, int y) - { - - - if (!this.wizardSource) - { - - using (List.Enumerator enumerator4 = this.seasonButtons.GetEnumerator()) - { - while (enumerator4.MoveNext()) - { - ClickableTextureComponent clickableTextureComponent4 = (ClickableTextureComponent)enumerator4.Current; - if (clickableTextureComponent4.containsPoint(x, y)) - { - clickableTextureComponent4.scale = Math.Min(clickableTextureComponent4.scale + 0.02f, clickableTextureComponent4.baseScale + 0.1f); - } - else - { - clickableTextureComponent4.scale = Math.Max(clickableTextureComponent4.scale - 0.02f, clickableTextureComponent4.baseScale); - } - } - } - - using (List.Enumerator enumerator4 = this.seasonTitleButtons.GetEnumerator()) - { - while (enumerator4.MoveNext()) - { - ClickableTextureComponent clickableTextureComponent4 = (ClickableTextureComponent)enumerator4.Current; - if (clickableTextureComponent4.containsPoint(x, y)) - { - clickableTextureComponent4.scale = Math.Min(clickableTextureComponent4.scale + 0.02f, clickableTextureComponent4.baseScale + 0.1f); - } - else - { - clickableTextureComponent4.scale = Math.Max(clickableTextureComponent4.scale - 0.02f, clickableTextureComponent4.baseScale); - } - } - } - } - if (this.okButton.containsPoint(x, y) && this.canLeaveMenu()) - { - this.okButton.scale = Math.Min(this.okButton.scale + 0.02f, this.okButton.baseScale + 0.1f); - } - else - { - this.okButton.scale = Math.Max(this.okButton.scale - 0.02f, this.okButton.baseScale); - } - - } - - public virtual bool canLeaveMenu() - { - return this.wizardSource || (Game1.player.name.Length > 0 && Game1.player.farmName.Length > 0 && Game1.player.favoriteThing.Length > 0); - } - - public override void draw(SpriteBatch b) - { - Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true, (string)null, false); - b.Draw(Game1.daybg, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize + Game1.tileSize * 2 / 3 - 2), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 4)), Color.White); - Game1.player.FarmerRenderer.draw(b, Game1.player.FarmerSprite.CurrentAnimationFrame, Game1.player.FarmerSprite.CurrentFrame, Game1.player.FarmerSprite.SourceRect, new Vector2((float)(this.xPositionOnScreen - 2 + Game1.tileSize * 2 / 3 + Game1.tileSize * 2 - Game1.tileSize / 2), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth - Game1.tileSize / 4 + IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 2)), Vector2.Zero, 0.8f, Color.White, 0.0f, 1f, Game1.player); - if (!this.wizardSource) - { - - if(HappyBirthday.Class1.player_birthday_season=="spring" || HappyBirthday.Class1.player_birthday_season == "summer" || HappyBirthday.Class1.player_birthday_season == "fall" || HappyBirthday.Class1.player_birthday_season == "winter"){ - foreach (ClickableTextureComponent textureComponent in this.seasonButtons) - { - textureComponent.draw(b); - // b.Draw(Game1.mouseCursors, textureComponent.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 34, -1, -1)), Color.White); - } - } - foreach (ClickableTextureComponent textureComponent in this.seasonTitleButtons) - { - textureComponent.draw(b); - // b.Draw(Game1.mouseCursors, textureComponent.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 34, -1, -1)), Color.White); - } - foreach (ClickableComponent clickableComponent in this.labels) - { - Color color = Color.Violet; - Utility.drawTextWithShadow(b, clickableComponent.name, Game1.smallFont, new Vector2((float)clickableComponent.bounds.X, (float)clickableComponent.bounds.Y), color, 1f, -1f, -1, -1, 1f, 3); - // b.Draw(Game1.mouseCursors, textureComponent.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 34, -1, -1)), Color.White); - } - - } - foreach (ClickableComponent clickableComponent in this.labels) - { - string text = ""; - Color color = Game1.textColor; - switch (clickableComponent.name.Substring(0, 4)) - { - case "Name": - color = Game1.player.name.Length < 1 ? Color.Red : Game1.textColor; - if (!this.wizardSource) - break; - continue; - case "Farm": - color = Game1.player.farmName.Length < 1 ? Color.Red : Game1.textColor; - if (!this.wizardSource) - break; - continue; - case "Favo": - color = Game1.player.favoriteThing.Length < 1 ? Color.Red : Game1.textColor; - if (!this.wizardSource) - break; - continue; - case "Shir": - text = string.Concat((object)(Game1.player.shirt + 1)); - break; - case "Skin": - text = string.Concat((object)(Game1.player.skin + 1)); - break; - case "Hair": - if (!clickableComponent.name.Contains("Color")) - { - text = string.Concat((object)(Game1.player.hair + 1)); - break; - } - break; - case "Acc.": - text = string.Concat((object)(Game1.player.accessory + 2)); - break; - default: - color = Game1.textColor; - break; - } - Utility.drawTextWithShadow(b, clickableComponent.name, Game1.smallFont, new Vector2((float)clickableComponent.bounds.X, (float)clickableComponent.bounds.Y), color, 1f, -1f, -1, -1, 1f, 3); - if (Enumerable.Count((IEnumerable)text) > 0) - Utility.drawTextWithShadow(b, text, Game1.smallFont, new Vector2((float)(clickableComponent.bounds.X + Game1.tileSize / 3) - Game1.smallFont.MeasureString(text).X / 2f, (float)(clickableComponent.bounds.Y + Game1.tileSize / 2)), color, 1f, -1f, -1, -1, 1f, 3); - } - - if (this.canLeaveMenu()) - { - if(HappyBirthday.Class1.player_birthday_date!=0 && HappyBirthday.Class1.player_birthday_season!="") this.okButton.draw(b); - } - else - { - this.okButton.draw(b); - this.okButton.draw(b, Color.Black * 0.5f, 0.97f); - } - if (!this.wizardSource) - { - - if (this.skipIntroButton != null) - { - - } - - } - this.drawMouse(b); - } - } -} diff --git a/GeneralMods/HappyBirthday/Class1.cs b/GeneralMods/HappyBirthday/Class1.cs deleted file mode 100644 index a39b6430..00000000 --- a/GeneralMods/HappyBirthday/Class1.cs +++ /dev/null @@ -1,929 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Omegasis.HappyBirthday.PatchedUtilities; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.HappyBirthday -{ - public class Class1 :Mod - { - public List npc_name_list; - bool game_loaded; - public string key_binding= "O"; - public List possible_birthday_gifts; - public Item birthday_gift_to_receive; - bool once; - bool has_input_birthday; - - public static IMonitor thisMonitor; - - Dictionary popedDialogue; - - bool seenEvent; - - public string folder_name ="Player_Birthdays"; - public string birthdays_path; - - public static int player_birthday_date; - public static string player_birthday_season; - public override void Entry(IModHelper helper) - { - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += Day_Update; - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged; - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - StardewModdingAPI.Events.SaveEvents.AfterLoad += PlayerEvents_LoadedGame; - - StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; - npc_name_list = new List(); - possible_birthday_gifts = new List(); - birthdays_path = Path.Combine(Helper.DirectoryPath, folder_name); - if (!Directory.Exists(birthdays_path)) - { - Directory.CreateDirectory(birthdays_path); - } - thisMonitor = Monitor; - } - - public void TimeEvents_DayOfMonthChanged(object sender, StardewModdingAPI.Events.EventArgsIntChanged e) - { - if (isplayersbirthday() == true) - { - } - if (Game1.player == null) return; - if (has_input_birthday == true) MyWritter_Birthday(); - MyWritter_Settings(); - once = false; - } - - public void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) - { - if (Game1.player == null) return; - if (Game1.player.currentLocation == null) return; - if (game_loaded == false) return; - if (has_input_birthday == true) return; - if (e.KeyPressed.ToString() == key_binding) //if the key is pressed, load my cusom save function - { - if (Game1.activeClickableMenu != null) return; - Game1.activeClickableMenu = new Birthday_Menu(); - } - //DataLoader_Settings(); //update the key if players changed it while playing. - } - - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - game_loaded = true; - DataLoader_Birthday(); - DataLoader_Settings(); - seenEvent = false; - popedDialogue = new Dictionary(); - } - - public void GameEvents_UpdateTick(object sender, EventArgs e) - { - if (Game1.eventUp == true) return; - if (Game1.isFestival() == true) return; - if (Game1.player == null) return; - if (game_loaded == false) return; - if (Game1.player.isMoving()==true && once == false) - - { - //Log.AsyncM("Is it my birthday? "+isplayersbirthday()); - if (isplayersbirthday() == true) - { - OmegasisUtility.Messages.showStarMessage("It's your birthday today! Happy birthday!"); - // Game1.addMailForTomorrow("birthdayMom", false, false); - // Game1.addMailForTomorrow("birthdayDad", false, false); - // Game1.mailbox.Enqueue("\n 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 %"); - // Game1.mailbox.Enqueue("\n 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 %"); - Game1.mailbox.Enqueue("birthdayMom"); - Game1.mailbox.Enqueue("birthdayDad"); - - try - { - updateNPCList(); - } - catch(Exception eee) - { - thisMonitor.Log(eee.ToString(), LogLevel.Error); - } - foreach (var location in Game1.locations) - { - // Log.AsyncC(location.name); - foreach (NPC npc in location.characters) - { - // Log.AsyncC(npc.name); - try - { - if (npc is StardewValley.Characters.Cat || npc is StardewValley.Characters.Child || npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Horse || npc is StardewValley.Characters.Junimo || npc is StardewValley.Characters.Pet) continue; - if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue; - Dialogue d =new Dialogue(Game1.content.Load>("Data\\FarmerBirthdayDialogue")[npc.name], npc); - npc.CurrentDialogue.Push(d); - if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(Game1.content.Load>("Data\\FarmerBirthdayDialogue")[npc.name]); - } - // npc.setNewDialogue(Game1.content.Load>("Data\\FarmerBirthdayDialogue")[npc.name], true, false); - catch - { - if (npc is StardewValley.Characters.Cat || npc is StardewValley.Characters.Child || npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Horse || npc is StardewValley.Characters.Junimo || npc is StardewValley.Characters.Pet) continue; - if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue; - // npc.setNewDialogue("Happy birthday @!", true, false); - Dialogue d = new Dialogue("Happy Birthday @!", npc); - npc.CurrentDialogue.Push(d); - if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue("Happy Birthday @!"); - } - } - } - //end birthday check - } - once = true; - if (player_birthday_season == "" || player_birthday_season == null || player_birthday_date == 0) - { - Game1.activeClickableMenu = new Birthday_Menu(); - once = false; - } - } - - if (Game1.eventUp == true) - { - foreach(string npcName in npc_name_list) - { - NPC npc = Game1.getCharacterFromName(npcName); - - try { - popedDialogue.Add(npcName, npc.CurrentDialogue.Pop()); - } - catch (Exception err) - { - thisMonitor.Log(err.ToString(), LogLevel.Error); - popedDialogue.Add(npcName, npc.CurrentDialogue.ElementAt(0)); - npc.loadSeasonalDialogue(); - } - - seenEvent = true; - } - } - - if (Game1.eventUp == false && seenEvent == true) - { - foreach (KeyValuePair v in popedDialogue) - { - NPC npc = Game1.getCharacterFromName(v.Key); - npc.CurrentDialogue.Push(v.Value); - } - popedDialogue.Clear(); - seenEvent = false; - } - if (Game1.currentSpeaker != null) - { - if (isplayersbirthday()==true) - { - - // Log.AsyncC("ITS MY BIRTDHAY"); - try - { - //Game1.currentSpeaker.setNewDialogue(Game1.content.Load>("Data\\FarmerBirthdayDialogue")[Game1.currentSpeaker.name], true, false); - foreach (var ehh in npc_name_list) - { - if (ehh == Game1.currentSpeaker.name) - { - try - { - birthday_gift(); - // Log.AsyncG("GOT THE GIFT"); - npc_name_list.Remove(Game1.currentSpeaker.name); - } - catch(Exception r) - { - thisMonitor.Log(r.ToString(), LogLevel.Error); - } - - } - } - } - catch - { - // Game1.currentSpeaker.setNewDialogue("Happy birthday @!", true, false); - foreach (var ehh in npc_name_list) - { - if (ehh == Game1.currentSpeaker.name) - { - birthday_gift(); - npc_name_list.Remove(Game1.currentSpeaker.name); - } - } - } - } - } - - if (birthday_gift_to_receive != null && Game1.currentSpeaker==null) - { - while (birthday_gift_to_receive.Name=="Error Item"|| birthday_gift_to_receive.Name=="Rock"|| birthday_gift_to_receive.Name == "???") - { - birthday_gift(); - } - Game1.player.addItemByMenuIfNecessaryElseHoldUp(birthday_gift_to_receive); - birthday_gift_to_receive = null; - } - - if (player_birthday_season != "" && player_birthday_season != null && player_birthday_date != 0) - { - if (has_input_birthday == false) - { - MyWritter_Settings(); - MyWritter_Birthday(); - has_input_birthday = true; - } - } - } - - public void Day_Update(object sender, StardewModdingAPI.Events.EventArgsIntChanged e) - { - // Log.AsyncC("is this running?"); - // foreach (var bleh in npc_name_list) npc_name_list.Remove(bleh); - - } - - - public void updateNPCList() - - { - //Log.AsyncO("Step 1"); - npc_name_list.Clear(); - - foreach (var location in Game1.locations) - { - // Log.AsyncO("Step 2" + location.name); - foreach (var npc in location.characters) - { - // Log.AsyncO("Step 3 " + npc.name); - if (npc is StardewValley.Characters.Cat || npc is StardewValley.Characters.Child || npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Horse || npc is StardewValley.Characters.Junimo || npc is StardewValley.Characters.Pet) continue; - if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue; - if (npc_name_list.Contains(npc.name)) - { - continue; - } - npc_name_list.Add(npc.name); - // Log.AsyncO("Added in " + npc.name); - } - //Log.AsyncM("NO SERIOUSLY"); - } - } - - public virtual void birthday_gift() - { - - //grab 0~3 hearts //Neutral - //grab 4~6 //Good - //grab 7~10 //Best - Item farmers_birthday_gift; - if (this.possible_birthday_gifts.Count > 0) - { - Random rnd = new Random(); - int r = rnd.Next(this.possible_birthday_gifts.Count); - farmers_birthday_gift = this.possible_birthday_gifts.ElementAt(r); - if (Game1.player.isInventoryFull() == true) - { - Game1.createItemDebris(farmers_birthday_gift, Game1.player.getStandingPosition(), Game1.player.getDirection()); - } - else { - birthday_gift_to_receive = farmers_birthday_gift; - } - return; - } - - this.get_default_birthday_gifts(); - - Random rnd2 = new Random(); - int r2 = rnd2.Next(this.possible_birthday_gifts.Count); - farmers_birthday_gift = this.possible_birthday_gifts.ElementAt(r2); - if (Game1.player.isInventoryFull() == true) - { - Game1.createItemDebris(farmers_birthday_gift, Game1.player.getStandingPosition(), Game1.player.getDirection()); - } - else { - birthday_gift_to_receive = farmers_birthday_gift; - //Game1.player.addItemByMenuIfNecessaryElseHoldUp(farmers_birthday_gift); - } - this.possible_birthday_gifts.Clear(); - // Log.AsyncO("IS THIS EVER WORKING????"); - return; - } - - public virtual void get_default_birthday_gifts() - { - Dictionary dictionary = null; - try - { - dictionary = Game1.content.Load>("Data\\PossibleBirthdayGifts"); - - - string text; - dictionary.TryGetValue(Game1.currentSpeaker.name, out text); - if (text != null) - { - string[] array = text.Split(new char[] - { - '/' - }); - //love - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 7) - { - - string[] array2 = array[1].Split(new char[] - { - ' ' - }); - for (int i = 0; i < array2.Count(); i += 2) - { - try - { - if (Convert.ToInt32(array2[i]) > 0) this.possible_birthday_gifts.Add((Item)new StardewValley.Object(Convert.ToInt32(array2[i]), Convert.ToInt32(array2[i + 1]), false, -1, 0)); - else - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array2[i])); - foreach (var obj in some_object_list) - { - StardewValley.Object new_obj = new StardewValley.Object(obj.parentSheetIndex, Convert.ToInt32(array2[i + 1]), false, -1, 0); - this.possible_birthday_gifts.Add((Item)new_obj); - } - } - // this.itemsRequired.Add(Convert.ToInt32(array2[i]), Convert.ToInt32(array2[i + 1])); - } - catch - { - - } - } - } - //Like - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 4 && Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) <= 6) - { - - string[] array3 = array[3].Split(new char[] - { - ' ' - }); - for (int i = 0; i < array3.Count(); i += 2) - { - try - { - - - if (Convert.ToInt32(array3[i]) > 0) this.possible_birthday_gifts.Add((Item)new StardewValley.Object(Convert.ToInt32(array3[i]), Convert.ToInt32(array3[i + 1]), false, -1, 0)); - else - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array3[i])); - foreach (var obj in some_object_list) - { - StardewValley.Object new_obj = new StardewValley.Object(obj.parentSheetIndex, Convert.ToInt32(array3[i + 1]), false, -1, 0); - this.possible_birthday_gifts.Add((Item)new_obj); - } - } - // this.itemsRequired.Add(Convert.ToInt32(array2[i]), Convert.ToInt32(array2[i + 1])); - } - catch - { - - } - } - } - //Neutral - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 0 && Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) <= 3) - { - - string[] array4 = array[5].Split(new char[] - { - ' ' - }); - - for (int i = 0; i < array4.Count(); i += 2) - { - try - { - if (Convert.ToInt32(array4[i]) > 0) this.possible_birthday_gifts.Add((Item)new StardewValley.Object(Convert.ToInt32(array4[i]), Convert.ToInt32(array4[i + 1]), false, -1, 0)); - else - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array4[i])); - foreach (var obj in some_object_list) - { - StardewValley.Object new_obj = new StardewValley.Object(obj.parentSheetIndex, Convert.ToInt32(array4[i + 1]), false, -1, 0); - this.possible_birthday_gifts.Add((Item)new_obj); - } - } - // this.itemsRequired.Add(Convert.ToInt32(array2[i]), Convert.ToInt32(array2[i + 1])); - } - catch - { - - } - } - } - } //text !=null - //grabs from //Data//PossibleBirthdayGifts - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 7) getAllUniversalLovedItems(true); - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 4 && Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) <= 6) getAllUniversalLikedItems(true); - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 0 && Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) <= 3) getAllUniversalNeutralItems(true); - return; - - - } - catch - { - //grabs from NPCGiftTastes - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 7) - { - getAllUniversalLovedItems(false); - getAllSpecifiedLovedItems(); - } - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 4 && Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) <= 6) - { - getAllSpecifiedLikedItems(); - getAllUniversalLikedItems(false); - } - if (Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) >= 0 && Game1.player.getFriendshipHeartLevelForNPC(Game1.currentSpeaker.name) <= 3) - { - getAllUniversalNeutralItems(false); - } - return; - } - - - //TODO: Make different tiers of gifts depending on the friendship, and if it is the spouse. - /* - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(198, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(204, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(220, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(221, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(223, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(233, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(234, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(286, 5)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(368, 5)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(608, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(612, 1)); - this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(773, 1)); - */ - - } - public virtual void getAllUniversalNeutralItems(bool is_birthday_gift_list) - { - string text; - if (is_birthday_gift_list == false) - { - Game1.NPCGiftTastes.TryGetValue("Universal_Neutral", out text); - if (text != null) - { - - string[] array = text.Split(new char[] - { - ' ' - }); - - - for (int i = 0; i < array.Count(); i++) - { - int parentSheetIndex = Convert.ToInt32(array[i]); - if (parentSheetIndex < 0) - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array[i])); - foreach (var obj in some_object_list) - { - this.possible_birthday_gifts.Add((Item)obj); - } - continue; - } - else - { - this.possible_birthday_gifts.Add((Item)new StardewValley.Object(parentSheetIndex, 1, false, -1, 0)); - } - //this.itemsRequired.Add(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])); - } - - - return;// new SytardewValley.Object(parentSheetIndex, 1, false, -1, 0); - } - } - else - { - Dictionary dictionary = Game1.content.Load>("Data\\PossibleBirthdayGifts"); - string text2; - dictionary.TryGetValue("Universal_Neutral_Gift", out text2); - string[] array = text2.Split(new char[] - { - ' ' - }); - - - for (int i = 0; i < array.Count(); i += 2) - { - int parentSheetIndex = Convert.ToInt32(array[i]); - if (parentSheetIndex < 0) - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array[i])); - foreach (var obj in some_object_list) - { - StardewValley.Object new_obj = new StardewValley.Object(obj.parentSheetIndex, Convert.ToInt32(array[i + 1]), false, -1, 0); - this.possible_birthday_gifts.Add((Item)new_obj); - } - continue; - } - else - { - this.possible_birthday_gifts.Add((Item)new StardewValley.Object(parentSheetIndex, Convert.ToInt32(array[i + 1]), false, -1, 0)); - } - //this.itemsRequired.Add(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])); - } - - - return;// new StardewValley.Object(parentSheetIndex, 1, false, -1, 0); - } - return;// null; - } - public virtual void getAllUniversalLikedItems(bool is_birthday_gift_list) - { - string text; - if (is_birthday_gift_list == false) - { - Game1.NPCGiftTastes.TryGetValue("Universal_Like", out text); - if (text != null) - { - - string[] array = text.Split(new char[] - { - ' ' - }); - - - for (int i = 0; i < array.Count(); i++) - { - int parentSheetIndex = Convert.ToInt32(array[i]); - if (parentSheetIndex < 0) - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array[i])); - foreach (var obj in some_object_list) - { - this.possible_birthday_gifts.Add((Item)obj); - } - continue; - } - else - { - this.possible_birthday_gifts.Add((Item)new StardewValley.Object(parentSheetIndex, 1, false, -1, 0)); - } - //this.itemsRequired.Add(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])); - } - - - return;// new StardewValley.Object(parentSheetIndex, 1, false, -1, 0); - } - } - else - { - Dictionary dictionary = Game1.content.Load>("Data\\PossibleBirthdayGifts"); - string text2; - dictionary.TryGetValue("Universal_Like_Gift", out text2); - string[] array = text2.Split(new char[] - { - ' ' - }); - - - for (int i = 0; i < array.Count(); i += 2) - { - int parentSheetIndex = Convert.ToInt32(array[i]); - if (parentSheetIndex < 0) - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array[i])); - foreach (var obj in some_object_list) - { - StardewValley.Object new_obj = new StardewValley.Object(obj.parentSheetIndex, Convert.ToInt32(array[i + 1]), false, -1, 0); - this.possible_birthday_gifts.Add((Item)new_obj); - } - continue; - } - else - { - this.possible_birthday_gifts.Add((Item)new StardewValley.Object(parentSheetIndex, Convert.ToInt32(array[i + 1]), false, -1, 0)); - } - //this.itemsRequired.Add(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])); - } - - - return;// new StardewValley.Object(parentSheetIndex, 1, false, -1, 0); - } - return;// null; - } - public virtual void getAllUniversalLovedItems(bool is_birthday_gift_list) - { - string text; - if (is_birthday_gift_list == false) - { - Game1.NPCGiftTastes.TryGetValue("Universal_Neutral", out text); - if (text != null) - { - - string[] array = text.Split(new char[] - { - ' ' - }); - - - for (int i = 0; i < array.Count(); i++) - { - int parentSheetIndex = Convert.ToInt32(array[i]); - if (parentSheetIndex < 0) - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array[i])); - foreach (var obj in some_object_list) - { - this.possible_birthday_gifts.Add((Item)obj); - } - continue; - } - else - { - this.possible_birthday_gifts.Add((Item)new StardewValley.Object(parentSheetIndex, 1, false, -1, 0)); - } - //this.itemsRequired.Add(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])); - } - - - return;// new StardewValley.Object(parentSheetIndex, 1, false, -1, 0); - } - } - else - { - Dictionary dictionary = Game1.content.Load>("Data\\PossibleBirthdayGifts"); - string text2; - dictionary.TryGetValue("Universal_Love_Gift", out text2); - string[] array = text2.Split(new char[] - { - ' ' - }); - - - for (int i = 0; i < array.Count(); i += 2) - { - int parentSheetIndex = Convert.ToInt32(array[i]); - if (parentSheetIndex < 0) - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array[i])); - foreach (var obj in some_object_list) - { - StardewValley.Object new_obj = new StardewValley.Object(obj.parentSheetIndex, Convert.ToInt32(array[i + 1]), false, -1, 0); - this.possible_birthday_gifts.Add((Item)new_obj); - } - continue; - } - else - { - this.possible_birthday_gifts.Add((Item)new StardewValley.Object(parentSheetIndex, Convert.ToInt32(array[i + 1]), false, -1, 0)); - } - //this.itemsRequired.Add(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])); - } - - - return;// new StardewValley.Object(parentSheetIndex, 1, false, -1, 0); - } - return;// null; - } - - - public virtual void getAllSpecifiedLikedItems() - { - string text; - Game1.NPCGiftTastes.TryGetValue(Game1.currentSpeaker.name, out text); - if (text != null) - { - - string[] array = text.Split(new char[] - { - '/' - }); - - string[] array2 = array[3].Split(new char[] - { - ' ' - }); - - for (int i = 0; i < array2.Count(); i++) - { - int parentSheetIndex = Convert.ToInt32(array2[i]); - if (parentSheetIndex < 0) - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array2[i])); - foreach (var obj in some_object_list) - { - this.possible_birthday_gifts.Add((Item)obj); - } - continue; - } - else - { - this.possible_birthday_gifts.Add((Item)new StardewValley.Object(parentSheetIndex, 1, false, -1, 0)); - } - //this.itemsRequired.Add(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])); - } - - - return;// new Object(parentSheetIndex, 1, false, -1, 0); - } - return;// null; - } - public virtual void getAllSpecifiedLovedItems() - { - string text; - Game1.NPCGiftTastes.TryGetValue(Game1.currentSpeaker.name, out text); - if (text != null) - { - - string[] array = text.Split(new char[] - { - '/' - }); - - string[] array2 = array[1].Split(new char[] - { - ' ' - }); - - for (int i = 0; i < array2.Count(); i++) - { - int parentSheetIndex = Convert.ToInt32(array2[i]); - if (parentSheetIndex < 0) - { - List some_object_list = ObjectUtility.getAllObjectsAssociatedWithCategory(Convert.ToInt32(array2[i])); - foreach (var obj in some_object_list) - { - this.possible_birthday_gifts.Add((Item)obj); - } - continue; - } - else - { - this.possible_birthday_gifts.Add((Item)new StardewValley.Object(parentSheetIndex, 1, false, -1, 0)); - } - //this.itemsRequired.Add(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])); - } - - - return;// new StardewValley.Object(parentSheetIndex, 1, false, -1, 0); - } - return;// null; - } - - public virtual bool isplayersbirthday() - { - if (player_birthday_date.Equals(Game1.dayOfMonth) && player_birthday_season.Equals(Game1.currentSeason)) return true; - else return false; - } - - void DataLoader_Settings() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "HappyBirthday_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - // Console.WriteLine("Can't load custom save info since the file doesn't exist."); - - key_binding = "O"; - // Monitor.Log("KEY TIME"); - } - - else - { - // Console.WriteLine("HEY THERE IM LOADING DATA"); - string[] readtext = File.ReadAllLines(mylocation3); - key_binding = Convert.ToString(readtext[3]); - - - // Monitor.Log(key_binding); - // Monitor.Log(Convert.ToString(readtext[3])); - - } - } - - void MyWritter_Settings() - { - - //write all of my info to a text file. - string myname = StardewValley.Game1.player.name; - - string mylocation = Path.Combine(Helper.DirectoryPath, "HappyBirthday_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("HappyBirthday: The HappyBirthday Config doesn't exist. Creating it now."); - - mystring3[0] = "Config: HappyBirthday Info. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Key binding for opening the birthday menu. Press this key to do so."; - mystring3[3] = key_binding.ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - - } - - else - { - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Config: HappyBirthday Info. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Key binding for opening the birthday menu. Press this key to do so."; - mystring3[3] = key_binding.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - } - - - - void DataLoader_Birthday() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(birthdays_path, "HappyBirthday_"); - string mylocation2 = mylocation+myname; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - // Console.WriteLine("Can't load custom save info since the file doesn't exist."); - - - // Monitor.Log("KEY TIME"); - } - - else - { - // Console.WriteLine("HEY THERE IM LOADING DATA"); - string[] readtext = File.ReadAllLines(mylocation3); - player_birthday_season = Convert.ToString(readtext[3]); - player_birthday_date = Convert.ToInt32(readtext[5]); - - // Monitor.Log(key_binding); - // Monitor.Log(Convert.ToString(readtext[3])); - - } - } - - void MyWritter_Birthday() - { - - //write all of my info to a text file. - string myname = StardewValley.Game1.player.name; - - string mylocation = Path.Combine(birthdays_path, "HappyBirthday_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("HappyBirthday: The HappyBirthday Player Info doesn't exist. Creating it now."); - - mystring3[0] = "Player Info: Modifying these values could be considered cheating or an exploit. Edit at your own risk."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player's Birthday Season"; - mystring3[3] = player_birthday_season; - mystring3[4] = "Player's Birthday Date"; - mystring3[5] = player_birthday_date.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - - } - - else - { - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player Info: Modifying these values could be considered cheating or an exploit. Edit at your own risk."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player's Birthday Season"; - mystring3[3] = player_birthday_season.ToString(); - mystring3[4] = "Player's Birthday Date"; - mystring3[5] = player_birthday_date.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - } - - - } -} diff --git a/GeneralMods/HappyBirthday/Framework/BirthdayMenu.cs b/GeneralMods/HappyBirthday/Framework/BirthdayMenu.cs new file mode 100644 index 00000000..909a403c --- /dev/null +++ b/GeneralMods/HappyBirthday/Framework/BirthdayMenu.cs @@ -0,0 +1,279 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewValley; +using StardewValley.Menus; + +namespace Omegasis.HappyBirthday.Framework +{ + /// The menu which lets the player choose their birthday. + internal class BirthdayMenu : IClickableMenu + { + /********* + ** Properties + *********/ + /// The labels to draw. + private readonly List Labels = new List(); + + /// The season buttons to draw. + private readonly List SeasonButtons = new List(); + + /// The day buttons to draw. + private readonly List DayButtons = new List(); + + /// The OK button to draw. + private ClickableTextureComponent OkButton; + + /// The player's current birthday season. + private string BirthdaySeason; + + /// The player's current birthday day. + private int BirthdayDay; + + /// The callback to invoke when the birthday value changes. + private readonly Action OnChanged; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The initial birthday season. + /// The initial birthday day. + /// The callback to invoke when the birthday value changes. + public BirthdayMenu(string season, int day, Action onChanged) + : base(Game1.viewport.Width / 2 - (632 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2 - Game1.tileSize, 632 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2 + Game1.tileSize) + { + this.BirthdaySeason = season; + this.BirthdayDay = day; + this.OnChanged = onChanged; + this.SetUpPositions(); + } + + /// The method called when the game window changes size. + /// The former viewport. + /// The new viewport. + public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) + { + base.gameWindowSizeChanged(oldBounds, newBounds); + this.xPositionOnScreen = Game1.viewport.Width / 2 - (632 + IClickableMenu.borderWidth * 2) / 2; + this.yPositionOnScreen = Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2 - Game1.tileSize; + this.SetUpPositions(); + } + + + /********* + ** Private methods + *********/ + /// Regenerate the UI. + private void SetUpPositions() + { + this.Labels.Clear(); + this.DayButtons.Clear(); + this.OkButton = new ClickableTextureComponent("OK", new Rectangle(this.xPositionOnScreen + this.width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize, this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 4, Game1.tileSize, Game1.tileSize), "", null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f); + + this.Labels.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 + 8, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 8, 1, 1), "Birthday Season: " + this.BirthdaySeason)); + this.Labels.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 + 8, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize, Game1.tileSize * 2, Game1.tileSize), "Birthday Date: " + this.BirthdayDay)); + this.SeasonButtons.Add(new ClickableTextureComponent("Spring", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 1 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + (int)(Game1.tileSize * 3.10) - Game1.tileSize / 4, Game1.tileSize * 2, Game1.tileSize), "", "", Game1.mouseCursors, new Rectangle(188, 438, 32, 9), Game1.pixelZoom)); + this.SeasonButtons.Add(new ClickableTextureComponent("Summer", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + (int)(Game1.tileSize * 3.10) - Game1.tileSize / 4, Game1.tileSize * 2, Game1.tileSize), "", "", Game1.mouseCursors, new Rectangle(220, 438, 32, 8), Game1.pixelZoom)); + this.SeasonButtons.Add(new ClickableTextureComponent("Fall", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + (int)(Game1.tileSize * 3.1) - Game1.tileSize / 4, Game1.tileSize * 2, Game1.tileSize), "", "", Game1.mouseCursors, new Rectangle(188, 447, 32, 10), Game1.pixelZoom)); + this.SeasonButtons.Add(new ClickableTextureComponent("Winter", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 7 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + (int)(Game1.tileSize * 3.1) - Game1.tileSize / 4, Game1.tileSize * 2, Game1.tileSize), "", "", Game1.mouseCursors, new Rectangle(220, 448, 32, 8), Game1.pixelZoom)); + + + this.DayButtons.Add(new ClickableTextureComponent("1", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 1 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("2", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 2 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("3", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(24, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("4", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 4 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(32, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("5", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(40, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("6", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 6 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(48, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("7", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 7 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(56, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("8", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 1 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(64, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("9", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 2 - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize * 1, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(72, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("10", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("10", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(0, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("11", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("11", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("12", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("12", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("13", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("13", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(24, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("14", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("14", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 7.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 5 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(32, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("15", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 0.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("15", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 1.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(40, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("16", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 1.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("16", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(48, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("17", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("17", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(56, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("18", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("18", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(64, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("19", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("19", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(72, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("20", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("20", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(0, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("21", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("21", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 7.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 6 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(8, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("22", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 0.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("22", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 1.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("23", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 1.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("23", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(24, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("24", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 2.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("24", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(32, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("25", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 3.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("25", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(40, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("26", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 4.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("26", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(48, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("27", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 5.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("27", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(56, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("28", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 6.75) - Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(16, 16, 8, 12), Game1.pixelZoom)); + this.DayButtons.Add(new ClickableTextureComponent("28", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + (int)(Game1.tileSize * 7.25) - Game1.tileSize / 3, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 7 - Game1.tileSize / 4, Game1.tileSize / 2, Game1.tileSize), "", "", Game1.content.Load("LooseSprites\\font_bold"), new Rectangle(64, 16, 8, 12), Game1.pixelZoom)); + } + + /// Handle a button click. + /// The button name that was clicked. + private void HandleButtonClick(string name) + { + if (name == null) + return; + + switch (name) + { + // season button + case "Spring": + case "Summer": + case "Fall": + case "Winter": + this.BirthdaySeason = name.ToLower(); + this.OnChanged(this.BirthdaySeason, this.BirthdayDay); + Game1.activeClickableMenu = new BirthdayMenu(this.BirthdaySeason, this.BirthdayDay, this.OnChanged); + break; + + // OK button + case "OK": + if (this.BirthdayDay >= 1 || this.BirthdayDay <= 28) + Game1.exitActiveMenu(); + break; + + default: + this.BirthdayDay = Convert.ToInt32(name); + this.OnChanged(this.BirthdaySeason, this.BirthdayDay); + Game1.activeClickableMenu = new BirthdayMenu(this.BirthdaySeason, this.BirthdayDay, this.OnChanged); + break; + } + Game1.playSound("coin"); + } + + /// The method invoked when the player left-clicks on the menu. + /// The X-position of the cursor. + /// The Y-position of the cursor. + /// Whether to enable sound. + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + foreach (ClickableTextureComponent button in this.DayButtons) + { + if (button.containsPoint(x, y)) + { + this.HandleButtonClick(button.name); + button.scale -= 0.5f; + button.scale = Math.Max(3.5f, button.scale); + } + } + + foreach (ClickableTextureComponent button in this.SeasonButtons) + { + if (button.containsPoint(x, y)) + { + this.HandleButtonClick(button.name); + button.scale -= 0.5f; + button.scale = Math.Max(3.5f, button.scale); + } + } + + if (this.OkButton.containsPoint(x, y)) + { + this.HandleButtonClick(this.OkButton.name); + this.OkButton.scale -= 0.25f; + this.OkButton.scale = Math.Max(0.75f, this.OkButton.scale); + } + } + + /// The method invoked when the player right-clicks on the lookup UI. + /// The X-position of the cursor. + /// The Y-position of the cursor. + /// Whether to enable sound. + public override void receiveRightClick(int x, int y, bool playSound = true) { } + + /// The method invoked when the player hovers the cursor over the menu. + /// The X-position of the cursor. + /// The Y-position of the cursor. + public override void performHoverAction(int x, int y) + { + foreach (ClickableTextureComponent button in this.DayButtons) + { + button.scale = button.containsPoint(x, y) + ? Math.Min(button.scale + 0.02f, button.baseScale + 0.1f) + : Math.Max(button.scale - 0.02f, button.baseScale); + } + + foreach (ClickableTextureComponent button in this.SeasonButtons) + { + button.scale = button.containsPoint(x, y) + ? Math.Min(button.scale + 0.02f, button.baseScale + 0.1f) + : Math.Max(button.scale - 0.02f, button.baseScale); + } + + this.OkButton.scale = this.OkButton.containsPoint(x, y) + ? Math.Min(this.OkButton.scale + 0.02f, this.OkButton.baseScale + 0.1f) + : Math.Max(this.OkButton.scale - 0.02f, this.OkButton.baseScale); + + } + + /// Draw the menu to the screen. + /// The sprite batch. + public override void draw(SpriteBatch b) + { + // draw menu box + Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true); + b.Draw(Game1.daybg, new Vector2((this.xPositionOnScreen + Game1.tileSize + Game1.tileSize * 2 / 3 - 2), (this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 4)), Color.White); + + // draw day buttons + if (this.BirthdaySeason == "spring" || this.BirthdaySeason == "summer" || this.BirthdaySeason == "fall" || this.BirthdaySeason == "winter") + { + foreach (ClickableTextureComponent button in this.DayButtons) + button.draw(b); + } + + // draw season buttons + foreach (ClickableTextureComponent button in this.SeasonButtons) + button.draw(b); + + // draw labels + foreach (ClickableComponent label in this.Labels) + { + Color color = Color.Violet; + Utility.drawTextWithShadow(b, label.name, Game1.smallFont, new Vector2(label.bounds.X, label.bounds.Y), color); + } + foreach (ClickableComponent label in this.Labels) + { + string text = ""; + Color color = Game1.textColor; + Utility.drawTextWithShadow(b, label.name, Game1.smallFont, new Vector2(label.bounds.X, label.bounds.Y), color); + if (text.Length > 0) + Utility.drawTextWithShadow(b, text, Game1.smallFont, new Vector2((label.bounds.X + Game1.tileSize / 3) - Game1.smallFont.MeasureString(text).X / 2f, (label.bounds.Y + Game1.tileSize / 2)), color); + } + + // draw OK button + if (this.BirthdayDay != 0 && this.BirthdaySeason != "") + this.OkButton.draw(b); + else + { + this.OkButton.draw(b); + this.OkButton.draw(b, Color.Black * 0.5f, 0.97f); + } + + // draw cursor + this.drawMouse(b); + } + } +} diff --git a/GeneralMods/HappyBirthday/Framework/Messages.cs b/GeneralMods/HappyBirthday/Framework/Messages.cs new file mode 100644 index 00000000..8d2c1c04 --- /dev/null +++ b/GeneralMods/HappyBirthday/Framework/Messages.cs @@ -0,0 +1,28 @@ +using StardewValley; + +namespace Omegasis.HappyBirthday.Framework +{ + /// Provides utility methods for displaying messages to the user. + internal class Messages + { + /********* + ** Public methods + *********/ + /// Show a message to the user with a star icon. + /// The message to display. + public static void ShowStarMessage(string message) + { + Game1.addHUDMessage(new HUDMessage(message, 1)); + if (!message.Contains("Inventory")) + { + Game1.playSound("cancel"); + return; + } + if (!Game1.player.mailReceived.Contains("BackpackTip")) + { + Game1.player.mailReceived.Add("BackpackTip"); + Game1.addMailForTomorrow("pierreBackpack", false, false); + } + } + } +} diff --git a/GeneralMods/HappyBirthday/Framework/ObjectUtility.cs b/GeneralMods/HappyBirthday/Framework/ObjectUtility.cs new file mode 100644 index 00000000..bd86d3d4 --- /dev/null +++ b/GeneralMods/HappyBirthday/Framework/ObjectUtility.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using System.Linq; +using StardewValley; +using Object = StardewValley.Object; + +namespace Omegasis.HappyBirthday.Framework +{ + /// Provides utility methods for managing in-game objects. + internal class ObjectUtility + { + /********* + ** Properties + *********/ + /// The cached object data. + private static readonly Object[] ObjectList = ObjectUtility.GetAllObjects().ToArray(); + + + /********* + ** Public methods + *********/ + /// Get objects with the given category. + /// The category for which to find objects. + public static IEnumerable GetObjectsInCategory(int category) + { + if (category > 0) + yield break; + + foreach (Object obj in ObjectUtility.ObjectList) + { + if (obj.category == category) + yield return obj; + } + } + + + /********* + ** Private methods + *********/ + /// Get all objects defined by the game. + private static IEnumerable GetAllObjects() + { + foreach (int key in Game1.content.Load>("Data\\ObjectInformation").Keys) + yield return new Object(key, 1); + } + } +} diff --git a/GeneralMods/HappyBirthday/HappyBirthday.cs b/GeneralMods/HappyBirthday/HappyBirthday.cs new file mode 100644 index 00000000..e4cd87c7 --- /dev/null +++ b/GeneralMods/HappyBirthday/HappyBirthday.cs @@ -0,0 +1,567 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Omegasis.HappyBirthday.Framework; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; +using StardewValley.Characters; +using StardewValley.Monsters; +using SObject = StardewValley.Object; + +namespace Omegasis.HappyBirthday +{ + /// The mod entry point. + public class HappyBirthday : Mod + { + /********* + ** Properties + *********/ + /// The key which shows the menu. + private string KeyBinding = "O"; + + /// Whether the player loaded a save. + private bool IsGameLoaded; + + /// Whether the player has chosen a birthday. + private bool HasChosenBirthday; + + /// The queue of villagers who haven't given a gift yet. + private List VillagerQueue; + + /// The gifts that villagers can give. + private List PossibleBirthdayGifts; + + /// The next birthday gift the player will receive. + private Item BirthdayGiftToReceive; + + /// Whether we've already checked for and (if applicable) set up the player's birthday today. + private bool CheckedForBirthday; + //private Dictionary Dialogue; + //private bool SeenEvent; + + /// The name of the folder containing birthday data files. + private readonly string FolderName = "Player_Birthdays"; + + /// The full path to the folder containing birthday data files. + private string BirthdayFolderPath; + + /// The player's current birthday day. + public int BirthdayDay; + + /// The player's current birthday season. + public string BirthdaySeason; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + + this.VillagerQueue = new List(); + this.PossibleBirthdayGifts = new List(); + this.BirthdayFolderPath = Path.Combine(Helper.DirectoryPath, this.FolderName); + + if (!Directory.Exists(this.BirthdayFolderPath)) + Directory.CreateDirectory(this.BirthdayFolderPath); + } + + + /********* + ** Private methods + *********/ + /// The method invoked when changes. + /// The event sender. + /// The event data. + private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e) + { + if (Game1.player == null) + return; + + if (this.HasChosenBirthday) + this.WriteBirthday(); + this.WriteConfig(); + this.CheckedForBirthday = false; + } + + /// The method invoked when the presses a keyboard button. + /// The event sender. + /// The event data. + private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + { + if (Game1.player == null || Game1.player.currentLocation == null || !this.IsGameLoaded || this.HasChosenBirthday || Game1.activeClickableMenu != null) + return; + + // show birthday selection menu + if (e.KeyPressed.ToString() == this.KeyBinding) + Game1.activeClickableMenu = new BirthdayMenu(this.BirthdaySeason, this.BirthdayDay, this.SetBirthday); + } + + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + this.IsGameLoaded = true; + this.LoadBirthday(); + this.LoadConfig(); + //this.SeenEvent = false; + //this.Dialogue = new Dictionary(); + } + + /// 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) + { + if (Game1.eventUp || Game1.isFestival() || Game1.player == null || !this.IsGameLoaded) + return; + + if (!this.CheckedForBirthday) + { + this.CheckedForBirthday = true; + + // set up birthday + if (this.IsBirthday()) + { + Messages.ShowStarMessage("It's your birthday today! Happy birthday!"); + Game1.mailbox.Enqueue("birthdayMom"); + Game1.mailbox.Enqueue("birthdayDad"); + + try + { + this.ResetVillagerQueue(); + } + catch (Exception ex) + { + this.Monitor.Log(ex.ToString(), LogLevel.Error); + } + foreach (GameLocation location in Game1.locations) + { + foreach (NPC npc in location.characters) + { + if (npc is Child || npc is Horse || npc is Junimo || npc is Monster || npc is Pet) + continue; + + try + { + Dialogue d = new Dialogue(Game1.content.Load>("Data\\FarmerBirthdayDialogue")[npc.name], npc); + npc.CurrentDialogue.Push(d); + if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(Game1.content.Load>("Data\\FarmerBirthdayDialogue")[npc.name]); + } + catch + { + Dialogue d = new Dialogue("Happy Birthday @!", npc); + npc.CurrentDialogue.Push(d); + if (npc.CurrentDialogue.ElementAt(0) != d) + npc.setNewDialogue("Happy Birthday @!"); + } + } + } + } + + // ask for birthday date + if ((string.IsNullOrEmpty(this.BirthdaySeason) || this.BirthdayDay == 0) && Game1.activeClickableMenu == null) + { + Game1.activeClickableMenu = new BirthdayMenu(this.BirthdaySeason, this.BirthdayDay, this.SetBirthday); + this.CheckedForBirthday = false; + } + } + + // unreachable since we exit early if Game1.eventUp + //if (Game1.eventUp) + //{ + // foreach (string npcName in this.VillagerQueue) + // { + // NPC npc = Game1.getCharacterFromName(npcName); + + // try + // { + // this.Dialogue.Add(npcName, npc.CurrentDialogue.Pop()); + // } + // catch (Exception ex) + // { + // this.Monitor.Log(ex.ToString(), LogLevel.Error); + // this.Dialogue.Add(npcName, npc.CurrentDialogue.ElementAt(0)); + // npc.loadSeasonalDialogue(); + // } + + // this.SeenEvent = true; + // } + //} + + //if (!Game1.eventUp && this.SeenEvent) + //{ + // foreach (KeyValuePair v in this.Dialogue) + // { + // NPC npc = Game1.getCharacterFromName(v.Key); + // npc.CurrentDialogue.Push(v.Value); + // } + // this.Dialogue.Clear(); + // this.SeenEvent = false; + //} + + // set birthday gift + if (Game1.currentSpeaker != null) + { + string name = Game1.currentSpeaker.name; + if (this.IsBirthday() && this.VillagerQueue.Contains(name)) + { + try + { + this.SetNextBirthdayGift(Game1.currentSpeaker.name); + this.VillagerQueue.Remove(Game1.currentSpeaker.name); + } + catch (Exception ex) + { + this.Monitor.Log(ex.ToString(), LogLevel.Error); + } + } + } + if (this.BirthdayGiftToReceive != null && Game1.currentSpeaker != null) + { + while (this.BirthdayGiftToReceive.Name == "Error Item" || this.BirthdayGiftToReceive.Name == "Rock" || this.BirthdayGiftToReceive.Name == "???") + this.SetNextBirthdayGift(Game1.currentSpeaker.name); + Game1.player.addItemByMenuIfNecessaryElseHoldUp(this.BirthdayGiftToReceive); + this.BirthdayGiftToReceive = null; + } + + // update settings + if (!this.HasChosenBirthday && !string.IsNullOrEmpty(this.BirthdaySeason) && this.BirthdayDay != 0) + { + this.WriteConfig(); + this.WriteBirthday(); + this.HasChosenBirthday = true; + } + } + + /// Set the player's birtday/ + /// The birthday season. + /// The birthday day. + private void SetBirthday(string season, int day) + { + this.BirthdaySeason = season; + this.BirthdayDay = day; + } + + /// Reset the queue of villager names. + private void ResetVillagerQueue() + { + this.VillagerQueue.Clear(); + + foreach (GameLocation location in Game1.locations) + { + foreach (NPC npc in location.characters) + { + if (npc is Child || npc is Horse || npc is Junimo || npc is Monster || npc is Pet) + continue; + if (this.VillagerQueue.Contains(npc.name)) + continue; + this.VillagerQueue.Add(npc.name); + } + } + } + + /// Set the next birthday gift the player will receive. + /// The villager's name who's giving the gift. + /// This returns gifts based on the speaker's heart level towards the player: neutral for 0-3, good for 4-6, and best for 7-10. + private void SetNextBirthdayGift(string name) + { + Item gift; + if (this.PossibleBirthdayGifts.Count > 0) + { + Random random = new Random(); + int index = random.Next(this.PossibleBirthdayGifts.Count); + gift = this.PossibleBirthdayGifts[index]; + if (Game1.player.isInventoryFull()) + Game1.createItemDebris(gift, Game1.player.getStandingPosition(), Game1.player.getDirection()); + else + this.BirthdayGiftToReceive = gift; + return; + } + + this.PossibleBirthdayGifts.AddRange(this.GetDefaultBirthdayGifts(name)); + + Random rnd2 = new Random(); + int r2 = rnd2.Next(this.PossibleBirthdayGifts.Count); + gift = this.PossibleBirthdayGifts.ElementAt(r2); + if (Game1.player.isInventoryFull()) + Game1.createItemDebris(gift, Game1.player.getStandingPosition(), Game1.player.getDirection()); + else + this.BirthdayGiftToReceive = gift; + + this.PossibleBirthdayGifts.Clear(); + } + + /// Get the default gift items. + /// The villager's name. + private IEnumerable GetDefaultBirthdayGifts(string name) + { + List gifts = new List(); + try + { + // read from birthday gifts file + IDictionary data = Game1.content.Load>("Data\\PossibleBirthdayGifts"); + string text; + data.TryGetValue(name, out text); + if (text != null) + { + string[] fields = text.Split('/'); + + // love + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 7) + { + string[] loveFields = fields[1].Split(' '); + for (int i = 0; i < loveFields.Length; i += 2) + { + try + { + gifts.AddRange(this.GetItems(Convert.ToInt32(loveFields[i]), Convert.ToInt32(loveFields[i + 1]))); + } + catch { } + } + } + + // like + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 4 && Game1.player.getFriendshipHeartLevelForNPC(name) <= 6) + { + string[] likeFields = fields[3].Split(' '); + for (int i = 0; i < likeFields.Length; i += 2) + { + try + { + gifts.AddRange(this.GetItems(Convert.ToInt32(likeFields[i]), Convert.ToInt32(likeFields[i + 1]))); + } + catch { } + } + } + + // neutral + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 0 && Game1.player.getFriendshipHeartLevelForNPC(name) <= 3) + { + string[] neutralFields = fields[5].Split(' '); + + for (int i = 0; i < neutralFields.Length; i += 2) + { + try + { + gifts.AddRange(this.GetItems(Convert.ToInt32(neutralFields[i]), Convert.ToInt32(neutralFields[i + 1]))); + } + catch { } + } + } + } + + // get NPC's preferred gifts + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 7) + gifts.AddRange(this.GetUniversalItems("Love", true)); + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 4 && Game1.player.getFriendshipHeartLevelForNPC(name) <= 6) + this.PossibleBirthdayGifts.AddRange(this.GetUniversalItems("Like", true)); + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 0 && Game1.player.getFriendshipHeartLevelForNPC(name) <= 3) + this.PossibleBirthdayGifts.AddRange(this.GetUniversalItems("Neutral", true)); + } + catch + { + // get NPC's preferred gifts + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 7) + { + this.PossibleBirthdayGifts.AddRange(this.GetUniversalItems("Love", false)); + this.PossibleBirthdayGifts.AddRange(this.GetLovedItems(name)); + } + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 4 && Game1.player.getFriendshipHeartLevelForNPC(name) <= 6) + { + this.PossibleBirthdayGifts.AddRange(this.GetLikedItems(name)); + this.PossibleBirthdayGifts.AddRange(this.GetUniversalItems("Like", false)); + } + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= 0 && Game1.player.getFriendshipHeartLevelForNPC(name) <= 3) + this.PossibleBirthdayGifts.AddRange(this.GetUniversalItems("Neutral", false)); + } + //TODO: Make different tiers of gifts depending on the friendship, and if it is the spouse. + /* + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(198, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(204, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(220, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(221, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(223, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(233, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(234, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(286, 5)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(368, 5)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(608, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(612, 1)); + this.possible_birthday_gifts.Add((Item)new SytardewValley.Object(773, 1)); + */ + + return gifts; + } + + /// Get the items loved by all villagers. + /// The group to get (one of Like, Love, Neutral). + /// Whether to get data from Data\PossibleBirthdayGifts.xnb instead of the game data. + private IEnumerable GetUniversalItems(string group, bool isBirthdayGiftList) + { + if (!isBirthdayGiftList) + { + // get raw data + string text; + Game1.NPCGiftTastes.TryGetValue($"Universal_{group}", out text); + if (text == null) + yield break; + + // parse + string[] neutralIDs = text.Split(' '); + foreach (string neutralID in neutralIDs) + { + foreach (SObject obj in this.GetItems(Convert.ToInt32(neutralID))) + yield return obj; + } + } + else + { + // get raw data + Dictionary data = Game1.content.Load>("Data\\PossibleBirthdayGifts"); + string text; + data.TryGetValue($"Universal_{group}_Gift", out text); + if (text == null) + yield break; + + // parse + string[] array = text.Split(' '); + for (int i = 0; i < array.Length; i += 2) + { + foreach (SObject obj in this.GetItems(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1]))) + yield return obj; + } + } + } + + /// Get a villager's loved items. + /// The villager's name. + private IEnumerable GetLikedItems(string name) + { + // get raw data + string text; + Game1.NPCGiftTastes.TryGetValue(name, out text); + if (text == null) + yield break; + + // parse + string[] data = text.Split('/'); + string[] likedIDs = data[3].Split(' '); + foreach (string likedID in likedIDs) + { + foreach (SObject obj in this.GetItems(Convert.ToInt32(likedID))) + yield return obj; + } + } + + /// Get a villager's loved items. + /// The villager's name. + private IEnumerable GetLovedItems(string name) + { + // get raw data + string text; + Game1.NPCGiftTastes.TryGetValue(name, out text); + if (text == null) + yield break; + + // parse + string[] data = text.Split('/'); + string[] lovedIDs = data[1].Split(' '); + foreach (string lovedID in lovedIDs) + { + foreach (SObject obj in this.GetItems(Convert.ToInt32(lovedID))) + yield return obj; + } + } + + /// Get the items matching the given ID. + /// The category or item ID. + private IEnumerable GetItems(int id) + { + return id < 0 + ? ObjectUtility.GetObjectsInCategory(id) + : new[] { new SObject(id, 1) }; + } + + /// Get the items matching the given ID. + /// The category or item ID. + /// The stack size. + private IEnumerable GetItems(int id, int stack) + { + foreach (SObject obj in this.GetItems(id)) + yield return new SObject(obj.parentSheetIndex, stack); + } + + /// Get whether today is the player's birthday. + private bool IsBirthday() + { + return + this.BirthdayDay == Game1.dayOfMonth + && this.BirthdaySeason == Game1.currentSeason; + } + + /// Load the configuration settings. + private void LoadConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "HappyBirthday_Config.txt"); + if (!File.Exists(path)) + this.KeyBinding = "O"; + else + { + string[] text = File.ReadAllLines(path); + this.KeyBinding = Convert.ToString(text[3]); + } + } + + /// Save the configuration settings. + private void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "HappyBirthday_Config.txt"); + string[] text = new string[20]; + text[0] = "Config: HappyBirthday Info. Feel free to mess with these settings."; + text[1] = "===================================================================================="; + + text[2] = "Key binding for opening the birthday menu. Press this key to do so."; + text[3] = this.KeyBinding; + + File.WriteAllLines(path, text); + } + + /// Load the player's birthday from the config file. + private void LoadBirthday() + { + string path = Path.Combine(this.BirthdayFolderPath, $"HappyBirthday_{Game1.player.name}.txt"); + if (File.Exists(path)) + { + string[] text = File.ReadAllLines(path); + this.BirthdaySeason = Convert.ToString(text[3]); + this.BirthdayDay = Convert.ToInt32(text[5]); + } + } + + /// Write the player's birthday to the config file. + private void WriteBirthday() + { + string path = Path.Combine(this.BirthdayFolderPath, $"HappyBirthday_{Game1.player.name}.txt"); + string[] text = new string[20]; + text[0] = "Player Info: Modifying these values could be considered cheating or an exploit. Edit at your own risk."; + text[1] = "===================================================================================="; + + text[2] = "Player's Birthday Season"; + text[3] = this.BirthdaySeason; + text[4] = "Player's Birthday Date"; + text[5] = this.BirthdayDay.ToString(); + + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/HappyBirthday/HappyBirthday.csproj b/GeneralMods/HappyBirthday/HappyBirthday.csproj index 427bbff2..d62fdc25 100644 --- a/GeneralMods/HappyBirthday/HappyBirthday.csproj +++ b/GeneralMods/HappyBirthday/HappyBirthday.csproj @@ -36,21 +36,30 @@ - - - - + + Properties\GlobalAssemblyInfo.cs + + + + + - - - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + - + diff --git a/GeneralMods/HappyBirthday/OmegasisUtility/Messages.cs b/GeneralMods/HappyBirthday/OmegasisUtility/Messages.cs deleted file mode 100644 index 3c2fe7d0..00000000 --- a/GeneralMods/HappyBirthday/OmegasisUtility/Messages.cs +++ /dev/null @@ -1,53 +0,0 @@ -using StardewValley; - -namespace Omegasis.HappyBirthday.OmegasisUtility -{ - class Messages - { - - public static void showStarMessage(string message) - { - Game1.addHUDMessage(new HUDMessage(message, 1)); - if (!message.Contains("Inventory")) - { - Game1.playSound("cancel"); - return; - } - if (!Game1.player.mailReceived.Contains("BackpackTip")) - { - Game1.player.mailReceived.Add("BackpackTip"); - Game1.addMailForTomorrow("pierreBackpack", false, false); - } - } - public static void showMessage2(string message) - { - Game1.addHUDMessage(new HUDMessage(message, 2)); - if (!message.Contains("Inventory")) - { - Game1.playSound("cancel"); - return; - } - if (!Game1.player.mailReceived.Contains("BackpackTip")) - { - Game1.player.mailReceived.Add("BackpackTip"); - Game1.addMailForTomorrow("pierreBackpack", false, false); - } - } - - - public static void showRedMessage(string message) - { - Game1.addHUDMessage(new HUDMessage(message, 3)); - if (!message.Contains("Inventory")) - { - Game1.playSound("cancel"); - return; - } - if (!Game1.player.mailReceived.Contains("BackpackTip")) - { - Game1.player.mailReceived.Add("BackpackTip"); - Game1.addMailForTomorrow("pierreBackpack", false, false); - } - } - } -} diff --git a/GeneralMods/HappyBirthday/PatchedUtilities/ObjectUtility.cs b/GeneralMods/HappyBirthday/PatchedUtilities/ObjectUtility.cs deleted file mode 100644 index 8c0433d7..00000000 --- a/GeneralMods/HappyBirthday/PatchedUtilities/ObjectUtility.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections.Generic; -using StardewValley; -using Object = StardewValley.Object; - -namespace Omegasis.HappyBirthday.PatchedUtilities -{ - class ObjectUtility - { - public static List object_list = new List(); - - public static void getAllObjects() - { - if (object_list.Count > 0) return; - Dictionary my_dic = Game1.content.Load>("Data\\ObjectInformation"); - foreach (var key in my_dic.Keys) - { - object_list.Add(new Object(key, 1, false, -1, 0)); - - } - - } - - public static List getAllObjectsAssociatedWithCategory(int category_number) - { - getAllObjects(); - List my_obj_list = new List(); - if (category_number > 0) return my_obj_list; ; - foreach (var obj in object_list) - { - if (obj.category == category_number) - { - my_obj_list.Add(obj); - } - } - - return my_obj_list; - } - - - } -} diff --git a/GeneralMods/HappyBirthday/Properties/AssemblyInfo.cs b/GeneralMods/HappyBirthday/Properties/AssemblyInfo.cs index 89c08b46..9d8be02d 100644 --- a/GeneralMods/HappyBirthday/Properties/AssemblyInfo.cs +++ b/GeneralMods/HappyBirthday/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("HappyBirthday")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HappyBirthday")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a7a4b67b-3cd7-421f-a4a7-2d656f0ab4d9")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/HappyBirthday/README.md b/GeneralMods/HappyBirthday/README.md new file mode 100644 index 00000000..8a8d545a --- /dev/null +++ b/GeneralMods/HappyBirthday/README.md @@ -0,0 +1,50 @@ +**Happy Birthday** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you pick a day +for your birthday. On your birthday, you get letters from your parents, and villagers give you +gifts and wish you happy birthday. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/520). +3. Merge the mod's `Content` folder with the game's `Content` folder. +4. Run the game using SMAPI. + +## Usage +The menu to choose your birthday should appear when you wake up in the morning. On your birthday, +talk to NPCs as usual and they'll wish you happy birthday and give you gifts. Their gifts will +change based on your friendship with them. Check your mailbox for letters from your parents. + +## Versions +1.0: +* Initial release. + +1.0.1: +* Fixed a dialogue error with Shane. +* Reduced log spam in the SMAPI console. + +1.0.2: +* Deleted some old data. + +1.0.3: +* Fixed being able to "talk" to your pet. + +1.0.4: +* Fixed everyone wishing you a happy birthday every day. Oops. + +1.0.5: +* Fixed NPCs giving you a gift but not wishing you a happy birthday. + +1.0.6: +* Fixed NPCs not wishing you a happy birthday if your birthday didn't exist already. + +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. +* Added a popup that wishes you happy birthday on your birthday. +* Added mail from your parents on your birthday. + +1.1.1: +* Fixed some gifts being too OP (like 25 rabbit foots). +* Fixed the birthday menu not letting you exit without choosing a date. +* Fixed NPCs sometimes giving you broken items and useless rocks. +* Fixed game crashing when in an event. It gives priority to the event over your birthday in worst case scenario. diff --git a/GeneralMods/HappyBirthday/ReadMe.txt b/GeneralMods/HappyBirthday/ReadMe.txt deleted file mode 100644 index 73282d51..00000000 --- a/GeneralMods/HappyBirthday/ReadMe.txt +++ /dev/null @@ -1,77 +0,0 @@ -Happy Birthday - -Version:1.1.1 - -Published: 8/18/16 11:21 AM - -Updated: 11/8/16 1:17 AM - -Compatability: - -Stardew Valley 1.1.0 Windows - -SMAPI 0.40.0 - -Description: - -Ever wonder why you don't have a birthday in Stardew Valley? Well worry no more! - -Introducing the mod, Happy Birthday! - -This mod is pretty basic and does a few things. - -1.Adds in a new menu where you can choose the birthday for your farmer. Just load up your character and try to move and the menu should pop up! - -2.NPCs wish you a happy birthday. Dialogue for this can be found at StardewValley/Content/Data/FarmerBirthdayDialogue.xnb - -3.You get a random gift from each NPC according to how close you are to them. Possible gifts can be found at StardewValley/Content/Data/PossibleBirthdayGifts.xnb - -There may or may not be a few content additions in the future depending on how much time I have, so keep an eye out just incase! - -Installation: -1.Download SMAPI -2.Download the main mod file -3.Download the mod Content file. -4.Place the main mod content file at StardewValley/Mods\ -5.Merge the mod Content file with the content file located at StardewValley/Content -OR -Place FarmerBirthdayDialogue.xnb and PossibleBirthdayGifts.xnb from the mod content folder inside of StardewValley/Content/Data -6.Run the game! - -Note: This mod was built with custom NPCs in mind. You can either add in your custom NPC to the mod content files to allow for NPC specific dialogue and gifts, but if you don't you'll just get a default birthday message and the NPC will choose a gift from the general gift pool. - -Have fun! - -Update Info: -1.1.1 --Balanced some gifts to be a bit less op. (Like 25 rabit foots); --Fixed the birthday menu to force you to choose a season and date before you are allowed to exit the menu. --Hopefully fixed the ???, Error Item, and useless rocks from showing up as possible gifts. --Implemented a cheep fix to hopefully prevent the game from crashing when inside an event. It gives priority to the event over your birthday in worst case scenario. - -1.1.0 --Updated to SDV 1.1 --Added a popup that wishes you happy birthday on your birthday --Added a way for the player to receive mail from their parents on their birthday. - -1.0.6 --Fixed a bug where NPC's wouldn't wish you a happy birthday if your birthday didn't exist already. - -1.0.5 --Fixed a bug where NPCs wouldn't wish you a happy birthday but give you a gift. - -1.0.4 --Fixed a bug where everyone would wish you a happy birthday every day. Opps - -1.0.3 --Fixed a bug where you could "talk" to your pet. - -1.0.2 --Deleted some old data. all good now. - -1.0.1 --Fixed a dialogue error with Shane --Stopped spamming info to the SMAPI console. - -1.0.0 --Initial Release diff --git a/GeneralMods/MoreRain/Class1.cs b/GeneralMods/MoreRain/Class1.cs deleted file mode 100644 index d37bf224..00000000 --- a/GeneralMods/MoreRain/Class1.cs +++ /dev/null @@ -1,299 +0,0 @@ -using System; -using System.IO; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.MoreRain -{ - - public class MoreRain : Mod - { - int springRainInt; - int springThunderInt; - int summerRainInt; - int summerThunderInt; - int fallRainInt; - int fallThunderInt; - int winterSnowInt; - - bool gameloaded; - - bool suppress_log; - - public override void Entry(IModHelper helper) - { - // set_up(); - StardewModdingAPI.Events.SaveEvents.AfterLoad += PlayerEvents_LoadedGame; - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged; - DataLoader(); - } - - public void TimeEvents_DayOfMonthChanged(object sender, StardewModdingAPI.Events.EventArgsIntChanged e) - { - if (gameloaded == false) return; - New_day_Update(); - } - - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - gameloaded = true; - - New_day_Update(); - } - - void New_day_Update() //updates all info whenever I call this. - { - - - - if (Game1.weatherForTomorrow == Game1.weather_festival ) - { - if(suppress_log==false)Monitor.Log("There is a festival tomorrow, therefore it will not rain."); - return; - } - - if(Game1.weatherForTomorrow== Game1.weather_wedding) - { - if(suppress_log==false)Monitor.Log("There is a wedding tomorrow and rain on your wedding day will not happen."); - return; - } - - - Random random = new Random(); - int randomNumber = random.Next(0, 100); //sets ran variable to some num between 0 and 100 - Random thunder_random = new Random(); - int thunder_randomNumber = random.Next(0, 100); - - if (Game1.currentSeason == "spring") - { - if (StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_sunny || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_rain || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_lightning || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_debris) - { //if my weather isn't something special. This is to prevent something from going wierd. - if (randomNumber <= springRainInt) //if the random variable is less than or equal to the chance for rain. - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_rain; //sets rainy weather tomorrow - if (suppress_log == false) Monitor.Log("It will rain tomorrow."); - } - else - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_sunny;//sets sunny weather tomorrow - if (suppress_log == false) Monitor.Log("It will not rain tomorrow."); - } - - if (StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_rain) - { - if (randomNumber <= springThunderInt) //if the random variable is less than or equal to the chance for rain. - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_lightning; //sets rainy weather tomorrow - if (suppress_log == false) Monitor.Log("It will be stormy tomorrow."); - } - else - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_rain;//sets sunny weather tomorrow - if (suppress_log == false) Monitor.Log("There will be no lightning tomorrow."); - } - } - } - } - else if (Game1.currentSeason == "summer") - { - if (StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_sunny || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_rain || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_lightning || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_debris) - { //if my weather isn't something special. This is to prevent something from going wierd. - if (randomNumber <= summerRainInt) //if the random variable is less than or equal to the chance for rain. - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_rain; //sets rainy weather tomorrow - if (suppress_log == false) Monitor.Log("It will rain tomorrow."); - } - else - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_sunny;//sets sunny weather tomorrow - if (suppress_log == false) Monitor.Log("It will not rain tomorrow."); - } - - if (StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_rain) - { - if (randomNumber <= summerThunderInt) //if the random variable is less than or equal to the chance for rain. - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_lightning; //sets rainy weather tomorrow - if (suppress_log == false) Monitor.Log("It will be stormy tomorrow."); - } - else - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_rain;//sets sunny weather tomorrow - if (suppress_log == false) Monitor.Log("There will be no lightning tomorrow."); - } - } - } - } - else if (Game1.currentSeason=="fall"|| Game1.currentSeason == "autumn") - { - if (StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_sunny || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_rain || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_lightning || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_debris) - { //if my weather isn't something special. This is to prevent something from going wierd. - if (randomNumber <= fallRainInt) //if the random variable is less than or equal to the chance for rain. - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_rain; //sets rainy weather tomorrow - if (suppress_log == false) Monitor.Log("It will rain tomorrow."); - } - else - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_sunny;//sets sunny weather tomorrow - if (suppress_log == false) Monitor.Log("It will not rain tomorrow."); - } - - if (StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_rain) - { - if (randomNumber <= fallThunderInt) //if the random variable is less than or equal to the chance for rain. - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_lightning; //sets rainy weather tomorrow - if (suppress_log == false) Monitor.Log("It will be stormy tomorrow."); - } - else - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_rain;//sets sunny weather tomorrow - if (suppress_log == false) Monitor.Log("There will be no lightning tomorrow."); - } - } - } - } - else if (Game1.currentSeason == "winter") - { - if (StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_sunny || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_rain || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_lightning || StardewValley.Game1.weatherForTomorrow == StardewValley.Game1.weather_debris || Game1.weatherForTomorrow==StardewValley.Game1.weather_snow) - { //if my weather isn't something special. This is to prevent something from going wierd. - if (randomNumber <= winterSnowInt) //if the random variable is less than or equal to the chance for rain. - { - StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_snow; //sets rainy weather tomorrow - if (suppress_log == false) Monitor.Log("It will snow tomorrow."); - } - else - { - //StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_sunny;//sets sunny weather tomorrow - if (suppress_log == false) Monitor.Log("It will not snow tomorrow."); - } - } - } - } - - - void MyWritter() - { - //saves the BuildEndurance_data at the end of a new day; - string mylocation = Path.Combine(Helper.DirectoryPath, "More_Rain_Config"); - //string mylocation2 = mylocation + myname; - string mylocation3 = mylocation + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("The data file for More Rain wasn't found. Time to create it!"); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - mystring3[0] = "Player: More Rain Config. Feel free to edit."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Spring Rain chance: The chance out of 100 that it will rain tomorrow."; - mystring3[3] = springRainInt.ToString(); - mystring3[4] = "Spring Storm chance: The chance out of 100 that it will be stormy tomorrow."; - mystring3[5] = springThunderInt.ToString(); - - mystring3[6] = "Summer Rain chance: The chance out of 100 that it will rain tomorrow."; - mystring3[7] = summerRainInt.ToString(); - mystring3[8] = "Summer Storm chance: The chance out of 100 that it will be stormy tomorrow."; - mystring3[9] = summerThunderInt.ToString(); - - mystring3[10] = "Fall Rain chance: The chance out of 100 that it will rain tomorrow."; - mystring3[11] = fallRainInt.ToString(); - mystring3[12] = "Fall Storm chance: The chance out of 100 that it will be stormy tomorrow."; - mystring3[13] = fallThunderInt.ToString(); - - mystring3[14] = "Winter Snow chance: The chance out of 100 that it will rain tomorrow."; - mystring3[15] = winterSnowInt.ToString(); - - - mystring3[16] = "Supress Log: If true, the mod won't output any messages to the console."; - mystring3[17] = suppress_log.ToString(); - - - File.WriteAllLines(mylocation3, mystring3); - } - else - { - Monitor.Log("The data file for More Rain wasn't found. Time to create it!"); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - mystring3[0] = "Player: More Rain Config. Feel free to edit."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Spring Rain chance: The chance out of 100 that it will rain tomorrow."; - mystring3[3] = springRainInt.ToString(); - mystring3[4] = "Spring Storm chance: The chance out of 100 that it will be stormy tomorrow."; - mystring3[5] = springThunderInt.ToString(); - - mystring3[6] = "Summer Rain chance: The chance out of 100 that it will rain tomorrow."; - mystring3[7] = summerRainInt.ToString(); - mystring3[8] = "Summer Storm chance: The chance out of 100 that it will be stormy tomorrow."; - mystring3[9] = summerThunderInt.ToString(); - - mystring3[10] = "Fall Rain chance: The chance out of 100 that it will rain tomorrow."; - mystring3[11] = fallRainInt.ToString(); - mystring3[12] = "Fall Storm chance: The chance out of 100 that it will be stormy tomorrow."; - mystring3[13] = fallThunderInt.ToString(); - - mystring3[14] = "Winter Snow chance: The chance out of 100 that it will rain tomorrow."; - mystring3[15] = winterSnowInt.ToString(); - - - mystring3[16] = "Supress Log: If true, the mod won't output any messages to the console."; - mystring3[17] = suppress_log.ToString(); - - - File.WriteAllLines(mylocation3, mystring3); - } - } - void DataLoader() - { - //loads the data to the variables upon loading the game. - string mylocation = Path.Combine(Helper.DirectoryPath, "More_Rain_Config"); - //string mylocation2 = mylocation + myname; - string mylocation3 = mylocation + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - springRainInt = 15; - summerRainInt = 5; - fallRainInt = 15; - winterSnowInt = 15; - - - springThunderInt = 5; - summerThunderInt = 10; - fallThunderInt = 5; - - suppress_log = true; - MyWritter(); - } - else - { - try - { - string[] readtext = File.ReadAllLines(mylocation3); - springRainInt = Convert.ToInt32(readtext[3]); - springThunderInt = Convert.ToInt32(readtext[5]); - summerRainInt = Convert.ToInt32(readtext[7]); - summerThunderInt = Convert.ToInt32(readtext[9]); - fallRainInt = Convert.ToInt32(readtext[11]); - fallThunderInt = Convert.ToInt32(readtext[13]); - winterSnowInt = Convert.ToInt32(readtext[15]); - suppress_log = Convert.ToBoolean(readtext[17]); - } - catch (Exception e) //something dun goofed - { - springRainInt = 15; - summerRainInt = 5; - fallRainInt = 15; - winterSnowInt = 15; - - - springThunderInt = 5; - summerThunderInt = 10; - fallThunderInt = 5; - - suppress_log = true; - MyWritter(); - } - } - } - } -} diff --git a/GeneralMods/MoreRain/MoreRain.cs b/GeneralMods/MoreRain/MoreRain.cs new file mode 100644 index 00000000..792e84d9 --- /dev/null +++ b/GeneralMods/MoreRain/MoreRain.cs @@ -0,0 +1,293 @@ +using System; +using System.Collections.Generic; +using System.IO; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +namespace Omegasis.MoreRain +{ + /// The mod entry point. + public class MoreRain : Mod + { + /********* + ** Properties + *********/ + /// The weathers that can be safely overridden. + private readonly HashSet NormalWeathers = new HashSet { Game1.weather_sunny, Game1.weather_rain, Game1.weather_lightning, Game1.weather_debris, Game1.weather_snow }; + + /// The chance out of 100 that it will rain tomorrow if it's spring. + private int SpringRainChance; + + /// The chance out of 100 that it will storm tomorrow if it's spring. + private int SpringThunderChance; + + /// The chance out of 100 that it will rain tomorrow if it's summer. + private int SummerRainChance; + + /// The chance out of 100 that it will storm tomorrow if it's summer. + private int SummerThunderChance; + + /// The chance out of 100 that it will rain tomorrow if it's fall. + private int FallRainChance; + + /// The chance out of 100 that it will storm tomorrow if it's fall. + private int FallThunderChance; + + /// The chance out of 100 that it will snow tomorrow if it's winter. + private int WinterSnowChance; + + /// Whether the player loaded a save. + private bool IsGameLoaded; + + /// Whether to suppress verbose logging. + private bool SuppressLog; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + this.LoadConfig(); + } + + + /********* + ** Private methods + *********/ + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + this.IsGameLoaded = true; + this.HandleNewDay(); + } + + /// The method invoked when changes. + /// The event sender. + /// The event data. + private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e) + { + if (this.IsGameLoaded) + this.HandleNewDay(); + } + + /// Update all data for a new day. + private void HandleNewDay() + { + // skip if special weather + if (!this.NormalWeathers.Contains(Game1.weatherForTomorrow)) + { + if (Game1.weatherForTomorrow == Game1.weather_festival) + this.VerboseLog("There is a festival tomorrow, therefore it will not rain."); + else if (Game1.weatherForTomorrow == Game1.weather_wedding) + this.VerboseLog("There is a wedding tomorrow and rain on your wedding day will not happen."); + else + this.VerboseLog("The weather tomorrow is unknown, so it will not rain."); + return; + } + + // set weather + Random random = new Random(); + int chance = random.Next(0, 100); + switch (Game1.currentSeason) + { + case "spring": + // set rain + if (chance <= this.SpringRainChance) + { + Game1.weatherForTomorrow = Game1.weather_rain; + this.VerboseLog("It will rain tomorrow."); + } + else + { + Game1.weatherForTomorrow = Game1.weather_sunny; + this.VerboseLog("It will not rain tomorrow."); + } + + // set storm + if (Game1.weatherForTomorrow == Game1.weather_rain) + { + if (chance <= this.SpringThunderChance) + { + Game1.weatherForTomorrow = Game1.weather_lightning; + this.VerboseLog("It will be stormy tomorrow."); + } + else + { + Game1.weatherForTomorrow = Game1.weather_rain; + this.VerboseLog("There will be no lightning tomorrow."); + } + } + break; + + case "summer": + // set rain + if (chance <= this.SummerRainChance) + { + Game1.weatherForTomorrow = Game1.weather_rain; + this.VerboseLog("It will rain tomorrow."); + } + else + { + Game1.weatherForTomorrow = Game1.weather_sunny; + this.VerboseLog("It will not rain tomorrow."); + } + + // set storm + if (Game1.weatherForTomorrow == Game1.weather_rain) + { + if (chance <= this.SummerThunderChance) + { + Game1.weatherForTomorrow = Game1.weather_lightning; + this.VerboseLog("It will be stormy tomorrow."); + } + else + { + Game1.weatherForTomorrow = Game1.weather_rain; + this.VerboseLog("There will be no lightning tomorrow."); + } + } + break; + + case "fall": + case "autumn": + // set rain + if (chance <= this.FallRainChance) + { + Game1.weatherForTomorrow = Game1.weather_rain; + this.VerboseLog("It will rain tomorrow."); + } + else + { + Game1.weatherForTomorrow = Game1.weather_sunny; + this.VerboseLog("It will not rain tomorrow."); + } + + // set storm + if (Game1.weatherForTomorrow == Game1.weather_rain) + { + if (chance <= this.FallThunderChance) + { + Game1.weatherForTomorrow = Game1.weather_lightning; + this.VerboseLog("It will be stormy tomorrow."); + } + else + { + Game1.weatherForTomorrow = Game1.weather_rain; + this.VerboseLog("There will be no lightning tomorrow."); + } + } + break; + + case "winter": + // set snow + if (chance <= this.WinterSnowChance) + { + Game1.weatherForTomorrow = Game1.weather_snow; + this.VerboseLog("It will snow tomorrow."); + } + else + { + //StardewValley.Game1.weatherForTomorrow = StardewValley.Game1.weather_sunny; + this.VerboseLog("It will not snow tomorrow."); + } + break; + } + } + + /// Save the configuration settings. + void SaveConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "More_Rain_Config.txt"); + string[] text = new string[20]; + text[0] = "Player: More Rain Config. Feel free to edit."; + text[1] = "===================================================================================="; + text[2] = "Spring Rain chance: The chance out of 100 that it will rain tomorrow."; + text[3] = this.SpringRainChance.ToString(); + text[4] = "Spring Storm chance: The chance out of 100 that it will be stormy tomorrow."; + text[5] = this.SpringThunderChance.ToString(); + + text[6] = "Summer Rain chance: The chance out of 100 that it will rain tomorrow."; + text[7] = this.SummerRainChance.ToString(); + text[8] = "Summer Storm chance: The chance out of 100 that it will be stormy tomorrow."; + text[9] = this.SummerThunderChance.ToString(); + + text[10] = "Fall Rain chance: The chance out of 100 that it will rain tomorrow."; + text[11] = this.FallRainChance.ToString(); + text[12] = "Fall Storm chance: The chance out of 100 that it will be stormy tomorrow."; + text[13] = this.FallThunderChance.ToString(); + + text[14] = "Winter Snow chance: The chance out of 100 that it will rain tomorrow."; + text[15] = this.WinterSnowChance.ToString(); + + text[16] = "Supress Log: If true, the mod won't output any messages to the console."; + text[17] = this.SuppressLog.ToString(); + + File.WriteAllLines(path, text); + } + + /// Load the configuration settings. + private void LoadConfig() + { + string path = Path.Combine(Helper.DirectoryPath, $"More_Rain_Config.txt"); + if (!File.Exists(path)) + { + this.SpringRainChance = 15; + this.SummerRainChance = 5; + this.FallRainChance = 15; + this.WinterSnowChance = 15; + + this.SpringThunderChance = 5; + this.SummerThunderChance = 10; + this.FallThunderChance = 5; + + this.SuppressLog = true; + this.SaveConfig(); + } + else + { + try + { + string[] text = File.ReadAllLines(path); + this.SpringRainChance = Convert.ToInt32(text[3]); + this.SpringThunderChance = Convert.ToInt32(text[5]); + this.SummerRainChance = Convert.ToInt32(text[7]); + this.SummerThunderChance = Convert.ToInt32(text[9]); + this.FallRainChance = Convert.ToInt32(text[11]); + this.FallThunderChance = Convert.ToInt32(text[13]); + this.WinterSnowChance = Convert.ToInt32(text[15]); + this.SuppressLog = Convert.ToBoolean(text[17]); + } + catch (Exception) //something dun goofed + { + this.SpringRainChance = 15; + this.SummerRainChance = 5; + this.FallRainChance = 15; + this.WinterSnowChance = 15; + + this.SpringThunderChance = 5; + this.SummerThunderChance = 10; + this.FallThunderChance = 5; + + this.SuppressLog = true; + this.SaveConfig(); + } + } + } + + /// Log a message if is false. + /// The message to log. + private void VerboseLog(string message) + { + if (!this.SuppressLog) + this.Monitor.Log(message); + } + } +} diff --git a/GeneralMods/MoreRain/MoreRain.csproj b/GeneralMods/MoreRain/MoreRain.csproj index 140ab3f4..96853537 100644 --- a/GeneralMods/MoreRain/MoreRain.csproj +++ b/GeneralMods/MoreRain/MoreRain.csproj @@ -34,7 +34,10 @@ - + + Properties\GlobalAssemblyInfo.cs + + diff --git a/GeneralMods/MoreRain/Properties/AssemblyInfo.cs b/GeneralMods/MoreRain/Properties/AssemblyInfo.cs index 08ce49aa..8bd66952 100644 --- a/GeneralMods/MoreRain/Properties/AssemblyInfo.cs +++ b/GeneralMods/MoreRain/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Stardew_More_Rain")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Stardew_More_Rain")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: AssemblyTitle("MoreRain")] [assembly: Guid("45721a43-630a-461f-9a50-e47d3d1926d0")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/MoreRain/README.md b/GeneralMods/MoreRain/README.md index 1269103b..73cb7380 100644 --- a/GeneralMods/MoreRain/README.md +++ b/GeneralMods/MoreRain/README.md @@ -1,24 +1,25 @@ -Stardew Valley MoreRain 1.2.0 +**More Rain** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you adjust the +probability of rain and storms for each season. +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. -Initial Release:v1.0.0 posted on 6/7/16 at 11:34 AM -Updated: 3/2/16 6:51 PM +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/441). +3. Run the game using SMAPI. -Updates: -1.2.0 -Updated the mod to have configurable rain and storm chances for every season except winter. Winter gets a snow chance. +## Usage +Edit `More_Rain_Config.txt` to change the chance of rain, storms, or snow. Each value is a +percentage (0 to 100). -1.1.0 --Updated to SDV 1.1 +It won't rain on days where a wedding or a festival would take place. -1.0.0 --Finally got around to an offical full release of this mod. Basically rewrote it from the ground up. +## Versions +1.0: +* Initial release. -Description -This is the MoreRain mod, which can increase or decrease how much it rains in your game as well as increase the chance to get lightning storms! -I basically wrote this mod a long time ago because some people complained about the rain in Stardew Valley being too spotty, so this adds in a new level of control to the game. - -It will not rain on days where a wedding or a festival would take place, so this mod will ignore those days. - -All of the values that can be configured in More_Rain_Config.txt +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. +1.2: +* Added configurable rain and storm chances for every season (snow chance in winter). diff --git a/GeneralMods/MoreRain/manifest.json b/GeneralMods/MoreRain/manifest.json index 2863d318..a49c5d71 100644 --- a/GeneralMods/MoreRain/manifest.json +++ b/GeneralMods/MoreRain/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "Stardew_More_Rain", "PerSaveConfigs": false, "EntryDll": "MoreRain.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/MuseumRearranger/Class1.cs b/GeneralMods/MuseumRearranger/Class1.cs deleted file mode 100644 index 19b3f4eb..00000000 --- a/GeneralMods/MuseumRearranger/Class1.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.IO; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.MuseumRearranger -{ - public class Class1 : Mod - { - string key_binding = "R"; - string key_binding2 = "T"; - public static bool showMenu; - bool game_loaded = false; - - public override void Entry(IModHelper helper) - { - //set up all of my events here - StardewModdingAPI.Events.SaveEvents.AfterLoad += PlayerEvents_LoadedGame; - StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; - } - - public void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) - { - if (Game1.player == null) return; - if (Game1.player.currentLocation == null) return; - if (game_loaded == false) return; - - if (e.KeyPressed.ToString() == key_binding) //if the key is pressed, load my cusom save function - { - if (Game1.activeClickableMenu != null) return; - if (StardewValley.Game1.player.currentLocation.name == "ArchaeologyHouse") Game1.activeClickableMenu = new NewMuseumMenu(); - else Monitor.Log("You can't rearrange the museum here!"); - } - if (e.KeyPressed.ToString() == key_binding2) //if the key is pressed, load my cusom save function - { - if (showMenu == true) showMenu = false; - else showMenu = true; - // Log.AsyncC(showMenu); - } - } - - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - game_loaded = true; - showMenu = true; - DataLoader_Settings(); - MyWritter_Settings(); - } - - void DataLoader_Settings() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "Museum_Rearrange_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - key_binding = "R"; - key_binding2 = "T"; - } - - else - { - string[] readtext = File.ReadAllLines(mylocation3); - key_binding = Convert.ToString(readtext[3]); - key_binding2 = Convert.ToString(readtext[5]); - } - } - - void MyWritter_Settings() - { - //write all of my info to a text file. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "Museum_Rearrange_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("Museum Rearranger: Config not found. Creating it now."); - - mystring3[0] = "Config: Museum_Rearranger. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Key binding for rearranging the museum."; - mystring3[3] = key_binding.ToString(); - mystring3[4] = "Key binding for showing the menu when rearranging the museum."; - mystring3[5] = key_binding2.ToString(); - File.WriteAllLines(mylocation3, mystring3); - } - else - { - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - mystring3[0] = "Config: Save_Anywhere Info. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Key binding for rearranging the museum."; - mystring3[3] = key_binding.ToString(); - mystring3[4] = "Key binding for showing the menu when rearranging the museum."; - mystring3[5] = key_binding2.ToString(); - File.WriteAllLines(mylocation3, mystring3); - } - } - } -} -//end class \ No newline at end of file diff --git a/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs b/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs new file mode 100644 index 00000000..f18c3185 --- /dev/null +++ b/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs @@ -0,0 +1,67 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Locations; +using StardewValley.Menus; + +namespace Omegasis.MuseumRearranger.Framework +{ + /// A subclass of which adds support for toggling the inventory box. + internal class NewMuseumMenu : MuseumMenu + { + /********* + ** Properties + *********/ + /// Whether to show the inventory screen. + private bool ShowInventory = true; + + /// A reference to a private field for use in the overridden draw code. + private readonly IPrivateField HoldingMuseumPiece; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// Simplifies access to private game code. + public NewMuseumMenu(IReflectionHelper reflection) + { + this.HoldingMuseumPiece = reflection.GetPrivateField(this, "holdingMuseumPiece"); + } + + /// Toggle the inventory box. + public void ToggleInventory() + { + this.ShowInventory = !this.ShowInventory; + } + + /// Draw the menu to the screen. + /// The sprite batch being drawn. + public override void draw(SpriteBatch b) + { + if ((this.fadeTimer <= 0 || !this.fadeIntoBlack) && this.state != 3) + { + if (this.heldItem != null) + { + for (int i = Game1.viewport.Y / Game1.tileSize - 1; i < (Game1.viewport.Y + Game1.viewport.Height) / Game1.tileSize + 2; i++) + { + for (int j = Game1.viewport.X / Game1.tileSize - 1; j < (Game1.viewport.X + Game1.viewport.Width) / Game1.tileSize + 1; j++) + { + if (((LibraryMuseum)Game1.currentLocation).isTileSuitableForMuseumPiece(j, i)) + b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(j, i) * Game1.tileSize), Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 29), Color.LightGreen); + } + } + } + if (!this.HoldingMuseumPiece.GetValue() && this.ShowInventory) + base.draw(b, false, false); + if (!this.hoverText.Equals("")) + IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont); + this.heldItem?.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 8, Game1.getOldMouseY() + 8), 1f); + base.drawMouse(b); + this.sparkleText?.draw(b, Game1.GlobalToLocal(Game1.viewport, this.globalLocationOfSparklingArtifact)); + } + b.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * this.blackFadeAlpha); + } + } +} diff --git a/GeneralMods/MuseumRearranger/MuseumRearranger.cs b/GeneralMods/MuseumRearranger/MuseumRearranger.cs new file mode 100644 index 00000000..5efaf879 --- /dev/null +++ b/GeneralMods/MuseumRearranger/MuseumRearranger.cs @@ -0,0 +1,110 @@ +using System; +using System.IO; +using Omegasis.MuseumRearranger.Framework; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; +using StardewValley.Locations; + +namespace Omegasis.MuseumRearranger +{ + /// The mod entry point. + public class MuseumRearranger : Mod + { + /********* + ** Properties + *********/ + /// The key which shows the museum rearranging menu. + private string ShowMenuKey = "R"; + + /// The key which toggles the inventory box when the menu is open. + private string ToggleInventoryKey = "T"; + + /// Whether the player loaded a save. + private bool IsGameLoaded; + + /// The open museum menu (if any). + private NewMuseumMenu OpenMenu; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + } + + + /********* + ** Private methods + *********/ + /// The method invoked when the presses a keyboard button. + /// The event sender. + /// The event data. + private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + { + if (Game1.player == null || Game1.player.currentLocation == null || !this.IsGameLoaded) + return; + + // open menu + if (e.KeyPressed.ToString() == this.ShowMenuKey) + { + if (Game1.activeClickableMenu != null) + return; + if (Game1.player.currentLocation is LibraryMuseum) + Game1.activeClickableMenu = this.OpenMenu = new NewMuseumMenu(this.Helper.Reflection); + else + this.Monitor.Log("You can't rearrange the museum here."); + } + + // toggle inventory box + if (e.KeyPressed.ToString() == this.ToggleInventoryKey) + this.OpenMenu?.ToggleInventory(); + } + + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + this.IsGameLoaded = true; + this.LoadConfig(); + this.WriteConfig(); + } + + /// Load the configuration settings. + private void LoadConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Museum_Rearrange_Config.txt"); + if (!File.Exists(path)) + { + this.ShowMenuKey = "R"; + this.ToggleInventoryKey = "T"; + } + else + { + string[] text = File.ReadAllLines(path); + this.ShowMenuKey = Convert.ToString(text[3]); + this.ToggleInventoryKey = Convert.ToString(text[5]); + } + } + + /// Save the configuration settings. + private void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Museum_Rearrange_Config.txt"); + string[] text = new string[20]; + text[0] = "Config: Museum_Rearranger. Feel free to mess with these settings."; + text[1] = "===================================================================================="; + text[2] = "Key binding for rearranging the museum."; + text[3] = this.ShowMenuKey; + text[4] = "Key binding for showing the menu when rearranging the museum."; + text[5] = this.ToggleInventoryKey; + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/MuseumRearranger/MuseumRearranger.csproj b/GeneralMods/MuseumRearranger/MuseumRearranger.csproj index e77afd8b..d551b058 100644 --- a/GeneralMods/MuseumRearranger/MuseumRearranger.csproj +++ b/GeneralMods/MuseumRearranger/MuseumRearranger.csproj @@ -36,15 +36,17 @@ - - - + + Properties\GlobalAssemblyInfo.cs + + + - + diff --git a/GeneralMods/MuseumRearranger/NewMenuWithInventory.cs b/GeneralMods/MuseumRearranger/NewMenuWithInventory.cs deleted file mode 100644 index 677a4553..00000000 --- a/GeneralMods/MuseumRearranger/NewMenuWithInventory.cs +++ /dev/null @@ -1,230 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewValley; -using StardewValley.Menus; - -namespace Omegasis.MuseumRearranger -{ - public class NewMenuWithInventory : IClickableMenu - { - public string descriptionText = ""; - - public string hoverText = ""; - - public string descriptionTitle = ""; - - public InventoryMenu inventory; - - public Item heldItem; - - public Item hoveredItem; - - public int wiggleWordsTimer; - - public ClickableTextureComponent okButton; - - public ClickableTextureComponent trashCan; - - public float trashCanLidRotation; - - public NewMenuWithInventory(InventoryMenu.highlightThisItem highlighterMethod = null, bool okButton = false, bool trashCan = false, int inventoryXOffset = 0, int inventoryYOffset = 0) : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2 + Game1.tileSize, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, false) - { - if (this.yPositionOnScreen < IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder) - { - this.yPositionOnScreen = IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder; - } - if (this.xPositionOnScreen < 0) - { - this.xPositionOnScreen = 0; - } - int yPosition = this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 - Game1.tileSize / 4 + inventoryYOffset; - this.inventory = new InventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth / 2 + inventoryXOffset, yPosition, false, null, highlighterMethod, -1, 3, 0, 0, true); - if (okButton) - { - this.okButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false); - } - if (trashCan) - { - this.trashCan = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize * 3 - Game1.tileSize / 2 - IClickableMenu.borderWidth - 104, Game1.tileSize, 104), Game1.mouseCursors, new Rectangle(669, 261, 16, 26), (float)Game1.pixelZoom, false); - } - } - - public void movePosition(int dx, int dy) - { - this.xPositionOnScreen += dx; - this.yPositionOnScreen += dy; - this.inventory.movePosition(dx, dy); - if (this.okButton != null) - { - ClickableTextureComponent expr_41_cp_0_cp_0 = this.okButton; - expr_41_cp_0_cp_0.bounds.X = expr_41_cp_0_cp_0.bounds.X + dx; - ClickableTextureComponent expr_56_cp_0_cp_0 = this.okButton; - expr_56_cp_0_cp_0.bounds.Y = expr_56_cp_0_cp_0.bounds.Y + dy; - } - if (this.trashCan != null) - { - ClickableTextureComponent expr_73_cp_0_cp_0 = this.trashCan; - expr_73_cp_0_cp_0.bounds.X = expr_73_cp_0_cp_0.bounds.X + dx; - ClickableTextureComponent expr_88_cp_0_cp_0 = this.trashCan; - expr_88_cp_0_cp_0.bounds.Y = expr_88_cp_0_cp_0.bounds.Y + dy; - } - } - - public override bool readyToClose() - { - return this.heldItem == null; - } - - public override bool isWithinBounds(int x, int y) - { - return base.isWithinBounds(x, y); - } - - public override void receiveLeftClick(int x, int y, bool playSound = true) - { - this.heldItem = this.inventory.leftClick(x, y, this.heldItem, playSound); - if (!this.isWithinBounds(x, y) && this.readyToClose() && this.trashCan != null) - { - this.trashCan.containsPoint(x, y); - } - if (this.okButton != null && this.okButton.containsPoint(x, y) && this.readyToClose()) - { - base.exitThisMenu(true); - if (Game1.currentLocation.currentEvent != null) - { - Event expr_7E = Game1.currentLocation.currentEvent; - int currentCommand = expr_7E.CurrentCommand; - expr_7E.CurrentCommand = currentCommand + 1; - } - Game1.playSound("bigDeSelect"); - } - if (this.trashCan != null && this.trashCan.containsPoint(x, y) && this.heldItem != null && this.heldItem.canBeTrashed()) - { - if (this.heldItem is StardewValley.Object && Game1.player.specialItems.Contains((this.heldItem as StardewValley.Object).parentSheetIndex)) - { - Game1.player.specialItems.Remove((this.heldItem as StardewValley.Object).parentSheetIndex); - } - this.heldItem = null; - Game1.playSound("trashcan"); - } - } - - public override void receiveRightClick(int x, int y, bool playSound = true) - { - this.heldItem = this.inventory.rightClick(x, y, this.heldItem, playSound); - } - - public override void performHoverAction(int x, int y) - { - this.descriptionText = ""; - this.descriptionTitle = ""; - this.hoveredItem = this.inventory.hover(x, y, this.heldItem); - this.hoverText = this.inventory.hoverText; - if (this.okButton != null) - { - if (this.okButton.containsPoint(x, y)) - { - this.okButton.scale = Math.Min(1.1f, this.okButton.scale + 0.05f); - } - else - { - this.okButton.scale = Math.Max(1f, this.okButton.scale - 0.05f); - } - } - if (this.trashCan != null) - { - if (this.trashCan.containsPoint(x, y)) - { - if (this.trashCanLidRotation <= 0f) - { - Game1.playSound("trashcanlid"); - } - this.trashCanLidRotation = Math.Min(this.trashCanLidRotation + 0.06544985f, 1.57079637f); - return; - } - this.trashCanLidRotation = Math.Max(this.trashCanLidRotation - 0.06544985f, 0f); - } - } - - public override void update(GameTime time) - { - if (this.wiggleWordsTimer > 0) - { - this.wiggleWordsTimer -= time.ElapsedGameTime.Milliseconds; - } - } - - public virtual void draw(SpriteBatch b, bool drawUpperPortion = true, bool drawDescriptionArea = true) - { - if (this.trashCan != null) - { - this.trashCan.draw(b); - b.Draw(Game1.mouseCursors, new Vector2((float)(this.trashCan.bounds.X + 60), (float)(this.trashCan.bounds.Y + 40)), new Rectangle?(new Rectangle(686, 256, 18, 10)), Color.White, this.trashCanLidRotation, new Vector2(16f, 10f), (float)Game1.pixelZoom, SpriteEffects.None, 0.86f); - } - if (Class1.showMenu == true) - { - if (drawUpperPortion) - { - Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true, null, false); - base.drawHorizontalPartition(b, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 4 * Game1.tileSize, false); - if (drawDescriptionArea) - { - base.drawVerticalUpperIntersectingPartition(b, this.xPositionOnScreen + Game1.tileSize * 9, 5 * Game1.tileSize + Game1.tileSize / 8); - if (!this.descriptionText.Equals("")) - { - int num = this.xPositionOnScreen + Game1.tileSize * 9 + Game1.tileSize * 2 / 3 + ((this.wiggleWordsTimer > 0) ? Game1.random.Next(-2, 3) : 0); - int num2 = this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 2 + ((this.wiggleWordsTimer > 0) ? Game1.random.Next(-2, 3) : 0); - b.DrawString(Game1.smallFont, Game1.parseText(this.descriptionText, Game1.smallFont, Game1.tileSize * 3 + Game1.tileSize / 2), new Vector2((float)num, (float)num2), Game1.textColor * 0.75f); - } - } - } - else - { - Game1.drawDialogueBox(this.xPositionOnScreen - IClickableMenu.borderWidth / 2, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize, this.width, this.height - (IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 3 * Game1.tileSize), false, true, null, false); - } - - if (this.okButton != null) - { - this.okButton.draw(b); - } - this.inventory.draw(b); - } - else - { - if (this.okButton != null) - { - this.okButton.draw(b); - } - } - } - - public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) - { - base.gameWindowSizeChanged(oldBounds, newBounds); - if (this.yPositionOnScreen < IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder) - { - this.yPositionOnScreen = IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder; - } - if (this.xPositionOnScreen < 0) - { - this.xPositionOnScreen = 0; - } - int yPosition = this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 - Game1.tileSize / 4; - this.inventory = new InventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth / 2, yPosition, false, null, this.inventory.highlightMethod, -1, 3, 0, 0, true); - if (this.okButton != null) - { - this.okButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false); - } - if (this.trashCan != null) - { - this.trashCan = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize * 3 - Game1.tileSize / 2 - IClickableMenu.borderWidth - 104, Game1.tileSize, 104), Game1.mouseCursors, new Rectangle(669, 261, 16, 26), (float)Game1.pixelZoom, false); - } - } - - public override void draw(SpriteBatch b) - { - throw new NotImplementedException(); - } - } -} diff --git a/GeneralMods/MuseumRearranger/NewMuseumMenu.cs b/GeneralMods/MuseumRearranger/NewMuseumMenu.cs deleted file mode 100644 index 1b530d84..00000000 --- a/GeneralMods/MuseumRearranger/NewMuseumMenu.cs +++ /dev/null @@ -1,293 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using StardewValley; -using StardewValley.BellsAndWhistles; -using StardewValley.Locations; -using StardewValley.Menus; -using xTile.Dimensions; - -namespace Omegasis.MuseumRearranger -{ - public class NewMuseumMenu : NewMenuWithInventory - { - public const int startingState = 0; - - public const int placingInMuseumState = 1; - - public const int exitingState = 2; - - public int fadeTimer; - - public int state; - - public int menuPositionOffset; - - public bool fadeIntoBlack; - - public bool menuMovingDown; - - public float blackFadeAlpha; - - public SparklingText sparkleText; - - public Vector2 globalLocationOfSparklingArtifact; - - private bool holdingMuseumPiece; - - public NewMuseumMenu() : base(new InventoryMenu.highlightThisItem((Game1.currentLocation as LibraryMuseum).isItemSuitableForDonation), true, false, 0, 0) - { - this.fadeTimer = 800; - this.fadeIntoBlack = true; - base.movePosition(0, Game1.viewport.Height - this.yPositionOnScreen - this.height); - Game1.player.forceCanMove(); - } - - public override void receiveKeyPress(Keys key) - { - if (this.fadeTimer <= 0) - { - if (Game1.options.doesInputListContain(Game1.options.menuButton, key) && this.readyToClose()) - { - this.state = 2; - this.fadeTimer = 500; - this.fadeIntoBlack = true; - } - if (Game1.options.doesInputListContain(Game1.options.moveDownButton, key)) - { - Game1.panScreen(0, 4); - return; - } - if (Game1.options.doesInputListContain(Game1.options.moveRightButton, key)) - { - Game1.panScreen(4, 0); - return; - } - if (Game1.options.doesInputListContain(Game1.options.moveUpButton, key)) - { - Game1.panScreen(0, -4); - return; - } - if (Game1.options.doesInputListContain(Game1.options.moveLeftButton, key)) - { - Game1.panScreen(-4, 0); - } - } - } - - public override void receiveLeftClick(int x, int y, bool playSound = true) - { - if (this.fadeTimer <= 0) - { - Item heldItem = this.heldItem; - if (!this.holdingMuseumPiece) - { - this.heldItem = this.inventory.leftClick(x, y, this.heldItem, true); - } - if (heldItem != null && this.heldItem != null && (y < Game1.viewport.Height - (this.height - (IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 3 * Game1.tileSize)) || this.menuMovingDown)) - { - int num = (x + Game1.viewport.X) / Game1.tileSize; - int num2 = (y + Game1.viewport.Y) / Game1.tileSize; - if ((Game1.currentLocation as LibraryMuseum).isTileSuitableForMuseumPiece(num, num2) && (Game1.currentLocation as LibraryMuseum).isItemSuitableForDonation(this.heldItem)) - { - int count = (Game1.currentLocation as LibraryMuseum).getRewardsForPlayer(Game1.player).Count; - (Game1.currentLocation as LibraryMuseum).museumPieces.Add(new Vector2((float)num, (float)num2), (this.heldItem as StardewValley.Object).parentSheetIndex); - Game1.playSound("stoneStep"); - this.holdingMuseumPiece = false; - if ((Game1.currentLocation as LibraryMuseum).getRewardsForPlayer(Game1.player).Count > count) - { - this.sparkleText = new SparklingText(Game1.dialogueFont, "New Reward!", Color.MediumSpringGreen, Color.White, false, 0.1, 2500, -1, 500); - Game1.playSound("reward"); - this.globalLocationOfSparklingArtifact = new Vector2((float)(num * Game1.tileSize + Game1.tileSize / 2) - this.sparkleText.textWidth / 2f, (float)(num2 * Game1.tileSize - Game1.tileSize * 3 / 4)); - } - else - { - Game1.playSound("newArtifact"); - } - Game1.player.completeQuest(24); - Item expr_1DE = this.heldItem; - int stack = expr_1DE.Stack; - expr_1DE.Stack = stack - 1; - if (this.heldItem.Stack <= 0) - { - this.heldItem = null; - } - this.menuMovingDown = false; - int count2 = (Game1.currentLocation as LibraryMuseum).museumPieces.Count; - if (count2 >= 95) - { - Game1.getAchievement(5); - } - else if (count2 >= 40) - { - Game1.getAchievement(28); - } - } - } - else if (this.heldItem == null) - { - int num3 = (x + Game1.viewport.X) / Game1.tileSize; - int num4 = (y + Game1.viewport.Y) / Game1.tileSize; - Vector2 key = new Vector2((float)num3, (float)num4); - if ((Game1.currentLocation as LibraryMuseum).museumPieces.ContainsKey(key)) - { - this.heldItem = new StardewValley.Object((Game1.currentLocation as LibraryMuseum).museumPieces[key], 1, false, -1, 0); - (Game1.currentLocation as LibraryMuseum).museumPieces.Remove(key); - this.holdingMuseumPiece = true; - } - } - if (this.heldItem != null && heldItem == null) - { - this.menuMovingDown = true; - } - if (this.okButton != null && this.okButton.containsPoint(x, y) && this.readyToClose()) - { - this.state = 2; - this.fadeTimer = 800; - this.fadeIntoBlack = true; - Game1.playSound("bigDeSelect"); - } - } - } - - public override void receiveRightClick(int x, int y, bool playSound = true) - { - Item heldItem = this.heldItem; - if (this.fadeTimer <= 0) - { - base.receiveRightClick(x, y, true); - } - if (this.heldItem != null && heldItem == null) - { - this.menuMovingDown = true; - } - } - - public override void update(GameTime time) - { - base.update(time); - if (this.sparkleText != null && this.sparkleText.update(time)) - { - this.sparkleText = null; - } - if (this.fadeTimer > 0) - { - this.fadeTimer -= time.ElapsedGameTime.Milliseconds; - if (this.fadeIntoBlack) - { - this.blackFadeAlpha = 0f + (1500f - (float)this.fadeTimer) / 1500f; - } - else - { - this.blackFadeAlpha = 1f - (1500f - (float)this.fadeTimer) / 1500f; - } - if (this.fadeTimer <= 0) - { - switch (this.state) - { - case 0: - this.state = 1; - Game1.viewportFreeze = true; - Game1.viewport.Location = new Location(18 * Game1.tileSize, 2 * Game1.tileSize); - Game1.clampViewportToGameMap(); - this.fadeTimer = 800; - this.fadeIntoBlack = false; - break; - case 2: - Game1.viewportFreeze = false; - this.fadeIntoBlack = false; - this.fadeTimer = 800; - this.state = 3; - break; - case 3: - Game1.exitActiveMenu(); - break; - } - } - } - if (this.menuMovingDown && this.menuPositionOffset < this.height / 3) - { - this.menuPositionOffset += 8; - base.movePosition(0, 8); - } - else if (!this.menuMovingDown && this.menuPositionOffset > 0) - { - this.menuPositionOffset -= 8; - base.movePosition(0, -8); - } - int num = Game1.getOldMouseX() + Game1.viewport.X; - int num2 = Game1.getOldMouseY() + Game1.viewport.Y; - if (num - Game1.viewport.X < Game1.tileSize) - { - Game1.panScreen(-4, 0); - } - else if (num - (Game1.viewport.X + Game1.viewport.Width) >= -Game1.tileSize) - { - Game1.panScreen(4, 0); - } - if (num2 - Game1.viewport.Y < Game1.tileSize) - { - Game1.panScreen(0, -4); - } - else if (num2 - (Game1.viewport.Y + Game1.viewport.Height) >= -Game1.tileSize) - { - Game1.panScreen(0, 4); - if (this.menuMovingDown) - { - this.menuMovingDown = false; - } - } - Keys[] pressedKeys = Game1.oldKBState.GetPressedKeys(); - for (int i = 0; i < pressedKeys.Length; i++) - { - Keys key = pressedKeys[i]; - this.receiveKeyPress(key); - } - } - - public override void gameWindowSizeChanged(Microsoft.Xna.Framework.Rectangle oldBounds, Microsoft.Xna.Framework.Rectangle newBounds) - { - base.gameWindowSizeChanged(oldBounds, newBounds); - base.movePosition(0, Game1.viewport.Height - this.yPositionOnScreen - this.height); - Game1.player.forceCanMove(); - } - - public override void draw(SpriteBatch b) - { - if ((this.fadeTimer <= 0 || !this.fadeIntoBlack) && this.state != 3) - { - if (this.heldItem != null) - { - for (int i = Game1.viewport.Y / Game1.tileSize - 1; i < (Game1.viewport.Y + Game1.viewport.Height) / Game1.tileSize + 2; i++) - { - for (int j = Game1.viewport.X / Game1.tileSize - 1; j < (Game1.viewport.X + Game1.viewport.Width) / Game1.tileSize + 1; j++) - { - if ((Game1.currentLocation as LibraryMuseum).isTileSuitableForMuseumPiece(j, i)) - { - b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)j, (float)i) * (float)Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 29, -1, -1)), Color.LightGreen); - } - } - } - } - if (!this.holdingMuseumPiece) - { - base.draw(b, false, false); - } - if (!this.hoverText.Equals("")) - { - IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, 0, 0, -1, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null); - } - if (this.heldItem != null) - { - this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + 8), (float)(Game1.getOldMouseY() + 8)), 1f); - } - base.drawMouse(b); - if (this.sparkleText != null) - { - this.sparkleText.draw(b, Game1.GlobalToLocal(Game1.viewport, this.globalLocationOfSparklingArtifact)); - } - } - b.Draw(Game1.fadeToBlackRect, new Microsoft.Xna.Framework.Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * this.blackFadeAlpha); - } - } -} diff --git a/GeneralMods/MuseumRearranger/Properties/AssemblyInfo.cs b/GeneralMods/MuseumRearranger/Properties/AssemblyInfo.cs index d6213719..ca0dcf14 100644 --- a/GeneralMods/MuseumRearranger/Properties/AssemblyInfo.cs +++ b/GeneralMods/MuseumRearranger/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Museum_Rearranger")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Museum_Rearranger")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: AssemblyTitle("MuseumRearranger")] [assembly: Guid("920d74fe-156f-4321-b461-5ac7ed7ef9c9")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/MuseumRearranger/ReadMe.md b/GeneralMods/MuseumRearranger/ReadMe.md index 610aaad2..b6795beb 100644 --- a/GeneralMods/MuseumRearranger/ReadMe.md +++ b/GeneralMods/MuseumRearranger/ReadMe.md @@ -1,23 +1,25 @@ -Museum Rearranger 1.1.0 +**Museum Rearranger** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you rearrange +donated items in the museum by pressing a key, even if you don't have a new item to donate. -Initial Release 7/12/16 1:52 AM -Updated: 10/11/16 11:51 PM +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. -Compatability: -SDV 1.1 -Windows +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/428). +3. Run the game using SMAPI. -Updates: -1.1.0 --Updated to SDV 1.1 --Added in a new key config for toggling if the inventory displays while rearranging the museum. Press T by default to toggle showing the menu. +## Usage +Press `R` while in the museum to open the rearranging menu. Press `T` while the menu is open to +toggle the inventory box. Edit `Museum_Rearrange_Config.txt` to change the keys. + +## Versions +1.0: +* Initial release. 1.0.2 --Massively rewrote some code because it was super necessary. --Fixed some typoes with the config files. +* Massively rewrote some code because it was super necessary. +* Fixed typos in the config files. -This is the museum rearranger mod! This mod allows you to rearrange the museum without having to have something to donate! - -Simply press the R key while inside the museum and you will be able to make the museum look however you like! - -That's pretty much it. I haven't found any issues thus far, so feel free to go at it! +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. +* Added key to toggle the inventory box while rearranging the museum. diff --git a/GeneralMods/MuseumRearranger/manifest.json b/GeneralMods/MuseumRearranger/manifest.json index 68af2b91..d9931291 100644 --- a/GeneralMods/MuseumRearranger/manifest.json +++ b/GeneralMods/MuseumRearranger/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "Museum_Rearranger", "PerSaveConfigs": false, "EntryDll": "MuseumRearranger.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/NightOwl/Class1.cs b/GeneralMods/NightOwl/Class1.cs deleted file mode 100644 index 15350ea7..00000000 --- a/GeneralMods/NightOwl/Class1.cs +++ /dev/null @@ -1,446 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Newtonsoft.Json; -using StardewModdingAPI; -using StardewValley; - -/*TODO: -*/ -/* -Issues: --Mail can't be wiped without destroying all mail. --Lighting transition does not work if it is raining. - -set the weather to clear if you are stayig up late. - -transition still doesnt work. However atleast it is dark now. - --Known glitched - -*/ - - - -namespace Omegasis.NightOwl -{ - public class Class1 : Mod - { - int player_x; - int player_y; - string prior_map; - - bool reset_check; - bool was_raining; - bool time_reset; - int prior_money; - int post_money; - float pre_stam; - int pre_health; - - bool lighting_transition; //if true transition happens. If false, game starts out bright at 2AM. Good to remove that awkward change from dark to bright. - bool warp; - bool stay_up; - - bool wipe_mail; - bool protect_money; - bool persistant_health; - bool persistant_stamina; - - bool game_loaded; - - bool once; - bool up_late; - - bool first_check; - - bool warped_check; - - bool super_map_warping_check; - - - - public static string ModPath; - public static string Error_Path; - public override void Entry(IModHelper helper) - { - StardewModdingAPI.Events.TimeEvents.TimeOfDayChanged += TimeEvents_TimeOfDayChanged; - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged; - StardewModdingAPI.Events.SaveEvents.AfterLoad += PlayerEvents_LoadedGame; - StardewModdingAPI.Events.GameEvents.FourthUpdateTick += GameEvents_FourthUpdateTick; - ModPath =Helper.DirectoryPath; - Error_Path = Path.Combine(ModPath, "Error_Logs"); - } - - - public void GameEvents_FourthUpdateTick(object sender, EventArgs e) - { - /* - IMPLEMENT TRY CATCH SYSTEM HERE; - - */ - try - { - - if (Game1.eventUp == true) return; - if (game_loaded == false) return; - - if (Game1.timeOfDay == 600) - { - if (once==true) - { - // Log.AsyncM("NEW MONEY" + Game1.player.money); - // Game1.player.money = Game1.player.money + post_money; - once = false; - } - - } - if (warped_check == false) - { - if (warp == true) - { - Monitor.Log("Warping!!!"); - if (prior_map == null) - { - warped_check = true; - super_map_warping_check = true; - return; - } - Game1.warpFarmer(prior_map, player_x, player_y, false); - warped_check = true; - super_map_warping_check = true; - prior_map = null; - } - - } - } - catch (Exception ex) - { - try - { - Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer(); - serializer.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; - serializer.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All; - serializer.Formatting = Newtonsoft.Json.Formatting.Indented; - serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - using (StreamWriter sw = new StreamWriter(Path.Combine(Error_Path, "Mod_State.json"))) - { - using (Newtonsoft.Json.JsonWriter writer2 = new Newtonsoft.Json.JsonTextWriter(sw)) - { - serializer.Serialize(writer2, this); - } - } - } - catch (Exception exc) - { - Monitor.Log(exc.ToString()); - } - } - } - - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - DataLoader(); - MyWritter(); - game_loaded = true; - once = false; - up_late = false; - first_check = false; - warped_check = true; - super_map_warping_check = true; - } - - public void TimeEvents_DayOfMonthChanged(object sender, StardewModdingAPI.Events.EventArgsIntChanged e) - { - /* - IMPLEMENT TRY CATCH SYSTEM HERE - - */ - try { - - if (game_loaded == false) return; - if (first_check == false) - { - first_check = true; - Monitor.Log("first"); - return; - } - else - { - first_check = false; - Monitor.Log("Second"); - } - if(Game1.farmerShouldPassOut== true) Game1.farmerShouldPassOut = false; //make the farmer collapse. - - reset_check = false; - //Game1.farmerShouldPassOut = false; //make the farmer collapse. - DataLoader(); - MyWritter(); - //List newmail = new List(); - Queue newmail = new Queue(); - - up_late = false; - - if (time_reset == true) - { - was_raining = false; - if (persistant_stamina==true) Game1.player.stamina = pre_stam; //reset health and stam upon collapsing - if (persistant_health == true) Game1.player.health = pre_health; - //post_money = Game1.player.money; - if (protect_money == true) { - - Game1.player.money += post_money; - once = true; - - - } //add the money back from colapsing. - time_reset = false; //reset my bool. - if(warp==true)Game1.warpFarmer(prior_map, player_x, player_y, false); - // very_old_money = (safety_cash - Game1.player.money); - //Game1.player.money += very_old_money; - } - - if (wipe_mail == true) - { - foreach (var i in Game1.mailbox) //delete those annoying charge messages. If only I could do this with mail IRL. - { - Monitor.Log(i); - - if (i.Contains("passedOut")) - { - Monitor.Log("Found bad mail"); - } - else { - newmail.Enqueue(i); - } - } - Game1.mailbox.Clear(); - foreach (string mail in newmail) - { - Game1.mailbox.Enqueue(mail); - } - } - warped_check = false; - //prior_map==null; //prevents multiple warping when sleeping - } - catch (Exception ex) - { - try - { - Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer(); - serializer.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; - serializer.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All; - serializer.Formatting = Newtonsoft.Json.Formatting.Indented; - serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - using (StreamWriter sw = new StreamWriter(Path.Combine(Error_Path, "Mod_State.json"))) - { - using (Newtonsoft.Json.JsonWriter writer2 = new Newtonsoft.Json.JsonTextWriter(sw)) - { - serializer.Serialize(writer2, this); - } - } - } - catch (Exception exc) - { - Monitor.Log(exc.ToString()); - } - } - } - - - public void TimeEvents_TimeOfDayChanged(object sender, StardewModdingAPI.Events.EventArgsIntChanged e) - { - /* - Implement try catch system here. - - */ - try { - if (game_loaded == false) return; - float color_mod; - //transition the lighting for more "realistic" lighting from 2am to 11am. There is an awkward screen shuffle that happens because of this update. - - if (lighting_transition == true) - { - if (Game1.timeOfDay > 400 && Game1.timeOfDay < 600) - { - color_mod = (1300 - Game1.timeOfDay) / 1000f; //.7f - Game1.outdoorLight = Game1.ambientLight * color_mod; - - } - } - - - if (stay_up == true) - { - if (Game1.timeOfDay == 2550) - { - if (StardewValley.Game1.isRaining == true) - { - was_raining = true; - StardewValley.Game1.isRaining = false; //regardless make sure I change the weather. Otherwise lighting gets screwy. - } - StardewValley.Game1.updateWeatherIcon(); - Game1.timeOfDay = 150; //change it from 1:50 am late, to 1:50 am early - } - } - - - if (Game1.timeOfDay == 550) //if the game time is 5:50 AM - { - up_late = true; - } - - if (Game1.timeOfDay == 600) //when time is 6:00 AM after staying up - { - - if (up_late == false) - { - return; - } - - - if (super_map_warping_check == true) - { - if (Game1.currentMinigame != null) Game1.currentMinigame = null; - //if (time_reset == false) return; - time_reset = true; - player_x = Game1.player.getTileX(); - player_y = Game1.player.getTileY(); - prior_map = Game1.player.currentLocation.name; - - Monitor.Log(prior_map); - Monitor.Log(player_x.ToString()); - Monitor.Log(player_y.ToString()); - super_map_warping_check = false; - - - Game1.farmerShouldPassOut = true; //make the farmer collapse. - - pre_stam = Game1.player.stamina; - pre_health = Game1.player.health; - prior_money = Game1.player.money; - - if (Game1.player.money <= 10000) - { - post_money = prior_money / 10; - } - else - { - post_money = 1000; - } - } - } - } - catch (Exception ex) - { - try - { - Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer(); - serializer.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; - serializer.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All; - serializer.Formatting = Newtonsoft.Json.Formatting.Indented; - serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - using (StreamWriter sw = new StreamWriter(Path.Combine(Error_Path, "Mod_State.json"))) - { - using (Newtonsoft.Json.JsonWriter writer2 = new Newtonsoft.Json.JsonTextWriter(sw)) - { - serializer.Serialize(writer2, this); - } - } - } - catch (Exception exc) - { - Monitor.Log(exc.ToString()); - } - } - } - - - void MyWritter() - { - //saves the BuildEndurance_data at the end of a new day; - string myname = Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "Night_Owl_Config_"); - //string mylocation2 = mylocation + myname; - string mylocation3 = mylocation + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Monitor.Log("The data file for Night Owl wasn't found. Time to create it!"); - mystring3[0] = "Player: Night Owl Config. Feel free to edit."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Stay up to 6 AM?: Do you wan't to stay up till 6 AM the next morning?"; - mystring3[3] = stay_up.ToString(); - mystring3[4] = "Custom Lighting Transition?: Do you want to have a lighting transition from 2AM to 5:50 AM? Setting this to false will keep the world dark until the player passes out or goes to bed."; - mystring3[5] = lighting_transition.ToString(); - mystring3[6] = "Warp to collapse position?: True: Stay in the same place. False: Warp back home."; - mystring3[7] = warp.ToString(); - mystring3[8] = "Keep Money?: True: Don't be charged for passing out."; - mystring3[9] = protect_money.ToString(); - mystring3[10] = "Keep stamina when staying up? When the farmer passes out at 6, should their stamina be their stamina before collapsing?"; - mystring3[11] = persistant_stamina.ToString(); - mystring3[12] = "Keep health when staying up? When the farmer passes out at 6, should their health be their health before collapsing?"; - mystring3[13] = persistant_health.ToString(); - mystring3[14] = "Clean out charges mail?: Get rid of the annoying We charged X gold for your health fees, etc."; - mystring3[15] = wipe_mail.ToString(); - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - // Console.WriteLine("HEY IM SAVING DATA"); - //write out the info to a text file at the end of a day. - mystring3[0] = "Player: Night Owl Config. Feel free to edit."; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Stay up to 6 AM?: Do you wan't to stay up till 6 AM the next morning?"; - mystring3[3] = stay_up.ToString(); - mystring3[4] = "Custom Lighting Transition?: Do you want to have a lighting transition from 2AM to 5:50 AM? Setting this to false will keep the world dark until the player passes out or goes to bed."; - mystring3[5] = lighting_transition.ToString(); - mystring3[6] = "Warp to collapse position?: True: Stay in the same place. False: Warp back home."; - mystring3[7] = warp.ToString(); - mystring3[8] = "Keep Money?: True: Don't be charged for passing out."; - mystring3[9] = protect_money.ToString(); - mystring3[10] = "Keep stamina when staying up? When the farmer passes out at 6, should their stamina be their stamina before collapsing?"; - mystring3[11] = persistant_stamina.ToString(); - mystring3[12] = "Keep health when staying up? When the farmer passes out at 6, should their health be their health before collapsing?"; - mystring3[13] = persistant_health.ToString(); - mystring3[14] = "Clean out charges mail?: Get rid of the annoying We charged X gold for your health fees, etc."; - mystring3[15] = wipe_mail.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - } - void DataLoader() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Helper.DirectoryPath, "Night_Owl_Config_"); - //string mylocation2 = mylocation + myname; - string mylocation3 = mylocation + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Monitor.Log("Loading Night_Owl_Config"); - lighting_transition = true; - warp = true; - stay_up = true; - - persistant_health = true; - persistant_stamina = true; - wipe_mail = true; - protect_money = true; - - } - - else - { - string[] readtext = File.ReadAllLines(mylocation3); - stay_up = Convert.ToBoolean(readtext[3]);//will the player stay up? - lighting_transition = Convert.ToBoolean(readtext[5]); //does the lighting transition occur? - warp = Convert.ToBoolean(readtext[7]); //does the player warp back to the spot they passed out at? - protect_money = Convert.ToBoolean(readtext[9]); //Is their money safe from stealing? - persistant_stamina = Convert.ToBoolean(readtext[11]); //Does the player have the same stam when collapsing? - persistant_health = Convert.ToBoolean(readtext[13]); //Ditto but with health. - if (readtext[15] == "") wipe_mail = true; - else wipe_mail = Convert.ToBoolean(readtext[15]); //will I clean out their mailbox? - } - } - } -} diff --git a/GeneralMods/NightOwl/NightOwl.cs b/GeneralMods/NightOwl/NightOwl.cs new file mode 100644 index 00000000..15af7869 --- /dev/null +++ b/GeneralMods/NightOwl/NightOwl.cs @@ -0,0 +1,325 @@ +using System; +using System.IO; +using System.Linq; +using Microsoft.Xna.Framework; +using Newtonsoft.Json; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +/*TODO: +Issues: +-Mail can't be wiped without destroying all mail. +-Lighting transition does not work if it is raining. + -set the weather to clear if you are stayig up late. + -transition still doesnt work. However atleast it is dark now. + +-Known glitched +*/ +namespace Omegasis.NightOwl +{ + /// The mod entry point. + public class NightOwl : Mod + { + /********* + ** Properties + *********/ + /**** + ** Context + ****/ + /// Whether the player loaded a save. + private bool IsGameLoaded; + + /// Whether the player stayed up all night. + private bool IsUpLate; + + /// Whether the player should be reset to their pre-collapse details for the morning transition on the next update. + private bool ShouldResetPlayerAfterCollapseNow; + + /// Whether the player just started a new day. + private bool JustStartedNewDay; + + /// Whether the player just collapsed for the morning transition. + private bool JustCollapsed; + + /**** + ** Pre-collapse state + ****/ + /// The player's location name before they collapsed. + private string PreCollapseMap; + + /// The player's tile position before they collapsed. + private Point PreCollapseTile; + + /// The player's money before they collapsed. + private int PreCollapseMoney; + + /// The player's stamina before they collapsed. + private float PreCollapseStamina; + + /// The player's health before they collapsed. + private int PreCollapseHealth; + + /**** + ** Settings + ****/ + /// Whether lighting should transition to day from 2am to 6am. If false, the world will stay dark until the player passes out or goes to bed. + private bool MorningLightTransition; + + /// Whether the player can stay up until 6am. + private bool StayUp; + + /// Whether to remove the mail received for collapsing like 'we charged X gold for your health fees'. + private bool SkipCollapseMail; + + /// Whether to restore the player's position after they collapse. + private bool KeepPositionAfterCollapse; + + /// Whether to restore the player's money after they collapse (i.e. prevent the automatic deduction). + private bool KeepMoneyAfterCollapse; + + /// Whether to keep stamina as-is after the player collapses. + private bool KeepHealthAfterCollapse; + + /// Whether to keep stamina as-is after the player collapses. + private bool KeepStaminaAfterCollapse; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + TimeEvents.TimeOfDayChanged += this.TimeEvents_TimeOfDayChanged; + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + GameEvents.FourthUpdateTick += this.GameEvents_FourthUpdateTick; + } + + + /********* + ** Private methods + *********/ + /// 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 + { + // reset position after collapse + if (!Game1.eventUp && this.IsGameLoaded && this.JustStartedNewDay && this.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; + } + } + catch (Exception ex) + { + this.Monitor.Log(ex.ToString(), LogLevel.Error); + this.WriteErrorLog(); + } + } + + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + public void SaveEvents_AfterLoad(object sender, EventArgs e) + { + this.LoadConfig(); + this.WriteConfig(); + this.IsGameLoaded = true; + this.IsUpLate = false; + this.JustStartedNewDay = false; + this.JustCollapsed = false; + } + + /// The method invoked when changes. + /// The event sender. + /// The event data. + public void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e) + { + if (!this.IsGameLoaded) + return; + + try + { + // reset data + this.LoadConfig(); + this.WriteConfig(); + this.IsUpLate = false; + Game1.farmerShouldPassOut = false; + + // transition to the next day + if (this.ShouldResetPlayerAfterCollapseNow) + { + this.ShouldResetPlayerAfterCollapseNow = false; + + if (this.KeepStaminaAfterCollapse) + Game1.player.stamina = this.PreCollapseStamina; + if (this.KeepHealthAfterCollapse) + Game1.player.health = this.PreCollapseHealth; + if (this.KeepMoneyAfterCollapse) + Game1.player.money = this.PreCollapseMoney; + if (this.KeepPositionAfterCollapse) + Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false); + } + + // delete annoying charge messages (if only I could do this with mail IRL) + if (this.SkipCollapseMail) + { + string[] validMail = Game1.mailbox + .Where(p => !p.Contains("passedOut")) + .ToArray(); + + Game1.mailbox.Clear(); + foreach (string mail in validMail) + Game1.mailbox.Enqueue(mail); + } + + this.JustStartedNewDay = true; + } + catch (Exception ex) + { + this.Monitor.Log(ex.ToString(), LogLevel.Error); + this.WriteErrorLog(); + } + } + + /// The method invoked when changes. + /// The event sender. + /// The event data. + private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e) + { + if (!this.IsGameLoaded) + return; + + try + { + // transition morning light more realistically + if (this.MorningLightTransition && Game1.timeOfDay > 400 && Game1.timeOfDay < 600) + { + float colorMod = (1300 - Game1.timeOfDay) / 1000f; + Game1.outdoorLight = Game1.ambientLight * colorMod; + } + + // transition to next morning + if (this.StayUp && Game1.timeOfDay == 2550) + { + Game1.isRaining = false; // remove rain, otherwise lighting gets screwy + Game1.updateWeatherIcon(); + Game1.timeOfDay = 150; //change it from 1:50 am late, to 1:50 am early + } + + // collapse player at 6am to save & reset + if (Game1.timeOfDay == 550) + this.IsUpLate = true; + if (this.IsUpLate && Game1.timeOfDay == 600 && !this.JustCollapsed) + { + this.JustCollapsed = true; + + this.ShouldResetPlayerAfterCollapseNow = true; + this.PreCollapseTile = new Point(Game1.player.getTileX(), Game1.player.getTileY()); + this.PreCollapseMap = Game1.player.currentLocation.name; + this.PreCollapseStamina = Game1.player.stamina; + this.PreCollapseHealth = Game1.player.health; + this.PreCollapseMoney = Game1.player.money; + + if (Game1.currentMinigame != null) + Game1.currentMinigame = null; + Game1.farmerShouldPassOut = true; + } + } + catch (Exception ex) + { + this.Monitor.Log(ex.ToString(), LogLevel.Error); + this.WriteErrorLog(); + } + } + + /// Save the configuration settings. + private void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Night_Owl_Config_.txt"); + string[] text = new string[20]; + + text[0] = "Player: Night Owl Config. Feel free to edit."; + text[1] = "===================================================================================="; + text[2] = "Whether you can stay up until 6am."; + text[3] = this.StayUp.ToString(); + text[4] = "Whether the lighting should transition to daytime from 2am to 6am. Setting this to false will keep the world dark until the player passes out or goes to bed."; + text[5] = this.MorningLightTransition.ToString(); + text[6] = "Whether to keep your position as-is after you collapse at 6am. If false, you'll warp back home."; + text[7] = this.KeepPositionAfterCollapse.ToString(); + text[8] = "Whether to prevent money from being deducted after you collapse at 6am."; + text[9] = this.KeepMoneyAfterCollapse.ToString(); + text[10] = "Whether to keep your stamina as-is after you collapse at 6am."; + text[11] = this.KeepStaminaAfterCollapse.ToString(); + text[12] = "Whether to keep your health as-is after you collapse at 6am."; + text[13] = this.KeepHealthAfterCollapse.ToString(); + text[14] = "Whether to remove the mail you receive for collapsing like 'we charged X gold for your health fees'."; + text[15] = this.SkipCollapseMail.ToString(); + + File.WriteAllLines(path, text); + } + + /// Load the configuration settings. + private void LoadConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Night_Owl_Config_.txt"); + if (!File.Exists(path)) + { + this.MorningLightTransition = true; + this.KeepPositionAfterCollapse = true; + this.StayUp = true; + + this.KeepHealthAfterCollapse = true; + this.KeepStaminaAfterCollapse = true; + this.SkipCollapseMail = true; + this.KeepMoneyAfterCollapse = true; + } + else + { + string[] text = File.ReadAllLines(path); + this.StayUp = Convert.ToBoolean(text[3]); + this.MorningLightTransition = Convert.ToBoolean(text[5]); + this.KeepPositionAfterCollapse = Convert.ToBoolean(text[7]); + this.KeepMoneyAfterCollapse = Convert.ToBoolean(text[9]); + this.KeepStaminaAfterCollapse = Convert.ToBoolean(text[11]); + this.KeepHealthAfterCollapse = Convert.ToBoolean(text[13]); + this.SkipCollapseMail = text[15] == "" || Convert.ToBoolean(text[15]); + } + } + + /// Write the current mod state to the error log file. + private void WriteErrorLog() + { + try + { + JsonSerializer serializer = new JsonSerializer + { + NullValueHandling = NullValueHandling.Ignore, + TypeNameHandling = TypeNameHandling.All, + Formatting = Formatting.Indented, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }; + string path = Path.Combine(this.Helper.DirectoryPath, "Error_Logs", "Mod_State.json"); + using (StreamWriter sw = new StreamWriter(path)) + { + using (JsonWriter writer2 = new JsonTextWriter(sw)) + serializer.Serialize(writer2, this); + } + } + catch (Exception ex) + { + this.Monitor.Log(ex.ToString(), LogLevel.Error); + } + } + } +} diff --git a/GeneralMods/NightOwl/NightOwl.csproj b/GeneralMods/NightOwl/NightOwl.csproj index 8bbc02b0..0c6927b2 100644 --- a/GeneralMods/NightOwl/NightOwl.csproj +++ b/GeneralMods/NightOwl/NightOwl.csproj @@ -32,21 +32,27 @@ ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + False - + + Properties\GlobalAssemblyInfo.cs + + - + + PreserveNewest + - + diff --git a/GeneralMods/NightOwl/Properties/AssemblyInfo.cs b/GeneralMods/NightOwl/Properties/AssemblyInfo.cs index b23714fd..d9a2452b 100644 --- a/GeneralMods/NightOwl/Properties/AssemblyInfo.cs +++ b/GeneralMods/NightOwl/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Stardew_NightOwl")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Stardew_NightOwl")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: AssemblyTitle("NightOwl")] [assembly: Guid("c7e7043f-c823-4fdd-9f4e-7cc255751246")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/NightOwl/README.md b/GeneralMods/NightOwl/README.md new file mode 100644 index 00000000..90082218 --- /dev/null +++ b/GeneralMods/NightOwl/README.md @@ -0,0 +1,21 @@ +**Night Owl** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you stay up a full +24 hours instead of collapsing at 2am, including a morning light transition as the sun rises. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/433). +3. _(optional)_ Merge the `Content` folder into your game's `Content` folder to improve night fishing. +3. Run the game using SMAPI. + +## Usage +Simply stay up past 2am, and you won't collapse. The lighting will gradually brighten as the sun +rises. At 6am you'll temporarily collapse so the game can save, but you won't lose anything and +you'll stay where you are. + +Edit the `Night_Owl_Config_.txt` to change the mod settings. + +## Versions +1.0: +* Initial release. diff --git a/GeneralMods/NightOwl/ReadMe.txt b/GeneralMods/NightOwl/ReadMe.txt deleted file mode 100644 index 49138e17..00000000 --- a/GeneralMods/NightOwl/ReadMe.txt +++ /dev/null @@ -1,47 +0,0 @@ -Night Owl - -Version:1.2.0 - -Published: 7/4/16 1:37 PM - -Updated: 10/21/16 12:35 AM - -Compatability: - -Stardew Valley 1.1.0 Windows - -SMAPI 0.40.0 1.1-3 - -Description: - -Night Owl is a mod that allows players to stay up a full 24 hours instead of being restricted to 2AM. -Some of the features include --A transitional lighting effect that lasts from 2AM to 6 AM --Gold doesn't have to be subtracted from you when you collapse. --Persistent health and stamina when you stay up 24 hours --Remaining in the same place as where you collapsed! -Plenty of features can be found in the Night Owl Config to be edited as you please. - -Installation: - -1.Unzip the NightOwl.zip folder. -2.Place the Unzipped folder into Stardew Valley/Mods -3.Play! - -Installation for Night Owl Fish: http://www.nexusmods.com/stardewvalley/mods/433/?tab=1&navtag=http%3A%2F%2Fwww.nexusmods.com%2Fstardewvalley%2Fajax%2Fmoddescription%2F%3Fid%3D433%26preview%3D&pUp=1 -1.Unzip the Fish.zip folder -2.Place the Fish.xnb FILE inside of Stardew Valley/Content/Data -3.Overwrite the old Fish.xnb -4.Play! -Yes this compatibility file is incompatible with other mods that edit the Fish.xnb file. No, I do not plan on making compatibility patches with these mods. - - -Update Info: -1.2.0 --Updated to SDV 1.1 - -1.1.0 --Added a bug/error catching system that should help prevent the mod from outright crashing, and instead just dump some error logic to the mod's folder for better debgging in the future. - -1.0.0 --Initial Release diff --git a/GeneralMods/NightOwl/manifest.json b/GeneralMods/NightOwl/manifest.json index 3e65ed53..81037820 100644 --- a/GeneralMods/NightOwl/manifest.json +++ b/GeneralMods/NightOwl/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "Stardew_NightOwl", "PerSaveConfigs": false, "EntryDll": "NightOwl.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/NoMorePets/Class1.cs b/GeneralMods/NoMorePets/Class1.cs deleted file mode 100644 index 57c3ee41..00000000 --- a/GeneralMods/NoMorePets/Class1.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.NoMorePets -{ - public class Class1 :Mod - { - bool game_loaded; - public override void Entry(IModHelper helper) - { - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - StardewModdingAPI.Events.SaveEvents.AfterLoad += PlayerEvents_LoadedGame; - } - - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - game_loaded = true; - } - - - public void GameEvents_UpdateTick(object sender, EventArgs e) - { - if (game_loaded == false) return; - List my_npc_list = new List(); - if (Game1.player == null) return; - string pet_name = Game1.player.getPetName(); - if (Game1.player.currentLocation.name == "Farm") - { - foreach(NPC npc in Game1.player.currentLocation.characters) - { - - if (npc.name == pet_name) my_npc_list.Add(npc); - } - foreach(var location in Game1.locations) - { - if (location.name == "Farm" || location.name == "farm") StardewValley.Game1.removeCharacterFromItsLocation(pet_name); - } - } - } - } -} diff --git a/GeneralMods/NoMorePets/NoMorePets.cs b/GeneralMods/NoMorePets/NoMorePets.cs new file mode 100644 index 00000000..2bf15e01 --- /dev/null +++ b/GeneralMods/NoMorePets/NoMorePets.cs @@ -0,0 +1,60 @@ +using System; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +namespace Omegasis.NoMorePets +{ + /// The mod entry point. + public class NoMorePets : Mod + { + /********* + ** Properties + *********/ + /// Whether the player loaded a save. + private bool IsGameLoaded; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + } + + + /********* + ** Private methods + *********/ + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + public void SaveEvents_AfterLoad(object sender, EventArgs e) + { + this.IsGameLoaded = true; + } + + /// The method invoked when the game updates (roughly 60 times per second). + /// The event sender. + /// The event data. + public void GameEvents_UpdateTick(object sender, EventArgs e) + { + if (!this.IsGameLoaded || Game1.player == null) + return; + + string petName = Game1.player.getPetName(); + if (Game1.player.currentLocation is Farm) + { + foreach (NPC npc in Game1.player.currentLocation.characters.ToArray()) + { + if (npc.name == petName) + Game1.removeCharacterFromItsLocation(petName); + } + } + } + } +} diff --git a/GeneralMods/NoMorePets/NoMorePets.csproj b/GeneralMods/NoMorePets/NoMorePets.csproj index 7507298a..a0fec869 100644 --- a/GeneralMods/NoMorePets/NoMorePets.csproj +++ b/GeneralMods/NoMorePets/NoMorePets.csproj @@ -34,7 +34,10 @@ - + + Properties\GlobalAssemblyInfo.cs + + @@ -42,7 +45,7 @@ - + diff --git a/GeneralMods/NoMorePets/Properties/AssemblyInfo.cs b/GeneralMods/NoMorePets/Properties/AssemblyInfo.cs index 80bc1380..7fb22ce3 100644 --- a/GeneralMods/NoMorePets/Properties/AssemblyInfo.cs +++ b/GeneralMods/NoMorePets/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("NoMorePets")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NoMorePets")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("2d41e7d7-b4b7-420f-acaf-8f687e876008")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/NoMorePets/README.md b/GeneralMods/NoMorePets/README.md new file mode 100644 index 00000000..b9a1fe83 --- /dev/null +++ b/GeneralMods/NoMorePets/README.md @@ -0,0 +1,19 @@ +**No More Pets** is a [Stardew Valley](http://stardewvalley.net/) mod which removes all pets from +the game. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/506). +3. Run the game using SMAPI. + +## Usage +All your pets will be removed automatically when you play the save. + +## Versions +1.0: +* Initial release. + +1.1: +* Updated to Stardew Valley 1.1 and SMAPI 0.40 1.1-3. diff --git a/GeneralMods/NoMorePets/ReadMe.txt b/GeneralMods/NoMorePets/ReadMe.txt deleted file mode 100644 index 25366a92..00000000 --- a/GeneralMods/NoMorePets/ReadMe.txt +++ /dev/null @@ -1,21 +0,0 @@ -NoMorePets - -version: 1.1.0 - -Released: 8/1/16 - -Updated:10/21/16 12:48 AM - -Compatability: - -Stardew Valley 1.1.0 Windows - -SMAPI 0.40.0 1.1-3 - -Description: A simple mod that removes your pet from the game incase you somehow dupe it, or are annoyed with it. - -Accidently duped my pet while modding. This helped clean up the issue for me. - -Updates: -1.1.0 --updated to SDV 1.1 \ No newline at end of file diff --git a/GeneralMods/NoMorePets/manifest.json b/GeneralMods/NoMorePets/manifest.json index e2fe4b1e..028d6459 100644 --- a/GeneralMods/NoMorePets/manifest.json +++ b/GeneralMods/NoMorePets/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "NoMorePets", "PerSaveConfigs": false, "EntryDll": "NoMorePets.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/SaveAnywhere/Animal_Utilities.cs b/GeneralMods/SaveAnywhere/Animal_Utilities.cs deleted file mode 100644 index e9246970..00000000 --- a/GeneralMods/SaveAnywhere/Animal_Utilities.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.IO; - -namespace Omegasis.SaveAnywhere -{ - class Animal_Utilities - { - - public static void save_animal_info() - { - Mod_Core.animal_path = Path.Combine(Mod_Core.player_path, "Animals"); - if (!Directory.Exists(Mod_Core.animal_path)) - { - Directory.CreateDirectory(Mod_Core.animal_path); - - } - Horse_Utility.Save_Horse_Info(); - Pet_Utilities.save_pet_info(); - } - - public static void load_animal_info() - { - Mod_Core.animal_path = Path.Combine(Mod_Core.player_path, "Animals"); - if (!Directory.Exists(Mod_Core.animal_path)) - { - Directory.CreateDirectory(Mod_Core.animal_path); - - } - Horse_Utility.Load_Horse_Info(); - Pet_Utilities.Load_pet_Info(); - } - - } -} diff --git a/GeneralMods/SaveAnywhere/Config_Utilities.cs b/GeneralMods/SaveAnywhere/Config_Utilities.cs deleted file mode 100644 index f2d88783..00000000 --- a/GeneralMods/SaveAnywhere/Config_Utilities.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.IO; - -namespace Omegasis.SaveAnywhere -{ - class Config_Utilities - { - public static string key_binding = "K"; - public static bool warp_character; - public static void DataLoader_Settings() - { - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Mod_Core.mod_path, "Save_Anywhere_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - key_binding = "K"; - warp_character = true; - } - - else - { - string[] readtext = File.ReadAllLines(mylocation3); - key_binding = Convert.ToString(readtext[3]); - } - } - - public static void MyWritter_Settings() - { - - //write all of my info to a text file. - string myname = StardewValley.Game1.player.name; - - string mylocation = Path.Combine(Mod_Core.mod_path, "Save_Anywhere_Config"); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now."); - - mystring3[0] = "Config: Save_Anywhere Info. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Key binding for saving anywhere. Press this key to save anywhere!"; - mystring3[3] = key_binding.ToString(); - - - File.WriteAllLines(mylocation3, mystring3); - - } - - else - { - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Config: Save_Anywhere Info. Feel free to mess with these settings."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Key binding for saving anywhere. Press this key to save anywhere!"; - mystring3[3] = key_binding.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - } - } -} diff --git a/GeneralMods/SaveAnywhere/Framework/ConfigUtilities.cs b/GeneralMods/SaveAnywhere/Framework/ConfigUtilities.cs new file mode 100644 index 00000000..4b893fb1 --- /dev/null +++ b/GeneralMods/SaveAnywhere/Framework/ConfigUtilities.cs @@ -0,0 +1,61 @@ +using System; +using System.IO; + +namespace Omegasis.SaveAnywhere.Framework +{ + /// Provides methods for reading and writing the config file. + internal class ConfigUtilities + { + /********* + ** Properties + *********/ + /// The full path to the mod folder. + private readonly string ModPath; + + + /********* + ** Accessors + *********/ + /// The key which saves the game. + public string KeyBinding { get; private set; } = "K"; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The full path to the mod folder. + public ConfigUtilities(string modPath) + { + this.ModPath = modPath; + } + + /// Load the configuration settings. + public void LoadConfig() + { + string path = Path.Combine(this.ModPath, "Save_Anywhere_Config.txt"); + if (!File.Exists(path)) + this.KeyBinding = "K"; + else + { + string[] text = File.ReadAllLines(path); + this.KeyBinding = Convert.ToString(text[3]); + } + } + + /// Save the configuration settings. + public void WriteConfig() + { + string path = Path.Combine(this.ModPath, "Save_Anywhere_Config.txt"); + + string[] text = new string[20]; + text[0] = "Config: Save_Anywhere Info. Feel free to mess with these settings."; + text[1] = "===================================================================================="; + + text[2] = "Key binding for saving anywhere. Press this key to save anywhere!"; + text[3] = this.KeyBinding; + + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/SaveAnywhere/Framework/NewShippingMenu.cs b/GeneralMods/SaveAnywhere/Framework/NewShippingMenu.cs new file mode 100644 index 00000000..5f3a3128 --- /dev/null +++ b/GeneralMods/SaveAnywhere/Framework/NewShippingMenu.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Menus; + +namespace Omegasis.SaveAnywhere.Framework +{ + /// A subclass of that does everything except save. + internal class NewShippingMenu : ShippingMenu + { + /********* + ** Properties + *********/ + /// The private field on the shipping menu which indicates the game has already been saved, which prevents it from saving. + private readonly IPrivateField SavedYet; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The shipping bin items. + /// Simplifies access to game code. + public NewShippingMenu(List items, IReflectionHelper reflection) + : base(items) + { + this.SavedYet = reflection.GetPrivateField(this, "savedYet"); + } + + /// Updates the menu during the game's update loop. + /// The game time that has passed. + public override void update(GameTime time) + { + this.SavedYet.SetValue(true); // prevent menu from saving + base.update(time); + } + } +} diff --git a/GeneralMods/SaveAnywhere/Framework/SaveManager.cs b/GeneralMods/SaveAnywhere/Framework/SaveManager.cs new file mode 100644 index 00000000..5a70a922 --- /dev/null +++ b/GeneralMods/SaveAnywhere/Framework/SaveManager.cs @@ -0,0 +1,368 @@ +using System; +using System.IO; +using System.Linq; +using Microsoft.Xna.Framework; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Characters; +using StardewValley.Menus; +using StardewValley.Monsters; +using SFarmer = StardewValley.Farmer; + +namespace Omegasis.SaveAnywhere.Framework +{ + /// Provides methods for saving and loading game data. + internal class SaveManager + { + /********* + ** Properties + *********/ + /// The player for which to save data. + private readonly SFarmer Player; + + /// Simplifies access to game code. + private readonly IReflectionHelper Reflection; + + /// Writes messages to the console and log file. + private readonly IMonitor Monitor; + + /// A callback invoked when villagers are reset during a load. + private readonly Action OnVillagersReset; + + /// The full path to the folder in which to store data for this player. + private readonly string SavePath; + + /// The full path to the folder in which to store animal data for this player. + private readonly string SaveAnimalsPath; + + /// The full path to the folder in which to store villager data for this player. + private readonly string SaveVillagersPath; + + /// Whether we should save at the next opportunity. + private bool WaitingToSave; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The player for which to save data. + /// The full path to the mod folder. + /// Writes messages to the console and log file. + /// Simplifies access to game code. + /// A callback invoked when villagers are reset during a load. + public SaveManager(SFarmer player, string modPath, IMonitor monitor, IReflectionHelper reflection, Action onVillagersReset) + { + // save info + this.Player = player; + this.Monitor = monitor; + this.Reflection = reflection; + this.OnVillagersReset = onVillagersReset; + + // generate paths + this.SavePath = Path.Combine(modPath, "Save_Data", player.name); + this.SaveAnimalsPath = Path.Combine(this.SavePath, "Animals"); + this.SaveVillagersPath = Path.Combine(this.SavePath, "NPC_Save_Info"); + } + + /// Perform any required update logic. + public void Update() + { + // perform passive save + if (this.WaitingToSave && Game1.activeClickableMenu == null) + { + Game1.activeClickableMenu = new SaveGameMenu(); + this.WaitingToSave = false; + } + } + + /// Save all game data. + public void SaveGameAndPositions() + { + // save game data + Farm farm = Game1.getFarm(); + if (farm.shippingBin.Any()) + { + Game1.activeClickableMenu = new NewShippingMenu(farm.shippingBin, this.Reflection); + farm.shippingBin.Clear(); + farm.lastItemShipped = null; + this.WaitingToSave = true; + } + else + Game1.activeClickableMenu = new SaveGameMenu(); + + // save custom data + Directory.CreateDirectory(this.SaveAnimalsPath); + Directory.CreateDirectory(this.SaveVillagersPath); + this.SavePlayerPosition(); + this.SaveHorsePosition(); + this.SavePetPosition(); + this.SaveVillagerPositions(); + } + + /// Load all game data. + public void LoadPositions() + { + if (!this.HasSaveData()) + return; + + this.LoadPlayerPosition(); + this.LoadHorsePosition(); + this.LoadPetPosition(); + bool anyVillagersMoved = this.LoadVillagerPositions(); + + if (anyVillagersMoved) + this.OnVillagersReset?.Invoke(); + } + + + /********* + ** Private methods + *********/ + /// Save the horse state to the save file. + private void SaveHorsePosition() + { + // find horse + Horse horse = Utility.findHorse(); + if (horse == null) + return; + + // get horse info + string map = horse.currentLocation.name; + Point tile = horse.getTileLocationPoint(); + + // save data + string path = Path.Combine(this.SaveAnimalsPath, $"Horse_Save_Info_{this.Player.name}.txt"); + string[] text = new string[20]; + text[0] = "Horse: Save_Anywhere Info. Editing this might break some things."; + text[1] = "===================================================================================="; + + text[2] = "Horse Current Map Name"; + text[3] = map; + + text[4] = "Horse X Position"; + text[5] = tile.X.ToString(); + + text[6] = "Horse Y Position"; + text[7] = tile.Y.ToString(); + + File.WriteAllLines(path, text); + } + + /// Reset the horse to the saved state. + private void LoadHorsePosition() + { + // find horse + Horse horse = Utility.findHorse(); + if (horse == null) + return; + + // get file path + string path = Path.Combine(this.SaveAnimalsPath, $"Horse_Save_Info_{this.Player.name}.txt"); + if (!File.Exists(path)) + return; + + // read saved data + string[] text = File.ReadAllLines(path); + string map = Convert.ToString(text[3]); + int x = Convert.ToInt32(text[5]); + int y = Convert.ToInt32(text[7]); + + // update horse + Game1.warpCharacter(horse, map, new Point(x, y), false, true); + } + + /// Save the villager states to the save file. + private void SaveVillagerPositions() + { + foreach (NPC npc in Utility.getAllCharacters()) + { + // ignore non-villagers + if (npc is Pet || npc is Monster) + continue; + + // get NPC data + string name = npc.name; + string map = npc.currentLocation.name; + Point tile = npc.getTileLocationPoint(); + + // save data + string path = Path.Combine(this.SaveVillagersPath, npc.name + ".txt"); + string[] text = new string[20]; + text[0] = "NPC: Save_Anywhere Info. Editing this might break some things."; + text[1] = "===================================================================================="; + + text[2] = "NPC Name"; + text[3] = name; + + text[4] = "NPC Current Map Name"; + text[5] = map; + + text[6] = "NPC X Position"; + text[7] = tile.X.ToString(); + + text[8] = "NPC Y Position"; + text[9] = tile.Y.ToString(); + + File.WriteAllLines(path, text); + } + } + + /// Reset the villagers to their saved state. + /// Returns whether any villagers changed position. + private bool LoadVillagerPositions() + { + bool anyLoaded = false; + foreach (NPC npc in Utility.getAllCharacters()) + { + // ignore non-villagers + if (npc is Pet || npc is Monster) + continue; + + // get file path + string path = Path.Combine(this.SaveVillagersPath, npc.name + ".txt"); + if (!File.Exists(path)) + { + this.Monitor.Log($"No save data for {npc.name} villager, skipping.", LogLevel.Error); + continue; + } + + // read data + string[] text = File.ReadAllLines(path); + string map = Convert.ToString(text[5]); + int x = Convert.ToInt32(text[7]); + int y = Convert.ToInt32(text[9]); + if (string.IsNullOrEmpty(map)) + continue; + + // update NPC + anyLoaded = true; + Game1.warpCharacter(npc, map, new Point(x, y), false, true); + } + + return anyLoaded; + } + + /// Save the pet state to the save file. + private void SavePetPosition() + { + if (!this.Player.hasPet()) + return; + + // find pet + Pet pet = Utility.getAllCharacters().OfType().FirstOrDefault(); + if (pet == null) + return; + + // get pet info + string map = pet.currentLocation.name; + Point tile = pet.getTileLocationPoint(); + + // save data + string path = Path.Combine(this.SaveAnimalsPath, $"Pet_Save_Info_{this.Player.name}.txt"); + string[] text = new string[20]; + text[0] = "Pet: Save_Anywhere Info. Editing this might break some things."; + text[1] = "===================================================================================="; + + text[2] = "Pet Current Map Name"; + text[3] = map; + + text[4] = "Pet X Position"; + text[5] = tile.X.ToString(); + + text[6] = "Pet Y Position"; + text[7] = tile.Y.ToString(); + + File.WriteAllLines(path, text); + } + + /// Reset the pet to the saved state. + private void LoadPetPosition() + { + if (!this.Player.hasPet()) + return; + + // find pet + Pet pet = Utility.getAllCharacters().OfType().FirstOrDefault(); + if (pet == null) + return; + + // get file path + string path = Path.Combine(this.SaveAnimalsPath, $"Pet_Save_Info_{this.Player.name}.txt"); + if (!File.Exists(path)) + return; + + // read saved data + string[] text = File.ReadAllLines(path); + string map = Convert.ToString(text[3]); + int x = Convert.ToInt32(text[5]); + int y = Convert.ToInt32(text[7]); + + // update pet + Game1.warpCharacter(pet, map, new Point(x, y), false, true); + } + + /// Save the player state to the save file. + private void SavePlayerPosition() + { + // get player info + string map = this.Player.currentLocation.name; + Point tile = this.Player.getTileLocationPoint(); + + // save data + string path = Path.Combine(this.SavePath, $"Player_Save_Info_{this.Player.name}.txt"); + string[] text = new string[20]; + + text[0] = "Player: Save_Anywhere Info. Editing this might break some things."; + text[1] = "===================================================================================="; + + text[2] = "Player Current Game Time"; + text[3] = Game1.timeOfDay.ToString(); + + text[4] = "Player Current Map Name"; + text[5] = map; + + text[6] = "Player X Position"; + text[7] = tile.X.ToString(); + + text[8] = "Player Y Position"; + text[9] = tile.Y.ToString(); + + File.WriteAllLines(path, text); + } + + /// Reset the player to the saved state. + private void LoadPlayerPosition() + { + // get file path + string path = Path.Combine(this.SavePath, $"Player_Save_Info_{this.Player.name}.txt"); + if (!File.Exists(path)) + return; + + // read saved data + string[] text = File.ReadAllLines(path); + int time = Convert.ToInt32(text[3]); + string map = Convert.ToString(text[5]); + int x = Convert.ToInt32(text[7]); + int y = Convert.ToInt32(text[9]); + + // update player + Game1.timeOfDay = time; + + this.Player.previousLocationName = this.Player.currentLocation.name; + Game1.locationAfterWarp = Game1.getLocationFromName(map); + Game1.xLocationAfterWarp = x; + Game1.yLocationAfterWarp = y; + //Game1.facingDirectionAfterWarp = this.player_facing_direction; + Game1.fadeScreenToBlack(); + Game1.warpFarmer(map, x, y, false); + //this.Player.faceDirection(this.player_facing_direction); + } + + /// Get whether any data has been saved for this player yet. + private bool HasSaveData() + { + return Directory.Exists(this.SavePath); + } + } +} diff --git a/GeneralMods/SaveAnywhere/GameUtilities.cs b/GeneralMods/SaveAnywhere/GameUtilities.cs deleted file mode 100644 index 392f6fda..00000000 --- a/GeneralMods/SaveAnywhere/GameUtilities.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.SaveAnywhere -{ - public class GameUtilities - { - public static bool passiveSave; - public static bool should_ship; - public static void save_game() - { - /* - - if (Game1.player.currentLocation.name == "Sewer") - { - Log.Error("There is an issue saving in the Sewer. Blame the animals for not being saved to the player's save file."); - Log.Error("Your data has not been saved. Sorry for the issue."); - return; - } - */ - - //if a player has shipped an item, run this code. - if (Enumerable.Count((IEnumerable)Game1.getFarm().shippingBin) > 0) - { - should_ship = true; - // Game1.endOfNightMenus.Push((IClickableMenu)new ShippingMenu(Game1.getFarm().shippingBin)); - // Game1.showEndOfNightStuff(); //shows the nightly shipping menu. - // Game1.getFarm().shippingBin.Clear(); //clears out the shipping bin to prevent exploits - } - - try - { - shipping_check(); - // Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); - } - catch(Exception rrr) - { - Game1.showRedMessage("Can't save here. See log for error."); - Mod_Core.thisMonitor.Log(rrr.ToString(), LogLevel.Error); - } - - // Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); //This command is what allows the player to save anywhere as it calls the saving function. - - Player_Utilities.save_player_info(); - Animal_Utilities.save_animal_info(); - NPC_Utilities.Save_NPC_Info(); - - //grab the player's info - // player_map_name = StardewValley.Game1.player.currentLocation.name; - // player_tile_x = StardewValley.Game1.player.getTileX(); - // player_tile_Y = StardewValley.Game1.player.getTileY(); - // player_flop = false; - - // MyWritter_Player(); //write my info to a text file - - - // MyWritter_Horse(); - - // DataLoader_Settings(); //load settings. Prevents acidental overwrite. - // MyWritter_Settings(); //save settings. - - //Game1.warpFarmer(player_map_name, player_tile_x, player_tile_Y, player_flop); //refresh the player's location just incase. That will prove that they character's info was valid. - - //so this is essentially the basics of the code... - // Log.Error("IS THIS BREAKING?"); - } - - public static void shipping_check() - { - - if (Game1.activeClickableMenu != null) return; - if (should_ship == true) - { - Game1.activeClickableMenu = new New_Shipping_Menu(Game1.getFarm().shippingBin); - should_ship = false; - Game1.getFarm().shippingBin.Clear(); - Game1.getFarm().lastItemShipped = null; - passiveSave = true; - } - else - { - Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); - } - } - } -} diff --git a/GeneralMods/SaveAnywhere/Horse_Utility.cs b/GeneralMods/SaveAnywhere/Horse_Utility.cs deleted file mode 100644 index 65b3ccf3..00000000 --- a/GeneralMods/SaveAnywhere/Horse_Utility.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.IO; -using Microsoft.Xna.Framework; -using StardewModdingAPI; -using StardewValley; -using StardewValley.Characters; - -namespace Omegasis.SaveAnywhere -{ - class Horse_Utility - { - - public static void Save_Horse_Info() - { - - - Horse horse = Utility.findHorse(); - - - if (horse == null) - { - //Game1.getFarm().characters.Add((NPC)new Horse(this.player_tile_x + 1, this.player_tile_Y + 1)); - Mod_Core.thisMonitor.Log("NEIGH: No horse exists", LogLevel.Debug); - return; - } - // else - // Game1.warpCharacter((NPC)horse, Game1.player.currentLocation.name, StardewValley.Game1.player.getTileLocationPoint(), false, true); - - - - - string myname = StardewValley.Game1.player.name; - - string mylocation = Path.Combine(Mod_Core.animal_path, "Horse_Save_Info_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - - Mod_Core.thisMonitor.Log("The horse save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Debug); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Horse: Save_Anywhere Info. Editing this might break some things."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Horse Current Map Name"; - mystring3[3] = horse.currentLocation.name.ToString(); - - mystring3[4] = "Horse X Position"; - mystring3[5] = horse.getTileX().ToString(); - - mystring3[6] = "Horse Y Position"; - mystring3[7] = horse.getTileY().ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - // Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now."); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Horse: Save_Anywhere Info. Editing this might break some things."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Horse Current Map Name"; - mystring3[3] = horse.currentLocation.name.ToString(); - - mystring3[4] = "Horse X Position"; - mystring3[5] = horse.getTileX().ToString(); - - mystring3[6] = "Horse Y Position"; - mystring3[7] = horse.getTileY().ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - } - } - - public static void Load_Horse_Info() - { - Horse horse = Utility.findHorse(); - if (horse == null) - { - Mod_Core.thisMonitor.Log("NEIGH: No horse exists", LogLevel.Debug); - return; - } - // DataLoader_Settings(); - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Mod_Core.animal_path, "Horse_Save_Info_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - } - - else - { - string horse_map_name = ""; - int horse_x; - int horse_y; - Point horse_point; - string[] readtext = File.ReadAllLines(mylocation3); - horse_map_name = Convert.ToString(readtext[3]); - horse_x = Convert.ToInt32(readtext[5]); - horse_y = Convert.ToInt32(readtext[7]); - horse_point.X = horse_x; - horse_point.Y = horse_y; - Game1.warpCharacter((NPC)horse, horse_map_name, horse_point, false, true); - } - } - } -} diff --git a/GeneralMods/SaveAnywhere/Mod_Core.cs b/GeneralMods/SaveAnywhere/Mod_Core.cs deleted file mode 100644 index 62bf003f..00000000 --- a/GeneralMods/SaveAnywhere/Mod_Core.cs +++ /dev/null @@ -1,1119 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using Microsoft.Xna.Framework; -using StardewModdingAPI; -using StardewModdingAPI.Events; -using StardewValley; -using StardewValley.Characters; - -namespace Omegasis.SaveAnywhere -{ - public class Mod_Core : StardewModdingAPI.Mod - { - - public static string mod_path; - public static string player_path; - public static string animal_path; - public static string npc_path; - public static bool npc_warp; - public static int checking_time; - public static bool once; - public static bool new_day; - Dictionary npc_key_value_pair; - - public static IMonitor thisMonitor; - - public override void Entry(IModHelper helper) - { - try { - StardewModdingAPI.Events.ControlEvents.KeyPressed += KeyPressed_Save_Load_Menu; - StardewModdingAPI.Events.SaveEvents.AfterLoad += PlayerEvents_LoadedGame; - StardewModdingAPI.Events.GameEvents.UpdateTick += Warp_Check; - StardewModdingAPI.Events.GameEvents.UpdateTick += PassiveSaveChecker; - StardewModdingAPI.Events.TimeEvents.TimeOfDayChanged += NPC_scheduel_update; - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged; - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_OnNewDay; - mod_path = Helper.DirectoryPath; - npc_key_value_pair = new Dictionary(); - thisMonitor = Monitor; - } - catch(Exception x) - { - Monitor.Log(x.ToString()); - } - } - - private void PassiveSaveChecker(object sender, EventArgs e) - { - if (GameUtilities.passiveSave == true && Game1.activeClickableMenu==null) - { - Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); - GameUtilities.passiveSave = false; - } - } - - //done - private void TimeEvents_OnNewDay(object sender, EventArgsIntChanged e) - { - try { - //Log.Info("Day of Month Changed"); - new_day = true; - string name = Game1.player.name; - Mod_Core.player_path = Path.Combine(Mod_Core.mod_path, "Save_Data", name); - - } - catch(Exception err) - { - Monitor.Log(err.ToString()); - } - } - - //done - private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e) - { - try { - //new_day = true; - // Log.Info("Day of Month Changed"); - npc_key_value_pair.Clear(); - foreach (var loc in Game1.locations) - { - foreach (var character in loc.characters) - { - - if(!npc_key_value_pair.ContainsKey(character.name)) npc_key_value_pair.Add(character.name, parseSchedule(character)); - // Monitor.Log(parseSchedule(character)); - } - } - } - catch(Exception err) - { - Monitor.Log(err.ToString()); - } - } - - private void NPC_scheduel_update(object sender, EventArgs e) - { - - if (Game1.weatherIcon == 4) - { - return; - } - if (Game1.isFestival() == true) - { - return; - } - if (Game1.eventUp == true) - { - return; - } - //if (once == true) return; - //FieldInfo field = typeof(NPC).GetField("scheduleTimeToTry", BindingFlags.NonPublic | BindingFlags.Instance); - // MethodInfo dynMethod = typeof(NPC).GetMethod("prepareToDisembarkOnNewSchedulePath",BindingFlags.NonPublic | BindingFlags.Instance); - MethodInfo dynMethod2 = typeof(NPC).GetMethod("pathfindToNextScheduleLocation", BindingFlags.NonPublic | BindingFlags.Instance); - - if (npc_warp == false) return; - if (new_day == true) return; - List child_list = new List(); - child_list = StardewValley.Game1.player.getChildren(); - foreach (var loc in Game1.locations) - { - foreach (var npc in loc.characters) - { - if (npc.DirectionsToNewLocation != null) continue; - if (npc.isMoving() == true) continue; - if (npc.Schedule == null) continue; - if (npc.controller != null) continue; - foreach (var child_name in child_list) - { - if (npc.name == child_name.name) continue; - } - if (npc.name == Game1.player.getPetName()) continue; - Horse horse = StardewValley.Utility.findHorse(); - if (horse != null) - { - if (npc.name == horse.name) continue; - } - // Log.Info("THIS IS MY NPC" + npc.name); - // Monitor.Log("NO SCHEDULE FOUND FOR " + npc.name); - - - // npc.checkSchedule(Game1.timeOfDay); - SchedulePathDescription schedulePathDescription; - - //int myint = (int)field.GetValue(npc); - /* - npc.Schedule.TryGetValue(Game1.timeOfDay, out schedulePathDescription); - int i = 0; - int pseudo_time=0; - - while (schedulePathDescription == null) - { - i += 10; - pseudo_time = Game1.timeOfDay - i; - if (pseudo_time <= 600) { break; } - npc.Schedule.TryGetValue(pseudo_time, out schedulePathDescription); - checking_time = pseudo_time; - } - // npc.directionsToNewLocation = schedulePathDescription; - // npc.prepareToDisembarkOnNewSchedulePath(); - - //field.SetValue(npc, 9999999); - - npc.DirectionsToNewLocation = schedulePathDescription; - */ - ////////////////////////////////////////// - // Log.Info("Does this break here 1"); - Dictionary dictionary; - string key_value = ""; - try - { - dictionary = Game1.content.Load>("Characters\\schedules\\" + npc.name); - } - catch (Exception ex) - { - this.Monitor.Log(ex.ToString(), LogLevel.Error); - // dictionary = new Dictionary();//(Dictionary)null; - continue; - } - // Log.Info("Does this break here 2"); - ////////////////////// - string value; - string end_map; - int x; - int y; - int end_dir; - npc_key_value_pair.TryGetValue(npc.name, out key_value); - if (key_value == "" || key_value == null) - { - Monitor.Log("THIS IS AWKWARD"); - continue; - } - dictionary.TryGetValue(key_value, out value); - // Log.Info("Does this break here 3"); - string[] valueArray1 = value.Split('/'); - int count1 = 0; - foreach (var josh in valueArray1) - { - string[] valueArray2 = valueArray1[count1].Split(' '); - - - if (valueArray2.Contains("GOTO")) - { - - for (int i = 0; i < valueArray2.Length; i++) - { - string s = valueArray2.ElementAt(i); - if (s == "GOTO") - { - dictionary.TryGetValue(valueArray2.ElementAt(i + 1), out value); - // Log.Info("Does this break here 3"); - string[] valueArray3 = value.Split('/'); - int count10 = 0; - - string[] valueArray4 = valueArray3[count10].Split(' '); - valueArray2 = valueArray4; - - } - } - } - - try { - if (Convert.ToInt32(valueArray2.ElementAt(0)) > Game1.timeOfDay) break; - end_map = Convert.ToString(valueArray2.ElementAt(1)); - x = Convert.ToInt32(valueArray2.ElementAt(2)); - y = Convert.ToInt32(valueArray2.ElementAt(3)); - end_dir = Convert.ToInt32(valueArray2.ElementAt(4)); - //MOST RELIABLE - schedulePathDescription = (SchedulePathDescription)dynMethod2.Invoke(npc, new object[] { npc.currentLocation.name, npc.getTileX(), npc.getTileY(), end_map, x, y, end_dir, null, null }); - - //FASTEST - //schedulePathDescription = pathfindToNextScheduleLocation(npc,npc.currentLocation.name, npc.getTileX(), npc.getTileY(), end_map, x, y, end_dir, null, null ); - count1++; - } - catch (Exception err) - { - this.Monitor.Log(err.ToString(), LogLevel.Error); - // Monitor.Log(npc.name); - foreach (var v in valueArray2) - { - //Monitor.Log(v); - } - schedulePathDescription = null; - // Monitor.Log(err); - } - - if (schedulePathDescription == null) continue; - // Log.Info("This works 2"); - // Utility.getGameLocationOfCharacter(npc); - // Log.Info("This works 3"); - - npc.DirectionsToNewLocation = schedulePathDescription; - npc.controller = new PathFindController(npc.DirectionsToNewLocation.route, (Character)npc, Utility.getGameLocationOfCharacter(npc)) - { - finalFacingDirection = npc.DirectionsToNewLocation.facingDirection, - endBehaviorFunction = null//npc.getRouteEndBehaviorFunction(npc.DirectionsToNewLocation.endOfRouteBehavior, npc.DirectionsToNewLocation.endOfRouteMessage) - }; - - } - } - } - once = true; - } - - - //done - /* - private void NPC_scheduel_update(object sender, EventArgs e) - { - /* - foreach (var key in npc_key_value_pair) - { - NPC npc = Game1.getCharacterFromName(key.Key); - Monitor.Log(npc.name); - Dictionary sch =npc.getSchedule(Game1.dayOfMonth); - if (sch == null) continue; - foreach (var ehh in sch) - { - Monitor.Log(ehh.Key); - Monitor.Log(ehh.Value); - } - } - - - return; - - //if (once == true) return; - //FieldInfo field = typeof(NPC).GetField("scheduleTimeToTry", BindingFlags.NonPublic | BindingFlags.Instance); - // MethodInfo dynMethod = typeof(NPC).GetMethod("prepareToDisembarkOnNewSchedulePath",BindingFlags.NonPublic | BindingFlags.Instance); - // MethodInfo dynMethod2 = typeof(NPC).GetMethod("pathfindToNextScheduleLocation", BindingFlags.NonPublic | BindingFlags.Instance); - - if (npc_warp == false) - { - Monitor.Log("LOL WHUT"); - return; - } - if (new_day == true) - { - Monitor.Log("Interesting"); - return; - } - List child_list = new List(); - child_list = StardewValley.Game1.player.getChildren(); - foreach (var loc in Game1.locations) - { - foreach (var npc in loc.characters) - { - // if (npc.DirectionsToNewLocation != null) continue; - if (npc.isMoving() == true) - { - Monitor.Log("I AM MOVING"); - continue; - } - //if (npc.Schedule == null) continue; - foreach (var child_name in child_list) - { - if (npc.name == child_name.name) - { - Monitor.Log("I AM A CHILD"); - continue; - } - } - if (Game1.player.hasPet() == true) { - if (npc.name == Game1.player.getPetName()) - { - Monitor.Log("I AM A PET"); - continue; - } - } - Horse horse = StardewValley.Utility.findHorse(); - - - if (horse != null) - { - if (npc.name == horse.name) continue; - } - Log.AsyncR("AM I GETTING TO STEP 1?"); - - // System.Threading.Thread.Sleep(1000); - - - // Log.Info("THIS IS MY NPC" + npc.name); - // Monitor.Log("NO SCHEDULE FOUND FOR " + npc.name); - - - // npc.checkSchedule(Game1.timeOfDay); - SchedulePathDescription schedulePathDescription; - - //int myint = (int)field.GetValue(npc); - - npc.Schedule.TryGetValue(Game1.timeOfDay, out schedulePathDescription); - int i = 0; - int pseudo_time=0; - - while (schedulePathDescription == null) - { - i += 10; - pseudo_time = Game1.timeOfDay - i; - if (pseudo_time <= 600) { break; } - npc.Schedule.TryGetValue(pseudo_time, out schedulePathDescription); - checking_time = pseudo_time; - } - // npc.directionsToNewLocation = schedulePathDescription; - // npc.prepareToDisembarkOnNewSchedulePath(); - - //field.SetValue(npc, 9999999); - - npc.DirectionsToNewLocation = schedulePathDescription; - - ////////////////////////////////////////// - // Log.Info("Does this break here 1"); - Dictionary dictionary; - string key_value = ""; - try - { - dictionary = Game1.content.Load>("Characters\\schedules\\" + npc.name); - } - catch (Exception ex) - { - // dictionary = new Dictionary();//(Dictionary)null; - //Monitor.Log(ex); - //Monitor.Log("YOU FIX THIS NOW"); - continue; - } - // Log.Info("Does this break here 2"); - ////////////////////// - string value; - string end_map; - int x; - int y; - int end_dir; - string behavior; - string message; - try { - npc_key_value_pair.TryGetValue(npc.name, out key_value); - if (key_value == "" || key_value == null) - { - Monitor.Log("NO KEYBLADE"); - continue; - } - dictionary.TryGetValue(key_value, out value); - - //Log.AsyncO(value); - // Log.Info("Does this break here 3"); - string[] valueArray1 = value.Split('/'); - int count1 = 0; - foreach (var josh in valueArray1) - { - Log.AsyncR("RAWRRRRR"); - string[] valueArray2 = valueArray1[count1].Split(' '); - - if (Convert.ToInt32(valueArray2.ElementAt(0)) > Game1.timeOfDay) break; - end_map = Convert.ToString(valueArray2.ElementAt(1)); - x = Convert.ToInt32(valueArray2.ElementAt(2)); - y = Convert.ToInt32(valueArray2.ElementAt(3)); - end_dir = Convert.ToInt32(valueArray2.ElementAt(4)); - schedulePathDescription = pathfindToNextScheduleLocation(npc, npc.currentLocation.name, npc.getTileX(), npc.getTileY(), end_map, x, y, end_dir, null, null); - count1++; - - - if (schedulePathDescription == null) - { - Monitor.Log("WHY???"); - } - // Log.Info("This works 2"); - // Utility.getGameLocationOfCharacter(npc); - // Log.Info("This works 3"); - - npc.DirectionsToNewLocation = schedulePathDescription; - npc.controller = new PathFindController(npc.DirectionsToNewLocation.route, (Character)npc, Utility.getGameLocationOfCharacter(npc)) - { - finalFacingDirection = npc.DirectionsToNewLocation.facingDirection, - endBehaviorFunction = null//npc.getRouteEndBehaviorFunction(npc.DirectionsToNewLocation.endOfRouteBehavior, npc.DirectionsToNewLocation.endOfRouteMessage) - }; - if (npc.controller == null) - { - Log.AsyncR("CRY"); - } - Monitor.Log("IS THIS RUNNING?"); - if (npc.name == "Shane") Monitor.Log("IS THIS RUNNING WITH BOOZE?"); - npc.warpToPathControllerDestination(); - } - } - catch(Exception err) - { - // Monitor.Log(err); - continue; - } - } - } - //once = true; - - } - */ - - - //done - private string get_key_value(NPC npc) - { - try - { - - - Dictionary dictionary; - string key_value = ""; - try - { - dictionary = Game1.content.Load>("Characters\\schedules\\" + npc.name); - } - catch (Exception ex) - { - this.Monitor.Log(ex.ToString(), LogLevel.Error); - dictionary = new Dictionary();//(Dictionary)null; - } - if (dictionary.ContainsKey(Game1.currentSeason + "_" + Convert.ToString(Game1.dayOfMonth))) - key_value = Game1.currentSeason + "_" + Convert.ToString(Game1.dayOfMonth); - for (int index = !Game1.player.friendships.ContainsKey(npc.name) ? -1 : Game1.player.friendships[npc.name][0] / 250; index > 0; --index) - { - if (dictionary.ContainsKey(Convert.ToString(Game1.dayOfMonth) + "_" + Convert.ToString(index))) - key_value = Convert.ToString(Game1.dayOfMonth) + "_" + Convert.ToString(index); - } - if (dictionary.ContainsKey(string.Empty + (object)Game1.dayOfMonth)) - key_value = string.Empty + (object)Game1.dayOfMonth; - if (npc.name.Equals("Pam") && Game1.player.mailReceived.Contains("ccVault")) - key_value = "bus"; - if (Game1.isRaining) - { - if (Game1.random.NextDouble() < 0.5 && dictionary.ContainsKey("rain2")) - key_value = "rain2"; - if (dictionary.ContainsKey("rain")) - key_value = "rain"; - } - List list = new List() - { - Game1.currentSeason, - Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth) - }; - int num1 = !Game1.player.friendships.ContainsKey(npc.name) ? -1 : Game1.player.friendships[npc.name][0] / 250; - while (num1 > 0) - { - list.Add(string.Empty + (object)num1); - if (dictionary.ContainsKey(string.Join("_", (IEnumerable)list))) - key_value = string.Join("_", (IEnumerable)list); - --num1; - list.RemoveAt(Enumerable.Count((IEnumerable)list) - 1); - } - if (dictionary.ContainsKey(string.Join("_", (IEnumerable)list))) - key_value = string.Join("_", (IEnumerable)list); - if (dictionary.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) - key_value = Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); - if (dictionary.ContainsKey(Game1.currentSeason)) - key_value = Game1.currentSeason; - if (dictionary.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) - key_value = "spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); - list.RemoveAt(Enumerable.Count((IEnumerable)list) - 1); - list.Add("spring"); - int num2 = !Game1.player.friendships.ContainsKey(npc.name) ? -1 : Game1.player.friendships[npc.name][0] / 250; - while (num2 > 0) - { - list.Add(string.Empty + (object)num2); - if (dictionary.ContainsKey(string.Join("_", (IEnumerable)list))) - key_value = string.Join("_", (IEnumerable)list); - --num2; - list.RemoveAt(Enumerable.Count((IEnumerable)list) - 1); - } - if (dictionary.ContainsKey("spring")) - key_value = "spring"; - - return key_value; - } - catch(Exception err) - { - Monitor.Log(err.ToString()); - return null; - } - } - - - private string parseSchedule(NPC npc) - { - if (npc.name.Equals("Robin") || Game1.player.currentUpgrade != null) - { - npc.isInvisible = false; - } - if (npc.name.Equals("Willy") && Game1.stats.DaysPlayed < 2u) - { - npc.isInvisible = true; - } - else if (npc.Schedule != null) - { - npc.followSchedule = true; - } - - Dictionary dictionary = null; - string result; - try - { - dictionary = Game1.content.Load>("Characters\\schedules\\" + npc.name); - } - catch (Exception) - { - result = null; - return ""; - } - if (npc.isMarried()) - { - string text = Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); - if ((npc.name.Equals("Penny") && (text.Equals("Tue") || text.Equals("Wed") || text.Equals("Fri"))) || (npc.name.Equals("Maru") && (text.Equals("Tue") || text.Equals("Thu"))) || (npc.name.Equals("Harvey") && (text.Equals("Tue") || text.Equals("Thu")))) - { - FieldInfo field = typeof(NPC).GetField("nameofTodaysSchedule", BindingFlags.NonPublic | BindingFlags.Instance); - field.SetValue(npc, "marriageJob"); - // npc.nameOfTodaysSchedule = "marriageJob"; - return (result = "marriageJob"); - } - if (!Game1.isRaining && dictionary.ContainsKey("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) - { - FieldInfo field = typeof(NPC).GetField("nameofTodaysSchedule", BindingFlags.NonPublic | BindingFlags.Instance); - field.SetValue(npc,"marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)); - return result="marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); - } - npc.followSchedule = false; - return null; - } - else - { - if (dictionary.ContainsKey(Game1.currentSeason + "_" + Game1.dayOfMonth)) - { - return result=(Game1.currentSeason + "_" + Game1.dayOfMonth); - } - int i; - for (i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); i > 0; i--) - { - if (dictionary.ContainsKey(Game1.dayOfMonth + "_" + i)) - { - return result=Game1.dayOfMonth + "_" + i; - } - } - if (dictionary.ContainsKey(string.Empty + Game1.dayOfMonth)) - { - return result=string.Empty + Game1.dayOfMonth; - } - if (npc.name.Equals("Pam") && Game1.player.mailReceived.Contains("ccVault")) - { - return result="bus"; - } - if (Game1.isRaining) - { - if (Game1.random.NextDouble() < 0.5 && dictionary.ContainsKey("rain2")) - { - return result="rain2"; - } - if (dictionary.ContainsKey("rain")) - { - return result="rain"; - } - } - List list = new List - { - Game1.currentSeason, - Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth) - }; - i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); - while (i > 0) - { - list.Add(string.Empty + i); - if (dictionary.ContainsKey(string.Join("_", list))) - { - return result=string.Join("_", list); - } - i--; - list.RemoveAt(list.Count - 1); - } - if (dictionary.ContainsKey(string.Join("_", list))) - { - return result=string.Join("_", list); - } - if (dictionary.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) - { - return result=Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); - } - if (dictionary.ContainsKey(Game1.currentSeason)) - { - return result=Game1.currentSeason; - } - if (dictionary.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) - { - return result="spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); - } - list.RemoveAt(list.Count - 1); - list.Add("spring"); - i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); - while (i > 0) - { - list.Add(string.Empty + i); - if (dictionary.ContainsKey(string.Join("_", list))) - { - return result=string.Join("_", list); - } - i--; - list.RemoveAt(list.Count - 1); - } - if (dictionary.ContainsKey("spring")) - { - return result="spring"; - } - return null; - } - - - } - - //done - private void ShippingCheck(object sender, EventArgs e) - { - try { - if (Game1.activeClickableMenu != null) return; - GameUtilities.shipping_check(); - } - catch(Exception err) - { - Monitor.Log(err.ToString()); - } - } - - //done - private void Warp_Check(object sender, EventArgs e) - { - try - { - string name = StardewValley.Game1.player.name; - Mod_Core.player_path = Path.Combine(Mod_Core.mod_path, "Save_Data", name); - if (!Directory.Exists(Mod_Core.player_path)) - { - //Log.AsyncM(Save_Anywhere_V2.Mod_Core.player_path); - //Log.AsyncC("WOOPS"); - return; - } - - // Log.AsyncY(Player_Utilities.has_player_warped_yet); - - if (Player_Utilities.has_player_warped_yet == false && Game1.player.isMoving() == true) - { - //Log.AsyncM("Ok Good"); - Player_Utilities.warp_player(); - Animal_Utilities.load_animal_info(); - NPC_Utilities.Load_NPC_Info(); - Player_Utilities.has_player_warped_yet = true; - - } - } - catch (Exception err) - { - //7Log.AsyncO("THIS DOESNT MAKE SENSE"); - Monitor.Log(err.ToString()); - } - } - - //done - private void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - try { - Player_Utilities.load_player_info(); - Config_Utilities.DataLoader_Settings(); - Config_Utilities.MyWritter_Settings(); - } - catch (Exception err) { - Monitor.Log(err.ToString()); - } - } - - public void KeyPressed_Save_Load_Menu(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) - { - if (e.KeyPressed.ToString() == Config_Utilities.key_binding) //if the key is pressed, load my cusom save function - { - if (Game1.activeClickableMenu != null) return; - try { - GameUtilities.save_game(); - } - catch(Exception exe) - { - Mod_Core.thisMonitor.Log(exe.ToString(), LogLevel.Error); - } - - } - } - - - - - private Dictionary parseMasterSchedule(NPC npc, string rawData) - { - string[] array = rawData.Split(new char[] - { - '/' - }); - Dictionary dictionary = new Dictionary(); - int num = 0; - if (array[0].Contains("GOTO")) - { - string text = array[0].Split(new char[] - { - ' ' - })[1]; - if (text.ToLower().Equals("season")) - { - text = Game1.currentSeason; - } - try - { - array = Game1.content.Load>("Characters\\schedules\\" + npc.name)[text].Split(new char[] - { - '/' - }); - } - catch (Exception) - { - return parseMasterSchedule(npc,Game1.content.Load>("Characters\\schedules\\" + npc.name)["spring"]); - } - } - if (array[0].Contains("NOT")) - { - string[] array2 = array[0].Split(new char[] - { - ' ' - }); - string a = array2[1].ToLower(); - if (a == "friendship") - { - string name = array2[2]; - int num2 = Convert.ToInt32(array2[3]); - bool flag = false; - using (List.Enumerator enumerator = Game1.getAllFarmers().GetEnumerator()) - { - while (enumerator.MoveNext()) - { - if (enumerator.Current.getFriendshipLevelForNPC(name) >= num2) - { - flag = true; - break; - } - } - } - if (flag) - { - return parseMasterSchedule(npc,Game1.content.Load>("Characters\\schedules\\" + npc.name)["spring"]); - } - num++; - } - } - if (array[num].Contains("GOTO")) - { - string text2 = array[num].Split(new char[] - { - ' ' - })[1]; - if (text2.ToLower().Equals("season")) - { - text2 = Game1.currentSeason; - } - array = Game1.content.Load>("Characters\\schedules\\" + npc.name)[text2].Split(new char[] - { - '/' - }); - num = 1; - } - - //FieldInfo field = typeof(NPC).GetField("scheduleTimeToTry", BindingFlags.NonPublic | BindingFlags.Instance); - Point point = npc.isMarried() ? new Point(0, 23) : new Point((int)npc.DefaultPosition.X / Game1.tileSize, (int)npc.DefaultPosition.Y / Game1.tileSize); - string text3 = npc.isMarried() ? "BusStop" : npc.defaultMap; - int num3 = num; - while (num3 < array.Length && array.Length > 1) - { - int num4 = 0; - string[] array3 = array[num3].Split(new char[] - { - ' ' - }); - int key = Convert.ToInt32(array3[num4]); - num4++; - string text4 = array3[num4]; - string endBehavior = null; - string endMessage = null; - int num5; - if (int.TryParse(text4, out num5)) - { - text4 = text3; - num4--; - } - num4++; - int num6 = Convert.ToInt32(array3[num4]); - num4++; - int num7 = Convert.ToInt32(array3[num4]); - num4++; - int finalFacingDirection = 2; - try - { - finalFacingDirection = Convert.ToInt32(array3[num4]); - num4++; - } - catch (Exception) - { - finalFacingDirection = 2; - } - if (changeScheduleForLocationAccessibility(npc,ref text4, ref num6, ref num7, ref finalFacingDirection)) - { - if (Game1.content.Load>("Characters\\schedules\\" + npc.name).ContainsKey("default")) - { - return parseMasterSchedule(npc,Game1.content.Load>("Characters\\schedules\\" + npc.name)["default"]); - } - return parseMasterSchedule(npc,Game1.content.Load>("Characters\\schedules\\" + npc.name)["spring"]); - } - else - { - if (num4 < array3.Length) - { - if (array3[num4].Length > 0 && array3[num4][0] == '"') - { - endMessage = array[num3].Substring(array[num3].IndexOf('"')); - } - else - { - endBehavior = array3[num4]; - num4++; - if (num4 < array3.Length && array3[num4].Length > 0 && array3[num4][0] == '"') - { - endMessage = array[num3].Substring(array[num3].IndexOf('"')).Replace("\"", ""); - } - } - } - dictionary.Add(key, pathfindToNextScheduleLocation(npc,text3, point.X, point.Y, text4, num6, num7, finalFacingDirection, endBehavior, endMessage)); - point.X = num6; - point.Y = num7; - text3 = text4; - num3++; - } - } - return dictionary; - } - - public Dictionary getSchedule(NPC npc,int dayOfMonth) - { - if (!npc.name.Equals("Robin") || Game1.player.currentUpgrade != null) - { - npc.isInvisible = false; - } - if (npc.name.Equals("Willy") && Game1.stats.DaysPlayed < 2u) - { - npc.isInvisible = true; - } - else if (npc.Schedule != null) - { - npc.followSchedule = true; - } - Dictionary dictionary = null; - Dictionary result; - try - { - dictionary = Game1.content.Load>("Characters\\schedules\\" + npc.name); - } - catch (Exception) - { - result = null; - return result; - } - if (npc.isMarried()) - { - string text = Game1.shortDayNameFromDayOfSeason(dayOfMonth); - if ((npc.name.Equals("Penny") && (text.Equals("Tue") || text.Equals("Wed") || text.Equals("Fri"))) || (npc.name.Equals("Maru") && (text.Equals("Tue") || text.Equals("Thu"))) || (npc.name.Equals("Harvey") && (text.Equals("Tue") || text.Equals("Thu")))) - { - FieldInfo field = typeof(NPC).GetField("nameofTodaysSchedule", BindingFlags.NonPublic | BindingFlags.Instance); - field.SetValue(npc, "marriageJob"); - return parseMasterSchedule(npc, (dictionary["marriageJob"])); - } - if (!Game1.isRaining && dictionary.ContainsKey("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) - { - FieldInfo field = typeof(NPC).GetField("nameofTodaysSchedule", BindingFlags.NonPublic | BindingFlags.Instance); - field.SetValue(npc, "marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)); - return parseMasterSchedule(npc, dictionary["marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)]); - } - npc.followSchedule = false; - return null; - } - else - { - if (dictionary.ContainsKey(Game1.currentSeason + "_" + Game1.dayOfMonth)) - { - return parseMasterSchedule(npc, dictionary[Game1.currentSeason + "_" + Game1.dayOfMonth]); - } - int i; - for (i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); i > 0; i--) - { - if (dictionary.ContainsKey(Game1.dayOfMonth + "_" + i)) - { - return parseMasterSchedule(npc, dictionary[Game1.dayOfMonth + "_" + i]); - } - } - if (dictionary.ContainsKey(string.Empty + Game1.dayOfMonth)) - { - return parseMasterSchedule(npc, dictionary[string.Empty + Game1.dayOfMonth]); - } - if (npc.name.Equals("Pam") && Game1.player.mailReceived.Contains("ccVault")) - { - return parseMasterSchedule(npc, dictionary["bus"]); - } - if (Game1.isRaining) - { - if (Game1.random.NextDouble() < 0.5 && dictionary.ContainsKey("rain2")) - { - return parseMasterSchedule(npc, dictionary["rain2"]); - } - if (dictionary.ContainsKey("rain")) - { - return parseMasterSchedule(npc,dictionary["rain"]); - } - } - List list = new List - { - Game1.currentSeason, - Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth) - }; - i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); - while (i > 0) - { - list.Add(string.Empty + i); - if (dictionary.ContainsKey(string.Join("_", list))) - { - return parseMasterSchedule(npc,dictionary[string.Join("_", list)]); - } - i--; - list.RemoveAt(list.Count - 1); - } - if (dictionary.ContainsKey(string.Join("_", list))) - { - return parseMasterSchedule(npc,dictionary[string.Join("_", list)]); - } - if (dictionary.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) - { - return parseMasterSchedule(npc,dictionary[Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)]); - } - if (dictionary.ContainsKey(Game1.currentSeason)) - { - return parseMasterSchedule(npc,dictionary[Game1.currentSeason]); - } - if (dictionary.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) - { - return parseMasterSchedule(npc,dictionary["spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)]); - } - list.RemoveAt(list.Count - 1); - list.Add("spring"); - i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); - while (i > 0) - { - list.Add(string.Empty + i); - if (dictionary.ContainsKey(string.Join("_", list))) - { - return parseMasterSchedule(npc,dictionary[string.Join("_", list)]); - } - i--; - list.RemoveAt(list.Count - 1); - } - if (dictionary.ContainsKey("spring")) - { - return parseMasterSchedule(npc,dictionary["spring"]); - } - return null; - } - } - private bool changeScheduleForLocationAccessibility(NPC npc,ref string locationName, ref int tileX, ref int tileY, ref int facingDirection) - { - string a = locationName; - if (!(a == "JojaMart") && !(a == "Railroad")) - { - if (a == "CommunityCenter") - { - return !Game1.isLocationAccessible(locationName); - } - } - else if (!Game1.isLocationAccessible(locationName)) - { - if (!Game1.content.Load>("Characters\\schedules\\" + npc.name).ContainsKey(locationName + "_Replacement")) - { - return true; - } - string[] array = Game1.content.Load>("Characters\\schedules\\" + npc.name)[locationName + "_Replacement"].Split(new char[] - { - ' ' - }); - locationName = array[0]; - tileX = Convert.ToInt32(array[1]); - tileY = Convert.ToInt32(array[2]); - facingDirection = Convert.ToInt32(array[3]); - } - return false; - } - - private SchedulePathDescription pathfindToNextScheduleLocation(NPC npc,string startingLocation, int startingX, int startingY, string endingLocation, int endingX, int endingY, int finalFacingDirection, string endBehavior, string endMessage) - { - Stack stack = new Stack(); - Point warpPointTarget = new Point(startingX, startingY); - List list = (!startingLocation.Equals(endingLocation)) ? getLocationRoute(npc, startingLocation, endingLocation) : null; - if (list != null) - { - for (int i = 0; i < list.Count; i++) - { - GameLocation locationFromName = Game1.getLocationFromName(list[i]); - if (i < list.Count - 1) - { - Point warpPointTo = locationFromName.getWarpPointTo(list[i + 1]); - if (warpPointTo.Equals(Point.Zero) || warpPointTarget.Equals(Point.Zero)) - { - throw new Exception("schedule pathing tried to find a warp point that doesn't exist."); - } - stack = addToStackForSchedule(stack, PathFindController.findPathForNPCSchedules(warpPointTarget, warpPointTo, locationFromName, 30000)); - warpPointTarget = locationFromName.getWarpPointTarget(warpPointTo); - } - else - { - stack = addToStackForSchedule(stack, PathFindController.findPathForNPCSchedules(warpPointTarget, new Point(endingX, endingY), locationFromName, 30000)); - } - } - } - else if (startingLocation.Equals(endingLocation)) - { - stack = PathFindController.findPathForNPCSchedules(warpPointTarget, new Point(endingX, endingY), Game1.getLocationFromName(startingLocation), 30000); - } - return new SchedulePathDescription(stack, finalFacingDirection, endBehavior, endMessage); - } - - private List getLocationRoute(NPC npc,string startingLocation, string endingLocation) - { - FieldInfo field = typeof(NPC).GetField("routesFromLocationToLocation", BindingFlags.NonPublic | BindingFlags.Instance); - List> s = (List>)field.GetValue(npc); - foreach (List current in s) - { - if (current.First().Equals(startingLocation) && current.Last().Equals(endingLocation) && (npc.gender == 0 || !current.Contains("BathHouse_MensLocker")) && (npc.gender != 0 || !current.Contains("BathHouse_WomensLocker"))) - { - return current; - } - } - return null; - } - - - private Stack addToStackForSchedule(Stack original, Stack toAdd) - { - if (toAdd == null) - { - return original; - } - original = new Stack(original); - while (original.Count > 0) - { - toAdd.Push(original.Pop()); - } - return toAdd; - } - } -} diff --git a/GeneralMods/SaveAnywhere/NPC_Utilities.cs b/GeneralMods/SaveAnywhere/NPC_Utilities.cs deleted file mode 100644 index c3f3d73f..00000000 --- a/GeneralMods/SaveAnywhere/NPC_Utilities.cs +++ /dev/null @@ -1,198 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.Xna.Framework; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.SaveAnywhere -{ - class NPC_Utilities - { - public static string npc_name; - public static int npc_tile_x; - public static int npc_tile_y; - public static string npc_current_map_name; - public static System.Collections.Generic.List> routesFromLocationToLocation = new List>(); - public static Microsoft.Xna.Framework.Point npc_point; - - public static void Save_NPC_Info() - { - Mod_Core.npc_path = Path.Combine(Mod_Core.player_path, "NPC_Save_Info"); - if (!Directory.Exists(Mod_Core.npc_path)) - { - Directory.CreateDirectory(Mod_Core.npc_path); - } - foreach (var location in Game1.locations) - { - foreach (var npc in location.characters) - { - if (npc.IsMonster == true) continue; - if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue; - npc_name = npc.name; - npc_current_map_name = location.name; - npc_tile_x = npc.getTileX(); - npc_tile_y = npc.getTileY(); - string mylocation = Path.Combine(Mod_Core.npc_path, npc.name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Mod_Core.thisMonitor.Log("Save Anywhere: The NPC save info for " + npc_name + " doesn't exist. It will be created when the custom saving method is run. Which is now."); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "NPC: Save_Anywhere Info. Editing this might break some things."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "NPC Name"; - mystring3[3] = npc_name.ToString(); - - mystring3[4] = "NPC Current Map Name"; - mystring3[5] = npc_current_map_name.ToString(); - - mystring3[6] = "NPC X Position"; - mystring3[7] = npc_tile_x.ToString(); - - mystring3[8] = "NPC Y Position"; - mystring3[9] = npc_tile_y.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - // Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now."); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - mystring3[0] = "NPC: Save_Anywhere Info. Editing this might break some things."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "NPC Current Map Name"; - mystring3[3] = npc_name.ToString(); - - mystring3[4] = "NPC Current Map Name"; - mystring3[5] = npc_current_map_name.ToString(); - - mystring3[6] = "NPC X Position"; - mystring3[7] = npc_tile_x.ToString(); - - mystring3[8] = "NPC Y Position"; - mystring3[9] = npc_tile_y.ToString(); - File.WriteAllLines(mylocation3, mystring3); - } - } - - } - - - } - - public static void Load_NPC_Info() - { - List npc_list = new List(); - foreach (var location in Game1.locations) - { - foreach (var npc in location.characters) - { - if (npc.IsMonster == true) continue; - if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue; - if (npc is StardewValley.NPC || npc is StardewValley.Characters.Cat || npc is StardewValley.Characters.Dog) npc_list.Add(npc); - } - } - foreach(var npc in npc_list) { - if (npc.IsMonster == true) continue; - if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue; - - - Mod_Core.npc_path = Path.Combine(Mod_Core.player_path, "NPC_Save_Info"); - if (!Directory.Exists(Mod_Core.npc_path)) - { - Directory.CreateDirectory(Mod_Core.npc_path); - } - string mylocation = Path.Combine(Mod_Core.npc_path, npc.name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Mod_Core.thisMonitor.Log("Missing character file?!?", LogLevel.Error); - continue; - } - - else - { - string[] readtext = File.ReadAllLines(mylocation3); - npc_name = Convert.ToString(readtext[3]); - npc_current_map_name = Convert.ToString(readtext[5]); - npc_tile_x = Convert.ToInt32(readtext[7]); - npc_tile_y = Convert.ToInt32(readtext[9]); - npc_point = new Microsoft.Xna.Framework.Point(); - npc_point.X = npc_tile_x; - npc_point.Y = npc_tile_y; - if (npc_current_map_name == "" || npc_current_map_name == null) continue; - //Log.Info("Warped NPC" +npc_name); - Game1.warpCharacter((StardewValley.NPC)npc, npc_current_map_name, npc_point, false, true); - - // npc.updateMovement(Game1.getLocationFromName(npc_current_map_name), Game1.currentGameTime); - //npc.moveCharacterOnSchedulePath(); - // npc.dayUpdate(Game1.dayOfMonth); - //npc_update(npc, Game1.dayOfMonth); - - // npc.DirectionsToNewLocation = pathfindToNextScheduleLocation(npc, npc.currentLocation.name, npc.getTileX(), npc.getTileY(), npc.currentLocation.name, 52, 99, 3, "", ""); - // npc.updateMovement(npc.currentLocation,Game1.currentGameTime); - //npc.Schedule = npc.getSchedule(Game1.dayOfMonth); - //npc.moveCharacterOnSchedulePath(); - - - } - } - Mod_Core.npc_warp = true; - } - private static Stack addToStackForSchedule(Stack original, Stack toAdd) - { - if (toAdd == null) - return original; - original = new Stack((IEnumerable)original); - while (original.Count > 0) - toAdd.Push(original.Pop()); - return toAdd; - } - private static List getLocationRoute(NPC npc, string startingLocation, string endingLocation) - { - foreach (List list in routesFromLocationToLocation) - { - if (Enumerable.First((IEnumerable)list).Equals(startingLocation) && Enumerable.Last((IEnumerable)list).Equals(endingLocation) && (npc.gender == 0 || !list.Contains("BathHouse_MensLocker")) && (npc.gender != 0 || !list.Contains("BathHouse_WomensLocker"))) - return list; - } - return (List)null; - } - private static SchedulePathDescription pathfindToNextScheduleLocation(NPC npc,string startingLocation, int startingX, int startingY, string endingLocation, int endingX, int endingY, int finalFacingDirection, string endBehavior, string endMessage) - { - Stack stack = new Stack(); - Point startPoint = new Point(startingX, startingY); - List list = startingLocation.Equals(endingLocation) ? (List)null : getLocationRoute(npc,startingLocation, endingLocation); - if (list != null) - { - for (int index = 0; index < Enumerable.Count((IEnumerable)list); ++index) - { - GameLocation locationFromName = Game1.getLocationFromName(list[index]); - if (index < Enumerable.Count((IEnumerable)list) - 1) - { - Point warpPointTo = locationFromName.getWarpPointTo(list[index + 1]); - if (warpPointTo.Equals(Point.Zero) || startPoint.Equals(Point.Zero)) - throw new Exception("schedule pathing tried to find a warp point that doesn't exist."); - stack = addToStackForSchedule(stack, PathFindController.findPathForNPCSchedules(startPoint, warpPointTo, locationFromName, 30000)); - startPoint = locationFromName.getWarpPointTarget(warpPointTo); - } - else - stack = addToStackForSchedule(stack, PathFindController.findPathForNPCSchedules(startPoint, new Point(endingX, endingY), locationFromName, 30000)); - } - } - else if (startingLocation.Equals(endingLocation)) - stack = PathFindController.findPathForNPCSchedules(startPoint, new Point(endingX, endingY), Game1.getLocationFromName(startingLocation), 30000); - return new SchedulePathDescription(stack, finalFacingDirection, endBehavior, endMessage); - - } - } - } diff --git a/GeneralMods/SaveAnywhere/New_Shipping_Menu.cs b/GeneralMods/SaveAnywhere/New_Shipping_Menu.cs deleted file mode 100644 index 6969f66c..00000000 --- a/GeneralMods/SaveAnywhere/New_Shipping_Menu.cs +++ /dev/null @@ -1,655 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: StardewValley.Menus.ShippingMenu -// Assembly: StardewValley, Version=1.0.6054.4284, Culture=neutral, PublicKeyToken=null -// MVID: 5E41EDE0-CE7E-41F9-BCB3-07C910BA6113 -// Assembly location: C:\Users\owner\Downloads\steam_cmd\ehh\StardewValley.exe - -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using StardewModdingAPI; -using StardewValley; -using StardewValley.BellsAndWhistles; -using StardewValley.Menus; - -namespace Omegasis.SaveAnywhere -{ - public class New_Shipping_Menu : IClickableMenu - { - public int currentPage = -1; - public int currentTab = 0; - private List categories = new List(); - private List categoryTotals = new List(); - private List categoryDials = new List(); - private List> categoryItems = new List>(); - private int introTimer = 3500; - public List animations = new List(); - public const int farming_category = 0; - public const int foraging_category = 1; - public const int fishing_category = 2; - public const int mining_category = 3; - public const int other_category = 4; - public const int total_category = 5; - public const int timePerIntroCategory = 500; - public const int outroFadeTime = 800; - public const int smokeRate = 100; - public const int categorylabelHeight = 25; - public const int itemsPerCategoryPage = 9; - private ClickableTextureComponent okButton; - private ClickableTextureComponent forwardButton; - private ClickableTextureComponent backButton; - private int categoryLabelsWidth; - private int plusButtonWidth; - private int itemSlotWidth; - private int itemAndPlusButtonWidth; - private int totalWidth; - private int centerX; - private int centerY; - private int outroFadeTimer; - private int outroPauseBeforeDateChange; - private int finalOutroTimer; - private int smokeTimer; - private int dayPlaqueY; - private float weatherX; - private bool outro; - private bool newDayPlaque; - private bool savedYet; - private SaveGameMenu saveGameMenu; - - public New_Shipping_Menu(List items) - : base(Game1.viewport.Width / 2 - 640, Game1.viewport.Height / 2 - 360, 1280, 720, false) - { - this.parseItems(items); - if (!Game1.wasRainingYesterday) - Game1.changeMusicTrack(!Game1.currentSeason.Equals("summer") ? "none" : "nightTime"); - this.categoryLabelsWidth = Game1.tileSize * 7; - this.plusButtonWidth = 10 * Game1.pixelZoom; - this.itemSlotWidth = 24 * Game1.pixelZoom; - this.itemAndPlusButtonWidth = this.plusButtonWidth + this.itemSlotWidth + 2 * Game1.pixelZoom; - this.totalWidth = this.categoryLabelsWidth + this.itemAndPlusButtonWidth; - this.centerX = Game1.viewport.Width / 2; - this.centerY = Game1.viewport.Height / 2; - for (int index = 0; index < 6; ++index) - { - List list = this.categories; - ClickableTextureComponent textureComponent1 = new ClickableTextureComponent("texture"+Convert.ToString(index),new Rectangle(this.centerX + this.totalWidth / 2 - this.plusButtonWidth, this.centerY - 25 * Game1.pixelZoom * 3 + index * 27 * Game1.pixelZoom, this.plusButtonWidth, 11 * Game1.pixelZoom), "", this.getCategoryName(index), Game1.mouseCursors, new Rectangle(392, 361, 10, 11), (float)Game1.pixelZoom, false); - textureComponent1.visible = index < 5 && Enumerable.Count((IEnumerable)this.categoryItems[index]) > 0; - ClickableTextureComponent textureComponent2 = textureComponent1; - list.Add(textureComponent2); - } - this.dayPlaqueY = this.categories[0].bounds.Y - Game1.tileSize * 2; - this.okButton = new ClickableTextureComponent("Done", new Rectangle(this.centerX + this.totalWidth / 2 - this.itemAndPlusButtonWidth + Game1.tileSize / 2, this.centerY + 25 * Game1.pixelZoom * 3 - Game1.tileSize, Game1.tileSize, Game1.tileSize), (string)null, "Done", Game1.mouseCursors, new Rectangle(128, 256, 64, 64), 1f, false); - this.backButton = new ClickableTextureComponent("Back", new Rectangle(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen + this.height - 16 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), (string)null, "", Game1.mouseCursors, new Rectangle(352, 495, 12, 11), (float)Game1.pixelZoom, false); - this.forwardButton = new ClickableTextureComponent("forward", new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - 16 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), (string)null, "", Game1.mouseCursors, new Rectangle(365, 495, 12, 11), (float)Game1.pixelZoom, false); - if (Game1.dayOfMonth == 25 && Game1.currentSeason.Equals("winter")) - { - Vector2 position = new Vector2((float)Game1.viewport.Width, (float)Game1.random.Next(0, 200)); - Rectangle sourceRect = new Rectangle(640, 800, 32, 16); - int numberOfLoops = 1000; - this.animations.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, sourceRect, 80f, 2, numberOfLoops, position, false, false, 0.01f, 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, true) - { - motion = new Vector2(-4f, 0.0f), - delayBeforeAnimationStart = 3000 - }); - } - Game1.stats.checkForShippingAchievements(); - if (Game1.player.achievements.Contains(34) || !Utility.hasFarmerShippedAllItems()) - return; - Game1.getAchievement(34); - } - - public void parseItems(List items) - { - Utility.consolidateStacks(items); - for (int index = 0; index < 6; ++index) - { - this.categoryItems.Add(new List()); - this.categoryTotals.Add(0); - this.categoryDials.Add(new MoneyDial(7, index == 5)); - } - foreach (Item obj in items) - { - if (obj is StardewValley.Object) - { - StardewValley.Object o = obj as StardewValley.Object; - int categoryIndexForObject = this.getCategoryIndexForObject(o); - this.categoryItems[categoryIndexForObject].Add((Item)o); - List list; - int index; - (list = this.categoryTotals)[index = categoryIndexForObject] = list[index] + o.sellToStorePrice() * o.Stack; - Game1.stats.itemsShipped += (uint)o.Stack; - if (o.countsForShippedCollection()) - Game1.player.shippedBasic(o.parentSheetIndex, o.stack); - } - } - for (int index = 0; index < 5; ++index) - { - List list; - (list = this.categoryTotals)[5] = list[5] + this.categoryTotals[index]; - this.categoryItems[5].AddRange((IEnumerable)this.categoryItems[index]); - this.categoryDials[index].currentValue = this.categoryTotals[index]; - this.categoryDials[index].previousTargetValue = this.categoryDials[index].currentValue; - } - this.categoryDials[5].currentValue = this.categoryTotals[5]; - Game1.player.Money += this.categoryTotals[5]; - } - - public int getCategoryIndexForObject(StardewValley.Object o) - { - switch (o.parentSheetIndex) - { - case 296: - case 396: - case 402: - case 406: - case 410: - case 414: - case 418: - return 1; - default: - int num = o.category; - switch (num + 81) - { - case 0: - label_8: - return 1; - case 1: - case 2: - case 6: - label_6: - return 0; - default: - switch (num + 27) - { - case 0: - case 4: - goto label_8; - case 1: - goto label_6; - case 7: - label_7: - return 2; - default: - switch (num + 6) - { - case 0: - case 1: - goto label_6; - case 2: - goto label_7; - case 4: - label_9: - return 3; - default: - switch (num + 15) - { - case 0: - case 3: - goto label_9; - case 1: - goto label_6; - default: - return 4; - } - } - } - } - } - } - - public string getCategoryName(int index) - { - switch (index) - { - case 0: - return "Farming"; - case 1: - return "Foraging"; - case 2: - return "Fishing"; - case 3: - return "Mining"; - case 4: - return "Other"; - case 5: - return "Total"; - default: - return ""; - } - } - - public override void update(GameTime time) - { - base.update(time); - if (this.saveGameMenu != null) - { - this.saveGameMenu.update(time); - if (this.saveGameMenu.quit) - { - this.saveGameMenu = (SaveGameMenu)null; - this.savedYet = true; - } - } - this.weatherX += (float)time.ElapsedGameTime.Milliseconds * 0.03f; - for (int index = Enumerable.Count((IEnumerable)this.animations) - 1; index >= 0; --index) - { - if (this.animations[index].update(time)) - this.animations.RemoveAt(index); - } - if (this.outro) - { - if (this.outroFadeTimer > 0) - this.outroFadeTimer -= time.ElapsedGameTime.Milliseconds; - else if (this.outroFadeTimer <= 0 && this.dayPlaqueY < this.centerY - Game1.tileSize) - { - if (Enumerable.Count((IEnumerable)this.animations) > 0) - this.animations.Clear(); - this.dayPlaqueY += (int)Math.Ceiling((double)time.ElapsedGameTime.Milliseconds * 0.349999994039536); - if (this.dayPlaqueY >= this.centerY - Game1.tileSize) - this.outroPauseBeforeDateChange = 700; - } - else if (this.outroPauseBeforeDateChange > 0) - { - this.outroPauseBeforeDateChange -= time.ElapsedGameTime.Milliseconds; - if (this.outroPauseBeforeDateChange <= 0) - { - this.newDayPlaque = true; - Game1.playSound("newRecipe"); - if (!Game1.currentSeason.Equals("winter")) - DelayedAction.playSoundAfterDelay(!Game1.isRaining ? "rooster" : "rainsound", 1500); - this.finalOutroTimer = 2000; - this.animations.Clear(); - if (!this.savedYet) - { - if (this.saveGameMenu != null) - return; - try - { - // Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); - } - catch (Exception rrr) - { - Game1.showRedMessage("Can't save here. See log for error."); - Mod_Core.thisMonitor.Log(rrr.ToString(), LogLevel.Error); - } - return; - } - } - } - else if (this.finalOutroTimer > 0 && this.savedYet) - { - this.finalOutroTimer -= time.ElapsedGameTime.Milliseconds; - if (this.finalOutroTimer <= 0) - this.exitThisMenu(false); - } - } - if (this.introTimer >= 0) - { - int num = this.introTimer; - this.introTimer -= time.ElapsedGameTime.Milliseconds * (Game1.oldMouseState.LeftButton != ButtonState.Pressed ? 1 : 3); - if (num % 500 < this.introTimer % 500 && this.introTimer <= 3000) - { - int which = 4 - this.introTimer / 500; - if (which < 6 && which > -1) - { - if (Enumerable.Count((IEnumerable)this.categoryItems[which]) > 0) - { - Game1.playSound(this.getCategorySound(which)); - this.categoryDials[which].currentValue = 0; - this.categoryDials[which].previousTargetValue = 0; - } - else - Game1.playSound("stoneStep"); - } - } - if (this.introTimer >= 0) - return; - Game1.playSound("money"); - this.categoryDials[5].currentValue = 0; - this.categoryDials[5].previousTargetValue = 0; - } - else - { - if (Game1.dayOfMonth == 28 || this.outro) - return; - if (!Game1.wasRainingYesterday) - { - Vector2 position = new Vector2((float)Game1.viewport.Width, (float)Game1.random.Next(200)); - Rectangle sourceRect = new Rectangle(640, 752, 16, 16); - int num = Game1.random.Next(1, 4); - if (Game1.random.NextDouble() < 0.001) - { - bool flipped = Game1.random.NextDouble() < 0.5; - if (Game1.random.NextDouble() < 0.5) - this.animations.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Rectangle(640, 826, 16, 8), 40f, 4, 0, new Vector2((float)Game1.random.Next(this.centerX * 2), (float)Game1.random.Next(this.centerY)), false, flipped) - { - rotation = 3.141593f, - scale = (float)Game1.pixelZoom, - motion = new Vector2(!flipped ? 8f : -8f, 8f), - local = true - }); - else - this.animations.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Rectangle(258, 1680, 16, 16), 40f, 4, 0, new Vector2((float)Game1.random.Next(this.centerX * 2), (float)Game1.random.Next(this.centerY)), false, flipped) - { - scale = (float)Game1.pixelZoom, - motion = new Vector2(!flipped ? 8f : -8f, 8f), - local = true - }); - } - else if (Game1.random.NextDouble() < 0.0002) - { - position = new Vector2((float)Game1.viewport.Width, (float)Game1.random.Next(4, Game1.tileSize * 4)); - this.animations.Add(new TemporaryAnimatedSprite(Game1.staminaRect, new Rectangle(0, 0, 1, 1), 9999f, 1, 10000, position, false, false, 0.01f, 0.0f, Color.White * (0.25f + (float)Game1.random.NextDouble()), 4f, 0.0f, 0.0f, 0.0f, true) - { - motion = new Vector2(-0.25f, 0.0f) - }); - } - else if (Game1.random.NextDouble() < 5E-05) - { - position = new Vector2((float)Game1.viewport.Width, (float)(Game1.viewport.Height - Game1.tileSize * 3)); - for (int index = 0; index < num; ++index) - { - this.animations.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, sourceRect, (float)Game1.random.Next(60, 101), 4, 100, position + new Vector2((float)((index + 1) * Game1.random.Next(15, 18)), (float)((index + 1) * -20)), false, false, 0.01f, 0.0f, Color.Black, 4f, 0.0f, 0.0f, 0.0f, true) - { - motion = new Vector2(-1f, 0.0f) - }); - this.animations.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, sourceRect, (float)Game1.random.Next(60, 101), 4, 100, position + new Vector2((float)((index + 1) * Game1.random.Next(15, 18)), (float)((index + 1) * 20)), false, false, 0.01f, 0.0f, Color.Black, 4f, 0.0f, 0.0f, 0.0f, true) - { - motion = new Vector2(-1f, 0.0f) - }); - } - } - else if (Game1.random.NextDouble() < 1E-05) - { - sourceRect = new Rectangle(640, 784, 16, 16); - this.animations.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, sourceRect, 75f, 4, 1000, position, false, false, 0.01f, 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, true) - { - motion = new Vector2(-3f, 0.0f), - yPeriodic = true, - yPeriodicLoopTime = 1000f, - yPeriodicRange = (float)(Game1.tileSize / 8), - shakeIntensity = 0.5f - }); - } - } - this.smokeTimer -= time.ElapsedGameTime.Milliseconds; - if (this.smokeTimer <= 0) - { - this.smokeTimer = 50; - this.animations.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Rectangle(684, 1075, 1, 1), 1000f, 1, 1000, new Vector2((float)(Game1.tileSize * 2 + Game1.tileSize * 3 / 4 + Game1.pixelZoom * 3), (float)(Game1.viewport.Height - Game1.tileSize * 2 + Game1.pixelZoom * 5)), false, false) - { - color = !Game1.wasRainingYesterday ? Color.White : Color.SlateGray, - scale = (float)Game1.pixelZoom, - scaleChange = 0.0f, - alphaFade = (float)1.0 / (float)400.0, - motion = new Vector2(0.0f, (float)((double)-Game1.random.Next(25, 75) / 100.0 / 4.0)), - acceleration = new Vector2((float)-1.0 / (float)1000.0, 0.0f) - }); - } - } - } - - public string getCategorySound(int which) - { - switch (which) - { - case 0: - return !(this.categoryItems[0][0] as StardewValley.Object).isAnimalProduct() ? "harvest" : "cluck"; - case 1: - return "leafrustle"; - case 2: - return "button1"; - case 3: - return "hammer"; - case 4: - return "coin"; - case 5: - return "money"; - default: - return "stoneStep"; - } - } - - public override void performHoverAction(int x, int y) - { - base.performHoverAction(x, y); - if (this.currentPage == -1) - { - this.okButton.tryHover(x, y, 0.1f); - foreach (ClickableTextureComponent textureComponent in this.categories) - textureComponent.sourceRect.X = !textureComponent.containsPoint(x, y) ? 392 : 402; - } - else - { - this.backButton.tryHover(x, y, 0.5f); - this.forwardButton.tryHover(x, y, 0.5f); - } - } - - public override void receiveKeyPress(Keys key) - { - if (this.introTimer > 0 || !key.Equals((object)Keys.Escape)) - return; - this.receiveLeftClick(this.okButton.bounds.Center.X, this.okButton.bounds.Center.Y, true); - } - - public override void receiveGamePadButton(Buttons b) - { - base.receiveGamePadButton(b); - if (b != Buttons.B || this.currentPage == -1) - return; - if (this.currentTab == 0) - this.currentPage = -1; - else - --this.currentTab; - Game1.playSound("shwip"); - } - - public override void receiveLeftClick(int x, int y, bool playSound = true) - { - if (this.outro && !this.savedYet) - { - if (this.saveGameMenu != null) - { - - } - - } - else - { - if (this.savedYet) - return; - base.receiveLeftClick(x, y, playSound); - if (this.currentPage == -1 && this.okButton.containsPoint(x, y)) - { - // this.outro = true; - // this.outroFadeTimer = 800; - Game1.playSound("bigDeSelect"); - // Game1.changeMusicTrack("none"); - Game1.exitActiveMenu(); - } - if (this.currentPage == -1) - { - for (int index = 0; index < Enumerable.Count((IEnumerable)this.categories); ++index) - { - if (this.categories[index].visible && this.categories[index].containsPoint(x, y)) - { - this.currentPage = index; - Game1.playSound("shwip"); - break; - } - } - } - else if (this.backButton.containsPoint(x, y)) - { - if (this.currentTab == 0) - this.currentPage = -1; - else - --this.currentTab; - Game1.playSound("shwip"); - } - else if (this.showForwardButton() && this.forwardButton.containsPoint(x, y)) - { - ++this.currentTab; - Game1.playSound("shwip"); - } - } - } - - public override void receiveRightClick(int x, int y, bool playSound = true) - { - } - - public bool showForwardButton() - { - return Enumerable.Count((IEnumerable)this.categoryItems[this.currentPage]) > 9 * (this.currentTab + 1); - } - - public override void draw(SpriteBatch b) - { - if (Game1.wasRainingYesterday) - { - b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), !Game1.currentSeason.Equals("winter") ? Color.SlateGray * (float)(1.0 - (double)this.introTimer / 3500.0) : Color.LightSlateGray); - b.Draw(Game1.mouseCursors, new Rectangle(639 * Game1.pixelZoom, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), !Game1.currentSeason.Equals("winter") ? Color.SlateGray * (float)(1.0 - (double)this.introTimer / 3500.0) : Color.LightSlateGray); - int num1 = -61 * Game1.pixelZoom; - while (num1 < Game1.viewport.Width + 61 * Game1.pixelZoom) - { - b.Draw(Game1.mouseCursors, new Vector2((float)num1 + this.weatherX / 2f % (float)(61 * Game1.pixelZoom), (float)(Game1.tileSize / 2)), new Rectangle?(new Rectangle(643, 1142, 61, 53)), Color.DarkSlateGray * 1f * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - num1 += 61 * Game1.pixelZoom; - } - b.Draw(Game1.mouseCursors, new Vector2(0.0f, (float)(Game1.viewport.Height - Game1.tileSize * 3)), new Rectangle?(new Rectangle(0, !Game1.currentSeason.Equals("winter") ? 737 : 1034, 639, 48)), (!Game1.currentSeason.Equals("winter") ? new Color(30, 62, 50) : Color.White * 0.25f) * (float)(0.5 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.FlipHorizontally, 1f); - b.Draw(Game1.mouseCursors, new Vector2((float)(639 * Game1.pixelZoom), (float)(Game1.viewport.Height - Game1.tileSize * 3)), new Rectangle?(new Rectangle(0, !Game1.currentSeason.Equals("winter") ? 737 : 1034, 639, 48)), (!Game1.currentSeason.Equals("winter") ? new Color(30, 62, 50) : Color.White * 0.25f) * (float)(0.5 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.FlipHorizontally, 1f); - b.Draw(Game1.mouseCursors, new Vector2(0.0f, (float)(Game1.viewport.Height - Game1.tileSize * 2)), new Rectangle?(new Rectangle(0, !Game1.currentSeason.Equals("winter") ? 737 : 1034, 639, 32)), (!Game1.currentSeason.Equals("winter") ? new Color(30, 62, 50) : Color.White * 0.5f) * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - b.Draw(Game1.mouseCursors, new Vector2((float)(639 * Game1.pixelZoom), (float)(Game1.viewport.Height - Game1.tileSize * 2)), new Rectangle?(new Rectangle(0, !Game1.currentSeason.Equals("winter") ? 737 : 1034, 639, 32)), (!Game1.currentSeason.Equals("winter") ? new Color(30, 62, 50) : Color.White * 0.5f) * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - b.Draw(Game1.mouseCursors, new Vector2((float)(Game1.tileSize * 2 + Game1.tileSize / 2), (float)(Game1.viewport.Height - Game1.tileSize * 2 + Game1.tileSize / 4 + Game1.pixelZoom * 2)), new Rectangle?(new Rectangle(653, 880, 10, 10)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - int num2 = -61 * Game1.pixelZoom; - while (num2 < Game1.viewport.Width + 61 * Game1.pixelZoom) - { - b.Draw(Game1.mouseCursors, new Vector2((float)num2 + this.weatherX % (float)(61 * Game1.pixelZoom), (float)(-Game1.tileSize / 2)), new Rectangle?(new Rectangle(643, 1142, 61, 53)), Color.SlateGray * 0.85f * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 0.9f); - num2 += 61 * Game1.pixelZoom; - } - foreach (TemporaryAnimatedSprite temporaryAnimatedSprite in this.animations) - temporaryAnimatedSprite.draw(b, true, 0, 0); - int num3 = -61 * Game1.pixelZoom; - while (num3 < Game1.viewport.Width + 61 * Game1.pixelZoom) - { - b.Draw(Game1.mouseCursors, new Vector2((float)num3 + this.weatherX * 1.5f % (float)(61 * Game1.pixelZoom), (float)(-Game1.tileSize * 2)), new Rectangle?(new Rectangle(643, 1142, 61, 53)), Color.LightSlateGray * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 0.9f); - num3 += 61 * Game1.pixelZoom; - } - } - else - { - b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0)); - b.Draw(Game1.mouseCursors, new Rectangle(639 * Game1.pixelZoom, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0)); - b.Draw(Game1.mouseCursors, new Vector2(0.0f, 0.0f), new Rectangle?(new Rectangle(0, 1453, 639, 195)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - b.Draw(Game1.mouseCursors, new Vector2((float)(639 * Game1.pixelZoom), 0.0f), new Rectangle?(new Rectangle(0, 1453, 639, 195)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - if (Game1.dayOfMonth == 28) - b.Draw(Game1.mouseCursors, new Vector2((float)(Game1.viewport.Width - 44 * Game1.pixelZoom), (float)Game1.pixelZoom), new Rectangle?(new Rectangle(642, 835, 43, 43)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - b.Draw(Game1.mouseCursors, new Vector2(0.0f, (float)(Game1.viewport.Height - Game1.tileSize * 3)), new Rectangle?(new Rectangle(0, !Game1.currentSeason.Equals("winter") ? 737 : 1034, 639, 48)), (!Game1.currentSeason.Equals("winter") ? new Color(0, 20, 40) : Color.White * 0.25f) * (float)(0.649999976158142 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.FlipHorizontally, 1f); - b.Draw(Game1.mouseCursors, new Vector2((float)(639 * Game1.pixelZoom), (float)(Game1.viewport.Height - Game1.tileSize * 3)), new Rectangle?(new Rectangle(0, !Game1.currentSeason.Equals("winter") ? 737 : 1034, 639, 48)), (!Game1.currentSeason.Equals("winter") ? new Color(0, 20, 40) : Color.White * 0.25f) * (float)(0.649999976158142 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.FlipHorizontally, 1f); - b.Draw(Game1.mouseCursors, new Vector2(0.0f, (float)(Game1.viewport.Height - Game1.tileSize * 2)), new Rectangle?(new Rectangle(0, !Game1.currentSeason.Equals("winter") ? 737 : 1034, 639, 32)), (!Game1.currentSeason.Equals("winter") ? new Color(0, 32, 20) : Color.White * 0.5f) * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - b.Draw(Game1.mouseCursors, new Vector2((float)(639 * Game1.pixelZoom), (float)(Game1.viewport.Height - Game1.tileSize * 2)), new Rectangle?(new Rectangle(0, !Game1.currentSeason.Equals("winter") ? 737 : 1034, 639, 32)), (!Game1.currentSeason.Equals("winter") ? new Color(0, 32, 20) : Color.White * 0.5f) * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - b.Draw(Game1.mouseCursors, new Vector2((float)(Game1.tileSize * 2 + Game1.tileSize / 2), (float)(Game1.viewport.Height - Game1.tileSize * 2 + Game1.tileSize / 4 + Game1.pixelZoom * 2)), new Rectangle?(new Rectangle(653, 880, 10, 10)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); - } - if (!this.outro && !Game1.wasRainingYesterday) - { - foreach (TemporaryAnimatedSprite temporaryAnimatedSprite in this.animations) - temporaryAnimatedSprite.draw(b, true, 0, 0); - } - if (this.currentPage == -1) - { - SpriteText.drawStringWithScrollCenteredAt(b, Utility.getYesterdaysDate(), Game1.viewport.Width / 2, this.categories[0].bounds.Y - Game1.tileSize * 2, "", 1f, -1, 0, 0.88f, false); - int num = -5 * Game1.pixelZoom; - int index1 = 0; - foreach (ClickableTextureComponent textureComponent in this.categories) - { - if (this.introTimer < 2500 - index1 * 500) - { - Vector2 vector2 = textureComponent.getVector2() + new Vector2((float)(Game1.pixelZoom * 3), (float)(-Game1.pixelZoom * 2)); - if (textureComponent.visible) - { - textureComponent.draw(b); - b.Draw(Game1.mouseCursors, vector2 + new Vector2((float)(-26 * Game1.pixelZoom), (float)(num + Game1.pixelZoom)), new Rectangle?(new Rectangle(293, 360, 24, 24)), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 0.88f); - this.categoryItems[index1][0].drawInMenu(b, vector2 + new Vector2((float)(-22 * Game1.pixelZoom), (float)(num + Game1.pixelZoom * 4)), 1f, 1f, 0.9f, false); - } - IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(384, 373, 18, 18), (int)((double)vector2.X + (double)-this.itemSlotWidth - (double)this.categoryLabelsWidth - (double)(Game1.pixelZoom * 3)), (int)((double)vector2.Y + (double)num), this.categoryLabelsWidth, 26 * Game1.pixelZoom, Color.White, (float)Game1.pixelZoom, false); - SpriteText.drawString(b, textureComponent.hoverText, (int)vector2.X - this.itemSlotWidth - this.categoryLabelsWidth + Game1.pixelZoom * 2, (int)vector2.Y + Game1.pixelZoom, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1); - for (int index2 = 0; index2 < 6; ++index2) - b.Draw(Game1.mouseCursors, vector2 + new Vector2((float)(-this.itemSlotWidth - Game1.tileSize * 3 - Game1.pixelZoom * 6 + index2 * 6 * Game1.pixelZoom), (float)(3 * Game1.pixelZoom)), new Rectangle?(new Rectangle(355, 476, 7, 11)), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 0.88f); - this.categoryDials[index1].draw(b, vector2 + new Vector2((float)(-this.itemSlotWidth - Game1.tileSize * 3 - Game1.pixelZoom * 12 + Game1.pixelZoom), (float)(5 * Game1.pixelZoom)), this.categoryTotals[index1]); - b.Draw(Game1.mouseCursors, vector2 + new Vector2((float)(-this.itemSlotWidth - Game1.tileSize - Game1.pixelZoom), (float)(3 * Game1.pixelZoom)), new Rectangle?(new Rectangle(408, 476, 9, 11)), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 0.88f); - } - ++index1; - } - if (this.introTimer <= 0) - this.okButton.draw(b); - } - else - { - IClickableMenu.drawTextureBox(b, Game1.viewport.Width / 2 - 640, Game1.viewport.Height / 2 - 360, 1280, 720, Color.White); - Vector2 location = new Vector2((float)(this.xPositionOnScreen + Game1.tileSize / 2), (float)(this.yPositionOnScreen + Game1.tileSize / 2)); - for (int index = this.currentTab * 9; index < this.currentTab * 9 + 9; ++index) - { - if (Enumerable.Count((IEnumerable)this.categoryItems[this.currentPage]) > index) - { - this.categoryItems[this.currentPage][index].drawInMenu(b, location, 1f, 1f, 1f, true); - SpriteText.drawString(b, this.categoryItems[this.currentPage][index].Name + (this.categoryItems[this.currentPage][index].Stack <= 1 ? "" : " x" + (object)this.categoryItems[this.currentPage][index].Stack), (int)location.X + Game1.tileSize + Game1.pixelZoom * 3, (int)location.Y + Game1.pixelZoom * 3, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1); - string s = "."; - int num = 0; - while (true) - { - if (num < this.width - Game1.tileSize * 3 / 2 - SpriteText.getWidthOfString(string.Concat(new object[4] - { - (object) this.categoryItems[this.currentPage][index].Name, - (object) (this.categoryItems[this.currentPage][index].Stack <= 1 ? "" : " x" + (object) this.categoryItems[this.currentPage][index].Stack), - (object) ((this.categoryItems[this.currentPage][index] as StardewValley.Object).sellToStorePrice() * (this.categoryItems[this.currentPage][index] as StardewValley.Object).Stack), - (object) "g" - }))) - { - s += " ."; - num += SpriteText.getWidthOfString(" ."); - } - else - break; - } - SpriteText.drawString(b, s, (int)location.X + Game1.tileSize * 5 / 4 + SpriteText.getWidthOfString(this.categoryItems[this.currentPage][index].Name + (this.categoryItems[this.currentPage][index].Stack <= 1 ? "" : " x" + (object)this.categoryItems[this.currentPage][index].Stack)), (int)location.Y + Game1.tileSize / 8, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1); - SpriteText.drawString(b, Convert.ToString(((this.categoryItems[this.currentPage][index] as StardewValley.Object).sellToStorePrice() * (this.categoryItems[this.currentPage][index] as StardewValley.Object).Stack)) +"g", (int)location.X + this.width - Game1.tileSize - SpriteText.getWidthOfString(Convert.ToString(((this.categoryItems[this.currentPage][index] as StardewValley.Object).sellToStorePrice() * (this.categoryItems[this.currentPage][index] as StardewValley.Object).Stack)) + "g"), (int)location.Y + Game1.pixelZoom * 3, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1); - location.Y += (float)(Game1.tileSize + Game1.pixelZoom); - } - } - this.backButton.draw(b); - if (this.showForwardButton()) - this.forwardButton.draw(b); - } - if (this.outro) - { - b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), Color.Black * (float)(1.0 - (double)this.outroFadeTimer / 800.0)); - SpriteBatch b1 = b; - string s; - if (this.newDayPlaque) - s = (string)(object)Game1.dayOfMonth + (object)Utility.getNumberEnding(Game1.dayOfMonth) + " of " + Utility.getSeasonNameFromNumber(Utility.getSeasonNumber(Game1.currentSeason)) + ", Year " + (string)(object)Game1.year; - else - s = Utility.getYesterdaysDate(); - int x = Game1.viewport.Width / 2; - int y = this.dayPlaqueY; - string placeHolderWidthText = ""; - double num1 = 1.0; - int color = -1; - int scrollType = 0; - double num2 = 0.879999995231628; - int num3 = 0; - SpriteText.drawStringWithScrollCenteredAt(b1, s, x, y, placeHolderWidthText, (float)num1, color, scrollType, (float)num2, num3 != 0); - foreach (TemporaryAnimatedSprite temporaryAnimatedSprite in this.animations) - temporaryAnimatedSprite.draw(b, true, 0, 0); - if (this.finalOutroTimer > 0) - b.Draw(Game1.staminaRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black * (float)(1.0 - (double)this.finalOutroTimer / 2000.0)); - } - if (this.saveGameMenu != null) - this.saveGameMenu.draw(b); - this.drawMouse(b); - } - } -} diff --git a/GeneralMods/SaveAnywhere/Pet_Utilities.cs b/GeneralMods/SaveAnywhere/Pet_Utilities.cs deleted file mode 100644 index 5cfd7d3e..00000000 --- a/GeneralMods/SaveAnywhere/Pet_Utilities.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.IO; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.SaveAnywhere -{ - class Pet_Utilities - { - public static string pet_name; - public static StardewValley.Character my_pet; - public static string pet_map_name; - public static int pet_tile_x; - public static int pet_tile_y; - public static bool is_pet_outside; - public static Microsoft.Xna.Framework.Point pet_point; - - public static void save_pet_info() - { - if (Game1.player.hasPet() == false) return; - pet_name = Game1.player.getPetName(); - foreach (var location in Game1.locations) - { - foreach (var npc in location.characters) - { - if (npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Cat) - { - pet_map_name = location.name; - pet_tile_x = npc.getTileX(); - pet_tile_y = npc.getTileY(); - is_pet_outside = location.isOutdoors; - - } - - } - - } - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Mod_Core.animal_path, "Pet_Save_Info_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - - Mod_Core.thisMonitor.Log("Save Anywhere: The pet save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Debug); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Pet: Save_Anywhere Info. Editing this might break some things."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Pet Current Map Name"; - mystring3[3] = pet_map_name.ToString(); - - mystring3[4] = "Pet X Position"; - mystring3[5] = pet_tile_x.ToString(); - - mystring3[6] = "Pet Y Position"; - mystring3[7] = pet_tile_y.ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - // Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now."); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - mystring3[0] = "Pet: Save_Anywhere Info. Editing this might break some things."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Pet Current Map Name"; - mystring3[3] = pet_map_name.ToString(); - - mystring3[4] = "Pet X Position"; - mystring3[5] = pet_tile_x.ToString(); - - mystring3[6] = "Pet Y Position"; - mystring3[7] = pet_tile_y.ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - } - - } - - public static void Load_pet_Info() - { - if (Game1.player.hasPet() == false) return; - // DataLoader_Settings(); - //loads the data to the variables upon loading the game. - string myname = StardewValley.Game1.player.name; - string mylocation = Path.Combine(Mod_Core.animal_path, "Pet_Save_Info_"); - string mylocation2 = mylocation + myname; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - } - - else - { - string[] readtext = File.ReadAllLines(mylocation3); - pet_map_name = Convert.ToString(readtext[3]); - pet_tile_x = Convert.ToInt32(readtext[5]); - pet_tile_y = Convert.ToInt32(readtext[7]); - get_pet(); - pet_point = new Microsoft.Xna.Framework.Point(); - pet_point.X = pet_tile_x; - pet_point.Y = pet_tile_y; - Game1.warpCharacter((StardewValley.NPC)my_pet, pet_map_name, pet_point, false, true); - } - } - - public static void get_pet() - { - if (Game1.player.hasPet() == false) return; - foreach (var location in Game1.locations) - { - foreach (var npc in location.characters) - { - if (npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Cat) - { - pet_map_name = location.name; - pet_tile_x = npc.getTileX(); - pet_tile_y = npc.getTileY(); - is_pet_outside = location.isOutdoors; - my_pet = npc; - } - - } - - } - - } - } -} diff --git a/GeneralMods/SaveAnywhere/Player_Utilities.cs b/GeneralMods/SaveAnywhere/Player_Utilities.cs deleted file mode 100644 index 9097f302..00000000 --- a/GeneralMods/SaveAnywhere/Player_Utilities.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.IO; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.SaveAnywhere -{ - class Player_Utilities - { - public static int player_x_tile; - public static int player_y_tile; - public static string players_current_map_name; - public static int player_game_time; - public static int player_facing_direction; - public static bool has_player_warped_yet; - public static void get_player_info() - { - get_x(); - get_y(); - get_current_map_name(); - get_facing_direction(); - } - - public static void get_x() - { - player_x_tile=Game1.player.getTileX(); - } - public static void get_y() - { - player_y_tile = Game1.player.getTileY(); - } - public static void get_current_map_name() - { - players_current_map_name = Game1.player.currentLocation.name; - } - public static void get_facing_direction() - { - player_facing_direction = Game1.player.facingDirection; - } - - public static void save_player_info() - { - get_player_info(); - string name = StardewValley.Game1.player.name; - Mod_Core.player_path= Path.Combine(Mod_Core.mod_path, "Save_Data", name); - if (!Directory.Exists(Mod_Core.player_path)){ - Directory.CreateDirectory(Mod_Core.player_path); - } - - - - string mylocation = Path.Combine(Mod_Core.player_path, "Player_Save_Info_"); - string mylocation2 = mylocation + name; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Mod_Core.thisMonitor.Log("Save Anywhere: The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Info); - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player: Save_Anywhere Info. Editing this might break some things."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player Current Game Time"; - mystring3[3] = Game1.timeOfDay.ToString(); - - mystring3[4] = "Player Current Map Name"; - mystring3[5] = players_current_map_name.ToString(); - - mystring3[6] = "Player X Position"; - mystring3[7] = player_x_tile.ToString(); - - mystring3[8] = "Player Y Position"; - mystring3[9] = player_y_tile.ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player: Save_Anywhere Info. Editing this might break some things."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Player Current Game Time"; - mystring3[3] = Game1.timeOfDay.ToString(); - - mystring3[4] = "Player Current Map Name"; - mystring3[5] = players_current_map_name.ToString(); - - mystring3[6] = "Player X Position"; - mystring3[7] = player_x_tile.ToString(); - - mystring3[8] = "Player Y Position"; - mystring3[9] = player_y_tile.ToString(); - - - - File.WriteAllLines(mylocation3, mystring3); - } - - } - - public static void load_player_info() - { - string name = StardewValley.Game1.player.name; - Mod_Core.player_path = Path.Combine(Mod_Core.mod_path, "Save_Data", name); - if (!Directory.Exists(Mod_Core.player_path)) - { - Directory.CreateDirectory(Mod_Core.player_path); - } - - - - string mylocation = Path.Combine(Mod_Core.player_path, "Player_Save_Info_"); - string mylocation2 = mylocation + name; - string mylocation3 = mylocation2 + ".txt"; - string[] mystring3 = new string[20]; - - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - // Console.WriteLine("Can't load custom save info since the file doesn't exist."); - Player_Utilities.has_player_warped_yet = true; - } - - else - { - // Console.WriteLine("HEY THERE IM LOADING DATA"); - - string[] readtext = File.ReadAllLines(mylocation3); - player_game_time = Convert.ToInt32(readtext[3]); - players_current_map_name = Convert.ToString(readtext[5]); - player_x_tile = Convert.ToInt32(readtext[7]); - player_y_tile = Convert.ToInt32(readtext[9]); - Game1.timeOfDay = player_game_time; - - } - } - - public static void warp_player() - { - GameLocation new_location = Game1.getLocationFromName(players_current_map_name); - Game1.player.previousLocationName = Game1.player.currentLocation.name; - Game1.locationAfterWarp = new_location; - Game1.xLocationAfterWarp = player_x_tile; - Game1.yLocationAfterWarp = player_y_tile; - Game1.facingDirectionAfterWarp = player_facing_direction; - Game1.fadeScreenToBlack(); - - Game1.warpFarmer(players_current_map_name, player_x_tile, player_y_tile, false); - Mod_Core.thisMonitor.Log("WARP THE PLAYER"); - Game1.player.faceDirection(player_facing_direction); - - if (Directory.Exists(Mod_Core.player_path)) - { - // Directory.Delete(player_path, true); - } - } - - } -} diff --git a/GeneralMods/SaveAnywhere/Properties/AssemblyInfo.cs b/GeneralMods/SaveAnywhere/Properties/AssemblyInfo.cs index 1994d0a3..608e9373 100644 --- a/GeneralMods/SaveAnywhere/Properties/AssemblyInfo.cs +++ b/GeneralMods/SaveAnywhere/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Save_Anywhere_V2")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Save_Anywhere_V2")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: AssemblyTitle("SaveAnywhere")] [assembly: Guid("e17855ad-dbaf-49bd-b3e2-9899403252f6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/SaveAnywhere/README.md b/GeneralMods/SaveAnywhere/README.md new file mode 100644 index 00000000..d3c27104 --- /dev/null +++ b/GeneralMods/SaveAnywhere/README.md @@ -0,0 +1,33 @@ +**Save Anywhere** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you save your +game anywhere by pressing a key. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/444). +3. Run the game using SMAPI. + +## Usage +Press `K` to save anywhere. Edit `Save_Anywhere_Config.txt` to configure the key. + +## Versions +1.0: +* Initial release. + +2.0: +* Major rewrite. +* Time is no longer simulated at high-speed to reset to the same time. This caused too many NPC pathfinding issues and players felt it was a bit of an exploit. +* NPCs should now properly pathfind themselves when loading after saving anywhere. Thanks to @Entoarox for the help! +* Save data is now better organised. +* Fixed various load crashes. +* Fixed the game transitioning to the next day when you save after putting items in your shipping bin. + +2.0.1: +* Fixed crash if you don't have a horse. + +2.0.2: +* Fixed config file. + +2.1: +* Fixed mod crashing in some cases. diff --git a/GeneralMods/SaveAnywhere/ReadMe.txt b/GeneralMods/SaveAnywhere/ReadMe.txt deleted file mode 100644 index efd7a8b4..00000000 --- a/GeneralMods/SaveAnywhere/ReadMe.txt +++ /dev/null @@ -1,70 +0,0 @@ -Save Anywhere V2 - -Version:2.1.0 - -Published: 8/26/16 8:46 AM - -Updated: 9/5/16 1:16 PM - -Compatability: - -Stardew Valley 1.0.7 Windows - -SMAPI 0.40.0 - -Description: - -UPDATE 2.0.0!!!! - -Hey everyone, it's been a super long time since this mod got an update, but here it is, Save Anywhere V2! - -The number one reason this mod took so long to re-release is the fact that the old code was garbage and full of bugs that I couldn't test because I didn't have access to a save file that was very far along. That all changes now. - -The re-written version has some fundamental changes. I'll post everything down below. - -1.Old versions of the Save Anywhere mod are no longer supported. Update to this new, much better version. That said old save_anywhere data files don't work when you update to this version of the mod. - -2.Time is no longer simulate at a higher speed. This caused too many issues for pathfinding for NPCs and many players complained about it being a bit of an exploit. - -3.NPCs should now properly pathfind themselves when loading after saving anywhere. Thanks to @Entoarox for the help! - -4.Folder organization: Tons of organization regarding the data files used to Save/Load with this mod. It's way nicer and simpler for me to manage now. - -5.You can now save in the community center! No more of this awful glitch. Just make sure you download this mod HERE so that this works. Otherwise this bug will still exist due to the game's serializer not understanding what the heck a Junimo is. - -6.Hopefully no more Load crashes. I tested this out on a 2nd year character with farm animals, horse, cat, a wife, etc. Also better folder organization and better techniques should help prevent this mod from exploding. - -7.The game no longer transitions to the next day when you save and items are shipped. Didn't realize this was a thing until someone pointed it out. - -Now for the good part: - -Installation: - -1.Download and install SMAPI. The link for that is HERE. - -2.Install the Serializer Utility by Advize which is HERE. - -3.Download Save Anywhere V2. (Not the old mod version). - -4.Place BOTH mods at Stardew Valley/Mods - -5.Run the game! - -Usage: -1.To save anywhere simply press the K key. This is configuragble in the config file in the mod directory. - -If you have any bugs/comments/etc please post them in the new discussion form tab for Save Anywhere V2. - -Thanks and have fun! - -Update Info: -2.1.0 --Added in some bug handling that should prevent the mod from outright crashing. Also it dumps error logs to (thisModDirectory)/Error_Logs - -2.0.2 --Forgot to change the config back to the original state -2.0.1 --Fixed a glitch that would cause the game to crash if you don't have a horse. - -2.0.0 --Initial rewritten release. diff --git a/GeneralMods/SaveAnywhere/SaveAnywhere.cs b/GeneralMods/SaveAnywhere/SaveAnywhere.cs new file mode 100644 index 00000000..4231f953 --- /dev/null +++ b/GeneralMods/SaveAnywhere/SaveAnywhere.cs @@ -0,0 +1,310 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Omegasis.SaveAnywhere.Framework; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; +using StardewValley.Characters; + +namespace Omegasis.SaveAnywhere +{ + /// The mod entry point. + public class SaveAnywhere : Mod + { + /********* + ** Properties + *********/ + /// Provides methods for saving and loading game data. + private SaveManager SaveManager; + + /// Provides methods for reading and writing the config file. + private ConfigUtilities ConfigUtilities; + + /// Whether villager schedules should be reset now. + private bool ShouldResetSchedules; + + /// The parsed schedules by NPC name. + private readonly IDictionary NpcSchedules = new Dictionary(); + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + this.ConfigUtilities = new ConfigUtilities(this.Helper.DirectoryPath); + + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + } + + + /********* + ** Private methods + *********/ + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + // load config + this.ConfigUtilities.LoadConfig(); + this.ConfigUtilities.WriteConfig(); + + // load positions + this.SaveManager = new SaveManager(Game1.player, this.Helper.DirectoryPath, this.Monitor, this.Helper.Reflection, onVillagersReset: () => this.ShouldResetSchedules = true); + this.SaveManager.LoadPositions(); + } + + /// 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) + { + // let save manager run background logic + if (Context.IsWorldReady) + this.SaveManager.Update(); + + // reset NPC schedules + if (Context.IsWorldReady && this.ShouldResetSchedules) + { + this.ShouldResetSchedules = false; + this.ApplySchedules(); + } + } + + /// The method invoked when changes. + /// The event sender. + /// The event data. + private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e) + { + // reload NPC schedules + this.ShouldResetSchedules = true; + + // update NPC schedules + this.NpcSchedules.Clear(); + foreach (NPC npc in Utility.getAllCharacters()) + { + if (!this.NpcSchedules.ContainsKey(npc.name)) + this.NpcSchedules.Add(npc.name, this.ParseSchedule(npc)); + } + } + + /// The method invoked when the presses a keyboard button. + /// The event sender. + /// The event data. + private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) + { + if (Game1.activeClickableMenu != null) + return; + + if (e.KeyPressed.ToString() == this.ConfigUtilities.KeyBinding) + this.SaveManager.SaveGameAndPositions(); + } + + /// Apply the NPC schedules to each NPC. + private void ApplySchedules() + { + if (Game1.weatherIcon == Game1.weather_festival || Game1.isFestival() || Game1.eventUp) + return; + + MethodInfo pathfind = typeof(NPC).GetMethod("pathfindToNextScheduleLocation", BindingFlags.NonPublic | BindingFlags.Instance); + + // apply for each NPC + foreach (NPC npc in Utility.getAllCharacters()) + { + if (npc.DirectionsToNewLocation != null || npc.isMoving() || npc.Schedule == null || npc.controller != null || npc is Horse) + continue; + + // get raw schedule from XNBs + IDictionary rawSchedule = this.GetRawSchedule(npc.name); + if (rawSchedule == null) + continue; + + // get schedule data + string scheduleData; + if (!this.NpcSchedules.TryGetValue(npc.name, out scheduleData) || string.IsNullOrEmpty(scheduleData)) + { + this.Monitor.Log("THIS IS AWKWARD"); + continue; + } + + // get schedule script + string script; + if (!rawSchedule.TryGetValue(scheduleData, out script)) + continue; + + // parse entries + string[] entries = script.Split('/'); + int index = 0; + foreach (string _ in entries) + { + string[] fields = entries[index].Split(' '); + + // handle GOTO command + if (fields.Contains("GOTO")) + { + for (int i = 0; i < fields.Length; i++) + { + string s = fields[i]; + if (s == "GOTO") + { + rawSchedule.TryGetValue(fields[i + 1], out script); + string[] newEntries = script.Split('/'); + fields = newEntries[0].Split(' '); + } + } + } + + // parse schedule script + SchedulePathDescription schedulePathDescription; + try + { + if (Convert.ToInt32(fields[0]) > Game1.timeOfDay) break; + string endMap = Convert.ToString(fields[1]); + int x = Convert.ToInt32(fields[2]); + int y = Convert.ToInt32(fields[3]); + int endFacingDir = Convert.ToInt32(fields[4]); + schedulePathDescription = (SchedulePathDescription)pathfind.Invoke(npc, new object[] { npc.currentLocation.name, npc.getTileX(), npc.getTileY(), endMap, x, y, endFacingDir, null, null }); + index++; + } + catch (Exception ex) + { + //this.Monitor.Log($"Error pathfinding NPC {npc.name}: {ex}", LogLevel.Error); + continue; + } + + npc.DirectionsToNewLocation = schedulePathDescription; + npc.controller = new PathFindController(npc.DirectionsToNewLocation.route, npc, Utility.getGameLocationOfCharacter(npc)) + { + finalFacingDirection = npc.DirectionsToNewLocation.facingDirection, + endBehaviorFunction = null + }; + } + } + } + + /// Get an NPC's raw schedule data from the XNB files. + /// The NPC name whose schedules to read. + /// Returns the NPC schedule if found, else null. + private IDictionary GetRawSchedule(string npcName) + { + try + { + return Game1.content.Load>($"Characters\\schedules\\{npcName}"); + } + catch (Exception) + { + return null; + } + } + + /// Load the raw schedule data for an NPC. + /// The NPC whose schedule to read. + private string ParseSchedule(NPC npc) + { + // set flags + if (npc.name.Equals("Robin") || Game1.player.currentUpgrade != null) + npc.isInvisible = false; + if (npc.name.Equals("Willy") && Game1.stats.DaysPlayed < 2u) + npc.isInvisible = true; + else if (npc.Schedule != null) + npc.followSchedule = true; + + // read schedule data + IDictionary schedule = this.GetRawSchedule(npc.name); + if (schedule == null) + return ""; + + // do stuff + if (npc.isMarried()) + { + string dayName = Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); + if ((npc.name.Equals("Penny") && (dayName.Equals("Tue") || dayName.Equals("Wed") || dayName.Equals("Fri"))) || (npc.name.Equals("Maru") && (dayName.Equals("Tue") || dayName.Equals("Thu"))) || (npc.name.Equals("Harvey") && (dayName.Equals("Tue") || dayName.Equals("Thu")))) + { + FieldInfo field = typeof(NPC).GetField("nameofTodaysSchedule", BindingFlags.NonPublic | BindingFlags.Instance); + field.SetValue(npc, "marriageJob"); + return "marriageJob"; + } + if (!Game1.isRaining && schedule.ContainsKey("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) + { + FieldInfo field = typeof(NPC).GetField("nameofTodaysSchedule", BindingFlags.NonPublic | BindingFlags.Instance); + field.SetValue(npc, "marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)); + return "marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); + } + npc.followSchedule = false; + return null; + } + else + { + if (schedule.ContainsKey(Game1.currentSeason + "_" + Game1.dayOfMonth)) + return Game1.currentSeason + "_" + Game1.dayOfMonth; + int i; + for (i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); i > 0; i--) + { + if (schedule.ContainsKey(Game1.dayOfMonth + "_" + i)) + return Game1.dayOfMonth + "_" + i; + } + if (schedule.ContainsKey(string.Empty + Game1.dayOfMonth)) + return string.Empty + Game1.dayOfMonth; + if (npc.name.Equals("Pam") && Game1.player.mailReceived.Contains("ccVault")) + return "bus"; + if (Game1.isRaining) + { + if (Game1.random.NextDouble() < 0.5 && schedule.ContainsKey("rain2")) + return "rain2"; + if (schedule.ContainsKey("rain")) + return "rain"; + } + List list = new List { Game1.currentSeason, Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth) }; + i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); + while (i > 0) + { + list.Add(string.Empty + i); + if (schedule.ContainsKey(string.Join("_", list))) + { + return string.Join("_", list); + } + i--; + list.RemoveAt(list.Count - 1); + } + if (schedule.ContainsKey(string.Join("_", list))) + { + return string.Join("_", list); + } + if (schedule.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) + { + return Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); + } + if (schedule.ContainsKey(Game1.currentSeason)) + { + return Game1.currentSeason; + } + if (schedule.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) + { + return "spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); + } + list.RemoveAt(list.Count - 1); + list.Add("spring"); + i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); + while (i > 0) + { + list.Add(string.Empty + i); + if (schedule.ContainsKey(string.Join("_", list))) + return string.Join("_", list); + i--; + list.RemoveAt(list.Count - 1); + } + if (schedule.ContainsKey("spring")) + return "spring"; + return null; + } + } + } +} diff --git a/GeneralMods/SaveAnywhere/SaveAnywhere.csproj b/GeneralMods/SaveAnywhere/SaveAnywhere.csproj index 46ba40b8..f3c289bb 100644 --- a/GeneralMods/SaveAnywhere/SaveAnywhere.csproj +++ b/GeneralMods/SaveAnywhere/SaveAnywhere.csproj @@ -34,15 +34,13 @@ - - - - - - - - - + + Properties\GlobalAssemblyInfo.cs + + + + + @@ -50,7 +48,7 @@ - + diff --git a/GeneralMods/SaveAnywhere/manifest.json b/GeneralMods/SaveAnywhere/manifest.json index 0f2201c7..fc7fd751 100644 --- a/GeneralMods/SaveAnywhere/manifest.json +++ b/GeneralMods/SaveAnywhere/manifest.json @@ -10,4 +10,4 @@ "Description": "Allows the farmer to save almost anywhere. SMAPI 1.12. Updated 5/14/17", "UniqueID": "Save_Anywhere_V2", "EntryDll": "SaveAnywhere.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/SaveBackup/Class1.cs b/GeneralMods/SaveBackup/Class1.cs deleted file mode 100644 index 28966710..00000000 --- a/GeneralMods/SaveBackup/Class1.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System; -using System.IO; -using System.IO.Compression; -using System.Linq; -using StardewModdingAPI; - -namespace Omegasis.SaveBackup -{ - public class Class1 : Mod - { - static string app_path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - static string stardew_path = Path.Combine(app_path, "StardewValley"); - static string stardew_save_path = Path.Combine(stardew_path, "Saves"); - static string saved_backups = Path.Combine(stardew_path, "Backed_Up_Saves"); //name of exported file - static string pre_play_saves = Path.Combine(saved_backups, "Pre_Play_Saves"); - static string sleeping_saves = Path.Combine(saved_backups, "Nightly_InGame_Saves"); - static string backup_path = Path.Combine(stardew_path, "Backed_Up_Saves"); - - public static string output; - static int pre_iterator = 0; - static int sleep_iterator =0; - static string pre_iterator_string = pre_iterator.ToString(); - static string sleep_iterator_string = sleep_iterator.ToString(); - - static int save_num = 30; - - public override void Entry(IModHelper helper) - { - DataLoader(); - MyWritter(); - - Save_Backup(); //Yup I wrote it all in one function.... kinda - - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += Sleep_Save_Backup; - } - - public void Save_Backup() - { - //insert data read and data writer functions if I want better future optimization. - - string mydatastring = "Pre_Play_Backup"; - string back_up_savefile = Path.Combine(pre_play_saves, mydatastring); - back_up_savefile = Path.Combine(pre_play_saves, mydatastring); - if (!Directory.Exists(saved_backups)) - { - Directory.CreateDirectory(saved_backups); - Console.WriteLine("Making Backup Directory"); - } - - if (!Directory.Exists(pre_play_saves)) - { - Directory.CreateDirectory(pre_play_saves); - Console.WriteLine("Making Backup Directory"); - } - - if (!Directory.Exists(sleeping_saves)) - { - Directory.CreateDirectory(sleeping_saves); - Console.WriteLine("Making Backup Directory"); - } - - - while (true) - { - - pre_iterator++; //initial iterations - pre_iterator_string = pre_iterator.ToString(); //string conversion - - if (File.Exists(back_up_savefile + pre_iterator_string +".zip")) continue; //if my file exists, go back to the top! - - if (!File.Exists(back_up_savefile + pre_iterator_string + ".zip")) //if my file doesnt exist, make it! - { - pre_iterator_string = pre_iterator.ToString(); - - string newbackup = back_up_savefile + pre_iterator_string; - output = newbackup + ".zip"; - - ZipFile.CreateFromDirectory(stardew_save_path, output); - break; - - } - } - - var files = new DirectoryInfo(pre_play_saves).EnumerateFiles() - .OrderByDescending(f => f.CreationTime) - .Skip(save_num) - .ToList(); - files.ForEach(f => f.Delete()); - - } - - static void Sleep_Save_Backup(object sender, EventArgs e) - { - //insert data read and data writer functions if I want better future optimization. - string mydatastring = "Nightly_Backup"; - string back_up_savefile = Path.Combine(pre_play_saves, mydatastring); - back_up_savefile = Path.Combine(sleeping_saves, mydatastring); - - - //This shouldn't run, but just incase... - if (!Directory.Exists(saved_backups)) - { - Directory.CreateDirectory(saved_backups); - Console.WriteLine("Making Backup Directory"); - } - - if (!Directory.Exists(pre_play_saves)) - { - Directory.CreateDirectory(pre_play_saves); - Console.WriteLine("Making Backup Directory"); - } - - if (!Directory.Exists(sleeping_saves)) - { - Directory.CreateDirectory(sleeping_saves); - Console.WriteLine("Making Backup Directory"); - } - - //string backup_path = Path.Combine(stardew_path, "Backed_Up_Saves"); - - while (true) - { - - sleep_iterator++; //initial iterations - sleep_iterator_string = sleep_iterator.ToString(); //string conversion - - if (File.Exists(back_up_savefile + sleep_iterator_string + ".zip")) continue; //if my file exists, go back to the top! - - if (!File.Exists(back_up_savefile + sleep_iterator_string + ".zip")) //if my file doesnt exist, make it! - { - sleep_iterator_string = sleep_iterator.ToString(); - - string newbackup = back_up_savefile + sleep_iterator_string; - output = newbackup + ".zip"; - - ZipFile.CreateFromDirectory(stardew_save_path, output); - break; - - } - } - - var files = new DirectoryInfo(sleeping_saves).EnumerateFiles() - .OrderByDescending(f => f.CreationTime) - .Skip(save_num) - .ToList(); - files.ForEach(f => f.Delete()); - } - - - void DataLoader() - { - //loads the data to the variables upon loading the game. - var mylocation = Path.Combine(Helper.DirectoryPath, "AutoBackup_data.txt"); - if (!File.Exists(mylocation)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - Console.WriteLine("The config file for AutoSpeed was not found, guess I'll create it..."); - - } - else - { - // Console.WriteLine("HEY THERE IM LOADING DATA"); - - //loads the BuildEndurance_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation); - save_num = Convert.ToInt32(readtext[3]); - - } - } - - void MyWritter() - { - //saves the BuildEndurance_data at the end of a new day; - var mylocation = Path.Combine(Helper.DirectoryPath, "AutoBackup_data.txt"); - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation)) - { - Console.WriteLine("The data file for AutoBackup was not found, guess I'll create it when you sleep."); - - mystring3[0] = "Player: AutoBackup Config:"; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Number of Backups to Keep:"; - mystring3[3] = save_num.ToString(); - File.WriteAllLines(mylocation, mystring3); - } - else - { - // Console.WriteLine("HEY IM SAVING DATA"); - - //write out the info to a text file upon loading - mystring3[0] = "Player: AutoBackup Config:"; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Number of Backups to Keep:"; - mystring3[3] = save_num.ToString(); - - File.WriteAllLines(mylocation, mystring3); - } - } - - - } - - - -} diff --git a/GeneralMods/SaveBackup/Properties/AssemblyInfo.cs b/GeneralMods/SaveBackup/Properties/AssemblyInfo.cs index 93a171f9..e1b3fb64 100644 --- a/GeneralMods/SaveBackup/Properties/AssemblyInfo.cs +++ b/GeneralMods/SaveBackup/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Stardew_Save_Backup")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Stardew_Save_Backup")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: AssemblyTitle("SaveBackup")] [assembly: Guid("12984468-2b79-4b3b-b045-ee917301dee0")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/SaveBackup/ReadMe.md b/GeneralMods/SaveBackup/ReadMe.md index cb01c432..38dd13b7 100644 --- a/GeneralMods/SaveBackup/ReadMe.md +++ b/GeneralMods/SaveBackup/ReadMe.md @@ -1,16 +1,20 @@ -[SMAPI]Stardew_Save_Backup +**Save Backup** is a [Stardew Valley](http://stardewvalley.net/) mod which automatically backs up +your save files before you play and every in-game night. --v1.0.2 3/31/16 12:43 AM PST +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. --Updated to back up upon launch and upon sleeping. --Now supports x# of save files (28 by default) for Nightly backups and pre-launch backups (28 for each category). This can be changed in AutoBackup_data.txt. +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/435). +3. Run the game using SMAPI. -This is the Stardew_Save_Backup mod which automatically takes your save folder and zips it into %appdata%/StardewValley/Backed_Up_Saves for later retrieval upon launching SMAPI! This is especially usefulif you are modding/using mods and don't want your characters to be messed up, or if your game happens to crash form some odd reason, or you lose your save file! +## Usage +Your saves will be backed up automatically before you play and each in-game night. You can find the +files in `%appdata%/StardewValley/Backed_Up_Saves`. -The back-up happens every time you load up SMAPI so your files are zipped up nice and safe before anything can touch them. Also works when you go to bed at night. +This keeps the last 30 backups of each type by default, but you can edit `AutoBackup_data.txt` to +configure that. -You can also keep as many back-ups as you desire, and are only limited by the hard drive space on your computer! (Editable by AutoBackup_data.txt) - -If you ever want to get back to your old save files, simply open up the desired .zip folder with any archival tool such as windows file manager or .7zip and you can now access your old save files! - -I'm open to improvements for this mod as of writing this. If so desired I will research adding functionality for when your character goes to bed that it will back up your save files, or doing a backup after x amount of days that have passed in game. +## Versions +1.0: +* Initial release. diff --git a/GeneralMods/SaveBackup/SaveBackup.cs b/GeneralMods/SaveBackup/SaveBackup.cs new file mode 100644 index 00000000..2df899da --- /dev/null +++ b/GeneralMods/SaveBackup/SaveBackup.cs @@ -0,0 +1,100 @@ +using System; +using System.IO; +using System.IO.Compression; +using System.Linq; +using StardewModdingAPI; +using StardewModdingAPI.Events; + +namespace Omegasis.SaveBackup +{ + /// The mod entry point. + public class SaveBackup : Mod + { + /********* + ** Properties + *********/ + /// The folder path containing the game's app data. + private static readonly string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley"); + + /// The folder path containing the game's saves. + private static readonly string SavesPath = Path.Combine(SaveBackup.AppDataPath, "Saves"); + + /// The folder path containing backups of the save before the player starts playing. + private static readonly string PrePlayBackupsPath = Path.Combine(SaveBackup.AppDataPath, "Backed_Up_Saves", "Pre_Play_Saves"); + + /// The folder path containing nightly backups of the save. + private static readonly string NightlyBackupsPath = Path.Combine(SaveBackup.AppDataPath, "Backed_Up_Saves", "Nightly_InGame_Saves"); + + /// The number of save backups to keep for each type. + private int SaveCount = 30; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + this.LoadConfig(); + this.WriteConfig(); + + this.BackupSaves(SaveBackup.PrePlayBackupsPath); + + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + } + + + /********* + ** Private methods + *********/ + /// The method invoked when changes. + /// The event sender. + /// The event data. + private void TimeEvents_DayOfMonthChanged(object sender, EventArgs e) + { + this.BackupSaves(SaveBackup.NightlyBackupsPath); + } + + /// Back up saves to the specified folder. + /// The folder path in which to generate saves. + private void BackupSaves(string folderPath) + { + // back up saves + Directory.CreateDirectory(folderPath); + ZipFile.CreateFromDirectory(SaveBackup.SavesPath, Path.Combine(folderPath, $"backup-{DateTime.Now:yyyyMMdd'-'HHmmss}.zip")); + + // delete old backups + new DirectoryInfo(folderPath) + .EnumerateFiles() + .OrderByDescending(f => f.CreationTime) + .Skip(this.SaveCount) + .ToList() + .ForEach(file => file.Delete()); + } + + /// Load the configuration settings. + private void LoadConfig() + { + var path = Path.Combine(Helper.DirectoryPath, "AutoBackup_data.txt"); + if (File.Exists(path)) + { + string[] text = File.ReadAllLines(path); + this.SaveCount = Convert.ToInt32(text[3]); + } + } + + /// Save the configuration settings. + private void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "AutoBackup_data.txt"); + string[] text = new string[20]; + text[0] = "Player: AutoBackup Config:"; + text[1] = "===================================================================================="; + text[2] = "Number of Backups to Keep:"; + text[3] = this.SaveCount.ToString(); + + File.WriteAllLines(path, text); + } + } +} diff --git a/GeneralMods/SaveBackup/SaveBackup.csproj b/GeneralMods/SaveBackup/SaveBackup.csproj index 0225c135..c9ddd410 100644 --- a/GeneralMods/SaveBackup/SaveBackup.csproj +++ b/GeneralMods/SaveBackup/SaveBackup.csproj @@ -36,13 +36,16 @@ - + + Properties\GlobalAssemblyInfo.cs + + - + diff --git a/GeneralMods/SaveBackup/manifest.json b/GeneralMods/SaveBackup/manifest.json index d1ab9cfd..54a57e77 100644 --- a/GeneralMods/SaveBackup/manifest.json +++ b/GeneralMods/SaveBackup/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "4be88c18-b6f3-49b0-ba96-f94b1a5be890", "PerSaveConfigs": false, "EntryDll": "SaveBackup.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index 6999bd93..55911a8a 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -40,6 +40,8 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "~metadata", "~metadata", "{90EB59CA-51F6-49CF-8DCE-A8BB62C58E17}" ProjectSection(SolutionItems) = preProject deploy.targets = deploy.targets + GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs + ..\README.md = ..\README.md EndProjectSection EndProject Global diff --git a/GeneralMods/StardewSymphony/Class1.cs b/GeneralMods/StardewSymphony/Class1.cs deleted file mode 100644 index 0775d1f5..00000000 --- a/GeneralMods/StardewSymphony/Class1.cs +++ /dev/null @@ -1,2446 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Timers; -using Microsoft.Xna.Framework.Audio; -using StardewModdingAPI; -using StardewValley; - -/* -TODO: -0. Add in event handling so that I don;t mute a heart event or wedding music. -6. add in Stardew songs again to music selection -7. add in more tracks. -11. Tutorial for adding more music into the game? -15.add in blank templates for users to make their own wave/sound banks - -*/ -namespace Omegasis.StardewSymphony -{ - - - - public class Class1 : Mod - { - public static string[] subdirectoryEntries = new string[9999999]; - public static string[] fileEntries = new string[9999999]; - - public static List master_list; //holds all of my WAVE banks and sound banks and their locations. - public static Dictionary song_wave_reference; //holds a list of all of the cue names that I ever add in. - public static List location_list; //holds all of the locations in SDV - public static List temp_cue; //temporary list of songs from music pack - - public static Dictionary music_packs; - - public static string master_path; //path to this mod - - static int delay_time; - static int delay_time_min; //min time to pass before next song - static int delay_time_max; //max time to pass before next song - static bool game_loaded; //make sure the game is loaded - bool silent_rain; //auto mix in SDV rain sound with music? - int night_time; //not really used, but keeping it for now. - public static bool seasonal_music; //will I play the seasonal music or not? - public static Random random; - - - static bool no_music; //will trigger if a music pack can't be loaded for that location. - - public static SoundBank old_sound_bank; //game's default sound bank - public static SoundBank new_sound_bank; - public static Cue cueball; //the actual song that is playing. Why do you call songs cues microsoft? Probably something I'm oblivious to. - - public static WaveBank oldwave; - public static WaveBank newwave; - - public bool once; - - public static MusicManager current_info_class; - - - public static bool farm_player; - public static bool is_farm; - - public override void Entry(IModHelper helper) - { - StardewModdingAPI.Events.SaveEvents.AfterLoad+= PlayerEvents_LoadedGame; - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged; - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; - once = true; - MusicHexProcessor.allsoundBanks = new List(); - MusicHexProcessor.allHexDumps = new List(); - MusicHexProcessor.allWaveBanks = new List(); - } - - public void GameEvents_UpdateTick(object sender, EventArgs e) - { - if (game_loaded == false) return; - if (master_list != null) - { - if (master_list.Count == 0) return; //basically if absolutly no music is loaded into the game for locations/festivals/seasons, don't override the game's default music player. - - } - if (cueball == null) - { - no_music = true; - return; //if there wasn't any music at loaded at all for the area, just play the default stardew soundtrack. - } - if (no_music == true && cueball.IsPlaying == false) - { - cueball = null; //if there was no music loaded for the area and the last song has finished playing, default to the Stardew Soundtrack. - } - if (cueball != null) - { - no_music = false; - if (cueball.IsPlaying == false) //if a song isn't playing - { - //cueball = null; - if (aTimer.Enabled == false) //if my timer isn't enabled, set it. - { - SetTimer(); - } - else - { - //do nothing - } - } - } - - if (StardewValley.Game1.isFestival() == true) - { - return; //replace with festival - } - if (StardewValley.Game1.eventUp == true) - { - return; //replace with event music - } - - if (StardewValley.Game1.isRaining == true) - { - if (silent_rain == false) return;// If silent_rain = false. AKA, play the rain ambience soundtrack. If it is true, turn off the rain ambience sound track. - } - - Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs - Game1.nextMusicTrack = ""; //same as above line - - } - public void TimeEvents_DayOfMonthChanged(object sender, StardewModdingAPI.Events.EventArgsIntChanged e) - { - if (game_loaded == false) return; - random.Next(); - stop_sound(); //if my music player is called and I forget to clean up sound before hand, kill the old sound. - DataLoader(); - MyWritter(); - - if (game_loaded == false) return; - night_time = Game1.getModeratelyDarkTime(); //not sure I even really use this... - music_selector(); - - - } - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - DataLoader(); - MyWritter(); - - music_packs = new Dictionary(); - random = new Random(); - master_list = new List(); - song_wave_reference = new Dictionary(); - location_list = new List(); - temp_cue = new List(); - no_music = true; - - master_creator(); //creates the directory and files necessary to run the mod. - Location_Grabber(); //grab all of the locations in the game and add them to a list; - ProcessDirectory(master_path); - //master_list.Add(new MusicManager("Wave Bank2", "Sound Bank2", PathOnDisk)); Old static way that only alowed one external wave bank. Good thing I found a way around that. - aTimer.Enabled = false; - night_time = Game1.getModeratelyDarkTime(); - process_music_packs(); - - - MusicHexProcessor.processHex(); - - - - Monitor.Log("READY TO GO"); - game_loaded = true; - music_selector(); - - } - public void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsCurrentLocationChanged e) - { - if (game_loaded == false) return; - // Monitor.Log("NEW LOCATION"); - if (Game1.player.currentLocation.name == "Farm") is_farm = true; - else is_farm = false; - music_selector(); - - } - - public static Timer aTimer = new Timer(); - public void SetTimer() - { - //set up a new timer - Random random2 = new Random(); - delay_time = random2.Next(delay_time_min, delay_time_max); //random number between 0 and n. 0 not included - - // Create a timer with a two second interval. - aTimer = new System.Timers.Timer(delay_time); - // Hook up the Elapsed event for the timer. - aTimer.Elapsed += OnTimedEvent; - aTimer.Enabled = true; - } - public void OnTimedEvent(System.Object source, ElapsedEventArgs e) - { - //when my timer runs out play some music - music_selector(); - aTimer.Enabled = false; - } - - - public void master_creator() - { - //loads the data to the variables upon loading the game. - var music_path = Helper.DirectoryPath; - if (!Directory.Exists(Path.Combine(music_path, "Music_Packs"))) - { - Monitor.Log("Creating Music Directory"); - Directory.CreateDirectory(Path.Combine(music_path, "Music_Packs")); //create the Music_Packs directory. Because organization is nice. - } - - /* - - Old chunk of code that was suppose to automatically populate the music packs with a blank music pack for people to use as a template. Sadly this doesn't work all the way. - - if (!Directory.Exists(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack"))) - { - Monitor.Log("Creating Music Directory"); - Directory.CreateDirectory(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack")); //create the Music_Packs directory. Because organization is nice. - Setup_Creator(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack", "Config.txt")); - Setup_Creator(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack", "master_reference_sheet.txt")); - File.Create(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack", "your_sound_bank_here.xsb")); - File.Create(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack", "your_wave_bank_here.xwb")); - } - - - if (!Directory.Exists(Path.Combine(music_path, "Music_Packs","Blank_Music_Pack","Music_Files", "Seasons"))) - { - Monitor.Log("Creating Music Directory"); - Directory.CreateDirectory(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack","Music_Files", "Seasons")); //create the Music_Packs directory. Because organization is nice. - } - if (!Directory.Exists(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack","Music_Files", "Locations"))) - { - Monitor.Log("Creating Music Directory"); - Directory.CreateDirectory(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack","Music_Files", "Locations")); //create the Music_Packs directory. Because organization is nice. - } - */ - - music_path = Path.Combine(music_path, "Music_Packs"); - master_path = music_path; - old_sound_bank = Game1.soundBank; - - oldwave = Game1.waveBank; - - } //works - - - public static void Info_Loader(string root_dir, string config_path) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. - { - - if (!File.Exists(config_path)) //check to make sure the file actually exists. It should. - { - Console.WriteLine("StardewSymphony:This music pack lacks a Config.txt. Without one, I can't load in the music."); - //Setup_Creator(config_path); - } - - else - { - // Load in all of the text files from the Music Packs - string[] readtext = File.ReadAllLines(config_path); - string wave = Convert.ToString(readtext[3]); - string sound = Convert.ToString(readtext[5]); - MusicManager lol = new MusicManager(wave,sound, root_dir); - lol.Music_Loader_Seasons("spring", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("summer", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("fall", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("winter", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("spring_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("summer_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("fall_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("winter_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("spring_rain", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("summer_rain", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("fall_rain", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("winter_snow", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("spring_rain_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("summer_rain_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("fall_rain_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("winter_snow_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - foreach (var loc in location_list) - { - lol.Music_Loader_Locations(loc.name, song_wave_reference); //name of location, and the song_wave_reference list - lol.Music_Loader_Locations_Night(loc.name+"_night", song_wave_reference); //name of location, and the song_wave_reference list - lol.Music_Loader_Locations_Rain(loc.name+"_rain", song_wave_reference); //name of location, and the song_wave_reference list - lol.Music_Loader_Locations_Rain_Night(loc.name+"_rain_night", song_wave_reference); //name of location, and the song_wave_reference list - } - if (lol != null) - { - master_list.Add(lol); //add everything to my master list of songs! - } - } - } - - public static void ProcessDirectory(string targetDirectory) - { - // System.Threading.Thread.Sleep(1); - // Process the list of files found in the directory. - fileEntries = Directory.GetFiles(targetDirectory); - - foreach (var v in fileEntries) - { - string extension = Path.GetExtension(v); - // Log.AsyncC(extension); - if (extension == ".xsb") - { - Log.AsyncG(v); - MusicHexProcessor.allsoundBanks.Add(v); - } - if(extension == "xwb") - { - Log.AsyncC(v); - MusicHexProcessor.allWaveBanks.Add(v); - } - } - - if (File.Exists(Path.Combine(targetDirectory, "Config.txt"))){ - string temp = Path.Combine(targetDirectory, "Config.txt"); - //Monitor.Log("YAY"); - music_packs.Add(targetDirectory, temp); - - } - - - - //do checking for spring, summer, night, etc. - - // Recurse into subdirectories of this directory. - subdirectoryEntries = Directory.GetDirectories(targetDirectory); - foreach (string subdirectory in subdirectoryEntries) - { - - ProcessDirectory(subdirectory); - } - } - - public static void process_music_packs() - { - foreach(var hello in music_packs) - { - Info_Loader(hello.Key, hello.Value); - // Monitor.Log("HORRAY"); - } - - - } - public void Location_Grabber() - { - //grab each location in SDV so that the mod will update itself accordingly incase new areas are added - foreach (var loc in StardewValley.Game1.locations) - { - Monitor.Log(loc.name); - location_list.Add(loc); - - } - } - public void music_selector() - { - if (game_loaded == false) - { - return; - } - // no_music = false; - //if at any time the music for an area can't be played for some unknown reason, the game should default to playing the Stardew Valley Soundtrack. - bool night_time=false; - bool rainy = Game1.isRaining; - - if (is_farm == true) - { - farm_music_selector(); - return; - } - if (StardewValley.Game1.isFestival() == true) - { - stop_sound(); - return; //replace with festival music if I decide to support it. - } - if (StardewValley.Game1.eventUp == true) - { - stop_sound(); - return; //replace with event music if I decide to support it/people request it. - } - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay > Game1.getModeratelyDarkTime()) - { - night_time = true; - } - else - { - night_time = false; - } - - if (rainy == true && night_time == true) - { - music_player_rain_night(); //some really awful heirarchy type thing I made up to help ensure that music plays all the time - if (no_music==true) - { - music_player_rain(); - if (no_music==true) - { - music_player_night(); - if (no_music == true) - { - music_player_location(); - - } - } - } - - } - if (rainy == true && night_time == false) - { - music_player_rain(); - if (no_music == true) - { - music_player_night(); - if (no_music == true) - { - music_player_location(); - - } - } - - } - if (rainy == false && night_time == true) - { - music_player_night(); - if (no_music == true) //if there is no music playing right now play some music. - { - music_player_location(); - - } - - } - if (rainy == false && night_time == false) - { - music_player_location(); - } - - if (no_music==false) //if there is valid music playing - { - // Monitor.Log("RETURN"); - return; - } - else - { - if (seasonal_music == false) - { - return; - } - - if (cueball != null) - { - if (cueball.IsPlaying == true) - { - return; - } - } - - Monitor.Log("Loading Default Seasonal Music"); - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - //add in seasonal stuff here - if (Game1.IsSpring == true && no_music==true) - { - if (rainy==true) - { - spring_rain_songs(); - } - else - { - spring_songs(); - } - } - if (Game1.IsSummer == true && no_music == true) - { - if (rainy == true) - { - summer_rain_songs(); - } - else - { - summer_songs(); - } - } - if (Game1.IsFall == true && no_music == true) - { - if (rainy == true) - { - fall_rain_songs(); - } - else - { - fall_songs(); - } - } - if (Game1.IsWinter == true && no_music == true) - { - if (Game1.isSnowing==true) - { - winter_snow_songs(); - } - else - { - winter_songs(); - } - } - - } - - - //end of function. Natural return; - return; - } - - - public void farm_music_selector() - { - - if (game_loaded == false) - { - return; - } - // no_music = false; - //if at any time the music for an area can't be played for some unknown reason, the game should default to playing the Stardew Valley Soundtrack. - bool night_time = false; - bool rainy = Game1.isRaining; - - Monitor.Log("Loading farm music."); - if (StardewValley.Game1.isFestival() == true) - { - stop_sound(); - return; //replace with festival music if I decide to support it. - } - if (StardewValley.Game1.eventUp == true) - { - stop_sound(); - return; //replace with event music if I decide to support it/people request it. - } - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay > Game1.getModeratelyDarkTime()) - { - night_time = true; - } - else - { - night_time = false; - } - - Monitor.Log("Loading Default Seasonal Music"); - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - //add in seasonal stuff here - if (Game1.IsSpring == true) - { - if (rainy == true) - { - spring_rain_songs(); - } - else - { - spring_songs(); - } - } - if (Game1.IsSummer == true) - { - if (rainy == true) - { - summer_rain_songs(); - } - else - { - summer_songs(); - } - } - if (Game1.IsFall == true) - { - if (rainy == true) - { - fall_rain_songs(); - } - else - { - fall_songs(); - } - } - if (Game1.IsWinter == true) - { - if (Game1.isSnowing == true) - { - winter_snow_songs(); - } - else - { - winter_songs(); - } - } - //end seasonal songs - if (cueball != null) - { - if (cueball.IsPlaying == true) - { - return; - } - } - //start locational songs - if (rainy == true && night_time == true) - { - music_player_rain_night(); //some really awful heirarchy type thing I made up to help ensure that music plays all the time - if (no_music == true) - { - music_player_rain(); - if (no_music == true) - { - music_player_night(); - if (no_music == true) - { - music_player_location(); - - } - } - } - - } - if (rainy == true && night_time == false) - { - music_player_rain(); - if (no_music == true) - { - music_player_night(); - if (no_music == true) - { - music_player_location(); - - } - } - - } - if (rainy == false && night_time == true) - { - music_player_night(); - if (no_music == true) - { - music_player_location(); - - } - - } - if (rainy == false && night_time == false) - { - music_player_location(); - } - - //end of function. Natural return; - return; - } - - public void music_player_location() - { - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - if (Game1.player.currentLocation != null) - { - int helper1 = 0; - int master_helper = 0; - bool found = false; - - int chedar = 0; - //this mess of a while loop iterates across all of my music packs looking for a valid music pack to play music from. - while (true) - { - if (current_info_class.locational_songs.Keys.Contains(Game1.player.currentLocation.name)) - { - - foreach (var happy in current_info_class.locational_songs) - { - if (happy.Key == Game1.player.currentLocation.name) - { - if (happy.Value.Count > 0) - { - //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); - found = true; - break; - } - else - { - //this section tells me if it is valid and is less than or equal to 0 - //Monitor.Log("Count is less than for this class zero. Switching music packs"); - found = false; - master_helper++; //iterate across the classes - break; - } - - } - else - {//this section iterates through the keys - Monitor.Log("Not there"); - found = false; - helper1++; - continue; - } - - } //itterate through all of the valid locations that were stored in this class - - } - else - { - Monitor.Log("No data could be loaded on this area. Swaping music packs"); - found = false; - } - if (found == false) //if I didnt find the music. - { - master_helper++; - - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - else - { - break; - } - - } - temp_cue = current_info_class.locational_songs.Values.ElementAt(helper1); //set a list of songs to a "random" list of songs from a music pack - int pointer = 0; - int motzy = 0; //why do I name my variables pointless names? - while (temp_cue.Count == 0) //yet another circular array - { - pointer++; - motzy = (pointer + randomNumber) % master_list.Count; - - current_info_class = master_list.ElementAt(motzy); - if (pointer > master_list.Count) - { - Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); - no_music = true; - return; - } - - } - - Monitor.Log("loading music for this area"); - if (temp_cue == null) - { - Monitor.Log("temp cue list is null????"); - return; - } - stop_sound(); - int random3 = random.Next(0, temp_cue.Count); - Game1.soundBank = current_info_class.new_sound_bank; //change the game's soundbank temporarily - Game1.waveBank = current_info_class.newwave;//dito but wave bank - - cueball = temp_cue.ElementAt(random3); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) - { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "for the location " + Game1.player.currentLocation); - no_music = false; - cueball.Play(); //play some music - reset(); - return; - } - } - else - { - Monitor.Log("Location is null"); - no_music = true; - } - }//end music player - public void music_player_rain() - { - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - if (Game1.player.currentLocation != null) - { - int helper1 = 0; - int master_helper = 0; - bool found = false; - - int chedar = 0; - - while (true) - { - if (current_info_class.locational_rain_songs.Keys.Contains(Game1.player.currentLocation.name+"_rain")) - { - - foreach (var happy in current_info_class.locational_rain_songs) - { - if (happy.Key == Game1.player.currentLocation.name+"_rain") - { - if (happy.Value.Count > 0) - { - //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); - found = true; - break; - } - else - { - //this section tells me if it is valid and is less than or equal to 0 - //Monitor.Log("Count is less than for this class zero. Switching music packs"); - found = false; - master_helper++; //iterate across the classes - break; - } - - } - else - {//this section iterates through the keys - Monitor.Log("Not there"); - found = false; - helper1++; - continue; - } - - } //itterate through all of the svalid locations that were stored in this class - - } - else - { - Monitor.Log("No data could be loaded on this area. Swaping music packs"); - found = false; - } - if (found == false) //if I didnt find the music. - { - master_helper++; - - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - else - { - break; - } - } - temp_cue = current_info_class.locational_rain_songs.Values.ElementAt(helper1); - - - int pointer = 0; - int motzy = 0; - while (temp_cue.Count == 0) - { - pointer++; - motzy = (pointer + randomNumber) % master_list.Count; - - current_info_class = master_list.ElementAt(motzy); - if (pointer > master_list.Count) - { - Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); - no_music = true; - return; - } - - } - - - - Monitor.Log("loading music for this area"); - if (temp_cue == null) - { - Monitor.Log("temp cue list is null????"); - return; - } - stop_sound(); - int random3 = random.Next(0, temp_cue.Count); - Game1.soundBank = current_info_class.new_sound_bank; - Game1.waveBank = current_info_class.newwave; - - cueball = temp_cue.ElementAt(random3); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) - { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "for the location " + Game1.player.currentLocation + " while it is raining"); - cueball.Play(); - reset(); - return; - } - - - - } - else - { - Monitor.Log("Location is null"); - } - }//end music player - public void music_player_night() - { - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - if (Game1.player.currentLocation != null) - { - int helper1 = 0; - int master_helper = 0; - bool found = false; - - int chedar = 0; - - while (true) - { - if (current_info_class.locational_night_songs.Keys.Contains(Game1.player.currentLocation.name+"_night")) - { - - foreach (var happy in current_info_class.locational_night_songs) - { - if (happy.Key == Game1.player.currentLocation.name+"_night") - { - if (happy.Value.Count > 0) - { - //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); - found = true; - break; - } - else - { - //this section tells me if it is valid and is less than or equal to 0 - //Monitor.Log("Count is less than for this class zero. Switching music packs"); - found = false; - master_helper++; //iterate across the classes - break; - } - - } - else - {//this section iterates through the keys - Monitor.Log("Not there"); - found = false; - helper1++; - continue; - } - - } //itterate through all of the svalid locations that were stored in this class - - } - else - { - Monitor.Log("No data could be loaded on this area. Swaping music packs"); - found = false; - } - if (found == false) //if I didnt find the music. - { - master_helper++; - - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - else - { - break; - } - } - temp_cue = current_info_class.locational_night_songs.Values.ElementAt(helper1); - int pointer = 0; - int motzy = 0; - while (temp_cue.Count == 0) - { - pointer++; - motzy = (pointer + randomNumber) % master_list.Count; - - current_info_class = master_list.ElementAt(motzy); - if (pointer > master_list.Count) - { - Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); - no_music = true; - return; - } - - } - - - Monitor.Log("loading music for this area"); - if (temp_cue == null) - { - Monitor.Log("temp cue list is null????"); - return; - } - stop_sound(); - int random3 = random.Next(0, temp_cue.Count); - Game1.soundBank = current_info_class.new_sound_bank; - Game1.waveBank = current_info_class.newwave; - - cueball = temp_cue.ElementAt(random3); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) - { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "for the location " + Game1.player.currentLocation + " while it is night time."); - cueball.Play(); - reset(); - return; - } - - - - } - else - { - Monitor.Log("Location is null"); - } - }//end music player - public void music_player_rain_night() - { - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - if (Game1.player.currentLocation != null) - { - - int helper1 = 0; - int master_helper = 0; - bool found = false; - - int chedar = 0; //this is why I shouldn't program before a date. I name my variables after really random crap. - - while (true) - { - if (current_info_class.locational_rain_night_songs.Keys.Contains(Game1.player.currentLocation.name+"_rain_night")) - { - - foreach (var happy in current_info_class.locational_rain_night_songs) - { - if (happy.Key == Game1.player.currentLocation.name+"_rain_night") - { - if (happy.Value.Count > 0) - { - //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); - found = true; - break; - } - else - { - //this section tells me if it is valid and is less than or equal to 0 - //Monitor.Log("Count is less than for this class zero. Switching music packs"); - found = false; - master_helper++; //iterate across the classes - break; - } - - } - else - {//this section iterates through the keys - Monitor.Log("Not there"); - found = false; - helper1++; - continue; - } - - } //itterate through all of the svalid locations that were stored in this class - - } - else - { - Monitor.Log("No data could be loaded on this area. Swaping music packs"); - found = false; - } - if (found == false) //if I didnt find the music. - { - master_helper++; - - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - else - { - break; - } - } - temp_cue = current_info_class.locational_rain_night_songs.Values.ElementAt(helper1); - - int pointer = 0; - int motzy = 0; - while (temp_cue.Count == 0) - { - pointer++; - motzy = (pointer + randomNumber) % master_list.Count; - - current_info_class = master_list.ElementAt(motzy); - if (pointer > master_list.Count) - { - Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); - no_music = true; - return; - } - - } - Monitor.Log("loading music for this area"); - if (temp_cue == null) - { - Monitor.Log("temp cue list is null????"); - return; - } - stop_sound(); - int random3 = random.Next(0, temp_cue.Count); - Game1.soundBank = current_info_class.new_sound_bank; - Game1.waveBank = current_info_class.newwave; - - cueball = temp_cue.ElementAt(random3); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) - { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "for the location " + Game1.player.currentLocation + " while it is raining at night."); - cueball.Play(); - reset(); - return; - } - - - - } - else - { - Monitor.Log("Location is null"); - } - }//end music player - - public void spring_songs() - { - - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. - { - randomNumber = random.Next(0,current_info_class.num_of_spring_night_songs); //random number between 0 and n. 0 not includes - - if (current_info_class.spring_night_song_list.Count == 0) //nightly spring songs - { - Monitor.Log("The spring night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.spring_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.spring_night_song_list.ElementAt(randomNumber); //grab a random song from the spring song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - - return; - - //break; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - - - else - { - stop_sound(); - cueball = current_info_class.spring_night_song_list.ElementAt(randomNumber); //grab a random song from the spring song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - if (cueball != null) - { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Spring Night. Check the seasons folder for more info"); - cueball.Play(); - Class1.reset(); - return; - } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. - - - } - //not nightly spring songs. AKA default songs - - randomNumber = random.Next(0,current_info_class.num_of_spring_songs); //random number between 0 and n. 0 not includes - if (current_info_class.spring_song_list.Count == 0) - { - Monitor.Log("The spring night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.spring_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.spring_song_list.ElementAt(randomNumber); //grab a random song from the spring song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - cueball = current_info_class.spring_song_list.ElementAt(randomNumber); //grab a random song from the spring song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - if (cueball == null) return; - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "while it is Spring Time. Check the seasons folder for more info"); - cueball.Play(); - Class1.reset(); - return; - - } //plays the songs associated with spring time - public void spring_rain_songs() - { - - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. - { - randomNumber = random.Next(0, current_info_class.num_of_spring_rain_night_songs); //random number between 0 and n. 0 not includes - - if (current_info_class.spring_rain_night_song_list.Count == 0) //nightly spring_rain songs - { - Monitor.Log("The spring_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.spring_rain_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.spring_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the spring_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - cueball = current_info_class.spring_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - - - if (cueball != null) - { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "while it is a rainy Spring night. Check the Seasons folder for more info"); - cueball.Play(); - Class1.reset(); - return; - } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. - - - } - //not nightly spring_rain songs. AKA default songs - - randomNumber = random.Next(0, current_info_class.num_of_spring_rain_songs); //random number between 0 and n. 0 not includes - if (current_info_class.spring_rain_song_list.Count == 0) - { - Monitor.Log("The spring_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.spring_rain_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.spring_rain_song_list.ElementAt(randomNumber); //grab a random song from the spring_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - cueball = current_info_class.spring_rain_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - if (cueball == null) return; - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "while it is a rainy Spring Day. Check the seasons folder for more info"); - cueball.Play(); - Class1.reset(); - return; - - } //plays the songs associated with spring time - public void summer_songs() - { - - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. - { - randomNumber = random.Next(0, current_info_class.num_of_summer_night_songs); //random number between 0 and n. 0 not includes - - if (current_info_class.summer_night_song_list.Count == 0) //nightly summer songs - { - Monitor.Log("The summer night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.summer_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_night_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_night_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - cueball = Game1.soundBank.GetCue(cueball.Name); - - } - - - - if (cueball != null) - { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Summer Night. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); - return; - } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. - - - } - //not nightly summer songs. AKA default songs - - randomNumber = random.Next(0, current_info_class.num_of_summer_songs); //random number between 0 and n. 0 not includes - if (current_info_class.summer_song_list.Count == 0) - { - Monitor.Log("The summer night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.summer_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - if (cueball == null) return; - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) - { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Fall day. Check the Seasons folder for more info."); - // System.Threading.Thread.Sleep(30000); - no_music = false; - cueball.Play(); - Class1.reset(); - } - return; - - } //plays the songs associated with summer time - public void summer_rain_songs() - { - - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. - { - randomNumber = random.Next(0, current_info_class.num_of_summer_rain_night_songs); //random number between 0 and n. 0 not includes - - if (current_info_class.summer_rain_night_song_list.Count == 0) //nightly summer_rain songs - { - Monitor.Log("The summer_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.summer_rain_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the summer_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - - else - { - stop_sound(); - cueball = current_info_class.summer_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - - if (cueball != null) - { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a rainy Summer Night. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); - return; - } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. - - - } - //not nightly summer_rain songs. AKA default songs - - randomNumber = random.Next(0, current_info_class.num_of_summer_rain_songs); //random number between 0 and n. 0 not includes - if (current_info_class.summer_rain_song_list.Count == 0) - { - Monitor.Log("The summer_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.summer_rain_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_rain_song_list.ElementAt(randomNumber); //grab a random song from the summer_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - - else - { - stop_sound(); - cueball = current_info_class.summer_rain_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - - if (cueball == null) return; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a rainy Summer day. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); - return; - - } //plays the songs associated with summer time - public void fall_songs() - { - - if (game_loaded == false) - { - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - // System.Threading.Thread.Sleep(3000); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. - { - randomNumber = random.Next(0, current_info_class.fall_night_song_list.Count); //random number between 0 and n. 0 not includes - - if (current_info_class.fall_night_song_list.Count == 0) //nightly fall songs - { - Monitor.Log("The fall night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - // System.Threading.Thread.Sleep(3000); - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.fall_night_song_list.Count > 0) - { - stop_sound(); - cueball = current_info_class.fall_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper >= master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - // System.Threading.Thread.Sleep(3000); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - - cueball = current_info_class.fall_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - - - if (cueball != null) - { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Fall Night. Check the Seasons folder for more info."); - - //System.Threading.Thread.Sleep(30000); - no_music = false; - cueball.Play(); - reset(); - return; - } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. - - - } - //not nightly fall songs. AKA default songs - - randomNumber = random.Next(0, current_info_class.fall_song_list.Count); //random number between 0 and n. 0 not includes - if (current_info_class.fall_song_list.Count == 0) - { - Monitor.Log("The fall night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - // System.Threading.Thread.Sleep(3000); - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.fall_song_list.Count > 0) - { - stop_sound(); - cueball = current_info_class.fall_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - - if (master_helper >= master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - // System.Thr1eading.Thread.Sleep(3000); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - cueball = current_info_class.fall_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - if (cueball != null) - { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Fall day. Check the Seasons folder for more info."); - // System.Threading.Thread.Sleep(30000); - no_music = false; - cueball.Play(); - reset(); - } - return; - - } //plays the songs associated with fall time - public void fall_rain_songs() - { - - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. - { - randomNumber = random.Next(0, current_info_class.num_of_fall_rain_night_songs); //random number between 0 and n. 0 not includes - - if (current_info_class.fall_rain_night_song_list.Count == 0) //nightly fall_rain songs - { - Monitor.Log("The fall_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.fall_rain_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.fall_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the fall_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); - - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - cueball = current_info_class.fall_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - - - if (cueball != null) - { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a rainy Fall Night. Check the Seasons folder for more info."); - cueball.Play(); - Class1.reset(); - return; - } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. - - - } - //not nightly fall_rain songs. AKA default songs - - randomNumber = random.Next(0, current_info_class.num_of_fall_rain_songs); //random number between 0 and n. 0 not includes - if (current_info_class.fall_rain_song_list.Count == 0) - { - Monitor.Log("The fall_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.fall_rain_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.fall_rain_song_list.ElementAt(randomNumber); //grab a random song from the fall_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - cueball = current_info_class.fall_rain_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - - if (cueball == null) return; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a rainy Fall day. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); - return; - - } //plays the songs associated with fall time - public void winter_songs() - { - - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. - { - randomNumber = random.Next(0, current_info_class.num_of_winter_night_songs); //random number between 0 and n. 0 not includes - - if (current_info_class.winter_night_song_list.Count == 0) //nightly winter songs - { - - Monitor.Log("The winter night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.winter_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.winter_night_song_list.ElementAt(randomNumber); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - - else - { - stop_sound(); - cueball = current_info_class.winter_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - - if (cueball != null) - { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Winter Night. Check the Seasons folder for more info."); - cueball.Play(); - Class1.reset(); - return; - } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. - - - } - //not nightly winter songs. AKA default songs - - randomNumber = random.Next(0, current_info_class.num_of_winter_songs); //random number between 0 and n. 0 not includes - if (current_info_class.winter_song_list.Count == 0) - { - Monitor.Log("The winter night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.winter_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.winter_song_list.ElementAt(randomNumber); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - cueball = current_info_class.winter_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - if (cueball == null) return; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Winter Day. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); - return; - - } //plays the songs associated with winter time - public void winter_snow_songs() - { - - if (game_loaded == false) - { - SetTimer(); - return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. - - - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. - { - randomNumber = random.Next(0, current_info_class.num_of_winter_snow_night_songs); //random number between 0 and n. 0 not includes - - if (current_info_class.winter_snow_night_song_list.Count == 0) //nightly winter_snow songs - { - Monitor.Log("The winter_snow night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.winter_snow_night_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.winter_snow_night_song_list.ElementAt(randomNumber); //grab a random song from the winter_snow song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - - else - { - stop_sound(); - cueball = current_info_class.winter_snow_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - - if (cueball != null) - { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a snowy Winter night. Check the Seasons folder for more info."); - cueball.Play(); - Class1.reset(); - return; - } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. - - - } - //not nightly winter_snow songs. AKA default songs - - randomNumber = random.Next(0, current_info_class.num_of_winter_snow_songs); //random number between 0 and n. 0 not includes - if (current_info_class.winter_snow_song_list.Count == 0) - { - Monitor.Log("The winter_snow night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) - { - if (current_info_class.winter_snow_song_list.Count > 0) - { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.winter_snow_song_list.ElementAt(randomNumber); //grab a random song from the winter_snow song list - cueball = Game1.soundBank.GetCue(cueball.Name); - break; - - } //itterate through all of the svalid locations that were stored in this class - else - { - master_helper++; - } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - return; - // cueball = null; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; - } - } - else - { - stop_sound(); - cueball = current_info_class.winter_snow_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); - } - if (cueball == null) return; - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a snowy winter day. Check the Seasons folder for more info."); - cueball.Play(); - Class1.reset(); - return; - - } //plays the songs associated with spring time - - - public static void stop_sound() //Stops any song that is playing at the time. - { - - if (cueball == null) - { - //trying to stop a song that doesn't "exist" crashes the game. This prevents that. - return; - } - - if (current_info_class == null) - { - //if my info class is null, return. Should only be null if the game starts. Pretty sure my code should prevent this. - return; - } - Game1.soundBank = current_info_class.new_sound_bank; //reset the wave/sound banks back to the music pack's - Game1.waveBank = current_info_class.newwave; - cueball.Stop(AudioStopOptions.Immediate); //redundant stopping code - cueball.Stop(AudioStopOptions.AsAuthored); - Game1.soundBank = old_sound_bank; //reset the wave/sound to the game's original - Game1.waveBank = oldwave; - cueball = null; - } //stop whatever song is playing. - public static void reset() - { - Game1.waveBank = oldwave; - Game1.soundBank = old_sound_bank; - } - -//config/loading stuff below - void MyWritter() - { - //saves the BuildEndurance_data at the end of a new day; - string mylocation = Path.Combine(Helper.DirectoryPath, "Music_Expansion_Config"); - //string mylocation2 = mylocation + myname; - string mylocation3 = mylocation + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) - { - Console.WriteLine("The config file for SDV_Music_Expansion wasn't found. Time to create it!"); - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player: Stardew Valley Music Expansion Config. Feel free to edit."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Minimum delay time: This is the minimal amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; - mystring3[3] = delay_time_min.ToString(); - - mystring3[4] = "Maximum delay time: This is the maximum amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; - mystring3[5] = delay_time_max.ToString(); - - mystring3[6] = "Silent rain? Setting this value to false plays the default ambient rain music along side whatever songs are set in rain music. Setting this to true will disable the ambient rain music. It's up to the soundpack creators wither or not they want to mix their music with rain prior to loading it in here."; - mystring3[7] = silent_rain.ToString(); - - mystring3[8] = "Seasonal_Music? Setting this value to true will play the seasonal music from the music packs instead of defaulting to the Stardew Valley Soundtrack."; - mystring3[9] = seasonal_music.ToString(); - - mystring3[10] = "Prioritize seasonal music on the Farm? If true the game will check for seasonal music before checking for locational music."; - mystring3[11] = farm_player.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player: Stardew Valley Music Expansion Config. Feel free to edit."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Minimum delay time: This is the minimal amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; - mystring3[3] = delay_time_min.ToString(); - - mystring3[4] = "Maximum delay time: This is the maximum amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; - mystring3[5] = delay_time_max.ToString(); - - mystring3[6] = "Silent rain? Setting this value to false plays the default ambient rain music along side whatever songs are set in rain music. Setting this to true will disable the ambient rain music. It's up to the soundpack creators wither or not they want to mix their music with rain prior to loading it in here."; - mystring3[7] = silent_rain.ToString(); - mystring3[8] = "Seasonal_Music? Setting this value to true will play the seasonal music from the music packs instead of defaulting to the Stardew Valley Soundtrack."; - mystring3[9] = seasonal_music.ToString(); - - mystring3[10] = "Prioritize seasonal music on the Farm? If true the game will check for seasonal music before checking for locational music."; - mystring3[11] = farm_player.ToString(); - - File.WriteAllLines(mylocation3, mystring3); - } - } - void DataLoader() - { - //loads the data to the variables upon loading the game. - string mylocation = Path.Combine(Helper.DirectoryPath, "Music_Expansion_Config"); - //string mylocation2 = mylocation + myname; - string mylocation3 = mylocation + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - delay_time_min = 10000; - delay_time_max = 30000; - silent_rain = false; - seasonal_music = true; - farm_player = true; - } - - else - { - Monitor.Log("Music Expansion Config Loaded"); - // Console.WriteLine("HEY THERE IM LOADING DATA"); - - //loads the BuildEndurance_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation3); - delay_time_min = Convert.ToInt32(readtext[3]); - delay_time_max = Convert.ToInt32(readtext[5]); //these array locations refer to the lines in BuildEndurance_data.json - silent_rain = Convert.ToBoolean(readtext[7]); - seasonal_music = Convert.ToBoolean(readtext[9]); - if (readtext[11] == "") farm_player = true; - else farm_player = Convert.ToBoolean(readtext[11]); - - } - } - - - - }//ends class1 -}//ends namespace \ No newline at end of file diff --git a/GeneralMods/StardewSymphony/Framework/MusicHexProcessor.cs b/GeneralMods/StardewSymphony/Framework/MusicHexProcessor.cs new file mode 100644 index 00000000..b7809b36 --- /dev/null +++ b/GeneralMods/StardewSymphony/Framework/MusicHexProcessor.cs @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using StardewValley; + +namespace Omegasis.StardewSymphony.Framework +{ + internal class MusicHexProcessor + { + /********* + ** Properties + *********/ + /// All of the music/soundbanks and their locations. + private readonly IList MasterList; + + /// The registered soundbanks. + private readonly List SoundBanks = new List(); + + /// The callback to reset the game audio. + private readonly Action Reset; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// All of the music/soundbanks and their locations. + /// The callback to reset the game audio. + public MusicHexProcessor(IList masterList, Action reset) + { + this.MasterList = masterList; + this.Reset = reset; + } + + /// Add a file path to the list of soundbanks. + /// The soundbank file path. + public void AddSoundBank(string path) + { + this.SoundBanks.Add(path); + } + + public void ProcessHex() + { + int counter = 0; + foreach (string entry in this.SoundBanks) + { + List cleanCueNames = new List(); + byte[] array = File.ReadAllBytes(entry); + string rawName = entry.Substring(0, entry.Length - 4); + string cueName = rawName + "CueList.txt"; + if (File.Exists(cueName)) continue; + + string hexDumpContents = this.HexDump(array); + + string rawHexName = rawName + "HexDump.txt"; + File.WriteAllText(rawHexName, hexDumpContents); + + string[] readText = File.ReadAllLines(rawHexName); + string largeString = ""; + foreach (var line in readText) + { + try + { + string newString = ""; + for (int i = 62; i <= 77; i++) + newString += line[i]; + largeString += newString; + } + catch { } + } + string[] splits = largeString.Split('ÿ'); + string fix = ""; + foreach (string s in splits) + { + if (s == "") continue; + fix += s; + } + splits = fix.Split('.'); + + foreach (var split in splits) + { + if (split == "") continue; + + try + { + Game1.waveBank = this.MasterList[counter].Wavebank; + Game1.soundBank = this.MasterList[counter].Soundbank; + + if (Game1.soundBank.GetCue(split) != null) + cleanCueNames.Add(split); + + this.Reset(); + } + catch { } + } + + cueName = rawName + "CueList.txt"; + cleanCueNames.Sort(); + File.WriteAllLines(cueName, cleanCueNames); + counter++; + } + } + + + /********* + ** Private methods + *********/ + private string HexDump(byte[] bytes, int bytesPerLine = 16) + { + if (bytes == null) + return ""; + + int bytesLength = bytes.Length; + + char[] hexChars = "0123456789ABCDEF".ToCharArray(); + + int firstHexColumn = + 8 // 8 characters for the address + + 3; // 3 spaces + + int firstCharColumn = firstHexColumn + + bytesPerLine * 3 // - 2 digit for the hexadecimal value and 1 space + + (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th + + 2; // 2 spaces + + int lineLength = firstCharColumn + + bytesPerLine // - characters to show the ascii value + + Environment.NewLine.Length; // Carriage return and line feed (should normally be 2) + + char[] line = (new String(' ', lineLength - 2) + Environment.NewLine).ToCharArray(); + int expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine; + StringBuilder result = new StringBuilder(expectedLines * lineLength); + + for (int i = 0; i < bytesLength; i += bytesPerLine) + { + line[0] = hexChars[(i >> 28) & 0xF]; + line[1] = hexChars[(i >> 24) & 0xF]; + line[2] = hexChars[(i >> 20) & 0xF]; + line[3] = hexChars[(i >> 16) & 0xF]; + line[4] = hexChars[(i >> 12) & 0xF]; + line[5] = hexChars[(i >> 8) & 0xF]; + line[6] = hexChars[(i >> 4) & 0xF]; + line[7] = hexChars[(i >> 0) & 0xF]; + + int hexColumn = firstHexColumn; + int charColumn = firstCharColumn; + + for (int j = 0; j < bytesPerLine; j++) + { + if (j > 0 && (j & 7) == 0) hexColumn++; + if (i + j >= bytesLength) + { + line[hexColumn] = ' '; + line[hexColumn + 1] = ' '; + line[charColumn] = ' '; + } + else + { + byte b = bytes[i + j]; + line[hexColumn] = hexChars[(b >> 4) & 0xF]; + line[hexColumn + 1] = hexChars[b & 0xF]; + line[charColumn] = this.GetAsciiSymbol(b); + } + hexColumn += 3; + charColumn++; + } + result.Append(line); + } + return result.ToString(); + } + + private char GetAsciiSymbol(byte ch) + { + if (ch < 32) return '.'; // Non-printable ASCII + if (ch < 127) return (char)ch; // Normal ASCII + // Handle the hole in Latin-1 + if (ch == 127) return '.'; + if (ch < 0x90) return "€.‚ƒ„…†‡ˆ‰Š‹Œ.Ž."[ch & 0xF]; + if (ch < 0xA0) return ".‘’“”•–—˜™š›œ.žŸ"[ch & 0xF]; + if (ch == 0xAD) return '.'; // Soft hyphen: this symbol is zero-width even in monospace fonts + return (char)ch; // Normal Latin-1 + } + } +} diff --git a/GeneralMods/StardewSymphony/Framework/MusicManager.cs b/GeneralMods/StardewSymphony/Framework/MusicManager.cs new file mode 100644 index 00000000..f23c2405 --- /dev/null +++ b/GeneralMods/StardewSymphony/Framework/MusicManager.cs @@ -0,0 +1,396 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.Xna.Framework.Audio; +using StardewValley; + +namespace Omegasis.StardewSymphony.Framework +{ + /// Data and metadata for a music pack. + internal class MusicManager + { + /********* + ** Properties + *********/ + /// The valid season values. + private readonly Season[] Seasons = Enum.GetValues(typeof(Season)).Cast().ToArray(); + + + /********* + ** Accessors + *********/ + /// The directory path containing the music. + public string Directory { get; } + + /// The name of the wavebank file. + public string WavebankName { get; } + + /// The name of the soundbank file. + public string SoundbankName { get; } + + /// The loaded wavebank (if any). + public WaveBank Wavebank { get; } + + /// The loaded soundbank (if any). + public SoundBank Soundbank { get; } + + /// The default music to play if there isn't a more specific option. + public IDictionary> DefaultSongs = MusicManager.CreateSeasonalSongList(); + + /// The music to play at night. + public IDictionary> NightSongs = MusicManager.CreateSeasonalSongList(); + + /// The music to play on rainy days. + public IDictionary> RainySongs = MusicManager.CreateSeasonalSongList(); + + /// The music to play on rainy nights. + public IDictionary> RainyNightSongs = MusicManager.CreateSeasonalSongList(); + + /// Songs that play in specific locations. + public Dictionary> LocationSongs { get; } = new Dictionary>(); + + /// Songs that play in specific locations on rainy days. + public Dictionary> LocationRainSongs { get; } = new Dictionary>(); + + /// Songs that play in specific locations at night. + public Dictionary> LocationNightSongs { get; } = new Dictionary>(); + + /// Songs that play in specific locations on rainy nights. + public Dictionary> LocationRainNightSongs { get; } = new Dictionary>(); + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The name of the wavebank file. + /// The name of the soundbank file. + /// The directory path containing the music. + public MusicManager(string wavebank, string soundbank, string directory) + { + // init data + this.Directory = directory; + this.WavebankName = wavebank + ".xwb"; + this.SoundbankName = soundbank + ".xsb"; + + // init banks + string wavePath = Path.Combine(this.Directory, this.WavebankName); + string soundPath = Path.Combine(this.Directory, this.SoundbankName); + + Console.WriteLine(wavePath); + Console.WriteLine(soundPath); + + if (File.Exists(wavePath)) + this.Wavebank = new WaveBank(Game1.audioEngine, wavePath); + if (File.Exists(Path.Combine(this.Directory, this.SoundbankName))) + this.Soundbank = new SoundBank(Game1.audioEngine, soundPath); + + // update audio + Game1.audioEngine.Update(); + } + + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void LoadSeasonalSongs(string conditionalName, IDictionary cues) + { + string path = Path.Combine(this.Directory, "Music_Files", "Seasons", conditionalName + ".txt"); + if (!File.Exists(path)) + { + Console.WriteLine($"Stardew Symohony:The specified music file could not be found. That music file is {conditionalName} which should be located at {path} but don't worry I'll create it for you right now. It's going to be blank though"); + string[] text = new string[3]; + text[0] = conditionalName + " music file. This file holds all of the music that will play when there is no music for this game location, or simply put this is default music. Simply type the name of the song below the wall of equal signs."; + text[1] = "========================================================================================"; + + File.WriteAllLines(path, text); + } + else + { + Console.WriteLine($"Stardew Symphony:The music pack located at: {this.Directory} is processing the song info for the game location: {conditionalName}"); + + string[] text = File.ReadAllLines(path); + int i = 2; + var lineCount = File.ReadLines(path).Count(); + + while (i < lineCount) //the ordering seems bad, but it works. + { + if (Convert.ToString(text[i]) == "") + break; + if (Convert.ToString(text[i]) == "\n") + break; + + foreach (Season season in this.Seasons) + { + // default music + if ($"{season}".Equals(conditionalName, StringComparison.InvariantCultureIgnoreCase)) + { + string cueName = Convert.ToString(text[i]); + i++; + + this.DefaultSongs[season].Add(this.Soundbank.GetCue(cueName)); + if (!cues.Keys.Contains(cueName)) + cues.Add(cueName, this); + } + + // night music + if ($"{season}_night".Equals(conditionalName, StringComparison.InvariantCultureIgnoreCase)) + { + string cueName = Convert.ToString(text[i]); + i++; + + this.NightSongs[season].Add(this.Soundbank.GetCue(cueName)); + if (!cues.Keys.Contains(cueName)) + cues.Add(cueName, this); + } + + // rain music + if ($"{season}_rain".Equals(conditionalName, StringComparison.InvariantCultureIgnoreCase)) + { + string cueName = Convert.ToString(text[i]); + i++; + + this.RainySongs[season].Add(this.Soundbank.GetCue(cueName)); + if (!cues.Keys.Contains(cueName)) + cues.Add(cueName, this); + } + + // rainy night + if ($"{season}_rain_night".Equals(conditionalName, StringComparison.InvariantCultureIgnoreCase)) + { + string cueName = Convert.ToString(text[i]); + i++; + + this.RainyNightSongs[season].Add(this.Soundbank.GetCue(cueName)); + if (!cues.Keys.Contains(cueName)) + cues.Add(cueName, this); + } + } + } + if (i == 2) + { + // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 +" this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); + return; + } + Console.WriteLine($"Stardew Symohony:The music pack located at: {this.Directory} has successfully processed the song info for the game location {conditionalName}"); + } + } + + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Locations(string conditionalName, IDictionary cues) + { + List locationSongs = new List(); + + string path = Path.Combine(this.Directory, "Music_Files", "Locations", conditionalName + ".txt"); + if (!File.Exists(path)) + { + Console.WriteLine("StardewSymohony:A music list for the location " + conditionalName + " does not exist for the music pack located at " + path + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); + + string[] text = new string[3];//seems legit. + text[0] = conditionalName + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; + text[1] = "========================================================================================"; + + File.WriteAllLines(path, text); + } + else + { + Console.WriteLine("Stardew Symphony:The music pack located at: " + this.Directory + " is processing the song info for the game location: " + conditionalName); + string[] readtext = File.ReadAllLines(path); + int i = 2; + var lineCount = File.ReadLines(path).Count(); + while (i < lineCount) //the ordering seems bad, but it works. + { + if (Convert.ToString(readtext[i]) == "") + break; + if (Convert.ToString(readtext[i]) == "\n") + break; + string cueName = Convert.ToString(readtext[i]); + i++; + if (!cues.Keys.Contains(cueName)) + { + locationSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); + } + else + locationSongs.Add(this.Soundbank.GetCue(cueName)); + } + if (i == 2) + { + // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); + return; + } + if (locationSongs.Count > 0) + { + this.LocationSongs.Add(conditionalName, locationSongs); + Console.WriteLine("StardewSymhony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); + } + } + } + + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Locations_Rain(string conditionalName, IDictionary cues) + { + List locationSongs = new List(); + string path = Path.Combine(this.Directory, "Music_Files", "Locations", conditionalName + ".txt"); + if (!File.Exists(path)) + { + Console.WriteLine("StardewSymphony:A music list for the location " + conditionalName + " does not exist for the music pack located at " + path + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); + string[] text = new string[3];//seems legit. + text[0] = conditionalName + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; + text[1] = "========================================================================================"; + File.WriteAllLines(path, text); + } + else + { + // add in data here + string[] readtext = File.ReadAllLines(path); + int i = 2; + var lineCount = File.ReadLines(path).Count(); + while (i < lineCount) //the ordering seems bad, but it works. + { + if (Convert.ToString(readtext[i]) == "") + break; + if (Convert.ToString(readtext[i]) == "\n") + break; + string cueName = Convert.ToString(readtext[i]); + i++; + if (!cues.Keys.Contains(cueName)) + { + locationSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); + } + else + locationSongs.Add(this.Soundbank.GetCue(cueName)); + } + if (i == 2) + { + // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); + return; + } + if (locationSongs.Count > 0) + { + this.LocationRainSongs.Add(conditionalName, locationSongs); + Console.WriteLine("StardewSymohony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); + } + } + } + + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Locations_Night(string conditionalName, IDictionary cues) + { + List locationSongs = new List(); + string path = Path.Combine(this.Directory, "Music_Files", "Locations", conditionalName + ".txt"); + if (!File.Exists(path)) + { + Console.WriteLine("StardewSymphony:A music list for the location " + conditionalName + " does not exist for the music pack located at " + path + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); + string[] text = new string[3];//seems legit. + text[0] = conditionalName + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; + text[1] = "========================================================================================"; + File.WriteAllLines(path, text); + } + else + { + // add in data here + string[] readtext = File.ReadAllLines(path); + int i = 2; + var lineCount = File.ReadLines(path).Count(); + + while (i < lineCount) //the ordering seems bad, but it works. + { + if (Convert.ToString(readtext[i]) == "") + break; + if (Convert.ToString(readtext[i]) == "\n") + break; + string cueName = Convert.ToString(readtext[i]); + i++; + if (!cues.Keys.Contains(cueName)) + { + locationSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); + } + else + locationSongs.Add(this.Soundbank.GetCue(cueName)); + } + if (i == 2) + { + // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); + return; + } + if (locationSongs.Count > 0) + { + this.LocationNightSongs.Add(conditionalName, locationSongs); + Console.WriteLine("StardewSymphonyLThe music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); + } + } + } + + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Locations_Rain_Night(string conditionalName, IDictionary cues) + { + List locationSongs = new List(); + var musicPath = this.Directory; + + string path = Path.Combine(musicPath, "Music_Files", "Locations", conditionalName + ".txt"); + if (!File.Exists(path)) + { + Console.WriteLine("StardewSymphony:A music list for the location " + conditionalName + " does not exist for the music pack located at " + path + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); + string[] text = new string[3];//seems legit. + text[0] = conditionalName + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; + text[1] = "========================================================================================"; + File.WriteAllLines(path, text); + } + else + { + //load in music stuff from the text files using the code below. + string[] text = File.ReadAllLines(path); + int i = 2; + var lineCount = File.ReadLines(path).Count(); + + while (i < lineCount) //the ordering seems bad, but it works. + { + if (Convert.ToString(text[i]) == "") //if there is ever an empty line, stop processing the music file + break; + if (Convert.ToString(text[i]) == "\n") + break; + string cueName = Convert.ToString(text[i]); + i++; + if (!cues.Keys.Contains(cueName)) + { + locationSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); + } + else + locationSongs.Add(this.Soundbank.GetCue(cueName)); + } + if (i == 2) + { + // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); + return; + } + + if (locationSongs.Count > 0) + { + this.LocationRainNightSongs.Add(conditionalName, locationSongs); + Console.WriteLine("StardewSymohony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); + } + } + } + + /// Create a dictionary of seasonal songs. + private static IDictionary> CreateSeasonalSongList() + { + IDictionary> dict = new Dictionary>(); + foreach (Season season in Enum.GetValues(typeof(Season))) + dict[season] = new List(); + return dict; + } + } +} diff --git a/GeneralMods/StardewSymphony/Framework/Season.cs b/GeneralMods/StardewSymphony/Framework/Season.cs new file mode 100644 index 00000000..b411c9da --- /dev/null +++ b/GeneralMods/StardewSymphony/Framework/Season.cs @@ -0,0 +1,18 @@ +namespace Omegasis.StardewSymphony.Framework +{ + /// In-game season values. + internal enum Season + { + /// The spring season. + Spring, + + /// The summer season. + Summer, + + /// The fall season. + Fall, + + /// The winter season. + Winter + } +} diff --git a/GeneralMods/StardewSymphony/MusicHexProcessor.cs b/GeneralMods/StardewSymphony/MusicHexProcessor.cs deleted file mode 100644 index 1946ea1a..00000000 --- a/GeneralMods/StardewSymphony/MusicHexProcessor.cs +++ /dev/null @@ -1,197 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using StardewValley; - -namespace Omegasis.StardewSymphony -{ - class MusicHexProcessor - { - public static List allsoundBanks; - public static List allHexDumps; - public static List allWaveBanks; - - public static void processHex() - { - int counter = 0; - string HexDumpContents = ""; - string rawName = ""; - string rawHexName = ""; - string cueName = ""; - List cleanCueNames = new List(); - foreach (var v in allsoundBanks) - { - cleanCueNames = new List(); - byte[] array = System.IO.File.ReadAllBytes(v); - // Log.AsyncC(HexDump(array)); - rawName=v.Substring(0,v.Length-4); - cueName = (rawName + "CueList.txt"); - if (File.Exists(cueName)) continue; - - HexDumpContents = HexDump(array); - - rawHexName = rawName + "HexDump.txt"; - File.WriteAllText(rawHexName, HexDumpContents); - // string fileName = (v.Remove(v.Length - 5, v.Length-1)); - //Log.AsyncM(fileName); - allHexDumps.Add(rawHexName); - - string[] readText = File.ReadAllLines(rawHexName); - string largeString=""; - foreach (var line in readText) - { - // Log.AsyncY(line); - try - { - string newString = ""; - for (int i = 62; i <= 77; i++) - { - newString += line[i]; - } - // Log.AsyncG(newString); - largeString += newString; - // Log.AsyncC(largeString); - //Log.AsyncG(line.Substring(63, 78)); - } - catch (Exception e) - { - // Log.AsyncY("WTF"); - // Log.AsyncO(line.Length); - } - } - string[] splits = largeString.Split('ÿ'); - string fix = ""; - foreach (string s in splits) - { - if (s == "") continue; - fix += s; - } - splits = fix.Split('.'); - - foreach (var split in splits) - { - if (split == "") continue; - // Log.AsyncM(split); - - try - { - - - - // Game1.playSound(split); - Game1.waveBank = Class1.master_list[counter].newwave; - Game1.soundBank = Class1.master_list[counter].new_sound_bank; - - - if (Game1.soundBank.GetCue(split) != null) - { - //Game1.playSound(split); - cleanCueNames.Add(split); - // Log.AsyncG("Sucessfully added " + split + " to the list of successful songs to play."); - } - - Class1.reset(); - - } - catch(Exception e) - { - // Log.AsyncR(e); - } - - } - - cueName = (rawName + "CueList.txt"); - // Log.AsyncM(cueName); - cleanCueNames.Sort(); - File.WriteAllLines(cueName, cleanCueNames); - counter++; - } - - } - - - - - - - - - public static string HexDump(byte[] bytes, int bytesPerLine = 16) - { - if (bytes == null) return ""; - int bytesLength = bytes.Length; - - char[] HexChars = "0123456789ABCDEF".ToCharArray(); - - int firstHexColumn = - 8 // 8 characters for the address - + 3; // 3 spaces - - int firstCharColumn = firstHexColumn - + bytesPerLine * 3 // - 2 digit for the hexadecimal value and 1 space - + (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th - + 2; // 2 spaces - - int lineLength = firstCharColumn - + bytesPerLine // - characters to show the ascii value - + Environment.NewLine.Length; // Carriage return and line feed (should normally be 2) - - char[] line = (new String(' ', lineLength - 2) + Environment.NewLine).ToCharArray(); - int expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine; - StringBuilder result = new StringBuilder(expectedLines * lineLength); - - for (int i = 0; i < bytesLength; i += bytesPerLine) - { - line[0] = HexChars[(i >> 28) & 0xF]; - line[1] = HexChars[(i >> 24) & 0xF]; - line[2] = HexChars[(i >> 20) & 0xF]; - line[3] = HexChars[(i >> 16) & 0xF]; - line[4] = HexChars[(i >> 12) & 0xF]; - line[5] = HexChars[(i >> 8) & 0xF]; - line[6] = HexChars[(i >> 4) & 0xF]; - line[7] = HexChars[(i >> 0) & 0xF]; - - int hexColumn = firstHexColumn; - int charColumn = firstCharColumn; - - for (int j = 0; j < bytesPerLine; j++) - { - if (j > 0 && (j & 7) == 0) hexColumn++; - if (i + j >= bytesLength) - { - line[hexColumn] = ' '; - line[hexColumn + 1] = ' '; - line[charColumn] = ' '; - } - else - { - byte b = bytes[i + j]; - line[hexColumn] = HexChars[(b >> 4) & 0xF]; - line[hexColumn + 1] = HexChars[b & 0xF]; - line[charColumn] = asciiSymbol(b); - } - hexColumn += 3; - charColumn++; - } - result.Append(line); - } - return result.ToString(); - } - static char asciiSymbol(byte val) - { - if (val < 32) return '.'; // Non-printable ASCII - if (val < 127) return (char)val; // Normal ASCII - // Handle the hole in Latin-1 - if (val == 127) return '.'; - if (val < 0x90) return "€.‚ƒ„…†‡ˆ‰Š‹Œ.Ž."[val & 0xF]; - if (val < 0xA0) return ".‘’“”•–—˜™š›œ.žŸ"[val & 0xF]; - if (val == 0xAD) return '.'; // Soft hyphen: this symbol is zero-width even in monospace fonts - return (char)val; // Normal Latin-1 - } - - - - -} -} diff --git a/GeneralMods/StardewSymphony/MusicManager.cs b/GeneralMods/StardewSymphony/MusicManager.cs deleted file mode 100644 index 5cbf4b09..00000000 --- a/GeneralMods/StardewSymphony/MusicManager.cs +++ /dev/null @@ -1,812 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.Xna.Framework.Audio; -using StardewValley; - -namespace Omegasis.StardewSymphony -{ - //also known as the music_pack - public class MusicManager - { - public string wave_bank_name; - public string sound_bank_name; - - public List spring_song_list; - public int num_of_spring_songs; - public List summer_song_list; - public int num_of_summer_songs; - public List fall_song_list; - public int num_of_fall_songs; - public List winter_song_list; - public int num_of_winter_songs; - - - public List spring_night_song_list; - public int num_of_spring_night_songs; - public List summer_night_song_list; - public int num_of_summer_night_songs; - public List fall_night_song_list; - public int num_of_fall_night_songs; - public List winter_night_song_list; - public int num_of_winter_night_songs; - - - public List spring_rain_song_list; - public int num_of_spring_rain_songs; - public List summer_rain_song_list; - public int num_of_summer_rain_songs; - public List fall_rain_song_list; - public int num_of_fall_rain_songs; - public List winter_snow_song_list; - public int num_of_winter_snow_songs; - - - public List spring_rain_night_song_list; - public int num_of_spring_rain_night_songs; - public List summer_rain_night_song_list; - public int num_of_summer_rain_night_songs; - public List fall_rain_night_song_list; - public int num_of_fall_rain_night_songs; - public List winter_snow_night_song_list; - public int num_of_winter_snow_night_songs; - - public List locational_cues; - public Dictionary> locational_songs; - - - public Dictionary> locational_rain_songs; - public Dictionary> locational_night_songs; - public Dictionary> locational_rain_night_songs; - - - public WaveBank newwave; - public SoundBank new_sound_bank; - public string path_loc; - - public MusicManager(string wb, string sb, string directory) - { - wave_bank_name = wb; - sound_bank_name = sb; - wave_bank_name += ".xwb"; - sound_bank_name += ".xsb"; - path_loc = directory; - - Console.WriteLine(Path.Combine(path_loc, wave_bank_name)); - Console.WriteLine(Path.Combine(path_loc, sound_bank_name)); - - - if (File.Exists(Path.Combine(path_loc, wave_bank_name))) - { - newwave = new WaveBank(Game1.audioEngine, Path.Combine(path_loc, wave_bank_name)); //look for wave bank in sound_pack root directory. - } - if (File.Exists(Path.Combine(path_loc, sound_bank_name))) - { - new_sound_bank = new SoundBank(Game1.audioEngine, Path.Combine(path_loc, sound_bank_name)); //look for sound bank in sound_pack root directory. - } - - Game1.audioEngine.Update(); - - spring_song_list = new List(); - num_of_spring_songs = 0; - summer_song_list = new List(); - num_of_summer_songs = 0; - fall_song_list = new List(); - num_of_fall_songs = 0; - winter_song_list = new List(); - num_of_winter_songs = 0; - - spring_night_song_list = new List(); - num_of_spring_night_songs = 0; - summer_night_song_list = new List(); - num_of_summer_night_songs = 0; - fall_night_song_list = new List(); - num_of_fall_night_songs = 0; - winter_night_song_list = new List(); - num_of_winter_night_songs = 0; - - - //rainy initialization - spring_rain_song_list = new List(); - num_of_spring_rain_songs = 0; - summer_rain_song_list = new List(); - num_of_summer_rain_songs = 0; - fall_rain_song_list = new List(); - num_of_fall_rain_songs = 0; - winter_snow_song_list = new List(); - num_of_winter_snow_songs = 0; - - spring_rain_night_song_list = new List(); - num_of_spring_rain_night_songs = 0; - summer_rain_night_song_list = new List(); - num_of_summer_rain_night_songs = 0; - fall_rain_night_song_list = new List(); - num_of_fall_rain_night_songs = 0; - winter_snow_night_song_list = new List(); - num_of_winter_snow_night_songs = 0; - - locational_songs = new Dictionary>(); - locational_rain_songs = new Dictionary>(); - locational_night_songs = new Dictionary>(); - locational_rain_night_songs = new Dictionary>(); - } - - public void Music_Loader_Seasons(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. - { - //loads the data to the variables upon loading the game. - var music_path = path_loc; - string mylocation = Path.Combine(music_path, "Music_Files", "Seasons", conditional_name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - - - if (!File.Exists(mylocation3)) //check to make sure the file actually exists - { - - string error_message = "Stardew Symohony:The specified music file could not be found. That music file is " + conditional_name + " which should be located at " + mylocation3 + " but don't worry I'll create it for you right now. It's going to be blank though"; - Console.WriteLine(error_message); - - string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when there is no music for this game location, or simply put this is default music. Simply type the name of the song below the wall of equal signs."; - mystring3[1] = "========================================================================================"; - - File.WriteAllLines(mylocation3, mystring3); - } - - else - { - Console.WriteLine("Stardew Symphony:The music pack located at: " + path_loc + " is processing the song info for the game location: " + conditional_name); - //System.Threading.Thread.Sleep(1000); - // add in data here - - string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; - int i = 2; - var lineCount = File.ReadLines(mylocation3).Count(); - - while (i < lineCount) //the ordering seems bad, but it works. - { - if (Convert.ToString(readtext[i]) == "") - { - // Monitor.Log("Blank space detected."); - break; - - } - if (Convert.ToString(readtext[i]) == "\n") - { - break; - - } - - - if (conditional_name == "spring") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - - if (!reference_dic.Keys.Contains(cue_name)) - { - spring_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - spring_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_songs++; - } - // Monitor.Log(cue_name); - } - if (conditional_name == "summer") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - summer_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - summer_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_songs++; - } - } - if (conditional_name == "fall") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - fall_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - fall_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_songs++; - } - } - if (conditional_name == "winter") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - winter_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - winter_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_songs++; - } - } - //add in other stuff here - //======================================================================================================================================================================================== - //NIGHTLY SEASONAL LOADERS - if (conditional_name == "spring_night") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - - if (!reference_dic.Keys.Contains(cue_name)) - { - spring_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_night_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - spring_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_night_songs++; - } - // Monitor.Log(cue_name); - } - if (conditional_name == "summer_night") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - summer_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_night_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - summer_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_night_songs++; - } - } - if (conditional_name == "fall_night") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - fall_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_night_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - fall_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_night_songs++; - } - } - if (conditional_name == "winter_night") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - winter_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_night_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - winter_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_night_songs++; - } - } - ////////NOW I"M ADDING THE PART THAT WILL READ IN RAINY SEASONAL SONGS FOR DAY AND NIGHT - if (conditional_name == "spring_rain") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - - if (!reference_dic.Keys.Contains(cue_name)) - { - spring_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_rain_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - spring_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_rain_songs++; - } - // Monitor.Log(cue_name); - } - if (conditional_name == "summer_rain") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - summer_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_rain_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - summer_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_rain_songs++; - } - } - if (conditional_name == "fall_rain") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - fall_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_rain_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - fall_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_rain_songs++; - } - } - if (conditional_name == "winter_snow") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - winter_snow_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_snow_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - winter_snow_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_snow_songs++; - } - } - //add in other stuff here - //======================================================================================================================================================================================== - //NIGHTLY SEASONAL RAIN LOADERS - if (conditional_name == "spring_rain_night") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - - if (!reference_dic.Keys.Contains(cue_name)) - { - spring_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_rain_night_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - spring_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_rain_night_songs++; - } - // Monitor.Log(cue_name); - } - if (conditional_name == "summer_rain_night") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - summer_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_rain_night_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - summer_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_rain_night_songs++; - } - } - if (conditional_name == "fall_rain_night") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - fall_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_rain_night_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - fall_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_rain_night_songs++; - } - } - if (conditional_name == "winter_snow_night") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - winter_snow_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_snow_night_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - winter_snow_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_snow_night_songs++; - } - } - } - if (i == 2) - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 +" this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - // System.Threading.Thread.Sleep(10); - return; - } - Console.WriteLine("StardewSymohony:The music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - } - } - public void Music_Loader_Locations(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. - { - locational_cues = new List(); - //loads the data to the variables upon loading the game. - var music_path = path_loc; - string mylocation = Path.Combine(music_path, "Music_Files", "Locations", conditional_name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //check to make sure the file actually exists - { - Console.WriteLine("StardewSymohony:A music list for the location " + conditional_name + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); - - //Console.WriteLine("Creating the Config file"); - string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; - mystring3[1] = "========================================================================================"; - - File.WriteAllLines(mylocation3, mystring3); - return; - } - - else - { - Console.WriteLine("Stardew Symphony:The music pack located at: " + path_loc + " is processing the song info for the game location: " + conditional_name); - //System.Threading.Thread.Sleep(1000); - string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; - int i = 2; - var lineCount = File.ReadLines(mylocation3).Count(); - while (i < lineCount) //the ordering seems bad, but it works. - { - if (Convert.ToString(readtext[i]) == "") - { - break; - } - if (Convert.ToString(readtext[i]) == "\n") - { - break; - } - cue_name = Convert.ToString(readtext[i]); - i++; - if (!reference_dic.Keys.Contains(cue_name)) - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - reference_dic.Add(cue_name, this); - } - else - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - } - } - if (i == 2) - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; - } - if (locational_cues.Count > 0) - { - locational_songs.Add(conditional_name, locational_cues); - Console.WriteLine("StardewSymhony:The music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - - return; - } - else - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; - } - } - } - - public void Music_Loader_Locations_Rain(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. - { - locational_cues = new List(); - var music_path = path_loc; - string mylocation = Path.Combine(music_path, "Music_Files", "Locations", conditional_name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //check to make sure the file actually exists - { - Console.WriteLine("StardewSymphony:A music list for the location " + conditional_name + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); - string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; - mystring3[1] = "========================================================================================"; - File.WriteAllLines(mylocation3, mystring3); - return; - } - - else - { - // add in data here - string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; - int i = 2; - var lineCount = File.ReadLines(mylocation3).Count(); - while (i < lineCount) //the ordering seems bad, but it works. - { - if (Convert.ToString(readtext[i]) == "") - { - // Monitor.Log("Blank space detected."); - break; - } - if (Convert.ToString(readtext[i]) == "\n") - { - // Monitor.Log("end line reached"); - break; - } - cue_name = Convert.ToString(readtext[i]); - i++; - if (!reference_dic.Keys.Contains(cue_name)) - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - reference_dic.Add(cue_name, this); - } - else - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - } - } - if (i == 2) - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; - } - if (locational_cues.Count > 0) - { - locational_rain_songs.Add(conditional_name, locational_cues); - Console.WriteLine("StardewSymohony:The music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - return; - } - else - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; - } - } - } - public void Music_Loader_Locations_Night(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. - { - locational_cues = new List(); - //loads the data to the variables upon loading the game. - var music_path = path_loc; - string mylocation = Path.Combine(music_path, "Music_Files", "Locations", conditional_name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //check to make sure the file actually exists - { - Console.WriteLine("StardewSymphony:A music list for the location " + conditional_name + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); - //Console.WriteLine("Creating the Config file"); - string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; - mystring3[1] = "========================================================================================"; - File.WriteAllLines(mylocation3, mystring3); - return; - } - - else - { - // add in data here - string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; - int i = 2; - var lineCount = File.ReadLines(mylocation3).Count(); - - while (i < lineCount) //the ordering seems bad, but it works. - { - if (Convert.ToString(readtext[i]) == "") - { - // Monitor.Log("Blank space detected."); - break; - - } - if (Convert.ToString(readtext[i]) == "\n") - { - //Monitor.Log("end line reached"); - break; - - } - cue_name = Convert.ToString(readtext[i]); - i++; - if (!reference_dic.Keys.Contains(cue_name)) - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - reference_dic.Add(cue_name, this); - } - else - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - } - - } - if (i == 2) - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; - } - if (locational_cues.Count > 0) - { - locational_night_songs.Add(conditional_name, locational_cues); - Console.WriteLine("StardewSymphonyLThe music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - return; - } - else - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; - } - } - } - public void Music_Loader_Locations_Rain_Night(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. - { - locational_cues = new List(); - var music_path = path_loc; - - string mylocation = Path.Combine(music_path, "Music_Files", "Locations", conditional_name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //check to make sure the file actually exists - { - Console.WriteLine("StardewSymphony:A music list for the location " + conditional_name + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); - string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; - mystring3[1] = "========================================================================================"; - - File.WriteAllLines(mylocation3, mystring3); - - - return; - } - - else - { - //load in music stuff from the text files using the code below. - string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; - int i = 2; - var lineCount = File.ReadLines(mylocation3).Count(); - - while (i < lineCount) //the ordering seems bad, but it works. - { - if (Convert.ToString(readtext[i]) == "") //if there is ever an empty line, stop processing the music file - { - break; - } - if (Convert.ToString(readtext[i]) == "\n") - { - break; - } - cue_name = Convert.ToString(readtext[i]); - i++; - if (!reference_dic.Keys.Contains(cue_name)) - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - reference_dic.Add(cue_name, this); - } - else - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - } - } - if (i == 2) - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - - return; - } - - if (locational_cues.Count > 0) - { - locational_rain_night_songs.Add(conditional_name, locational_cues); - - Console.WriteLine("StardewSymohony:The music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - return; - } - else - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; - } - - } - } - - }; -} diff --git a/GeneralMods/StardewSymphony/Music_Expansion_Config.txt b/GeneralMods/StardewSymphony/Music_Expansion_Config.txt deleted file mode 100644 index ce8fd1c6..00000000 --- a/GeneralMods/StardewSymphony/Music_Expansion_Config.txt +++ /dev/null @@ -1,20 +0,0 @@ -Player: Stardew Valley Music Expansion Config. Feel free to edit. -==================================================================================== -Minimum delay time: This is the minimal amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs. -10000 -Maximum delay time: This is the maximum amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs. -30000 -Silent rain? Setting this value to false plays the default ambient rain music along side whatever songs are set in rain music. Setting this to true will disable the ambient rain music. It's up to the soundpack creators wither or not they want to mix their music with rain prior to loading it in here. -False -Seasonal_Music? Setting this value to true will play the seasonal music from the music packs instead of defaulting to the Stardew Valley Soundtrack. -True -Prioritize seasonal music on the Farm? If true the game will check for seasonal music before checking for locational music. -True - - - - - - - - diff --git a/GeneralMods/StardewSymphony/Properties/AssemblyInfo.cs b/GeneralMods/StardewSymphony/Properties/AssemblyInfo.cs index 8ce84a72..a9567751 100644 --- a/GeneralMods/StardewSymphony/Properties/AssemblyInfo.cs +++ b/GeneralMods/StardewSymphony/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("Stardew_Music_Expansion_API")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Stardew_Music_Expansion_API")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("697f7ec8-02c6-4f39-a917-ee45955cfff9")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/StardewSymphony/README.md b/GeneralMods/StardewSymphony/README.md new file mode 100644 index 00000000..080ad71f --- /dev/null +++ b/GeneralMods/StardewSymphony/README.md @@ -0,0 +1,19 @@ +**Stardew Symphony** is a [Stardew Valley](http://stardewvalley.net/) mod which lets you add music +packs to Stardew Valley and play them without editing the game's default sound files. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/425). +3. Run the game using SMAPI. + +## Usage +Drop Stardew Symphony music packs into `Mods/Stardew_Symphony/Music_Files` to enable them. +Music can be conditional on location, season, and weather. + +This won't mute the music for in-game events or festivals. + +## Versions +1.0: +* Initial release. diff --git a/GeneralMods/StardewSymphony/ReadMe.txt b/GeneralMods/StardewSymphony/ReadMe.txt deleted file mode 100644 index ff90cd01..00000000 --- a/GeneralMods/StardewSymphony/ReadMe.txt +++ /dev/null @@ -1,11 +0,0 @@ -This is Stardew Symphony - -What this is is a music expansion API that allows users to add in music packs into Stardew Valley and play them without editing the game's default soundtrack. Music can be player per location and season, with additional options to play specific music depending on the time of day and the weather. More options such as muting the default rain soundtrack exist within the config file. This will not mute the music for in-game events or festivals. - -Installing music packs is simple as dragging and dropping a music pack into Stardew Valley/Mods/Stardew_Symphony/Music_Files/ - -Only music names included into the files located at -Stardew Valley/Mods/Stardew_Symphony/Music_Files/(music_pack_name)/Locations -and -Stardew Valley/Mods/Stardew_Symphony/Music_Files/(music_pack_name)/Seasons -will play according to the name of the file.txt \ No newline at end of file diff --git a/GeneralMods/StardewSymphony/StardewSymphony.cs b/GeneralMods/StardewSymphony/StardewSymphony.cs new file mode 100644 index 00000000..241ffca6 --- /dev/null +++ b/GeneralMods/StardewSymphony/StardewSymphony.cs @@ -0,0 +1,1239 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Timers; +using Microsoft.Xna.Framework.Audio; +using Omegasis.StardewSymphony.Framework; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +namespace Omegasis.StardewSymphony +{ + /* + TODO: + 0. Add in event handling so that I don't mute a heart event or wedding music. + 6. add in Stardew songs again to music selection + 7. add in more tracks. + 11. Tutorial for adding more music into the game? + 15. add in blank templates for users to make their own wave/sound banks + */ + /// The mod entry point. + public class StardewSymphony : Mod + { + /********* + ** Properties + *********/ + /// All of the music/soundbanks and their locations. + private IList MasterList = new List(); + + /// All of the cue names that I ever add in. + private IDictionary SongWaveReference; + + /// The game locations. + private IList GameLocations; + + /// The number generator for randomisation. + private Random Random; + + /// The game's original soundbank. + private SoundBank DefaultSoundbank; + + /// The game's original wavebank. + private WaveBank DefaultWavebank; + + private MusicHexProcessor HexProcessor; + + /**** + ** Context + ****/ + /// Whether the player loaded a save. + private bool IsGameLoaded; + + /// Whether no music pack was loaded for the current location. + private bool HasNoMusic; + + /// The song that's currently playing. + private Cue CurrentSong; + + /// The current sound info. + private MusicManager CurrentSoundInfo; + + /// A timer used to create random pauses between songs. + private Timer SongDelayTimer = new Timer(); + + /**** + ** Config + ****/ + /// The minimum delay (in milliseconds) to pass before playing the next song, or 0 for no delay. + private int MinSongDelay; + + /// The maximum delay (in milliseconds) to pass before playing the next song, or 0 for no delay. + private int MaxSongDelay; + + /// Whether to disable ambient rain audio when music is playing. If false, plays ambient rain audio alongside whatever songs are set in rain music. + private bool SilentRain; + + /// Whether to play seasonal music from the music packs, instead of defaulting to the Stardew Valley Soundtrack. + private bool PlaySeasonalMusic; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + this.HexProcessor = new MusicHexProcessor(this.MasterList, this.Reset); + + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + LocationEvents.CurrentLocationChanged += this.LocationEvents_CurrentLocationChanged; + } + + + /********* + ** Private methods + *********/ + /// 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) + { + if (!this.IsGameLoaded || !this.MasterList.Any()) + return; //basically if absolutly no music is loaded into the game for locations/festivals/seasons, don't override the game's default music player. + + if (this.CurrentSong == null) + { + this.HasNoMusic = true; + return; //if there wasn't any music at loaded at all for the area, just play the default stardew soundtrack. + } + if (this.HasNoMusic && !this.CurrentSong.IsPlaying) + this.CurrentSong = null; //if there was no music loaded for the area and the last song has finished playing, default to the Stardew Soundtrack. + + if (this.CurrentSong != null) + { + this.HasNoMusic = false; + if (!this.CurrentSong.IsPlaying && !this.SongDelayTimer.Enabled) + this.StartMusicDelay(); + } + + if (Game1.isFestival()) + return; // replace with festival + if (Game1.eventUp) + return; // replace with event music + if (Game1.isRaining && !this.SilentRain) + return; // play the rain ambience soundtrack + + Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs + Game1.nextMusicTrack = ""; //same as above line + } + + /// The method invoked when changes. + /// The event sender. + /// The event data. + private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e) + { + if (!this.IsGameLoaded) + return; + this.StopSound(); //if my music player is called and I forget to clean up sound before hand, kill the old sound. + this.LoadConfig(); + this.WriteConfig(); + + this.SelectMusic(); + } + + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + // init config + this.LoadConfig(); + this.WriteConfig(); + + // init context + this.Random = new Random(); + this.MasterList = new List(); + this.SongWaveReference = new Dictionary(); + this.GameLocations = Game1.locations; + this.HasNoMusic = true; + + // keep a copy of the original banks + this.DefaultSoundbank = Game1.soundBank; + this.DefaultWavebank = Game1.waveBank; + + // load music packs + { + string musicPacksPath = Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "Music_Packs")).FullName; + var musicPacks = new Dictionary(); + ProcessDirectory(musicPacksPath, musicPacks); + this.SongDelayTimer.Enabled = false; + foreach (var pack in musicPacks) + this.LoadMusicInfo(pack.Key, pack.Value); + } + + // init sound + this.HexProcessor.ProcessHex(); + this.IsGameLoaded = true; + this.SelectMusic(); + } + + /// The method invoked after the player warps to a new area. + /// The event sender. + /// The event data. + private void LocationEvents_CurrentLocationChanged(object sender, EventArgsCurrentLocationChanged e) + { + if (!this.IsGameLoaded) + return; + + this.SelectMusic(); + } + + /// Create a random delay and then choose the next song. + private void StartMusicDelay() + { + // reset timer + this.SongDelayTimer.Dispose(); + this.SongDelayTimer = new Timer(this.Random.Next(this.MinSongDelay, this.MaxSongDelay)); + + // start timer + this.SongDelayTimer.Elapsed += (sender, args) => + { + this.SelectMusic(); + this.SongDelayTimer.Enabled = false; + }; + this.SongDelayTimer.Start(); + } + + /// Reads cue names from a text file and adds them to a specific list. Morphs with specific conditional name. + /// The root directory for music files. + /// The full path to the config file to read. + private void LoadMusicInfo(string rootDir, string configPath) + { + // make sure file exists + if (!File.Exists(configPath)) + { + Console.WriteLine("StardewSymphony:This music pack lacks a Config.txt. Without one, I can't load in the music."); + return; + } + + // parse config file + string[] text = File.ReadAllLines(configPath); + string wave = Convert.ToString(text[3]); + string sound = Convert.ToString(text[5]); + + // load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. + MusicManager manager = new MusicManager(wave, sound, rootDir); + manager.LoadSeasonalSongs("spring", this.SongWaveReference); + manager.LoadSeasonalSongs("summer", this.SongWaveReference); + manager.LoadSeasonalSongs("fall", this.SongWaveReference); + manager.LoadSeasonalSongs("winter", this.SongWaveReference); + manager.LoadSeasonalSongs("spring_night", this.SongWaveReference); + manager.LoadSeasonalSongs("summer_night", this.SongWaveReference); + manager.LoadSeasonalSongs("fall_night", this.SongWaveReference); + manager.LoadSeasonalSongs("winter_night", this.SongWaveReference); + manager.LoadSeasonalSongs("spring_rain", this.SongWaveReference); + manager.LoadSeasonalSongs("summer_rain", this.SongWaveReference); + manager.LoadSeasonalSongs("fall_rain", this.SongWaveReference); + manager.LoadSeasonalSongs("winter_snow", this.SongWaveReference); + manager.LoadSeasonalSongs("spring_rain_night", this.SongWaveReference); + manager.LoadSeasonalSongs("summer_rain_night", this.SongWaveReference); + manager.LoadSeasonalSongs("fall_rain_night", this.SongWaveReference); + manager.LoadSeasonalSongs("winter_snow_night", this.SongWaveReference); + + // load location music + foreach (GameLocation location in this.GameLocations) + { + manager.Music_Loader_Locations(location.name, this.SongWaveReference); + manager.Music_Loader_Locations_Night(location.name + "_night", this.SongWaveReference); + manager.Music_Loader_Locations_Rain(location.name + "_rain", this.SongWaveReference); + manager.Music_Loader_Locations_Rain_Night(location.name + "_rain_night", this.SongWaveReference); + } + + // add everything to master song list + this.MasterList.Add(manager); + } + + /// Recursively load music packs from the given directory. + /// The directory path to search for music packs. + /// The dictionary to update with music packs. + private void ProcessDirectory(string dirPath, IDictionary musicPacks) + { + // load music files + foreach (string filePath in Directory.GetFiles(dirPath)) + { + string extension = Path.GetExtension(filePath); + if (extension == ".xsb") + { + Log.AsyncG(filePath); + this.HexProcessor.AddSoundBank(filePath); + } + //if (extension == "xwb") + //{ + // Log.AsyncC(path); + // MusicHexProcessor.allWaveBanks.Add(path); + //} + } + + // read config file + string configPath = Path.Combine(dirPath, "Config.txt"); + if (File.Exists(configPath)) + musicPacks.Add(dirPath, configPath); + + // check subdirectories + foreach (string childDir in Directory.GetDirectories(dirPath)) + this.ProcessDirectory(childDir, musicPacks); + } + + /// Get the current in-game season. + private Season GetSeason() + { + if (Game1.IsSpring) + return Season.Spring; + if (Game1.IsSummer) + return Season.Summer; + if (Game1.IsFall) + return Season.Fall; + return Season.Winter; + } + + /// Select music for the current location. + private void SelectMusic() + { + if (!this.IsGameLoaded) + return; + + // no_music = false; + //if at any time the music for an area can't be played for some unknown reason, the game should default to playing the Stardew Valley Soundtrack. + bool isRaining = Game1.isRaining; + + if (Game1.player.currentLocation is Farm) + { + farm_music_selector(); + return; + } + if (Game1.isFestival()) + { + this.StopSound(); + return; //replace with festival music if I decide to support it. + } + if (Game1.eventUp) + { + this.StopSound(); + return; //replace with event music if I decide to support it/people request it. + } + + + bool isNight = (Game1.timeOfDay < 600 || Game1.timeOfDay > Game1.getModeratelyDarkTime()); + if (isRaining) + { + if (isNight) + { + this.PlayRainyNightMusic(); //some really awful heirarchy type thing I made up to help ensure that music plays all the time + if (this.HasNoMusic) + { + this.PlayRainSong(); + if (this.HasNoMusic) + { + this.PlayNightSong(); + if (this.HasNoMusic) + this.PlayDefaultSong(); + } + } + } + else + { + this.PlayRainSong(); + if (this.HasNoMusic) + { + this.PlayNightSong(); + if (this.HasNoMusic) + this.PlayDefaultSong(); + } + } + } + else + { + if (isNight) + { + this.PlayNightSong(); + if (this.HasNoMusic) //if there is no music playing right now play some music. + this.PlayDefaultSong(); + } + else + this.PlayDefaultSong(); + } + + if (this.HasNoMusic) //if there is valid music playing + { + if (!this.PlaySeasonalMusic) + return; + + if (this.CurrentSong != null && this.CurrentSong.IsPlaying) + return; + + this.Monitor.Log("Loading Default Seasonal Music"); + + if (!this.MasterList.Any()) + { + this.Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + } + + //add in seasonal stuff here + if (this.HasNoMusic) + { + Season season = this.GetSeason(); + if (isRaining) + this.StartRainySong(season); + else + this.StartDefaultSong(season); + } + } + } + + public void farm_music_selector() + { + if (!this.IsGameLoaded) + return; + + // no_music = false; + //if at any time the music for an area can't be played for some unknown reason, the game should default to playing the Stardew Valley Soundtrack. + bool rainy = Game1.isRaining; + + this.Monitor.Log("Loading farm music."); + if (Game1.isFestival()) + { + this.StopSound(); + return; //replace with festival music if I decide to support it. + } + if (Game1.eventUp) + { + this.StopSound(); + return; //replace with event music if I decide to support it/people request it. + } + + this.Monitor.Log("Loading Default Seasonal Music"); + + if (!this.MasterList.Any()) + { + this.Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + + } + + //add in seasonal stuff here + Season season = this.GetSeason(); + if (rainy) + this.StartRainySong(season); + else + this.StartDefaultSong(season); + + //end seasonal songs + if (this.CurrentSong != null && this.CurrentSong.IsPlaying) + return; + + //start locational songs + bool nightTime = Game1.timeOfDay < 600 || Game1.timeOfDay > Game1.getModeratelyDarkTime(); + if (rainy && nightTime) + { + this.PlayRainyNightMusic(); //some really awful heirarchy type thing I made up to help ensure that music plays all the time + if (this.HasNoMusic) + { + this.PlayRainSong(); + if (this.HasNoMusic) + { + this.PlayNightSong(); + if (this.HasNoMusic) + this.PlayDefaultSong(); + } + } + + } + if (rainy && !nightTime) + { + this.PlayRainSong(); + if (this.HasNoMusic) + { + this.PlayNightSong(); + if (this.HasNoMusic) + this.PlayDefaultSong(); + } + + } + if (!rainy && nightTime) + { + this.PlayNightSong(); + if (this.HasNoMusic) + this.PlayDefaultSong(); + + } + if (!rainy && !nightTime) + this.PlayDefaultSong(); + } + + public void PlayDefaultSong() + { + if (!this.IsGameLoaded) + { + this.StartMusicDelay(); + return; + } + int randomNumber = this.Random.Next(0, this.MasterList.Count); + + if (!this.MasterList.Any()) + { + this.Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + + } + + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + if (Game1.player.currentLocation != null) + { + int helper1 = 0; + int masterHelper = 0; + bool found = false; + + //this mess of a while loop iterates across all of my music packs looking for a valid music pack to play music from. + while (true) + { + if (this.CurrentSoundInfo.LocationSongs.Keys.Contains(Game1.player.currentLocation.name)) + { + + foreach (var entry in this.CurrentSoundInfo.LocationSongs) + { + if (entry.Key == Game1.player.currentLocation.name) + { + if (entry.Value.Count > 0) + { + //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); + found = true; + break; + } + else + { + //this section tells me if it is valid and is less than or equal to 0 + masterHelper++; //iterate across the classes + break; + } + + } + else + { + this.Monitor.Log("Not there"); + helper1++; + } + } //itterate through all of the valid locations that were stored in this class + } + else + this.Monitor.Log("No data could be loaded on this area. Swaping music packs"); + if (found) + break; + + masterHelper++; + + if (masterHelper > this.MasterList.Count) + { + this.Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; + return; + + } + int randomIndex = (masterHelper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + } + + List cues = this.CurrentSoundInfo.LocationSongs.Values.ElementAt(helper1); //set a list of songs to a "random" list of songs from a music pack + int pointer = 0; + while (!cues.Any()) //yet another circular array + { + pointer++; + int randomID = (pointer + randomNumber) % this.MasterList.Count; + + this.CurrentSoundInfo = this.MasterList.ElementAt(randomID); + if (pointer > this.MasterList.Count) + { + this.Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); + this.HasNoMusic = true; + return; + } + + } + + this.Monitor.Log("loading music for this area"); + this.StopSound(); + int random3 = this.Random.Next(0, cues.Count); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //change the game's soundbank temporarily + Game1.waveBank = this.CurrentSoundInfo.Wavebank;//dito but wave bank + + this.CurrentSong = cues.ElementAt(random3); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) + { + this.Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "for the location " + Game1.player.currentLocation); + this.HasNoMusic = false; + this.CurrentSong.Play(); //play some music + this.Reset(); + } + } + else + { + this.Monitor.Log("Location is null"); + this.HasNoMusic = true; + } + } + + public void PlayRainSong() + { + if (!this.IsGameLoaded) + { + this.StartMusicDelay(); + return; + } + int randomNumber = this.Random.Next(0, this.MasterList.Count); + + if (!this.MasterList.Any()) + { + this.Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + + } + + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + + if (Game1.player.currentLocation != null) + { + int helper1 = 0; + int masterHelper = 0; + bool found = false; + + while (true) + { + if (this.CurrentSoundInfo.LocationRainSongs.Keys.Contains(Game1.player.currentLocation.name + "_rain")) + { + + foreach (var entry in this.CurrentSoundInfo.LocationRainSongs) + { + if (entry.Key == Game1.player.currentLocation.name + "_rain") + { + if (entry.Value.Count > 0) + { + //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); + found = true; + break; + } + else + { + //this section tells me if it is valid and is less than or equal to 0 + masterHelper++; //iterate across the classes + break; + } + + } + else + { + this.Monitor.Log("Not there"); + helper1++; + } + } + } + else + this.Monitor.Log("No data could be loaded on this area. Swaping music packs"); + + if (found) + break; + masterHelper++; + + if (masterHelper > this.MasterList.Count) + { + this.Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; + return; + } + int randomIndex = (masterHelper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + } + + List cues = this.CurrentSoundInfo.LocationRainSongs.Values.ElementAt(helper1); + + + int pointer = 0; + while (!cues.Any()) + { + pointer++; + int randomID = (pointer + randomNumber) % this.MasterList.Count; + + this.CurrentSoundInfo = this.MasterList.ElementAt(randomID); + if (pointer > this.MasterList.Count) + { + this.Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); + this.HasNoMusic = true; + return; + } + } + + this.Monitor.Log("loading music for this area"); + this.StopSound(); + int random3 = this.Random.Next(0, cues.Count); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + + this.CurrentSong = cues.ElementAt(random3); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) + { + this.HasNoMusic = false; + this.Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "for the location " + Game1.player.currentLocation + " while it is raining"); + this.CurrentSong.Play(); + this.Reset(); + } + } + else + this.Monitor.Log("Location is null"); + } + + public void PlayNightSong() + { + if (!this.IsGameLoaded) + { + this.StartMusicDelay(); + return; + } + int randomNumber = this.Random.Next(0, this.MasterList.Count); + + if (!this.MasterList.Any()) + { + this.Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + } + + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + + if (Game1.player.currentLocation != null) + { + int helper1 = 0; + int masterHelper = 0; + bool found = false; + + while (true) + { + if (this.CurrentSoundInfo.LocationNightSongs.Keys.Contains(Game1.player.currentLocation.name + "_night")) + { + foreach (var entry in this.CurrentSoundInfo.LocationNightSongs) + { + if (entry.Key == Game1.player.currentLocation.name + "_night") + { + if (entry.Value.Count > 0) + { + found = true; + break; + } + else + { + //this section tells me if it is valid and is less than or equal to 0 + masterHelper++; //iterate across the classes + break; + } + } + else + { + this.Monitor.Log("Not there"); + helper1++; + } + } + } + else + this.Monitor.Log("No data could be loaded on this area. Swaping music packs"); + if (found) + break; + + masterHelper++; + + if (masterHelper > this.MasterList.Count) + { + this.Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; + return; + } + int randomIndex = (masterHelper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + } + + List cues = this.CurrentSoundInfo.LocationNightSongs.Values.ElementAt(helper1); + int pointer = 0; + while (!cues.Any()) + { + pointer++; + int randomID = (pointer + randomNumber) % this.MasterList.Count; + + this.CurrentSoundInfo = this.MasterList.ElementAt(randomID); + if (pointer > this.MasterList.Count) + { + this.Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); + this.HasNoMusic = true; + return; + } + } + + this.Monitor.Log("loading music for this area"); + this.StopSound(); + int random3 = this.Random.Next(0, cues.Count); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + + this.CurrentSong = cues.ElementAt(random3); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) + { + this.HasNoMusic = false; + this.Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "for the location " + Game1.player.currentLocation + " while it is night time."); + this.CurrentSong.Play(); + this.Reset(); + } + } + else + this.Monitor.Log("Location is null"); + } + + public void PlayRainyNightMusic() + { + if (!this.IsGameLoaded) + { + this.StartMusicDelay(); + return; + } + int randomNumber = this.Random.Next(0, this.MasterList.Count); + + if (!this.MasterList.Any()) + { + this.Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + + } + + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + + if (Game1.player.currentLocation != null) + { + + int helper1 = 0; + int masterHelper = 0; + bool found = false; + + while (true) + { + if (this.CurrentSoundInfo.LocationRainNightSongs.Keys.Contains(Game1.player.currentLocation.name + "_rain_night")) + { + + foreach (var entry in this.CurrentSoundInfo.LocationRainNightSongs) + { + if (entry.Key == Game1.player.currentLocation.name + "_rain_night") + { + if (entry.Value.Count > 0) + { + found = true; + break; + } + else + { + //this section tells me if it is valid and is less than or equal to 0 + masterHelper++; //iterate across the classes + break; + } + + } + else + { + this.Monitor.Log("Not there"); + helper1++; + } + } + } + else + { + this.Monitor.Log("No data could be loaded on this area. Swaping music packs"); + } + + if (found) + break; + + masterHelper++; + + if (masterHelper > this.MasterList.Count) + { + this.Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; + return; + + } + int randomIndex = (masterHelper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + } + + List cues = this.CurrentSoundInfo.LocationRainNightSongs.Values.ElementAt(helper1); + + int pointer = 0; + while (!cues.Any()) + { + pointer++; + int randomID = (pointer + randomNumber) % this.MasterList.Count; + + this.CurrentSoundInfo = this.MasterList.ElementAt(randomID); + if (pointer > this.MasterList.Count) + { + this.Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); + this.HasNoMusic = true; + return; + } + + } + this.Monitor.Log("loading music for this area"); + this.StopSound(); + int random3 = this.Random.Next(0, cues.Count); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + + this.CurrentSong = cues.ElementAt(random3); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) + { + this.HasNoMusic = false; + this.Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "for the location " + Game1.player.currentLocation + " while it is raining at night."); + this.CurrentSong.Play(); + this.Reset(); + } + } + else + this.Monitor.Log("Location is null"); + } + + /// Start a default song for the given season. + /// The season for which to play music. + private void StartDefaultSong(Season season) + { + // check exit conditions + if (!this.IsGameLoaded) + { + this.StartMusicDelay(); + return; + } + if (!this.MasterList.Any()) + { + this.Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + } + + // get random song from available music packs + this.CurrentSoundInfo = this.MasterList[this.Random.Next(0, this.MasterList.Count)]; + + // pick night music + if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) + { + int randomSongIndex = this.Random.Next(0, this.CurrentSoundInfo.NightSongs[season].Count); + + if (!this.CurrentSoundInfo.NightSongs[season].Any()) + { + this.Monitor.Log($"The {season} night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? + + int minIndex = 0; + for (; minIndex < this.MasterList.Count; minIndex++) + { + if (this.CurrentSoundInfo.NightSongs[season].Count > 0) + { + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.NightSongs[season].ElementAt(randomSongIndex); //grab a random song from the seasonal song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + break; + } + + if (minIndex == this.MasterList.Count - 1) + { + this.Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; + return; + } + int randomIndex = (minIndex + randomSongIndex) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + } + } + else + { + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.NightSongs[season].ElementAt(randomSongIndex); //grab a random song from the seasonal song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + } + + // play selected song + if (this.CurrentSong != null) + { + this.HasNoMusic = false; + this.Monitor.Log($"Now listening to: {this.CurrentSong.Name} from the music pack located at: {this.CurrentSoundInfo.Directory} while it is a {season} Night. Check the seasons folder for more info"); + this.CurrentSong.Play(); + this.Reset(); + return; + } + } + + // else pick default music + { + int randomSongIndex = this.Random.Next(0, this.CurrentSoundInfo.DefaultSongs[season].Count); //random number between 0 and n. 0 not includes + if (!this.CurrentSoundInfo.DefaultSongs[season].Any()) + { + this.Monitor.Log($"The {season} night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? + + int minIndex = 0; + for (; minIndex < this.MasterList.Count; minIndex++) + { + if (this.CurrentSoundInfo.NightSongs[season].Count > 0) + { + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.DefaultSongs[season].ElementAt(randomSongIndex); //grab a random song from the seasonal song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + break; + } + + if (minIndex == this.MasterList.Count - 1) + { + this.Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; + return; + } + int randomIndex = (minIndex + randomSongIndex) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + } + } + else + { + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.DefaultSongs[season].ElementAt(randomSongIndex); //grab a random song from the seasonal song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + } + + // play selected song + if (this.CurrentSong != null) + { + this.HasNoMusic = false; + this.Monitor.Log($"Now listening to: {this.CurrentSong.Name} from the music pack located at: {this.CurrentSoundInfo.Directory} while it is {season} Time. Check the seasons folder for more info"); + this.CurrentSong.Play(); + this.Reset(); + } + } + } + + /// Start a song for rainy days in the given season. + /// The season for which to play music. + private void StartRainySong(Season season) + { + // check exit conditions + if (!this.IsGameLoaded) + { + this.StartMusicDelay(); + return; + } + if (!this.MasterList.Any()) + { + this.Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + } + + // get random song from available music packs + this.CurrentSoundInfo = this.MasterList[this.Random.Next(0, this.MasterList.Count)]; + + // pick night song + if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) + { + int randomNumber = this.Random.Next(0, this.CurrentSoundInfo.RainyNightSongs[season].Count); + + if (this.CurrentSoundInfo.RainyNightSongs[season].Count == 0) + { + this.Monitor.Log($"The {season}_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? + + int minIndex = 0; + for (; minIndex < this.MasterList.Count; minIndex++) + { + if (this.CurrentSoundInfo.RainyNightSongs[season].Count > 0) + { + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.RainyNightSongs[season].ElementAt(randomNumber); //grab a random song from the seasonal rain song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + break; + } + + if (minIndex == this.MasterList.Count - 1) + { + this.Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; + return; + } + int randomIndex = (minIndex + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + } + } + else + { + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.RainyNightSongs[season].ElementAt(randomNumber); //grab a random song from the seasonal song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + } + + // play selected song + if (this.CurrentSong != null) + { + this.HasNoMusic = false; + this.Monitor.Log($"Now listening to: {this.CurrentSong.Name} from the music pack located at: {this.CurrentSoundInfo.Directory} while it is a rainy {season} night. Check the Seasons folder for more info"); + this.CurrentSong.Play(); + this.Reset(); + return; + } + } + + // pick default song + { + int randomNumber = this.Random.Next(0, this.CurrentSoundInfo.RainySongs[season].Count); + + if (this.CurrentSoundInfo.RainySongs[season].Count == 0) + { + this.Monitor.Log($"The {season}_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? + int minIndex = 0; + for (; minIndex < this.MasterList.Count; minIndex++) + { + if (this.CurrentSoundInfo.RainySongs[Season.Spring].Count > 0) + { + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.RainySongs[Season.Spring].ElementAt(randomNumber); //grab a random song from the spring_rain song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + break; + } + + if (minIndex > this.MasterList.Count) + { + this.Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; + return; + } + int randomIndex = (minIndex + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + } + } + else + { + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.RainySongs[Season.Spring].ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + } + + // play selected song + if (this.CurrentSong != null) + { + this.HasNoMusic = false; + this.Monitor.Log($"Now listening to: {this.CurrentSong.Name} from the music pack located at: {this.CurrentSoundInfo.Directory} while it is a rainy {season} Day. Check the seasons folder for more info"); + this.CurrentSong.Play(); + this.Reset(); + } + } + } + + /// Stop the currently playing sound, if any. + public void StopSound() + { + if (this.CurrentSong == null) + { + //trying to stop a song that doesn't "exist" crashes the game. This prevents that. + return; + } + + if (this.CurrentSoundInfo == null) + { + //if my info class is null, return. Should only be null if the game starts. Pretty sure my code should prevent this. + return; + } + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //reset the wave/sound banks back to the music pack's + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong.Stop(AudioStopOptions.Immediate); //redundant stopping code + this.CurrentSong.Stop(AudioStopOptions.AsAuthored); + Game1.soundBank = this.DefaultSoundbank; //reset the wave/sound to the game's original + Game1.waveBank = this.DefaultWavebank; + this.CurrentSong = null; + } + + /// Reset the game audio to the original settings. + private void Reset() + { + Game1.waveBank = this.DefaultWavebank; + Game1.soundBank = this.DefaultSoundbank; + } + + /// Save the configuration settings. + private void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Music_Expansion_Config.txt"); + string[] text = new string[20]; + text[0] = "Player: Stardew Valley Music Expansion Config. Feel free to edit."; + text[1] = "===================================================================================="; + + text[2] = "Minimum delay time: This is the minimal amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; + text[3] = this.MinSongDelay.ToString(); + + text[4] = "Maximum delay time: This is the maximum amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; + text[5] = this.MaxSongDelay.ToString(); + + text[6] = "Silent rain? Setting this value to false plays the default ambient rain music along side whatever songs are set in rain music. Setting this to true will disable the ambient rain music. It's up to the soundpack creators wither or not they want to mix their music with rain prior to loading it in here."; + text[7] = this.SilentRain.ToString(); + + text[8] = "Seasonal_Music? Setting this value to true will play the seasonal music from the music packs instead of defaulting to the Stardew Valley Soundtrack."; + text[9] = this.PlaySeasonalMusic.ToString(); + + File.WriteAllLines(path, text); + } + + /// Load the configuration settings. + void LoadConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Music_Expansion_Config.txt"); + if (!File.Exists(path)) + { + this.MinSongDelay = 10000; + this.MaxSongDelay = 30000; + this.SilentRain = false; + this.PlaySeasonalMusic = true; + } + else + { + string[] text = File.ReadAllLines(path); + this.MinSongDelay = Convert.ToInt32(text[3]); + this.MaxSongDelay = Convert.ToInt32(text[5]); + this.SilentRain = Convert.ToBoolean(text[7]); + this.PlaySeasonalMusic = Convert.ToBoolean(text[9]); + } + } + } +} diff --git a/GeneralMods/StardewSymphony/StardewSymphony.csproj b/GeneralMods/StardewSymphony/StardewSymphony.csproj index bed73026..14be478a 100644 --- a/GeneralMods/StardewSymphony/StardewSymphony.csproj +++ b/GeneralMods/StardewSymphony/StardewSymphony.csproj @@ -34,18 +34,21 @@ - - - + + Properties\GlobalAssemblyInfo.cs + + + + + - - + diff --git a/GeneralMods/StardewSymphony/manifest.json b/GeneralMods/StardewSymphony/manifest.json index deb898c9..ca2e1844 100644 --- a/GeneralMods/StardewSymphony/manifest.json +++ b/GeneralMods/StardewSymphony/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "StardewSymphony", "PerSaveConfigs": false, "EntryDll": "StardewSymphony.dll" -} \ No newline at end of file +} diff --git a/GeneralMods/TimeFreeze/Class1.cs b/GeneralMods/TimeFreeze/Class1.cs deleted file mode 100644 index 394f7bf2..00000000 --- a/GeneralMods/TimeFreeze/Class1.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.IO; -using StardewModdingAPI; -using StardewValley; - -namespace Omegasis.TimeFreeze -{ - public class Class1 :Mod - { - string doVanillaCheck; //used to check for bathing in just the default BathHouse - string doBathingCheck; //used to check if time passes while bathing. - public override void Entry(IModHelper helper) - { - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; - DataLoader(); //used to load/write to the config. - } - - private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsCurrentLocationChanged e) - { - // Game1.showGlobalMessage(Game1.player.currentLocation.name); - } - - private void GameEvents_UpdateTick(object sender, EventArgs e) - { - if (Game1.player == null || Game1.player.currentLocation == null) return; - //if the player isn't bathing and the location is inside. - - if (doBathingCheck == "True") - { - if (doVanillaCheck == "True") - { - - if ((Game1.player.swimming == false && (Game1.player.currentLocation) as StardewValley.Locations.BathHousePool == null) && Game1.player.currentLocation.isOutdoors == false) - { - if (!doesTimePassHere()) - { - Game1.gameTimeInterval = 0; - } - } - } - else - { - if (Game1.player.swimming == false && Game1.player.currentLocation.isOutdoors == false) - { - if (!doesTimePassHere()) - { - Game1.gameTimeInterval = 0; - } - } - } - } - else - { - if (Game1.player.currentLocation.isOutdoors == false) - { - if (!doesTimePassHere()) - { - Game1.gameTimeInterval = 0; - } - } - } - } - - - public bool doesTimePassHere() - { - if (Game1.player.currentLocation.name == "Mine" || Game1.player.currentLocation.name == "SkullCave" || Game1.player.currentLocation.name=="UndergroundMine") return true; - return false; - } - - void MyWritter() - { - string mylocation = Path.Combine(Helper.DirectoryPath, "ModConfig.txt"); - string[] mystring3 = new string[6]; - if (!File.Exists(mylocation)) - { - mystring3[0] = "Player: TimeFreeze Config"; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Unfreeze time in only vanilla bathhouse: True means that time will pass when the player is bathing when in the bathhouse. False means that time will pass when the player is swimming indoors. Use this to rebalance some custom maps."; - mystring3[3] = doVanillaCheck.ToString(); - mystring3[4] = "Does time pass while bathing? True means yes, no means that time is still frozen while bathing indoors."; - mystring3[5] = doVanillaCheck.ToString(); - File.WriteAllLines(mylocation, mystring3); - } - else - { - mystring3[0] = "Player: TimeFreeze Config"; - mystring3[1] = "===================================================================================="; - mystring3[2] = "Unfreeze time in only vanilla bathhouse: True means that time will pass when the player is bathing when in the bathhouse. False means that time will pass when the player is swimming indoors. Use this to rebalance some custom maps."; - mystring3[3] = "True"; - mystring3[4] = "Does time pass while bathing? True means yes, no means that time is still frozen while bathing indoors."; - mystring3[5] = doVanillaCheck.ToString(); - File.WriteAllLines(mylocation, mystring3); - } - } - void DataLoader() - { - string mylocation = Path.Combine(Helper.DirectoryPath, "ModConfig.txt"); - if (!File.Exists(mylocation)) - { - doVanillaCheck = "True"; - doBathingCheck = "True"; - MyWritter(); - } - else - { - string[] readtext = File.ReadAllLines(mylocation); - doVanillaCheck = readtext[3]; - doBathingCheck=readtext[5]; - } - } - } -} diff --git a/GeneralMods/TimeFreeze/Properties/AssemblyInfo.cs b/GeneralMods/TimeFreeze/Properties/AssemblyInfo.cs index b2871223..ffadf2b8 100644 --- a/GeneralMods/TimeFreeze/Properties/AssemblyInfo.cs +++ b/GeneralMods/TimeFreeze/Properties/AssemblyInfo.cs @@ -1,36 +1,7 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("TimeFreeze")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TimeFreeze")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("07410bc3-9b33-40e9-a2ef-b8edf983f0a3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/TimeFreeze/README.md b/GeneralMods/TimeFreeze/README.md new file mode 100644 index 00000000..790b788a --- /dev/null +++ b/GeneralMods/TimeFreeze/README.md @@ -0,0 +1,17 @@ +**Time Freeze** is a [Stardew Valley](http://stardewvalley.net/) mod which freezes time while +indoors. It configurably lets time pass while bathing. + +Compatible with Stardew Valley 1.2+ on Linux, Mac, and Windows. + +## Installation +1. [Install the latest version of SMAPI](https://github.com/Pathoschild/SMAPI/releases). +2. Install [this mod from Nexus mods](http://www.nexusmods.com/stardewvalley/mods/973). +3. Run the game using SMAPI. + +## Usage +Time will be frozen automatically when you're indoors. Time will unfreeze by default if you swim, +but you can edit `ModConfig.txt` to change that. + +## Versions +1.0: +* Initial release. diff --git a/GeneralMods/TimeFreeze/ReadMe.txt b/GeneralMods/TimeFreeze/ReadMe.txt deleted file mode 100644 index f65f488a..00000000 --- a/GeneralMods/TimeFreeze/ReadMe.txt +++ /dev/null @@ -1,8 +0,0 @@ -TimeFreeze - -Version 1.0.0 Windows/Mac/Linux - -Created: 3/2/17 6:07 P.M -Updated: 3/2/17 6:07 P.M - -Description: Freezes the passage of time while indoors with some extra config options for balancing and play style. \ No newline at end of file diff --git a/GeneralMods/TimeFreeze/TimeFreeze.cs b/GeneralMods/TimeFreeze/TimeFreeze.cs new file mode 100644 index 00000000..40fe4a6a --- /dev/null +++ b/GeneralMods/TimeFreeze/TimeFreeze.cs @@ -0,0 +1,98 @@ +using System; +using System.IO; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; +using StardewValley.Locations; + +namespace Omegasis.TimeFreeze +{ + /// The mod entry point. + public class TimeFreeze : Mod + { + /********* + ** Properties + *********/ + /// Whether time should be unfrozen while the player is swimming. + private bool PassTimeWhileSwimming = true; + + /// Whether time should be unfrozen while the player is swimming in the vanilla bathhouse. + private bool PassTimeWhileSwimmingInBathhouse = true; + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + this.LoadConfig(); + } + + /********* + ** Private methods + *********/ + /// 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) + { + if (Game1.player == null || Game1.player.currentLocation == null) + return; + + if (this.ShouldFreezeTime(Game1.player, Game1.player.currentLocation)) + Game1.gameTimeInterval = 0; + } + + /// Get whether time should be frozen for the player at the given location. + /// The player to check. + /// The location to check. + private bool ShouldFreezeTime(StardewValley.Farmer player, GameLocation location) + { + if (location.name == "Mine" || location.name == "SkullCave" || location.name == "UndergroundMine" || location.isOutdoors) + return false; + if (player.swimming) + { + if (this.PassTimeWhileSwimmingInBathhouse && location is BathHousePool) + return false; + if (this.PassTimeWhileSwimming) + return false; + } + return true; + } + + /// Save the configuration settings. + private void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "ModConfig.txt"); + string[] text = new string[6]; + text[0] = "Player: TimeFreeze Config"; + text[1] = "===================================================================================="; + text[2] = "Whether to unfreeze time while swimming in the vanilla bathhouse."; + text[3] = this.PassTimeWhileSwimmingInBathhouse.ToString(); + text[4] = "Whether to unfreeze time while swimming anywhere."; + text[5] = this.PassTimeWhileSwimming.ToString(); + File.WriteAllLines(path, text); + } + + /// Load the configuration settings. + private void LoadConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "ModConfig.txt"); + if (!File.Exists(path)) + { + this.PassTimeWhileSwimming = true; + this.PassTimeWhileSwimmingInBathhouse = true; + this.WriteConfig(); + } + else + { + string[] text = File.ReadAllLines(path); + this.PassTimeWhileSwimming = Convert.ToBoolean(text[3]); + this.PassTimeWhileSwimmingInBathhouse = Convert.ToBoolean(text[5]); + } + } + } +} diff --git a/GeneralMods/TimeFreeze/TimeFreeze.csproj b/GeneralMods/TimeFreeze/TimeFreeze.csproj index 1c15b109..56f71209 100644 --- a/GeneralMods/TimeFreeze/TimeFreeze.csproj +++ b/GeneralMods/TimeFreeze/TimeFreeze.csproj @@ -34,7 +34,10 @@ - + + Properties\GlobalAssemblyInfo.cs + + @@ -42,7 +45,7 @@ - + diff --git a/GeneralMods/TimeFreeze/manifest.json b/GeneralMods/TimeFreeze/manifest.json index d76bacbc..9e428138 100644 --- a/GeneralMods/TimeFreeze/manifest.json +++ b/GeneralMods/TimeFreeze/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "4108e859-333c-4fec-a1a7-d2e18c1019fe", "PerSaveConfigs": false, "EntryDll": "TimeFreeze.dll" -} \ No newline at end of file +} diff --git a/OmegasisCore.7z b/OmegasisCore.7z deleted file mode 100644 index 54185767..00000000 Binary files a/OmegasisCore.7z and /dev/null differ diff --git a/README.md b/README.md index 30d41a79..d7ab8eab 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,80 @@ -TODO: Rewrite this readme because I goofed up and put the wrong one here... +This repository contains my SMAPI mods for Stardew Valley. See the individual mods for +documentation and release notes. -The beginnings of Stardew Valley Revitalize. +## Mods +Active mods: +* **[Auto Speed](http://www.nexusmods.com/stardewvalley/mods/443)** ([source](AutoSpeed)) + _Lets you move faster without the need to enter commands in the console._ -+:add -~:Edit --:Remove +* **[Billboard Anywhere](http://www.nexusmods.com/stardewvalley/mods/492)** ([source](BillboardAnywhere)) + _Lets you look at the billboard anywhere in-game for easy access to upcoming events and birthdays._ -Implemented. +* **[Build Endurance](http://www.nexusmods.com/stardewvalley/mods/445)** ([source](BuildEndurance)) + _Lets you level up your endurance to increase your max stamina as you play._ -0.3.0 2/22/17 -+crops anywhere: Crops can now be placed anywhere where dirt can be tilled. -+Custom Seeds: Now exist in seperate .xnb -~Objects.xnb: Add in new crops -+Crops - +Pink Turnip:Spring - +Blue Charm:Fall -+Farm Swap Menu: Allows the user to have multiple custom farms loaded in without replacing original farm.xnb files, and allows them to choose one. -+Custom Inventory Game Menu: Will allow for more edits of the game menu in the future. Possibly adding in more tabs, and equipment options. -+Gift Packages: Now receive multiple objects from a single item. Good for gifts/rewards/etc. -+Shop Objects: Objects that can be placed in the world, and when interacted with call a shop menu. +* **[Build Health](http://www.nexusmods.com/stardewvalley/mods/446)** ([source](BuildHealth)) + _Lets you level up your endurance to increase your max health as you play._ +* **[Buy Back Collectables](http://www.nexusmods.com/stardewvalley/mods/507)** ([source](BuyBackCollectables)) + _Lets you buy items from the collectables menu by pressing a key, at a configurable markup._ -0.2.0 Alpha 12/30/16 2:52 AM -+Quarry machines. Drills I suppose you could call them? +* **[Daily Quest Anywhere](http://www.nexusmods.com/stardewvalley/mods/513)** ([source](DailyQuestAnywhere)) + _Lets you open the daily quest menu from anywhere in-game._ -0.1.0 Alpha 12/15/16 -+Custom Shop Objects -+Ground work done for new machines -+Customizable lights -+Preset Lighting Class with 100+ different light colors. +* **[Fall 28 Snow Day](http://www.nexusmods.com/stardewvalley/mods/486)** ([source](Fall28SnowDay)) + _Snow falls on the last day of fall._ -Planned: -TBD -More Crops -More Weapons -More Areas? -More Machines: Assembly Lines, Power, Pollution, etc -Verbose Magic System: Runes, More Junimos, Magic Spells/Books, Crystals, Alchemy, Potions -Mail system? Sending mail to npcs for friendship+gifts? +* **[Happy Birthday](http://www.nexusmods.com/stardewvalley/mods/520)** ([source](HappyBirthday)) + _Lets you pick a day for your birthday. On your birthday, you get letters from your parents, and + villagers give you gifts and wish you happy birthday._ + +* **[More Rain](http://www.nexusmods.com/stardewvalley/mods/441)** ([source](MoreRain)) + _Lets you adjust the probability of rain and storms for each season._ + +* **[Museum Rearranger](http://www.nexusmods.com/stardewvalley/mods/428)** ([source](MuseumRearranger)) + _Lets you rearrange donated items in the museum by pressing a key, even if you don't have a new + item to donate._ + +* **[Night Owl](http://www.nexusmods.com/stardewvalley/mods/433)** ([source](NightOwl)) + _Lets you stay up a full 24 hours instead of collapsing at 2am, including a morning light + transition as the sun rises._ + +* **[No More Pets](http://www.nexusmods.com/stardewvalley/mods/506)** ([source](NoMorePets)) + _Removes all pets from the game._ + +* **[Save Anywhere](http://www.nexusmods.com/stardewvalley/mods/444)** ([source](SaveAnywhere)) + _Lets you save your game anywhere by pressing a key._ + +* **[Save Backup](http://www.nexusmods.com/stardewvalley/mods/435)** ([source](SaveBackup)) + _Automatically backs up your save files before you play and every in-game night._ + +* **[Stardew Symphony](http://www.nexusmods.com/stardewvalley/mods/425)** ([source](StardewSymphony)) + _Lets you add music packs to Stardew Valley and play them without editing the game's default + sound files. Music can be conditional on location, season, and weather._ + +* **[Time Freeze](http://www.nexusmods.com/stardewvalley/mods/973)** ([source](TimeFreeze)) + _Freezes time while indoors. Configurably lets time pass while bathing._ + +Inactive mods: +* **Custom Shops Redux GUI** ([source](CustomShopsRedux)) + _In development. Lets you create custom shops by editing text files._ + +## Compiling the mods +Installing stable releases from Nexus Mods is recommended for most users. If you really want to +compile the mod yourself, read on. + +These mods use the [crossplatform build config](https://github.com/Pathoschild/Stardew.ModBuildConfig#readme) +so they can be built on Linux, Mac, and Windows without changes. See [the build config documentation](https://github.com/Pathoschild/Stardew.ModBuildConfig#readme) +for troubleshooting. + +To compile a mod and add it to your game's `Mods` directory: + +1. Rebuild the project in [Visual Studio](https://www.visualstudio.com/vs/community/) or [MonoDevelop](http://www.monodevelop.com/). + This will compile the code and package it into the mod directory. +2. Launch the project with debugging. + This will start the game through SMAPI and attach the Visual Studio debugger. + +To package a mod for release: + +1. Rebuild the project in release mode. +2. The release zips will be generated in the `_releases` folder. diff --git a/Revitalize/README.md b/Revitalize/README.md new file mode 100644 index 00000000..30d41a79 --- /dev/null +++ b/Revitalize/README.md @@ -0,0 +1,40 @@ +TODO: Rewrite this readme because I goofed up and put the wrong one here... + +The beginnings of Stardew Valley Revitalize. + ++:add +~:Edit +-:Remove + +Implemented. + +0.3.0 2/22/17 ++crops anywhere: Crops can now be placed anywhere where dirt can be tilled. ++Custom Seeds: Now exist in seperate .xnb +~Objects.xnb: Add in new crops ++Crops + +Pink Turnip:Spring + +Blue Charm:Fall ++Farm Swap Menu: Allows the user to have multiple custom farms loaded in without replacing original farm.xnb files, and allows them to choose one. ++Custom Inventory Game Menu: Will allow for more edits of the game menu in the future. Possibly adding in more tabs, and equipment options. ++Gift Packages: Now receive multiple objects from a single item. Good for gifts/rewards/etc. ++Shop Objects: Objects that can be placed in the world, and when interacted with call a shop menu. + + +0.2.0 Alpha 12/30/16 2:52 AM ++Quarry machines. Drills I suppose you could call them? + +0.1.0 Alpha 12/15/16 ++Custom Shop Objects ++Ground work done for new machines ++Customizable lights ++Preset Lighting Class with 100+ different light colors. + +Planned: +TBD +More Crops +More Weapons +More Areas? +More Machines: Assembly Lines, Power, Pollution, etc +Verbose Magic System: Runes, More Junimos, Magic Spells/Books, Crystals, Alchemy, Potions +Mail system? Sending mail to npcs for friendship+gifts?