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

UIButton() public method

public UIButton ( AddButtonNode Node, ParserState State, UIScreen Screen ) : Files
Node UIParser.Nodes.AddButtonNode
State UIParser.ParserState
Screen UIScreen
return Files
        public UIButton(AddButtonNode Node, ParserState State, UIScreen Screen)
            : base(Screen)
        {
            Name = Node.Name;
            m_ID = Node.ID;
            m_Screen = Screen;

            if (!State.InSharedPropertiesGroup)
            {
                if (Node.Image != null)
                {
                    Image = m_Screen.GetImage(Node.Image, false);
                    //Initialize to second frame in the image.
                    m_SourcePosition = new Vector2((Image.Texture.Width / (4)) * 2, 0.0f);

                    m_Size = new Vector2();
                    m_Size.X = (Image.Texture.Width) / (4);
                    m_Size.Y = Image.Texture.Height;

                    Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                }
                else
                {
                    Image = new UIImage(FileManager.GetTexture((ulong)FileIDs.UIFileIDs.buttontiledialog), m_Screen);
                    //Initialize to second frame in the image.
                    m_SourcePosition = new Vector2((Image.Texture.Width / 4) * 2, 0.0f);

                    m_Size = new Vector2();
                    m_Size.X = (Image.Texture.Width) / (4);
                    m_Size.Y = Image.Texture.Height;

                    Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                }
            }
            else
            {
                if (State.Image != "")
                {
                    Image = m_Screen.GetImage(State.Image, true);
                    //Initialize to second frame in the image.
                    m_SourcePosition = new Vector2((Image.Texture.Width / 4) * 2, 0.0f);

                    m_Size = new Vector2();
                    m_Size.X = Image.Texture.Width / 4;
                    m_Size.Y = Image.Texture.Height;

                    Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                }
                else
                {
                    if (State.TextButton)
                    {
                        m_Text = State.Caption;
                        //Text buttons always use this image.
                        Image = new UIImage(FileManager.GetTexture((ulong)FileIDs.UIFileIDs.buttontiledialog), m_Screen);
                        //Initialize to second frame in the image.
                        m_SourcePosition = new Vector2((Image.Texture.Width / 4) * 2, 0.0f);

                        m_Size = new Vector2();
                        m_Size.X = Image.Texture.Width / 4;
                        m_Size.Y = Image.Texture.Height;
                    }
                    else
                    {
                        Image = m_Screen.GetImage(Node.Image, false);
                        //Initialize to second frame in the image.
                        m_SourcePosition = new Vector2((Image.Texture.Width / (4)) * 2, 0.0f);

                        m_Size = new Vector2();
                        m_Size.X = (Image.Texture.Width) / (4);
                        m_Size.Y = Image.Texture.Height;

                        Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                    }

                    Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                }

                if (State.Tooltip != "")
                    Tooltip = m_Screen.GetString(State.Tooltip);
            }

            if (Node.TextHighlighted != null)
                m_IsTextHighlighted = (Node.TextHighlighted == 1) ? true : false;

            if (Node.Font != null)
            {
                int FontSize = (int)Node.Font;

                switch (FontSize)
                {
                    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;
                }
            }
            else if(State.Font != 0)
            {
                switch (State.Font)
                {
                    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;
                    default:
                        m_Font = Screen.Font12px;
                        break;
                }
            }

            if (Node.TextColor != null)
            {
                TextColor = new Color();
                TextColor.A = 255;
                TextColor.R = (byte)Node.TextColor.Numbers[0];
                TextColor.G = (byte)Node.TextColor.Numbers[1];
                TextColor.B = (byte)Node.TextColor.Numbers[2];
            }
            else
            {
                TextColor = State.TextColor;
                TextColor.A = 255;
            }

            if (Node.TextColorSelected != null)
            {
                TextColorSelected = new Color();
                TextColorSelected.A = 255;
                TextColorSelected.R = (byte)Node.TextColorSelected.Numbers[0];
                TextColorSelected.G = (byte)Node.TextColorSelected.Numbers[1];
                TextColorSelected.B = (byte)Node.TextColorSelected.Numbers[2];
            }
            else
            {
                TextColorSelected = State.TextColorSelected;
                TextColorSelected.A = 255;
            }

            if (Node.TextColorHighlighted != null)
            {
                TextColorHighlighted = new Color();
                TextColorHighlighted.A = 255;
                TextColorHighlighted.R = (byte)Node.TextColorHighlighted.Numbers[0];
                TextColorHighlighted.G = (byte)Node.TextColorHighlighted.Numbers[1];
                TextColorHighlighted.B = (byte)Node.TextColorHighlighted.Numbers[2];
            }
            else
            {
                TextColorHighlighted = State.TextColorHighlighted;
                TextColorHighlighted.A = 255;
            }

            if (Node.TextColorDisabled != null)
            {
                TextColorDisabled = new Color();
                TextColorDisabled.A = 255;
                TextColorDisabled.R = (byte)Node.TextColorDisabled.Numbers[0];
                TextColorDisabled.G = (byte)Node.TextColorDisabled.Numbers[1];
                TextColorDisabled.B = (byte)Node.TextColorDisabled.Numbers[2];
            }
            else
            {
                TextColorDisabled = State.TextColorDisabled;
                TextColorDisabled.A = 255;
            }

            if (Node.TextButton != null)
                m_IsTextButton = (Node.TextButton == 1) ? true : false;
            else
                m_IsTextButton = m_IsTextButton = State.TextButton;

            if (m_IsTextButton)
            {
                if (Node.Text != string.Empty)
                    m_Text = m_Screen.GetString(Node.Text);
                else
                    m_Text = m_Screen.GetString(State.Caption);

                m_TextPosition = Position;

                if (m_Size.X != 0)
                    ScaleToText();
            }

            if (Node.Tooltip != "")
                Tooltip = m_Screen.GetString(Node.Tooltip);

            if (Node.Tracking != null)
                Tracking = (int)Node.Tracking;
        }

Same methods

UIButton::UIButton ( string Name, Microsoft.Xna.Framework.Graphics.Texture2D Tex, Vector2 Pos, UIScreen Screen, UIElement Parent = null ) : Files