diff options
Diffstat (limited to 'apworld/client/panel.gd')
| -rw-r--r-- | apworld/client/panel.gd | 101 |
1 files changed, 101 insertions, 0 deletions
| diff --git a/apworld/client/panel.gd b/apworld/client/panel.gd new file mode 100644 index 0000000..fdaaf0e --- /dev/null +++ b/apworld/client/panel.gd | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | extends "res://scripts/nodes/panel.gd" | ||
| 2 | |||
| 3 | var panel_logic = null | ||
| 4 | var symbol_solvable = true | ||
| 5 | |||
| 6 | var black = load("res://assets/materials/black.material") | ||
| 7 | |||
| 8 | |||
| 9 | func _ready(): | ||
| 10 | super._ready() | ||
| 11 | |||
| 12 | var node_path = String( | ||
| 13 | get_tree().get_root().get_node("scene").get_path_to(self).get_concatenated_names() | ||
| 14 | ) | ||
| 15 | |||
| 16 | var gamedata = global.get_node("Gamedata") | ||
| 17 | var panel_id = gamedata.get_panel_for_map_node_path(global.map, node_path) | ||
| 18 | if panel_id != null: | ||
| 19 | var ap = global.get_node("Archipelago") | ||
| 20 | if ap.shuffle_symbols: | ||
| 21 | if global.map == "the_entry" and node_path == "Panels/Entry/front_1": | ||
| 22 | clue = "i" | ||
| 23 | symbol = "" | ||
| 24 | |||
| 25 | setField("clue", clue) | ||
| 26 | setField("symbol", symbol) | ||
| 27 | |||
| 28 | panel_logic = gamedata.objects.get_panels()[panel_id] | ||
| 29 | checkSymbolSolvable() | ||
| 30 | |||
| 31 | if not symbol_solvable: | ||
| 32 | get_tree().get_root().get_node("scene/player").connect( | ||
| 33 | "evaluate_solvability", evaluateSolvability | ||
| 34 | ) | ||
| 35 | |||
| 36 | |||
| 37 | func checkSymbolSolvable(): | ||
| 38 | var old_solvable = symbol_solvable | ||
| 39 | symbol_solvable = true | ||
| 40 | |||
| 41 | if panel_logic == null: | ||
| 42 | # There's no logic for this panel. | ||
| 43 | return | ||
| 44 | |||
| 45 | var ap = global.get_node("Archipelago") | ||
| 46 | if not ap.shuffle_symbols: | ||
| 47 | # Symbols aren't item-locked. | ||
| 48 | return | ||
| 49 | |||
| 50 | var gamedata = global.get_node("Gamedata") | ||
| 51 | for symbol in panel_logic.get_symbols(): | ||
| 52 | var item_name = gamedata.kSYMBOL_ITEMS.get(symbol) | ||
| 53 | var item_id = gamedata.objects.get_special_ids()[item_name] | ||
| 54 | if ap.client.getItemAmount(item_id) < 1: | ||
| 55 | symbol_solvable = false | ||
| 56 | break | ||
| 57 | |||
| 58 | if symbol_solvable != old_solvable: | ||
| 59 | if symbol_solvable: | ||
| 60 | setField("clue", clue) | ||
| 61 | setField("symbol", symbol) | ||
| 62 | setField("answer", answer) | ||
| 63 | else: | ||
| 64 | quad_mesh.surface_set_material(0, black) | ||
| 65 | get_node("Hinge/clue").text = "missing" | ||
| 66 | get_node("Hinge/answer").text = "symbols" | ||
| 67 | |||
| 68 | |||
| 69 | func checkSolvable(key): | ||
| 70 | checkSymbolSolvable() | ||
| 71 | if not symbol_solvable: | ||
| 72 | return false | ||
| 73 | |||
| 74 | return super.checkSolvable(key) | ||
| 75 | |||
| 76 | |||
| 77 | func evaluateSolvability(): | ||
| 78 | checkSolvable("") | ||
| 79 | |||
| 80 | |||
| 81 | func passedInput(key, skip_focus_check = false): | ||
| 82 | if not symbol_solvable: | ||
| 83 | return | ||
| 84 | |||
| 85 | super.passedInput(key, skip_focus_check) | ||
| 86 | |||
| 87 | |||
| 88 | func focus(): | ||
| 89 | if not symbol_solvable: | ||
| 90 | has_focus = false | ||
| 91 | return | ||
| 92 | |||
| 93 | super.focus() | ||
| 94 | |||
| 95 | |||
| 96 | func unfocus(): | ||
| 97 | if not symbol_solvable: | ||
| 98 | has_focus = false | ||
| 99 | return | ||
| 100 | |||
| 101 | super.unfocus() | ||
