diff options
Diffstat (limited to 'Archipelago/settings_screen.gd')
-rw-r--r-- | Archipelago/settings_screen.gd | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index 2ed8594..ec3b5f1 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd | |||
@@ -1,5 +1,10 @@ | |||
1 | extends Spatial | 1 | extends Spatial |
2 | 2 | ||
3 | var generator_thread = Thread.new() | ||
4 | var generator | ||
5 | |||
6 | signal finished_randomizing | ||
7 | |||
3 | 8 | ||
4 | func _ready(): | 9 | func _ready(): |
5 | # Some helpful logging. | 10 | # Some helpful logging. |
@@ -25,6 +30,7 @@ func _ready(): | |||
25 | 30 | ||
26 | apclient_instance.SCRIPT_doorControl = load("user://maps/Archipelago/doorControl.gd") | 31 | apclient_instance.SCRIPT_doorControl = load("user://maps/Archipelago/doorControl.gd") |
27 | apclient_instance.SCRIPT_effects = load("user://maps/Archipelago/effects.gd") | 32 | apclient_instance.SCRIPT_effects = load("user://maps/Archipelago/effects.gd") |
33 | apclient_instance.SCRIPT_generator = load("user://maps/Archipelago/generator.gd") | ||
28 | apclient_instance.SCRIPT_location = load("user://maps/Archipelago/location.gd") | 34 | apclient_instance.SCRIPT_location = load("user://maps/Archipelago/location.gd") |
29 | apclient_instance.SCRIPT_multiplayer = load("user://maps/Archipelago/multiplayer.gd") | 35 | apclient_instance.SCRIPT_multiplayer = load("user://maps/Archipelago/multiplayer.gd") |
30 | apclient_instance.SCRIPT_mypainting = load("user://maps/Archipelago/mypainting.gd") | 36 | apclient_instance.SCRIPT_mypainting = load("user://maps/Archipelago/mypainting.gd") |
@@ -124,6 +130,16 @@ func installScriptExtension(childScript: Resource): | |||
124 | childScript.take_over_path(parentScriptPath) | 130 | childScript.take_over_path(parentScriptPath) |
125 | 131 | ||
126 | 132 | ||
133 | func getVariantFromFile(path): | ||
134 | var cbin = File.new() | ||
135 | var err = cbin.open_compressed( | ||
136 | "%s\\%s" % [filename.get_base_dir(), path], File.READ, File.COMPRESSION_ZSTD | ||
137 | ) | ||
138 | if err != OK: | ||
139 | global._print("Error: %d" % err) | ||
140 | return cbin.get_var() | ||
141 | |||
142 | |||
127 | func connectionStatus(message): | 143 | func connectionStatus(message): |
128 | var popup = self.get_node("Panel/AcceptDialog") | 144 | var popup = self.get_node("Panel/AcceptDialog") |
129 | popup.window_title = "Connecting to Archipelago" | 145 | popup.window_title = "Connecting to Archipelago" |
@@ -136,6 +152,36 @@ func connectionStatus(message): | |||
136 | func connectionSuccessful(): | 152 | func connectionSuccessful(): |
137 | var apclient = global.get_node("Archipelago") | 153 | var apclient = global.get_node("Archipelago") |
138 | 154 | ||
155 | if apclient._panel_shuffle == apclient.kEXPERIMENTAL_PANELS: | ||
156 | #connect("finished_randomizing", self, "loadLevel") | ||
157 | |||
158 | #generator_thread.start(self, "doGeneration", null, Thread.PRIORITY_HIGH) | ||
159 | #yield(self, "finished_randomizing") | ||
160 | #generator_thread.wait_to_finish() | ||
161 | doGeneration() | ||
162 | |||
163 | loadLevel() | ||
164 | else: | ||
165 | loadLevel() | ||
166 | |||
167 | |||
168 | func doGeneration(): | ||
169 | var apclient = global.get_node("Archipelago") | ||
170 | var gpv = getVariantFromFile("generated_puzzles.bin") | ||
171 | global._print("Forms: %d" % gpv[0].size()) | ||
172 | generator = apclient.SCRIPT_generator.new(gpv) | ||
173 | generator.name = "Generator" | ||
174 | apclient.add_child(generator) | ||
175 | |||
176 | generator.connect("generator_status", self, "connectionStatus") | ||
177 | generator.generate(str(apclient._slot_seed)) | ||
178 | |||
179 | emit_signal("finished_randomizing") | ||
180 | |||
181 | |||
182 | func loadLevel(): | ||
183 | var apclient = global.get_node("Archipelago") | ||
184 | |||
139 | # Save connection details | 185 | # Save connection details |
140 | var connection_details = [apclient.ap_server, apclient.ap_user, apclient.ap_pass] | 186 | var connection_details = [apclient.ap_server, apclient.ap_user, apclient.ap_pass] |
141 | if apclient.connection_history.has(connection_details): | 187 | if apclient.connection_history.has(connection_details): |