public override void ProcessTriggers(TriggersSet triggersSet) { base.ProcessTriggers(triggersSet); if (DepositAll.JustPressed) { ChestUI.DepositAll(); } if (LootAll.JustPressed) { ChestUI.LootAll(); } if (QuickStack.JustPressed) { player.QuickStackAllChests(); ChestUI.QuickStack(); } if (Restock.JustPressed) { ChestUI.Restock(); } if (SortChest.JustPressed) { ItemSorting.SortChest(); } if (SortInventory.JustPressed) { ItemSorting.SortInventory(); } }
public void Awake() { if (Instance == null) { Instance = this; } }
internal void smartQuickStack() { if (player.chest != -1) { // check this chest for cateroies, then stack all items that fit those categories into this chest. Item[] items = player.bank.item; if (player.chest > -1) { items = Main.chest[player.chest].item; } else if (player.chest == -2) { items = player.bank.item; } else if (player.chest == -3) { items = player.bank2.item; } else if (player.chest == -4) { items = player.bank3.item; } bool itemMoved = false; List<ItemSorting.ItemSortingLayer> layersInThisChest = ItemSorting.GetPassingLayers(items); for (int i = 0; i < 50; i++) { Item item = player.inventory[i]; if (item.type == ItemID.Count || item.favorited || (item.type >= 71 && item.type <= 74)) continue; foreach (var layer in ItemSorting.layerList) { if (layer.Pass(item)) { if (layersInThisChest.Contains(layer)) { itemMoved |= ChestUI.TryPlacingInChest(item, false); break; } else { break; } } } } if (itemMoved) { Main.PlaySound(7, -1, -1, 1, 1f, 0f); } } else { //TODO smartQuickStackAllChests(); Recipe.FindRecipes(); } }
void Start() { gameObject.transform.GetChild(0).gameObject.SetActive(false); instance = this; slots = itemsParent.GetComponentsInChildren <ChestSlot>(); }
private void OnEnable() { if (chestUI == null) { chestUI = ChestUI.Instance; } chestUI.ActiveSlotModifiedEvent += UpdateItemInfo; }
void Start() { inventoryScript = GameObject.FindGameObjectWithTag("Player").GetComponent <Inventory>(); hotbarScript = inventoryScript.GetComponent <Hotbar>(); chestUIScript = inventoryScript.GetComponent <ChestUI>(); rTransform = GetComponent <RectTransform>(); UITransform = GameObject.Find("UI").GetComponent <RectTransform>(); }
// Start is called before the first frame update void Awake() { instance = this; //items = new List<Item>(); ui = GetComponent <ChestUI>(); render = GetComponent <CanvasGroup>(); render.alpha = 0f; render.blocksRaycasts = false; }
private void Awake() { Instance = this; canvas = GetComponent <Canvas>(); for (int i = 0; i < 27; i++) { slots[i] = transform.Find("slot (" + i + ")").GetComponent <InventorySlotUI>(); } }
internal void smartQuickStackAllChests() { if (player.IsStackingItems()) { return; } if (Main.netMode == 1) { Main.NewText("Smart Quick Stack to Nearby Chests not implemented in Multiplayer yet"); //TODO return; } bool itemMoved = false; for (int chestIndex = 0; chestIndex < 1000; chestIndex++) { if (Main.chest[chestIndex] != null && /*!Chest.IsPlayerInChest(i) &&*/ !Chest.isLocked(Main.chest[chestIndex].x, Main.chest[chestIndex].y)) { Vector2 distanceToPlayer = new Vector2((float)(Main.chest[chestIndex].x * 16 + 16), (float)(Main.chest[chestIndex].y * 16 + 16)); if ((distanceToPlayer - player.Center).Length() < 200f) { player.chest = chestIndex; Item[] items = Main.chest[chestIndex].item; List <ItemSorting.ItemSortingLayer> layersInThisChest = ItemSorting.GetPassingLayers(items); for (int i = 0; i < 50; i++) { Item item = player.inventory[i]; if (item.type == ItemID.Count || item.favorited || (item.type >= 71 && item.type <= 74)) { continue; } foreach (var layer in ItemSorting.layerList) { if (layer.Pass(item)) { if (layersInThisChest.Contains(layer)) { itemMoved |= ChestUI.TryPlacingInChest(item, false); break; } else { break; } } } } } } } if (itemMoved) { Main.PlaySound(7, -1, -1, 1, 1f, 0f); } player.chest = -1; }
public void QuickStackToChests() { if (player.chest != -1) { ChestUI.QuickStack(); } else { player.QuickStackAllChests(); } Recipe.FindRecipes(); }
public static void QuickStack() { if (Main.player[Main.myPlayer].chest > -1 || (Main.player[Main.myPlayer].chest == -2 || Main.player[Main.myPlayer].chest == -3)) { ChestUI.QuickStack(); } else { Main.player[Main.myPlayer].QuickStackAllChests(); Recipe.FindRecipes(); } }
protected override void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } rectTransform = GetComponent <RectTransform>(); InitInventorySlotsUI(); }
public override void Update() { if (!Main.gameMenu && !Main.mapFullscreen) { //if (kQuickMoveItem.KeyDown && Main.playerInventory) //{ // CheckInventory(); // if (player.chest != -1) CheckChest(); //} //if (kQuickMoveItem.KeyDown && Main.playerInventory && ((Main.mouseLeft && Main.mouseLeftRelease) || (Main.mouseRight && Main.mouseRightRelease))) //{ // CheckQuickCraft(); // CheckQuickBuy(); //} if (Main.playerInventory) { if (kSortInventory.KeyPressed) { //Terraria.UI.ItemSorting.Sort(); ModUtils.Sort(); Recipe.FindRecipes(); //Console.WriteLine("clean inv"); //CleanInventory(); } } //if (Main.playerInventory && player.chest != -1) { if (kQuickStack.KeyPressed) { Player player = Main.player[Main.myPlayer]; if (player.chest != -1) { ChestUI.QuickStack(); } else { player.QuickStackAllChests(); Recipe.FindRecipes(); } } } if (kSwapHotbar.KeyPressed) { SwapHotbar(); } } }
void Start() { GameObject player = GameObject.FindGameObjectWithTag("Player"); playerScript = player.GetComponent <Player>(); chestUI = player.GetComponent <ChestUI>(); int items = chestUI.slots; chestItems = new Item[items]; itemCount = new int[items]; GenerateChest(); }
private static void OpenLootConfirmation() { var ui = new ConfirmationUI { buttonID = ChestUI.ButtonID.LootAll, topOffset = 30, onclick = (evt, elm) => { ChestUI.LootAll(); ConfirmationUI.visible = false; } }; BetterChests.instance.ConfirmationUserInterface.SetState(ui); ConfirmationUI.visible = true; }
public static void Show(Vector3Int pos) { if (Instance != null) { Instance.pos = pos; Instance.InitData(); Instance.gameObject.SetActive(true); Instance.RefreshUI(); Instance.RefreshGrabItem(); } else { Instance = UISystem.InstantiateUI("ChestUI").GetComponent <ChestUI>(); Instance.pos = pos; Instance.InitData(); } InputManager.enabled = false; PlayerController.LockCursor(false); }
GameObject item; // Current item in the slot private void Start() { inventory = Inventory.instance; chest = Chest.instance; chestUI = ChestUI.instance; }
protected override void DrawSelf(SpriteBatch spriteBatch) { if (Main.gameMenu) { if (PlayerInput.UsingGamepad) { this.outerLayer2.Remove(); if (!this.Elements.Contains(this.outerLayer1)) { this.Append(this.outerLayer1); } this.outerLayer1.Activate(); this.outerLayer2.Deactivate(); this.Recalculate(); this.RecalculateChildren(); if ((double)this._labelHeight != 0.0) { this._textBox.Top.Pixels = this._textBoxHeight; this._label.Top.Pixels = this._labelHeight; this._textBox.Recalculate(); this._label.Recalculate(); this._labelHeight = this._textBoxHeight = 0.0f; UserInterface.ActiveInstance.ResetLasts(); } } else { this.outerLayer1.Remove(); if (!this.Elements.Contains(this.outerLayer2)) { this.Append(this.outerLayer2); } this.outerLayer2.Activate(); this.outerLayer1.Deactivate(); this.Recalculate(); this.RecalculateChildren(); if ((double)this._textBoxHeight == 0.0) { this._textBoxHeight = this._textBox.Top.Pixels; this._labelHeight = this._label.Top.Pixels; this._textBox.Top.Pixels += 50f; this._label.Top.Pixels += 50f; this._textBox.Recalculate(); this._label.Recalculate(); UserInterface.ActiveInstance.ResetLasts(); } } } if (!Main.editSign && this._edittingSign) { IngameFancyUI.Close(); } else if (!Main.editChest && this._edittingChest) { IngameFancyUI.Close(); } else { base.DrawSelf(spriteBatch); this.UpdateOffsetDown(); UIVirtualKeyboard.OffsetDown = 0; this.SetupGamepadPoints(spriteBatch); PlayerInput.WritingText = true; Main.instance.HandleIME(); Vector2 position; // ISSUE: explicit reference operation // ISSUE: variable of a reference type Vector2& local1 = @position; double num1 = (double)(Main.screenWidth / 2); Rectangle rectangle = this._textBox.GetDimensions().ToRectangle(); // ISSUE: explicit reference operation double num2 = (double)(((Rectangle)@rectangle).get_Bottom() + 32); ((Vector2)local1).\u002Ector((float)num1, (float)num2); Main.instance.DrawWindowsIMEPanel(position, 0.5f); string inputText = Main.GetInputText(this.Text); if (this._edittingSign && Main.inputTextEnter) { inputText += "\n"; } else { if (this._edittingChest && Main.inputTextEnter) { ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]); IngameFancyUI.Close(); return; } if (Main.inputTextEnter && UIVirtualKeyboard.CanSubmit) { UIVirtualKeyboard.Submit(); } else if (Main.inputTextEscape) { if (this._edittingSign) { Main.InputTextSignCancel(); } if (this._edittingChest) { ChestUI.RenameChestCancel(); } IngameFancyUI.Close(); return; } } if (IngameFancyUI.CanShowVirtualKeyboard(this._keyboardContext)) { if (inputText != this.Text) { this.Text = inputText; } if (this._edittingSign) { this.CopyTextToSign(); } if (this._edittingChest) { this.CopyTextToChest(); } } // ISSUE: explicit reference operation byte num3 = (byte)(((int)byte.MaxValue + (int)((Color)@Main.tileColor).get_R() * 2) / 3); Color color; // ISSUE: explicit reference operation ((Color)@color).\u002Ector((int)num3, (int)num3, (int)num3, (int)byte.MaxValue); this._textBox.TextColor = Color.Lerp(Color.get_White(), color, 0.2f); this._label.TextColor = Color.Lerp(Color.get_White(), color, 0.2f); // ISSUE: explicit reference operation // ISSUE: variable of a reference type Vector2& local2 = @position; double num4 = (double)(Main.screenWidth / 2); rectangle = this._textBox.GetDimensions().ToRectangle(); // ISSUE: explicit reference operation double num5 = (double)(((Rectangle)@rectangle).get_Bottom() + 32); ((Vector2)local2).\u002Ector((float)num4, (float)num5); Main.instance.DrawWindowsIMEPanel(position, 0.5f); } }
public static void QuickStack(On.Terraria.UI.ChestUI.orig_QuickStack orig) { Player player = Main.player[Main.myPlayer]; if (player.chest == -4) { ChestUI.MoveCoins(player.inventory, player.bank3.item); } else if (player.chest == -3) { ChestUI.MoveCoins(player.inventory, player.bank2.item); } else if (player.chest == -2) { ChestUI.MoveCoins(player.inventory, player.bank.item); } Item[] inventory = player.inventory; Item[] openChest = player.bank.item; if (player.chest > -1) { openChest = Main.chest[player.chest].item; } else if (player.chest == -2) { openChest = player.bank.item; } else if (player.chest == -3) { openChest = player.bank2.item; } else if (player.chest == -4) { openChest = player.bank3.item; } List <Item> possibleStackItems = new List <Item>(); List <int> possibleStackSlots = new List <int>(); List <int> quickStackIgnoreSlots = new List <int>(); Dictionary <int, Item> dictionary = new Dictionary <int, Item>(); List <int> removeItems = new List <int>(); bool[] quickStacked = new bool[openChest.Length]; for (int i = 0; i < 40; i++) { if (openChest[i].type > 0 && openChest[i].stack > 0 && openChest[i].maxStack > 1 && (openChest[i].type < 71 || openChest[i].type > 74)) { possibleStackSlots.Add(i); possibleStackItems.Add(openChest[i]); } if (openChest[i].type == 0 || openChest[i].stack <= 0) { quickStackIgnoreSlots.Add(i); } } int num = 50; if (player.chest <= -2) { num += 4; } for (int j = 0; j < num; j++) { foreach (Item itm in possibleStackItems) { if (inventory[j].IsTheSameAs(itm) && !inventory[j].favorited) { dictionary.Add(j, inventory[j]); } } } for (int k = 0; k < possibleStackSlots.Count; k++) { int num2 = possibleStackSlots[k]; Item itm2 = openChest[num2]; foreach (KeyValuePair <int, Item> keyValuePair in dictionary) { if (keyValuePair.Value.IsTheSameAs(itm2) && inventory[keyValuePair.Key].IsTheSameAs(itm2)) { int num3 = inventory[keyValuePair.Key].stack; int num4 = openChest[num2].maxStack - openChest[num2].stack; if (num4 == 0) { break; } if (num3 > num4) { num3 = num4; } Main.PlaySound(7, -1, -1, 1, 1f, 0f); openChest[num2].stack += num3; inventory[keyValuePair.Key].stack -= num3; if (inventory[keyValuePair.Key].stack == 0) { inventory[keyValuePair.Key].SetDefaults(0, false); } quickStacked[num2] = true; } } } foreach (KeyValuePair <int, Item> keyValuePair2 in dictionary) { if (inventory[keyValuePair2.Key].stack == 0) { removeItems.Add(keyValuePair2.Key); } } foreach (int key in removeItems) { dictionary.Remove(key); } for (int l = 0; l < quickStackIgnoreSlots.Count; l++) { int num5 = quickStackIgnoreSlots[l]; bool flag = true; Item num6 = openChest[num5]; foreach (KeyValuePair <int, Item> keyValuePair3 in dictionary) { if ((keyValuePair3.Value.IsTheSameAs(num6) && inventory[keyValuePair3.Key].IsTheSameAs(num6)) || (flag && inventory[keyValuePair3.Key].stack > 0)) { Main.PlaySound(7, -1, -1, 1, 1f, 0f); if (flag) { num6 = keyValuePair3.Value; openChest[num5] = inventory[keyValuePair3.Key]; inventory[keyValuePair3.Key] = new Item(); } else { int num7 = inventory[keyValuePair3.Key].stack; int num8 = openChest[num5].maxStack - openChest[num5].stack; if (num8 == 0) { break; } if (num7 > num8) { num7 = num8; } openChest[num5].stack += num7; inventory[keyValuePair3.Key].stack -= num7; if (inventory[keyValuePair3.Key].stack == 0) { inventory[keyValuePair3.Key] = new Item(); } } quickStacked[num5] = true; flag = false; } } } if (Main.netMode == 1 && player.chest >= 0) { for (int m = 0; m < quickStacked.Length; m++) { NetMessage.SendData(32, -1, -1, null, player.chest, (float)m, 0f, 0f, 0, 0, 0); } } possibleStackItems.Clear(); possibleStackSlots.Clear(); quickStackIgnoreSlots.Clear(); dictionary.Clear(); removeItems.Clear(); }
public void ButtonSettings() { if (PauseMenuUI.activeSelf == false) { PauseMenuUI.SetActive(true); settingsOutline.SetActive(true); vjMove.SetActive(false); viFight.SetActive(false); bInteractA.SetActive(false); bGatherB.SetActive(false); bHide.SetActive(false); SetTools(false); bMainWeapon.SetActive(false); bSwap.SetActive(false); SetQuickAccessSlots(false); bInventory.SetActive(false); if (isInventoryOpen == true) { InventoryUI.SetActive(false); } if (isChestOpen == true) { ChestUI.SetActive(false); } if (isBuildModeOn == true || isRemoveModeOn == true) { bCancel.SetActive(false); bRotate.SetActive(false); stateText.SetActive(false); } Time.timeScale = 0f; } else { settingsOutline.SetActive(false); Time.timeScale = 1f; PauseMenuUI.SetActive(false); vjMove.SetActive(true); bGatherB.SetActive(true); bHide.SetActive(true); // Check if we was in remove mode if (isRemoveModeOn == false) { bInventory.SetActive(true); bInteractA.SetActive(true); } // Check if we was on Items and the tool bar wasn't hidden, also if we wasn't in build or remove mode if (isQuickAccessSlotsSwapped == true && isShown != false && isBuildModeOn != true && isRemoveModeOn != true) { SetTools(true); bMainWeapon.SetActive(true); bSwap.SetActive(true); } // Check if we was on QASlots and the tool bar wasn't hidden, also if we wasn't in build or remove mode else if (isQuickAccessSlotsSwapped == false && isShown != false && isBuildModeOn != true && isRemoveModeOn != true) { SetQuickAccessSlots(true); bMainWeapon.SetActive(true); bSwap.SetActive(true); } // Check if inventory was open if (isInventoryOpen == true) { InventoryUI.SetActive(true); viFight.SetActive(false); bInteractA.SetActive(false); bGatherB.SetActive(false); } // Check if we was in build or remove mode if (isBuildModeOn == true || isRemoveModeOn == true) { bCancel.SetActive(true); bRotate.SetActive(true); stateText.SetActive(true); } // Check if tools for build mode was hidden if (isShownBuildTools == false) { bCancel.SetActive(false); bRotate.SetActive(false); } // Check if we wasn't in build or remove mode and inventory closed to show Visual Icon for Fight mode if (isBuildModeOn == false && isRemoveModeOn == false && isInventoryOpen != true) { viFight.SetActive(true); } } }
void Awake() { instance = this; }
private static void ItemSlot_OverrideHover(On.Terraria.UI.ItemSlot.orig_OverrideHover orig, Terraria.Item[] inv, int context, int slot) { Item item = inv[slot]; if (ItemSlot.ShiftInUse && item.type > 0 && item.stack > 0 && !inv[slot].favorited) { switch (context) { case 0: case 1: case 2: if (Main.player[Main.myPlayer].chest != -1) { if (ChestUI.TryPlacingInChest(item, true)) { Main.cursorOverride = 9; } } break; case 3: case 4: if (Main.player[Main.myPlayer].ItemSpace(item)) { Main.cursorOverride = 8; } break; case 5: case 8: case 9: case 10: case 11: case 12: case 16: case 17: case 18: case 19: case 20: if (Main.player[Main.myPlayer].ItemSpace(inv[slot])) { Main.cursorOverride = 7; } break; } } if (IsCtrlPressed() && item.type > 0 && item.stack > 0 && !inv[slot].favorited) { if (context < 3) { if (Main.npcShop > 0 && !item.favorited) { Main.cursorOverride = 10; } else { Main.cursorOverride = 6; } } } if (Main.keyState.IsKeyDown(Main.FavoriteKey) && context < 3) { if (item.type > 0 && item.stack > 0 && Main.drawingPlayerChat) { Main.cursorOverride = 2; return; } if (item.type > 0 && item.stack > 0) { Main.cursorOverride = 3; } } }
private void ItemSlot_OverrideHover(On.Terraria.UI.ItemSlot.orig_OverrideHover orig, Item[] inv, int context, int slot) { Item item = inv[slot]; if (ItemSlot.ShiftInUse && item.type > 0 && item.stack > 0 && !inv[slot].favorited) { switch (context) { case 0: case 1: case 2: if (Main.npcShop > 0 && !item.favorited) { Main.cursorOverride = 10; } else if (Main.player[Main.myPlayer].chest != -1) { if (ChestUI.TryPlacingInChest(item, true)) { Main.cursorOverride = 9; } } else { Main.cursorOverride = 6; } break; case 3: case 4: if (Main.player[Main.myPlayer].ItemSpace(item)) { Main.cursorOverride = 8; } break; case 5: case 8: case 9: case 10: case 11: case 12: case 16: case 17: case 18: case 19: case 20: if (Main.player[Main.myPlayer].ItemSpace(inv[slot])) { Main.cursorOverride = 7; } break; } } //Check if the slot has an item in it and the favorite key is down and if the item in the slot can actually be favorited if (item.IsAir && Main.keyState.IsKeyDown(Main.FavoriteKey) && CanFavoriteAt[context]) { //Draw favorite cursor Main.cursorOverride = 3; } if (Main.keyState.IsKeyDown(Main.FavoriteKey) && CanFavoriteAt[context]) { if (item.type > 0 && item.stack > 0 && Main.drawingPlayerChat) { Main.cursorOverride = 2; return; } if (item.type > 0 && item.stack > 0) { Main.cursorOverride = 3; } } }
private int slot = 1; //inventory row #. 1-4. public override void ProcessTriggers(TriggersSet triggersSet) { if (PressF11.SwitchSlots.JustPressed && player.whoAmI == Main.myPlayer) { //inventory row swap with #0 and #slot for (int i = 0; i < 10; i++) { Item tmp = player.inventory[slot * 10 + i]; player.inventory[slot * 10 + i] = player.inventory[i]; player.inventory[i] = tmp; Main.PlaySound(7, -1, -1, 1, 1f, 0f); if (Main.netMode == 2) { NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(i), (float)Main.player[Main.myPlayer].inventory[i].prefix, 0f, 0, 0, 0); NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(slot * 10 + i), (float)Main.player[Main.myPlayer].inventory[slot * 10 + i].prefix, 0f, 0, 0, 0); } } slot++; if (slot > 4) { slot = 1; } } if (PressF11.SwapVertical.JustPressed && player.whoAmI == Main.myPlayer) { //swap with selected item and next row item(same column. 0 and 10, 1 and 11, ... , 9 and 19) Item tmp = player.inventory[player.selectedItem]; player.inventory[player.selectedItem] = player.inventory[player.selectedItem + 10]; player.inventory[player.selectedItem + 10] = tmp; Main.PlaySound(7, -1, -1, 1, 1f, 0f); if (Main.netMode == 2) { NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(player.selectedItem), (float)Main.player[Main.myPlayer].inventory[player.selectedItem].prefix, 0f, 0, 0, 0); NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(player.selectedItem + 10), (float)Main.player[Main.myPlayer].inventory[player.selectedItem + 10].prefix, 0f, 0, 0, 0); } } if (PressF11.SwapHorizontal.JustPressed && player.whoAmI == Main.myPlayer) { //swap with selected item and next column item(0 and 1, 1 and 2, ... , 9 and 0) Item tmp = player.inventory[player.selectedItem]; player.inventory[player.selectedItem] = player.inventory[(player.selectedItem + 1) % 10]; player.inventory[(player.selectedItem + 1) % 10] = tmp; Main.PlaySound(7, -1, -1, 1, 1f, 0f); if (Main.netMode == 2) { NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(player.selectedItem), (float)Main.player[Main.myPlayer].inventory[player.selectedItem].prefix, 0f, 0, 0, 0); NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)((player.selectedItem + 1) % 10), (float)Main.player[Main.myPlayer].inventory[(player.selectedItem + 1) % 10].prefix, 0f, 0, 0, 0); } } if (PressF11.LootAll.JustPressed && player.whoAmI == Main.myPlayer) { if (player.chest != -1) { ChestUI.LootAll(); } } //random craft if (PressF11.CraftRandom.JustPressed && player.whoAmI == Main.myPlayer) { Recipe.FindRecipes(); if (Main.numAvailableRecipes >= 1) { Main.focusRecipe = Main.rand.Next(Main.numAvailableRecipes); Recipe r = Main.recipe[Main.availableRecipe[Main.focusRecipe]]; r.Create(); Main.PlaySound(7, -1, -1, 1, 1f, 0f); Item.NewItem(player.position + player.Size / 2, r.createItem.type, r.createItem.stack, false, r.createItem.prefix, true); } } }
protected override void DrawSelf(SpriteBatch spriteBatch) { if (Main.gameMenu) { if (PlayerInput.UsingGamepad) { outerLayer2.Remove(); if (!Elements.Contains(outerLayer1)) { Append(outerLayer1); } outerLayer1.Activate(); outerLayer2.Deactivate(); Recalculate(); RecalculateChildren(); if (_labelHeight != 0f) { _textBox.Top.Pixels = _textBoxHeight; _label.Top.Pixels = _labelHeight; _textBox.Recalculate(); _label.Recalculate(); _labelHeight = (_textBoxHeight = 0f); UserInterface.ActiveInstance.ResetLasts(); } } else { outerLayer1.Remove(); if (!Elements.Contains(outerLayer2)) { Append(outerLayer2); } outerLayer2.Activate(); outerLayer1.Deactivate(); Recalculate(); RecalculateChildren(); if (_textBoxHeight == 0f) { _textBoxHeight = _textBox.Top.Pixels; _labelHeight = _label.Top.Pixels; _textBox.Top.Pixels += 50f; _label.Top.Pixels += 50f; _textBox.Recalculate(); _label.Recalculate(); UserInterface.ActiveInstance.ResetLasts(); } } } if (!Main.editSign && _edittingSign) { IngameFancyUI.Close(); return; } if (!Main.editChest && _edittingChest) { IngameFancyUI.Close(); return; } base.DrawSelf(spriteBatch); UpdateOffsetDown(); OffsetDown = 0; ShouldHideText = false; SetupGamepadPoints(spriteBatch); PlayerInput.WritingText = true; Main.instance.HandleIME(); Vector2 position = new Vector2(Main.screenWidth / 2, _textBox.GetDimensions().ToRectangle().Bottom + 32); Main.instance.DrawWindowsIMEPanel(position, 0.5f); string text = Main.GetInputText(Text, _edittingSign); if (_edittingSign && Main.inputTextEnter) { text += "\n"; } else { if (_edittingChest && Main.inputTextEnter) { ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]); IngameFancyUI.Close(); return; } if (Main.inputTextEnter && CanSubmit) { Submit(); } else if (_edittingChest && Main.player[Main.myPlayer].chest < 0) { ChestUI.RenameChestCancel(); } else if (Main.inputTextEscape) { if (_edittingSign) { Main.InputTextSignCancel(); } if (_edittingChest) { ChestUI.RenameChestCancel(); } IngameFancyUI.Close(); return; } } if (IngameFancyUI.CanShowVirtualKeyboard(_keyboardContext)) { if (text != Text) { Text = text; } if (_edittingSign) { CopyTextToSign(); } if (_edittingChest) { CopyTextToChest(); } } byte b = (byte)((255 + Main.tileColor.R * 2) / 3); Color value = new Color((int)b, (int)b, (int)b, 255); _textBox.TextColor = Color.Lerp(Color.White, value, 0.2f); _label.TextColor = Color.Lerp(Color.White, value, 0.2f); position = new Vector2(Main.screenWidth / 2, _textBox.GetDimensions().ToRectangle().Bottom + 32); Main.instance.DrawWindowsIMEPanel(position, 0.5f); }
public override void OnRightClick() { ChestUI.Show(WireFrameHelper.pos); }
protected override void DrawSelf(SpriteBatch spriteBatch) { if (Main.gameMenu) { if (PlayerInput.UsingGamepad) { this.outerLayer2.Remove(); if (!this.Elements.Contains(this.outerLayer1)) { this.Append(this.outerLayer1); } this.outerLayer1.Activate(); this.outerLayer2.Deactivate(); this.Recalculate(); this.RecalculateChildren(); if ((double)this._labelHeight != 0.0) { this._textBox.Top.Pixels = this._textBoxHeight; this._label.Top.Pixels = this._labelHeight; this._textBox.Recalculate(); this._label.Recalculate(); this._labelHeight = this._textBoxHeight = 0.0f; UserInterface.ActiveInstance.ResetLasts(); } } else { this.outerLayer1.Remove(); if (!this.Elements.Contains(this.outerLayer2)) { this.Append(this.outerLayer2); } this.outerLayer2.Activate(); this.outerLayer1.Deactivate(); this.Recalculate(); this.RecalculateChildren(); if ((double)this._textBoxHeight == 0.0) { this._textBoxHeight = this._textBox.Top.Pixels; this._labelHeight = this._label.Top.Pixels; this._textBox.Top.Pixels += 50f; this._label.Top.Pixels += 50f; this._textBox.Recalculate(); this._label.Recalculate(); UserInterface.ActiveInstance.ResetLasts(); } } } if (!Main.editSign && this._edittingSign) { IngameFancyUI.Close(); } else if (!Main.editChest && this._edittingChest) { IngameFancyUI.Close(); } else { base.DrawSelf(spriteBatch); this.UpdateOffsetDown(); UIVirtualKeyboard.OffsetDown = 0; this.SetupGamepadPoints(spriteBatch); PlayerInput.WritingText = true; Main.instance.HandleIME(); Vector2 position = new Vector2((float)(Main.screenWidth / 2), (float)(this._textBox.GetDimensions().ToRectangle().Bottom + 32)); Main.instance.DrawWindowsIMEPanel(position, 0.5f); string inputText = Main.GetInputText(this.Text); if (this._edittingSign && Main.inputTextEnter) { inputText += (string)(object)'\n'; } else { if (this._edittingChest && Main.inputTextEnter) { ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]); IngameFancyUI.Close(); return; } if (Main.inputTextEnter && UIVirtualKeyboard.CanSubmit) { UIVirtualKeyboard.Submit(); } else if (Main.inputTextEscape) { if (this._edittingSign) { Main.InputTextSignCancel(); } if (this._edittingChest) { ChestUI.RenameChestCancel(); } IngameFancyUI.Close(); return; } } if (IngameFancyUI.CanShowVirtualKeyboard(this._keyboardContext)) { if (inputText != this.Text) { this.Text = inputText; } if (this._edittingSign) { this.CopyTextToSign(); } if (this._edittingChest) { this.CopyTextToChest(); } } byte num = (byte)(((int)byte.MaxValue + (int)Main.tileColor.R * 2) / 3); Color color = new Color((int)num, (int)num, (int)num, (int)byte.MaxValue); this._textBox.TextColor = Color.Lerp(Color.White, color, 0.2f); this._label.TextColor = Color.Lerp(Color.White, color, 0.2f); position = new Vector2((float)(Main.screenWidth / 2), (float)(this._textBox.GetDimensions().ToRectangle().Bottom + 32)); Main.instance.DrawWindowsIMEPanel(position, 0.5f); } }
private bool ItemSlot_OverrideLeftClick(On.Terraria.UI.ItemSlot.orig_OverrideLeftClick orig, Item[] inv, int context, int slot) { Item item = inv[slot]; //Check if the slot has no item in it and the favorite key is down and if the item in the slot can actually be favorited if (item.IsAir && Main.keyState.IsKeyDown(Main.FavoriteKey) && CanFavoriteAt[context]) { //If true, add lock to inventory slot item.SetDefaults(ModContent.ItemType <ItemLock>()); //Favorite lock item item.favorited = true; //Play sound Main.PlaySound(SoundID.Unlock); return(true); } if (Main.cursorOverride == 2) { if (ChatManager.AddChatText(Main.fontMouseText, ItemTagHandler.GenerateTag(item), Vector2.One)) { Main.PlaySound(12, -1, -1, 1, 1f, 0f); } return(true); } if (Main.cursorOverride == 3) { if (!CanFavoriteAt[context]) { return(false); } item.favorited = !item.favorited; Main.PlaySound(12, -1, -1, 1, 1f, 0f); return(true); } else { if (Main.cursorOverride == 7) { inv[slot] = Main.player[Main.myPlayer].GetItem(Main.myPlayer, inv[slot], false, true); Main.PlaySound(12, -1, -1, 1, 1f, 0f); return(true); } if (Main.cursorOverride == 8) { inv[slot] = Main.player[Main.myPlayer].GetItem(Main.myPlayer, inv[slot], false, true); if (Main.player[Main.myPlayer].chest > -1) { NetMessage.SendData(32, -1, -1, null, Main.player[Main.myPlayer].chest, slot, 0f, 0f, 0, 0, 0); } return(true); } if (Main.cursorOverride == 9) { ChestUI.TryPlacingInChest(inv[slot], false); return(true); } return(false); } }