Merge pull request #16 from Pathoschild/refactor

Refactor mod code & add READMEs
This commit is contained in:
janavarro95 2017-08-05 10:02:24 -07:00 committed by GitHub
commit fc7aff3564
148 changed files with 7486 additions and 13440 deletions

View File

@ -1,74 +1,73 @@
using System;
using System.IO;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace Omegasis.AutoSpeed
{
/// <summary>The mod entry point.</summary>
public class AutoSpeed : Mod
{
int speed_int = 5;
/*********
** Properties
*********/
/// <summary>The speed multiplier.</summary>
private int Speed = 5;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
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
*********/
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
{
StardewValley.Game1.player.addedSpeed = speed_int;
Game1.player.addedSpeed = Speed;
}
void DataLoader()
/// <summary>Load the configuration settings.</summary>
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()
/// <summary>Save the configuration settings.</summary>
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
}
}

View File

@ -34,6 +34,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AutoSpeed.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@ -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")]

View File

@ -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.

View File

@ -0,0 +1,88 @@
using System;
using System.IO;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Menus;
namespace Omegasis.BillboardAnywhere
{
/// <summary>The mod entry point.</summary>
public class BillboardAnywhere : Mod
{
/*********
** Properties
*********/
/// <summary>The key which shows the billboard menu.</summary>
private string KeyBinding = "B";
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
}
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
{
this.IsGameLoaded = true;
this.LoadConfig();
}
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
}
}

View File

@ -34,7 +34,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BillboardAnywhere.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@ -42,7 +45,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Readme.txt" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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

View File

@ -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")]

View File

@ -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.

View File

@ -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

View File

@ -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
{
/// <summary>The mod entry point.</summary>
public class BuildEndurance : Mod
{
/*********
** Properties
*********/
/// <summary>The mod settings and player data.</summary>
private ModConfig Config;
/// <summary>Whether the player has been exhausted today.</summary>
private bool WasExhausted;
/// <summary>Whether the player has collapsed today.</summary>
private bool WasCollapsed;
/// <summary>The XP points needed to reach the next endurance level.</summary>
private double ExpToNextLevel = 20;
/// <summary>The player's current endurance XP points.</summary>
private double CurrentExp;
/// <summary>The player's current endurance level.</summary>
private int CurrentLevel;
/// <summary>The stamina points to add to the player's base stamina due to their current endurance level.</summary>
private int CurrentLevelStaminaBonus;
/// <summary>The initial stamina bonus to apply regardless of the player's endurance level, from the config file.</summary>
private int BaseStaminaBonus;
/// <summary>Whether to reset all changes by the mod to the default values (i.e. start over).</summary>
private bool ClearModEffects;
/// <summary>The player's original stamina value, excluding mod effects.</summary>
private int OriginalStamina;
/// <summary>Whether the player recently gained XP for tool use.</summary>
private bool HasRecentToolExp;
/// <summary>Whether the player was eating last time we checked.</summary>
private bool WasEating;
/// <summary>Whether the player has loaded a save.</summary>
private bool IsLoaded;
/// <summary>The player's stamina last time they slept.</summary>
private int NightlyStamina;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
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<ModConfig>(Encoding.UTF8.GetString(File.ReadAllBytes(configPath)));
this.Monitor.Log("Found BuildEndurance config file.");
}
this.Monitor.Log("BuildEndurance Initialization Completed");
}
/// <summary>The method invoked once per second during a game update.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void GameEvents_OneSecondTick(object sender, EventArgs e)
{
// nerf how quickly tool xp is gained (I hope)
if (this.HasRecentToolExp)
this.HasRecentToolExp = false;
}
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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!");
}
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
/// <summary>The method invoked when <see cref="Game1.dayOfMonth"/> changes.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
/// <summary>Update the settings needed for <see cref="ClearModEffects"/> from the latest config file on disk.</summary>
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]);
}
}
/// <summary>Update <see cref="ClearModEffects"/> based on the latest config file on disk.</summary>
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]);
}
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
}
}

View File

@ -32,17 +32,23 @@
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BuildEndurance.cs" />
<Compile Include="Framework\ModConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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<Config>(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
}

View File

@ -0,0 +1,45 @@
namespace Omegasis.BuildEndurance.Framework
{
/// <summary>The mod settings and player data.</summary>
internal class ModConfig
{
/// <summary>The XP points needed to reach the next endurance level.</summary>
public double ExpToNextLevel { get; set; }
/// <summary>The player's current endurance XP points.</summary>
public double CurrentExp { get; set; }
/// <summary>The player's current endurance level.</summary>
public int CurrentLevel { get; set; }
/// <summary>The initial stamina bonus to apply regardless of the player's endurance level.</summary>
public int BaseStaminaBonus { get; set; }
/// <summary>The stamina points to add to the player's base stamina due to their current endurance level.</summary>
public int CurrentLevelStaminaBonus { get; set; }
/// <summary>The multiplier for the experience points to need to reach an endurance level relative to the previous one.</summary>
public double ExpCurve { get; set; }
/// <summary>The maximum endurance level the player can reach.</summary>
public int MaxLevel { get; set; }
/// <summary>The amount of stamina the player should gain for each endurance level.</summary>
public int StaminaIncreasePerLevel { get; set; }
/// <summary>The experience points to gain for using a tool.</summary>
public int ExpForToolUse { get; set; }
/// <summary>The experience points to gain for eating or drinking.</summary>
public int ExpForEating { get; set; }
/// <summary>The experience points to gain for sleeping.</summary>
public int ExpForSleeping { get; set; }
/// <summary>The experience points to gain for reaching a state of exhaustion for the day.</summary>
public int ExpForExhaustion { get; set; }
/// <summary>The experience points to gain for collapsing for the day.</summary>
public int ExpForCollapsing { get; set; }
}
}

View File

@ -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")]

View File

@ -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.

View File

@ -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
{
/// <summary>The mod entry point.</summary>
public class BuildHealth : Mod
{
/*********
** Properties
*********/
/// <summary>The mod settings and player data.</summary>
private ModConfig Config;
/// <summary>The XP points needed to reach the next level.</summary>
private double ExpToNextLevel = 20;
/// <summary>The player's current XP points.</summary>
private double CurrentExp;
/// <summary>The player's current level.</summary>
private int CurrentLevel;
/// <summary>The health points to add to the player's base health due to their current level.</summary>
private int CurrentLevelHealthBonus;
/// <summary>The initial health bonus to apply regardless of the player's level, from the config file.</summary>
private int BaseHealthBonus;
/// <summary>Whether to reset all changes by the mod to the default values (i.e. start over).</summary>
private bool ClearModEffects;
/// <summary>The player's original max health value, excluding mod effects.</summary>
private int OriginalMaxHealth;
/// <summary>Whether the player recently gained XP for tool use.</summary>
private bool HasRecentToolExp;
/// <summary>Whether the player was eating last time we checked.</summary>
private bool WasEating;
/// <summary>The player's health last time we checked it.</summary>
private int LastHealth;
/// <summary>Whether the player has loaded a save.</summary>
private bool IsLoaded;
/// <summary>Whether the player has collapsed today.</summary>
private bool WasCollapsed;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
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<ModConfig>(Encoding.UTF8.GetString(File.ReadAllBytes(configPath)));
this.Monitor.Log("Found BuildHealth config file.");
}
this.Monitor.Log("BuildHealth Initialization Completed");
}
/// <summary>The method invoked once per second during a game update.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void GameEvents_OneSecondTick(object sender, EventArgs e)
{
// nerf how quickly tool xp is gained (I hope)
if (this.HasRecentToolExp)
this.HasRecentToolExp = false;
}
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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!");
}
}
/// <summary>The method invoked when <see cref="Game1.dayOfMonth"/> changes.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
/// <summary>Update the settings needed for <see cref="ClearModEffects"/> from the latest config file on disk.</summary>
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]);
}
}
/// <summary>Update <see cref="ClearModEffects"/> based on the latest config file on disk.</summary>
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]);
}
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
}
}

View File

@ -32,18 +32,23 @@
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BuildHealth.cs" />
<Compile Include="Framework\ModConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
<None Include="ReadMe.md" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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<Config>(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
}

View File

@ -0,0 +1,42 @@
namespace Omegasis.BuildHealth.Framework
{
/// <summary>The mod settings and player data.</summary>
internal class ModConfig
{
/// <summary>The XP points needed to reach the next level.</summary>
public double ExpToNextLevel { get; set; }
/// <summary>The player's current XP points.</summary>
public double CurrentExp { get; set; }
/// <summary>The player's current level.</summary>
public int CurrentLevel { get; set; }
/// <summary>The initial health bonus to apply regardless of the player's level, from the config file.</summary>
public int BaseHealthBonus { get; set; }
/// <summary>The health points to add to the player's base health due to their current level.</summary>
public int CurrentLevelHealthBonus { get; set; }
/// <summary>The multiplier for the experience points to need to reach an endurance level relative to the previous one.</summary>
public double ExpCurve { get; set; }
/// <summary>The maximum endurance level the player can reach.</summary>
public int MaxLevel { get; set; }
/// <summary>The amount of stamina the player should gain for each endurance level.</summary>
public int HealthIncreasePerLevel { get; set; }
/// <summary>The experience points to gain for using a tool.</summary>
public int ExpForToolUse { get; set; }
/// <summary>The experience points to gain for eating or drinking.</summary>
public int ExpForEating { get; set; }
/// <summary>The experience points to gain for sleeping.</summary>
public int ExpForSleeping { get; set; }
/// <summary>The experience points to gain for collapsing for the day.</summary>
public int ExpForCollapsing { get; set; }
}
}

View File

@ -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")]

View File

@ -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.

View File

@ -0,0 +1,96 @@
using System;
using System.IO;
using Omegasis.BuyBackCollectables.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace Omegasis.BuyBackCollectables
{
/// <summary>The mod entry point.</summary>
public class BuyBackCollectables : Mod
{
/*********
** Properties
*********/
/// <summary>The key which shows the menu.</summary>
private string KeyBinding = "B";
/// <summary>The multiplier applied to the cost of buying back a collectable.</summary>
private double CostMultiplier = 3.0;
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
}
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void SaveEvents_AfterLoad(object sender, EventArgs e)
{
this.IsGameLoaded = true;
this.LoadConfig();
this.WriteConfig();
}
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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);
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
}
}

View File

@ -34,17 +34,19 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Collections_Buy_Back.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BuyBackCollectables.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UpdatedCollections.cs" />
<Compile Include="Framework\BuyBackMenu.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="ReadMe.txt" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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<String> 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<string>();
}
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

View File

@ -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<ClickableTextureComponent> sideTabs = new List<ClickableTextureComponent>();
public int currentTab;
public int currentPage;
public Dictionary<int, List<List<ClickableTextureComponent>>> collections = new Dictionary<int, List<List<ClickableTextureComponent>>>();
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<ClickableTextureComponent>()];
int num = this.xPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearSideBorder;
int num2 = this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 4;
int num3 = 10;
foreach (KeyValuePair<int, string> 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<char>() - 3).Equals("-2"))
{
num4 = 3;
if (Game1.player.mineralsFound.ContainsKey(current.Key))
{
flag = true;
}
}
else if (text.Contains("Cooking") || text.Substring(text.Count<char>() - 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<char>() - 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<ClickableTextureComponent>());
array[num4] = 0;
x2 = num;
num5 = num2;
}
if (this.collections[num4].Count<List<ClickableTextureComponent>>() == 0)
{
this.collections[num4].Add(new List<ClickableTextureComponent>());
}
this.collections[num4].Last<List<ClickableTextureComponent>>().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<List<ClickableTextureComponent>>() == 0)
{
this.collections[5].Add(new List<ClickableTextureComponent>());
}
foreach (KeyValuePair<int, string> 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<List<ClickableTextureComponent>>() - 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<int, string> 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<char>() - 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<List<ClickableTextureComponent>>() - 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);
}
}
}
}

View File

@ -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
{
/// <summary>The clickable menu which lets the player buy back collectables.</summary>
internal class BuyBackMenu : IClickableMenu
{
/*********
** Properties
*********/
/// <summary>The organics tab ID.</summary>
private const int OrganicsTab = 0;
/// <summary>The fish tab ID.</summary>
private const int FishTab = 1;
/// <summary>The archaeology tab ID.</summary>
private const int ArchaeologyTab = 2;
/// <summary>The minerals tab ID.</summary>
private const int MineralsTab = 3;
/// <summary>The cooking tab ID.</summary>
private const int CookingTab = 4;
/// <summary>The achievements tab ID.</summary>
private const int AchievementsTab = 5;
/// <summary>The offset to apply to the selected tab.</summary>
private readonly int WidthToMoveActiveTab = Game1.tileSize / 8;
/// <summary>The multiplier applied to the cost of buying back a collectable.</summary>
private readonly double CostMultiplier;
/// <summary>The back button.</summary>
private readonly ClickableTextureComponent BackButton;
/// <summary>The forward button.</summary>
private readonly ClickableTextureComponent ForwardButton;
/// <summary>The category tabs shown along the side.</summary>
private readonly List<ClickableTextureComponent> SideTabs = new List<ClickableTextureComponent>();
/// <summary>The text to display in a hover tooltip.</summary>
private string HoverText = "";
/// <summary>The selected tab.</summary>
private int CurrentTab;
/// <summary>The selected page.</summary>
private int CurrentPage;
/// <summary>The buttons to show for each tab.</summary>
private readonly Dictionary<int, List<List<ClickableTextureComponent>>> Collections = new Dictionary<int, List<List<ClickableTextureComponent>>>();
/// <summary>The cost to buy back the selected item.</summary>
private int Value;
/// <summary>The selected item.</summary>
public Item NewItem;
/// <summary>The cost to buy back the selected item.</summary>
public int NewItemValue;
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="costMultiplier">The multiplier applied to the cost of buying back a collectable.</param>
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<int, string> 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<ClickableTextureComponent>());
array[selectedTab] = 0;
x2 = num;
num5 = num2;
}
if (this.Collections[selectedTab].Count == 0)
this.Collections[selectedTab].Add(new List<ClickableTextureComponent>());
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<ClickableTextureComponent>());
foreach (KeyValuePair<int, string> 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
*********/
/// <summary>Get whether the farmer has the given achievements.</summary>
/// <param name="listOfAchievementNumbers">The achievement IDs as a space-separated list.</param>
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;
}
/// <summary>The method invoked when the player left-clicks on the menu.</summary>
/// <param name="x">The X-position of the cursor.</param>
/// <param name="y">The Y-position of the cursor.</param>
/// <param name="playSound">Whether to enable sound.</param>
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);
}
}
}
/// <summary>The method invoked when the player right-clicks on the lookup UI.</summary>
/// <param name="x">The X-position of the cursor.</param>
/// <param name="y">The Y-position of the cursor.</param>
/// <param name="playSound">Whether to enable sound.</param>
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);
}
}
/// <summary>The method invoked when the player hovers the cursor over the menu.</summary>
/// <param name="x">The X-position of the cursor.</param>
/// <param name="y">The Y-position of the cursor.</param>
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);
}
/// <summary>Generate the item description for an item ID.</summary>
/// <param name="index">The item ID.</param>
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<int, string> 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;
}
/// <summary>Draw the menu to the screen.</summary>
/// <param name="b">The sprite batch.</param>
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);
}
}
}

View File

@ -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")]

View File

@ -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.

View File

@ -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.

View File

@ -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<ClickableTextureComponent> sideTabs = new List<ClickableTextureComponent>();
private int currentTab;
private int currentPage;
private Dictionary<int, List<List<ClickableTextureComponent>>> collections = new Dictionary<int, List<List<ClickableTextureComponent>>>();
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<List<ClickableTextureComponent>>());
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<int, string> 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<ClickableTextureComponent>());
array[num4] = 0;
x2 = num;
num5 = num2;
}
if (this.collections[num4].Count == 0)
{
this.collections[num4].Add(new List<ClickableTextureComponent>());
}
this.collections[num4].Last<List<ClickableTextureComponent>>().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<ClickableTextureComponent>());
}
foreach (KeyValuePair<int, string> 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<int, string> 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<ClickableTextureComponent>.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);
}
}
}
}

View File

@ -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<Item, int[]> list_price = new Dictionary<Item, int[]>();
static string master_path;
List<string> myoptions = new List<string>();
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<Item> list = new List<Item>();
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<Item> list = new List<Item>();
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<Item> list = new List<Item>();
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<Item> myshop()
{
List<Item> list = new List<Item>();
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

View File

@ -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
{
/// <summary>The mod entry point.</summary>
public class CustomShopsRedux : Mod
{
/*********
** Properties
*********/
/// <summary>The prices for the items to list.</summary>
private readonly Dictionary<Item, int[]> ListPrices = new Dictionary<Item, int[]>();
/// <summary>The folder path containing shop data files.</summary>
private string DataPath;
/// <summary>The configured shop options.</summary>
private readonly List<string> Options = new List<string>();
/// <summary>The key which shows the menu.</summary>
private string KeyBinding = "U";
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="args">The mod arguments.</param>
public override void Entry(params object[] args)
{
PlayerEvents.LoadedGame += this.PlayerEvents_LoadedGame;
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
}
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void PlayerEvents_LoadedGame(object sender, EventArgsLoadedGameChanged e)
{
this.IsGameLoaded = true;
this.LoadConfig();
this.WriteConfig();
}
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
/// <summary>Open the menu which lets the player choose a file.</summary>
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);
}
/// <summary>The method called when the player chooses an option from the file list.</summary>
/// <param name="filename">The selected file name.</param>
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<Item> list = new List<Item>();
// 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<Item> list = new List<Item>();
// 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<Item> MyShop()
//{
// List<Item> list = new List<Item>();
// 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;
//}
}
}

View File

@ -34,20 +34,27 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="CustomShopsRedux.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Custom_Shops\My_Streaming_Shop.txt" />
<Content Include="Custom_Shops\Test_Shop_1.txt" />
<Content Include="Custom_Shops\Test_Shop_2.txt" />
<Content Include="Custom_Shop_Redux_Config.txt" />
<Content Include="Mod_readme.txt" />
<Content Include="Custom_Shops\My_Streaming_Shop.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Custom_Shops\Test_Shop_1.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Custom_Shops\Test_Shop_2.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
<None Include="ReadMe.md" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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

View File

@ -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!

View File

@ -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")]

View File

@ -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. <s>Install this mod from Nexus mods</s> (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.

View File

@ -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

View File

@ -0,0 +1,87 @@
using System;
using System.IO;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Menus;
namespace Omegasis.DailyQuestAnywhere
{
/// <summary>The mod entry point.</summary>
public class DailyQuestAnywhere : Mod
{
/*********
** Properties
*********/
/// <summary>The key which shows the menu.</summary>
private string KeyBinding = "H";
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
}
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
{
this.IsGameLoaded = true;
this.LoadConfig();
this.WriteConfig();
}
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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);
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
}
}

View File

@ -34,7 +34,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="DailyQuestAnywhere.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@ -42,7 +45,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="ReadMe.txt" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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")]

View File

@ -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.

View File

@ -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

View File

@ -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;
}
}
}
}

View File

@ -0,0 +1,33 @@
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace Omegasis.Fall28SnowDay
{
/// <summary>The mod entry point.</summary>
public class Fall28SnowDay : Mod
{
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged;
}
/*********
** Private methods
*********/
/// <summary>The method invoked when <see cref="Game1.dayOfMonth"/> changes.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e)
{
if (Game1.dayOfMonth == 27 && Game1.IsFall)
Game1.weatherForTomorrow = Game1.weather_snow;
}
}
}

View File

@ -34,7 +34,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Fall28SnowDay.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@ -42,7 +45,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Readme.txt" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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")]

View File

@ -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.

View File

@ -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.

View File

@ -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)]

View File

@ -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<int> shirtOptions;
public List<int> hairStyleOptions;
public List<int> accessoryOptions;
public int currentShirt;
public int currentHair;
public int currentAccessory;
public int colorPickerTimer;
public ColorPicker pantsColorPicker;
public ColorPicker hairColorPicker;
public ColorPicker eyeColorPicker;
public List<ClickableComponent> labels = new List<ClickableComponent>();
public List<ClickableComponent> seasonButtons = new List<ClickableComponent>();
public List<ClickableComponent> seasonTitleButtons = new List<ClickableComponent>();
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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<ClickableComponent>.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<ClickableComponent>.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<char>((IEnumerable<char>)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);
}
}
}

View File

@ -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<string> npc_name_list;
bool game_loaded;
public string key_binding= "O";
public List<Item> possible_birthday_gifts;
public Item birthday_gift_to_receive;
bool once;
bool has_input_birthday;
public static IMonitor thisMonitor;
Dictionary<string, Dialogue> 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<string>();
possible_birthday_gifts = new List<Item>();
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<string, Dialogue>();
}
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<Dictionary<string, string>>("Data\\FarmerBirthdayDialogue")[npc.name], npc);
npc.CurrentDialogue.Push(d);
if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(Game1.content.Load<Dictionary<string, string>>("Data\\FarmerBirthdayDialogue")[npc.name]);
}
// npc.setNewDialogue(Game1.content.Load<Dictionary<string, string>>("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<string,Dialogue> 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<Dictionary<string, string>>("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<string, string> dictionary = null;
try
{
dictionary = Game1.content.Load<Dictionary<string, string>>("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<string>(); 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<StardewValley.Object> 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<string>(); 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<StardewValley.Object> 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<string>(); 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<StardewValley.Object> 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<string>(); i++)
{
int parentSheetIndex = Convert.ToInt32(array[i]);
if (parentSheetIndex < 0)
{
List<StardewValley.Object> 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<string, string> dictionary = Game1.content.Load<Dictionary<string, string>>("Data\\PossibleBirthdayGifts");
string text2;
dictionary.TryGetValue("Universal_Neutral_Gift", out text2);
string[] array = text2.Split(new char[]
{
' '
});
for (int i = 0; i < array.Count<string>(); i += 2)
{
int parentSheetIndex = Convert.ToInt32(array[i]);
if (parentSheetIndex < 0)
{
List<StardewValley.Object> 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<string>(); i++)
{
int parentSheetIndex = Convert.ToInt32(array[i]);
if (parentSheetIndex < 0)
{
List<StardewValley.Object> 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<string, string> dictionary = Game1.content.Load<Dictionary<string, string>>("Data\\PossibleBirthdayGifts");
string text2;
dictionary.TryGetValue("Universal_Like_Gift", out text2);
string[] array = text2.Split(new char[]
{
' '
});
for (int i = 0; i < array.Count<string>(); i += 2)
{
int parentSheetIndex = Convert.ToInt32(array[i]);
if (parentSheetIndex < 0)
{
List<StardewValley.Object> 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<string>(); i++)
{
int parentSheetIndex = Convert.ToInt32(array[i]);
if (parentSheetIndex < 0)
{
List<StardewValley.Object> 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<string, string> dictionary = Game1.content.Load<Dictionary<string, string>>("Data\\PossibleBirthdayGifts");
string text2;
dictionary.TryGetValue("Universal_Love_Gift", out text2);
string[] array = text2.Split(new char[]
{
' '
});
for (int i = 0; i < array.Count<string>(); i += 2)
{
int parentSheetIndex = Convert.ToInt32(array[i]);
if (parentSheetIndex < 0)
{
List<StardewValley.Object> 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<string>(); i++)
{
int parentSheetIndex = Convert.ToInt32(array2[i]);
if (parentSheetIndex < 0)
{
List<StardewValley.Object> 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<string>(); i++)
{
int parentSheetIndex = Convert.ToInt32(array2[i]);
if (parentSheetIndex < 0)
{
List<StardewValley.Object> 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);
}
}
}
}

View File

@ -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
{
/// <summary>The menu which lets the player choose their birthday.</summary>
internal class BirthdayMenu : IClickableMenu
{
/*********
** Properties
*********/
/// <summary>The labels to draw.</summary>
private readonly List<ClickableComponent> Labels = new List<ClickableComponent>();
/// <summary>The season buttons to draw.</summary>
private readonly List<ClickableTextureComponent> SeasonButtons = new List<ClickableTextureComponent>();
/// <summary>The day buttons to draw.</summary>
private readonly List<ClickableTextureComponent> DayButtons = new List<ClickableTextureComponent>();
/// <summary>The OK button to draw.</summary>
private ClickableTextureComponent OkButton;
/// <summary>The player's current birthday season.</summary>
private string BirthdaySeason;
/// <summary>The player's current birthday day.</summary>
private int BirthdayDay;
/// <summary>The callback to invoke when the birthday value changes.</summary>
private readonly Action<string, int> OnChanged;
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="season">The initial birthday season.</param>
/// <param name="day">The initial birthday day.</param>
/// <param name="onChanged">The callback to invoke when the birthday value changes.</param>
public BirthdayMenu(string season, int day, Action<string, int> 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();
}
/// <summary>The method called when the game window changes size.</summary>
/// <param name="oldBounds">The former viewport.</param>
/// <param name="newBounds">The new viewport.</param>
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
*********/
/// <summary>Regenerate the UI.</summary>
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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("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<Texture2D>("LooseSprites\\font_bold"), new Rectangle(64, 16, 8, 12), Game1.pixelZoom));
}
/// <summary>Handle a button click.</summary>
/// <param name="name">The button name that was clicked.</param>
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");
}
/// <summary>The method invoked when the player left-clicks on the menu.</summary>
/// <param name="x">The X-position of the cursor.</param>
/// <param name="y">The Y-position of the cursor.</param>
/// <param name="playSound">Whether to enable sound.</param>
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);
}
}
/// <summary>The method invoked when the player right-clicks on the lookup UI.</summary>
/// <param name="x">The X-position of the cursor.</param>
/// <param name="y">The Y-position of the cursor.</param>
/// <param name="playSound">Whether to enable sound.</param>
public override void receiveRightClick(int x, int y, bool playSound = true) { }
/// <summary>The method invoked when the player hovers the cursor over the menu.</summary>
/// <param name="x">The X-position of the cursor.</param>
/// <param name="y">The Y-position of the cursor.</param>
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);
}
/// <summary>Draw the menu to the screen.</summary>
/// <param name="b">The sprite batch.</param>
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);
}
}
}

View File

@ -0,0 +1,28 @@
using StardewValley;
namespace Omegasis.HappyBirthday.Framework
{
/// <summary>Provides utility methods for displaying messages to the user.</summary>
internal class Messages
{
/*********
** Public methods
*********/
/// <summary>Show a message to the user with a star icon.</summary>
/// <param name="message">The message to display.</param>
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);
}
}
}
}

View File

@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Linq;
using StardewValley;
using Object = StardewValley.Object;
namespace Omegasis.HappyBirthday.Framework
{
/// <summary>Provides utility methods for managing in-game objects.</summary>
internal class ObjectUtility
{
/*********
** Properties
*********/
/// <summary>The cached object data.</summary>
private static readonly Object[] ObjectList = ObjectUtility.GetAllObjects().ToArray();
/*********
** Public methods
*********/
/// <summary>Get objects with the given category.</summary>
/// <param name="category">The category for which to find objects.</param>
public static IEnumerable<Object> GetObjectsInCategory(int category)
{
if (category > 0)
yield break;
foreach (Object obj in ObjectUtility.ObjectList)
{
if (obj.category == category)
yield return obj;
}
}
/*********
** Private methods
*********/
/// <summary>Get all objects defined by the game.</summary>
private static IEnumerable<Object> GetAllObjects()
{
foreach (int key in Game1.content.Load<Dictionary<int, string>>("Data\\ObjectInformation").Keys)
yield return new Object(key, 1);
}
}
}

View File

@ -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
{
/// <summary>The mod entry point.</summary>
public class HappyBirthday : Mod
{
/*********
** Properties
*********/
/// <summary>The key which shows the menu.</summary>
private string KeyBinding = "O";
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/// <summary>Whether the player has chosen a birthday.</summary>
private bool HasChosenBirthday;
/// <summary>The queue of villagers who haven't given a gift yet.</summary>
private List<string> VillagerQueue;
/// <summary>The gifts that villagers can give.</summary>
private List<Item> PossibleBirthdayGifts;
/// <summary>The next birthday gift the player will receive.</summary>
private Item BirthdayGiftToReceive;
/// <summary>Whether we've already checked for and (if applicable) set up the player's birthday today.</summary>
private bool CheckedForBirthday;
//private Dictionary<string, Dialogue> Dialogue;
//private bool SeenEvent;
/// <summary>The name of the folder containing birthday data files.</summary>
private readonly string FolderName = "Player_Birthdays";
/// <summary>The full path to the folder containing birthday data files.</summary>
private string BirthdayFolderPath;
/// <summary>The player's current birthday day.</summary>
public int BirthdayDay;
/// <summary>The player's current birthday season.</summary>
public string BirthdaySeason;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
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<string>();
this.PossibleBirthdayGifts = new List<Item>();
this.BirthdayFolderPath = Path.Combine(Helper.DirectoryPath, this.FolderName);
if (!Directory.Exists(this.BirthdayFolderPath))
Directory.CreateDirectory(this.BirthdayFolderPath);
}
/*********
** Private methods
*********/
/// <summary>The method invoked when <see cref="Game1.dayOfMonth"/> changes.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e)
{
if (Game1.player == null)
return;
if (this.HasChosenBirthday)
this.WriteBirthday();
this.WriteConfig();
this.CheckedForBirthday = false;
}
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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);
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
{
this.IsGameLoaded = true;
this.LoadBirthday();
this.LoadConfig();
//this.SeenEvent = false;
//this.Dialogue = new Dictionary<string, Dialogue>();
}
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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<Dictionary<string, string>>("Data\\FarmerBirthdayDialogue")[npc.name], npc);
npc.CurrentDialogue.Push(d);
if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(Game1.content.Load<Dictionary<string, string>>("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<string, Dialogue> 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;
}
}
/// <summary>Set the player's birtday/</summary>
/// <param name="season">The birthday season.</param>
/// <param name="day">The birthday day.</param>
private void SetBirthday(string season, int day)
{
this.BirthdaySeason = season;
this.BirthdayDay = day;
}
/// <summary>Reset the queue of villager names.</summary>
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);
}
}
}
/// <summary>Set the next birthday gift the player will receive.</summary>
/// <param name="name">The villager's name who's giving the gift.</param>
/// <remarks>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.</remarks>
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();
}
/// <summary>Get the default gift items.</summary>
/// <param name="name">The villager's name.</param>
private IEnumerable<SObject> GetDefaultBirthdayGifts(string name)
{
List<SObject> gifts = new List<SObject>();
try
{
// read from birthday gifts file
IDictionary<string, string> data = Game1.content.Load<Dictionary<string, string>>("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;
}
/// <summary>Get the items loved by all villagers.</summary>
/// <param name="group">The group to get (one of <c>Like</c>, <c>Love</c>, <c>Neutral</c>).</param>
/// <param name="isBirthdayGiftList">Whether to get data from <c>Data\PossibleBirthdayGifts.xnb</c> instead of the game data.</param>
private IEnumerable<SObject> 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<string, string> data = Game1.content.Load<Dictionary<string, string>>("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;
}
}
}
/// <summary>Get a villager's loved items.</summary>
/// <param name="name">The villager's name.</param>
private IEnumerable<SObject> 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;
}
}
/// <summary>Get a villager's loved items.</summary>
/// <param name="name">The villager's name.</param>
private IEnumerable<SObject> 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;
}
}
/// <summary>Get the items matching the given ID.</summary>
/// <param name="id">The category or item ID.</param>
private IEnumerable<SObject> GetItems(int id)
{
return id < 0
? ObjectUtility.GetObjectsInCategory(id)
: new[] { new SObject(id, 1) };
}
/// <summary>Get the items matching the given ID.</summary>
/// <param name="id">The category or item ID.</param>
/// <param name="stack">The stack size.</param>
private IEnumerable<SObject> GetItems(int id, int stack)
{
foreach (SObject obj in this.GetItems(id))
yield return new SObject(obj.parentSheetIndex, stack);
}
/// <summary>Get whether today is the player's birthday.</summary>
private bool IsBirthday()
{
return
this.BirthdayDay == Game1.dayOfMonth
&& this.BirthdaySeason == Game1.currentSeason;
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
/// <summary>Load the player's birthday from the config file.</summary>
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]);
}
}
/// <summary>Write the player's birthday to the config file.</summary>
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);
}
}
}

View File

@ -36,21 +36,30 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Birthday_Menu.cs" />
<Compile Include="Class1.cs" />
<Compile Include="OmegasisUtility\Messages.cs" />
<Compile Include="PatchedUtilities\ObjectUtility.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Framework\BirthdayMenu.cs" />
<Compile Include="HappyBirthday.cs" />
<Compile Include="Framework\Messages.cs" />
<Compile Include="Framework\ObjectUtility.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Content\Data\FarmerBirthdayDialogue.xnb" />
<None Include="Content\Data\mail.xnb" />
<None Include="Content\Data\PossibleBirthdayGifts.xnb" />
<None Include="Content\Data\FarmerBirthdayDialogue.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Data\mail.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Data\PossibleBirthdayGifts.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="ReadMe.txt" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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);
}
}
}
}

View File

@ -1,41 +0,0 @@
using System.Collections.Generic;
using StardewValley;
using Object = StardewValley.Object;
namespace Omegasis.HappyBirthday.PatchedUtilities
{
class ObjectUtility
{
public static List<Object> object_list = new List<Object>();
public static void getAllObjects()
{
if (object_list.Count > 0) return;
Dictionary<int, string> my_dic = Game1.content.Load<Dictionary<int, string>>("Data\\ObjectInformation");
foreach (var key in my_dic.Keys)
{
object_list.Add(new Object(key, 1, false, -1, 0));
}
}
public static List<Object> getAllObjectsAssociatedWithCategory(int category_number)
{
getAllObjects();
List<Object> my_obj_list = new List<Object>();
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;
}
}
}

View File

@ -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")]

View File

@ -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.

View File

@ -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

View File

@ -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();
}
}
}
}
}

View File

@ -0,0 +1,293 @@
using System;
using System.Collections.Generic;
using System.IO;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace Omegasis.MoreRain
{
/// <summary>The mod entry point.</summary>
public class MoreRain : Mod
{
/*********
** Properties
*********/
/// <summary>The weathers that can be safely overridden.</summary>
private readonly HashSet<int> NormalWeathers = new HashSet<int> { Game1.weather_sunny, Game1.weather_rain, Game1.weather_lightning, Game1.weather_debris, Game1.weather_snow };
/// <summary>The chance out of 100 that it will rain tomorrow if it's spring.</summary>
private int SpringRainChance;
/// <summary>The chance out of 100 that it will storm tomorrow if it's spring.</summary>
private int SpringThunderChance;
/// <summary>The chance out of 100 that it will rain tomorrow if it's summer.</summary>
private int SummerRainChance;
/// <summary>The chance out of 100 that it will storm tomorrow if it's summer.</summary>
private int SummerThunderChance;
/// <summary>The chance out of 100 that it will rain tomorrow if it's fall.</summary>
private int FallRainChance;
/// <summary>The chance out of 100 that it will storm tomorrow if it's fall.</summary>
private int FallThunderChance;
/// <summary>The chance out of 100 that it will snow tomorrow if it's winter.</summary>
private int WinterSnowChance;
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/// <summary>Whether to suppress verbose logging.</summary>
private bool SuppressLog;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged;
this.LoadConfig();
}
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
{
this.IsGameLoaded = true;
this.HandleNewDay();
}
/// <summary>The method invoked when <see cref="Game1.dayOfMonth"/> changes.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e)
{
if (this.IsGameLoaded)
this.HandleNewDay();
}
/// <summary>Update all data for a new day.</summary>
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;
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
/// <summary>Load the configuration settings.</summary>
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();
}
}
}
/// <summary>Log a message if <see cref="SuppressLog"/> is <c>false</c>.</summary>
/// <param name="message">The message to log.</param>
private void VerboseLog(string message)
{
if (!this.SuppressLog)
this.Monitor.Log(message);
}
}
}

View File

@ -34,7 +34,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="MoreRain.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -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")]

View File

@ -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).

View File

@ -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

View File

@ -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
{
/// <summary>A subclass of <see cref="MuseumMenu"/> which adds support for toggling the inventory box.</summary>
internal class NewMuseumMenu : MuseumMenu
{
/*********
** Properties
*********/
/// <summary>Whether to show the inventory screen.</summary>
private bool ShowInventory = true;
/// <summary>A reference to a private <see cref="MuseumMenu"/> field for use in the overridden draw code.</summary>
private readonly IPrivateField<bool> HoldingMuseumPiece;
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="reflection">Simplifies access to private game code.</param>
public NewMuseumMenu(IReflectionHelper reflection)
{
this.HoldingMuseumPiece = reflection.GetPrivateField<bool>(this, "holdingMuseumPiece");
}
/// <summary>Toggle the inventory box.</summary>
public void ToggleInventory()
{
this.ShowInventory = !this.ShowInventory;
}
/// <summary>Draw the menu to the screen.</summary>
/// <param name="b">The sprite batch being drawn.</param>
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);
}
}
}

View File

@ -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
{
/// <summary>The mod entry point.</summary>
public class MuseumRearranger : Mod
{
/*********
** Properties
*********/
/// <summary>The key which shows the museum rearranging menu.</summary>
private string ShowMenuKey = "R";
/// <summary>The key which toggles the inventory box when the menu is open.</summary>
private string ToggleInventoryKey = "T";
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/// <summary>The open museum menu (if any).</summary>
private NewMuseumMenu OpenMenu;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
}
/*********
** Private methods
*********/
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
{
this.IsGameLoaded = true;
this.LoadConfig();
this.WriteConfig();
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
}
}

View File

@ -36,15 +36,17 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="NewMenuWithInventory.cs" />
<Compile Include="NewMuseumMenu.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="MuseumRearranger.cs" />
<Compile Include="Framework\NewMuseumMenu.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
<None Include="ReadMe.md" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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();
}
}
}

View File

@ -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);
}
}
}

View File

@ -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")]

View File

@ -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.

View File

@ -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<string> newmail = new List<string>();
Queue<string> newmail = new Queue<string>();
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?
}
}
}
}

View File

@ -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
{
/// <summary>The mod entry point.</summary>
public class NightOwl : Mod
{
/*********
** Properties
*********/
/****
** Context
****/
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/// <summary>Whether the player stayed up all night.</summary>
private bool IsUpLate;
/// <summary>Whether the player should be reset to their pre-collapse details for the morning transition on the next update.</summary>
private bool ShouldResetPlayerAfterCollapseNow;
/// <summary>Whether the player just started a new day.</summary>
private bool JustStartedNewDay;
/// <summary>Whether the player just collapsed for the morning transition.</summary>
private bool JustCollapsed;
/****
** Pre-collapse state
****/
/// <summary>The player's location name before they collapsed.</summary>
private string PreCollapseMap;
/// <summary>The player's tile position before they collapsed.</summary>
private Point PreCollapseTile;
/// <summary>The player's money before they collapsed.</summary>
private int PreCollapseMoney;
/// <summary>The player's stamina before they collapsed.</summary>
private float PreCollapseStamina;
/// <summary>The player's health before they collapsed.</summary>
private int PreCollapseHealth;
/****
** Settings
****/
/// <summary>Whether lighting should transition to day from 2am to 6am. If <c>false</c>, the world will stay dark until the player passes out or goes to bed.</summary>
private bool MorningLightTransition;
/// <summary>Whether the player can stay up until 6am.</summary>
private bool StayUp;
/// <summary>Whether to remove the mail received for collapsing like 'we charged X gold for your health fees'.</summary>
private bool SkipCollapseMail;
/// <summary>Whether to restore the player's position after they collapse.</summary>
private bool KeepPositionAfterCollapse;
/// <summary>Whether to restore the player's money after they collapse (i.e. prevent the automatic deduction).</summary>
private bool KeepMoneyAfterCollapse;
/// <summary>Whether to keep stamina as-is after the player collapses.</summary>
private bool KeepHealthAfterCollapse;
/// <summary>Whether to keep stamina as-is after the player collapses.</summary>
private bool KeepStaminaAfterCollapse;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
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
*********/
/// <summary>The method invoked every fourth game update (roughly 15 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void SaveEvents_AfterLoad(object sender, EventArgs e)
{
this.LoadConfig();
this.WriteConfig();
this.IsGameLoaded = true;
this.IsUpLate = false;
this.JustStartedNewDay = false;
this.JustCollapsed = false;
}
/// <summary>The method invoked when <see cref="Game1.dayOfMonth"/> changes.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
}
/// <summary>The method invoked when <see cref="Game1.timeOfDay"/> changes.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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();
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Write the current mod state to the error log file.</summary>
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);
}
}
}
}

View File

@ -32,21 +32,27 @@
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="NightOwl.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Content\Data\Fish.xnb" />
<None Include="Content\Data\Fish.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="ReadMe.txt" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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")]

View File

@ -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.

View File

@ -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

View File

@ -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<NPC> my_npc_list = new List<NPC>();
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);
}
}
}
}
}

View File

@ -0,0 +1,60 @@
using System;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace Omegasis.NoMorePets
{
/// <summary>The mod entry point.</summary>
public class NoMorePets : Mod
{
/*********
** Properties
*********/
/// <summary>Whether the player loaded a save.</summary>
private bool IsGameLoaded;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
}
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void SaveEvents_AfterLoad(object sender, EventArgs e)
{
this.IsGameLoaded = true;
}
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
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);
}
}
}
}
}

View File

@ -34,7 +34,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="NoMorePets.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@ -42,7 +45,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="ReadMe.txt" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />

View File

@ -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")]

View File

@ -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.

View File

@ -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

View File

@ -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();
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -0,0 +1,61 @@
using System;
using System.IO;
namespace Omegasis.SaveAnywhere.Framework
{
/// <summary>Provides methods for reading and writing the config file.</summary>
internal class ConfigUtilities
{
/*********
** Properties
*********/
/// <summary>The full path to the mod folder.</summary>
private readonly string ModPath;
/*********
** Accessors
*********/
/// <summary>The key which saves the game.</summary>
public string KeyBinding { get; private set; } = "K";
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="modPath">The full path to the mod folder.</param>
public ConfigUtilities(string modPath)
{
this.ModPath = modPath;
}
/// <summary>Load the configuration settings.</summary>
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]);
}
}
/// <summary>Save the configuration settings.</summary>
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);
}
}
}

View File

@ -0,0 +1,39 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Menus;
namespace Omegasis.SaveAnywhere.Framework
{
/// <summary>A subclass of <see cref="ShippingMenu"/> that does everything except save.</summary>
internal class NewShippingMenu : ShippingMenu
{
/*********
** Properties
*********/
/// <summary>The private field on the shipping menu which indicates the game has already been saved, which prevents it from saving.</summary>
private readonly IPrivateField<bool> SavedYet;
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="items">The shipping bin items.</param>
/// <param name="reflection">Simplifies access to game code.</param>
public NewShippingMenu(List<Item> items, IReflectionHelper reflection)
: base(items)
{
this.SavedYet = reflection.GetPrivateField<bool>(this, "savedYet");
}
/// <summary>Updates the menu during the game's update loop.</summary>
/// <param name="time">The game time that has passed.</param>
public override void update(GameTime time)
{
this.SavedYet.SetValue(true); // prevent menu from saving
base.update(time);
}
}
}

View File

@ -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
{
/// <summary>Provides methods for saving and loading game data.</summary>
internal class SaveManager
{
/*********
** Properties
*********/
/// <summary>The player for which to save data.</summary>
private readonly SFarmer Player;
/// <summary>Simplifies access to game code.</summary>
private readonly IReflectionHelper Reflection;
/// <summary>Writes messages to the console and log file.</summary>
private readonly IMonitor Monitor;
/// <summary>A callback invoked when villagers are reset during a load.</summary>
private readonly Action OnVillagersReset;
/// <summary>The full path to the folder in which to store data for this player.</summary>
private readonly string SavePath;
/// <summary>The full path to the folder in which to store animal data for this player.</summary>
private readonly string SaveAnimalsPath;
/// <summary>The full path to the folder in which to store villager data for this player.</summary>
private readonly string SaveVillagersPath;
/// <summary>Whether we should save at the next opportunity.</summary>
private bool WaitingToSave;
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="player">The player for which to save data.</param>
/// <param name="modPath">The full path to the mod folder.</param>
/// <param name="monitor">Writes messages to the console and log file.</param>
/// <param name="reflection">Simplifies access to game code.</param>
/// <param name="onVillagersReset">A callback invoked when villagers are reset during a load.</param>
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");
}
/// <summary>Perform any required update logic.</summary>
public void Update()
{
// perform passive save
if (this.WaitingToSave && Game1.activeClickableMenu == null)
{
Game1.activeClickableMenu = new SaveGameMenu();
this.WaitingToSave = false;
}
}
/// <summary>Save all game data.</summary>
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();
}
/// <summary>Load all game data.</summary>
public void LoadPositions()
{
if (!this.HasSaveData())
return;
this.LoadPlayerPosition();
this.LoadHorsePosition();
this.LoadPetPosition();
bool anyVillagersMoved = this.LoadVillagerPositions();
if (anyVillagersMoved)
this.OnVillagersReset?.Invoke();
}
/*********
** Private methods
*********/
/// <summary>Save the horse state to the save file.</summary>
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);
}
/// <summary>Reset the horse to the saved state.</summary>
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);
}
/// <summary>Save the villager states to the save file.</summary>
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);
}
}
/// <summary>Reset the villagers to their saved state.</summary>
/// <returns>Returns whether any villagers changed position.</returns>
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;
}
/// <summary>Save the pet state to the save file.</summary>
private void SavePetPosition()
{
if (!this.Player.hasPet())
return;
// find pet
Pet pet = Utility.getAllCharacters().OfType<Pet>().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);
}
/// <summary>Reset the pet to the saved state.</summary>
private void LoadPetPosition()
{
if (!this.Player.hasPet())
return;
// find pet
Pet pet = Utility.getAllCharacters().OfType<Pet>().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);
}
/// <summary>Save the player state to the save file.</summary>
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);
}
/// <summary>Reset the player to the saved state.</summary>
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);
}
/// <summary>Get whether any data has been saved for this player yet.</summary>
private bool HasSaveData()
{
return Directory.Exists(this.SavePath);
}
}
}

View File

@ -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<Item>((IEnumerable<Item>)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();
}
}
}
}

View File

@ -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);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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<List<string>> routesFromLocationToLocation = new List<List<string>>();
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> npc_list = new List<NPC>();
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<Point> addToStackForSchedule(Stack<Point> original, Stack<Point> toAdd)
{
if (toAdd == null)
return original;
original = new Stack<Point>((IEnumerable<Point>)original);
while (original.Count > 0)
toAdd.Push(original.Pop());
return toAdd;
}
private static List<string> getLocationRoute(NPC npc, string startingLocation, string endingLocation)
{
foreach (List<string> list in routesFromLocationToLocation)
{
if (Enumerable.First<string>((IEnumerable<string>)list).Equals(startingLocation) && Enumerable.Last<string>((IEnumerable<string>)list).Equals(endingLocation) && (npc.gender == 0 || !list.Contains("BathHouse_MensLocker")) && (npc.gender != 0 || !list.Contains("BathHouse_WomensLocker")))
return list;
}
return (List<string>)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<Point> stack = new Stack<Point>();
Point startPoint = new Point(startingX, startingY);
List<string> list = startingLocation.Equals(endingLocation) ? (List<string>)null : getLocationRoute(npc,startingLocation, endingLocation);
if (list != null)
{
for (int index = 0; index < Enumerable.Count<string>((IEnumerable<string>)list); ++index)
{
GameLocation locationFromName = Game1.getLocationFromName(list[index]);
if (index < Enumerable.Count<string>((IEnumerable<string>)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);
}
}
}

View File

@ -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<ClickableTextureComponent> categories = new List<ClickableTextureComponent>();
private List<int> categoryTotals = new List<int>();
private List<MoneyDial> categoryDials = new List<MoneyDial>();
private List<List<Item>> categoryItems = new List<List<Item>>();
private int introTimer = 3500;
public List<TemporaryAnimatedSprite> animations = new List<TemporaryAnimatedSprite>();
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<Item> 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<ClickableTextureComponent> 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<Item>((IEnumerable<Item>)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<Item> items)
{
Utility.consolidateStacks(items);
for (int index = 0; index < 6; ++index)
{
this.categoryItems.Add(new List<Item>());
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<int> 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<int> list;
(list = this.categoryTotals)[5] = list[5] + this.categoryTotals[index];
this.categoryItems[5].AddRange((IEnumerable<Item>)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<TemporaryAnimatedSprite>((IEnumerable<TemporaryAnimatedSprite>)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<TemporaryAnimatedSprite>((IEnumerable<TemporaryAnimatedSprite>)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<Item>((IEnumerable<Item>)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<ClickableTextureComponent>((IEnumerable<ClickableTextureComponent>)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<Item>((IEnumerable<Item>)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<Item>((IEnumerable<Item>)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);
}
}
}

View File

@ -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;
}
}
}
}
}
}

View File

@ -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);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More