summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-11-04 00:10:10 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-11-04 00:10:10 -0400
commit69bb8178d216d2d75d771114643d6749abdc7aea (patch)
tree07161a3e38efb1733fbc47bcb98d24cac6fbebe7
parentc01ffd233120cad625b74d4cec69a52cb9c1ce0b (diff)
downloadSMAPI-69bb8178d216d2d75d771114643d6749abdc7aea.tar.gz
SMAPI-69bb8178d216d2d75d771114643d6749abdc7aea.tar.bz2
SMAPI-69bb8178d216d2d75d771114643d6749abdc7aea.zip
normalise inconsistent line endings
-rw-r--r--.gitattributes2
-rw-r--r--src/StardewModdingAPI.sln145
-rw-r--r--src/StardewModdingAPI/Inheritance/ItemStackChange.cs20
-rw-r--r--src/StardewModdingAPI/Inheritance/SGame.cs2678
-rw-r--r--src/StardewModdingAPI/Program.cs740
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.csproj512
-rw-r--r--src/StardewModdingAPI/packages.config10
-rw-r--r--src/TrainerMod/TrainerMod.cs1454
-rw-r--r--src/TrainerMod/TrainerMod.csproj250
-rw-r--r--src/TrainerMod/packages.config6
10 files changed, 2910 insertions, 2907 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..cd1acd35
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# normalise line endings
+* text=auto
diff --git a/src/StardewModdingAPI.sln b/src/StardewModdingAPI.sln
index 9c999731..29c80e89 100644
--- a/src/StardewModdingAPI.sln
+++ b/src/StardewModdingAPI.sln
@@ -1,72 +1,73 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrainerMod", "TrainerMod\TrainerMod.csproj", "{28480467-1A48-46A7-99F8-236D95225359}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI", "StardewModdingAPI\StardewModdingAPI.csproj", "{F1A573B0-F436-472C-AE29-0B91EA6B9F8F}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "metadata", "metadata", "{86C452BE-D2D8-45B4-B63F-E329EB06CEDA}"
- ProjectSection(SolutionItems) = preProject
- ..\.gitignore = ..\.gitignore
- ..\LICENSE = ..\LICENSE
- ..\README.md = ..\README.md
- ..\release-notes.md = ..\release-notes.md
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.Installer", "StardewModdingAPI.Installer\StardewModdingAPI.Installer.csproj", "{443DDF81-6AAF-420A-A610-3459F37E5575}"
- ProjectSection(ProjectDependencies) = postProject
- {28480467-1A48-46A7-99F8-236D95225359} = {28480467-1A48-46A7-99F8-236D95225359}
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F} = {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|Mixed Platforms = Debug|Mixed Platforms
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|Mixed Platforms = Release|Mixed Platforms
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {28480467-1A48-46A7-99F8-236D95225359}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Debug|x86.ActiveCfg = Debug|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Release|Any CPU.Build.0 = Release|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {28480467-1A48-46A7-99F8-236D95225359}.Release|x86.ActiveCfg = Release|Any CPU
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Mixed Platforms.Build.0 = Debug|x86
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|x86.ActiveCfg = Debug|x86
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|x86.Build.0 = Debug|x86
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Any CPU.Build.0 = Release|Any CPU
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Mixed Platforms.ActiveCfg = Release|x86
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Mixed Platforms.Build.0 = Release|x86
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|x86.ActiveCfg = Release|x86
- {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|x86.Build.0 = Release|x86
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|x86.ActiveCfg = Debug|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|x86.Build.0 = Debug|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|Any CPU.Build.0 = Release|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|x86.ActiveCfg = Release|Any CPU
- {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|x86.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrainerMod", "TrainerMod\TrainerMod.csproj", "{28480467-1A48-46A7-99F8-236D95225359}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI", "StardewModdingAPI\StardewModdingAPI.csproj", "{F1A573B0-F436-472C-AE29-0B91EA6B9F8F}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "metadata", "metadata", "{86C452BE-D2D8-45B4-B63F-E329EB06CEDA}"
+ ProjectSection(SolutionItems) = preProject
+ ..\.gitattributes = ..\.gitattributes
+ ..\.gitignore = ..\.gitignore
+ ..\LICENSE = ..\LICENSE
+ ..\README.md = ..\README.md
+ ..\release-notes.md = ..\release-notes.md
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.Installer", "StardewModdingAPI.Installer\StardewModdingAPI.Installer.csproj", "{443DDF81-6AAF-420A-A610-3459F37E5575}"
+ ProjectSection(ProjectDependencies) = postProject
+ {28480467-1A48-46A7-99F8-236D95225359} = {28480467-1A48-46A7-99F8-236D95225359}
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F} = {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {28480467-1A48-46A7-99F8-236D95225359}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Release|Any CPU.Build.0 = Release|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {28480467-1A48-46A7-99F8-236D95225359}.Release|x86.ActiveCfg = Release|Any CPU
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|x86.ActiveCfg = Debug|x86
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|x86.Build.0 = Debug|x86
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Mixed Platforms.Build.0 = Release|x86
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|x86.ActiveCfg = Release|x86
+ {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|x86.Build.0 = Release|x86
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Debug|x86.Build.0 = Debug|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|Any CPU.Build.0 = Release|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|x86.ActiveCfg = Release|Any CPU
+ {443DDF81-6AAF-420A-A610-3459F37E5575}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/StardewModdingAPI/Inheritance/ItemStackChange.cs b/src/StardewModdingAPI/Inheritance/ItemStackChange.cs
index 78775094..8abe3a76 100644
--- a/src/StardewModdingAPI/Inheritance/ItemStackChange.cs
+++ b/src/StardewModdingAPI/Inheritance/ItemStackChange.cs
@@ -1,11 +1,11 @@
-using StardewValley;
-
-namespace StardewModdingAPI.Inheritance
-{
- public class ItemStackChange
- {
- public Item Item { get; set; }
- public int StackChange { get; set; }
- public ChangeType ChangeType { get; set; }
- }
+using StardewValley;
+
+namespace StardewModdingAPI.Inheritance
+{
+ public class ItemStackChange
+ {
+ public Item Item { get; set; }
+ public int StackChange { get; set; }
+ public ChangeType ChangeType { get; set; }
+ }
} \ No newline at end of file
diff --git a/src/StardewModdingAPI/Inheritance/SGame.cs b/src/StardewModdingAPI/Inheritance/SGame.cs
index 26421136..808f0812 100644
--- a/src/StardewModdingAPI/Inheritance/SGame.cs
+++ b/src/StardewModdingAPI/Inheritance/SGame.cs
@@ -1,1340 +1,1340 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework.Input;
-using StardewModdingAPI.Events;
-using StardewValley;
-using StardewValley.BellsAndWhistles;
-using StardewValley.Locations;
-using StardewValley.Menus;
-using StardewValley.Tools;
-using xTile.Dimensions;
-using Rectangle = Microsoft.Xna.Framework.Rectangle;
-
-namespace StardewModdingAPI.Inheritance
-{
- /// <summary>
- /// The 'SGame' class.
- /// This summary, and many others, only exists because XML doc tags.
- /// </summary>
- public class SGame : Game1
- {
- private bool FireLoadedGameEvent;
-
- /// <summary>
- /// Gets a jagged array of all buttons pressed on the gamepad the prior frame.
- /// </summary>
- public Buttons[][] PreviouslyPressedButtons;
-
- internal SGame()
- {
- Instance = this;
- FirstUpdate = true;
- }
-
- /// <summary>
- /// The current KeyboardState
- /// </summary>
- public KeyboardState KStateNow { get; private set; }
- /// <summary>
- /// The prior KeyboardState
- /// </summary>
- public KeyboardState KStatePrior { get; private set; }
-
- /// <summary>
- /// The current MouseState
- /// </summary>
- public MouseState MStateNow { get; private set; }
-
- /// <summary>
- /// The prior MouseState
- /// </summary>
- public MouseState MStatePrior { get; private set; }
-
- /// <summary>The current mouse position on the screen adjusted for the zoom level.</summary>
- public Point MPositionNow { get; private set; }
-
- /// <summary>The previous mouse position on the screen adjusted for the zoom level.</summary>
- public Point MPositionPrior { get; private set; }
-
- /// <summary>
- /// All keys pressed on the current frame
- /// </summary>
- public Keys[] CurrentlyPressedKeys => KStateNow.GetPressedKeys();
-
- /// <summary>
- /// All keys pressed on the prior frame
- /// </summary>
- public Keys[] PreviouslyPressedKeys => KStatePrior.GetPressedKeys();
-
- /// <summary>
- /// All keys pressed on this frame except for the ones pressed on the prior frame
- /// </summary>
- public Keys[] FramePressedKeys => CurrentlyPressedKeys.Except(PreviouslyPressedKeys).ToArray();
-
- /// <summary>
- /// All keys pressed on the prior frame except for the ones pressed on the current frame
- /// </summary>
- public Keys[] FrameReleasedKeys => PreviouslyPressedKeys.Except(CurrentlyPressedKeys).ToArray();
-
- /// <summary>
- /// Whether or not a save was tagged as 'Loaded' the prior frame.
- /// </summary>
- public bool PreviouslyLoadedGame { get; private set; }
-
- /// <summary>
- /// The list of GameLocations on the prior frame
- /// </summary>
- public int PreviousGameLocations { get; private set; }
-
- /// <summary>
- /// The list of GameObjects on the prior frame
- /// </summary>
- public int PreviousLocationObjects { get; private set; }
-
- /// <summary>
- /// The list of Items in the player's inventory on the prior frame
- /// </summary>
- public Dictionary<Item, int> PreviousItems { get; private set; }
-
- /// <summary>
- /// The player's Combat level on the prior frame
- /// </summary>
- public int PreviousCombatLevel { get; private set; }
- /// <summary>
- /// The player's Farming level on the prior frame
- /// </summary>
- public int PreviousFarmingLevel { get; private set; }
- /// <summary>
- /// The player's Fishing level on the prior frame
- /// </summary>
- public int PreviousFishingLevel { get; private set; }
- /// <summary>
- /// The player's Foraging level on the prior frame
- /// </summary>
- public int PreviousForagingLevel { get; private set; }
- /// <summary>
- /// The player's Mining level on the prior frame
- /// </summary>
- public int PreviousMiningLevel { get; private set; }
- /// <summary>
- /// The player's Luck level on the prior frame
- /// </summary>
- public int PreviousLuckLevel { get; private set; }
-
- //Kill me now comments are so boring
-
- /// <summary>
- /// The player's previous game location
- /// </summary>
- public GameLocation PreviousGameLocation { get; private set; }
-
- /// <summary>
- /// The previous ActiveGameMenu in Game1
- /// </summary>
- public IClickableMenu PreviousActiveMenu { get; private set; }
-
- /// <summary>
- /// Indicates if the MenuClosed event was fired to prevent it from re-firing.
- /// </summary>
- internal bool WasMenuClosedInvoked = false;
-
- /// <summary>
- /// The previous mine level
- /// </summary>
- public int PreviousMineLevel { get; private set; }
-
- /// <summary>
- /// The previous TimeOfDay (Int32 between 600 and 2400?)
- /// </summary>
- public int PreviousTimeOfDay { get; private set; }
-
- /// <summary>
- /// The previous DayOfMonth (Int32 between 1 and 28?)
- /// </summary>
- public int PreviousDayOfMonth { get; private set; }
-
- /// <summary>
- /// The previous Season (String as follows: "winter", "spring", "summer", "fall")
- /// </summary>
- public string PreviousSeasonOfYear { get; private set; }
-
- /// <summary>
- /// The previous Year
- /// </summary>
- public int PreviousYearOfGame { get; private set; }
-
- /// <summary>
- /// The previous result of Game1.newDay
- /// </summary>
- public bool PreviousIsNewDay { get; private set; }
-
- /// <summary>
- /// The previous 'Farmer' (Player)
- /// </summary>
- public Farmer PreviousFarmer { get; private set; }
-
- /// <summary>
- /// The current index of the update tick. Recycles every 60th tick to 0. (Int32 between 0 and 59)
- /// </summary>
- public int CurrentUpdateTick { get; private set; }
-
- /// <summary>
- /// Whether or not this update frame is the very first of the entire game
- /// </summary>
- public bool FirstUpdate { get; private set; }
-
- /// <summary>
- /// The current RenderTarget in Game1 (Private field, uses reflection)
- /// </summary>
- public RenderTarget2D Screen
- {
- get { return typeof (Game1).GetBaseFieldValue<RenderTarget2D>(Program.gamePtr, "screen"); }
- set { typeof (Game1).SetBaseFieldValue<RenderTarget2D>(this, "screen", value); }
- }
-
- /// <summary>
- /// The current Colour in Game1 (Private field, uses reflection)
- /// </summary>
- public Color BgColour
- {
- get { return (Color)typeof(Game1).GetBaseFieldValue<object>(Program.gamePtr, "bgColor"); }
- set { typeof(Game1).SetBaseFieldValue<object>(this, "bgColor", value); }
- }
-
- /// <summary>
- /// Static accessor for an Instance of the class SGame
- /// </summary>
- public static SGame Instance { get; private set; }
-
- /// <summary>
- /// The game's FPS. Re-determined every Draw update.
- /// </summary>
- public static float FramesPerSecond { get; private set; }
-
- /// <summary>
- /// Whether or not we're in a pseudo 'debug' mode. Mostly for displaying information like FPS.
- /// </summary>
- public static bool Debug { get; private set; }
- internal static Queue<String> DebugMessageQueue { get; private set; }
-
- /// <summary>
- /// The current player (equal to Farmer.Player)
- /// </summary>
- [Obsolete("Use Farmer.Player instead")]
- public Farmer CurrentFarmer => player;
-
- /// <summary>
- /// Gets ALL static fields that belong to 'Game1'
- /// </summary>
- public static FieldInfo[] GetStaticFields => typeof (Game1).GetFields();
-
- /// <summary>
- /// Whether or not a button was just pressed on the controller
- /// </summary>
- /// <param name="button"></param>
- /// <param name="buttonState"></param>
- /// <param name="stateIndex"></param>
- /// <returns></returns>
- private bool WasButtonJustPressed(Buttons button, ButtonState buttonState, PlayerIndex stateIndex)
- {
- return buttonState == ButtonState.Pressed && !PreviouslyPressedButtons[(int) stateIndex].Contains(button);
- }
-
- /// <summary>
- /// Whether or not a button was just released on the controller
- /// </summary>
- /// <param name="button"></param>
- /// <param name="buttonState"></param>
- /// <param name="stateIndex"></param>
- /// <returns></returns>
- private bool WasButtonJustReleased(Buttons button, ButtonState buttonState, PlayerIndex stateIndex)
- {
- return buttonState == ButtonState.Released && PreviouslyPressedButtons[(int) stateIndex].Contains(button);
- }
-
- /// <summary>
- /// Whether or not an analog button was just pressed on the controller
- /// </summary>
- /// <param name="button"></param>
- /// <param name="value"></param>
- /// <param name="stateIndex"></param>
- /// <returns></returns>
- private bool WasButtonJustPressed(Buttons button, float value, PlayerIndex stateIndex)
- {
- return WasButtonJustPressed(button, value > 0.2f ? ButtonState.Pressed : ButtonState.Released, stateIndex);
- }
-
- /// <summary>
- /// Whether or not an analog button was just released on the controller
- /// </summary>
- /// <param name="button"></param>
- /// <param name="value"></param>
- /// <param name="stateIndex"></param>
- /// <returns></returns>
- private bool WasButtonJustReleased(Buttons button, float value, PlayerIndex stateIndex)
- {
- return WasButtonJustReleased(button, value > 0.2f ? ButtonState.Pressed : ButtonState.Released, stateIndex);
- }
-
- /// <summary>
- /// Gets an array of all Buttons pressed on a joystick
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- public Buttons[] GetButtonsDown(PlayerIndex index)
- {
- var state = GamePad.GetState(index);
- var buttons = new List<Buttons>();
- if (state.IsConnected)
- {
- if (state.Buttons.A == ButtonState.Pressed) buttons.Add(Buttons.A);
- if (state.Buttons.B == ButtonState.Pressed) buttons.Add(Buttons.B);
- if (state.Buttons.Back == ButtonState.Pressed) buttons.Add(Buttons.Back);
- if (state.Buttons.BigButton == ButtonState.Pressed) buttons.Add(Buttons.BigButton);
- if (state.Buttons.LeftShoulder == ButtonState.Pressed) buttons.Add(Buttons.LeftShoulder);
- if (state.Buttons.LeftStick == ButtonState.Pressed) buttons.Add(Buttons.LeftStick);
- if (state.Buttons.RightShoulder == ButtonState.Pressed) buttons.Add(Buttons.RightShoulder);
- if (state.Buttons.RightStick == ButtonState.Pressed) buttons.Add(Buttons.RightStick);
- if (state.Buttons.Start == ButtonState.Pressed) buttons.Add(Buttons.Start);
- if (state.Buttons.X == ButtonState.Pressed) buttons.Add(Buttons.X);
- if (state.Buttons.Y == ButtonState.Pressed) buttons.Add(Buttons.Y);
- if (state.DPad.Up == ButtonState.Pressed) buttons.Add(Buttons.DPadUp);
- if (state.DPad.Down == ButtonState.Pressed) buttons.Add(Buttons.DPadDown);
- if (state.DPad.Left == ButtonState.Pressed) buttons.Add(Buttons.DPadLeft);
- if (state.DPad.Right == ButtonState.Pressed) buttons.Add(Buttons.DPadRight);
- if (state.Triggers.Left > 0.2f) buttons.Add(Buttons.LeftTrigger);
- if (state.Triggers.Right > 0.2f) buttons.Add(Buttons.RightTrigger);
- }
- return buttons.ToArray();
- }
-
- /// <summary>
- /// Gets all buttons that were pressed on the current frame of a joystick
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- public Buttons[] GetFramePressedButtons(PlayerIndex index)
- {
- var state = GamePad.GetState(index);
- var buttons = new List<Buttons>();
- if (state.IsConnected)
- {
- if (WasButtonJustPressed(Buttons.A, state.Buttons.A, index)) buttons.Add(Buttons.A);
- if (WasButtonJustPressed(Buttons.B, state.Buttons.B, index)) buttons.Add(Buttons.B);
- if (WasButtonJustPressed(Buttons.Back, state.Buttons.Back, index)) buttons.Add(Buttons.Back);
- if (WasButtonJustPressed(Buttons.BigButton, state.Buttons.BigButton, index)) buttons.Add(Buttons.BigButton);
- if (WasButtonJustPressed(Buttons.LeftShoulder, state.Buttons.LeftShoulder, index)) buttons.Add(Buttons.LeftShoulder);
- if (WasButtonJustPressed(Buttons.LeftStick, state.Buttons.LeftStick, index)) buttons.Add(Buttons.LeftStick);
- if (WasButtonJustPressed(Buttons.RightShoulder, state.Buttons.RightShoulder, index)) buttons.Add(Buttons.RightShoulder);
- if (WasButtonJustPressed(Buttons.RightStick, state.Buttons.RightStick, index)) buttons.Add(Buttons.RightStick);
- if (WasButtonJustPressed(Buttons.Start, state.Buttons.Start, index)) buttons.Add(Buttons.Start);
- if (WasButtonJustPressed(Buttons.X, state.Buttons.X, index)) buttons.Add(Buttons.X);
- if (WasButtonJustPressed(Buttons.Y, state.Buttons.Y, index)) buttons.Add(Buttons.Y);
- if (WasButtonJustPressed(Buttons.DPadUp, state.DPad.Up, index)) buttons.Add(Buttons.DPadUp);
- if (WasButtonJustPressed(Buttons.DPadDown, state.DPad.Down, index)) buttons.Add(Buttons.DPadDown);
- if (WasButtonJustPressed(Buttons.DPadLeft, state.DPad.Left, index)) buttons.Add(Buttons.DPadLeft);
- if (WasButtonJustPressed(Buttons.DPadRight, state.DPad.Right, index)) buttons.Add(Buttons.DPadRight);
- if (WasButtonJustPressed(Buttons.LeftTrigger, state.Triggers.Left, index)) buttons.Add(Buttons.LeftTrigger);
- if (WasButtonJustPressed(Buttons.RightTrigger, state.Triggers.Right, index)) buttons.Add(Buttons.RightTrigger);
- }
- return buttons.ToArray();
- }
-
- /// <summary>
- /// Gets all buttons that were released on the current frame of a joystick
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- public Buttons[] GetFrameReleasedButtons(PlayerIndex index)
- {
- var state = GamePad.GetState(index);
- var buttons = new List<Buttons>();
- if (state.IsConnected)
- {
- if (WasButtonJustReleased(Buttons.A, state.Buttons.A, index)) buttons.Add(Buttons.A);
- if (WasButtonJustReleased(Buttons.B, state.Buttons.B, index)) buttons.Add(Buttons.B);
- if (WasButtonJustReleased(Buttons.Back, state.Buttons.Back, index)) buttons.Add(Buttons.Back);
- if (WasButtonJustReleased(Buttons.BigButton, state.Buttons.BigButton, index)) buttons.Add(Buttons.BigButton);
- if (WasButtonJustReleased(Buttons.LeftShoulder, state.Buttons.LeftShoulder, index)) buttons.Add(Buttons.LeftShoulder);
- if (WasButtonJustReleased(Buttons.LeftStick, state.Buttons.LeftStick, index)) buttons.Add(Buttons.LeftStick);
- if (WasButtonJustReleased(Buttons.RightShoulder, state.Buttons.RightShoulder, index)) buttons.Add(Buttons.RightShoulder);
- if (WasButtonJustReleased(Buttons.RightStick, state.Buttons.RightStick, index)) buttons.Add(Buttons.RightStick);
- if (WasButtonJustReleased(Buttons.Start, state.Buttons.Start, index)) buttons.Add(Buttons.Start);
- if (WasButtonJustReleased(Buttons.X, state.Buttons.X, index)) buttons.Add(Buttons.X);
- if (WasButtonJustReleased(Buttons.Y, state.Buttons.Y, index)) buttons.Add(Buttons.Y);
- if (WasButtonJustReleased(Buttons.DPadUp, state.DPad.Up, index)) buttons.Add(Buttons.DPadUp);
- if (WasButtonJustReleased(Buttons.DPadDown, state.DPad.Down, index)) buttons.Add(Buttons.DPadDown);
- if (WasButtonJustReleased(Buttons.DPadLeft, state.DPad.Left, index)) buttons.Add(Buttons.DPadLeft);
- if (WasButtonJustReleased(Buttons.DPadRight, state.DPad.Right, index)) buttons.Add(Buttons.DPadRight);
- if (WasButtonJustReleased(Buttons.LeftTrigger, state.Triggers.Left, index)) buttons.Add(Buttons.LeftTrigger);
- if (WasButtonJustReleased(Buttons.RightTrigger, state.Triggers.Right, index)) buttons.Add(Buttons.RightTrigger);
- }
- return buttons.ToArray();
- }
-
- /// <summary>
- ///
- /// </summary>
- public static MethodInfo DrawFarmBuildings = typeof (Game1).GetMethod("drawFarmBuildings", BindingFlags.NonPublic | BindingFlags.Instance);
-
- /// <summary>
- ///
- /// </summary>
- public static MethodInfo DrawHUD = typeof (Game1).GetMethod("drawHUD", BindingFlags.NonPublic | BindingFlags.Instance);
-
- /// <summary>
- ///
- /// </summary>
- public static MethodInfo DrawDialogueBox = typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance);
-
- public static MethodInfo CheckForEscapeKeys = typeof (Game1).GetMethod("checkForEscapeKeys", BindingFlags.NonPublic | BindingFlags.Instance);
-
- public static MethodInfo UpdateControlInput = typeof(Game1).GetMethod("UpdateControlInput", BindingFlags.NonPublic | BindingFlags.Instance);
-
- public static MethodInfo UpdateCharacters = typeof(Game1).GetMethod("UpdateCharacters", BindingFlags.NonPublic | BindingFlags.Instance);
-
- public static MethodInfo UpdateLocations = typeof(Game1).GetMethod("UpdateLocations", BindingFlags.NonPublic | BindingFlags.Instance);
-
- public static MethodInfo getViewportCenter = typeof(Game1).GetMethod("getViewportCenter", BindingFlags.NonPublic | BindingFlags.Instance);
-
- public static MethodInfo UpdateTitleScreen = typeof(Game1).GetMethod("UpdateTitleScreen", BindingFlags.NonPublic | BindingFlags.Instance);
-
- public delegate void BaseBaseDraw();
-
- /// <summary>
- /// Whether or not the game's zoom level is 1.0f
- /// </summary>
- public bool ZoomLevelIsOne => options.zoomLevel.Equals(1.0f);
-
- /// <summary>
- /// XNA Init Method
- /// </summary>
- protected override void Initialize()
- {
- Log.AsyncY("XNA Initialize");
- //ModItems = new Dictionary<int, SObject>();
- DebugMessageQueue = new Queue<string>();
- PreviouslyPressedButtons = new Buttons[4][];
- for (var i = 0; i < 4; ++i) PreviouslyPressedButtons[i] = new Buttons[0];
-
- base.Initialize();
- GameEvents.InvokeInitialize();
- }
-
- /// <summary>
- /// XNA LC Method
- /// </summary>
- protected override void LoadContent()
- {
- Log.AsyncY("XNA LoadContent");
- base.LoadContent();
- GameEvents.InvokeLoadContent();
- }
-
- /// <summary>
- /// XNA Update Method
- /// </summary>
- /// <param name="gameTime"></param>
- protected override void Update(GameTime gameTime)
- {
- QueueDebugMessage("FPS: " + FramesPerSecond);
- UpdateEventCalls();
-
- if (FramePressedKeys.Contains(Keys.F3))
- {
- Debug = !Debug;
- }
-
- try
- {
- base.Update(gameTime);
- }
- catch (Exception ex)
- {
- Log.AsyncR("An error occured in the base update loop: " + ex);
- Console.ReadKey();
- }
-
- GameEvents.InvokeUpdateTick();
- if (FirstUpdate)
- {
- GameEvents.InvokeFirstUpdateTick();
- FirstUpdate = false;
- }
-
- if (CurrentUpdateTick % 2 == 0)
- GameEvents.InvokeSecondUpdateTick();
-
- if (CurrentUpdateTick % 4 == 0)
- GameEvents.InvokeFourthUpdateTick();
-
- if (CurrentUpdateTick % 8 == 0)
- GameEvents.InvokeEighthUpdateTick();
-
- if (CurrentUpdateTick % 15 == 0)
- GameEvents.InvokeQuarterSecondTick();
-
- if (CurrentUpdateTick % 30 == 0)
- GameEvents.InvokeHalfSecondTick();
-
- if (CurrentUpdateTick % 60 == 0)
- GameEvents.InvokeOneSecondTick();
-
- CurrentUpdateTick += 1;
- if (CurrentUpdateTick >= 60)
- CurrentUpdateTick = 0;
-
- if (KStatePrior != KStateNow)
- KStatePrior = KStateNow;
-
- for (var i = PlayerIndex.One; i <= PlayerIndex.Four; i++)
- {
- PreviouslyPressedButtons[(int) i] = GetButtonsDown(i);
- }
- }
-
- /// <summary>
- /// XNA Draw Method
- /// </summary>
- /// <param name="gameTime"></param>
- protected override void Draw(GameTime gameTime)
- {
- FramesPerSecond = 1 / (float) gameTime.ElapsedGameTime.TotalSeconds;
-
- if (Constants.EnableCompletelyOverridingBaseCalls)
- {
- #region Overridden Draw
-
- try
- {
- if (!ZoomLevelIsOne)
- {
- GraphicsDevice.SetRenderTarget(Screen);
- }
-
- GraphicsDevice.Clear(BgColour);
- if (options.showMenuBackground && activeClickableMenu != null && activeClickableMenu.showWithoutTransparencyIfOptionIsSet())
- {
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- activeClickableMenu.drawBackground(spriteBatch);
- GraphicsEvents.InvokeOnPreRenderGuiEvent(null, EventArgs.Empty);
- activeClickableMenu.draw(spriteBatch);
- GraphicsEvents.InvokeOnPostRenderGuiEvent(null, EventArgs.Empty);
- spriteBatch.End();
- if (!ZoomLevelIsOne)
- {
- GraphicsDevice.SetRenderTarget(null);
- GraphicsDevice.Clear(BgColour);
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
- spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
- spriteBatch.End();
- }
- return;
- }
- if (gameMode == 11)
- {
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- spriteBatch.DrawString(smoothFont, "Stardew Valley has crashed...", new Vector2(16f, 16f), Color.HotPink);
- spriteBatch.DrawString(smoothFont, "Please send the error report or a screenshot of this message to @ConcernedApe. (http://stardewvalley.net/contact/)", new Vector2(16f, 32f), new Color(0, 255, 0));
- spriteBatch.DrawString(smoothFont, parseText(errorMessage, smoothFont, graphics.GraphicsDevice.Viewport.Width), new Vector2(16f, 48f), Color.White);
- spriteBatch.End();
- return;
- }
- if (currentMinigame != null)
- {
- currentMinigame.draw(spriteBatch);
- if (globalFade && !menuUp && (!nameSelectUp || messagePause))
- {
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Black * ((gameMode == 0) ? (1f - fadeToBlackAlpha) : fadeToBlackAlpha));
- spriteBatch.End();
- }
- if (!ZoomLevelIsOne)
- {
- GraphicsDevice.SetRenderTarget(null);
- GraphicsDevice.Clear(BgColour);
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilS