CrabUI
Loading...
Searching...
No Matches
CUIMessageBox.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5using Barotrauma;
6using Microsoft.Xna.Framework;
7using Microsoft.Xna.Framework.Input;
8using Microsoft.Xna.Framework.Graphics;
9
10namespace CrabUI
11{
12 /// <summary>
13 /// Simple dialog box with a message and ok button
14 /// use public static void Open(string msg) to open it
15 /// </summary>
16 public class CUIMessageBox : CUIFrame
17 {
18 public static void Open(string msg)
19 {
21 }
22
23
24 public CUIMessageBox(string msg) : base()
25 {
26 Palette = PaletteOrder.Quaternary;
27 Resizible = false;
28
29 Relative = new CUINullRect(0, 0, 0.25f, 0.25f);
30 Anchor = CUIAnchor.Center;
31
32 OutlineThickness = 2;
33
34 this["layout"] = new CUIVerticalList()
35 {
36 Relative = new CUINullRect(0, 0, 1, 1),
37 };
38
39 this["layout"]["main"] = new CUIVerticalList()
40 {
41 FillEmptySpace = new CUIBool2(false, true),
42 Scrollable = true,
43 ScrollSpeed = 0.5f,
44 Style = CUIStylePrefab.Main,
45 };
46
47 this["layout"]["main"]["msg"] = new CUITextBlock(msg)
48 {
49 TextScale = 1.2f,
50 Wrap = true,
51 Font = GUIStyle.Font,
52 TextAlign = CUIAnchor.TopCenter,
53 Style = new CUIStyle()
54 {
55 ["Padding"] = "[10,10]",
56 },
57 };
58 this["layout"]["ok"] = new CUIButton("Ok")
59 {
60 TextScale = 1.0f,
61 Style = new CUIStyle()
62 {
63 ["Padding"] = "[10,10]",
64 },
65 AddOnMouseDown = (e) => this.RemoveSelf(),
66 };
67 }
68
69
70 }
71}
CUIAnchor is just a Vector2 This is a static class containing some helper methods.
Definition CUIAnchor.cs:18
A button It's derived from CUITextBlock and has all its props.
Definition CUIButton.cs:19
CUIBool2 FillEmptySpace
Will be resized to fill empty space in list components.
PaletteOrder Palette
This palette will be used to resolve palette styles Primary, Secondary, Tertiary,...
CUINullRect Relative
Relative to parent size and position, [0..1].
virtual CUIComponent Append(CUIComponent child, string name=null, [CallerMemberName] string memberName="")
Adds children to the end of the list.
CUIStyle Style
Allows you to assing parsable string or link to CUIPalette to any prop It's indexable,...
Vector2 Anchor
this point of this component
Draggable and resizable container for other components.
Definition CUIFrame.cs:16
In fact a static class managing static things.
Definition CUIErrors.cs:16
static CUIMainComponent TopMain
Orchestrates Drawing and updates, there could be only one CUI.TopMain is located above vanilla GUI.
Definition CUI.cs:89
Simple dialog box with a message and ok button use public static void Open(string msg) to open it.
In Fact just an observable dict.
Definition CUIStyle.cs:21
Passive block of text.
Resizing components to it's Width and placing them sequentially.
Vector2 but with bools.
Definition CUIBool2.cs:17
Rectangle with float?
Definition CUIRect.cs:104