RlNiceX is a Raylib library for creating and styling interactive GUI and HUD widgets.
Example usages for all widgets + styling
import (
rl "github.com/gen2brain/raylib-go/raylib"
rlx "github.com/manen/rlnicex"
)
(You'll need a correctly initialized Raylib window)
Styles can be read from a JSON file. An example can be found here
Load style:
err := rlx.LoadStyle("./path/to/style.json")
if err != nil {
// Handle error
}
NOTE: You can create manual styles too. Not recommended though.
sc := rlx.StyleConfig{
Base: rlx.Style{
Background: rl.Black,
},
Held: rlx.Style{
BorderWidth: 4,
},
}
err := sc.Apply()
if err != nil {
// Handle error
}
If you've done this, all widgets will use the respected theme.
r := rlx.NewOffset(0, 0) // Why 'r'? I don't know, lol
for !rl.WindowShouldClose() {
widget.Render(r)
}
lbl := rlx.NewLabel("Label here!", false, 4, 4)
btn := rlx.NewButton(rlx.NewLabelSimple("Click me!"), 10, 10, 140, 40)
Check if clicked:
if btn.IsClicked(r) {
log.Println("Clicked!")
}