Rework item descriptions, fix item rescue menu

This commit is contained in:
2026-02-18 02:41:22 -08:00
parent d39524ffe2
commit 104b9cf25e
172 changed files with 1336 additions and 915 deletions

View File

@@ -19,10 +19,18 @@ public partial class InventoryMenu : Control, IInventoryMenu
[Node] public Label ItemName { get; set; }
[Node] public Label ItemType { get; set; }
[Node] public Label ItemParameter { get; set; }
[Node] public Label ItemFlavor { get; set; }
[Node] public Label ItemStats { get; set; }
[Node] public Label ItemAugment { get; set; }
[Node] public TextureRect ItemAugmentTexture { get; set; }
[Node] public ActionPanel ActionPanel { get; set; }
[Node] public VBoxContainer Inventory { get; set; }
@@ -63,19 +71,13 @@ public partial class InventoryMenu : Control, IInventoryMenu
Hide();
}
private void EquipmentChanged(IEquipableItem obj)
{
AttackChanged(0);
DefenseChanged(0);
}
private void AttackChanged(int obj) => PlayerATKLabel.Text = $"{_player.AttackComponent.CurrentAttack.Value:D2}/{_player.AttackComponent.MaximumAttack.Value:D2}+{_player.EquipmentComponent.BonusAttack}";
private void DefenseChanged(int obj) => PlayerDEFLabel.Text = $"{_player.DefenseComponent.CurrentDefense.Value:D2}/{_player.DefenseComponent.MaximumDefense.Value:D2}+{_player.EquipmentComponent.BonusDefense}";
public override void _Input(InputEvent @event)
{
var validSelectableItems = _player.Inventory.Items.Except(_player.Inventory.Items.OfType<IEquipableItem>().Where(x => x.Glued)).ToList();
var validSelectableItems = _player.Inventory.Items.ToList();
if (Input.IsActionJustPressed(GameInputs.MoveUp) && _currentlySelected != null && _currentlySelected.Item.Value != validSelectableItems.First())
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
@@ -114,7 +116,15 @@ public partial class InventoryMenu : Control, IInventoryMenu
{
_currentlySelected = selectedItem;
ItemName.Text = selectedItem.Item.Value.ItemName;
ItemFlavor.Text = selectedItem.Item.Value.Description;
ItemType.Text = SetItemTypeName(selectedItem.Item.Value);
ItemParameter.Text = GetItemParameterText(selectedItem.Item.Value);
ItemParameter.Visible = !string.IsNullOrEmpty(ItemParameter.Text);
ItemFlavor.Text = selectedItem.Item.Value.FlavorText;
ItemFlavor.Visible = !string.IsNullOrEmpty(ItemFlavor.Text);
ItemStats.Text = selectedItem.Item.Value.StatDescription;
ItemStats.Visible = !string.IsNullOrEmpty(ItemStats.Text);
ItemAugmentTexture.Texture = null;
ItemAugment.Text = GetAugmentText(selectedItem.Item.Value);
}
private void ResetInventoryState()
@@ -126,15 +136,13 @@ public partial class InventoryMenu : Control, IInventoryMenu
for (var i = 0; i < inventory.Count; i++)
ItemSlots[i].SetItemToSlot(inventory[i]);
var validSelectableItems = inventory.Except(inventory.OfType<IEquipableItem>().Where(x => x.Glued)).ToList();
if (_currentlySelected != null && !validSelectableItems.Contains(_currentlySelected.Item.Value))
if (_currentlySelected != null && !inventory.Contains(_currentlySelected.Item.Value))
_currentlySelected = null;
if (_currentlySelected == null && validSelectableItems.Count > 0)
_currentlySelected = ItemSlots.FirstOrDefault(x => x.Item.Value == validSelectableItems.First());
if (_currentlySelected == null && inventory.Count > 0)
_currentlySelected = ItemSlots.FirstOrDefault(x => x.Item.Value == inventory.First());
if (validSelectableItems.Count > 0)
if (inventory.Count > 0)
_currentlySelected.FocusItem();
ActionPanel.Hide();
}
@@ -142,8 +150,12 @@ public partial class InventoryMenu : Control, IInventoryMenu
private void ClearDescriptionBox()
{
ItemName.Text = string.Empty;
ItemFlavor.Text = string.Empty;
ItemType.Text = string.Empty;
ItemParameter.Text = string.Empty;
ItemStats.Text = string.Empty;
ItemFlavor.Text = string.Empty;
ItemAugment.Text = string.Empty;
ItemAugmentTexture.Texture = null;
}
private void ActionPanel_ActionPanelClosing()
@@ -166,4 +178,52 @@ public partial class InventoryMenu : Control, IInventoryMenu
AugmentMenu.Hide();
ResetInventoryState();
}
private void EquipmentChanged(IEquipableItem obj)
{
AttackChanged(0);
DefenseChanged(0);
}
private static string GetItemParameterText(IBaseInventoryItem item)
{
if (item is Weapon potentiallyProjectile && (potentiallyProjectile.WeaponTag == WeaponTag.KineticProjectile || potentiallyProjectile.WeaponTag == WeaponTag.ElementalProjectile))
return string.Empty;
return item switch
{
Weapon weapon => $"ATK: {(weapon.ItemTag == ItemTag.MysteryItem ? "???" : weapon.BonusAttack)}",
Armor armor => $"DEF: {(armor.ItemTag == ItemTag.MysteryItem ? "???" : armor.BonusDefense)}",
_ => string.Empty,
};
}
private string GetAugmentText(IBaseInventoryItem item)
{
if (item is IAugmentableItem augmentable && augmentable.Augment != null)
{
ItemAugmentTexture.Texture = augmentable.Augment.AugmentTexture;
return $"{augmentable.Augment.AugmentName}{System.Environment.NewLine}{augmentable.Augment.AugmentDescription}";
}
return string.Empty;
}
private static string SetItemTypeName(IBaseInventoryItem item)
{
return item switch
{
Weapon => "Weapon",
Armor => "Armor",
Accessory => "Mask",
Ammo => "Ammo",
BoxItem => "Box",
ConsumableItem => "Restorative",
EffectItem => "Spell",
Jewel => "Jewel",
Plastique => "Explosive",
ThrowableItem => "Dice",
_ => "Unknown item type.",
};
}
}