From afe534376da33347f2d15ab9b5cb6a2f70b6f984 Mon Sep 17 00:00:00 2001 From: copygirl Date: Wed, 15 May 2024 14:27:55 +0200 Subject: [PATCH] Mockup of load / save menu --- ui/LoadSaveMenu.cs | 38 +++++++++++++++ ui/menu.tscn | 119 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 ui/LoadSaveMenu.cs diff --git a/ui/LoadSaveMenu.cs b/ui/LoadSaveMenu.cs new file mode 100644 index 0000000..6440dc6 --- /dev/null +++ b/ui/LoadSaveMenu.cs @@ -0,0 +1,38 @@ +public partial class LoadSaveMenu : MarginContainer +{ + const string SAVES_FOLDER = "user://saves/"; + + [Export] public FileDialog LoadFileDialog { get; set; } + [Export] public FileDialog SaveFileDialog { get; set; } + + public override void _EnterTree() + { + DirAccess.MakeDirAbsolute(SAVES_FOLDER); + LoadFileDialog.RootSubfolder = SAVES_FOLDER; + SaveFileDialog.RootSubfolder = SAVES_FOLDER; + } + + + public void OnLoadPressed() + { + LoadFileDialog.Popup(); + } + + public void OnOverwriteSavePressed() + { + } + + public void OnCreateSavePressed() + { + SaveFileDialog.Popup(); + } + + + public void OnLoadFileDialogSelected(string path) + { + } + + public void OnSaveFileDialogSelected(string path) + { + } +} diff --git a/ui/menu.tscn b/ui/menu.tscn index 9756bd9..fce4ba5 100644 --- a/ui/menu.tscn +++ b/ui/menu.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=12 format=3 uid="uid://c5ooi36ibspfo"] +[gd_scene load_steps=13 format=3 uid="uid://c5ooi36ibspfo"] [ext_resource type="Script" path="res://ui/Menu.cs" id="1_5qxrt"] +[ext_resource type="Script" path="res://ui/LoadSaveMenu.cs" id="2_0yqy1"] [ext_resource type="Script" path="res://ui/MultiplayerMenu.cs" id="2_3ulcb"] [ext_resource type="Script" path="res://ui/ControlsMenu.cs" id="3_jnj0g"] @@ -62,50 +63,125 @@ columns = 2 custom_minimum_size = Vector2(160, 0) layout_mode = 2 -[node name="Gameplay" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] +[node name="LoadSave" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] layout_mode = 2 -toggle_mode = true -text = "Gameplay" +disabled = true +text = "Load / Save" [node name="Multiplayer" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] layout_mode = 2 -toggle_mode = true text = "Multiplayer" +[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] +custom_minimum_size = Vector2(0, 40) +layout_mode = 2 +text = "Options" +horizontal_alignment = 1 +vertical_alignment = 2 + +[node name="HSeparator" type="HSeparator" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] +layout_mode = 2 + +[node name="Gameplay" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] +layout_mode = 2 +text = "Gameplay" + [node name="Controls" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] layout_mode = 2 -toggle_mode = true text = "Controls" [node name="Graphics" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] layout_mode = 2 -toggle_mode = true text = "Graphics" [node name="Audio" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/SideButtons"] layout_mode = 2 -toggle_mode = true text = "Audio" [node name="TabContainer" type="TabContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer"] custom_minimum_size = Vector2(400, 300) layout_mode = 2 size_flags_vertical = 3 -current_tab = 1 tabs_visible = false use_hidden_tabs_for_min_size = true -[node name="Gameplay" type="CenterContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer"] -visible = false +[node name="LoadSave" type="MarginContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer" node_paths=PackedStringArray("LoadFileDialog", "SaveFileDialog")] layout_mode = 2 +theme_override_constants/margin_left = 8 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 8 +theme_override_constants/margin_bottom = 8 +script = ExtResource("2_0yqy1") +LoadFileDialog = NodePath("LoadFileDialog") +SaveFileDialog = NodePath("SaveFileDialog") -[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Gameplay"] +[node name="LoadFileDialog" type="FileDialog" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave"] +title = "Open a File" +initial_position = 2 +size = Vector2i(480, 400) +popup_window = true +ok_button_text = "Open" +file_mode = 0 +access = 1 +use_native_dialog = true + +[node name="SaveFileDialog" type="FileDialog" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave"] +initial_position = 2 +size = Vector2i(480, 400) +popup_window = true +ok_button_text = "Save" +access = 1 +use_native_dialog = true + +[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave"] layout_mode = 2 -text = "Gameplay -(nothing here yet)" + +[node name="Load" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer"] +layout_mode = 2 +text = "Load existing Save File" + +[node name="GridContainer" type="GridContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer"] +layout_mode = 2 +columns = 2 + +[node name="Label1" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer/GridContainer"] +custom_minimum_size = Vector2(112, 0) +layout_mode = 2 +text = "Filename: " +horizontal_alignment = 2 + +[node name="Filename" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "" +label_settings = SubResource("LabelSettings_nmchh") +horizontal_alignment = 1 +text_overrun_behavior = 3 + +[node name="Label2" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer/GridContainer"] +custom_minimum_size = Vector2(112, 0) +layout_mode = 2 +text = "Last Saved: " +horizontal_alignment = 2 + +[node name="LastSaved" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "never" +label_settings = SubResource("LabelSettings_nmchh") horizontal_alignment = 1 +[node name="OverwriteSave" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer"] +layout_mode = 2 +disabled = true +text = "Overwrite current Save File" + +[node name="CreateSave" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer"] +layout_mode = 2 +text = "Create new Save File ..." + [node name="Multiplayer" type="MarginContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer" node_paths=PackedStringArray("StatusLabel", "WhenDisconnected", "AddressInput", "PortInput", "ConnectButton", "HostButton", "WhenServer", "PortDisplay", "WhenConnected", "PlayersLabel", "DisconnectButton")] +visible = false layout_mode = 2 theme_override_constants/margin_left = 8 theme_override_constants/margin_top = 8 @@ -256,6 +332,16 @@ layout_mode = 2 size_flags_horizontal = 3 text = "Disconnect" +[node name="Gameplay" type="CenterContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer"] +visible = false +layout_mode = 2 + +[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Gameplay"] +layout_mode = 2 +text = "Gameplay +(nothing here yet)" +horizontal_alignment = 1 + [node name="Controls" type="MarginContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer" node_paths=PackedStringArray("DisplayX", "DisplayY", "SliderX", "SliderY", "InvertX", "InvertY")] visible = false layout_mode = 2 @@ -368,6 +454,11 @@ text = "Return to Game " [connection signal="tab_changed" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer" to="." method="OnTabChanged"] +[connection signal="file_selected" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/LoadFileDialog" to="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave" method="OnLoadFileDialogSelected"] +[connection signal="file_selected" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/SaveFileDialog" to="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave" method="OnSaveFileDialogSelected"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer/Load" to="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave" method="OnLoadPressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer/OverwriteSave" to="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave" method="OnOverwriteSavePressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave/VBoxContainer/CreateSave" to="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/LoadSave" method="OnCreateSavePressed"] [connection signal="toggled" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Multiplayer/VBoxContainer/WhenDisconnected/HBoxContainer/ShowAddress" to="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Multiplayer" method="OnShowAddressToggled"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Multiplayer/VBoxContainer/WhenDisconnected/HBoxContainer/Connect" to="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Multiplayer" method="OnConnectPressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Multiplayer/VBoxContainer/WhenDisconnected/HBoxContainer2/Create" to="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Multiplayer" method="OnHostPressed"]