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); } } } diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs index a629407e..5abf7f7d 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -43,9 +43,13 @@ namespace StardewModdingAPI.Metadata // rewrite for crossplatform compatibility yield return new MethodParentRewriter(typeof(SpriteBatch), typeof(SpriteBatchMethods), onlyIfPlatformChanged: true); - //isRaining and isDebrisWeather fix 75% done. - yield return new TypeFieldToAnotherTypeFieldRewriter(typeof(Game1), typeof(RainManager), "isRaining", "Instance", this.Monitor); - yield return new TypeFieldToAnotherTypeFieldRewriter(typeof(Game1), typeof(WeatherDebrisManager), "isDebrisWeather", "Instance", this.Monitor); + //isRaining and isDebrisWeather fix done. + yield return new TypeFieldToAnotherTypePropertyRewriter(typeof(Game1), typeof(Game1Methods), "isRaining", "IsRainingProp"); + yield return new TypeFieldToAnotherTypePropertyRewriter(typeof(Game1), typeof(Game1Methods), "isDebrisWeather", "IsDebrisWeatherProp"); + + // Cause of System.Security.VerificationException : Invalid instruction target + //yield return new TypeFieldToAnotherTypeFieldRewriter(typeof(Game1), typeof(RainManager), "isRaining", "Instance", this.Monitor); + //yield return new TypeFieldToAnotherTypeFieldRewriter(typeof(Game1), typeof(WeatherDebrisManager), "isDebrisWeather", "Instance", this.Monitor); yield return new TypeFieldToAnotherTypeFieldRewriter(typeof(GameLocation), typeof(DebrisManager), "debris", "Instance", this.Monitor, "debrisNetCollection", false); yield return new TypeFieldToAnotherTypeFieldRewriter(typeof(Game1), typeof(WeatherDebrisManager), "debrisWeather", "Instance", this.Monitor, "weatherDebrisList"); yield return new TypeFieldToAnotherTypeFieldRewriter(typeof(Game1), typeof(Game1Methods), "rainDrops", "Instance", this.Monitor, null, false, true);