Skip to content

Commit

Permalink
Merge pull request #30 from shnok/inventory
Browse files Browse the repository at this point in the history
Inventory
  • Loading branch information
shnok authored Aug 16, 2024
2 parents d54e2a9 + 8cf3833 commit 9c47bf3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryGearTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void UpdateItemList(List<ItemInstance> items) {
}
_gearSlots.Clear();
}
_gearSlots = new Dictionary<ItemSlot, GearSlot>();

_gearSlots = new Dictionary<ItemSlot, GearSlot>();
// Clean up gear anchors from any child visual element
foreach (KeyValuePair<ItemSlot, VisualElement> kvp in _gearAnchors) {
if (kvp.Value == null) {
Expand All @@ -62,7 +62,7 @@ public void UpdateItemList(List<ItemInstance> items) {
VisualElement slotElement = InventoryWindow.Instance.InventorySlotTemplate.Instantiate()[0];
kvp.Value.Add(slotElement);

GearSlot slot = new GearSlot((int)kvp.Key, kvp.Value, this);
GearSlot slot = new GearSlot((int)kvp.Key, slotElement, this);
_gearSlots.Add(kvp.Key, slot);
}

Expand Down
14 changes: 5 additions & 9 deletions l2-unity/Assets/Scripts/UI/Game/Inventory/InventorySlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public InventorySlot(int position, VisualElement slotElement, L2Tab tab, bool ha
_currentTab = tab;
_slotElement.AddToClassList("inventory-slot");
_empty = true;

if(_slotClickSoundManipulator == null) {
_slotClickSoundManipulator = new SlotClickSoundManipulator(_slotElement);
_slotElement.AddManipulator(_slotClickSoundManipulator);
}
}

public void AssignItem(ItemInstance item) {
Expand Down Expand Up @@ -56,11 +61,6 @@ public void AssignItem(ItemInstance item) {
_slotDragManipulator = new SlotDragManipulator(_slotElement, this);
_slotElement.AddManipulator(_slotDragManipulator);
}

if(_slotClickSoundManipulator == null) {
_slotClickSoundManipulator = new SlotClickSoundManipulator(_slotElement);
_slotElement.AddManipulator(_slotClickSoundManipulator);
}
}

private void AddTooltip(ItemInstance item) {
Expand All @@ -87,9 +87,6 @@ public void ClearSlot() {
}

if(_slotDragManipulator != null) {
if(this is GearSlot) {
Debug.LogWarning("Remove drag manip " + _slotElement);
}
_slotElement.RemoveManipulator(_slotDragManipulator);
_slotDragManipulator = null;
}
Expand All @@ -101,7 +98,6 @@ public void ClearSlot() {
}

protected override void HandleLeftClick() {
//AudioManager.Instance.PlayUISound("click_03");
_currentTab.SelectSlot(_position);
}

Expand Down
1 change: 1 addition & 0 deletions l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void UpdateItemList(List<ItemInstance> items) {
// Clear slots
if(_inventorySlots != null) {
foreach(InventorySlot slot in _inventorySlots) {
slot.UnregisterCallbacks();
slot.ClearSlot();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ protected override void UnregisterCallbacksFromTarget() {
}

private void MouseDownHandler(PointerDownEvent evt) {
AudioManager.Instance.PlayUISound("click_03");
if (evt.button == 0) {
AudioManager.Instance.PlayUISound("click_03");
}
}
}

0 comments on commit 9c47bf3

Please sign in to comment.