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 +++++++++++++++++++++++++++++++ archipelago.tscn | 25 +++++++++++++++++-------- 3 files changed, 53 insertions(+), 9 deletions(-) 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] diff --git a/archipelago.tscn b/archipelago.tscn index f0b8ab9..f063af9 100644 --- a/archipelago.tscn +++ b/archipelago.tscn @@ -86,9 +86,9 @@ align = 2 [node name="credit5" parent="Panel" instance=ExtResource( 1 )] margin_left = 1239.0 -margin_top = 271.0 +margin_top = 422.0 margin_right = 1829.0 -margin_bottom = 335.0 +margin_bottom = 486.0 custom_fonts/font = ExtResource( 2 ) custom_styles/normal = SubResource( 1 ) text = "OPTIONS" @@ -155,9 +155,9 @@ margin_bottom = 58.0 [node name="confusing_box" type="CheckBox" parent="Panel"] margin_left = 1227.0 -margin_top = 351.0 +margin_top = 502.0 margin_right = 1832.0 -margin_bottom = 439.0 +margin_bottom = 590.0 custom_fonts/font = ExtResource( 6 ) custom_icons/checked = ExtResource( 8 ) custom_icons/unchecked = ExtResource( 7 ) @@ -165,9 +165,9 @@ text = "Make world more confusing" [node name="multiplayer_box" type="CheckBox" parent="Panel"] margin_left = 1227.0 -margin_top = 461.0 +margin_top = 612.0 margin_right = 1832.0 -margin_bottom = 549.0 +margin_bottom = 700.0 custom_fonts/font = ExtResource( 6 ) custom_icons/checked = ExtResource( 8 ) custom_icons/unchecked = ExtResource( 7 ) @@ -175,13 +175,22 @@ text = "Show other players" [node name="position_box" type="CheckBox" parent="Panel"] margin_left = 1227.0 -margin_top = 571.0 +margin_top = 722.0 margin_right = 1832.0 -margin_bottom = 654.0 +margin_bottom = 810.0 custom_fonts/font = ExtResource( 6 ) custom_icons/checked = ExtResource( 8 ) custom_icons/unchecked = ExtResource( 7 ) text = "Send position to tracker" +[node name="connection_history" type="MenuButton" parent="Panel"] +margin_left = 1239.0 +margin_top = 276.0 +margin_right = 1829.0 +margin_bottom = 372.0 +custom_fonts/font = ExtResource( 6 ) +text = "connection history" +flat = false + [connection signal="pressed" from="Panel/connect_button" to="Panel/connect_button" method="_connect_pressed"] [connection signal="pressed" from="Panel/quit_button" to="Panel/quit_button" method="_back_pressed"] -- cgit 1.4.1