From 832043c49ebca487dcf07ee900a35fe3423dd9d7 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 23 Mar 2020 22:23:12 +0100 Subject: [PATCH] Reworked the menu a bit as an experiment, now a player can only have one character active at a time. (It is really hacky for now, it will show more characters if manually added.) --- game/scenes/CharacterSelectorMenu.gd | 21 ++++++++++- game/scenes/Menu.tscn | 53 ++++++++++++++-------------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/game/scenes/CharacterSelectorMenu.gd b/game/scenes/CharacterSelectorMenu.gd index 2db5efa5..a3deb72c 100644 --- a/game/scenes/CharacterSelectorMenu.gd +++ b/game/scenes/CharacterSelectorMenu.gd @@ -27,6 +27,10 @@ export(ButtonGroup) var character_button_group : ButtonGroup export(PackedScene) var character_entry : PackedScene export(String) var character_folder : String +export(NodePath) var load_button_path : NodePath +export(NodePath) var renounce_button_path : NodePath +export(NodePath) var create_button_path : NodePath + var container : Node var player_display_container_node : Node @@ -98,9 +102,24 @@ func refresh(): if first_entry != null: first_entry.pressed = true - + + if first_entry != null: + get_node(container_path).show() + get_node(load_button_path).show() + get_node(create_button_path).hide() + get_node(renounce_button_path).show() + else: + get_node(container_path).hide() + get_node(load_button_path).hide() + get_node(create_button_path).show() + get_node(renounce_button_path).hide() else: dir.make_dir("user://" + character_folder) + + get_node(container_path).hide() + get_node(load_button_path).hide() + get_node(create_button_path).show() + get_node(renounce_button_path).hide() func clear() -> void: for c in container.get_children(): diff --git a/game/scenes/Menu.tscn b/game/scenes/Menu.tscn index bfa86a8b..6b2fccd0 100644 --- a/game/scenes/Menu.tscn +++ b/game/scenes/Menu.tscn @@ -108,11 +108,14 @@ __meta__ = { "_editor_description_": "" } menu_path = NodePath("..") -container_path = NodePath("CharacterSelector/CharacterSelector/VBoxContainer/ScrollContainer/Container") +container_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Container") player_display_container_path = NodePath("../Char/CharacterDisplay") character_button_group = ExtResource( 4 ) character_entry = ExtResource( 2 ) character_folder = "characters" +load_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Load") +renounce_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Renounce") +create_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Create") [node name="CharacterSelector" type="MarginContainer" parent="CharacterSelectorMenu"] anchor_left = 1.0 @@ -129,52 +132,48 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="CharacterSelector" type="PanelContainer" parent="CharacterSelectorMenu/CharacterSelector"] +[node name="VBoxContainer" type="VBoxContainer" parent="CharacterSelectorMenu/CharacterSelector"] margin_top = 20.0 margin_right = 269.0 margin_bottom = 580.0 +alignment = 2 + +[node name="CharacterSelector" type="PanelContainer" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer"] +margin_top = 450.0 +margin_right = 269.0 +margin_bottom = 560.0 __meta__ = { "_edit_use_anchors_": false } -[node name="VBoxContainer" type="VBoxContainer" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector"] +[node name="VBoxContainer" type="VBoxContainer" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector"] margin_left = 4.0 margin_top = 4.0 margin_right = 265.0 -margin_bottom = 556.0 +margin_bottom = 106.0 -[node name="ScrollContainer" type="ScrollContainer" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer"] -margin_right = 261.0 -margin_bottom = 484.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="Container" type="VBoxContainer" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/ScrollContainer"] +[node name="Container" type="VBoxContainer" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"] margin_right = 261.0 size_flags_horizontal = 3 -[node name="Load" type="Button" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer"] -margin_top = 492.0 +[node name="Load" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"] +margin_top = 8.0 margin_right = 261.0 -margin_bottom = 518.269 +margin_bottom = 34.269 text = "Load" -[node name="HBoxContainer" type="HBoxContainer" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer"] -margin_top = 526.0 +[node name="Renounce" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"] +margin_top = 42.0 margin_right = 261.0 -margin_bottom = 552.0 - -[node name="Renounce" type="Button" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer"] -margin_right = 128.0 -margin_bottom = 26.269 +margin_bottom = 68.269 size_flags_horizontal = 3 size_flags_vertical = 3 text = "Renounce" -[node name="Create" type="Button" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer"] -margin_left = 132.0 +[node name="Create" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"] +margin_top = 76.0 margin_right = 261.0 -margin_bottom = 26.269 +margin_bottom = 102.269 size_flags_horizontal = 3 size_flags_vertical = 3 text = "Create" @@ -588,9 +587,9 @@ light_energy = 0.87 light_specular = 0.65 shadow_bias = 0.07 script = ExtResource( 19 ) -[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/Load" to="CharacterSelectorMenu" method="load_character"] -[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer/Renounce" to="CharacterSelectorMenu" method="renounce_character"] -[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer/Create" to="." method="switch_to_menu" binds= [ 1 ]] +[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Load" to="CharacterSelectorMenu" method="load_character"] +[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Renounce" to="CharacterSelectorMenu" method="renounce_character"] +[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Create" to="." method="switch_to_menu" binds= [ 1 ]] [connection signal="pressed" from="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer/Create" to="CharacterCreationMenu" method="create"] [connection signal="pressed" from="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer/Back" to="." method="switch_to_menu" binds= [ 0 ]] [connection signal="pressed" from="ConnectMenu/PanelContainer/VBoxContainer/Button2" to="ConnectMenu" method="hide"]