public static WindowControl Error(ControlBase parent, GLWindow game, string text, string title) { var wc = new WindowControl(parent, title, false); wc.MakeModal(true); wc.Width = 200; RichLabel l = new RichLabel(wc); // Align.StretchHorizontally(l); l.Dock = Pos.Top; l.Width = wc.Width; l.AddText(text, parent.Skin.Colors.Label.Default, parent.Skin.DefaultFont); wc.Layout(); l.SizeToChildren(false, true); wc.Height = 65 + l.Height; Align.CenterHorizontally(l); Button btn = new Button(wc); btn.Name = "Okay"; btn.Text = "Okay"; btn.Height = 20; btn.Y = l.Y + l.Height + 10; btn.Width = 100; btn.Clicked += (o, e) => { ((WindowControl)o.Parent).Close(); }; Align.AlignLeft(l); wc.Show(); wc.SetPosition((game.RenderSize.Width / 2) - (wc.Width / 2), (game.RenderSize.Height / 2) - (wc.Height / 2)); wc.DisableResizing(); return(wc); }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(Skin.Base skin) { base.Layout(skin); Align.PlaceDownLeft(m_Button, m_Label, 10); Align.CenterHorizontally(m_Button); m_InnerPanel.SizeToChildren(); m_InnerPanel.Height += 10; SizeToChildren(); }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void layout(Skin.SkinBase skin) { base.layout(skin); Align.PlaceDownLeft(button, label, 10); Align.CenterHorizontally(button); innerPanel.SizeToChildren(); innerPanel.Height += 10; SizeToChildren(); }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(Skin.Base skin) { base.Layout(skin); if (m_Image != null) { Align.CenterVertically(m_Image); if (m_CenterImage) { Align.CenterHorizontally(m_Image); } } }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void layout(Skin.SkinBase skin) { base.layout(skin); if (image != null) { Align.CenterVertically(image); if (centerImage) { Align.CenterHorizontally(image); } } }
private void _spriteDropdown_ItemSelected(Base sender, ItemSelectedEventArgs arguments) { SpritePanel.Texture = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Entity, mSpriteDropdown.Text ); if (SpritePanel.Texture != null) { SpritePanel.SetTextureRect(0, 0, SpritePanel.Texture.GetWidth() / Options.Instance.Sprites.NormalFrames, SpritePanel.Texture.GetHeight() / Options.Instance.Sprites.Directions); SpritePanel.SetSize(SpritePanel.Texture.GetWidth() / Options.Instance.Sprites.NormalFrames, SpritePanel.Texture.GetHeight() / Options.Instance.Sprites.Directions); Align.AlignTop(SpritePanel); Align.CenterHorizontally(SpritePanel); } }
private void _spriteDropdown_ItemSelected(Base sender, ItemSelectedEventArgs arguments) { SpritePanel.Texture = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Entity, mSpriteDropdown.Text ); if (SpritePanel.Texture != null) { SpritePanel.SetUv(0, 0, .25f, .25f); SpritePanel.SetSize(SpritePanel.Texture.GetWidth() / 4, SpritePanel.Texture.GetHeight() / 4); Align.AlignTop(SpritePanel); Align.CenterHorizontally(SpritePanel); } }
public static WindowControl Create(ControlBase parent, GLWindow game, string text, string title, bool ok, bool cancel) { var wc = new WindowControl(parent, title, false); wc.MakeModal(true); wc.Width = 200; RichLabel l = new RichLabel(wc); // Align.StretchHorizontally(l); l.Dock = Pos.Top; l.Width = wc.Width; l.AddText(text, parent.Skin.Colors.Label.Default, parent.Skin.DefaultFont); wc.Layout(); l.SizeToChildren(false, true); wc.Height = 65 + l.Height; Align.CenterHorizontally(l); if (ok) { Button btn = new Button(wc); btn.Name = "Okay"; btn.Text = "Okay"; btn.Height = 20; btn.Y = l.Y + l.Height + 10; btn.Width = 100; Align.AlignLeft(l); } if (cancel) { Button btn = new Button(wc); btn.Name = "Cancel"; btn.Text = "Cancel"; btn.SizeToContents(); btn.Height = 20; btn.Width = 70; btn.Y = l.Y + l.Height + 10; btn.X = (wc.Width - 12) - btn.Width; } wc.Show(); wc.SetPosition((game.RenderSize.Width / 2) - (wc.Width / 2), (game.RenderSize.Height / 2) - (wc.Height / 2)); wc.DisableResizing(); return(wc); }
private void _myWindow_BeforeDraw(Base sender, EventArgs arguments) { if (!mInitialized) { mMyWindow.LoadJsonUi(_uiStage, Graphics.Renderer.GetResolutionString(), true); var text = Interface.WrapText(mPrompt, mPromptLabel.Width, mPromptLabel.Font); var y = mPromptLabel.Y; foreach (var s in text) { var label = new Label(mMyWindow) { Text = s, TextColorOverride = mPromptLabel.TextColor, Font = mPromptLabel.Font }; label.SetPosition(mPromptLabel.X, y); y += label.Height; Align.CenterHorizontally(label); } switch (mInputType) { case InputType.YesNo: mYesButton.Text = Strings.InputBox.yes; mNoButton.Text = Strings.InputBox.no; mOkayButton.Hide(); mYesButton.Show(); mNoButton.Show(); mNumericTextboxBg.Hide(); mTextboxBg.Hide(); break; case InputType.OkayOnly: mOkayButton.Show(); mYesButton.Hide(); mNoButton.Hide(); mNumericTextboxBg.Hide(); mTextboxBg.Hide(); break; case InputType.NumericInput: mOkayButton.Hide(); mYesButton.Show(); mNoButton.Show(); mNumericTextboxBg.Show(); mTextboxBg.Hide(); break; case InputType.TextInput: mOkayButton.Hide(); mYesButton.Show(); mNoButton.Show(); mNumericTextboxBg.Hide(); mTextboxBg.Show(); break; } mMyWindow.Show(); mMyWindow.Focus(); mInitialized = true; } }