diff --git a/Luxe/assets/resources.lx b/Luxe/assets/resources.lx index bc0a603..45e34ed 100644 --- a/Luxe/assets/resources.lx +++ b/Luxe/assets/resources.lx @@ -1,15 +1,16 @@ [ //the text decides how the resources are actually dealt with //this is mainly here to define a order in the UI - {name: "wood", "alwaysSingular": true}, - {name: "clothes", "alwaysSingular":true}, - {name: "tent"}, - {name: "water bag"}, - {name: "dog"}, - {name: "map"}, - {name: "marble"}, - {name: "gold", "alwaysSingular":true}, - {name: "tea", "alwaysSingular": true}, - {name: "spices", "alwaysSingular": true}, - {name: "sunscreen", "alwaysSingular": true}, + {name:"wood" alwaysSingular:true} + {name:"clothes" alwaysSingular:true} + {name:"tent"} + {name:"water bag"} + {name:"cat"} + {name:"dog"} + {name:"map"} + {name:"marble"} + {name:"gold" alwaysSingular:true} + {name:"tea" alwaysSingular:true} + {name:"spices" alwaysSingular:true} + {name:"sunscreen" alwaysSingular:true} ] \ No newline at end of file diff --git a/Luxe/blocks/adventures.wren b/Luxe/blocks/adventures.wren new file mode 100644 index 0000000..327f00e --- /dev/null +++ b/Luxe/blocks/adventures.wren @@ -0,0 +1,33 @@ +import "math/observable" for Observable +import "luxe: Game" for Game +import "luxe: world" for Entity, Values, Tags + +class Adventures{ + planning{_planning} + + construct new(){ + _planning = Observable.new() + _in_progress = [] + _archive = [] + } + + plan_new(){ + var adventure = Entity.create(Game.app.world, "Adventure") + Values.set(adventure, "adventurers", []) + Values.set(adventure, "resources", {}) + Values.set(adventure, "data", {}) + Tags.add(adventure, "Adventure") + _planning.value = adventure + return adventure + } + + new_or_current(){ + if(_planning.value) return _planning.value + return plan_new() + } + + discard(){ + Entity.destroy(_planning.value) + _planning.value = null + } +} \ No newline at end of file diff --git a/Luxe/blocks/human/human.modifier.lx b/Luxe/blocks/human/human.modifier.lx index 6c42606..bf04b29 100644 --- a/Luxe/blocks/human/human.modifier.lx +++ b/Luxe/blocks/human/human.modifier.lx @@ -14,6 +14,7 @@ modifier = { //todo: turn this into a implicit number via references from adventure list //todo: make this int? { name="adventure_count" type="number" default=0 } + { name="diary" type="id32" default="{}" } ] } } diff --git a/Luxe/blocks/human/human.modifier.wren b/Luxe/blocks/human/human.modifier.wren index f9b2043..5266c45 100644 --- a/Luxe/blocks/human/human.modifier.wren +++ b/Luxe/blocks/human/human.modifier.wren @@ -160,6 +160,7 @@ import "luxe: world" for Block _name = "unnamed" _color = [1, 0, 0, 1] _adventure_count = 0 + _diary = "{}" } //new active { _active } @@ -174,6 +175,9 @@ import "luxe: world" for Block adventure_count { _adventure_count } adventure_count=(vvv) { _adventure_count = vvv } + diary { _diary } + diary=(vvv) { _diary = vvv } + } //ModifierData //`blocks/human/human > data` compilers @@ -195,6 +199,8 @@ import "luxe: world" for Block size = size + 8 // adventure_count + size = size + 4 // diary + size = size + 0 return size @@ -211,6 +217,7 @@ import "luxe: world" for Block "name": false, "color": false, "adventure_count": false, + "diary": false, } for(element in elements) { var instance = element.value @@ -257,13 +264,18 @@ import "luxe: world" for Block out.write_float64(adventure_count) + var diary = instance["diary"] + if(diary == null) diary = "{}" + out.write_uint32((diary && diary != "") ? compiler.string.hash(diary) : 0) + + return out } //write bytes_count_block() { - return 72 + return 84 } //bytes_count_block @@ -273,7 +285,7 @@ import "luxe: world" for Block out.write_uint32(compiler.string.hash("blocks/human/human > data")) //fields count - out.write_int32(4) + out.write_int32(5) // active out.write_uint32(compiler.string.hash("active")) @@ -306,6 +318,13 @@ import "luxe: world" for Block out.write_float64(adventure_count_default) + // diary + out.write_uint32(compiler.string.hash("diary")) + out.write_uint32(2729592961) //type id32 + var diary_default = "{}" + out.write_uint32((diary_default && diary_default != "") ? compiler.string.hash(diary_default) : 0) + + } //write_block write(instance) { @@ -344,6 +363,7 @@ import "luxe: world" for Block Block.add(_block, "name", "id32", "unnamed") Block.add(_block, "color", "float4", [1, 0, 0, 1]) Block.add(_block, "adventure_count", "number", 0) + Block.add(_block, "diary", "id32", "{}") Block.set_type(_block, "blocks/human/human > data") } //new @@ -358,6 +378,8 @@ import "luxe: world" for Block 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) } + diary { Block.get(_block, "diary", _slot) } + diary=(v) { Block.set(_block, "diary", _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 f2c7eef..3c4aa9f 100644 --- a/Luxe/blocks/human/human.wren +++ b/Luxe/blocks/human/human.wren @@ -142,4 +142,4 @@ class HumanSystem is ModifierSystem { var Modifier = HumanSystem //required -import "blocks/ui" for Ui //import at the end in case of cyclic dependency \ No newline at end of file +import "blocks/ui/ui" for Ui //import at the end in case of cyclic dependency \ No newline at end of file diff --git a/Luxe/blocks/resources.wren b/Luxe/blocks/resources.wren index 3342ee8..5971d32 100644 --- a/Luxe/blocks/resources.wren +++ b/Luxe/blocks/resources.wren @@ -1,4 +1,5 @@ import "luxe: assets" for Assets +import "luxe: world" for Entity import "math/event" for Event import "math/observable" for Observable import "math/stringUtil" for StringUtil diff --git a/Luxe/blocks/adventure.wren b/Luxe/blocks/ui/adventure.wren similarity index 83% rename from Luxe/blocks/adventure.wren rename to Luxe/blocks/ui/adventure.wren index 4fd8cae..4bdfeb7 100644 --- a/Luxe/blocks/adventure.wren +++ b/Luxe/blocks/ui/adventure.wren @@ -14,7 +14,7 @@ import "globals" for Globals import "blocks/ui/image_button" for ImageButton import "math/observable" for Observable import "blocks/ui/simple_text" for UISimpleText -import "blocks/ui" for Ui +import "blocks/ui/ui" for Ui class UiAdventure{ root{_root} @@ -41,13 +41,11 @@ class UiAdventure{ UILayout.set_margin(_ent, list, 0, 0, 0, 0) UILayout.set_contain(_ent, list, UILayoutContain.row | UILayoutContain.start) //| - var adventureButtons = Assets.image("assets/AdventureButtons") var tiles = [10, 1] var button //back to info button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Info") ImageButton.set_tile_uv(button, tiles, [1, 0]) ImageButton.set_state_change(button) { |data| @@ -58,31 +56,31 @@ class UiAdventure{ //abort button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Abort") ImageButton.set_tile_uv(button, tiles, [0, 0]) + ImageButton.set_state_change(button) { |data| + if(data["press"]){ + _ui.ui_mode = Ui.Info + } + } //people button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "People") ImageButton.set_tile_uv(button, tiles, [2, 0]) //stuff button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Stuff") ImageButton.set_tile_uv(button, tiles, [4, 0]) //direction button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Direction") ImageButton.set_tile_uv(button, tiles, [3, 0]) //go button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Depart") ImageButton.set_tile_uv(button, tiles, [5, 0]) } diff --git a/Luxe/blocks/info.wren b/Luxe/blocks/ui/info.wren similarity index 95% rename from Luxe/blocks/info.wren rename to Luxe/blocks/ui/info.wren index 6e7f74b..45b4101 100644 --- a/Luxe/blocks/info.wren +++ b/Luxe/blocks/ui/info.wren @@ -15,8 +15,9 @@ import "blocks/ui/image_button" for ImageButton import "math/observable" for Observable import "math/stringUtil" for StringUtil import "blocks/ui/simple_text" for UISimpleText -import "blocks/ui" for Ui +import "blocks/ui/ui" for Ui import "blocks/human/human" for Human +import "luxe: Game" for Game class UiInfo{ root{_root} @@ -81,6 +82,7 @@ class UiInfo{ ImageButton.set_tile_uv(button, tiles, [1, 0]) ImageButton.set_state_change(button) { |data| if(data["press"]){ + Game.adventures.new_or_current() _ui.ui_mode = Ui.Planning } } diff --git a/Luxe/blocks/ui.wren b/Luxe/blocks/ui/ui.wren similarity index 71% rename from Luxe/blocks/ui.wren rename to Luxe/blocks/ui/ui.wren index a217113..a4122f2 100644 --- a/Luxe/blocks/ui.wren +++ b/Luxe/blocks/ui/ui.wren @@ -62,11 +62,34 @@ class Ui{ var button = ImageButton.create(_ent) Control.set_size(button, 16, 16) Control.child_add(parent, button) + var adventureButtons = Assets.image("assets/AdventureButtons") + UIImage.set_image(button, adventureButtons) return button } + + list_button(parent, tile){ + var tiles = [10, 1] + + var button = list_button(parent) + ImageButton.set_tile_uv(button, tiles, tile) + return button + } + + list_button(parent, tile, tooltip){ + var button = list_button(parent, tile) + ImageButton.set_tooltip(button, tooltip) + } + + list_button(parent, tile, tooltip, pressFn){ + var button = list_button(parent, tile) + ImageButton.set_state_change(button) { |data| + if(data["press"]){ + _ui.ui_mode = Ui.Info + } + } + } } //this is behind the class def to make cyclic dependency happy lol -import "blocks/human/human" for Human -import "blocks/info" for UiInfo -import "blocks/adventure" for UiAdventure \ No newline at end of file +import "blocks/ui/info" for UiInfo +import "blocks/ui/adventure" for UiAdventure \ No newline at end of file diff --git a/Luxe/game.wren b/Luxe/game.wren index ecca897..f616051 100644 --- a/Luxe/game.wren +++ b/Luxe/game.wren @@ -9,7 +9,7 @@ import "luxe: color" for Color import "outline/app" for App import "outline/Renderer" for Renderer -import "blocks/ui" for Ui +import "blocks/ui/ui" for Ui import "blocks/debug" for DrawDebug, Holder import "globals" for Globals, RandomInst import "math/vector" for Vector @@ -19,6 +19,7 @@ import "math/observable" for Observable import "blocks/tooltip" for Tooltip import "blocks/human/human" for Human import "blocks/resources" for Resources +import "blocks/adventures" for Adventures class Game is Ready { construct ready() { @@ -26,7 +27,7 @@ class Game is Ready { Globals["Game"] = this _focus = Observable.new() - _adventure = Observable.new() + _adventures = Adventures.new() app = App.new() _resources = Resources.new() @@ -101,7 +102,7 @@ class Game is Ready { } Focus{_focus} - Adventure{_adventure} + adventures{_adventures} resources{_resources} app { _app }