make simple text work and use it to display name
except block strings still dont work (:
This commit is contained in:
parent
1ad9014fb1
commit
8cce750252
4 changed files with 21 additions and 9 deletions
|
|
@ -31,7 +31,7 @@ class Human {
|
||||||
static get_name(entity){
|
static get_name(entity){
|
||||||
if(entity == 0 || !entity) return null
|
if(entity == 0 || !entity) return null
|
||||||
var data = Modifiers.get(This, entity)
|
var data = Modifiers.get(This, entity)
|
||||||
return data.name
|
return Strings.get(data.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static get_color(entity){
|
static get_color(entity){
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,15 @@ class Ui{
|
||||||
UIImage.set_color(portrait, Human.get_color(val) || [0, 0, 0, 1])
|
UIImage.set_color(portrait, Human.get_color(val) || [0, 0, 0, 1])
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = Control.create(_ui)
|
var name = UISimpleText.create(_ui)
|
||||||
Control.set_pos(name, 32, 1)
|
Control.set_pos(name, 33, 1)
|
||||||
|
Control.child_add(root, name)
|
||||||
|
Control.set_allow_input(name, true)
|
||||||
|
Control.set_id(name, "human name info")
|
||||||
|
Globals["Game"].Focus.on_change(true) {|val|
|
||||||
|
var name_string = Human.get_name(val) || "-"
|
||||||
|
UISimpleText.set_text(name, name_string)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_planning(){
|
setup_planning(){
|
||||||
|
|
@ -196,7 +203,6 @@ class Ui{
|
||||||
var i = Control.child_index(parent, button)
|
var i = Control.child_index(parent, button)
|
||||||
Control.set_size(button, 16, 16)
|
Control.set_size(button, 16, 16)
|
||||||
Control.set_pos(button, i*16, 0) //let list handle this in future
|
Control.set_pos(button, i*16, 0) //let list handle this in future
|
||||||
System.print("%(Control.get_pos_x(button)), %(Control.get_pos_y(button))")
|
|
||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,24 @@
|
||||||
import "luxe: ui/control" for Control
|
import "luxe: ui/control" for Control
|
||||||
|
import "luxe: world" for UI
|
||||||
|
import "luxe: render" for TextAlign
|
||||||
|
|
||||||
class UISimpleText{
|
class UISimpleText{
|
||||||
|
static font{"assets/fonts/BabyBlocks"}
|
||||||
|
static size{8}
|
||||||
|
|
||||||
static create(ent){
|
static create(ent){
|
||||||
var text = Control.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|
|
Control.set_render(text) {|control, state, x,y,w,h|
|
||||||
//System.print(control)
|
UI.draw_text(control, x, y + size/2, 0, state["text"], size, font, [1,1,1,1], TextAlign.left, TextAlign.top)
|
||||||
}
|
}
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
static set_text(con, text){
|
static set_text(con, text){
|
||||||
System.print(text)
|
var data = Control.get_state_data(con)
|
||||||
|
data["text"] = text
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -14,5 +14,5 @@ engine = {
|
||||||
depth = 0
|
depth = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.debug_vis = true
|
//ui.debug_vis = true
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue