Gonzo.Elements.UILabel.UILabel C# (CSharp) Method

UILabel() public method

public UILabel ( AddTextNode Node, ParserState State, UIScreen Screen ) : Microsoft.Xna.Framework
Node UIParser.Nodes.AddTextNode
State UIParser.ParserState
Screen UIScreen
return Microsoft.Xna.Framework
        public UILabel(AddTextNode Node, ParserState State, UIScreen Screen)
            : base(Screen)
        {
            Name = Node.Name;
            m_ID = Node.ID;
            Position = new Vector2(Node.TextPosition.Numbers[0], Node.TextPosition.Numbers[1]) + Screen.Position;

            if (Node.Size != null)
                m_Size = new Vector2(Node.Size.Numbers[0], Node.Size.Numbers[1]);
            else
                m_Size = State.Size;

            if (Node.Color != null)
            {
                m_TextColor = new Color();
                m_TextColor.A = 255; //Ignore opacity, The Sims Online doesn't support transparent text.
                m_TextColor.R = (byte)Node.Color.Numbers[0];
                m_TextColor.G = (byte)Node.Color.Numbers[1];
                m_TextColor.B = (byte)Node.Color.Numbers[2];
            }
            else
            {
                m_TextColor = State.Color;
                m_TextColor.A = 255; //Ignore opacity, The Sims Online doesn't support transparent text.
            }

            if (Node.Alignment != 0)
                m_Alignment = Node.Alignment;
            else
                m_Alignment = (TextAlignment)State.Alignment;

            int Font = 0;
            if (Node.Font != null)
            {
                if (Node.Font != 0)
                    Font = (int)Node.Font;
            }
            else
                Font = State.Font;

            switch (Font)
            {
                    case 7:
                        m_Font = Screen.Font10px; //TODO: Fixme.
                    break;
                    case 9:
                    m_Font = Screen.Font9px;
                        break;
                    case 10:
                        m_Font = Screen.Font10px;
                        break;
                    case 12:
                        m_Font = Screen.Font12px;
                        break;
                    case 14:
                        m_Font = Screen.Font14px;
                        break;
                    case 16:
                        m_Font = Screen.Font16px;
                        break;
            }

            if (Node.Text != "")
                Caption = m_Screen.GetString(Node.Text);
            else
            {
                if(State.Caption != "")
                    //Sometimes labels will not have pre-defined text, as they will hold text
                    //generated in-game.
                    Caption = m_Screen.GetString(State.Caption);
            }

            AlignText();
        }