From 27dece2cf445147c5e2848f9ec26f38a101f50fc Mon Sep 17 00:00:00 2001 From: Gormogon Date: Sun, 29 May 2016 18:23:01 -0400 Subject: Attempt to migrate to new directory structure. --- .../Inheritance/ItemStackChange.cs | 18 + .../Inheritance/Menus/SBobberBar.cs | 288 ++++ .../Inheritance/Menus/SGameMenu.cs | 48 + .../Inheritance/Menus/SInventoryPage.cs | 19 + .../Inheritance/Minigames/SMinigameBase.cs | 34 + src/StardewModdingAPI/Inheritance/SBareObject.cs | 20 + src/StardewModdingAPI/Inheritance/SGame.cs | 1726 ++++++++++++++++++++ src/StardewModdingAPI/Inheritance/SObject.cs | 277 ++++ 8 files changed, 2430 insertions(+) create mode 100644 src/StardewModdingAPI/Inheritance/ItemStackChange.cs create mode 100644 src/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs create mode 100644 src/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs create mode 100644 src/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs create mode 100644 src/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs create mode 100644 src/StardewModdingAPI/Inheritance/SBareObject.cs create mode 100644 src/StardewModdingAPI/Inheritance/SGame.cs create mode 100644 src/StardewModdingAPI/Inheritance/SObject.cs (limited to 'src/StardewModdingAPI/Inheritance') diff --git a/src/StardewModdingAPI/Inheritance/ItemStackChange.cs b/src/StardewModdingAPI/Inheritance/ItemStackChange.cs new file mode 100644 index 00000000..88fc002e --- /dev/null +++ b/src/StardewModdingAPI/Inheritance/ItemStackChange.cs @@ -0,0 +1,18 @@ +using StardewValley; + +namespace StardewModdingAPI.Inheritance +{ + public enum ChangeType + { + Removed, + Added, + StackChange + } + + 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/Menus/SBobberBar.cs b/src/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs new file mode 100644 index 00000000..1e424f73 --- /dev/null +++ b/src/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs @@ -0,0 +1,288 @@ +using System.Reflection; +using Microsoft.Xna.Framework; +using StardewValley.BellsAndWhistles; +using StardewValley.Menus; + +namespace StardewModdingAPI.Inheritance.Menus +{ + public class SBobberBar : BobberBar + { + /// + /// DO NOT CONSTRUCT THIS CLASS + /// To retrieve an instance of SBobberBar, use SBobberBar.ConstructFromBaseClass() + /// + public SBobberBar(int whichFish, float fishSize, bool treasure, int bobber) : base(whichFish, fishSize, treasure, bobber) + { + } + + public BobberBar BaseBobberBar { get; private set; } + + /// + /// The green rectangle bar that moves up and down + /// + public float bobberPosition + { + get { return (float) GetBaseFieldInfo("bobberPosition").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberPosition").SetValue(BaseBobberBar, value); } + } + + /// + /// The green bar on the right. How close to catching the fish you are + /// Range: 0 - 1 | 1 = catch, 0 = fail + /// + public float distanceFromCatching + { + get { return (float) GetBaseFieldInfo("distanceFromCatching").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("distanceFromCatching").SetValue(BaseBobberBar, value); } + } + + public float difficulty + { + get { return (float) GetBaseFieldInfo("difficulty").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("difficulty").SetValue(BaseBobberBar, value); } + } + + public int motionType + { + get { return (int) GetBaseFieldInfo("motionType").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("motionType").SetValue(BaseBobberBar, value); } + } + + public int whichFish + { + get { return (int) GetBaseFieldInfo("whichFish").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("whichFish").SetValue(BaseBobberBar, value); } + } + + public float bobberSpeed + { + get { return (float) GetBaseFieldInfo("bobberSpeed").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberSpeed").SetValue(BaseBobberBar, value); } + } + + public float bobberAcceleration + { + get { return (float) GetBaseFieldInfo("bobberAcceleration").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberAcceleration").SetValue(BaseBobberBar, value); } + } + + public float bobberTargetPosition + { + get { return (float) GetBaseFieldInfo("bobberTargetPosition").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberTargetPosition").SetValue(BaseBobberBar, value); } + } + + public float scale + { + get { return (float) GetBaseFieldInfo("scale").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("scale").SetValue(BaseBobberBar, value); } + } + + public float everythingShakeTimer + { + get { return (float) GetBaseFieldInfo("everythingShakeTimer").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("everythingShakeTimer").SetValue(BaseBobberBar, value); } + } + + public float floaterSinkerAcceleration + { + get { return (float) GetBaseFieldInfo("floaterSinkerAcceleration").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("floaterSinkerAcceleration").SetValue(BaseBobberBar, value); } + } + + public float treasurePosition + { + get { return (float) GetBaseFieldInfo("treasurePosition").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("treasurePosition").SetValue(BaseBobberBar, value); } + } + + public float treasureCatchLevel + { + get { return (float) GetBaseFieldInfo("treasureCatchLevel").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("treasureCatchLevel").SetValue(BaseBobberBar, value); } + } + + public float treasureAppearTimer + { + get { return (float) GetBaseFieldInfo("treasureAppearTimer").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("treasureAppearTimer").SetValue(BaseBobberBar, value); } + } + + public float treasureScale + { + get { return (float) GetBaseFieldInfo("treasureScale").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("treasureScale").SetValue(BaseBobberBar, value); } + } + + public bool bobberInBar + { + get { return (bool) GetBaseFieldInfo("bobberInBar").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberInBar").SetValue(BaseBobberBar, value); } + } + + public bool buttonPressed + { + get { return (bool) GetBaseFieldInfo("buttonPressed").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("buttonPressed").SetValue(BaseBobberBar, value); } + } + + public bool flipBubble + { + get { return (bool) GetBaseFieldInfo("flipBubble").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("flipBubble").SetValue(BaseBobberBar, value); } + } + + public bool fadeIn + { + get { return (bool) GetBaseFieldInfo("fadeIn").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("fadeIn").SetValue(BaseBobberBar, value); } + } + + public bool fadeOut + { + get { return (bool) GetBaseFieldInfo("fadeOut").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberPfadeOutosition").SetValue(BaseBobberBar, value); } + } + + /// + /// Whether or not a treasure chest appears + /// + public bool treasure + { + get { return (bool) GetBaseFieldInfo("treasure").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("treasure").SetValue(BaseBobberBar, value); } + } + + public bool treasureCaught + { + get { return (bool) GetBaseFieldInfo("treasureCaught").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("treasureCaught").SetValue(BaseBobberBar, value); } + } + + public bool perfect + { + get { return (bool) GetBaseFieldInfo("perfect").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("perfect").SetValue(BaseBobberBar, value); } + } + + public bool bossFish + { + get { return (bool) GetBaseFieldInfo("bossFish").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bossFish").SetValue(BaseBobberBar, value); } + } + + public int bobberBarHeight + { + get { return (int) GetBaseFieldInfo("bobberBarHeight").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberBarHeight").SetValue(BaseBobberBar, value); } + } + + public int fishSize + { + get { return (int) GetBaseFieldInfo("fishSize").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("fishSize").SetValue(BaseBobberBar, value); } + } + + public int fishQuality + { + get { return (int) GetBaseFieldInfo("fishQuality").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("fishQuality").SetValue(BaseBobberBar, value); } + } + + public int minFishSize + { + get { return (int) GetBaseFieldInfo("minFishSize").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("minFishSize").SetValue(BaseBobberBar, value); } + } + + public int maxFishSize + { + get { return (int) GetBaseFieldInfo("maxFishSize").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("maxFishSize").SetValue(BaseBobberBar, value); } + } + + public int fishSizeReductionTimer + { + get { return (int) GetBaseFieldInfo("fishSizeReductionTimer").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("fishSizeReductionTimer").SetValue(BaseBobberBar, value); } + } + + public int whichBobber + { + get { return (int) GetBaseFieldInfo("whichBobber").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("whichBobber").SetValue(BaseBobberBar, value); } + } + + public Vector2 barShake + { + get { return (Vector2) GetBaseFieldInfo("barShake").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("barShake").SetValue(BaseBobberBar, value); } + } + + public Vector2 fishShake + { + get { return (Vector2) GetBaseFieldInfo("fishShake").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("fishShake").SetValue(BaseBobberBar, value); } + } + + public Vector2 everythingShake + { + get { return (Vector2) GetBaseFieldInfo("everythingShake").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("everythingShake").SetValue(BaseBobberBar, value); } + } + + public Vector2 treasureShake + { + get { return (Vector2) GetBaseFieldInfo("treasureShake").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("treasureShake").SetValue(BaseBobberBar, value); } + } + + public float reelRotation + { + get { return (float) GetBaseFieldInfo("reelRotation").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("reelRotation").SetValue(BaseBobberBar, value); } + } + + public SparklingText sparkleText + { + get { return (SparklingText) GetBaseFieldInfo("sparkleText").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("sparkleText").SetValue(BaseBobberBar, value); } + } + + public float bobberBarPos + { + get { return (float) GetBaseFieldInfo("bobberBarPos").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberBarPos").SetValue(BaseBobberBar, value); } + } + + public float bobberBarSpeed + { + get { return (float) GetBaseFieldInfo("bobberBarSpeed").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberBarSpeed").SetValue(BaseBobberBar, value); } + } + + public float bobberBarAcceleration + { + get { return (float) GetBaseFieldInfo("bobberBarAcceleration").GetValue(BaseBobberBar); } + set { GetBaseFieldInfo("bobberBarAcceleration").SetValue(BaseBobberBar, value); } + } + + public static FieldInfo[] PrivateFields => GetPrivateFields(); + + public static SBobberBar ConstructFromBaseClass(BobberBar baseClass) + { + var b = new SBobberBar(0, 0, false, 0) {BaseBobberBar = baseClass}; + return b; + } + + public static FieldInfo[] GetPrivateFields() + { + return typeof(BobberBar).GetFields(BindingFlags.Instance | BindingFlags.NonPublic); + } + + public static FieldInfo GetBaseFieldInfo(string name) + { + return typeof(BobberBar).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs b/src/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs new file mode 100644 index 00000000..a4d3d8d0 --- /dev/null +++ b/src/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Reflection; +using StardewValley.Menus; + +namespace StardewModdingAPI.Inheritance.Menus +{ + public class SGameMenu : GameMenu + { + public GameMenu BaseGameMenu { get; private set; } + + public List tabs + { + get { return (List) GetBaseFieldInfo("tabs").GetValue(BaseGameMenu); } + set { GetBaseFieldInfo("tabs").SetValue(BaseGameMenu, value); } + } + + public List pages + { + get { return (List) GetBaseFieldInfo("pages").GetValue(BaseGameMenu); } + set { GetBaseFieldInfo("pages").SetValue(BaseGameMenu, value); } + } + + public static SGameMenu ConstructFromBaseClass(GameMenu baseClass) + { + var s = new SGameMenu {BaseGameMenu = baseClass}; + return s; + } + + public override void receiveRightClick(int x, int y, bool playSound = true) + { + if (pages[currentTab] is InventoryPage) + { + Log.AsyncY("INV SCREEN"); + } + base.receiveRightClick(x, y, playSound); + } + + public static FieldInfo[] GetPrivateFields() + { + return typeof(GameMenu).GetFields(BindingFlags.Instance | BindingFlags.NonPublic); + } + + public static FieldInfo GetBaseFieldInfo(string name) + { + return typeof(GameMenu).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs b/src/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs new file mode 100644 index 00000000..436b834d --- /dev/null +++ b/src/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs @@ -0,0 +1,19 @@ +using StardewValley.Menus; + +namespace StardewModdingAPI.Inheritance.Menus +{ + public class SInventoryPage : InventoryPage + { + public SInventoryPage(int x, int y, int width, int height) : base(x, y, width, height) + { + } + + public InventoryPage BaseInventoryPage { get; private set; } + + public static SInventoryPage ConstructFromBaseClass(InventoryPage baseClass) + { + var s = new SInventoryPage(0, 0, 0, 0) {BaseInventoryPage = baseClass}; + return s; + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs b/src/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs new file mode 100644 index 00000000..f30021de --- /dev/null +++ b/src/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using StardewValley.Minigames; + +namespace StardewModdingAPI.Inheritance.Minigames +{ + internal abstract class SMinigameBase : IMinigame + { + public abstract bool tick(GameTime time); + + public abstract void receiveLeftClick(int x, int y, bool playSound = true); + + public abstract void leftClickHeld(int x, int y); + + public abstract void receiveRightClick(int x, int y, bool playSound = true); + + public abstract void releaseLeftClick(int x, int y); + + public abstract void releaseRightClick(int x, int y); + + public abstract void receiveKeyPress(Keys k); + + public abstract void receiveKeyRelease(Keys k); + + public abstract void draw(SpriteBatch b); + + public abstract void changeScreenSize(); + + public abstract void unload(); + + public abstract void receiveEventPoke(int data); + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Inheritance/SBareObject.cs b/src/StardewModdingAPI/Inheritance/SBareObject.cs new file mode 100644 index 00000000..5bef7b3e --- /dev/null +++ b/src/StardewModdingAPI/Inheritance/SBareObject.cs @@ -0,0 +1,20 @@ +namespace StardewModdingAPI.Inheritance +{ + public struct SBareObject + { + public int parentSheetIndex { get; set; } + public int stack { get; set; } + public bool isRecipe { get; set; } + public int price { get; set; } + public int quality { get; set; } + + public SBareObject(int psi, int sta, bool ir, int pri, int qua) + { + parentSheetIndex = psi; + stack = sta; + isRecipe = ir; + price = pri; + quality = qua; + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Inheritance/SGame.cs b/src/StardewModdingAPI/Inheritance/SGame.cs new file mode 100644 index 00000000..9b69434a --- /dev/null +++ b/src/StardewModdingAPI/Inheritance/SGame.cs @@ -0,0 +1,1726 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +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 +{ + /// + /// The 'SGame' class. + /// This summary, and many others, only exists because XML doc tags. + /// + public class SGame : Game1 + { + /// + /// Useless right now. + /// + public const int LowestModItemID = 1000; + + private bool FireLoadedGameEvent; + + /// + /// Gets a jagged array of all buttons pressed on the gamepad the prior frame. + /// + public Buttons[][] PreviouslyPressedButtons; + + internal SGame() + { + Instance = this; + FirstUpdate = true; + } + + /// + /// Useless at this time. + /// + [Obsolete] + // ReSharper disable once UnusedAutoPropertyAccessor.Local + public static Dictionary ModItems { get; private set; } + + /// + /// The current KeyboardState + /// + public KeyboardState KStateNow { get; private set; } + + /// + /// The prior KeyboardState + /// + public KeyboardState KStatePrior { get; private set; } + + /// + /// The current MouseState + /// + public MouseState MStateNow { get; private set; } + + /// + /// The prior MouseState + /// + public MouseState MStatePrior { get; private set; } + + /// + /// All keys pressed on the current frame + /// + public Keys[] CurrentlyPressedKeys => KStateNow.GetPressedKeys(); + + /// + /// All keys pressed on the prior frame + /// + public Keys[] PreviouslyPressedKeys => KStatePrior.GetPressedKeys(); + + /// + /// All keys pressed on this frame except for the ones pressed on the prior frame + /// + public Keys[] FramePressedKeys => CurrentlyPressedKeys.Except(PreviouslyPressedKeys).ToArray(); + + /// + /// All keys pressed on the prior frame except for the ones pressed on the current frame + /// + public Keys[] FrameReleasedKeys => PreviouslyPressedKeys.Except(CurrentlyPressedKeys).ToArray(); + + /// + /// Whether or not a save was tagged as 'Loaded' the prior frame. + /// + public bool PreviouslyLoadedGame { get; private set; } + + /// + /// The list of GameLocations on the prior frame + /// + public int PreviousGameLocations { get; private set; } + + /// + /// The list of GameObjects on the prior frame + /// + public int PreviousLocationObjects { get; private set; } + + /// + /// The list of Items in the player's inventory on the prior frame + /// + public Dictionary PreviousItems { get; private set; } + + /// + /// The player's Combat level on the prior frame + /// + public int PreviousCombatLevel { get; private set; } + + /// + /// The player's Farming level on the prior frame + /// + public int PreviousFarmingLevel { get; private set; } + + /// + /// The player's Fishing level on the prior frame + /// + public int PreviousFishingLevel { get; private set; } + + /// + /// The player's Foraging level on the prior frame + /// + public int PreviousForagingLevel { get; private set; } + + /// + /// The player's Mining level on the prior frame + /// + public int PreviousMiningLevel { get; private set; } + + /// + /// The player's Luck level on the prior frame + /// + public int PreviousLuckLevel { get; private set; } + + //Kill me now comments are so boring + + /// + /// The player's previous game location + /// + public GameLocation PreviousGameLocation { get; private set; } + + /// + /// The previous ActiveGameMenu in Game1 + /// + public IClickableMenu PreviousActiveMenu { get; private set; } + + /// + /// Indicates if the MenuClosed event was fired to prevent it from re-firing. + /// + internal bool WasMenuClosedInvoked = false; + + /// + /// The previous mine level + /// + public int PreviousMineLevel { get; private set; } + + /// + /// The previous TimeOfDay (Int32 between 600 and 2400?) + /// + public int PreviousTimeOfDay { get; private set; } + + /// + /// The previous DayOfMonth (Int32 between 1 and 28?) + /// + public int PreviousDayOfMonth { get; private set; } + + /// + /// The previous Season (String as follows: "winter", "spring", "summer", "fall") + /// + public string PreviousSeasonOfYear { get; private set; } + + /// + /// The previous Year + /// + public int PreviousYearOfGame { get; private set; } + + /// + /// The previous result of Game1.newDay + /// + public bool PreviousIsNewDay { get; private set; } + + /// + /// The previous 'Farmer' (Player) + /// + public Farmer PreviousFarmer { get; private set; } + + /// + /// The current index of the update tick. Recycles every 60th tick to 0. (Int32 between 0 and 59) + /// + public int CurrentUpdateTick { get; private set; } + + /// + /// Whether or not this update frame is the very first of the entire game + /// + public bool FirstUpdate { get; private set; } + + /// + /// The current RenderTarget in Game1 (Private field, uses reflection) + /// + public RenderTarget2D Screen + { + get { return typeof(Game1).GetBaseFieldValue(Program.gamePtr, "screen"); } + set { typeof(Game1).SetBaseFieldValue(this, "screen", value); } + } + + /// + /// The current Colour in Game1 (Private field, uses reflection) + /// + public Color BgColour + { + get { return (Color) typeof(Game1).GetBaseFieldValue(Program.gamePtr, "bgColor"); } + set { typeof(Game1).SetBaseFieldValue(this, "bgColor", value); } + } + + /// + /// Static accessor for an Instance of the class SGame + /// + public static SGame Instance { get; private set; } + + /// + /// The game's FPS. Re-determined every Draw update. + /// + public static float FramesPerSecond { get; private set; } + + /// + /// Whether or not we're in a pseudo 'debug' mode. Mostly for displaying information like FPS. + /// + public static bool Debug { get; private set; } + + internal static Queue DebugMessageQueue { get; private set; } + + /// + /// The current player (equal to Farmer.Player) + /// + [Obsolete("Use Farmer.Player instead")] + public Farmer CurrentFarmer => player; + + /// + /// Gets ALL static fields that belong to 'Game1' + /// + public static FieldInfo[] GetStaticFields => typeof(Game1).GetFields(); + + /// + /// Whether or not a button was just pressed on the controller + /// + /// + /// + /// + /// + private bool WasButtonJustPressed(Buttons button, ButtonState buttonState, PlayerIndex stateIndex) + { + return buttonState == ButtonState.Pressed && !PreviouslyPressedButtons[(int) stateIndex].Contains(button); + } + + /// + /// Whether or not a button was just released on the controller + /// + /// + /// + /// + /// + private bool WasButtonJustReleased(Buttons button, ButtonState buttonState, PlayerIndex stateIndex) + { + return buttonState == ButtonState.Released && PreviouslyPressedButtons[(int) stateIndex].Contains(button); + } + + /// + /// Whether or not an analog button was just pressed on the controller + /// + /// + /// + /// + /// + private bool WasButtonJustPressed(Buttons button, float value, PlayerIndex stateIndex) + { + return WasButtonJustPressed(button, value > 0.2f ? ButtonState.Pressed : ButtonState.Released, stateIndex); + } + + /// + /// Whether or not an analog button was just released on the controller + /// + /// + /// + /// + /// + private bool WasButtonJustReleased(Buttons button, float value, PlayerIndex stateIndex) + { + return WasButtonJustReleased(button, value > 0.2f ? ButtonState.Pressed : ButtonState.Released, stateIndex); + } + + /// + /// Gets an array of all Buttons pressed on a joystick + /// + /// + /// + public Buttons[] GetButtonsDown(PlayerIndex index) + { + var state = GamePad.GetState(index); + var buttons = new List(); + 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(); + } + + /// + /// Gets all buttons that were pressed on the current frame of a joystick + /// + /// + /// + public Buttons[] GetFramePressedButtons(PlayerIndex index) + { + var state = GamePad.GetState(index); + var buttons = new List(); + 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(); + } + + /// + /// Gets all buttons that were released on the current frame of a joystick + /// + /// + /// + public Buttons[] GetFrameReleasedButtons(PlayerIndex index) + { + var state = GamePad.GetState(index); + var buttons = new List(); + 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(); + } + + /// + /// + /// + public static MethodInfo DrawFarmBuildings = typeof(Game1).GetMethod("drawFarmBuildings", BindingFlags.NonPublic | BindingFlags.Instance); + + /// + /// + /// + public static MethodInfo DrawHUD = typeof(Game1).GetMethod("drawHUD", BindingFlags.NonPublic | BindingFlags.Instance); + + /// + /// + /// + 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(); + + /// + /// Whether or not the game's zoom level is 1.0f + /// + public bool ZoomLevelIsOne => options.zoomLevel.Equals(1.0f); + + /// + /// XNA Init Method + /// + protected override void Initialize() + { + Log.AsyncY("XNA Initialize"); + //ModItems = new Dictionary(); + DebugMessageQueue = new Queue(); + PreviouslyPressedButtons = new Buttons[4][]; + for (var i = 0; i < 4; ++i) PreviouslyPressedButtons[i] = new Buttons[0]; + + base.Initialize(); + GameEvents.InvokeInitialize(); + } + + /// + /// XNA LC Method + /// + protected override void LoadContent() + { + Log.AsyncY("XNA LoadContent"); + base.LoadContent(); + GameEvents.InvokeLoadContent(); + } + + /// + /// XNA Update Method + /// + /// + protected override void Update(GameTime gameTime) + { + QueueDebugMessage("FPS: " + FramesPerSecond); + UpdateEventCalls(); + + /* + if (ZoomLevelIsOne) + { + options.zoomLevel = 0.99f; + InvokeBasePrivateInstancedMethod("Window_ClientSizeChanged", null, null); + } + */ + + if (FramePressedKeys.Contains(Keys.F3)) + { + Debug = !Debug; + } + + if (FramePressedKeys.Contains(Keys.F2)) + { + //Built-in debug mode + debugMode = !debugMode; + } + + if (Constants.EnableCompletelyOverridingBaseCalls) + { + #region Overridden Update Call + + try + { + if (Program.BuildType == 0) + SteamHelper.update(); + if ((paused /*|| !this.IsActive*/) && (options == null || options.pauseWhenOutOfFocus || paused)) + return; + if (quit) + Exit(); + currentGameTime = gameTime; + if (gameMode != 11) + { + if (IsMultiplayer && gameMode == 3) + { + if (multiplayerMode == 2) + server.receiveMessages(); + else + client.receiveMessages(); + } + if (IsActive) + InvokeMethodInfo(CheckForEscapeKeys); + //InvokeBasePrivateInstancedMethod("checkForEscapeKeys"); + + //this.checkForEscapeKeys(); + updateMusic(); + updateRaindropPosition(); + bloom?.tick(gameTime); + if (globalFade) + { + if (!dialogueUp) + { + if (fadeIn) + { + fadeToBlackAlpha = Math.Max(0.0f, fadeToBlackAlpha - globalFadeSpeed); + if (fadeToBlackAlpha <= 0.0) + { + globalFade = false; + if (afterFade != null) + { + afterFadeFunction afterFadeFunction = afterFade; + afterFade(); + if (afterFade != null && afterFade.Equals(afterFadeFunction)) + afterFade = null; + if (nonWarpFade) + fadeToBlack = false; + } + } + } + else + { + fadeToBlackAlpha = Math.Min(1f, fadeToBlackAlpha + globalFadeSpeed); + if (fadeToBlackAlpha >= 1.0) + { + globalFade = false; + if (afterFade != null) + { + afterFadeFunction afterFadeFunction = afterFade; + afterFade(); + if (afterFade != null && afterFade.Equals(afterFadeFunction)) + afterFade = null; + if (nonWarpFade) + fadeToBlack = false; + } + } + } + } + else + InvokeMethodInfo(UpdateControlInput, gameTime); + //InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime); + //this.UpdateControlInput(gameTime); + } + else if (pauseThenDoFunctionTimer > 0) + { + freezeControls = true; + pauseThenDoFunctionTimer -= gameTime.ElapsedGameTime.Milliseconds; + if (pauseThenDoFunctionTimer <= 0) + { + freezeControls = false; + afterPause?.Invoke(); + } + } + if (gameMode == 3 || gameMode == 2) + { + player.millisecondsPlayed += (uint) gameTime.ElapsedGameTime.Milliseconds; + bool flag = true; + if (currentMinigame != null) + { + if (pauseTime > 0.0) + updatePause(gameTime); + if (fadeToBlack) + { + updateScreenFade(gameTime); + if (fadeToBlackAlpha >= 1.0) + fadeToBlack = false; + } + else + { + if (thumbstickMotionMargin > 0) + thumbstickMotionMargin -= gameTime.ElapsedGameTime.Milliseconds; + if (IsActive) + { + KeyboardState state1 = Keyboard.GetState(); + MouseState state2 = Mouse.GetState(); + GamePadState state3 = GamePad.GetState(PlayerIndex.One); + foreach (Keys keys in state1.GetPressedKeys()) + { + if (!oldKBState.IsKeyDown(keys)) + currentMinigame.receiveKeyPress(keys); + } + if (options.gamepadControls) + { + if (currentMinigame == null) + { + oldMouseState = state2; + oldKBState = state1; + oldPadState = state3; + return; + } + foreach (Buttons b in Utility.getPressedButtons(state3, oldPadState)) + currentMinigame.receiveKeyPress(Utility.mapGamePadButtonToKey(b)); + if (currentMinigame == null) + { + oldMouseState = state2; + oldKBState = state1; + oldPadState = state3; + return; + } + if (state3.ThumbSticks.Right.Y < -0.200000002980232 && oldPadState.ThumbSticks.Right.Y >= -0.200000002980232) + currentMinigame.receiveKeyPress(Keys.Down); + if (state3.ThumbSticks.Right.Y > 0.200000002980232 && oldPadState.ThumbSticks.Right.Y <= 0.200000002980232) + currentMinigame.receiveKeyPress(Keys.Up); + if (state3.ThumbSticks.Right.X < -0.200000002980232 && oldPadState.ThumbSticks.Right.X >= -0.200000002980232) + currentMinigame.receiveKeyPress(Keys.Left); + if (state3.ThumbSticks.Right.X > 0.200000002980232 && oldPadState.ThumbSticks.Right.X <= 0.200000002980232) + currentMinigame.receiveKeyPress(Keys.Right); + if (oldPadState.ThumbSticks.Right.Y < -0.200000002980232 && state3.ThumbSticks.Right.Y >= -0.200000002980232) + currentMinigame.receiveKeyRelease(Keys.Down); + if (oldPadState.ThumbSticks.Right.Y > 0.200000002980232 && state3.ThumbSticks.Right.Y <= 0.200000002980232) + currentMinigame.receiveKeyRelease(Keys.Up); + if (oldPadState.ThumbSticks.Right.X < -0.200000002980232 && state3.ThumbSticks.Right.X >= -0.200000002980232) + currentMinigame.receiveKeyRelease(Keys.Left); + if (oldPadState.ThumbSticks.Right.X > 0.200000002980232 && state3.ThumbSticks.Right.X <= 0.200000002980232) + currentMinigame.receiveKeyRelease(Keys.Right); + if (isGamePadThumbstickInMotion()) + { + setMousePosition(getMouseX() + (int) (state3.ThumbSticks.Left.X * 16.0), getMouseY() - (int) (state3.ThumbSticks.Left.Y * 16.0)); + lastCursorMotionWasMouse = false; + } + else if (getMousePosition().X != getOldMouseX() || getMousePosition().Y != getOldMouseY()) + lastCursorMotionWasMouse = true; + } + foreach (Keys keys in oldKBState.GetPressedKeys()) + { + if (!state1.IsKeyDown(keys)) + currentMinigame.receiveKeyRelease(keys); + } + if (options.gamepadControls) + { + if (currentMinigame == null) + { + oldMouseState = state2; + oldKBState = state1; + oldPadState = state3; + return; + } + if (state3.IsConnected && state3.IsButtonDown(Buttons.X) && !oldPadState.IsButtonDown(Buttons.X)) + currentMinigame.receiveRightClick(getMouseX(), getMouseY(), true); + else if (state3.IsConnected && state3.IsButtonDown(Buttons.A) && !oldPadState.IsButtonDown(Buttons.A)) + currentMinigame.receiveLeftClick(getMouseX(), getMouseY(), true); + else if (state3.IsConnected && !state3.IsButtonDown(Buttons.X) && oldPadState.IsButtonDown(Buttons.X)) + currentMinigame.releaseRightClick(getMouseX(), getMouseY()); + else if (state3.IsConnected && !state3.IsButtonDown(Buttons.A) && oldPadState.IsButtonDown(Buttons.A)) + currentMinigame.releaseLeftClick(getMouseX(), getMouseY()); + foreach (Buttons b in Utility.getPressedButtons(oldPadState, state3)) + currentMinigame.receiveKeyRelease(Utility.mapGamePadButtonToKey(b)); + if (state3.IsConnected && state3.IsButtonDown(Buttons.A)) + currentMinigame?.leftClickHeld(0, 0); + } + if (currentMinigame == null) + { + oldMouseState = state2; + oldKBState = state1; + oldPadState = state3; + return; + } + if (state2.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton != ButtonState.Pressed) + currentMinigame.receiveLeftClick(getMouseX(), getMouseY(), true); + if (state2.RightButton == ButtonState.Pressed && oldMouseState.RightButton != ButtonState.Pressed) + currentMinigame.receiveRightClick(getMouseX(), getMouseY(), true); + if (state2.LeftButton == ButtonState.Released && oldMouseState.LeftButton == ButtonState.Pressed) + currentMinigame.releaseLeftClick(getMouseX(), getMouseY()); + if (state2.RightButton == ButtonState.Released && oldMouseState.RightButton == ButtonState.Pressed) + currentMinigame.releaseLeftClick(getMouseX(), getMouseY()); + if (state2.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Pressed) + currentMinigame.leftClickHeld(getMouseX(), getMouseY()); + oldMouseState = state2; + oldKBState = state1; + oldPadState = state3; + } + if (currentMinigame != null && currentMinigame.tick(gameTime)) + { + currentMinigame.unload(); + currentMinigame = null; + fadeIn = true; + fadeToBlackAlpha = 1f; + return; + } + } + flag = IsMultiplayer; + } + else if (farmEvent != null && farmEvent.tickUpdate(gameTime)) + { + farmEvent.makeChangesToLocation(); + timeOfDay = 600; + UpdateOther(gameTime); + displayHUD = true; + farmEvent = null; + currentLocation = getLocationFromName("FarmHouse"); + player.position = Utility.PointToVector2(Utility.getHomeOfFarmer(player).getBedSpot()) * tileSize; + player.position.X -= tileSize; + changeMusicTrack("none"); + currentLocation.resetForPlayerEntry(); + player.forceCanMove(); + freezeControls = false; + displayFarmer = true; + outdoorLight = Color.White; + viewportFreeze = false; + fadeToBlackAlpha = 0.0f; + fadeToBlack = false; + globalFadeToClear(null, 0.02f); + player.mailForTomorrow.Clear(); + showEndOfNightStuff(); + } + if (flag) + { + if (endOfNightMenus.Count() > 0 && activeClickableMenu == null) + activeClickableMenu = endOfNightMenus.Pop(); + if (activeClickableMenu != null) + { + updateActiveMenu(gameTime); + } + else + { + if (pauseTime > 0.0) + updatePause(gameTime); + if (!globalFade && !freezeControls && (activeClickableMenu == null && IsActive)) + InvokeMethodInfo(UpdateControlInput, gameTime); + //InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime); + //this.UpdateControlInput(gameTime); + } + if (showingEndOfNightStuff && endOfNightMenus.Count() == 0 && activeClickableMenu == null) + { + showingEndOfNightStuff = false; + globalFadeToClear(playMorningSong, 0.02f); + } + if (!showingEndOfNightStuff) + { + if (IsMultiplayer || activeClickableMenu == null && currentMinigame == null) + UpdateGameClock(gameTime); + //this.UpdateCharacters(gameTime); + //this.UpdateLocations(gameTime); + //InvokeBasePrivateInstancedMethod("UpdateCharacters", gameTime); + //InvokeBasePrivateInstancedMethod("UpdateLocations", gameTime); + //UpdateViewPort(false, (Point)InvokeBasePrivateInstancedMethod("getViewportCenter")); + + InvokeMethodInfo(UpdateCharacters, gameTime); + InvokeMethodInfo(UpdateLocations, gameTime); + UpdateViewPort(false, (Point) InvokeMethodInfo(getViewportCenter)); + } + UpdateOther(gameTime); + if (messagePause) + { + KeyboardState state1 = Keyboard.GetState(); + MouseState state2 = Mouse.GetState(); + GamePadState state3 = GamePad.GetState(PlayerIndex.One); + if (isOneOfTheseKeysDown(state1, options.actionButton) && !isOneOfTheseKeysDown(oldKBState, options.actionButton)) + pressActionButton(state1, state2, state3); + oldKBState = state1; + oldPadState = state3; + } + } + } + else + { + //InvokeBasePrivateInstancedMethod("UpdateTitleScreen", gameTime); + InvokeMethodInfo(UpdateTitleScreen, gameTime); + //this.UpdateTitleScreen(gameTime); + if (activeClickableMenu != null) + updateActiveMenu(gameTime); + if (gameMode == 10) + UpdateOther(gameTime); + } + audioEngine?.Update(); + if (multiplayerMode == 2 && gameMode == 3) + server.sendMessages(gameTime); + } + } + catch (Exception ex) + { + Log.Error("An error occurred in the overridden update loop: " + ex); + } + + //typeof (Game).GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(this, new object[] {gameTime}); + //base.Update(gameTime); + + #endregion + } + else + { + 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); + } + } + + /// + /// XNA Draw Method + /// + /// + 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, BlendSta