about summary refs log tree commit diff stats
path: root/Archipelago
diff options
context:
space:
mode:
Diffstat (limited to 'Archipelago')
-rw-r--r--Archipelago/client.gd44
-rw-r--r--Archipelago/settings_buttons.gd24
-rw-r--r--Archipelago/settings_screen.gd22
3 files changed, 59 insertions, 31 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd new file mode 100644 index 0000000..1d2affd --- /dev/null +++ b/Archipelago/client.gd
@@ -0,0 +1,44 @@
1extends Node
2
3var ap_server = ""
4var ap_user = ""
5var ap_pass = ""
6
7
8func _init():
9 global._print("Instantiated APClient")
10
11 # Read AP settings from file, if there are any
12 var file = File.new()
13 if file.file_exists("user://settings/archipelago"):
14 file.open("user://settings/archipelago", File.READ)
15 var data = file.get_var(true)
16 file.close()
17
18 if data.size() > 0:
19 ap_server = data[0]
20 if data.size() > 1:
21 ap_user = data[1]
22 if data.size() > 2:
23 ap_pass = data[2]
24
25
26func _ready():
27 pass
28
29
30func saveSettings():
31 # Save the AP settings to disk.
32 var dir = Directory.new()
33 var path = "user://settings"
34 if dir.dir_exists(path):
35 pass
36 else:
37 dir.make_dir(path)
38
39 var file = File.new()
40 file.open("user://settings/archipelago", File.WRITE)
41
42 var data = [ap_server, ap_user, ap_pass]
43 file.store_var(data, true)
44 file.close()
diff --git a/Archipelago/settings_buttons.gd b/Archipelago/settings_buttons.gd index 5b4d837..1ab3788 100644 --- a/Archipelago/settings_buttons.gd +++ b/Archipelago/settings_buttons.gd
@@ -6,25 +6,11 @@ func _ready():
6 6
7 7
8func _connect_pressed(): 8func _connect_pressed():
9 # Save the AP settings to disk. 9 var apclient = global.get_node("Archipelago")
10 var dir = Directory.new() 10 apclient.ap_server = self.get_parent().get_node("server_box").text
11 var path = "user://settings" 11 apclient.ap_user = self.get_parent().get_node("player_box").text
12 if dir.dir_exists(path): 12 apclient.ap_pass = self.get_parent().get_node("password_box").text
13 pass 13 apclient.saveSettings()
14 else:
15 dir.make_dir(path)
16
17 var file = File.new()
18 file.open("user://settings/archipelago", File.WRITE)
19
20 var data = [
21 self.get_parent().get_node("server_box").text,
22 self.get_parent().get_node("player_box").text,
23 self.get_parent().get_node("password_box").text
24 ]
25
26 file.store_var(data, true)
27 file.close()
28 14
29 15
30func _back_pressed(): 16func _back_pressed():
diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index 91f233d..3740751 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd
@@ -6,16 +6,14 @@ func _ready():
6 get_tree().get_root().set_disable_input(false) 6 get_tree().get_root().set_disable_input(false)
7 Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) 7 Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
8 8
9 # Read AP settings from file, if there are any 9 # Create the global AP client, if it doesn't already exist.
10 var file = File.new() 10 if not global.has_node("Archipelago"):
11 if file.file_exists("user://settings/archipelago"): 11 var apclient = ResourceLoader.load("user://maps/Archipelago/client.gd")
12 file.open("user://settings/archipelago", File.READ) 12 var apclient_instance = apclient.new()
13 var data = file.get_var(true) 13 apclient_instance.name = "Archipelago"
14 file.close() 14 global.add_child(apclient_instance)
15 15
16 if data.size() > 0: 16 # Populate textboxes with AP settings.
17 self.get_node("Panel/server_box").text = data[0] 17 self.get_node("Panel/server_box").text = global.get_node("Archipelago").ap_server
18 if data.size() > 1: 18 self.get_node("Panel/player_box").text = global.get_node("Archipelago").ap_user
19 self.get_node("Panel/player_box").text = data[1] 19 self.get_node("Panel/password_box").text = global.get_node("Archipelago").ap_pass
20 if data.size() > 2:
21 self.get_node("Panel/password_box").text = data[2]