예제 #1
0
        public void UpdateTextTokens(List <TextToken2D> textTokens, params string[] parameters)
        {
            this.textToken2Ds = textTokens;

            this.indexToParameterTextTokens.Clear();
            int index = 0;

            foreach (TextToken2D textToken in this.textToken2Ds)
            {
                if (textToken is ParameterTextToken2D)
                {
                    ParameterTextToken2D parameterTextToken2D = textToken as ParameterTextToken2D;

                    this.indexToParameterTextTokens.Add(index++, parameterTextToken2D);
                }

                textToken.CharacterSize = this.CharacterSize;
                textToken.SpriteColor   = this.SpriteColor;
                textToken.CustomZoom    = this.CustomZoom;
            }

            index = 0;
            foreach (string parameter in parameters)
            {
                this.SetParameterText(index, parameter);

                index++;
            }

            this.AlignTextTokens();
        }
예제 #2
0
        private void SetParameterText(int index, string text)
        {
            ParameterTextToken2D parameterTextToken2D = this.indexToParameterTextTokens[index];
            int indexParameterTextToken = this.textToken2Ds.IndexOf(parameterTextToken2D) + 1;

            this.textToken2Ds.RemoveRange(indexParameterTextToken, parameterTextToken2D.NbHandlingToken);

            this.textToken2Ds.InsertRange(indexParameterTextToken, parameterTextToken2D.CreateTextToken2DFrom(text));
        }
예제 #3
0
        public void UpdateParameterColor(int index, Color color)
        {
            ParameterTextToken2D parameterTextToken2D = this.indexToParameterTextTokens[index];
            int indexParameterTextToken = this.textToken2Ds.IndexOf(parameterTextToken2D);

            for (int i = 0; i < parameterTextToken2D.NbHandlingToken + 1; i++)
            {
                this.textToken2Ds[indexParameterTextToken + i].FillTextColor = color;
            }
        }
예제 #4
0
        public void AppendTextTokens(List <TextToken2D> tokenListToAppend, string text, string tokenType, Color fillColor)
        {
            string[] textTokens = text.Split(' ');

            foreach (string textToken in textTokens)
            {
                if (string.IsNullOrEmpty(textToken) == false)
                {
                    TextToken2D textToken2D = null;

                    if (textToken.StartsWith("{") && textToken.EndsWith("}") && int.TryParse(textToken.Substring(1, textToken.Length - 2), out int parameterIndex))
                    {
                        textToken2D = new ParameterTextToken2D(tokenType, fillColor);
                    }
                    else
                    {
                        textToken2D = CreateTextToken(tokenType, textToken, fillColor);
                    }

                    tokenListToAppend.Add(textToken2D);
                }
            }
        }