-
Notifications
You must be signed in to change notification settings - Fork 2
Creating a GUI
GUIs can be made from extending the Gui class and implementing the PopulateWidgets method.
Creating a widget and adding it with AddWidget will add it as a top level widget. In this case the parent is null. All widgets are removed and disposed before PopulateWidgets is called.
Creating a widget with a non-null parent will automatically add it as a child.
Widgets have built in bounds for them to position based on their parent.
A widgets position and size can be set with one of the many Fixed() and Percent() methods. The x, y, width, and height can have either a fixed or percent value. The fixed position will not be dependent on the current GUI scale (1x-4x), but the size will be multiplied by it.
If no parent is set it will align to the game window.
Gui.Scaled() can be used to get a position multiplied by the current GUI scale, in the case where you need to offset a list of elements.
A widget will align to it's parent based on what is set with Align(). It will align perfectly to that axis when 0 position is set, with the position being the offset from that. Flags can be set to align outside of that horizontally or vertically.
Child sizing can be set with ChildSizing(). The once flag can be set to only try to fit it's immediate children.
Simply create your new GUI object and call TryOpen() to open it with the GUI manager, this GUI extends the vanilla GUI.