public override void Update(GameTime gameTime)
        {
            cursorTimer++;
            cursorTimer %= 60;

            if (StorageGUI.MouseClicked && Parent != null)
            {
                Rectangle  dim = InterfaceHelper.GetFullRectangle(this);
                MouseState mouse = StorageGUI.curMouse;
                bool       mouseOver = mouse.X > dim.X && mouse.X <dim.X + dim.Width && mouse.Y> dim.Y && mouse.Y < dim.Y + dim.Height;
                if (!hasFocus && mouseOver)
                {
                    hasFocus = true;
                    CheckBlockInput();
                }
                else if (hasFocus && !mouseOver)
                {
                    hasFocus = false;
                    CheckBlockInput();
                    cursorPosition = text.Length;
                }
            }
            else if (StorageGUI.curMouse.RightButton == ButtonState.Pressed && StorageGUI.oldMouse.RightButton == ButtonState.Released && Parent != null && hasFocus)
            {
                Rectangle  dim = InterfaceHelper.GetFullRectangle(this);
                MouseState mouse = StorageGUI.curMouse;
                bool       mouseOver = mouse.X > dim.X && mouse.X <dim.X + dim.Width && mouse.Y> dim.Y && mouse.Y < dim.Y + dim.Height;
                if (!mouseOver)
                {
                    hasFocus       = false;
                    cursorPosition = text.Length;
                    CheckBlockInput();
                }
            }

            if (hasFocus)
            {
                PlayerInput.WritingText = true;
                Main.instance.HandleIME();
                string newString = Main.GetInputText(text);
                if (!newString.Equals(text))
                {
                    text           = newString;
                    cursorPosition = text.Length;
                    StorageGUI.RefreshItems();
                }
                if (KeyTyped(Keys.Enter) || KeyTyped(Keys.Tab) || KeyTyped(Keys.Escape))
                {
                    hasFocus = false;
                    CheckBlockInput();
                }
            }
            base.Update(gameTime);
        }
Exemple #2
0
        public override bool ShiftClickSlot(Item[] inventory, int context, int slot)
        {
            if (context != ItemSlot.Context.InventoryItem && context != ItemSlot.Context.InventoryCoin && context != ItemSlot.Context.InventoryAmmo)
            {
                return(false);
            }
            if (storageAccess.X < 0 || storageAccess.Y < 0)
            {
                return(false);
            }
            Item item = inventory[slot];

            if (item.favorited || item.IsAir)
            {
                return(false);
            }
            int oldType  = item.type;
            int oldStack = item.stack;

            if (StorageCrafting())
            {
                if (Main.netMode == 0)
                {
                    GetCraftingAccess().TryDepositStation(item);
                }
                else
                {
                    NetHelper.SendDepositStation(GetCraftingAccess().ID, item);
                    item.SetDefaults(0, true);
                }
            }
            else
            {
                if (Main.netMode == 0)
                {
                    GetStorageHeart().DepositItem(item);
                }
                else
                {
                    NetHelper.SendDeposit(GetStorageHeart().ID, item);
                    item.SetDefaults(0, true);
                }
            }
            if (item.type != oldType || item.stack != oldStack)
            {
                Main.PlaySound(7, -1, -1, 1, 1f, 0f);
                StorageGUI.RefreshItems();
            }
            return(true);
        }
        public static void HandlePacket(BinaryReader reader, int sender)
        {
            MessageType type = (MessageType)reader.ReadByte();

            if (type == MessageType.SearchAndRefreshNetwork)
            {
                ReceiveSearchAndRefresh(reader);
            }
            else if (type == MessageType.TryStorageOperation)
            {
                ReceiveStorageOperation(reader, sender);
            }
            else if (type == MessageType.StorageOperationResult)
            {
                ReceiveOperationResult(reader);
            }
            else if (type == MessageType.RefreshNetworkItems)
            {
                StorageGUI.RefreshItems();
            }
            else if (type == MessageType.ClientSendTEUpdate)
            {
                ReceiveClientSendTEUpdate(reader, sender);
            }
            else if (type == MessageType.TryStationOperation)
            {
                ReceiveStationOperation(reader, sender);
            }
            else if (type == MessageType.StationOperationResult)
            {
                ReceiveStationResult(reader);
            }
            else if (type == MessageType.ResetCompactStage)
            {
                ReceiveResetCompactStage(reader);
            }
            else if (type == MessageType.CraftRequest)
            {
                ReceiveCraftRequest(reader, sender);
            }
            else if (type == MessageType.CraftResult)
            {
                ReceiveCraftResult(reader);
            }
        }
        public override void Update(GameTime gameTime)
        {
            int oldChoice = choice;

            if (StorageGUI.MouseClicked && Parent != null)
            {
                for (int k = 0; k < buttons.Length; k++)
                {
                    if (MouseOverButton(StorageGUI.curMouse.X, StorageGUI.curMouse.Y, k))
                    {
                        choice = k;
                        break;
                    }
                }
            }
            if (oldChoice != choice)
            {
                StorageGUI.RefreshItems();
            }
        }
Exemple #5
0
 public void OpenStorage(Point16 point, bool remote = false)
 {
     storageAccess = point;
     remoteAccess  = remote;
     StorageGUI.RefreshItems();
 }