Esempio n. 1
0
        /** Updates the text to display, and recalculates the scroll height */
        private void RefreshText()
        {
            TrimMessages();

            int firstMessage = Util.ClampInt(Messages.Count - MaxMessages, 0, int.MaxValue);
            int lastMessage  = Messages.Count;

            StringBuilder stringBuilder = new StringBuilder();

            if (ReversedMessageText)
            {
                for (int lp = lastMessage - 1; lp >= firstMessage; lp--)
                {
                    stringBuilder.Append(Messages[lp].FormattedMessage + "\n");
                }
            }
            else
            {
                for (int lp = firstMessage; lp < lastMessage; lp++)
                {
                    stringBuilder.Append(Messages[lp].FormattedMessage + "\n");
                }
            }

            string text = stringBuilder.ToString().TrimEnd('\n', ' ');

            Label.Caption = text;
            scrollBox.ContentsScrollRect.height = Label.Height;

            lastMessageCount = Messages.Count;
            if (Messages.Count > 0)
            {
                mostRecentTimeStamp = Messages[Messages.Count - 1].TimeStamp;
            }
        }
Esempio n. 2
0
        /** Sets the position of the tool tip based on the mouse location, making sure to not let the tool tip go off the
         * screen. */
        public void PositionToMouse()
        {
            int xPos = (int)Mouse.Position.x - Width - 10;
            int yPos = (int)Mouse.Position.y - Height - 10;

            xPos = Util.ClampInt(xPos, 10, (int)(Screen.width / Engine.GuiScale) - Width - 10);
            yPos = Util.ClampInt(yPos, 10, (int)(Screen.height / Engine.GuiScale) - Height - 10);

            X = xPos;
            Y = yPos;
        }