From 583fb44f4c93a8cc647a0761d1671a035499d838 Mon Sep 17 00:00:00 2001 From: yangzhi <@4F!xZpJwly&KbWq> Date: Thu, 20 Feb 2020 11:39:13 +0800 Subject: [PATCH] Modify some ui position for Android --- SDVModTest/UIElements/ExperienceBar.cs | 9 +++++++ .../UIElements/ExperiencePointDisplay.cs | 13 ++++++++++ SDVModTest/UIElements/LuckOfDay.cs | 6 +++++ SDVModTest/UIElements/ShowBirthdayIcon.cs | 15 ++++++++++++ SDVModTest/UIElements/ShowQueenOfSauceIcon.cs | 24 +++++++++++++++++++ .../UIElements/ShowToolUpgradeStatus.cs | 12 ++++++++++ .../UIElements/ShowTravelingMerchant.cs | 13 ++++++++++ 7 files changed, 92 insertions(+) diff --git a/SDVModTest/UIElements/ExperienceBar.cs b/SDVModTest/UIElements/ExperienceBar.cs index 2e3a9af..7874ab4 100644 --- a/SDVModTest/UIElements/ExperienceBar.cs +++ b/SDVModTest/UIElements/ExperienceBar.cs @@ -519,6 +519,15 @@ namespace UIInfoSuite.UIElements { float leftSide = Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Left; + if(Constants.TargetPlatform == GamePlatform.Android) + { + if (this._helper.Reflection.GetField(Game1.options, "verticalToolbar", true).GetValue()) + { + Toolbar toolbar = this._helper.Reflection.GetField(typeof(Game1), "toolbar", true).GetValue(); + leftSide += this._helper.Reflection.GetField(typeof(Game1), "toolbarPaddingX", true).GetValue() + this._helper.Reflection.GetProperty(toolbar, "itemSlotSize", true).GetValue(); + } + } + if (Game1.isOutdoorMapSmallerThanViewport()) { int num3 = Game1.currentLocation.map.Layers[0].LayerWidth * Game1.tileSize; diff --git a/SDVModTest/UIElements/ExperiencePointDisplay.cs b/SDVModTest/UIElements/ExperiencePointDisplay.cs index d1b8c44..ee4e2ea 100644 --- a/SDVModTest/UIElements/ExperiencePointDisplay.cs +++ b/SDVModTest/UIElements/ExperiencePointDisplay.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using StardewModdingAPI; using StardewValley; using System; using System.Collections.Generic; @@ -24,6 +25,18 @@ namespace UIInfoSuite.UIElements { _position.Y -= 0.5f; --_alpha; + if(Constants.TargetPlatform == GamePlatform.Android) + { + Game1.drawWithBorder( + "Exp " + _experiencePoints, + Color.DarkSlateGray * ((float)_alpha / 100f), + Color.PaleTurquoise * ((float)_alpha / 100f), + new Vector2(_position.X - 28, _position.Y - 130) * Game1.options.zoomLevel, + 0.0f, + 0.8f, + 0.0f); + return; + } Game1.drawWithBorder( "Exp " + _experiencePoints, Color.DarkSlateGray * ((float)_alpha / 100f), diff --git a/SDVModTest/UIElements/LuckOfDay.cs b/SDVModTest/UIElements/LuckOfDay.cs index 6659512..a266095 100644 --- a/SDVModTest/UIElements/LuckOfDay.cs +++ b/SDVModTest/UIElements/LuckOfDay.cs @@ -85,6 +85,12 @@ namespace UIInfoSuite.UIElements private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text + if (Constants.TargetPlatform == GamePlatform.Android) + { + if (_icon.containsPoint((int)(Game1.getMouseX() * Game1.options.zoomLevel), (int)(Game1.getMouseY() * Game1.options.zoomLevel))) + IClickableMenu.drawHoverText(Game1.spriteBatch, _hoverText, Game1.dialogueFont); + return; + } if (_icon.containsPoint(Game1.getMouseX(), Game1.getMouseY())) IClickableMenu.drawHoverText(Game1.spriteBatch, _hoverText, Game1.dialogueFont); } diff --git a/SDVModTest/UIElements/ShowBirthdayIcon.cs b/SDVModTest/UIElements/ShowBirthdayIcon.cs index 33f08d7..f53751f 100644 --- a/SDVModTest/UIElements/ShowBirthdayIcon.cs +++ b/SDVModTest/UIElements/ShowBirthdayIcon.cs @@ -5,6 +5,7 @@ using StardewModdingAPI.Events; using StardewValley; using StardewValley.Menus; using System; +using StardewModdingAPI; namespace UIInfoSuite.UIElements { @@ -137,6 +138,20 @@ namespace UIInfoSuite.UIElements private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text + if (Constants.TargetPlatform == GamePlatform.Android) + { + if (_birthdayNPC != null && + (_birthdayIcon?.containsPoint((int)(Game1.getMouseX() * Game1.options.zoomLevel), (int)(Game1.getMouseY() * Game1.options.zoomLevel)) ?? false)) + { + String hoverText = String.Format("{0}'s Birthday", _birthdayNPC.Name); + IClickableMenu.drawHoverText( + Game1.spriteBatch, + hoverText, + Game1.dialogueFont); + } + return; + } + if (_birthdayNPC != null && (_birthdayIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { diff --git a/SDVModTest/UIElements/ShowQueenOfSauceIcon.cs b/SDVModTest/UIElements/ShowQueenOfSauceIcon.cs index c7109aa..478c144 100644 --- a/SDVModTest/UIElements/ShowQueenOfSauceIcon.cs +++ b/SDVModTest/UIElements/ShowQueenOfSauceIcon.cs @@ -192,6 +192,17 @@ namespace UIInfoSuite.UIElements texture.draw(Game1.spriteBatch); + if(Constants.TargetPlatform == GamePlatform.Android) + { + if (texture.containsPoint((int)(Game1.getMouseX() * Game1.options.zoomLevel), (int)(Game1.getMouseY() * Game1.options.zoomLevel))) + { + IClickableMenu.drawHoverText( + Game1.spriteBatch, + "Gus is selling " + Game1.dishOfTheDay.DisplayName + " recipe today!", + Game1.dialogueFont); + } + return; + } if (texture.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { IClickableMenu.drawHoverText( @@ -209,6 +220,19 @@ namespace UIInfoSuite.UIElements private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text + if (Constants.TargetPlatform == GamePlatform.Android) + { + if (_drawQueenOfSauceIcon && + _queenOfSauceIcon.containsPoint((int)(Game1.getMouseX() * Game1.options.zoomLevel), (int)(Game1.getMouseY() * Game1.options.zoomLevel))) + { + IClickableMenu.drawHoverText( + Game1.spriteBatch, + _helper.SafeGetString( + LanguageKeys.TodaysRecipe) + _todaysRecipe, + Game1.dialogueFont); + } + return; + } if (_drawQueenOfSauceIcon && _queenOfSauceIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { diff --git a/SDVModTest/UIElements/ShowToolUpgradeStatus.cs b/SDVModTest/UIElements/ShowToolUpgradeStatus.cs index 0debc5e..4573c8a 100644 --- a/SDVModTest/UIElements/ShowToolUpgradeStatus.cs +++ b/SDVModTest/UIElements/ShowToolUpgradeStatus.cs @@ -139,6 +139,18 @@ namespace UIInfoSuite.UIElements private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text + if (Constants.TargetPlatform == GamePlatform.Android) + { + if (_toolBeingUpgraded != null && + (_toolUpgradeIcon?.containsPoint((int)(Game1.getMouseX() * Game1.options.zoomLevel), (int)(Game1.getMouseY() * Game1.options.zoomLevel)) ?? false)) + { + IClickableMenu.drawHoverText( + Game1.spriteBatch, + _hoverText, Game1.dialogueFont); + } + return; + } + if (_toolBeingUpgraded != null && (_toolUpgradeIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { diff --git a/SDVModTest/UIElements/ShowTravelingMerchant.cs b/SDVModTest/UIElements/ShowTravelingMerchant.cs index a9f8cb5..8aa20af 100644 --- a/SDVModTest/UIElements/ShowTravelingMerchant.cs +++ b/SDVModTest/UIElements/ShowTravelingMerchant.cs @@ -79,6 +79,19 @@ namespace UIInfoSuite.UIElements private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text + if (Constants.TargetPlatform == GamePlatform.Android) + { + if (_travelingMerchantIsHere && (_travelingMerchantIcon?.containsPoint((int)(Game1.getMouseX() * Game1.options.zoomLevel), (int)(Game1.getMouseY() * Game1.options.zoomLevel)) ?? false)) + { + string hoverText = _helper.SafeGetString( + LanguageKeys.TravelingMerchantIsInTown); + IClickableMenu.drawHoverText( + Game1.spriteBatch, + hoverText, Game1.dialogueFont); + } + return; + } + if (_travelingMerchantIsHere && (_travelingMerchantIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { string hoverText = _helper.SafeGetString(