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,10 +70,21 @@ namespace UIInfoSuite.UIElements
if (!e.IsMultipleOf(4)) if (!e.IsMultipleOf(4))
return; return;
// check draw tile outlines if (_mutex.WaitOne())
_effectiveArea.Clear(); {
try
{
// check draw tile outlines
_effectiveArea.Clear();
}
finally
{
_mutex.ReleaseMutex();
}
}
if (Game1.activeClickableMenu == null && if (Game1.activeClickableMenu == null &&
!Game1.eventUp) !Game1.eventUp)
{ {
if (Game1.currentLocation is BuildableGameLocation buildableLocation) if (Game1.currentLocation is BuildableGameLocation buildableLocation)
{ {
@ -126,7 +140,7 @@ namespace UIInfoSuite.UIElements
{ {
arrayToUse = _modConfig.QualitySprinkler; arrayToUse = _modConfig.QualitySprinkler;
} }
else if (name.Contains("prismatic")) else if (name.Contains("prismatic"))
{ {
arrayToUse = _modConfig.PrismaticSprinkler; arrayToUse = _modConfig.PrismaticSprinkler;
} }
@ -153,10 +167,10 @@ namespace UIInfoSuite.UIElements
{ {
arrayToUse = _modConfig.QualitySprinkler; arrayToUse = _modConfig.QualitySprinkler;
} }
else if (name.Contains("prismatic")) else if (name.Contains("prismatic"))
{ {
arrayToUse = _modConfig.PrismaticSprinkler; arrayToUse = _modConfig.PrismaticSprinkler;
} }
else else
{ {
arrayToUse = _modConfig.Sprinkler; arrayToUse = _modConfig.Sprinkler;
@ -174,6 +188,7 @@ 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>
@ -181,30 +196,51 @@ namespace UIInfoSuite.UIElements
/// <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)
{ {
// draw tile outlines if (_mutex.WaitOne(0))
foreach (Point point in _effectiveArea) {
Game1.spriteBatch.Draw( try
Game1.mouseCursors, {
Game1.GlobalToLocal(new Vector2(point.X * Game1.tileSize, point.Y * Game1.tileSize)), // draw tile outlines
new Rectangle(194, 388, 16, 16), foreach (Point point in _effectiveArea)
Color.White * 0.7f, Game1.spriteBatch.Draw(
0.0f, Game1.mouseCursors,
Vector2.Zero, Game1.GlobalToLocal(new Vector2(point.X * Game1.tileSize, point.Y * Game1.tileSize)),
Game1.pixelZoom, new Rectangle(194, 388, 16, 16),
SpriteEffects.None, Color.White * 0.7f,
0.01f); 0.0f,
Vector2.Zero,
Game1.pixelZoom,
SpriteEffects.None,
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;
for (int i = 0; i < highlightedLocation.Length; ++i)
if (_mutex.WaitOne())
{ {
int yOffset = highlightedLocation[i].Length / 2; try
for (int j = 0; j < highlightedLocation[i].Length; ++j)
{ {
if (highlightedLocation[i][j] == 1) for (int i = 0; i < highlightedLocation.Length; ++i)
_effectiveArea.Add(new Point(xPos + i - xOffset, yPos + j - yOffset)); {
int yOffset = highlightedLocation[i].Length / 2;
for (int j = 0; j < highlightedLocation[i].Length; ++j)
{
if (highlightedLocation[i][j] == 1)
_effectiveArea.Add(new Point(xPos + i - xOffset, yPos + j - yOffset));
}
}
}
finally
{
_mutex.ReleaseMutex();
} }
} }
} }

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",