Exemplo n.º 1
0
        protected DialogWindow(string title, string text, string yesText, string noText)
            : base(WindowFlags.CustomAnim | WindowFlags.Blackout)
        {
            m_panel = new WidgetWindow(WidgetManager.GetStyle("dialog_window"));
            Vector2 size = m_panel.Size;

            m_text           = new WidgetText();
            m_text.Text      = text;
            m_text.Size      = new Vector2(size.X, 0);
            m_text.MaxWidth  = size.X - 40;
            m_text.FontSize *= 1.25f;
            m_text.TextAlign = WidgetAlign.VerticalCenter | WidgetAlign.HorizontalCenter;
            m_text.Relayout();
            size            = m_panel.Size = m_panel.Size + new Vector2(0, m_text.Size.Y - 80);
            m_text.Position = new Vector2(0, size.Y / 2 - m_text.Size.Y / 2);
            m_panel.AddChild(m_text);

            Size = size;

            if (!string.IsNullOrEmpty(noText))
            {
                m_noButton      = new WidgetButton(noText);
                m_noButton.Size = new Vector2(128, 48);

                m_noButton.Position = new Vector2(size.X * 2 / 3 - (m_noButton.Size.X) / 2, size.Y - m_noButton.Size.Y - 25);
                m_noButton.OnPress += delegate { HandleButtonPress(1); };
                m_panel.AddChild(m_noButton);
            }

            m_yesButton          = new WidgetButton(yesText);
            m_yesButton.Size     = new Vector2(128, 48);
            m_yesButton.Position = new Vector2(m_noButton == null ? size.X / 2 - (m_yesButton.Size.X) / 2 : size.X / 3 - m_yesButton.Size.X * 0.25f, size.Y - m_yesButton.Size.Y - 25);
            m_yesButton.OnPress += delegate { HandleButtonPress(0); };
            m_panel.AddChild(m_yesButton);

            m_closeButton              = new WidgetButton(WidgetManager.GetStyle("image_button"), "");
            m_closeButton.Size         = new Vector2(40, 40);
            m_closeButton.Image        = "close_icon";
            m_closeButton.ImagePadding = new Margin(10, 10, 10, 10);
            m_closeButton.Position     = new Vector2(size.X - m_closeButton.Size.X, 0);
            m_closeButton.OnPress     += delegate { HandleButtonPress(2); };
            m_panel.AddChild(m_closeButton);

            m_title           = new WidgetLabel();
            m_title.Text      = title;
            m_title.Size      = new Vector2(size.X, 50);
            m_title.Position  = new Vector2(0, 20);
            m_title.FontSize *= 1.5f;
            m_title.TextAlign = WidgetAlign.Top | WidgetAlign.HorizontalCenter;
            m_panel.AddChild(m_title);

            AddChild(m_panel);
        }