Skip to content

Commit

Permalink
Quick bug fixes and button sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Dannode36 committed Aug 27, 2024
1 parent 841b177 commit c923361
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ public override void Entry(IModHelper helper)
dumpAllButton = new(helper.ModContent.Load<Texture2D>("assets/dumpButton.png"), new(0, 0, 16, 16))
{
BoxDraw = false,
Tooltip = "Dump All"
Tooltip = "Dump All",
HoveredSound = string.Empty,
ClickedSound = "Ship"
};
root.AddChild(dumpAllButton);

stealAllButton = new(helper.ModContent.Load<Texture2D>("assets/stealButton.png"), new(0, 0, 16, 16))
{
BoxDraw = false,
Tooltip = "Take All"
Tooltip = "Take All",
HoveredSound = string.Empty,
ClickedSound = "Ship"
};
root.AddChild(stealAllButton);
}
Expand Down Expand Up @@ -68,33 +72,35 @@ private void OnMenuChanged(object? sender, MenuChangedEventArgs e)
activeItemGrabMenu = itemGrabmenu;
stealAllButton.Callback = (e) =>
{
int log_grabMenuItemCount = itemGrabmenu.ItemsToGrabMenu.actualInventory.Count;
var grabableInv = itemGrabmenu.ItemsToGrabMenu.actualInventory;
for (int i = 0; i < grabableInv.Count; i++)
{
grabableInv[i] = Game1.player.addItemToInventory(grabableInv[i]);
}
Monitor.Log($"{Game1.player.Name} used TakeAll on {itemGrabmenu.context.GetType().Name}. {itemGrabmenu.ItemsToGrabMenu.actualInventory.Count} -> {Game1.player.Items}");
Monitor.Log($"{Game1.player.Name} used TakeAll on {itemGrabmenu.context.GetType().Name}. {log_grabMenuItemCount} -> {Game1.player.Items.CountItemStacks()}");
};

dumpAllButton.Callback = (e) =>
{
int log_playerItemCount = Game1.player.Items.CountItemStacks();
var playerInv = itemGrabmenu.inventory.actualInventory;

for (int i = 0; i < playerInv.Count; i++)
{
playerInv[i] = itemGrabmenu.ItemsToGrabMenu.tryToAddItem(playerInv[i]);
playerInv[i] = itemGrabmenu.ItemsToGrabMenu.tryToAddItem(playerInv[i], string.Empty);

//Weird af fix
//Probably due to Stardew skipping slots if actualInventory is smaller than
//the Grab Menu's actual capacity when using tryToAddItem
if (playerInv[i] != null && playerInv[i].Stack != 0 && itemGrabmenu.ItemsToGrabMenu.actualInventory.Count < itemGrabmenu.ItemsToGrabMenu.capacity)
{
itemGrabmenu.ItemsToGrabMenu.actualInventory.Add(null);
playerInv[i] = itemGrabmenu.ItemsToGrabMenu.tryToAddItem(playerInv[i]);
playerInv[i] = itemGrabmenu.ItemsToGrabMenu.tryToAddItem(playerInv[i], string.Empty);
}
}

Monitor.Log($"{Game1.player.Name} used DumpAll on {itemGrabmenu.context.GetType().Name}. {Game1.player.Items} -> {itemGrabmenu.ItemsToGrabMenu.actualInventory.Count}");
Monitor.Log($"{Game1.player.Name} used DumpAll on {itemGrabmenu.context.GetType().Name}. {Game1.player.Items.CountItemStacks()} -> {itemGrabmenu.ItemsToGrabMenu.actualInventory.Count}");
};

RepositionButtons();
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Valley Chests",
"Author": "Dannode36",
"Version": "0.1.0",
"Version": "1.0.0",
"Description": "",
"UniqueID": "Dannode36.ValleyChests",
"EntryDll": "ValleyChests.dll",
Expand Down

0 comments on commit c923361

Please sign in to comment.