From cc0aad761be6f387aa848141697eb5d3c6b636fc Mon Sep 17 00:00:00 2001 From: Jan Heemstra Date: Wed, 1 Dec 2021 00:22:47 +0100 Subject: [PATCH] Added menu scrollcontainer --- Game/Assets/UI/GUI.tscn | 44 ++++++++++++++++++++++++-------------- Game/Assets/UI/Menu.gd | 4 ++-- Game/Assets/UI/Menu.tscn | 5 ++++- Game/Assets/UI/MenuData.gd | 2 +- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Game/Assets/UI/GUI.tscn b/Game/Assets/UI/GUI.tscn index 3bc8248..d65f27b 100644 --- a/Game/Assets/UI/GUI.tscn +++ b/Game/Assets/UI/GUI.tscn @@ -6,9 +6,12 @@ [ext_resource type="Script" path="res://Assets/UI/GUI.gd" id="3"] [ext_resource type="AudioStream" uid="uid://dpjwcruomxgkk" path="res://Assets/SFX/UI_Cancel.wav" id="4_lnh50"] -[node name="GUI" type="CenterContainer"] +[node name="GUI" type="VBoxContainer"] anchor_right = 1.0 anchor_bottom = 1.0 +offset_top = 20.0 +offset_bottom = -20.0 +alignment = 1 script = ExtResource( "3" ) __meta__ = { "_edit_use_anchors_": false @@ -16,24 +19,33 @@ __meta__ = { [node name="Logo" type="TextureRect" parent="."] offset_left = 256.0 -offset_top = 12.0 offset_right = 768.0 -offset_bottom = 587.0 -rect_min_size = Vector2(0, 575) -size_flags_horizontal = 0 +offset_bottom = 197.0 +size_flags_horizontal = 4 size_flags_vertical = 0 texture = ExtResource( "2_oueme" ) __meta__ = { "_edit_use_anchors_": false } -[node name="Menu" parent="." instance=ExtResource( "2" )] +[node name="ScrollContainer" type="ScrollContainer" parent="."] offset_left = 387.0 -offset_top = 236.0 +offset_top = 201.0 offset_right = 637.0 -offset_bottom = 364.0 +offset_bottom = 560.0 +size_flags_horizontal = 6 +size_flags_vertical = 3 +follow_focus = true +scroll_horizontal_enabled = false +scroll_horizontal_visible = false -[node name="Play" parent="Menu" instance=ExtResource( "1" )] +[node name="Menu" parent="ScrollContainer" instance=ExtResource( "2" )] +offset_left = 0.0 +offset_top = 0.0 +offset_right = 250.0 +offset_bottom = 128.0 + +[node name="Play" parent="ScrollContainer/Menu" instance=ExtResource( "1" )] anchor_right = 0.0 anchor_bottom = 0.0 offset_top = 33.0 @@ -43,7 +55,7 @@ text = "play " label = "play" -[node name="Options" parent="Menu" instance=ExtResource( "1" )] +[node name="Options" parent="ScrollContainer/Menu" instance=ExtResource( "1" )] anchor_right = 0.0 anchor_bottom = 0.0 offset_top = 66.0 @@ -53,7 +65,7 @@ theme_override_font_sizes/font_size = 16 text = "options" label = "options" -[node name="Quit" parent="Menu" instance=ExtResource( "1" )] +[node name="Quit" parent="ScrollContainer/Menu" instance=ExtResource( "1" )] anchor_right = 0.0 anchor_bottom = 0.0 offset_top = 99.0 @@ -62,11 +74,11 @@ offset_bottom = 128.0 text = "quit" label = "quit" -[node name="ClickSound" parent="Menu/Quit" index="0"] +[node name="ClickSound" parent="ScrollContainer/Menu/Quit" index="0"] stream = ExtResource( "4_lnh50" ) -[connection signal="pressed" from="Menu/Play" to="Menu" method="open_menu" binds= ["res://Assets/UI/PlayMenu.tscn"]] -[connection signal="pressed" from="Menu/Options" to="Menu" method="open_menu" binds= ["res://Assets/UI/OptionsMenu.tscn"]] -[connection signal="pressed" from="Menu/Quit" to="." method="quit_game"] +[connection signal="pressed" from="ScrollContainer/Menu/Play" to="ScrollContainer/Menu" method="open_menu" binds= ["res://Assets/UI/PlayMenu.tscn"]] +[connection signal="pressed" from="ScrollContainer/Menu/Options" to="ScrollContainer/Menu" method="open_menu" binds= ["res://Assets/UI/OptionsMenu.tscn"]] +[connection signal="pressed" from="ScrollContainer/Menu/Quit" to="." method="quit_game"] -[editable path="Menu/Quit"] +[editable path="ScrollContainer/Menu/Quit"] diff --git a/Game/Assets/UI/Menu.gd b/Game/Assets/UI/Menu.gd index dbbc9af..830b1bd 100644 --- a/Game/Assets/UI/Menu.gd +++ b/Game/Assets/UI/Menu.gd @@ -2,8 +2,8 @@ extends VBoxContainer var previous_menu : Node = null var settings = {} -@onready var GUI = get_parent() -@onready var Main = get_parent().get_parent() +@onready var GUI = get_parent().get_parent() +@onready var Main = get_parent().get_parent().get_parent() # Called when the node enters the scene tree for the first time. func _ready(): diff --git a/Game/Assets/UI/Menu.tscn b/Game/Assets/UI/Menu.tscn index 920f7f7..a30fe84 100644 --- a/Game/Assets/UI/Menu.tscn +++ b/Game/Assets/UI/Menu.tscn @@ -10,14 +10,17 @@ offset_top = 269.0 offset_right = 548.0 offset_bottom = 331.0 rect_min_size = Vector2(250, 0) +size_flags_vertical = 3 +alignment = 1 script = ExtResource( "1" ) __meta__ = { "_edit_use_anchors_": false } [node name="Back" type="Button" parent="."] +offset_top = 16.0 offset_right = 250.0 -offset_bottom = 29.0 +offset_bottom = 45.0 text = "back " diff --git a/Game/Assets/UI/MenuData.gd b/Game/Assets/UI/MenuData.gd index abae6b5..6ac6b44 100644 --- a/Game/Assets/UI/MenuData.gd +++ b/Game/Assets/UI/MenuData.gd @@ -1,7 +1,7 @@ extends "res://Assets/UI/MenuItem.gd" @export var index = "" -@onready var GUI = get_parent().get_parent() +@onready var GUI = get_parent().get_parent().get_parent() signal data_changed(data)