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/settings_screen.gd | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Archipelago/settings_screen.gd') 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