private void ItemRow_OnSelected(UCEItemRow itemRow) { if (itemRow.Selected) { SelectedItemRow?.Deselect(); SelectedItemRow = itemRow; OnItemSelected?.Invoke(itemRow); } else { SelectedItemRow = null; OnItemSelected?.Invoke(null); } }
/* *** */ public void Refresh() { spSpells.Children.Clear(); if (Character == null) { return; } foreach (Object spell in Character.Spells) { UCEItemRow row = new UCEItemRow(spell, null, false); row.OnSelected += ItemRow_OnSelected; spSpells.Children.Add(row); } }
private void OnSpellSelected(UCEItemRow itemRow) { map.DeselectAll(); inventoryPanel.DeselectAll(); if (itemRow != null && itemRow.Selected) { SelectedObject = itemRow.Item; } else { SelectedObject = null; } Refresh(); }
private void ItemRow_OnMoveClicked(UCEItemRow itemRow) { var slotSelectorDialog = new SlotSelectorDialog(itemRow.Item, Game); if (slotSelectorDialog.ShowDialog() == true) { if (slotSelectorDialog.SelectedSlot == SpecialSlots.Bag) { Game.CurrentPlayer.Character.MoveItemToBag(itemRow.Item, Game.Config); } else { Game.CurrentPlayer.Character.MoveItemToSlot(itemRow.Item, slotSelectorDialog.SelectedSlot, Game.Config); } Refresh(); } }
/* *** */ public void Refresh() { spSlotItems.Children.Clear(); spBagItems.Children.Clear(); if (Character == null) { return; } List <Object> slotItems = new List <Object>(); foreach (var slot in Game.Config.CharacterConfig.InventorySlots) { string slotName = slot.Name; var slotItem = Character.GetItemBySlot(slotName, Game.Config); if (slotItem != null) { slotItems.Add(slotItem); UCEItemRow row = new UCEItemRow(slotItem, slotName); row.OnSelected += ItemRow_OnSelected; row.OnMoveClicked += ItemRow_OnMoveClicked; spSlotItems.Children.Add(row); } } foreach (Object item in Character.Items) { if (!slotItems.Contains(item)) { UCEItemRow row = new UCEItemRow(item); row.OnSelected += ItemRow_OnSelected; row.OnMoveClicked += ItemRow_OnMoveClicked; spBagItems.Children.Add(row); } } }
public void DeselectAll() { SelectedItemRow?.Deselect(); SelectedItemRow = null; }