public DaggerfallInputMessageBox(
     IUserInterfaceManager uiManager,
     TextFile.Token[] textTokens,
     int maxCharacters = 31,
     string textBoxLabel = null,
     bool useParchmentBackGround = true,
     UserInterfaceWindow previous = null)
     : base(uiManager, previous)
 {
     this.textBox.MaxCharacters = maxCharacters;
     this.useParchmentStyle = useParchmentBackGround;
     this.SetTextBoxLabel(textBoxLabel);
     SetupBox(textTokens);
 }
        public void SetTextTokens(TextFile.Token[] tokens)
        {
            if (!IsSetup)
                Setup();

            label.SetText(tokens);
            UpdatePanelSizes();
        }
        void LayoutTextElements(TextFile.Token[] tokens)
        {
            labels.Clear();
            totalWidth = 0;
            totalHeight = 0;
            cursorX = 0;
            cursorY = 0;

            TextFile.Token token = new TextFile.Token();
            TextFile.Token nextToken = new TextFile.Token();
            for (int i = 0; i < tokens.Length; i++)
            {
                token = tokens[i];
                nextToken.formatting = TextFile.Formatting.Nothing;
                if (i < tokens.Length - 1)
                    nextToken = tokens[i + 1];

                // Still working out rules for justify logic
                // This will adapt over time as required
                switch (token.formatting)
                {
                    case TextFile.Formatting.NewLine:
                        NewLine();
                        break;
                    case TextFile.Formatting.JustifyLeft:
                        NewLine();
                        break;
                    case TextFile.Formatting.JustifyCenter:
                        if (lastLabel != null)
                            lastLabel.HorizontalAlignment = HorizontalAlignment.Center;
                        NewLine();
                        break;
                    case TextFile.Formatting.PositionPrefix:
                        if (token.x != 0)
                        {
                            // Tab by specific number of pixels
                            cursorX += token.x;
                        }
                        else
                        {
                            // Tab to next tab stop
                            tabStop++;
                            cursorX = tabStop * tabWidth;
                        }
                        break;
                    case TextFile.Formatting.Text:
                        TextLabel label = AddTextLabel(font, new Vector2(cursorX, cursorY), token.text);
                        label.TextColor = DaggerfallUI.DaggerfallDefaultTextColor;
                        label.ShadowColor = DaggerfallUI.DaggerfallDefaultShadowColor;
                        label.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos;
                        labels.Add(label);
                        lastLabel = label;
                        cursorX += label.TextWidth;
                        break;
                    default:
                        Debug.Log("MultilineTextLabel: Unknown formatting token: " + (int)token.formatting);
                        break;
                }

                if (lastLabel != null)
                {
                    int rowWidth = (int)lastLabel.Position.x + lastLabel.TextWidth;
                    if (rowWidth > totalWidth)
                        totalWidth = rowWidth;
                }
            }

            Size = new Vector2(totalWidth, totalHeight);
        }
        /// <summary>
        /// Sets the formatted text from a token array.
        /// </summary>
        /// <param name="tokens">Format token array.</param>
        public virtual void SetTextTokens(TextFile.Token[] tokens)
        {
            if (font == null)
                font = DaggerfallUI.DefaultFont;

            LayoutTextElements(tokens);
        }
 private void SetupBox(TextFile.Token[] tokens)
 {
     if (tokens != null)
         SetTextTokens(tokens);
 }
 public void SetTextTokens(TextFile.Token[] tokens)
 {
     multiLineLabel.SetText(tokens);
 }
 /// <summary>
 /// Adds formatted text labels from a RSC token array.
 /// </summary>
 /// <param name="tokens">Daggerfall RSC token array.</param>
 public virtual void SetText(TextFile.Token[] tokens)
 {
     LayoutTextElements(tokens);
 }