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 +++++++ archipelago.tscn | 133 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+) create mode 100644 Archipelago/settings_buttons.gd create mode 100644 Archipelago/settings_screen.gd create mode 100644 archipelago.tscn 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] diff --git a/archipelago.tscn b/archipelago.tscn new file mode 100644 index 0000000..def9ce4 --- /dev/null +++ b/archipelago.tscn @@ -0,0 +1,133 @@ +[gd_scene load_steps=9 format=2] + +[ext_resource path="res://nodes/label.tscn" type="PackedScene" id=1] +[ext_resource path="res://fonts/Lingo.tres" type="DynamicFont" id=2] +[ext_resource path="res://nodes/button.tscn" type="PackedScene" id=3] +[ext_resource path="user://maps/Archipelago/settings_buttons.gd" type="Script" id=4] +[ext_resource path="user://maps/Archipelago/settings_screen.gd" type="Script" id=5] +[ext_resource path="res://fonts/Lingo35.tres" type="DynamicFont" id=6] + +[sub_resource type="StyleBoxFlat" id=1] +bg_color = Color( 0, 0, 0, 0 ) + +[sub_resource type="StyleBoxFlat" id=2] +bg_color = Color( 1, 1, 1, 1 ) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color( 1, 1, 0, 1 ) +border_blend = true +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 +expand_margin_left = 5.0 +expand_margin_right = 5.0 +expand_margin_top = 5.0 +expand_margin_bottom = 5.0 + +[node name="settings_screen" type="Spatial"] +script = ExtResource( 5 ) + +[node name="Panel" type="Panel" parent="."] +margin_right = 1920.0 +margin_bottom = 1080.0 + +[node name="title" parent="Panel" instance=ExtResource( 1 )] +margin_left = 0.0 +margin_top = 75.0 +margin_right = 1920.0 +margin_bottom = 225.0 +custom_fonts/font = ExtResource( 2 ) +text = "ARCHIPELAGO" +valign = 1 + +[node name="credit" parent="Panel" instance=ExtResource( 1 )] +visible = false +margin_left = 1278.0 +margin_top = 974.0 +margin_right = 1868.0 +margin_bottom = 1034.0 +custom_fonts/font = ExtResource( 2 ) +text = "Brenton Wildes" + +[node name="connect_button" parent="Panel" instance=ExtResource( 3 )] +margin_left = 255.0 +margin_top = 875.0 +margin_right = 891.0 +margin_bottom = 1025.0 +custom_colors/font_color_hover = Color( 1, 0.501961, 0, 1 ) +custom_fonts/font = ExtResource( 2 ) +text = "CONNECT" +script = ExtResource( 4 ) + +[node name="quit_button" parent="Panel" instance=ExtResource( 3 )] +margin_left = 1102.0 +margin_top = 875.0 +margin_right = 1738.0 +margin_bottom = 1025.0 +custom_colors/font_color_hover = Color( 1, 0, 0, 1 ) +custom_fonts/font = ExtResource( 2 ) +text = "BACK" +script = ExtResource( 4 ) + +[node name="credit2" parent="Panel" instance=ExtResource( 1 )] +margin_left = 267.0 +margin_top = 347.0 +margin_right = 857.0 +margin_bottom = 411.0 +custom_fonts/font = ExtResource( 2 ) +custom_styles/normal = SubResource( 1 ) +text = "SERVER" + +[node name="credit3" parent="Panel" instance=ExtResource( 1 )] +margin_left = 263.0 +margin_top = 515.0 +margin_right = 853.0 +margin_bottom = 579.0 +custom_fonts/font = ExtResource( 2 ) +custom_styles/normal = SubResource( 1 ) +text = "PLAYER" + +[node name="credit4" parent="Panel" instance=ExtResource( 1 )] +margin_left = 199.0 +margin_top = 691.0 +margin_right = 789.0 +margin_bottom = 755.0 +custom_fonts/font = ExtResource( 2 ) +custom_styles/normal = SubResource( 1 ) +text = "PASSWORD" + +[node name="server_box" type="LineEdit" parent="Panel"] +margin_left = 682.0 +margin_top = 295.0 +margin_right = 1324.0 +margin_bottom = 445.0 +custom_colors/selection_color = Color( 0.482353, 0, 0, 1 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_styles/focus = SubResource( 2 ) +align = 1 + +[node name="player_box" type="LineEdit" parent="Panel"] +margin_left = 682.0 +margin_top = 477.0 +margin_right = 1324.0 +margin_bottom = 627.0 +custom_colors/selection_color = Color( 0.482353, 0, 0, 1 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_styles/focus = SubResource( 2 ) +align = 1 + +[node name="password_box" type="LineEdit" parent="Panel"] +margin_left = 682.0 +margin_top = 659.0 +margin_right = 1324.0 +margin_bottom = 809.0 +custom_colors/selection_color = Color( 0.482353, 0, 0, 1 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_styles/focus = SubResource( 2 ) +align = 1 + +[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