Skip to content

UI Objects

SWCreeperKing edited this page Apr 10, 2022 · 1 revision

RayWrapper contains ALOT of UI elements

Every UI Element inherits from GameObject

Styles

Most UI objects have both a default style and a current style. The default style is static while style is not and is per UI element. All styles are located in their respective GameObject, using the Style of Text as an Example: Text.Style. Most Styles have a Draw() to them, however only Text and Label have their Style's Draw() be independent from the actual object. Some Styles like Text have a DrawMode for how the text should be drawn, for example: DrawMode.Center which draws the text centered on the position its given. Styles ALSO have a Copy() method, so if you want to copy a style (in most cases) you can just do object.style.Copy().

Unconventional Styles

RectStyle

RectStyle is found in the RectWrapper static class via RectWrapper.RectStyle. It is used to draw a rectangle via StyleClasses. It consists of a color, if the edges should be round, how round the edges should be, and the amount of segments for the rounded edges. Its Draw() requires a rectangle.

OutlineStyle

Nearly identical to RectStyle, but this draws an outline rather than a filled rectangle. It also differs in the way that it has a thickness field for line thickness and a display outline field for if you wanted to display it or not (true by default).

Text

If you want to draw text to the screen, then the Text object has you covered. Text has 2 constructors where the only difference is that one takes a Vector2 and the other takes a Rectangle. The reason behind this is the Rectangle constructor should only really be used for the need of Style.DrawMode.Wrap which is for text wrap. The BIGGEST reason why you should use Text and anything else that uses Text is the setting of a default font. By default RayWrapper uses Raylib's default font, but that can easily be changed by using Text.Style.SetDefaultFont(Raylib.LoadFont(path)). When you change the default font this way, ALL Text objects receive that font as their new default, as long as the Text does not have its local font set with object.SetFont()

RichText

  • inherits Text.Style

RichText is like Text but not, it has 2 major differences. 1 difference is that it does not use Actionable<string>, if you want to change its text you need to use UpdateText(newText). The reason why it doesn't use an Actionable<string> is because of its second major difference from Text, which is that you can change the color mid text. To change color mid text you can add [#insert color's hex value], or [#ff0a0a] as an example. But that's not all! You can use [@color name] like [@blue], but what colors does it except? it accepts any of these colors.

Label

Labels are cool little objects, as they have a click checker that checks if the mouse clicked on it, and also a hover check with the colors automatically adjusting. Label's style can also be used without the actual object like (Text)[#text]'s style can, however you need to forgo their click checking.

THERE ARE A LOT OF UI ELEMENTS TO DOCUMENT, SO IT MIGHT TAKE SOME TIME FOR THEM ALL TO APPEAR HERE

Clone this wiki locally