/// <summary> /// Creates a new instance of the <see cref="PoroCYon.MCT.UI.Interface.MessageBox"/> class. /// </summary> /// <param name="text">The text the message box contains</param> /// <param name="caption">The caption of the message box</param> /// <param name="btn">The button type of the message box</param> public MessageBox(string text, string caption, MessageBoxButton btn) : base(caption) { OnClosed += (w) => { Result(this, null); }; TextBlock t = new TextBlock(text); AddControl(t); OnUpdate += (c) => { if (TextIsCopyable && GInput.Mouse.Rectangle.Intersects(Hitbox) && GInput.Mouse.Left) Clipboard.SetText(t.Text); }; switch (btn) { case MessageBoxButton.OK: { TextButton ok = new TextButton("OK"); ok.OnClicked += (b) => { Result(this, true); }; ok.Position = new Vector2(0f, t.Hitbox.Height); AddControl(ok); } break; case MessageBoxButton.YesNo: { TextButton y = new TextButton("Yes"); y.OnClicked += (b) => { Result(this, true); }; y.Position = new Vector2(0f, t.Hitbox.Height + 16f); AddControl(y); TextButton n = new TextButton("No"); n.OnClicked += (b) => { Result(this, false); }; n.Position = new Vector2(0f, t.Hitbox.Height + y.Hitbox.Height + 16f); AddControl(n); } break; } }
/// <summary> /// Initializes the Control /// </summary> public override void Init() { Position += topBar; base.Init(); Position -= topBar; close = new TextButton("X") { Colour = new Color(255, 255, 255, 0), OnClicked = (c) => { Destroy(); } }; }