public override void Update(GameTime gameTime)
        {
            hoverSlot = -1;
            Vector2    origin   = InterfaceHelper.GetFullRectangle(this).TopLeft();
            MouseState curMouse = StorageGUI.curMouse;

            if (curMouse.X <= origin.X || curMouse.Y <= origin.Y)
            {
                return;
            }
            int slotWidth  = (int)(Main.inventoryBackTexture.Width * inventoryScale * Main.UIScale);
            int slotHeight = (int)(Main.inventoryBackTexture.Height * inventoryScale * Main.UIScale);
            int slotX      = (curMouse.X - (int)origin.X) / (slotWidth + padding);
            int slotY      = (curMouse.Y - (int)origin.Y) / (slotHeight + padding);

            if (slotX < 0 || slotX >= numColumns || slotY < 0 || slotY >= numRows)
            {
                return;
            }
            Vector2 slotPos = origin + new Vector2(slotX * (slotWidth + padding * Main.UIScale), slotY * (slotHeight + padding * Main.UIScale));

            if (curMouse.X > slotPos.X && curMouse.X < slotPos.X + slotWidth && curMouse.Y > slotPos.Y && curMouse.Y < slotPos.Y + slotHeight)
            {
                onHover(slotX + numColumns * slotY, ref hoverSlot);
            }
        }
        private bool MouseOverButton(int mouseX, int mouseY, int button)
        {
            Rectangle dim    = InterfaceHelper.GetFullRectangle(this);
            float     left   = dim.X + button * (buttonSize + buttonPadding) * Main.UIScale;
            float     right  = left + buttonSize * Main.UIScale;
            float     top    = dim.Y;
            float     bottom = top + buttonSize * Main.UIScale;

            return(mouseX > left && mouseX < right && mouseY > top && mouseY < bottom);
        }
        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);
        }
Example #4
0
 public override void Load()
 {
     if (ModLoader.version < requiredVersion)
     {
         throw new Exception("Magic storage requires a tModLoader version of at least " + requiredVersion);
     }
     Instance = this;
     InterfaceHelper.Initialize();
     legendMod    = ModLoader.GetMod("LegendOfTerraria3");
     bluemagicMod = ModLoader.GetMod("Bluemagic");
     AddTranslations();
 }
        public static void Draw(TEStorageHeart heart)
        {
            Player        player    = Main.player[Main.myPlayer];
            StoragePlayer modPlayer = player.GetModPlayer <StoragePlayer>(MagicStorage.Instance);

            Initialize();
            if (Main.mouseX > panelLeft && Main.mouseX < panelLeft + panelWidth && Main.mouseY > panelTop && Main.mouseY < panelTop + panelHeight)
            {
                player.mouseInterface = true;
                player.showItemIcon   = false;
                InterfaceHelper.HideItemIconCache();
            }
            basePanel.Draw(Main.spriteBatch);
            slotZone.DrawText();
            sortButtons.DrawText();
            filterButtons.DrawText();
        }
        private static void UpdateDepositButton()
        {
            Rectangle dim = InterfaceHelper.GetFullRectangle(depositButton);

            if (curMouse.X > dim.X && curMouse.X < dim.X + dim.Width && curMouse.Y > dim.Y && curMouse.Y < dim.Y + dim.Height)
            {
                depositButton.BackgroundColor = new Color(73, 94, 171);
                if (MouseClicked)
                {
                    if (TryDepositAll())
                    {
                        RefreshItems();
                        Main.PlaySound(7, -1, -1, 1);
                    }
                }
            }
            else
            {
                depositButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            }
        }
Example #7
0
 public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
 {
     InterfaceHelper.ModifyInterfaceLayers(layers);
 }