예제 #1
0
        /// <summary>
        /// Default mouse hover URL drawing.
        /// </summary>
        /// <param name="sb">SpriteBatch to draw to. Usually `Main.spriteBatch`.</param>
        public void DrawHoverEffects(SpriteBatch sb)
        {
            if (!string.IsNullOrEmpty(this.Url))
            {
                Vector2 pos = UILibraries.GetHoverTipPosition(this.Url);

                Utils.DrawBorderStringFourWay(sb, Main.fontMouseText, this.Url, pos.X, pos.Y, Color.White, Color.Black, default(Vector2));
                //sb.DrawString( Main.fontMouseText, this.Url, UILibaries.GetHoverTipPosition( this.Url ), Color.White );
            }
        }
예제 #2
0
        ////////////////

        private void UpdateInteractivity()
        {
            if (this.HasFocus)
            {
                // Hackish:
                if (Main.drawingPlayerChat)
                {
                    Main.drawingPlayerChat = false;
                    Main.chatText          = "";
                    Main.chatRelease       = false;
                }
                if (!this.IsInteractive || !UILibraries.IsUIAvailable(keyboardNotInVanillaUI: true))
                {
                    this.Unfocus();
                    return;
                }
                if (UILibraries.JustPressedKey(Keys.Escape) || UILibraries.JustPressedKey(Keys.Enter))
                {
                    this.Unfocus();
                    return;
                }
            }

            CalculatedStyle dim = this.GetDimensions();

            // Detect if user selects this element
            if (Main.mouseLeft)
            {
                bool isNowSelected = false;

                if (Main.mouseX >= dim.X && Main.mouseX < (dim.X + dim.Width))
                {
                    if (Main.mouseY >= dim.Y && Main.mouseY < (dim.Y + dim.Height))
                    {
                        isNowSelected = true;
                        Main.keyCount = 0;
                    }
                }

                if (this.HasFocus && !isNowSelected)
                {
                    // Delay Unfocus (lets Update (Draw?) code finish, first)
                    Timers.RunNow(() => { this.Unfocus(); });
                    return;
                }

                this.HasFocus = isNowSelected;
            }

            if (this.HasFocus)
            {
                this.UpdateInput();
            }
        }
        ////////////////

        internal static void UpdateDisplay()
        {
            if (!ReadableBookItem.IsDisplayingNote)
            {
                return;
            }

            bool uiAvailable = UILibraries.IsUIAvailable(
                //mouseNotInUse: true,
                playerAvailable: true,
                playerNotTalkingToNPC: true,
                noFullscreenMap: true
                );

            if (Main.gameMenu || Main.playerInventory || !uiAvailable)
            {
                ReadableBookItem.IsDisplayingNote = false;
                ReadableBookItem.ClearDisplay();
            }
        }
예제 #4
0
        ////////////////

        private void UpdateFocus()
        {
            if (this.HasFocus)
            {
                if (!this.IsInteractive || !UILibraries.IsUIAvailable(keyboardNotInVanillaUI: true))
                {
                    this.Unfocus();
                    return;
                }
                if (UILibraries.JustPressedKey(Keys.Escape) || UILibraries.JustPressedKey(Keys.Enter))
                {
                    this.Unfocus();
                    return;
                }

                Main.blockInput = true;                 // Force the point!

                this.CursorAnimation++;

                PlayerInput.WritingText = true;
                Main.instance.HandleIME();

                string newText = Main.GetInputText(this.Text);

                if (!newText.Equals(this.Text))
                {
                    this.SetTextWithValidation(newText);
                }
            }

            if (this.HasFocus)
            {
                var mouse = new Vector2(Main.mouseX, Main.mouseY);
                if (!this.ContainsPoint(mouse) && Main.mouseLeft)
                {
                    this.Unfocus();
                }
            }
        }