From ee2dbc9c0a7bb1c4162d996ef7c8bb7056916041 Mon Sep 17 00:00:00 2001 From: Ronja Date: Wed, 9 Sep 2020 16:12:39 +0200 Subject: [PATCH] try to do outlines via frankenfont --- Luxe/assets/fonts/BabyBlocksBigger.font.lx | 7 +++++ Luxe/assets/fonts/src/BabyBlocksBigger.ttf | 3 ++ Luxe/blocks/human/human.wren | 9 ++++-- Luxe/blocks/tooltip.wren | 35 +++++++++++++++------- Luxe/blocks/ui.wren | 2 +- Luxe/blocks/ui/simple_text.wren | 2 +- 6 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 Luxe/assets/fonts/BabyBlocksBigger.font.lx create mode 100644 Luxe/assets/fonts/src/BabyBlocksBigger.ttf diff --git a/Luxe/assets/fonts/BabyBlocksBigger.font.lx b/Luxe/assets/fonts/BabyBlocksBigger.font.lx new file mode 100644 index 0000000..08db481 --- /dev/null +++ b/Luxe/assets/fonts/BabyBlocksBigger.font.lx @@ -0,0 +1,7 @@ +font = { + source = "assets/fonts/src/BabyBlocksBigger.ttf" + ranges = [ + "0020-007F" + "00A0-00FF" + ] +} \ No newline at end of file diff --git a/Luxe/assets/fonts/src/BabyBlocksBigger.ttf b/Luxe/assets/fonts/src/BabyBlocksBigger.ttf new file mode 100644 index 0000000..27a2811 --- /dev/null +++ b/Luxe/assets/fonts/src/BabyBlocksBigger.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba5e85836bbbc4991c3190b4f888e7751cfb2d24da9b44e00fdd7e556300ad38 +size 10856 diff --git a/Luxe/blocks/human/human.wren b/Luxe/blocks/human/human.wren index 96acf97..1cb099e 100644 --- a/Luxe/blocks/human/human.wren +++ b/Luxe/blocks/human/human.wren @@ -23,9 +23,8 @@ class Human { } static set_name(entity, name){ var data = Modifiers.get(This, entity) - var id = Strings.add(name) - System.print("Setting name of %(entity) to %(name) via string id of %(id).") - //data.name = id + Strings.add(name) + data.name = name } static get_name(entity){ @@ -77,6 +76,8 @@ class HumanSystem is ModifierSystem { } tick(delta) { + if(World.tag_has(_world, "edit")) return + //called usually once every frame. //called when the world that this modifier lives in, is ticked each {|entity, data| @@ -105,6 +106,8 @@ class HumanSystem is ModifierSystem { } //tick update(){ + if(World.tag_has(_world, "edit")) return + var size = Vector.new(player_size) var pos = Vector.new(player_start) + size / 2 each {|entity, data| diff --git a/Luxe/blocks/tooltip.wren b/Luxe/blocks/tooltip.wren index 74cbe52..4beef7d 100644 --- a/Luxe/blocks/tooltip.wren +++ b/Luxe/blocks/tooltip.wren @@ -7,15 +7,23 @@ import "math/vector" for Vector class Tooltip{ depth{100} color{[1, 1, 1, 1]} + background{[1, 0, 1, 1]} construct new(app){ - _ent = Entity.create(app.ui) - _mat_font = Assets.material("luxe: material/font") - Text.create(_ent, _mat_font, 8, "assets/fonts/BabyBlocks", color) + _text = Entity.create(app.ui) + _bg = Entity.create(app.ui) + var font1 = Assets.material("luxe: material/font") + var font2 = Assets.material("luxe: material/font") + Text.create(_bg, font1, 8, "assets/fonts/BabyBlocksBigger", background) + Text.create(_text, font2, 8, "assets/fonts/BabyBlocks", color) - Transform.create(_ent) - Transform.set_pos(_ent, 64, 128, depth) - Transform.set_snap(_ent, 1, 1, 0) + Transform.create(_text) + Transform.set_pos(_text, 64, 128, depth) + Transform.set_snap(_text, 1, 1, 0) + + Transform.create(_bg) + Transform.set_pos(_bg, 64, 128, depth) + Transform.set_snap(_bg, 1, 1, 0) Globals["Tooltip"] = this } @@ -29,7 +37,8 @@ class Tooltip{ if(_y){ pos.y = _y } - Transform.set_pos(_ent, pos.x, pos.y, depth) + Transform.set_pos(_text, pos.x, pos.y, depth) + Transform.set_pos(_bg, pos.x, pos.y - 1, depth-1) } } @@ -46,8 +55,10 @@ class Tooltip{ } set(text, source){ - Text.set_text_buffer(_ent, text) - Text.commit(_ent) + Text.set_text_buffer(_bg, text) + Text.commit(_bg) + //Text.set_text_buffer(_text, text) + //Text.commit(_text) _active = true _source = source _x = null @@ -62,8 +73,10 @@ class Tooltip{ if(_source != source) { return } - Text.set_text_buffer(_ent, "") - Text.commit(_ent) + Text.set_text_buffer(_text, "") + Text.commit(_text) + Text.set_text_buffer(_bg, "") + Text.commit(_bg) _active = false } } \ No newline at end of file diff --git a/Luxe/blocks/ui.wren b/Luxe/blocks/ui.wren index 56ee722..819b3e3 100644 --- a/Luxe/blocks/ui.wren +++ b/Luxe/blocks/ui.wren @@ -132,7 +132,7 @@ class Ui{ 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) + UISimpleText.set_text(name, name_string + "\n" + name_string) } } diff --git a/Luxe/blocks/ui/simple_text.wren b/Luxe/blocks/ui/simple_text.wren index 92f2bd6..5864c50 100644 --- a/Luxe/blocks/ui/simple_text.wren +++ b/Luxe/blocks/ui/simple_text.wren @@ -10,7 +10,7 @@ class UISimpleText{ 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| UI.draw_text(control, x, y + size/2, 0, state["text"], size, font, [1,1,1,1], TextAlign.left, TextAlign.top) } return text