mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-25 09:34:24 +00:00
Add buttons to the menu
This commit is contained in:
parent
0a88bc0db9
commit
5186a2e90b
3 changed files with 59 additions and 1 deletions
11
main.gd
11
main.gd
|
@ -2,6 +2,7 @@ extends Node
|
|||
class_name Main
|
||||
|
||||
|
||||
@onready var tree: SceneTree = get_tree()
|
||||
@onready var container: Control = $"PrimaryCanvas/SafeMarginContainer"
|
||||
|
||||
|
||||
|
@ -9,6 +10,8 @@ class_name Main
|
|||
enum Stage {
|
||||
NONE = 0,
|
||||
MENU = 1,
|
||||
OPTIONS = 2,
|
||||
GAME = 3,
|
||||
}
|
||||
|
||||
## The [Stage] the game is currently in.
|
||||
|
@ -50,9 +53,17 @@ func destroy_menu() -> void:
|
|||
## Build the main menu.
|
||||
func build_menu() -> void:
|
||||
scene_menu = SCENE_MENU.instantiate()
|
||||
scene_menu.selected_play.connect(_on_menu_selected_play)
|
||||
scene_menu.selected_options.connect(_on_menu_selected_options)
|
||||
container.add_child(scene_menu)
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
current_stage = starting_stage
|
||||
|
||||
func _on_menu_selected_play() -> void:
|
||||
current_stage = Stage.GAME
|
||||
|
||||
func _on_menu_selected_options() -> void:
|
||||
current_stage = Stage.OPTIONS
|
||||
|
|
|
@ -1,2 +1,16 @@
|
|||
extends Control
|
||||
class_name MainMenu
|
||||
|
||||
|
||||
## Emitted when the player has clicked on the Play button.
|
||||
signal selected_play
|
||||
|
||||
## Emitted when the player has clicked on the Options button.
|
||||
signal selected_options
|
||||
|
||||
|
||||
func _on_play_pressed() -> void:
|
||||
selected_play.emit()
|
||||
|
||||
func _on_options_pressed() -> void:
|
||||
selected_options.emit()
|
||||
|
|
|
@ -28,7 +28,14 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/Layout"]
|
||||
[node name="Title" type="MarginContainer" parent="Panel/Layout"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_top = 16
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 16
|
||||
|
||||
[node name="Label" type="RichTextLabel" parent="Panel/Layout/Title"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
bbcode_enabled = true
|
||||
|
@ -37,3 +44,29 @@ text = "[center][font_size=144px]Garasauto[/font_size]
|
|||
|
||||
[font_size=32px]Un gioco del Garasautomobileclub Italia[/font_size][/center]"
|
||||
fit_content = true
|
||||
|
||||
[node name="Buttons" type="MarginContainer" parent="Panel/Layout"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_top = 16
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 16
|
||||
|
||||
[node name="Layout" type="HBoxContainer" parent="Panel/Layout/Buttons"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Play" type="Button" parent="Panel/Layout/Buttons/Layout"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 36
|
||||
text = "Play"
|
||||
|
||||
[node name="Options" type="Button" parent="Panel/Layout/Buttons/Layout"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 36
|
||||
text = "Options"
|
||||
|
||||
[connection signal="pressed" from="Panel/Layout/Buttons/Layout/Play" to="." method="_on_play_pressed"]
|
||||
[connection signal="pressed" from="Panel/Layout/Buttons/Layout/Options" to="." method="_on_options_pressed"]
|
||||
|
|
Loading…
Reference in a new issue