From 1873ccff40f81c4d20fb752df1fe34adf33fd254 Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Wed, 19 Jan 2022 15:39:52 +0100 Subject: cost check, icons --- assets/blender/turrets.blend | Bin 1362944 -> 1362944 bytes assets/blender/turrets.blend1 | Bin 1362944 -> 1362944 bytes assets/textures/thumbnails/generic/.png | Bin 0 -> 6763 bytes assets/textures/thumbnails/generic/back.svg | 196 +++++++++++++++++++++ assets/textures/thumbnails/generic/back.svg.import | 35 ++++ assets/textures/thumbnails/generic/modules.svg | 138 +++++++++++++++ .../textures/thumbnails/generic/modules.svg.import | 35 ++++ assets/textures/thumbnails/generic/sell.svg | 145 +++++++++++++++ assets/textures/thumbnails/generic/sell.svg.import | 35 ++++ assets/textures/thumbnails/generic/targeting.svg | 129 ++++++++++++++ .../thumbnails/generic/targeting.svg.import | 35 ++++ assets/textures/thumbnails/generic/upgrade.svg | 121 +++++++++++++ .../textures/thumbnails/generic/upgrade.svg.import | 35 ++++ assets/textures/upgrade.png.import | 35 ++++ scenes/gui.tscn | 2 +- scenes/gui/gui_button.tscn | 11 +- scenes/gui/gui_map_item.tscn | 3 + scripts/bullet.gd | 1 + scripts/control.gd | 43 +++-- scripts/gui_picker.gd | 22 ++- scripts/load_turrets.gd | 1 - 21 files changed, 1005 insertions(+), 17 deletions(-) create mode 100644 assets/textures/thumbnails/generic/.png create mode 100644 assets/textures/thumbnails/generic/back.svg create mode 100644 assets/textures/thumbnails/generic/back.svg.import create mode 100644 assets/textures/thumbnails/generic/modules.svg create mode 100644 assets/textures/thumbnails/generic/modules.svg.import create mode 100644 assets/textures/thumbnails/generic/sell.svg create mode 100644 assets/textures/thumbnails/generic/sell.svg.import create mode 100644 assets/textures/thumbnails/generic/targeting.svg create mode 100644 assets/textures/thumbnails/generic/targeting.svg.import create mode 100644 assets/textures/thumbnails/generic/upgrade.svg create mode 100644 assets/textures/thumbnails/generic/upgrade.svg.import create mode 100644 assets/textures/upgrade.png.import diff --git a/assets/blender/turrets.blend b/assets/blender/turrets.blend index 3c763d2..ad8a28f 100644 Binary files a/assets/blender/turrets.blend and b/assets/blender/turrets.blend differ diff --git a/assets/blender/turrets.blend1 b/assets/blender/turrets.blend1 index cb403e4..3c763d2 100644 Binary files a/assets/blender/turrets.blend1 and b/assets/blender/turrets.blend1 differ diff --git a/assets/textures/thumbnails/generic/.png b/assets/textures/thumbnails/generic/.png new file mode 100644 index 0000000..f4df55f Binary files /dev/null and b/assets/textures/thumbnails/generic/.png differ diff --git a/assets/textures/thumbnails/generic/back.svg b/assets/textures/thumbnails/generic/back.svg new file mode 100644 index 0000000..bb47d37 --- /dev/null +++ b/assets/textures/thumbnails/generic/back.svg @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/textures/thumbnails/generic/back.svg.import b/assets/textures/thumbnails/generic/back.svg.import new file mode 100644 index 0000000..841a5c8 --- /dev/null +++ b/assets/textures/thumbnails/generic/back.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/back.svg-1e0b89102b76a6bd20ee6b68f0ae36ac.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/thumbnails/generic/back.svg" +dest_files=[ "res://.import/back.svg-1e0b89102b76a6bd20ee6b68f0ae36ac.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/textures/thumbnails/generic/modules.svg b/assets/textures/thumbnails/generic/modules.svg new file mode 100644 index 0000000..3ff9c3c --- /dev/null +++ b/assets/textures/thumbnails/generic/modules.svg @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/textures/thumbnails/generic/modules.svg.import b/assets/textures/thumbnails/generic/modules.svg.import new file mode 100644 index 0000000..02870ef --- /dev/null +++ b/assets/textures/thumbnails/generic/modules.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/modules.svg-cb8005b3a45c6c189555115b136cc028.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/thumbnails/generic/modules.svg" +dest_files=[ "res://.import/modules.svg-cb8005b3a45c6c189555115b136cc028.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/textures/thumbnails/generic/sell.svg b/assets/textures/thumbnails/generic/sell.svg new file mode 100644 index 0000000..9e13add --- /dev/null +++ b/assets/textures/thumbnails/generic/sell.svg @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/textures/thumbnails/generic/sell.svg.import b/assets/textures/thumbnails/generic/sell.svg.import new file mode 100644 index 0000000..3798108 --- /dev/null +++ b/assets/textures/thumbnails/generic/sell.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/sell.svg-feae56ffe9b835824e665e5ac3a20b82.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/thumbnails/generic/sell.svg" +dest_files=[ "res://.import/sell.svg-feae56ffe9b835824e665e5ac3a20b82.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/textures/thumbnails/generic/targeting.svg b/assets/textures/thumbnails/generic/targeting.svg new file mode 100644 index 0000000..44fbb23 --- /dev/null +++ b/assets/textures/thumbnails/generic/targeting.svg @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/textures/thumbnails/generic/targeting.svg.import b/assets/textures/thumbnails/generic/targeting.svg.import new file mode 100644 index 0000000..45280ca --- /dev/null +++ b/assets/textures/thumbnails/generic/targeting.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/targeting.svg-6bbd6316cddfa07731913282808803ad.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/thumbnails/generic/targeting.svg" +dest_files=[ "res://.import/targeting.svg-6bbd6316cddfa07731913282808803ad.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/textures/thumbnails/generic/upgrade.svg b/assets/textures/thumbnails/generic/upgrade.svg new file mode 100644 index 0000000..e97ae0e --- /dev/null +++ b/assets/textures/thumbnails/generic/upgrade.svg @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/textures/thumbnails/generic/upgrade.svg.import b/assets/textures/thumbnails/generic/upgrade.svg.import new file mode 100644 index 0000000..13beb27 --- /dev/null +++ b/assets/textures/thumbnails/generic/upgrade.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/upgrade.svg-f05530159f65bd8f096a42d4e4e15d02.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/thumbnails/generic/upgrade.svg" +dest_files=[ "res://.import/upgrade.svg-f05530159f65bd8f096a42d4e4e15d02.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/textures/upgrade.png.import b/assets/textures/upgrade.png.import new file mode 100644 index 0000000..799a8b7 --- /dev/null +++ b/assets/textures/upgrade.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/upgrade.png-0bfc21b98741c72ad249a23821a24246.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/upgrade.png" +dest_files=[ "res://.import/upgrade.png-0bfc21b98741c72ad249a23821a24246.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/scenes/gui.tscn b/scenes/gui.tscn index 20c5bec..bd364c9 100644 --- a/scenes/gui.tscn +++ b/scenes/gui.tscn @@ -366,9 +366,9 @@ __meta__ = { } [node name="mapname" type="Label" parent="bottom_bar/editor_bar/hbox_map"] -anchor_bottom = 1.0 margin_left = 324.0 margin_right = 379.4 +margin_bottom = 24.4 text = "mapname" valign = 2 script = SubResource( 8 ) diff --git a/scenes/gui/gui_button.tscn b/scenes/gui/gui_button.tscn index bc3f5f5..1922583 100644 --- a/scenes/gui/gui_button.tscn +++ b/scenes/gui/gui_button.tscn @@ -32,6 +32,15 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="texture_back" type="TextureRect" parent="."] +modulate = Color( 1, 0.619608, 0, 1 ) +margin_right = 100.0 +margin_bottom = 100.0 +mouse_filter = 2 +__meta__ = { +"_edit_use_anchors_": false +} + [node name="texture" type="TextureRect" parent="."] margin_right = 100.0 margin_bottom = 100.0 @@ -65,7 +74,7 @@ __meta__ = { anchor_right = 1.0 margin_right = -2.0 margin_bottom = 118.0 -align = 2 +align = 1 __meta__ = { "_edit_use_anchors_": false } diff --git a/scenes/gui/gui_map_item.tscn b/scenes/gui/gui_map_item.tscn index 6e893b1..82d795d 100644 --- a/scenes/gui/gui_map_item.tscn +++ b/scenes/gui/gui_map_item.tscn @@ -4,6 +4,9 @@ margin_right = 200.0 margin_bottom = 25.0 rect_min_size = Vector2( 0, 25 ) +__meta__ = { +"_edit_use_anchors_": false +} [node name="name" type="Label" parent="."] margin_right = 62.4 diff --git a/scripts/bullet.gd b/scripts/bullet.gd index 2a5df41..dd9793e 100644 --- a/scripts/bullet.gd +++ b/scripts/bullet.gd @@ -63,4 +63,5 @@ func collided(body): queue_free() else: hitlist.append(parent) + print(hitlist) diff --git a/scripts/control.gd b/scripts/control.gd index 0b94adb..7c8b95d 100644 --- a/scripts/control.gd +++ b/scripts/control.gd @@ -86,6 +86,34 @@ func build_option (st, sttype): gui.bottom_bar.picker.build(opts) +func buy (pos, rot, turr_name): + var info = load_turrets.info[turr_name] + if resources.greater_than(info.cost): + resources.sub(info.cost) + var obj = placer.inst_turret(pos, rot, turr_name) + editing_turret = obj.name + state = Globals.PlayerState.EDIT + build_option(state, statetype) + else: + pass + ## TODO feedback + +func upgrade (turr_inst_name, upg_name): + var info = load_turrets.info[upg_name] + if resources.greater_than(info.cost): + resources.sub(info.cost) + var prv = turret_holder.get_node(turr_inst_name) + var pos = prv.transform.origin + var rot = prv.transform.basis.get_rotation_quat() + placer.delete(statetype, pos, rot) + var obj = placer.inst_turret(pos, rot, upg_name) + editing_turret = obj.name + state = Globals.PlayerState.EDIT + build_option(state, statetype) + else: + pass + ## TODO feedback + func sell (turr_name): var turr = turret_holder.get_node(turr_name) var info = turr.info @@ -136,11 +164,7 @@ func do (action, par = {}): Globals.PlayerActions.PLACE: match statetype: Globals.StateType.TURRET: - var obj = placer.inst_turret( - par.pos, par.rot, selected) - editing_turret = obj.name - state = Globals.PlayerState.EDIT - build_option(state, statetype) + buy(par.pos, par.rot, selected) Globals.StateType.ATTACH: placer.inst_attach(par.pos, par.rot) Globals.StateType.PATH: @@ -174,14 +198,7 @@ func do (action, par = {}): selected = par.name match par.type: "turret upg": - var prv = turret_holder.get_node(editing_turret) - var pos = prv.transform.origin - var rot = prv.transform.basis.get_rotation_quat() - placer.delete(statetype, pos, rot) - var obj = placer.inst_turret(pos, rot, par.name) - editing_turret = obj.name - state = Globals.PlayerState.EDIT - build_option(state, statetype) + upgrade(editing_turret, par.name) _ : match par.name: "targeting": diff --git a/scripts/gui_picker.gd b/scripts/gui_picker.gd index 9a7e373..b888572 100644 --- a/scripts/gui_picker.gd +++ b/scripts/gui_picker.gd @@ -5,7 +5,10 @@ var _gui_button : Resource = load("res://scenes/gui/gui_button.tscn") var _options = [] +var thumbs_generic = {} + var gui : Control +var saveload : Node var load_turrets : Node var resources : Node @@ -17,8 +20,18 @@ func _fetch (): var root = get_tree().root.get_node("world") resources = root.get_node("player").get_node("resources") - load_turrets = root.get_node("saveload").get_node("load_turrets") + saveload = root.get_node("saveload") + load_turrets = saveload.get_node("load_turrets") + load_thumbnails() if !load_turrets.loaded: yield(load_turrets, "done_loading") + + +func load_thumbnails(): + var thumbspath = "res://assets/textures/thumbnails/generic" + thumbs_generic.clear() + var files = saveload.parse_dir(thumbspath, ".svg") + for turr in files: + thumbs_generic[turr] = load(thumbspath + "/" + turr) func build (options : Array = []): _fetch() @@ -34,6 +47,7 @@ func build (options : Array = []): for opt in _options: var button = _gui_button.instance() button.option = opt + var tback = button.get_node("texture_back"); if opt.type == "turret buy": var tinfo = load_turrets.info[opt.name] @@ -45,8 +59,14 @@ func build (options : Array = []): button.get_node("name").text = tinfo.name button.get_node("cash").text = resources.dict_to_str(tinfo.cost) button.get_node("texture").texture = load_turrets.thumbnails[tinfo.thumbnail_name] + tback.texture = thumbs_generic["upgrade.svg"] if opt.type == "text": button.get_node("name").text = opt.name + if opt.name == "back": tback.texture = thumbs_generic["back.svg"] + if opt.name == "modules": tback.texture = thumbs_generic["modules.svg"] + if opt.name == "targeting": tback.texture = thumbs_generic["targeting.svg"] + if opt.name == "sell": tback.texture = thumbs_generic["sell.svg"] + tback.modulate = Color.white if opt.type == "color": button.get_node("name").text = "" button.get_node("color").color = opt.color diff --git a/scripts/load_turrets.gd b/scripts/load_turrets.gd index 3cfd802..e79a68c 100644 --- a/scripts/load_turrets.gd +++ b/scripts/load_turrets.gd @@ -57,5 +57,4 @@ func load_thumbnails(): thumbnails.clear() var files = saveload.parse_dir("res://assets/textures/thumbnails/turrets", ".png") for turr in files: - print(turr) thumbnails[turr] = load("res://assets/textures/thumbnails/turrets/" + turr) -- cgit v1.2.3-54-g00ecf