Improved menu system

This commit is contained in:
Sch1nken 2024-03-23 17:49:33 +01:00
parent da78e7f287
commit c95b8186ab
12 changed files with 181 additions and 111 deletions

View file

@ -0,0 +1,78 @@
[gd_scene load_steps=4 format=3 uid="uid://ddr6rgskqfh8o"]
[ext_resource type="Script" path="res://InGameMenu.gd" id="1_q28o4"]
[ext_resource type="Shader" path="res://Testbed/UIBlur.gdshader" id="2_tx6hg"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_hbvdu"]
shader = ExtResource("2_tx6hg")
shader_parameter/lod = 1.0
[node name="InGameMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_q28o4")
[node name="PanelContainer" type="PanelContainer" parent="."]
self_modulate = Color(1, 1, 1, 0.392157)
material = SubResource("ShaderMaterial_hbvdu")
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Pivot" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MarginContainer" type="MarginContainer" parent="Pivot"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 450
theme_override_constants/margin_top = 250
theme_override_constants/margin_right = 450
theme_override_constants/margin_bottom = 250
[node name="PanelContainer" type="PanelContainer" parent="Pivot/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="MarginContainer" type="MarginContainer" parent="Pivot/MarginContainer/PanelContainer"]
layout_mode = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="VBoxContainer" type="VBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer"]
layout_mode = 2
[node name="Settings" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Settings"
[node name="ExitButton" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Exit"
[node name="CloseButton" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Close"
[connection signal="pressed" from="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/Settings" to="." method="_on_settings_pressed"]
[connection signal="pressed" from="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"]
[connection signal="pressed" from="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/CloseButton" to="." method="_on_close_button_pressed"]

View file

@ -49,6 +49,7 @@ func hide_panel() -> void:
func _on_panel_hidden() -> void:
visible = false
queue_free()
func _on_close_button_pressed():

View file

@ -18,7 +18,7 @@ func show_panel() -> void:
# Called when the node enters the scene tree for the first time.
func _ready():
mat = panel_container.material
mat = panel_container.material.duplicate()
pass # Replace with function body.
func tween_blur(val: float) -> void:
@ -35,6 +35,7 @@ func hide_panel() -> void:
func _on_panel_hidden() -> void:
visible = false
queue_free()
func _on_cancel_pressed():
hide_panel()

View file

@ -3,8 +3,8 @@ extends Control
@onready var exit_button = $PanelContainer/MarginContainer/VBoxContainer/ExitButton
@onready var lan_button = $PanelContainer/MarginContainer/VBoxContainer/LANButton
@onready var rules = $Rules
@onready var settings = $Settings
const SETTINGS = preload("res://UI/Settings/Settings.tscn")
const RULES = preload("res://UI/Rules/Rules.tscn")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -35,6 +35,10 @@ func _on_exit_button_pressed():
func _on_rules_button_pressed():
var rules = RULES.instantiate()
get_tree().root.add_child(rules)
rules.show_panel()
@ -52,5 +56,8 @@ func _on_local_button_pressed():
func _on_settings_button_pressed():
var settings = SETTINGS.instantiate()
get_tree().root.add_child(settings)
settings.show_panel()
pass # Replace with function body.

View file

@ -1,9 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://dogu37xma5vsp"]
[gd_scene load_steps=4 format=3 uid="uid://dogu37xma5vsp"]
[ext_resource type="Script" path="res://UI/main_menu.gd" id="1_q3q3u"]
[ext_resource type="Script" path="res://DisconnectInfo.gd" id="2_2fkdc"]
[ext_resource type="PackedScene" uid="uid://8ffmln680deh" path="res://UI/Rules/Rules.tscn" id="2_7qmw6"]
[ext_resource type="PackedScene" uid="uid://cua6l3r0yh82y" path="res://UI/Settings/Settings.tscn" id="3_2m2r5"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_47fa1"]
bg_color = Color(0, 0, 0, 1)
@ -101,14 +99,6 @@ text = "Rules"
layout_mode = 2
text = "Exit"
[node name="Rules" parent="." instance=ExtResource("2_7qmw6")]
visible = false
layout_mode = 1
[node name="Settings" parent="." instance=ExtResource("3_2m2r5")]
visible = false
layout_mode = 1
[node name="DisconnectInfo" type="Control" parent="."]
visible = false
layout_mode = 1