CabinGame/Luxe/blocks/ui/simple_text.wren

24 lines
651 B
Text
Raw Normal View History

2020-09-06 15:04:41 +00:00
import "luxe: ui/control" for Control
import "luxe: world" for UI
import "luxe: render" for TextAlign
2020-09-06 15:04:41 +00:00
class UISimpleText{
static font{"assets/fonts/BabyBlocks"}
static size{8}
2020-09-06 15:04:41 +00:00
static create(ent){
var text = Control.create(ent)
Control.set_state_data(text, {"text": ""})
Control.set_size(text, 100, size)
2020-09-09 14:12:39 +00:00
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)
2020-09-06 15:04:41 +00:00
}
return text
}
static set_text(con, text){
var data = Control.get_state_data(con)
data["text"] = text
2020-09-06 15:04:41 +00:00
}
}