extends Spatial func _ready(): # Undo the load screen removing our cursor get_tree().get_root().set_disable_input(false) Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) # Create the global Randomizer node, if it doesn't already exist. if not global.has_node("Randomizer"): var randomizer_script = ResourceLoader.load("user://maps/randomizer/randomizer.gd") var randomizer_instance = randomizer_script.new() randomizer_instance.name = "Randomizer" global.add_child(randomizer_instance) randomizer_instance.SCRIPT_generator = load("user://maps/randomizer/generator.gd") randomizer_instance.SCRIPT_steady = load("user://maps/randomizer/steady.gd") var generated_puzzles = ResourceLoader.load("user://maps/randomizer/generated_puzzles.gd") var generated_puzzles_instance = generated_puzzles.new() generated_puzzles_instance.name = "GeneratedPuzzles" randomizer_instance.add_child(generated_puzzles_instance) var extradata = ResourceLoader.load("user://maps/randomizer/extradata.gd") var extradata_instance = extradata.new() extradata_instance.name = "Extradata" randomizer_instance.add_child(extradata_instance) # Let's also inject any scripts we need to inject now. installScriptExtension(ResourceLoader.load("user://maps/randomizer/doorControl.gd")) installScriptExtension(ResourceLoader.load("user://maps/randomizer/load.gd")) installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelEnd.gd")) installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelInput.gd")) installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelLevelSwitch.gd")) installScriptExtension(ResourceLoader.load("user://maps/randomizer/worldTransporter.gd")) var randomizer = global.get_node("Randomizer") randomizer.connect("finished_randomizing", self, "randomizationSuccessful") randomizer.connect("randomizer_status", self, "randomizationStatus") # Show client version. self.get_node("Panel/title").text = "RANDOMIZER (%s)" % randomizer.my_version # Increase font size in text boxes. var field_font = DynamicFont.new() field_font.font_data = load("res://fonts/CutiveMono_Regular.ttf") field_font.size = 36 self.get_node("Panel/seed_box").add_font_override("font", field_font) # Adapted from https://gitlab.com/Delta-V-Modding/Mods/-/blob/main/game/ModLoader.gd func installScriptExtension(childScript: Resource): # Force Godot to compile the script now. # We need to do this here to ensure that the inheritance chain is # properly set up, and multiple mods can chain-extend the same # class multiple times. # This is also needed to make Godot instantiate the extended class # when creating singletons. # The actual instance is thrown away. childScript.new() var parentScript = childScript.get_base_script() var parentScriptPath = parentScript.resource_path global._print("ModLoader: Installing script extension over %s" % parentScriptPath) childScript.take_over_path(parentScriptPath) func randomizationStatus(message): var popup = self.get_node("Panel/AcceptDialog") popup.window_title = "Randomizing..." popup.dialog_text = message popup.popup_exclusive = true popup.get_ok().visible = false popup.popup_centered() func randomizationSuccessful(): var randomizer = global.get_node("Randomizer") # Switch to LL1 Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) global.map = "level1" global.save_file = randomizer.getSaveFileName() var _discard = get_tree().change_scene("res://scenes/load_screen.tscn")