From 8cce750252bdb9a73fa5d4c659c81c0e9f0224d7 Mon Sep 17 00:00:00 2001 From: Ronja Date: Sun, 6 Sep 2020 17:45:33 +0200 Subject: [PATCH] make simple text work and use it to display name except block strings still dont work (: --- Luxe/blocks/human/human.wren | 2 +- Luxe/blocks/ui.wren | 12 +++++++++--- Luxe/blocks/ui/simple_text.wren | 14 ++++++++++---- Luxe/outline/settings.settings.lx | 2 +- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Luxe/blocks/human/human.wren b/Luxe/blocks/human/human.wren index d9af71a..96acf97 100644 --- a/Luxe/blocks/human/human.wren +++ b/Luxe/blocks/human/human.wren @@ -31,7 +31,7 @@ class Human { static get_name(entity){ if(entity == 0 || !entity) return null var data = Modifiers.get(This, entity) - return data.name + return Strings.get(data.name) } static get_color(entity){ diff --git a/Luxe/blocks/ui.wren b/Luxe/blocks/ui.wren index ee1b44a..56ee722 100644 --- a/Luxe/blocks/ui.wren +++ b/Luxe/blocks/ui.wren @@ -125,8 +125,15 @@ class Ui{ UIImage.set_color(portrait, Human.get_color(val) || [0, 0, 0, 1]) } - var name = Control.create(_ui) - Control.set_pos(name, 32, 1) + var name = UISimpleText.create(_ui) + 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(){ @@ -196,7 +203,6 @@ class Ui{ var i = Control.child_index(parent, button) Control.set_size(button, 16, 16) 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 } diff --git a/Luxe/blocks/ui/simple_text.wren b/Luxe/blocks/ui/simple_text.wren index 26e063c..92f2bd6 100644 --- a/Luxe/blocks/ui/simple_text.wren +++ b/Luxe/blocks/ui/simple_text.wren @@ -1,18 +1,24 @@ 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| - //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 } static set_text(con, text){ - System.print(text) + var data = Control.get_state_data(con) + data["text"] = text } } \ No newline at end of file diff --git a/Luxe/outline/settings.settings.lx b/Luxe/outline/settings.settings.lx index 1f7655a..ffe71ab 100644 --- a/Luxe/outline/settings.settings.lx +++ b/Luxe/outline/settings.settings.lx @@ -14,5 +14,5 @@ engine = { depth = 0 } - ui.debug_vis = true + //ui.debug_vis = true } \ No newline at end of file