More inventory fixes

This commit is contained in:
2024-09-10 00:09:53 -07:00
parent b5798e7bc0
commit 086370987c
18 changed files with 373 additions and 63 deletions

View File

@@ -58,8 +58,8 @@ public partial class InventoryMenu : Control, IInventoryMenu
public void PopulateItems()
{
PopulatePlayerInfo();
PopulateInventory();
PopulatePlayerInfo();
}
public void PopulatePlayerInfo()
@@ -102,13 +102,9 @@ public partial class InventoryMenu : Control, IInventoryMenu
if (ItemSlots.Any())
{
ItemDescriptionTitle.Text = $"{ItemSlots.ElementAtOrDefault(_currentIndex).Item.Info.Name}";
ItemEffectLabel.Text = $"{ItemSlots.ElementAtOrDefault(_currentIndex).Item.Info.Description}";
}
else
{
ItemDescriptionTitle.Text = string.Empty;
ItemEffectLabel.Text = string.Empty;
var item = ItemSlots.ElementAt(_currentIndex).Item;
ItemDescriptionTitle.Text = $"{item.Info.Name}";
ItemEffectLabel.Text = $"{item.Info.Description}";
}
}
@@ -187,6 +183,9 @@ public partial class InventoryMenu : Control, IInventoryMenu
oldItem.SetEquippedItemStyle();
if (newItem.Item is IEquipable newEquipable && GameRepo.IsItemEquipped(newEquipable))
newItem.SetEquippedSelectedItemStyle();
ItemDescriptionTitle.Text = $"{newItem.Item.Info.Name}";
ItemEffectLabel.Text = $"{newItem.Item.Info.Description}";
}
if (ItemSlots.Any() && Input.IsActionJustPressed(GameInputs.UiUp))
@@ -204,6 +203,8 @@ public partial class InventoryMenu : Control, IInventoryMenu
oldItem.SetEquippedItemStyle();
if (newItem.Item is IEquipable newEquipable && GameRepo.IsItemEquipped(newEquipable))
newItem.SetEquippedSelectedItemStyle();
ItemDescriptionTitle.Text = $"{newItem.Item.Info.Name}";
ItemEffectLabel.Text = $"{newItem.Item.Info.Description}";
}
if (ItemSlots.Any() && Input.IsActionJustPressed(GameInputs.UiAccept))
@@ -221,6 +222,11 @@ public partial class InventoryMenu : Control, IInventoryMenu
GameRepo.EquipItem(equipableItem);
itemSlot.SetEquippedSelectedItemStyle();
}
var atkBonus = GameRepo.PlayerStatInfo.Value.BonusAttack;
ATKBonusLabel.Text = atkBonus != 0 ? $"{atkBonus:+0;-#}" : "...";
var defBonus = GameRepo.PlayerStatInfo.Value.BonusDefense;
DEFBonusLabel.Text = defBonus != 0 ? $"{defBonus:+0;-#}" : "...";
}
}
}