From f06bf177578ca168c32a12b7afd8f30e4a855714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sat, 23 Aug 2025 21:04:26 +0200 Subject: [PATCH] game: add minimal main menu --- scenes/main_menu.gd | 19 ++++++++++++ scenes/main_menu.gd.uid | 1 + scenes/main_menu.tscn | 69 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 scenes/main_menu.gd create mode 100644 scenes/main_menu.gd.uid create mode 100644 scenes/main_menu.tscn diff --git a/scenes/main_menu.gd b/scenes/main_menu.gd new file mode 100644 index 0000000..0fbe4fe --- /dev/null +++ b/scenes/main_menu.gd @@ -0,0 +1,19 @@ +extends Control + +const MAIN = preload("res://scenes/main.tscn") + + +func _ready() -> void: + pass + + +func _on_new_game_button_pressed() -> void: + get_tree().change_scene_to_packed(MAIN) + + +func _on_options_button_pressed() -> void: + pass # Replace with function body. + + +func _on_exit_game_button_pressed() -> void: + get_tree().quit() diff --git a/scenes/main_menu.gd.uid b/scenes/main_menu.gd.uid new file mode 100644 index 0000000..0b296eb --- /dev/null +++ b/scenes/main_menu.gd.uid @@ -0,0 +1 @@ +uid://sd158y3mdmkt diff --git a/scenes/main_menu.tscn b/scenes/main_menu.tscn new file mode 100644 index 0000000..53f5e10 --- /dev/null +++ b/scenes/main_menu.tscn @@ -0,0 +1,69 @@ +[gd_scene load_steps=4 format=3 uid="uid://cynet50emve6c"] + +[ext_resource type="Script" uid="uid://sd158y3mdmkt" path="res://scenes/main_menu.gd" id="1_l6cm7"] + +[sub_resource type="Gradient" id="Gradient_vue75"] +colors = PackedColorArray(0.252028, 0.252028, 0.252028, 1, 0.25098, 0.25098, 0.25098, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_l6cm7"] +gradient = SubResource("Gradient_vue75") + +[node name="MainMenu" 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_l6cm7") + +[node name="Background" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("GradientTexture1D_l6cm7") +expand_mode = 2 + +[node name="PanelContainer" type="PanelContainer" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 20 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 20 +theme_override_constants/margin_bottom = 20 + +[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 10 + +[node name="NewGameButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "New game" + +[node name="OptionsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Options" + +[node name="ExitGameButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Exit game" + +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/NewGameButton" to="." method="_on_new_game_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/ExitGameButton" to="." method="_on_exit_game_button_pressed"]