From ce831897b89974f38fd6f0583e5feac178643a14 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 17 Apr 2024 12:30:18 -0400 Subject: Add connection history --- Archipelago/client.gd | 6 +++++- Archipelago/settings_screen.gd | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'Archipelago') diff --git a/Archipelago/client.gd b/Archipelago/client.gd index f15afe6..489fdb9 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -15,6 +15,7 @@ var ap_pass = "" var confusify_world = false var enable_multiplayer = false var track_player = false +var connection_history = [] const my_version = "2.1.1" const ap_version = {"major": 0, "minor": 4, "build": 5, "class": "Version"} @@ -161,6 +162,8 @@ func _init(): enable_multiplayer = data[5] if data.size() > 6: track_player = data[6] + if data.size() > 7: + connection_history = data[7] processDatapackages() @@ -485,7 +488,8 @@ func saveSettings(): _datapackages, confusify_world, enable_multiplayer, - track_player + track_player, + connection_history ] file.store_var(data, true) file.close() diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index de64214..453e3bf 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd @@ -67,6 +67,19 @@ func _ready(): self.get_node("Panel/multiplayer_box").pressed = apclient.enable_multiplayer self.get_node("Panel/position_box").pressed = apclient.track_player + var history_box = get_node("Panel/connection_history") + if apclient.connection_history.empty(): + history_box.disabled = true + else: + history_box.disabled = false + + var i = 0 + for details in apclient.connection_history: + history_box.get_popup().add_item("%s (%s)" % [details[1], details[0]], i) + i += 1 + + history_box.get_popup().connect("id_pressed", self, "historySelected") + # Show client version. self.get_node("Panel/title").text = "ARCHIPELAGO (%s)" % apclient.my_version @@ -109,6 +122,15 @@ func connectionStatus(message): func connectionSuccessful(): var apclient = global.get_node("Archipelago") + # Save connection details + var connection_details = [apclient.ap_server, apclient.ap_user, apclient.ap_pass] + if apclient.connection_history.has(connection_details): + apclient.connection_history.erase(connection_details) + apclient.connection_history.push_front(connection_details) + if apclient.connection_history.size() > 10: + apclient.connection_history.resize(10) + apclient.saveSettings() + # Switch to LL1 Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) global.save_file = apclient.getSaveFileName() @@ -130,3 +152,12 @@ func connectionUnsuccessful(error_message): popup.popup_exclusive = true popup.get_ok().visible = true popup.popup_centered() + + +func historySelected(index): + var apclient = global.get_node("Archipelago") + var details = apclient.connection_history[index] + + self.get_node("Panel/server_box").text = details[0] + self.get_node("Panel/player_box").text = details[1] + self.get_node("Panel/password_box").text = details[2] -- cgit 1.4.1