summaryrefslogtreecommitdiff
path: root/StardewModdingAPI/Inheritance
diff options
context:
space:
mode:
Diffstat (limited to 'StardewModdingAPI/Inheritance')
-rw-r--r--StardewModdingAPI/Inheritance/SGame.cs1318
1 files changed, 701 insertions, 617 deletions
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs
index 434f8341..ccd3846c 100644
--- a/StardewModdingAPI/Inheritance/SGame.cs
+++ b/StardewModdingAPI/Inheritance/SGame.cs
@@ -2,6 +2,7 @@
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;
@@ -207,8 +208,8 @@ namespace StardewModdingAPI.Inheritance
/// </summary>
public int ThumbstickMotionMargin
{
- get { return (int)typeof(Game1).GetBaseFieldValue<object>(Program.gamePtr, "thumbstickMotionMargin"); }
- set { typeof(Game1).SetBaseFieldValue<object>(this, "thumbstickMotionMargin", value); }
+ get { return (int)typeof(Game1).GetField("thumbstickMotionMargin", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); }
+ set { typeof(Game1).GetField("thumbstickMotionMargin", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, value); }
}
/// <summary>
@@ -392,6 +393,35 @@ namespace StardewModdingAPI.Inheritance
}
/// <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);
@@ -430,11 +460,13 @@ namespace StardewModdingAPI.Inheritance
QueueDebugMessage("FPS: " + FramesPerSecond);
UpdateEventCalls();
- /*if (ZoomLevelIsOne)
+ /*
+ if (ZoomLevelIsOne)
{
options.zoomLevel = 0.99f;
InvokeBasePrivateInstancedMethod("Window_ClientSizeChanged", null, null);
- }*/
+ }
+ */
if (FramePressedKeys.Contains(Keys.F3))
{
@@ -451,160 +483,185 @@ namespace StardewModdingAPI.Inheritance
{
#region Overridden Update Call
- if (Program.BuildType == 0)
- SteamHelper.update();
- if ((paused /*|| !this.IsActive*/) && (options == null || options.pauseWhenOutOfFocus || paused))
- return;
- if (quit)
- Exit();
- currentGameTime = gameTime;
- if (gameMode != 11)
+ try
{
- if (IsMultiplayer && gameMode == 3)
+ 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 (multiplayerMode == 2)
- server.receiveMessages();
- else
- client.receiveMessages();
- }
- if (IsActive)
- InvokeBasePrivateInstancedMethod("checkForEscapeKeys");
+ if (IsMultiplayer && gameMode == 3)
+ {
+ if (multiplayerMode == 2)
+ server.receiveMessages();
+ else
+ client.receiveMessages();
+ }
+ if (IsActive)
+ InvokeMethodInfo(CheckForEscapeKeys);
+ //InvokeBasePrivateInstancedMethod("checkForEscapeKeys");
+
//this.checkForEscapeKeys();
- updateMusic();
- updateRaindropPosition();
- if (bloom != null)
- bloom.tick(gameTime);
- if (globalFade)
- {
- if (!dialogueUp)
+ updateMusic();
+ updateRaindropPosition();
+ if (bloom != null)
+ bloom.tick(gameTime);
+ if (globalFade)
{
- if (fadeIn)
+ if (!dialogueUp)
{
- fadeToBlackAlpha = Math.Max(0.0f, fadeToBlackAlpha - globalFadeSpeed);
- if (fadeToBlackAlpha <= 0.0)
+ if (fadeIn)
{
- globalFade = false;
- if (afterFade != null)
+ fadeToBlackAlpha = Math.Max(0.0f, fadeToBlackAlpha - globalFadeSpeed);
+ if (fadeToBlackAlpha <= 0.0)
{
- afterFadeFunction afterFadeFunction = afterFade;
- afterFade();
- if (afterFade != null && afterFade.Equals(afterFadeFunction))
- afterFade = null;
- if (nonWarpFade)
- fadeToBlack = false;
+ 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)
+ else
{
- globalFade = false;
- if (afterFade != null)
+ fadeToBlackAlpha = Math.Min(1f, fadeToBlackAlpha + globalFadeSpeed);
+ if (fadeToBlackAlpha >= 1.0)
{
- afterFadeFunction afterFadeFunction = afterFade;
- afterFade();
- if (afterFade != null && afterFade.Equals(afterFadeFunction))
- afterFade = null;
- if (nonWarpFade)
- fadeToBlack = false;
+ 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
- InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
- //this.UpdateControlInput(gameTime);
- }
- else if (pauseThenDoFunctionTimer > 0)
- {
- freezeControls = true;
- pauseThenDoFunctionTimer -= gameTime.ElapsedGameTime.Milliseconds;
- if (pauseThenDoFunctionTimer <= 0)
- {
- freezeControls = false;
- if (afterPause != null)
- afterPause();
- }
- }
- if (gameMode == 3 || gameMode == 2)
- {
- player.millisecondsPlayed += (uint)gameTime.ElapsedGameTime.Milliseconds;
- bool flag = true;
- if (currentMinigame != null)
+ else if (pauseThenDoFunctionTimer > 0)
{
- if (pauseTime > 0.0)
- updatePause(gameTime);
- if (fadeToBlack)
+ freezeControls = true;
+ pauseThenDoFunctionTimer -= gameTime.ElapsedGameTime.Milliseconds;
+ if (pauseThenDoFunctionTimer <= 0)
{
- updateScreenFade(gameTime);
- if (fadeToBlackAlpha >= 1.0)
- fadeToBlack = false;
+ freezeControls = false;
+ if (afterPause != null)
+ afterPause();
}
- else
+ }
+ if (gameMode == 3 || gameMode == 2)
+ {
+ player.millisecondsPlayed += (uint) gameTime.ElapsedGameTime.Milliseconds;
+ bool flag = true;
+ if (currentMinigame != null)
{
- if (ThumbstickMotionMargin > 0)
- ThumbstickMotionMargin -= gameTime.ElapsedGameTime.Milliseconds;
- if (IsActive)
+ if (pauseTime > 0.0)
+ updatePause(gameTime);
+ if (fadeToBlack)
{
- 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)
+ updateScreenFade(gameTime);
+ if (fadeToBlackAlpha >= 1.0)
+ fadeToBlack = false;
+ }
+ else
+ {
+ if (ThumbstickMotionMargin > 0)
+ ThumbstickMotionMargin -= gameTime.ElapsedGameTime.Milliseconds;
+ if (IsActive)
{
- if (currentMinigame == null)
+ KeyboardState state1 = Keyboard.GetState();
+ MouseState state2 = Mouse.GetState();
+ GamePadState state3 = GamePad.GetState(PlayerIndex.One);
+ foreach (Keys keys in state1.GetPressedKeys())
{
- oldMouseState = state2;
- oldKBState = state1;
- oldPadState = state3;
- return;
+ if (!oldKBState.IsKeyDown(keys))
+ currentMinigame.receiveKeyPress(keys);
}
- foreach (Buttons b in Utility.getPressedButtons(state3, oldPadState))
- currentMinigame.receiveKeyPress(Utility.mapGamePadButtonToKey(b));
- if (currentMinigame == null)
+ if (options.gamepadControls)
{
- oldMouseState = state2;
- oldKBState = state1;
- oldPadState = state3;
- return;
+ 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;
}
- 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())
+ foreach (Keys keys in oldKBState.GetPressedKeys())
{
- setMousePosition(getMouseX() + (int)(state3.ThumbSticks.Left.X * 16.0), getMouseY() - (int)(state3.ThumbSticks.Left.Y * 16.0));
- lastCursorMotionWasMouse = false;
+ 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 != null)
+ currentMinigame.leftClickHeld(0, 0);
}
- 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;
@@ -612,131 +669,122 @@ namespace StardewModdingAPI.Inheritance
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))
+ if (state2.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton != ButtonState.Pressed)
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))
+ 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());
- foreach (Buttons b in Utility.getPressedButtons(oldPadState, state3))
- currentMinigame.receiveKeyRelease(Utility.mapGamePadButtonToKey(b));
- if (state3.IsConnected && state3.IsButtonDown(Buttons.A) && currentMinigame != null)
- currentMinigame.leftClickHeld(0, 0);
- }
- if (currentMinigame == null)
- {
+ 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;
}
- 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))
+ 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)
{
- currentMinigame.unload();
- currentMinigame = null;
- fadeIn = true;
- fadeToBlackAlpha = 1f;
- return;
+ 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;
}
}
- 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)
+ else
{
- if (endOfNightMenus.Count() > 0 && activeClickableMenu == null)
- activeClickableMenu = endOfNightMenus.Pop();
+ //InvokeBasePrivateInstancedMethod("UpdateTitleScreen", gameTime);
+ InvokeMethodInfo(UpdateTitleScreen, gameTime);
+ //this.UpdateTitleScreen(gameTime);
if (activeClickableMenu != null)
- {
updateActiveMenu(gameTime);
- }
- else
- {
- if (pauseTime > 0.0)
- updatePause(gameTime);
- if (!globalFade && !freezeControls && (activeClickableMenu == null && IsActive))
- 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"));
- }
- 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;
- }
+ if (gameMode == 10)
+ UpdateOther(gameTime);
}
+ if (audioEngine != null)
+ audioEngine.Update();
+ if (multiplayerMode == 2 && gameMode == 3)
+ server.sendMessages(gameTime);
}
- else
- {
- InvokeBasePrivateInstancedMethod("UpdateTitleScreen", gameTime);
- //this.UpdateTitleScreen(gameTime);
- if (activeClickableMenu != null)
- updateActiveMenu(gameTime);
- if (gameMode == 10)
- UpdateOther(gameTime);
- }
- if (audioEngine != null)
- 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});
@@ -807,464 +855,480 @@ namespace StardewModdingAPI.Inheritance
{
#region Overridden Draw
- if (!ZoomLevelIsOne)
- {
- GraphicsDevice.SetRenderTarget(Screen);
- }
-
- GraphicsDevice.Clear(BgColour);
- if (options.showMenuBackground && activeClickableMenu != null && activeClickableMenu.showWithoutTransparencyIfOptionIsSet())
+ try
{
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- activeClickableMenu.drawBackground(spriteBatch);
- activeClickableMenu.draw(spriteBatch);
- 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();
+ GraphicsDevice.SetRenderTarget(Screen);
}
- 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))
+
+ GraphicsDevice.Clear(BgColour);
+ if (options.showMenuBackground && activeClickableMenu != null && activeClickableMenu.showWithoutTransparencyIfOptionIsSet())
{
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Black * ((gameMode