summary refs log tree commit diff stats
path: root/randomizer/settings_screen.gd
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-12-09 13:14:25 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2023-12-09 13:14:25 -0500
commitf0555579cd462b27c71c486bd7456265cc827937 (patch)
tree12dd8a500dd836f9466e534039fda46005547639 /randomizer/settings_screen.gd
parente72b3e5fae63db0f669155b7b965c2c5fc6f97e3 (diff)
downloadlingo-randomizer-f0555579cd462b27c71c486bd7456265cc827937.tar.gz
lingo-randomizer-f0555579cd462b27c71c486bd7456265cc827937.tar.bz2
lingo-randomizer-f0555579cd462b27c71c486bd7456265cc827937.zip
Starting to work
Diffstat (limited to 'randomizer/settings_screen.gd')
-rw-r--r--randomizer/settings_screen.gd78
1 files changed, 78 insertions, 0 deletions
diff --git a/randomizer/settings_screen.gd b/randomizer/settings_screen.gd new file mode 100644 index 0000000..708b4ef --- /dev/null +++ b/randomizer/settings_screen.gd
@@ -0,0 +1,78 @@
1extends Spatial
2
3
4func _ready():
5 # Undo the load screen removing our cursor
6 get_tree().get_root().set_disable_input(false)
7 Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
8
9 # Create the global Randomizer node, if it doesn't already exist.
10 if not global.has_node("Randomizer"):
11 var randomizer_script = ResourceLoader.load("user://maps/randomizer/randomizer.gd")
12 var randomizer_instance = randomizer_script.new()
13 randomizer_instance.name = "Randomizer"
14 global.add_child(randomizer_instance)
15
16 randomizer_instance.SCRIPT_generator = load("user://maps/randomizer/generator.gd")
17
18 var generated_puzzles = ResourceLoader.load("user://maps/randomizer/generated_puzzles.gd")
19 var generated_puzzles_instance = generated_puzzles.new()
20 generated_puzzles_instance.name = "GeneratedPuzzles"
21 randomizer_instance.add_child(generated_puzzles_instance)
22
23 # Let's also inject any scripts we need to inject now.
24 installScriptExtension(ResourceLoader.load("user://maps/randomizer/load.gd"))
25 installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelEnd.gd"))
26 installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelInput.gd"))
27 installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelLevelSwitch.gd"))
28 installScriptExtension(ResourceLoader.load("user://maps/randomizer/worldTransporter.gd"))
29
30 var randomizer = global.get_node("Randomizer")
31 randomizer.connect("finished_randomizing", self, "randomizationSuccessful")
32 randomizer.connect("randomizer_status", self, "randomizationStatus")
33
34 # Show client version.
35 self.get_node("Panel/title").text = "RANDOMIZER (%s)" % randomizer.my_version
36
37 # Increase font size in text boxes.
38 var field_font = DynamicFont.new()
39 field_font.font_data = load("res://fonts/CutiveMono_Regular.ttf")
40 field_font.size = 36
41
42 self.get_node("Panel/seed_box").add_font_override("font", field_font)
43
44
45# Adapted from https://gitlab.com/Delta-V-Modding/Mods/-/blob/main/game/ModLoader.gd
46func installScriptExtension(childScript: Resource):
47 # Force Godot to compile the script now.
48 # We need to do this here to ensure that the inheritance chain is
49 # properly set up, and multiple mods can chain-extend the same
50 # class multiple times.
51 # This is also needed to make Godot instantiate the extended class
52 # when creating singletons.
53 # The actual instance is thrown away.
54 childScript.new()
55
56 var parentScript = childScript.get_base_script()
57 var parentScriptPath = parentScript.resource_path
58 global._print("ModLoader: Installing script extension over %s" % parentScriptPath)
59 childScript.take_over_path(parentScriptPath)
60
61
62func randomizationStatus(message):
63 var popup = self.get_node("Panel/AcceptDialog")
64 popup.window_title = "Randomizing..."
65 popup.dialog_text = message
66 popup.popup_exclusive = true
67 popup.get_ok().visible = false
68 popup.popup_centered()
69
70
71func randomizationSuccessful():
72 var randomizer = global.get_node("Randomizer")
73
74 # Switch to LL1
75 Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
76 global.map = "level1"
77 global.save_file = randomizer.getSaveFileName()
78 var _discard = get_tree().change_scene("res://scenes/load_screen.tscn")