CabinGame/Luxe/blocks/ui/simple_text.wren
2020-09-09 16:12:39 +02:00

24 lines
No EOL
651 B
Text

import "luxe: ui/control" for Control
import "luxe: world" for UI
import "luxe: render" for TextAlign
class UISimpleText{
static font{"assets/fonts/BabyBlocks"}
static size{8}
static create(ent){
var text = Control.create(ent)
Control.set_state_data(text, {"text": ""})
Control.set_size(text, 100, size)
Control.set_render(text) {|control, state, x, y, w, h|
UI.draw_text(control, x, y + size/2, 0, state["text"], size, font, [1,1,1,1], TextAlign.left, TextAlign.top)
}
return text
}
static set_text(con, text){
var data = Control.get_state_data(con)
data["text"] = text
}
}