private void OnClick(UISlot uislot) { int slot = uislot.index; ItemSlot islot = (ItemSlot)uislot; CraftData item = islot.GetCraftable(); foreach (ItemSlot aslot in slots) { aslot.UnselectSlot(); } CraftInfoPanel info_panel = CraftInfoPanel.Get(GetPlayerID()); if (info_panel) { if (item == info_panel.GetData()) { info_panel.Hide(); } else { parent_ui.CancelSelection(); slots[slot].SelectSlot(); info_panel.ShowData(item); } } }
public UISlot GetSelectedSlot() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); UISlot selected_slot = selected_panel?.GetSelectSlot(); return(selected_slot); }
private void OnClickSlot(UISlot islot) { if (onClickSlot != null) { onClickSlot.Invoke(islot); } }
private void OnPressUse(UISlot slot) { if (onPressUse != null) { onPressUse.Invoke(slot); } }
private void OnPressCancel(UISlot slot) { if (onPressCancel != null) { onPressCancel.Invoke(slot); } }
private void OnPressAccept(UISlot slot) { if (onPressAccept != null) { onPressAccept.Invoke(slot); } }
public bool IsPanelFocusItem() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); UISlot slot = selected_panel?.GetSelectSlot(); ItemSlot islot = (slot != null && slot is ItemSlot) ? (ItemSlot)slot : null; return(islot != null && islot.GetItem() != null); }
private void OnClickSlotRight(UISlot islot) { //Event if (onRightClickSlot != null) { onRightClickSlot.Invoke(islot); } }
public void PressSlot(int index) { UISlot slot = GetSlot(index); if (slot != null && onPressAccept != null) { onPressAccept.Invoke(slot); } }
public void OnClickResult(UISlot slot) { if (player != null && result_slot.GetItem() != null) { player.Inventory.GainItem(result_slot.GetItem()); result_slot.SetSlot(null, 0); crafed_item = null; } }
private void OnAccept(UISlot slot) { OnClick(slot); UISlotPanel.UnfocusAll(); if (prev_panel != null) { prev_panel.Focus(); } }
private void OnPressUse() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); UISlot selected_slot = selected_panel?.GetSelectSlot(); if (selected_slot != null) { selected_slot.KeyPressUse(); } }
private void OnAccept(UISlot slot) { PlayerCharacter player = PlayerCharacter.Get(GetPlayerID()); CraftInfoPanel.Get(GetPlayerID())?.OnClickCraft(); if (player.Crafting.IsBuildMode()) { UISlotPanel.UnfocusAll(); } }
public void Focus() { UnfocusAll(); focused = true; UISlot slot = GetSelectSlot(); if (slot == null && slots.Length > 0) { selection_index = slots[0].index; } }
public void NavigateTo(UISlot slot, Vector2 dir) { UISlotPanel panel = slot?.GetParent(); if (panel != null && panel.IsVisible()) { panel.Focus(); panel.selection_index = slot.index; } else { Navigate(panel, dir); } }
private void OnPressCancel() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); UISlot selected_slot = selected_panel?.GetSelectSlot(); if (selected_slot != null) { selected_slot.KeyPressCancel(); } if (ReadPanel.Get().IsVisible()) { ReadPanel.Get().Hide(); } }
public void Navigate(UISlotPanel panel, Vector2 dir) { UISlot current = panel?.GetSelectSlot(); if (panel == null || current == null) { if (IsLeft(dir)) { panel = default_left; } else if (IsRight(dir)) { panel = default_right; } else if (IsUp(dir)) { panel = default_top; } else if (IsDown(dir)) { panel = default_down; } panel.Focus(); } else { if (IsLeft(dir) && current.left) { NavigateTo(current.left, dir); } else if (IsRight(dir) && current.right) { NavigateTo(current.right, dir); } else if (IsUp(dir) && current.top) { NavigateTo(current.top, dir); } else if (IsDown(dir) && current.down) { NavigateTo(current.down, dir); } else { NavigateAuto(panel, dir); } } }
private void OnClickRight(UISlot uislot) { //Cancel select selected_slot = -1; selected_right_slot = -1; ActionSelectorUI.Get(GetPlayerID()).Hide(); //Show action selector ItemSlot islot = (ItemSlot)uislot; CraftData item = islot.GetCraftable(); if (item != null && item.GetItem() != null && item.GetItem().actions.Length > 0) { selected_right_slot = islot.index; ActionSelectorUI.Get(GetPlayerID()).Show(islot); } }
private void OnClick(UISlot uislot) { if (uislot != null) { //Cancel right click and action selector int previous_right_select = selected_right_slot; ActionSelectorUI.Get(GetPlayerID()).Hide(); selected_right_slot = -1; int slot = uislot.index; ItemSlot selslot = GetSelectedSlotInAllPanels(); //Cancel action selector if (slot == previous_right_select) { CancelSelection(); return; } //Merge two slots ItemSlot islot = (ItemSlot)uislot; if (islot != null && selslot != null) { MergeSlots(selslot, (ItemSlot)uislot); if (onMergeSlot != null) { onMergeSlot.Invoke(selslot, islot); } } //Select slot else if (islot.GetCraftable() != null) { CancelSelectionAll(); selected_slot = slot; ItemData idata = islot?.GetItem(); idata?.RunAutoActions(GetPlayer(), islot); if (onSelectSlot != null) { onSelectSlot.Invoke(islot); } } } }
protected override void RefreshPanel() { base.RefreshPanel(); PlayerCharacter player = GetPlayer(); if (player != null) { CraftStation station = player.Crafting.GetCraftStation(); if (current_staton != station) { current_staton = station; RefreshCategories(); } } //Gamepad auto controls PlayerControls controls = PlayerControls.Get(GetPlayerID()); CraftSubPanel sub_panel = CraftSubPanel.Get(GetPlayerID()); UISlotPanel focus_panel = UISlotPanel.GetFocusedPanel(); if (focus_panel != this && focus_panel != sub_panel && !TheUI.Get().IsBlockingPanelOpened() && controls.IsGamePad() && player != null && !player.Crafting.IsBuildMode()) { Focus(); CraftInfoPanel.Get(GetPlayerID())?.Hide(); } if (focus_panel == this) { selection_index = Mathf.Clamp(selection_index, 0, CountActiveSlots() - 1); UISlot slot = GetSelectSlot(); if (prev_slot != slot || !sub_panel.IsVisible()) { OnClick(slot); sub_panel.selection_index = 0; prev_slot = slot; } } }
private void OnClick(UISlot uislot) { if (uislot != null) { CategorySlot cslot = (CategorySlot)uislot; for (int i = 0; i < slots.Length; i++) { slots[i].UnselectSlot(); } if (cslot.group == CraftSubPanel.Get(GetPlayerID())?.GetCurrentCategory()) { CraftSubPanel.Get(GetPlayerID())?.Hide(); } else { selected_slot = uislot.index; uislot.SelectSlot(); CraftSubPanel.Get(GetPlayerID())?.ShowCategory(cslot.group); } } }
protected override void RefreshPanel() { base.RefreshPanel(); //Gamepad auto controls PlayerCharacter player = GetPlayer(); CraftInfoPanel info_panel = CraftInfoPanel.Get(GetPlayerID()); if (UISlotPanel.GetFocusedPanel() == this) { selection_index = Mathf.Clamp(selection_index, 0, CountActiveSlots() - 1); UISlot slot = GetSelectSlot(); if (player != null && !player.Crafting.IsBuildMode()) { if (prev_slot != slot || !info_panel.IsVisible()) { OnClick(slot); prev_slot = slot; } } } }
private void OnCancel(UISlot slot) { ItemSlotPanel.CancelSelectionAll(); UISlotPanel.UnfocusAll(); }
private void OnCancel(UISlot slot) { Hide(); }
private void OnAccept(UISlot slot) { OnClick(slot); UISlotPanel.UnfocusAll(); }
private void OnClick(UISlot islot) { ActionSelectorButton button = (ActionSelectorButton)islot; OnClickAction(button.GetAction()); }
private void OnCancel(UISlot slot) { CancelSelection(); CraftInfoPanel.Get(GetPlayerID())?.Hide(); CraftPanel.Get(GetPlayerID())?.Focus(); }
private void OnCancel(UISlot slot) { ItemSlotPanel.CancelSelectionAll(); Hide(); }
private void OnCancel(UISlot slot) { Toggle(); CraftSubPanel.Get(GetPlayerID())?.Hide(); UISlotPanel.UnfocusAll(); }
private void OnAccept(UISlot slot) { CraftSubPanel.Get(GetPlayerID())?.Focus(); }