From 304885a1015dacf82d84702fe9345d9ac5432d78 Mon Sep 17 00:00:00 2001 From: yangzhi <@4F!xZpJwly&KbWq> Date: Fri, 14 Feb 2020 20:09:18 +0800 Subject: [PATCH] 1.Fix isRaining and isDebrisWeather. 2.Fix a critical error of SpriteTextMethods.getWidthOfString (infinite self recursion) --- .../Framework/RewriteFacades/Game1Methods.cs | 24 +++++++++++++++++++ .../RewriteFacades/SpriteTextMethods.cs | 6 ++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/SMAPI/Framework/RewriteFacades/Game1Methods.cs b/src/SMAPI/Framework/RewriteFacades/Game1Methods.cs index e6744e78..3e2578d1 100644 --- a/src/SMAPI/Framework/RewriteFacades/Game1Methods.cs +++ b/src/SMAPI/Framework/RewriteFacades/Game1Methods.cs @@ -12,6 +12,30 @@ namespace StardewModdingAPI.Framework.RewriteFacades public static RainDrop[] rainDrops => (typeof(RainManager).GetField("_rainDropList", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(RainManager.Instance) as List).ToArray(); public static new IList onScreenMenus => Game1.onScreenMenus; + public static bool IsRainingProp + { + get + { + return RainManager.Instance.isRaining; + } + set + { + RainManager.Instance.isRaining = value; + } + } + + public static bool IsDebrisWeatherProp + { + get + { + return WeatherDebrisManager.Instance.isDebrisWeather; + } + set + { + WeatherDebrisManager.Instance.isDebrisWeather = value; + } + } + public static void updateDebrisWeatherForMovement(List debris) { WeatherDebrisManager.Instance.UpdateDebrisWeatherForMovement(); diff --git a/src/SMAPI/Framework/RewriteFacades/SpriteTextMethods.cs b/src/SMAPI/Framework/RewriteFacades/SpriteTextMethods.cs index 06fba8a1..f8580058 100644 --- a/src/SMAPI/Framework/RewriteFacades/SpriteTextMethods.cs +++ b/src/SMAPI/Framework/RewriteFacades/SpriteTextMethods.cs @@ -11,12 +11,12 @@ namespace StardewModdingAPI.Framework.RewriteFacades { public static int getWidthOfString(string s, int widthConstraint = 999999) { - return getWidthOfString(s); + return SpriteText.getWidthOfString(s); } public static void drawStringHorizontallyCenteredAt(SpriteBatch b, string s, int x, int y, int characterPosition = 999999, int width = -1, int height = 999999, float alpha = -1f, float layerDepth = 0.088f, bool junimoText = false, int color = -1, int maxWdith = 99999) { - drawString(b, s, x - SpriteText.getWidthOfString(s) / 2, y, characterPosition, width, height, alpha, layerDepth, junimoText, -1, "", color); + SpriteText.drawString(b, s, x - SpriteText.getWidthOfString(s) / 2, y, characterPosition, width, height, alpha, layerDepth, junimoText, -1, "", color); } public static void drawStringWithScrollBackground(SpriteBatch b, string s, int x, int y, string placeHolderWidthText = "", float alpha = 1f, int color = -1, SpriteText.ScrollTextAlignment scroll_text_alignment = SpriteText.ScrollTextAlignment.Left) @@ -26,7 +26,7 @@ namespace StardewModdingAPI.Framework.RewriteFacades public static void drawStringWithScrollBackground(SpriteBatch b, string s, int x, int y, string placeHolderWidthText, float alpha, int color) { - drawStringWithScrollBackground(b, s, x, y, placeHolderWidthText, alpha, color, 0.088f); + SpriteText.drawStringWithScrollBackground(b, s, x, y, placeHolderWidthText, alpha, color, 0.088f); } } }