diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2022-02-01 14:36:39 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2022-02-01 14:36:39 +0100 |
commit | ff51a1e6f7bfa7e005a6894cd22e7bce4971b963 (patch) | |
tree | 3eeca80f55c6579faf05c371d1ee8734adf81b92 /scripts | |
parent | ef2fa8b2b8b545f52a21052713b15c3b406a3055 (diff) |
turret detail GUI compare upgrades and modules
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/control.gd | 4 | ||||
-rw-r--r-- | scripts/gui_turret_detail.gd | 28 | ||||
-rw-r--r-- | scripts/turret.gd | 23 |
3 files changed, 39 insertions, 16 deletions
diff --git a/scripts/control.gd b/scripts/control.gd index 2fd7164..ff2d8da 100644 --- a/scripts/control.gd +++ b/scripts/control.gd @@ -245,8 +245,8 @@ func do (action, par = {}): _: statetype = Globals.StateType.MODULES var turr = turret_holder.get_node(editing_turret) - turr.mods += [par.name] - turr.make_info_mod() + turr.modules += [par.name] + turr.refresh_info(turr.info) build_option(state, statetype) _: to_pick() diff --git a/scripts/gui_turret_detail.gd b/scripts/gui_turret_detail.gd index 2f42833..c1e0519 100644 --- a/scripts/gui_turret_detail.gd +++ b/scripts/gui_turret_detail.gd @@ -33,29 +33,39 @@ func flatten (dict : Dictionary): else: flat[k] = dict[k] return flat -func refresh (turret_info : Dictionary, upgraded : Dictionary = {}): +func refresh (turret_info : Dictionary, comp : Dictionary = {}): _fetch() get_node("vbox").get_node("name_label").text = "name: " + turret_info.name var base_labels = hbox_global.get_node("hbox_labels") var base_values = hbox_global.get_node("hbox_values") + var base_cmp = hbox_global.get_node("hbox_cmp") for child in base_labels.get_children(): child.queue_free() for child in base_values.get_children(): child.queue_free() + for child in base_cmp.get_children(): child.queue_free() var flat = flatten(turret_info) + var flat_comp = flatten(comp) var skip = ["upgrades"] for k in flat: if k in skip or "name" in k: continue - var val = str(flat[k]) var label_lab = Label.new() label_lab.text = k base_labels.add_child(label_lab) + + var val = str(flat[k]) var label_val = Label.new() label_val.text = val base_values.add_child(label_val) + + var cmp_val = str(flat_comp.get(k, "")) + if (cmp_val == val): cmp_val = "" + var label_cmp = Label.new() + label_cmp.text = cmp_val + base_cmp.add_child(label_cmp) func _process(delta): _fetch() @@ -85,6 +95,20 @@ func _process(delta): if highlight != null: info = highlight.info_mod + + var opts = ["back", "targeting", "modules", "sell", "add"] + if gui.control.state == Globals.PlayerState.EDIT and \ + gui.control.statetype == Globals.StateType.TURRET and \ + gui.bottom_bar.picker.hovering != "" and \ + not gui.bottom_bar.picker.hovering in opts: + comp = load_turrets.info[gui.bottom_bar.picker.hovering] + + elif gui.control.state == Globals.PlayerState.EDIT and \ + gui.control.statetype == Globals.StateType.MODULES_PICK and \ + gui.bottom_bar.picker.hovering != "" and \ + not gui.bottom_bar.picker.hovering in opts: + comp = highlight.make_info_mod(highlight.modules + [gui.bottom_bar.picker.hovering]) + elif placing != null: info = load_turrets.info[placing] elif hovering != null: diff --git a/scripts/turret.gd b/scripts/turret.gd index f365898..32fb17a 100644 --- a/scripts/turret.gd +++ b/scripts/turret.gd @@ -24,7 +24,7 @@ var ray : PackedScene var info : Dictionary var info_mod : Dictionary -var mods = [] +var modules = [] func dict_get (d, keys : Array): var val = d @@ -33,10 +33,10 @@ func dict_get (d, keys : Array): val = dict_get(d.get(key, null), keys) return val -func complete (prev, chain): +func complete (prev, chain, mods): for k in prev: if prev[k] is Dictionary: - complete(prev[k], chain + [k]) + complete(prev[k], chain + [k], mods) else: for m in mods: var mod = load_turrets.modules[m] @@ -49,11 +49,11 @@ func complete (prev, chain): prev[h] = 0 break -func traverse (prev, next, chain): +func traverse (prev, next, chain, mods): for k in prev: if prev[k] is Dictionary: if not next.has(k): next[k] = {} - traverse(prev[k], next[k], chain + [k]) + traverse(prev[k], next[k], chain + [k], mods) else: var add = 0 var mul = 0 @@ -68,12 +68,11 @@ func traverse (prev, next, chain): next[k] = next[k] * (1+mul) else: next[k] = prev[k] -func make_info_mod (): - info_mod.clear() - complete(info, []) - traverse(info, info_mod, []) - - print(info, info_mod) +func make_info_mod (mods): + var modded = {} + complete(info, [], mods) + traverse(info, modded, [], mods) + return modded func _ready(): var root = get_tree().root.get_node("world") @@ -101,7 +100,7 @@ func refresh_model(): func refresh_info(tinfo): self.info = tinfo - make_info_mod() + info_mod = make_info_mod(modules) func filter_in_range(set): var filtered = [] |