borken again
This commit is contained in:
parent
488a913cd9
commit
58abf3fffa
10 changed files with 111 additions and 29 deletions
|
|
@ -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}
|
||||
]
|
||||
33
Luxe/blocks/adventures.wren
Normal file
33
Luxe/blocks/adventures.wren
Normal file
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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="{}" }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
import "blocks/ui/ui" for Ui //import at the end in case of cyclic dependency
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
import "blocks/ui/info" for UiInfo
|
||||
import "blocks/ui/adventure" for UiAdventure
|
||||
|
|
@ -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 }
|
||||
|
|
|
|||
Loading…
Reference in a new issue