Skip to content

Commit 9f53601

Browse files
authored
Merge pull request #635 from drewhoener/djh/legacy-master
Version update v2.3.7 for Stardew 1.6.14
2 parents f4bfe9b + 2801e6d commit 9f53601

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

UIInfoSuite2/Infrastructure/Tools.cs

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using StardewValley.GameData.FruitTrees;
1010
using StardewValley.Menus;
1111
using StardewValley.TerrainFeatures;
12+
using StardewValley.WorldMaps;
1213
using SObject = StardewValley.Object;
1314

1415
namespace UIInfoSuite2.Infrastructure;
@@ -303,4 +304,11 @@ public static IEnumerable<int> GetDaysFromCondition(GameStateQuery.ParsedGameSta
303304

304305
return days.Count == 0 ? null : days.Max();
305306
}
307+
308+
public static MapAreaPosition? GetMapPositionDataSafe(GameLocation location, Point position)
309+
{
310+
MapAreaPosition? mapAreaPosition = WorldMapManager.GetPositionData(location, position)?.Data;
311+
312+
return mapAreaPosition ?? WorldMapManager.GetPositionData(Game1.getFarm(), Point.Zero)?.Data;
313+
}
306314
}

UIInfoSuite2/UIElements/LocationOfTownsfolk.cs

+16-14
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void OnUpdateTicked(object? sender, UpdateTickedEventArgs e)
117117
{
118118
foreach (NPC? character in loc.characters)
119119
{
120-
if (character.isVillager())
120+
if (character.IsVillager)
121121
{
122122
_townsfolk.Add(character);
123123
}
@@ -311,13 +311,18 @@ private static void DrawNPC(NPC character, List<string> namesToShow)
311311
}
312312

313313
Rectangle headShot = character.GetHeadShot();
314-
MapAreaPosition? mapPosition =
315-
WorldMapManager.GetPositionData(
316-
Game1.player.currentLocation,
317-
new Point((int)location.Value.X, (int)location.Value.Y)
318-
) ??
319-
WorldMapManager.GetPositionData(Game1.getFarm(), Point.Zero);
320-
MapRegion? mapRegion = mapPosition.Region;
314+
MapAreaPosition? mapPosition = Tools.GetMapPositionDataSafe(
315+
Game1.player.currentLocation,
316+
new Point((int)location.Value.X, (int)location.Value.Y)
317+
);
318+
319+
if (mapPosition is null)
320+
{
321+
ModEntry.MonitorObject.LogOnce($"Unable to draw headshot for {character.Name}");
322+
return;
323+
}
324+
325+
MapRegion mapRegion = mapPosition.Region;
321326
Rectangle mapBounds = mapRegion.GetMapPixelBounds();
322327
var offsetLocation = new Vector2(
323328
location.Value.X + mapBounds.X - headShot.Width,
@@ -356,21 +361,18 @@ private static void DrawNPC(NPC character, List<string> namesToShow)
356361
private static Vector2? GetMapCoordinatesForNPC(NPC character)
357362
{
358363
var playerNormalizedTile = new Point(Math.Max(0, Game1.player.TilePoint.X), Math.Max(0, Game1.player.TilePoint.Y));
359-
MapAreaPosition playerMapAreaPosition =
360-
WorldMapManager.GetPositionData(Game1.player.currentLocation, playerNormalizedTile) ??
361-
WorldMapManager.GetPositionData(Game1.getFarm(), Point.Zero);
364+
MapAreaPosition? playerMapAreaPosition = Tools.GetMapPositionDataSafe(Game1.player.currentLocation, playerNormalizedTile);
362365
// ^^ Regarding that ?? clause... If the player is in the farmhouse or barn or any building on the farm, GetPositionData is
363366
// going to return null. Thus the fallback to pretending the player is on the farm. However, it seems to me that
364367
// Game1.player.currentLocation.GetParentLocation() would be the safer long-term bet. But rule number 1 of modding is this:
365368
// the game code is always right, even when it's wrong.
366369

367370
var characterNormalizedTile = new Point(Math.Max(0, character.TilePoint.X), Math.Max(0, character.TilePoint.Y));
368-
MapAreaPosition characterMapAreaPosition =
369-
WorldMapManager.GetPositionData(character.currentLocation, characterNormalizedTile);
371+
MapAreaPosition? characterMapAreaPosition = Tools.GetMapPositionDataSafe(character.currentLocation, characterNormalizedTile);
370372

371373
if (playerMapAreaPosition != null &&
372374
characterMapAreaPosition != null &&
373-
!(characterMapAreaPosition.Region.Id != playerMapAreaPosition.Region.Id))
375+
characterMapAreaPosition.Region.Id == playerMapAreaPosition.Region.Id)
374376
{
375377
return characterMapAreaPosition.GetMapPixelPosition(character.currentLocation, characterNormalizedTile);
376378
}

UIInfoSuite2/UIInfoSuite2.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<Version>2.3.6</Version>
3+
<Version>2.3.7</Version>
44
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ModZipPath>$(SolutionDir)\Releases</ModZipPath>
@@ -18,8 +18,8 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.1.1"/>
22-
<PackageReference Include="Pathoschild.Stardew.ModTranslationClassBuilder" Version="2.0.1"/>
21+
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.3.2" />
22+
<PackageReference Include="Pathoschild.Stardew.ModTranslationClassBuilder" Version="2.2.0" />
2323
</ItemGroup>
2424

2525
<Import Project="UIInfoSuite2.csproj.local" Condition="Exists('UIInfoSuite2.csproj.local')"/>

UIInfoSuite2/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Name": "UI Info Suite 2",
33
"Author": "Annosz",
4-
"Version": "2.3.6",
4+
"Version": "2.3.7",
55
"Description": "Adds a useful information to the user interface. Based on Cdaragorn's excellent UI Info Suite.",
66
"UniqueID": "Annosz.UiInfoSuite2",
77
"EntryDll": "UIInfoSuite2.dll",

0 commit comments

Comments
 (0)