aboutsummaryrefslogtreecommitdiff
path: root/scripts/control.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-02-08 11:24:51 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-02-08 11:24:51 +0100
commiteea642395bb0ef706c7241d4a749f3e0ac4cc460 (patch)
tree6c015c9315b0102247661f942b018ccf8c45551d /scripts/control.gd
parente8b2ea6b2bf789b7942d86faebbcc4d810741f25 (diff)
revised wave generation
Diffstat (limited to 'scripts/control.gd')
-rw-r--r--scripts/control.gd59
1 files changed, 56 insertions, 3 deletions
diff --git a/scripts/control.gd b/scripts/control.gd
index fafd3d8..2a9c76e 100644
--- a/scripts/control.gd
+++ b/scripts/control.gd
@@ -59,11 +59,12 @@ func build_option (st, sttype):
opts += [ { "type": "text", "name": "path" } ]
opts += [ { "type": "text", "name": "end path" } ]
Globals.StateType.VOXEL:
- for i in world.voxel_set.size():
+ for i in world.voxel_set.get_ids():
var details = world.voxel_set.get_voxel(i)
var color = Color(1, 0, 1)
if details.has("color"): color = details.color
opts += [ { "type": "color", "name": str(i), "color": color} ]
+ opts += [ { "type": "text", "name": "add" } ]
Globals.PlayerState.EDIT:
match sttype:
@@ -155,8 +156,19 @@ func do (action, par = {}):
Globals.PlayerState.PICK:
match action:
Globals.PlayerActions.PICK:
- selected = par.name
- state = Globals.PlayerState.PLACE
+ match statetype:
+ Globals.StateType.VOXEL:
+ match par.name:
+ "add":
+ selected = "add"
+ gui.edit_palette.popup()
+ build_option(state, statetype)
+ _:
+ selected = par.name
+ state = Globals.PlayerState.PLACE
+ _:
+ selected = par.name
+ state = Globals.PlayerState.PLACE
Globals.PlayerActions.SELECT:
match statetype:
@@ -174,6 +186,21 @@ func do (action, par = {}):
statetype = par.statetype
build_option(state, statetype)
+ Globals.PlayerActions.EDIT:
+ match statetype:
+ Globals.StateType.VOXEL:
+ match par.name:
+ "add":
+ selected = "add"
+ gui.edit_palette.popup()
+ build_option(state, statetype)
+ _:
+ selected = par.name
+ var dict = world.voxel_set.get_voxel(int(par.name))
+ gui.edit_palette.get_node("ColorPicker").color = dict.color
+ gui.edit_palette.popup()
+ build_option(state, statetype)
+
Globals.PlayerState.PLACE:
match action:
Globals.PlayerActions.PLACE:
@@ -205,6 +232,21 @@ func do (action, par = {}):
statetype = par.statetype
build_option(state, statetype)
+ Globals.PlayerActions.EDIT:
+ match statetype:
+ Globals.StateType.VOXEL:
+ match par.name:
+ "add":
+ selected = "add"
+ gui.edit_palette.popup()
+ build_option(state, statetype)
+ _:
+ selected = par.name
+ var dict = world.voxel_set.get_voxel(int(par.name))
+ gui.edit_palette.get_node("ColorPicker").color = dict.color
+ gui.edit_palette.popup()
+ build_option(state, statetype)
+
Globals.PlayerState.EDIT:
match action:
Globals.PlayerActions.PICK:
@@ -315,3 +357,14 @@ func gui_change_map_event (mapname : String):
path.refresh_path(ineditor)
gui.refresh()
+
+func gui_picked_color (color : Color):
+ if selected != "add":
+ var dict = world.voxel_set.get_voxel(int(selected))
+ dict.color = color
+ world.voxel_set.set_voxel(int(selected), dict)
+ else:
+ world.voxel_set.add_voxel({"color":color})
+ world.update_mesh()
+ build_option(state, statetype)
+ gui.refresh()