diff options
Diffstat (limited to 'Archipelago/settings_screen.gd')
| -rw-r--r-- | Archipelago/settings_screen.gd | 26 |
1 files changed, 26 insertions, 0 deletions
| diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index 0854a8b..9624693 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd | |||
| @@ -13,6 +13,11 @@ func _ready(): | |||
| 13 | apclient_instance.name = "Archipelago" | 13 | apclient_instance.name = "Archipelago" |
| 14 | global.add_child(apclient_instance) | 14 | global.add_child(apclient_instance) |
| 15 | 15 | ||
| 16 | # Let's also inject any scripts we need to inject now. | ||
| 17 | installScriptExtension("user://maps/Archipelago/doorControl.gd") | ||
| 18 | installScriptExtension("user://maps/Archipelago/load.gd") | ||
| 19 | installScriptExtension("user://maps/Archipelago/painting_eye.gd") | ||
| 20 | |||
| 16 | global.get_node("Archipelago").connect("client_connected", self, "connectionSuccessful") | 21 | global.get_node("Archipelago").connect("client_connected", self, "connectionSuccessful") |
| 17 | 22 | ||
| 18 | # Populate textboxes with AP settings. | 23 | # Populate textboxes with AP settings. |
| @@ -21,6 +26,27 @@ func _ready(): | |||
| 21 | self.get_node("Panel/password_box").text = global.get_node("Archipelago").ap_pass | 26 | self.get_node("Panel/password_box").text = global.get_node("Archipelago").ap_pass |
| 22 | 27 | ||
| 23 | 28 | ||
| 29 | # Adapted from https://gitlab.com/Delta-V-Modding/Mods/-/blob/main/game/ModLoader.gd | ||
| 30 | func installScriptExtension(childScriptPath: String): | ||
| 31 | var childScript = ResourceLoader.load(childScriptPath) | ||
| 32 | |||
| 33 | # Force Godot to compile the script now. | ||
| 34 | # We need to do this here to ensure that the inheritance chain is | ||
| 35 | # properly set up, and multiple mods can chain-extend the same | ||
| 36 | # class multiple times. | ||
| 37 | # This is also needed to make Godot instantiate the extended class | ||
| 38 | # when creating singletons. | ||
| 39 | # The actual instance is thrown away. | ||
| 40 | childScript.new() | ||
| 41 | |||
| 42 | var parentScript = childScript.get_base_script() | ||
| 43 | var parentScriptPath = parentScript.resource_path | ||
| 44 | global._print( | ||
| 45 | "ModLoader: Installing script extension: %s <- %s" % [parentScriptPath, childScriptPath] | ||
| 46 | ) | ||
| 47 | childScript.take_over_path(parentScriptPath) | ||
| 48 | |||
| 49 | |||
| 24 | func connectionSuccessful(): | 50 | func connectionSuccessful(): |
| 25 | # Switch to LL1 | 51 | # Switch to LL1 |
| 26 | Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) | 52 | Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) |
