From 563382d459ce18b6df4e5cf9161bc47d942d9276 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 12 Apr 2023 15:44:51 -0400 Subject: Settings screen --- Archipelago/settings_buttons.gd | 31 +++++++++++++++++++++++++++++++ Archipelago/settings_screen.gd | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Archipelago/settings_buttons.gd create mode 100644 Archipelago/settings_screen.gd (limited to 'Archipelago') diff --git a/Archipelago/settings_buttons.gd b/Archipelago/settings_buttons.gd new file mode 100644 index 0000000..5b4d837 --- /dev/null +++ b/Archipelago/settings_buttons.gd @@ -0,0 +1,31 @@ +extends Button + + +func _ready(): + pass + + +func _connect_pressed(): + # Save the AP settings to disk. + var dir = Directory.new() + var path = "user://settings" + if dir.dir_exists(path): + pass + else: + dir.make_dir(path) + + var file = File.new() + file.open("user://settings/archipelago", File.WRITE) + + var data = [ + self.get_parent().get_node("server_box").text, + self.get_parent().get_node("player_box").text, + self.get_parent().get_node("password_box").text + ] + + file.store_var(data, true) + file.close() + + +func _back_pressed(): + fader._fade_start("main_menu") diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd new file mode 100644 index 0000000..91f233d --- /dev/null +++ b/Archipelago/settings_screen.gd @@ -0,0 +1,21 @@ +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) + + # Read AP settings from file, if there are any + var file = File.new() + if file.file_exists("user://settings/archipelago"): + file.open("user://settings/archipelago", File.READ) + var data = file.get_var(true) + file.close() + + if data.size() > 0: + self.get_node("Panel/server_box").text = data[0] + if data.size() > 1: + self.get_node("Panel/player_box").text = data[1] + if data.size() > 2: + self.get_node("Panel/password_box").text = data[2] -- cgit 1.4.1