Adapt to SMAPI for Android

This commit is contained in:
yangzhi 2020-02-08 15:35:33 +08:00
parent a972062f5e
commit f3dfcc64ae
6 changed files with 21 additions and 18 deletions

View File

@ -31,7 +31,7 @@ namespace UIInfoSuite
int xPosition = (int)Tools.GetWidthInPlayArea() - 70 - 48 * _amountOfVisibleIcons; int xPosition = (int)Tools.GetWidthInPlayArea() - 70 - 48 * _amountOfVisibleIcons;
if (Game1.player.questLog.Any()) if (Game1.player.questLog.Any())
{ {
x -= 65; xPosition -= 65;
} }
++_amountOfVisibleIcons; ++_amountOfVisibleIcons;
return new Point(xPosition, yPos); return new Point(xPosition, yPos);

View File

@ -90,7 +90,8 @@ namespace UIInfoSuite
public static Item GetHoveredItem() public static Item GetHoveredItem()
{ {
Item hoverItem = null; Item hoverItem = null;
if (Game1.onScreenMenus != null)
{
for (int i = 0; i < Game1.onScreenMenus.Count; ++i) for (int i = 0; i < Game1.onScreenMenus.Count; ++i)
{ {
Toolbar onScreenMenu = Game1.onScreenMenus[i] as Toolbar; Toolbar onScreenMenu = Game1.onScreenMenus[i] as Toolbar;
@ -101,6 +102,7 @@ namespace UIInfoSuite
//hoverItemField.SetValue(onScreenMenu, null); //hoverItemField.SetValue(onScreenMenu, null);
} }
} }
}
if (Game1.activeClickableMenu is GameMenu gameMenu) if (Game1.activeClickableMenu is GameMenu gameMenu)
{ {

View File

@ -9,7 +9,6 @@ using StardewValley.Tools;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Media;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers; using System.Timers;
@ -46,7 +45,7 @@ namespace UIInfoSuite.UIElements
private bool _showLevelUpAnimation = true; private bool _showLevelUpAnimation = true;
private bool _showExperienceBar = true; private bool _showExperienceBar = true;
private readonly IModHelper _helper; private readonly IModHelper _helper;
private SoundPlayer _player; private object _player;
private LevelExtenderInterface _levelExtenderAPI; private LevelExtenderInterface _levelExtenderAPI;
@ -62,7 +61,7 @@ namespace UIInfoSuite.UIElements
try try
{ {
path = Path.Combine(_helper.DirectoryPath, "LevelUp.wav"); path = Path.Combine(_helper.DirectoryPath, "LevelUp.wav");
_player = new SoundPlayer(path); _player = Type.GetType("System.Media.SoundPlayer")?.GetConstructor(new Type[] { }).Invoke(new object[] { });
//path = path.Replace(Environment.CurrentDirectory, ""); //path = path.Replace(Environment.CurrentDirectory, "");
//path = path.TrimStart(Path.DirectorySeparatorChar); //path = path.TrimStart(Path.DirectorySeparatorChar);
//_soundEffect = SoundEffect.FromStream(TitleContainer.OpenStream(path)).CreateInstance(); //_soundEffect = SoundEffect.FromStream(TitleContainer.OpenStream(path)).CreateInstance();
@ -209,7 +208,7 @@ namespace UIInfoSuite.UIElements
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
Thread.Sleep(100); Thread.Sleep(100);
_player.Play(); Type.GetType("System.Media.SoundPlayer")?.GetMethod("Play").Invoke(this._player, new object[] { });
}); });
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>

View File

@ -215,7 +215,7 @@ namespace UIInfoSuite.UIElements
{ {
if (Game1.activeClickableMenu is GameMenu gameMenu) if (Game1.activeClickableMenu is GameMenu gameMenu)
{ {
if (gameMenu.currentTab == 3) if (gameMenu.currentTab == (Constants.TargetPlatform == GamePlatform.Android ? 4 : 3))
{ {
List<String> namesToShow = new List<string>(); List<String> namesToShow = new List<string>();
foreach (var character in _townsfolk) foreach (var character in _townsfolk)

View File

@ -42,7 +42,8 @@ namespace UIInfoSuite.UIElements
// draw shop harvest prices // draw shop harvest prices
if (Game1.activeClickableMenu is ShopMenu menu) if (Game1.activeClickableMenu is ShopMenu menu)
{ {
if (menu.hoveredItem is Item hoverItem) object item = _helper.Reflection.GetField<object>(menu, "hoveredItem").GetValue();
if (item is Item hoverItem)
{ {
String text = string.Empty; String text = string.Empty;
bool itemHasPriceInfo = Tools.GetTruePrice(hoverItem) > 0; bool itemHasPriceInfo = Tools.GetTruePrice(hoverItem) > 0;
@ -67,7 +68,8 @@ namespace UIInfoSuite.UIElements
text = " " + temp.Price; text = " " + temp.Price;
} }
var heldItem = menu.heldItem as Item; item = _helper.Reflection.GetField<object>(menu, "heldItem").GetValue();
var heldItem = item as Item;
if (heldItem == null) if (heldItem == null)
{ {
int value = 0; int value = 0;
@ -162,7 +164,7 @@ namespace UIInfoSuite.UIElements
getHoveredItemExtraItemIndex.Invoke<int>(new object[0]), getHoveredItemExtraItemIndex.Invoke<int>(new object[0]),
getHoveredItemExtraItemAmount.Invoke<int>(new object[0]), getHoveredItemExtraItemAmount.Invoke<int>(new object[0]),
null, null,
menu.hoverPrice); _helper.Reflection.GetField<Int32>(menu, "hoverPrice").GetValue());
} }
} }
} }

View File

@ -103,7 +103,7 @@ namespace UIInfoSuite.UIElements
} }
} }
String hoverText = gameMenu.hoverText; String hoverText = (string)gameMenu.GetType().GetField("hoverText", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)?.GetValue(gameMenu);
IClickableMenu.drawHoverText( IClickableMenu.drawHoverText(
Game1.spriteBatch, Game1.spriteBatch,
hoverText, hoverText,