From 6e1db30a8bcfdc24be7221cc617b1b6f712ff3d9 Mon Sep 17 00:00:00 2001 From: Ronja Date: Sat, 12 Sep 2020 07:21:12 +0200 Subject: [PATCH] move to luxe 2020.3 --- Luxe/assets/names.lx | 26 +++++++++++++------------- Luxe/blocks/human/human.modifier.lx | 13 ++++++++----- Luxe/blocks/human/human.modifier.wren | 26 ++++++++++++++++++++++++-- Luxe/blocks/human/human.wren | 11 +++++++++++ Luxe/blocks/tooltip.wren | 13 +++++++------ Luxe/blocks/ui.wren | 21 ++++++++++++++------- Luxe/game.wren | 7 +++---- Luxe/math/util.wren | 2 +- Luxe/outline/app.wren | 7 ++----- Luxe/outline/renderer.wren | 5 +++-- Luxe/outline/settings.settings.lx | 2 +- Luxe/project.luxe | 6 +++--- Luxe/project.modules.lx | 2 +- 13 files changed, 91 insertions(+), 50 deletions(-) diff --git a/Luxe/assets/names.lx b/Luxe/assets/names.lx index e6f25e5..1faea76 100644 --- a/Luxe/assets/names.lx +++ b/Luxe/assets/names.lx @@ -3,18 +3,18 @@ names = [ //make groups based on origin culture / meaning //probably better to do when I have a procgen text engine - "Bob", - "Steve", - "Ronja", - "Amelia", - "Chloe", - "Lauren", - "Innes", - "Rami", - "Mao", - "Richard", - "Jules", - "Mercedes", - "Karl", + "Bob" + "Steve" + "Ronja" + "Amelia" + "Chloe" + "Lauren" + "Innes" + "Rami" + "Mao" + "Richard" + "Jules" + "Mercedes" + "Karl" "Lara" ] \ No newline at end of file diff --git a/Luxe/blocks/human/human.modifier.lx b/Luxe/blocks/human/human.modifier.lx index aa5ae7d..6c42606 100644 --- a/Luxe/blocks/human/human.modifier.lx +++ b/Luxe/blocks/human/human.modifier.lx @@ -1,16 +1,19 @@ modifier = { - description = "Moves to a point in space at a constant speed." + description = "What is a man?" field = "human" display = "Human" class = "Human" dependency = [] blocks = { - data={ + data = { fields = [ - { name="active" type="boolean" default=true } - { name="name" type="id32" default="unnamed" } - { name="color" type="float4" default=[1, 0, 0, 1] } + { name="active" type="boolean" default=true } + { name="name" type="id32" default="unnamed" } + { name="color" type="float4" default=[1, 0, 0, 1] } + //todo: turn this into a implicit number via references from adventure list + //todo: make this int? + { name="adventure_count" type="number" default=0 } ] } } diff --git a/Luxe/blocks/human/human.modifier.wren b/Luxe/blocks/human/human.modifier.wren index 282333a..f9b2043 100644 --- a/Luxe/blocks/human/human.modifier.wren +++ b/Luxe/blocks/human/human.modifier.wren @@ -159,6 +159,7 @@ import "luxe: world" for Block _active = true _name = "unnamed" _color = [1, 0, 0, 1] + _adventure_count = 0 } //new active { _active } @@ -170,6 +171,9 @@ import "luxe: world" for Block color { _color } color=(vvv) { _color = vvv } + adventure_count { _adventure_count } + adventure_count=(vvv) { _adventure_count = vvv } + } //ModifierData //`blocks/human/human > data` compilers @@ -189,6 +193,8 @@ import "luxe: world" for Block size = size + 16 // color + size = size + 8 // adventure_count + size = size + 0 return size @@ -204,6 +210,7 @@ import "luxe: world" for Block "active": false, "name": false, "color": false, + "adventure_count": false, } for(element in elements) { var instance = element.value @@ -245,13 +252,18 @@ import "luxe: world" for Block out.write_float32(color[3]) + var adventure_count = instance["adventure_count"] + if(adventure_count == null) adventure_count = 0 + out.write_float64(adventure_count) + + return out } //write bytes_count_block() { - return 56 + return 72 } //bytes_count_block @@ -261,7 +273,7 @@ import "luxe: world" for Block out.write_uint32(compiler.string.hash("blocks/human/human > data")) //fields count - out.write_int32(3) + out.write_int32(4) // active out.write_uint32(compiler.string.hash("active")) @@ -287,6 +299,13 @@ import "luxe: world" for Block out.write_float32(color_default[3]) + // adventure_count + out.write_uint32(compiler.string.hash("adventure_count")) + out.write_uint32(467038368) //type number + var adventure_count_default = 0 + out.write_float64(adventure_count_default) + + } //write_block write(instance) { @@ -324,6 +343,7 @@ import "luxe: world" for Block Block.add(_block, "active", "boolean", true) Block.add(_block, "name", "id32", "unnamed") Block.add(_block, "color", "float4", [1, 0, 0, 1]) + Block.add(_block, "adventure_count", "number", 0) Block.set_type(_block, "blocks/human/human > data") } //new @@ -336,6 +356,8 @@ import "luxe: world" for Block name=(v) { Block.set(_block, "name", _slot, v) } color { Block.get(_block, "color", _slot) } color=(v) { Block.set(_block, "color", _slot, v) } + adventure_count { Block.get(_block, "adventure_count", _slot) } + adventure_count=(v) { Block.set(_block, "adventure_count", _slot, v) } slot { _slot } entity { Block.get_handle(_block, _slot) } block_set_slot(value) { diff --git a/Luxe/blocks/human/human.wren b/Luxe/blocks/human/human.wren index 1cb099e..132e658 100644 --- a/Luxe/blocks/human/human.wren +++ b/Luxe/blocks/human/human.wren @@ -39,6 +39,17 @@ class Human { return data.color } + static get_adventure_count(entity){ + if(entity == 0 || !entity) return null + var data = Modifiers.get(This, entity) + return data.adventure_count + } + + static increase_adventure_count(entity){ + var data = Modifiers.get(This, entity) + data.adventure_count = data.adventure_count + 1 + } + } //Human //Your modifier system implementation. diff --git a/Luxe/blocks/tooltip.wren b/Luxe/blocks/tooltip.wren index 43fadfd..811af72 100644 --- a/Luxe/blocks/tooltip.wren +++ b/Luxe/blocks/tooltip.wren @@ -1,5 +1,6 @@ import "luxe: world" for Entity, Text, Transform import "luxe: assets" for Assets +import "luxe: render" for Material import "globals" for Globals import "math/vector" for Vector @@ -7,9 +8,9 @@ import "math/vector" for Vector class Tooltip{ depth{100} color{[1, 1, 1, 1]} - background{[1, 0, 1, 1]} + background{[0, 0, 0, 1]} - shadowOffsets{[[1, 0],[0, 1],[-1, 0],[0, -1]]} + shadowOffsets{[[1, 0],[0, 1],[-1, 0],[0, -1],[1, 1],[1, -1],[-1, -1],[-1, 1]]} construct new(app){ _text = Entity.create(app.ui) @@ -23,9 +24,9 @@ class Tooltip{ _shadows = [] for(i in offsets){ var shadow = Entity.create(app.ui) - Text.create(shadow, mat, 8, "assets/fonts/BabyBlocks", background) + Text.create(shadow, Material.clone(mat), 8, "assets/fonts/BabyBlocks", background) Transform.create(shadow) - Transform.set_snap(_text, 1, 1, 0) + Transform.set_snap(shadow, 1, 1, 0) _shadows.add(shadow) } @@ -63,12 +64,12 @@ class Tooltip{ } set(text, source){ - Text.set_text_buffer(_text, text) - Text.commit(_text) for(shadow in _shadows){ Text.set_text_buffer(shadow, text) Text.commit(shadow) } + Text.set_text_buffer(_text, text) + Text.commit(_text) _active = true _source = source _x = null diff --git a/Luxe/blocks/ui.wren b/Luxe/blocks/ui.wren index 819b3e3..2daf7db 100644 --- a/Luxe/blocks/ui.wren +++ b/Luxe/blocks/ui.wren @@ -81,6 +81,7 @@ class Ui{ ImageButton.set_tooltip(button, "Adventure!") ImageButton.set_tile_uv(button, tiles, [1, 0]) ImageButton.set_state_change(button) { |data| + System.print("adventure button: %(data)") if(data["press"]){ ui_mode = Ui.Planning } @@ -128,11 +129,20 @@ class Ui{ 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 + "\n" + name_string) + UISimpleText.set_text(name, name_string) + } + + var adventures = UISimpleText.create(_ui) + Control.set_pos(adventures, 33, 10) + Control.child_add(root, adventures) + Control.set_id(name, "human adventure count") + Globals["Game"].Focus.on_change(true) {|val| + var count = Human.get_adventure_count(val) + var text = count ? "Adventures: %(count)" : "" + UISimpleText.set_text(adventures, text) } } @@ -158,7 +168,8 @@ class Ui{ UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Info") ImageButton.set_tile_uv(button, tiles, [1, 0]) - ImageButton.set_state_change(button) { |data| + ImageButton.set_state_change(button) { |data| + System.print("info button: %(data)") if(data["press"]){ ui_mode = Ui.Info } @@ -205,10 +216,6 @@ class Ui{ Control.set_pos(button, i*16, 0) //let list handle this in future return button } - - test(){ - ImageButton.get_data(_test) - } } //this is behind the class def to make cyclic dependency happy lol diff --git a/Luxe/game.wren b/Luxe/game.wren index 5b79632..d62776b 100644 --- a/Luxe/game.wren +++ b/Luxe/game.wren @@ -1,4 +1,4 @@ -import "luxe: game" for Game +import "luxe: game" for Ready import "luxe: input" for Input, Key import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera import "luxe: math" for Math @@ -19,8 +19,9 @@ import "math/observable" for Observable import "blocks/tooltip" for Tooltip import "blocks/human/human" for Human -class game is Game { +class Game is Ready { construct ready() { + super("Cabin Game") Globals["Game"] = this _focus = Observable.new() @@ -53,8 +54,6 @@ class game is Game { if(Input.key_state_pressed(Key.key_q)) { _tooltip.cycle_size() } - - _ui.test() DrawDebug.commit() diff --git a/Luxe/math/util.wren b/Luxe/math/util.wren index 64d12ca..90c9e83 100644 --- a/Luxe/math/util.wren +++ b/Luxe/math/util.wren @@ -11,7 +11,7 @@ class Util{ static material_from_image(image){ var material = Material.create("luxe: material_basis/sprite_pixelated") - Material.set_image(material, 0, image) + Material.set_input(material, "sprite.image", image) return material } diff --git a/Luxe/outline/app.wren b/Luxe/outline/app.wren index d83ad38..111dd24 100644 --- a/Luxe/outline/app.wren +++ b/Luxe/outline/app.wren @@ -73,11 +73,8 @@ class App { //update worlds - World.tick_systems(_world, delta) - World.tick_systems(_ui_world, delta) - - World.tick_world(_world, delta) - World.tick_world(_ui_world, delta) + World.tick(_world, delta) + World.tick(_ui_world, delta) //render worlds render_empty("clear") diff --git a/Luxe/outline/renderer.wren b/Luxe/outline/renderer.wren index 27a5347..4dc3d02 100644 --- a/Luxe/outline/renderer.wren +++ b/Luxe/outline/renderer.wren @@ -136,9 +136,10 @@ class Renderer { } //ui_render_path target_to_screen(ctx){ + //{ library="luxe: shaders" function="vert_color_uv" } var out_pass = PassLayerDesc.new() - out_pass.library = "shaders/upscale" - out_pass.function = "upscale_top_center" + out_pass.fragment.library = "shaders/upscale" + out_pass.fragment.function = "upscale_top_center" out_pass.targets = ["screen"] out_pass.inputs = { "pass.flipy" : true, diff --git a/Luxe/outline/settings.settings.lx b/Luxe/outline/settings.settings.lx index ffe71ab..b18a5d2 100644 --- a/Luxe/outline/settings.settings.lx +++ b/Luxe/outline/settings.settings.lx @@ -3,7 +3,7 @@ engine = { window = { width = 512 height = 768 - resizable = true + resizable = false fullscreen = false } } diff --git a/Luxe/project.luxe b/Luxe/project.luxe index e98c98e..b343f2b 100644 --- a/Luxe/project.luxe +++ b/Luxe/project.luxe @@ -1,8 +1,8 @@ -import "luxe: project" for Project +import "luxe: project" for Entry -class project is Project { +class Project is Entry { - construct new(target) { + construct entry(target) { name = "Cabin Game" version = "0.0.0" diff --git a/Luxe/project.modules.lx b/Luxe/project.modules.lx index d493c0b..567dfa2 100644 --- a/Luxe/project.modules.lx +++ b/Luxe/project.modules.lx @@ -1,3 +1,3 @@ modules = { - luxe = "2020.2.0" + luxe = "2020.3.0" } //modules