Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for SDV 1.6 #2

Open
wants to merge 23 commits into
base: tqdv-2.2.10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
49be3ef
Make it build in 1.6 using SMAPI rules
SteveBenz Nov 30, 2023
ccfd73b
Builds under 1.6. Running... well...
SteveBenz Nov 30, 2023
2bae9d6
Fixed recipe display
SteveBenz Nov 30, 2023
560a128
Merge commit '752ab945892f27d9d18a57fae0785eb1950fe442' into alpha (f…
SteveBenz Dec 1, 2023
e7fc462
Fix the patch for spring onions
SteveBenz Dec 2, 2023
ab61576
Fix fruit tree harvest data for realsies. Hopefully.
SteveBenz Dec 4, 2023
052fec5
Hacky patch to get animal produce icon to show up
SteveBenz Dec 4, 2023
99e534f
Legit? fix for showing milk icons above cows
SteveBenz Dec 4, 2023
64f2b7d
Fix how bundle membership is calculated to use Qualified Item ID rath…
SteveBenz Dec 4, 2023
af31983
Fix partial heart displays
SteveBenz Dec 6, 2023
9bc3191
Better fix for partial hearts
SteveBenz Dec 6, 2023
f944a27
Made the same fix from ShowPartialHearts to the similar code in ShowT…
SteveBenz Dec 7, 2023
3304eeb
Fix sprinkler-in-hand highlighting
SteveBenz Dec 7, 2023
539bb35
Added unmilled rice and translations.
KryptoST Dec 7, 2023
0e966d9
Merge pull request #1 from KryptoST/alpha
NermNermNerm Dec 7, 2023
2d56d7d
Fix new-object-qualified-id warning
SteveBenz Dec 26, 2023
dcb587e
Fix null check
SteveBenz Dec 26, 2023
d40752c
Fix exception thrown when on loading screen
SteveBenz Dec 27, 2023
d03ef56
Fix null warnings in preparation for GI map surgery
SteveBenz Dec 27, 2023
87e78f6
More tidying
SteveBenz Dec 27, 2023
96047fd
Works pretty well, but it looks like the Island code could work for a…
SteveBenz Dec 28, 2023
fe5ae0d
Map works correctly
SteveBenz Dec 28, 2023
3559207
Fixes to bring it up to date with latest 1.6 SDV release
SteveBenz Feb 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SDV Build
_releases/

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
Expand Down
20 changes: 20 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- common build settings -->
<PropertyGroup>
<Authors>NermNermNerm</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/NermNermNerm/StardewMods</RepositoryUrl>
<RepositoryType>git</RepositoryType>

<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ModZipPath>$(SolutionDir)\_releases</ModZipPath>
</PropertyGroup>

<!-- mod build package -->
<ItemGroup>
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.1.1" />
</ItemGroup>
</Project>
6 changes: 0 additions & 6 deletions UIInfoSuite2.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A}.Debug|x86.ActiveCfg = Debug|x86
{B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A}.Debug|x86.Build.0 = Debug|x86
{B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A}.Release|Any CPU.Build.0 = Release|Any CPU
{B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A}.Release|x86.ActiveCfg = Release|x86
{B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
65 changes: 34 additions & 31 deletions UIInfoSuite2/Compatibility/DynamicGameAssetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,52 +66,55 @@ private void OnDayEnding(object? sender, DayEndingEventArgs e)
private class DgaFakeIdRetriever
{
private DynamicGameAssetsHelper DgaHelper { get; init; }
private bool? deterministicHashCodeIsCorrect = null;

public DgaFakeIdRetriever(DynamicGameAssetsHelper dgaHelper)
{
this.DgaHelper = dgaHelper;
}

public int GetId(SObject dgaItem)
{
if (deterministicHashCodeIsCorrect == null)
{
int hashedId = this.GetIdByDeterministicHashCode(dgaItem);
int shippedId = this.GetIdByShippingIt(dgaItem);
deterministicHashCodeIsCorrect = (hashedId == shippedId);
public string GetId(SObject dgaItem)
{
// TODO 1.6 -- I'm assuming this deterministic hash code thing was some shenanigans to deal with not having a unique ID
return dgaItem.ItemId;
//if (deterministicHashCodeIsCorrect == null)
//{
// int hashedId = this.GetIdByDeterministicHashCode(dgaItem);
// string shippedId = this.GetIdByShippingIt(dgaItem);
// deterministicHashCodeIsCorrect = (hashedId == shippedId);

if ((bool) deterministicHashCodeIsCorrect)
DgaHelper.Monitor.Log($"{this.GetType().Name}: The GetDeterministicHashCode implementation seems to be correct", LogLevel.Trace);
else
DgaHelper.Monitor.Log($"{this.GetType().Name}: The GetDeterministicHashCode implementation seems to be incorrect. Processing DGA items will be slower.", LogLevel.Info);

return shippedId;
}
else if (deterministicHashCodeIsCorrect == true)
{
return this.GetIdByDeterministicHashCode(dgaItem);
}
else
{
return this.GetIdByShippingIt(dgaItem);
}
// if ((bool) deterministicHashCodeIsCorrect)
// DgaHelper.Monitor.Log($"{this.GetType().Name}: The GetDeterministicHashCode implementation seems to be correct", LogLevel.Trace);
// else
// DgaHelper.Monitor.Log($"{this.GetType().Name}: The GetDeterministicHashCode implementation seems to be incorrect. Processing DGA items will be slower.", LogLevel.Info);

// return shippedId;
//}
//else if (deterministicHashCodeIsCorrect == true)
//{
// return this.GetIdByDeterministicHashCode(dgaItem);
//}
//else
//{
// return this.GetIdByShippingIt(dgaItem);
//}
}

private int GetIdByDeterministicHashCode(SObject dgaItem)
private string GetIdByDeterministicHashCode(SObject dgaItem)
{
return this.GetDeterministicHashCode(DgaHelper.GetFullId(dgaItem)!);
// TODO 1.6 -- I'm assuming this deterministic hash code thing was some shenanigans to deal with not having a unique ID
return dgaItem.ItemId;
//return this.GetDeterministicHashCode(DgaHelper.GetFullId(dgaItem)!);
}

private int GetIdByShippingIt(SObject dgaItem)
private string GetIdByShippingIt(SObject dgaItem)
{
DgaHelper.Monitor.Log($"{this.GetType().Name}: Retrieving the fake DGA item ID for {dgaItem.Name} by shipping it.", LogLevel.Trace);

var shippingMenu = new StardewValley.Menus.ShippingMenu(new List<Item>());

// Record previous state
uint oldCropsShipped = Game1.stats.CropsShipped;
var oldBasicShipped = new Dictionary<int, int>(Game1.player.basicShipped.FieldDict.Select(x => KeyValuePair.Create(x.Key, x.Value.Value)));
var oldBasicShipped = new Dictionary<string, int>(Game1.player.basicShipped.FieldDict.Select(x => KeyValuePair.Create(x.Key, x.Value.Value)));

// Ship the item to observe side-effects
shippingMenu.parseItems(new List<Item>{ dgaItem });
Expand All @@ -121,7 +124,7 @@ private int GetIdByShippingIt(SObject dgaItem)
var basicShipped = Game1.player.basicShipped;

// Find the new item
List<int> newItems = new();
List<string> newItems = new();
foreach (var shipped in basicShipped.Keys)
{
if (oldBasicShipped.TryGetValue(shipped, out int oldValue))
Expand Down Expand Up @@ -175,9 +178,9 @@ private int GetDeterministicHashCode(string str)
return modFind.Invoke<object?>(fullId);
}

public int GetDgaObjectFakeId(SObject dgaItem)
public string GetDgaObjectFakeId(SObject dgaItem)
{
return DgaFakeId.GetId(dgaItem);
return dgaItem.ItemId;
}

#region DGA instance fields, methods and properties
Expand Down Expand Up @@ -252,7 +255,7 @@ public int GetDgaObjectFakeId(SObject dgaItem)
if (dropItemType == "DGAItem")
return (StardewValley.Object) this.Api.SpawnDGAItem(dropItemValue);
else if (dropItemType == "VanillaItem")
return new StardewValley.Object(int.Parse(dropItemValue), 1);
return new StardewValley.Object(dropItemValue, 1);
else
throw new Exception("Harvest types other than DGAItem and VanillaItem are not supported");
}
Expand Down
49 changes: 14 additions & 35 deletions UIInfoSuite2/Infrastructure/Tools.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
using System;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
using StardewValley;
using StardewValley.GameData.Crops;
using StardewValley.Menus;
using StardewValley.TerrainFeatures;
using SObject = StardewValley.Object;

namespace UIInfoSuite2.Infrastructure
{
public static class Tools
{
public static void CreateSafeDelayedDialogue(string dialogue, int timer)
{
Task.Factory.StartNew(() =>
{
Thread.Sleep(timer);

do
{
Thread.Sleep(TimeSpan.FromSeconds(1));
}
while (Game1.activeClickableMenu is GameMenu);
Game1.setDialogue(dialogue, true);
});
}

public static int GetWidthInPlayArea()
{
if (Game1.isOutdoorMapSmallerThanViewport())
Expand Down Expand Up @@ -59,13 +47,13 @@ public static int GetSellToStorePrice(Item item)
public static SObject? GetHarvest(Item item)
{
if (item is SObject seedsObject
&& seedsObject.Category == StardewValley.Object.SeedsCategory
&& seedsObject.ParentSheetIndex != Crop.mixedSeedIndex)
&& seedsObject.Category == SObject.SeedsCategory
&& seedsObject.ItemId != Crop.mixedSeedsId)
{
if (seedsObject.isSapling())
if (seedsObject.IsFruitTreeSapling() && FruitTree.TryGetData(item.ItemId, out var fruitTreeData))
{
var tree = new StardewValley.TerrainFeatures.FruitTree(seedsObject.ParentSheetIndex);
return new SObject(tree.indexOfFruit.Value, 1);
// TODO 1.6: It looks like 1.6 supports the idea of fruit tree having more than one kind of fruit.
return ItemRegistry.Create<SObject>(fruitTreeData.Fruit[0].ItemId);
}
else if (ModEntry.DGA.IsCustomObject(item, out var dgaHelper))
{
Expand All @@ -89,14 +77,13 @@ public static int GetSellToStorePrice(Item item)
return null;
}
}
else
else if (Crop.TryGetData(item.ItemId, out CropData cropData) && cropData.HarvestItemId is not null)
{
var crop = new Crop(seedsObject.ParentSheetIndex, 0, 0);
return new SObject(crop.indexOfHarvest.Value, 1);
return ItemRegistry.Create<SObject>(cropData.HarvestItemId);
}
} else {
return null;
}

return null;
}

public static int GetHarvestPrice(Item item)
Expand Down Expand Up @@ -130,20 +117,12 @@ public static void DrawMouseCursor()

if (Game1.activeClickableMenu == null && Game1.onScreenMenus != null)
{
foreach (var menu in Game1.onScreenMenus)
{
if (menu is Toolbar toolbar)
{
FieldInfo hoverItemField = typeof(Toolbar).GetField("hoverItem", BindingFlags.Instance | BindingFlags.NonPublic);
hoverItem = hoverItemField.GetValue(toolbar) as Item;
}
}
hoverItem = Game1.onScreenMenus.OfType<Toolbar>().Select(tb => tb.hoverItem).Where(hi => hi is not null).FirstOrDefault();
}

if (Game1.activeClickableMenu is GameMenu gameMenu && gameMenu.GetCurrentPage() is InventoryPage inventory)
{
FieldInfo hoveredItemField = typeof(InventoryPage).GetField("hoveredItem", BindingFlags.Instance | BindingFlags.NonPublic);
hoverItem = hoveredItemField.GetValue(inventory) as Item;
hoverItem = inventory.hoveredItem;
}

if (Game1.activeClickableMenu is ItemGrabMenu itemMenu)
Expand Down
20 changes: 10 additions & 10 deletions UIInfoSuite2/Options/ModOptionsPageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,17 @@ private void OnGameMenuTabChanged(GameMenu? gameMenu)
{
// Update the downNeighborID for our tab
// Based on GameMenu.setTabNeighborsForCurrentPage
switch (gameMenu.currentTab)
if (gameMenu.currentTab == GameMenu.inventoryTab)
{
case GameMenu.inventoryTab:
_modOptionsTab.Value.downNeighborID = downNeighborInInventory;
break;
case GameMenu.exitTab:
_modOptionsTab.Value.downNeighborID = 535;
break;
default:
_modOptionsTab.Value.downNeighborID = ClickableComponent.SNAP_TO_DEFAULT;
break;
_modOptionsTab.Value.downNeighborID = downNeighborInInventory;
}
else if (gameMenu.currentTab == GameMenu.exitTab)
{
_modOptionsTab.Value.downNeighborID = 535;
}
else
{
_modOptionsTab.Value.downNeighborID = ClickableComponent.SNAP_TO_DEFAULT;
}

AddOurTabToClickableComponents(gameMenu, _modOptionsTab.Value);
Expand Down
Loading