Fixed calendar/billboard deleting items when you click on them while holding something on the mouse.

This commit is contained in:
cdaragorn 2018-05-20 22:24:04 -06:00
parent 68a2a760c1
commit b31dd223d8
3 changed files with 17 additions and 7 deletions

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.5.0")] [assembly: AssemblyVersion("1.7.6.0")]
[assembly: AssemblyFileVersion("1.7.5.0")] [assembly: AssemblyFileVersion("1.7.6.0")]

View File

@ -29,6 +29,7 @@ namespace UIInfoSuite.UIElements
private readonly IModHelper _helper; private readonly IModHelper _helper;
private Item _hoverItem = null; private Item _hoverItem = null;
private Item _heldItem = null;
public ShowCalendarAndBillboardOnGameMenuButton(IModHelper helper) public ShowCalendarAndBillboardOnGameMenuButton(IModHelper helper)
{ {
@ -40,20 +41,27 @@ namespace UIInfoSuite.UIElements
GraphicsEvents.OnPostRenderGuiEvent -= RenderButtons; GraphicsEvents.OnPostRenderGuiEvent -= RenderButtons;
ControlEvents.MouseChanged -= OnBillboardIconClick; ControlEvents.MouseChanged -= OnBillboardIconClick;
ControlEvents.ControllerButtonPressed -= OnBillboardIconPressed; ControlEvents.ControllerButtonPressed -= OnBillboardIconPressed;
GraphicsEvents.OnPreRenderEvent -= GetHoverItem; GameEvents.EighthUpdateTick -= GetHoverItem;
if (showCalendarAndBillboard) if (showCalendarAndBillboard)
{ {
GraphicsEvents.OnPostRenderGuiEvent += RenderButtons; GraphicsEvents.OnPostRenderGuiEvent += RenderButtons;
ControlEvents.MouseChanged += OnBillboardIconClick; ControlEvents.MouseChanged += OnBillboardIconClick;
ControlEvents.ControllerButtonPressed += OnBillboardIconPressed; ControlEvents.ControllerButtonPressed += OnBillboardIconPressed;
GraphicsEvents.OnPreRenderEvent += GetHoverItem; GameEvents.EighthUpdateTick += GetHoverItem;
} }
} }
private void GetHoverItem(object sender, EventArgs e) private void GetHoverItem(object sender, EventArgs e)
{ {
_hoverItem = Tools.GetHoveredItem(); _hoverItem = Tools.GetHoveredItem();
if (Game1.activeClickableMenu is GameMenu gameMenu)
{
List<IClickableMenu> menuList = typeof(GameMenu).GetField("pages", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Game1.activeClickableMenu) as List<IClickableMenu>;
if (menuList[0] is InventoryPage inventory)
_heldItem = typeof(InventoryPage).GetField("heldItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(inventory) as Item;
}
} }
private void OnBillboardIconPressed(object sender, EventArgsControllerButtonPressed e) private void OnBillboardIconPressed(object sender, EventArgsControllerButtonPressed e)
@ -79,7 +87,8 @@ namespace UIInfoSuite.UIElements
{ {
if (Game1.activeClickableMenu is GameMenu && if (Game1.activeClickableMenu is GameMenu &&
(Game1.activeClickableMenu as GameMenu).currentTab == 0 && (Game1.activeClickableMenu as GameMenu).currentTab == 0 &&
_showBillboardButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) _showBillboardButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())
&& _heldItem == null)
{ {
if (Game1.questOfTheDay != null && if (Game1.questOfTheDay != null &&
String.IsNullOrEmpty(Game1.questOfTheDay.currentObjective)) String.IsNullOrEmpty(Game1.questOfTheDay.currentObjective))
@ -95,7 +104,8 @@ namespace UIInfoSuite.UIElements
{ {
if (_hoverItem == null && if (_hoverItem == null &&
Game1.activeClickableMenu is GameMenu && Game1.activeClickableMenu is GameMenu &&
(Game1.activeClickableMenu as GameMenu).currentTab == 0) (Game1.activeClickableMenu as GameMenu).currentTab == 0
&& _heldItem == null)
{ {
_showBillboardButton.bounds.X = Game1.activeClickableMenu.xPositionOnScreen + Game1.activeClickableMenu.width - 160; _showBillboardButton.bounds.X = Game1.activeClickableMenu.xPositionOnScreen + Game1.activeClickableMenu.width - 160;

View File

@ -1,7 +1,7 @@
{ {
"Name": "UI Info Suite", "Name": "UI Info Suite",
"Author": "Cdaragorn", "Author": "Cdaragorn",
"Version": "1.7.5", "Version": "1.7.6",
"Description": "Adds a lot of useful information to the user interface. This is based on Demiacle's excellent UIModSuite.", "Description": "Adds a lot of useful information to the user interface. This is based on Demiacle's excellent UIModSuite.",
"UniqueID": "Cdaragorn.UiInfoSuite", "UniqueID": "Cdaragorn.UiInfoSuite",
"EntryDll": "UIInfoSuite.dll", "EntryDll": "UIInfoSuite.dll",