Some bug fixes.

This commit is contained in:
cdaragorn 2019-11-26 23:12:29 -07:00
parent 459fd8124f
commit d31f1a0827
6 changed files with 73 additions and 30 deletions

View File

@ -34,6 +34,7 @@ namespace UIInfoSuite
helper.Events.GameLoop.Saved += OnSaved; helper.Events.GameLoop.Saved += OnSaved;
helper.Events.GameLoop.ReturnedToTitle += OnReturnedToTitle; helper.Events.GameLoop.ReturnedToTitle += OnReturnedToTitle;
helper.Events.Display.Rendering += IconHandler.Handler.Reset; helper.Events.Display.Rendering += IconHandler.Handler.Reset;
helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;
//Resources = new ResourceManager("UIInfoSuite.Resource.strings", Assembly.GetAssembly(typeof(ModEntry))); //Resources = new ResourceManager("UIInfoSuite.Resource.strings", Assembly.GetAssembly(typeof(ModEntry)));
//try //try
@ -47,6 +48,11 @@ namespace UIInfoSuite
//} //}
} }
private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
{
}
/// <summary>Raised after the game returns to the title screen.</summary> /// <summary>Raised after the game returns to the title screen.</summary>
/// <param name="sender">The event sender.</param> /// <param name="sender">The event sender.</param>
private void OnReturnedToTitle(object sender, ReturnedToTitleEventArgs e) private void OnReturnedToTitle(object sender, ReturnedToTitleEventArgs e)

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.8.0.0")] [assembly: AssemblyVersion("1.8.3.0")]
[assembly: AssemblyFileVersion("1.8.0.0")] [assembly: AssemblyFileVersion("1.8.3.0")]

View File

@ -6,6 +6,7 @@ using StardewValley.Buildings;
using StardewValley.Locations; using StardewValley.Locations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace UIInfoSuite.UIElements namespace UIInfoSuite.UIElements
{ {
@ -15,6 +16,8 @@ namespace UIInfoSuite.UIElements
private readonly ModConfig _modConfig; private readonly ModConfig _modConfig;
private readonly IModEvents _events; private readonly IModEvents _events;
private readonly Mutex _mutex = new Mutex();
private static readonly int[][] _junimoHutArray = new int[17][] private static readonly int[][] _junimoHutArray = new int[17][]
{ {
new int[17] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, new int[17] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
@ -67,8 +70,19 @@ namespace UIInfoSuite.UIElements
if (!e.IsMultipleOf(4)) if (!e.IsMultipleOf(4))
return; return;
if (_mutex.WaitOne())
{
try
{
// check draw tile outlines // check draw tile outlines
_effectiveArea.Clear(); _effectiveArea.Clear();
}
finally
{
_mutex.ReleaseMutex();
}
}
if (Game1.activeClickableMenu == null && if (Game1.activeClickableMenu == null &&
!Game1.eventUp) !Game1.eventUp)
{ {
@ -174,12 +188,17 @@ namespace UIInfoSuite.UIElements
} }
} }
} }
/// <summary>Raised after the game draws to the sprite patch in a draw tick, just before the final sprite batch is rendered to the screen.</summary> /// <summary>Raised after the game draws to the sprite patch in a draw tick, just before the final sprite batch is rendered to the screen.</summary>
/// <param name="sender">The event sender.</param> /// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param> /// <param name="e">The event arguments.</param>
private void OnRendered(object sender, RenderedEventArgs e) private void OnRendered(object sender, RenderedEventArgs e)
{
if (_mutex.WaitOne(0))
{
try
{ {
// draw tile outlines // draw tile outlines
foreach (Point point in _effectiveArea) foreach (Point point in _effectiveArea)
@ -194,10 +213,21 @@ namespace UIInfoSuite.UIElements
SpriteEffects.None, SpriteEffects.None,
0.01f); 0.01f);
} }
finally
{
_mutex.ReleaseMutex();
}
}
}
private void ParseConfigToHighlightedArea(int[][] highlightedLocation, int xPos, int yPos) private void ParseConfigToHighlightedArea(int[][] highlightedLocation, int xPos, int yPos)
{ {
int xOffset = highlightedLocation.Length / 2; int xOffset = highlightedLocation.Length / 2;
if (_mutex.WaitOne())
{
try
{
for (int i = 0; i < highlightedLocation.Length; ++i) for (int i = 0; i < highlightedLocation.Length; ++i)
{ {
int yOffset = highlightedLocation[i].Length / 2; int yOffset = highlightedLocation[i].Length / 2;
@ -208,6 +238,12 @@ namespace UIInfoSuite.UIElements
} }
} }
} }
finally
{
_mutex.ReleaseMutex();
}
}
}
private int TileUnderMouseX private int TileUnderMouseX
{ {

View File

@ -139,7 +139,8 @@ namespace UIInfoSuite.UIElements
private void OnRenderedHud(object sender, RenderedHudEventArgs e) private void OnRenderedHud(object sender, RenderedHudEventArgs e)
{ {
// draw hover text // draw hover text
if (_toolBeingUpgraded != null && _toolUpgradeIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY())) if (_toolBeingUpgraded != null &&
(_toolUpgradeIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false))
{ {
IClickableMenu.drawHoverText( IClickableMenu.drawHoverText(
Game1.spriteBatch, Game1.spriteBatch,

View File

@ -79,7 +79,7 @@ namespace UIInfoSuite.UIElements
private void OnRenderedHud(object sender, RenderedHudEventArgs e) private void OnRenderedHud(object sender, RenderedHudEventArgs e)
{ {
// draw hover text // draw hover text
if (_travelingMerchantIsHere && _travelingMerchantIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY())) if (_travelingMerchantIsHere && (_travelingMerchantIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false))
{ {
string hoverText = _helper.SafeGetString( string hoverText = _helper.SafeGetString(
LanguageKeys.TravelingMerchantIsInTown); LanguageKeys.TravelingMerchantIsInTown);

View File

@ -1,7 +1,7 @@
{ {
"Name": "UI Info Suite", "Name": "UI Info Suite",
"Author": "Cdaragorn", "Author": "Cdaragorn",
"Version": "1.8.0", "Version": "1.8.3",
"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",