Skip to content

Commit

Permalink
Game menu (#115)
Browse files Browse the repository at this point in the history
* makes the buttons  in the menu accessible with the arrow keys

* adds a texture to the buttons

* Makes the version tag be updated according to the game version on the settings

* Makes the buttons that are hovered be lighted
  • Loading branch information
Paper-2 authored Aug 10, 2024
1 parent facd0a4 commit ae7d779
Show file tree
Hide file tree
Showing 27 changed files with 482 additions and 37 deletions.
2 changes: 1 addition & 1 deletion #Scenes/Events/mob/0.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[ext_resource type="Texture2D" uid="uid://d4muqvs3etnr8" path="res://Art/Card_layout/discard_pile.png" id="12_0nlrw"]
[ext_resource type="Script" path="res://UI/DiscardPileUISetter.gd" id="13_8nsar"]
[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="14_os5i4"]
[ext_resource type="PackedScene" uid="uid://ruwidm3egyrx" path="res://#Scenes/xp_bar.tscn" id="15_r7cr8"]
[ext_resource type="PackedScene" path="res://#Scenes/xp_bar.tscn" id="15_r7cr8"]

[node name="TestingScene" type="Node2D"]
script = ExtResource("1_nmgwp")
Expand Down
130 changes: 94 additions & 36 deletions #Scenes/MainMenu.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://dpmfv4x71bcw7"]
[gd_scene load_steps=13 format=3 uid="uid://chw8kc2q4o3pi"]

[ext_resource type="Script" path="res://#Scenes/SceneScripts/MainMenu.gd" id="1_mwp8y"]
[ext_resource type="Texture2D" uid="uid://u5naod8gur3m" path="res://Art/Menus/main_menu_bg-1.png" id="2_v07no"]
[ext_resource type="Texture2D" uid="uid://dnbmjftura7ij" path="res://Art/Menus/main_menu_bg-2.png" id="2_00vte"]
[ext_resource type="Texture2D" uid="uid://b0qf2xlgmuhxo" path="res://Art/Menus/Button_normal/continue-0.png" id="3_76twh"]
[ext_resource type="Texture2D" uid="uid://drawyashi8bx0" path="res://Art/Menus/Button_focused/continue-1.png" id="4_d6gd7"]
[ext_resource type="Texture2D" uid="uid://ck042otua8tmp" path="res://Art/Menus/Button_normal/new_game-0.png" id="5_jn1yb"]
[ext_resource type="Texture2D" uid="uid://dqwvbpqsi6i5t" path="res://Art/Menus/Button_focused/new_game-1.png" id="6_3ot3c"]
[ext_resource type="Texture2D" uid="uid://bhvskryq17bd2" path="res://Art/Menus/Button_normal/options-0.png" id="7_whbdq"]
[ext_resource type="Texture2D" uid="uid://dp0sfj3tdor8w" path="res://Art/Menus/Button_focused/options-1.png" id="8_hktx2"]
[ext_resource type="Texture2D" uid="uid://2hmlylb45gfa" path="res://Art/Menus/Button_normal/credits-0.png" id="9_70yof"]
[ext_resource type="Texture2D" uid="uid://cg7x1jklsh8pn" path="res://Art/Menus/Button_focused/credits-1.png" id="10_vce0e"]
[ext_resource type="Texture2D" uid="uid://bfy3htfthvnvb" path="res://Art/Menus/Button_normal/quit-0.png" id="11_g0haw"]
[ext_resource type="Texture2D" uid="uid://cxnt3pjokwbjy" path="res://Art/Menus/Button_focused/quit-1.png" id="12_eqc6b"]

[node name="Main menu" type="Control"]
layout_mode = 3
Expand All @@ -16,46 +26,94 @@ script = ExtResource("1_mwp8y")
layout_mode = 2
offset_right = 1920.0
offset_bottom = 1080.0
texture = ExtResource("2_v07no")
texture = ExtResource("2_00vte")
expand_mode = 1

[node name="Label" type="Label" parent="."]
[node name="game version" type="Label" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
theme_override_font_sizes/font_size = 34
text = "This is the main menu"

[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -180.0
offset_top = -230.0
offset_right = -21.0
offset_bottom = -27.0
grow_horizontal = 0
grow_vertical = 0
theme_override_constants/separation = 7

[node name="Start" type="Button" parent="VBoxContainer"]
offset_left = 9.0
offset_top = 1037.0
offset_right = 345.0
offset_bottom = 1084.0
theme_override_font_sizes/font_size = 24
text = "Version"

[node name="Title" type="Label" parent="."]
layout_mode = 0
offset_left = 1030.0
offset_top = 137.0
offset_right = 1863.0
offset_bottom = 274.0
theme_override_font_sizes/font_size = 100
text = "Title place holder"

[node name="Menu buttons" type="VBoxContainer" parent="."]
layout_mode = 0
offset_left = 25.0
offset_top = 481.0
offset_right = 465.0
offset_bottom = 1162.0
focus_mode = 2
theme_override_constants/separation = -195
alignment = 1

[node name="Continue" type="TextureButton" parent="Menu buttons"]
layout_mode = 2
size_flags_vertical = 3
focus_neighbor_top = NodePath("../Quit")
focus_neighbor_bottom = NodePath("../New game")
disabled = true
texture_normal = ExtResource("3_76twh")
texture_hover = ExtResource("4_d6gd7")
texture_focused = ExtResource("4_d6gd7")
ignore_texture_size = true
stretch_mode = 4

[node name="New game" type="TextureButton" parent="Menu buttons"]
layout_mode = 2
size_flags_vertical = 3
focus_neighbor_top = NodePath("../Continue")
focus_neighbor_bottom = NodePath("../Options")
texture_normal = ExtResource("5_jn1yb")
texture_hover = ExtResource("6_3ot3c")
texture_focused = ExtResource("6_3ot3c")
ignore_texture_size = true
stretch_mode = 4

[node name="Options" type="TextureButton" parent="Menu buttons"]
layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "Start"
size_flags_vertical = 3
focus_neighbor_top = NodePath("../New game")
focus_neighbor_bottom = NodePath("../Credits")
texture_normal = ExtResource("7_whbdq")
texture_hover = ExtResource("8_hktx2")
texture_focused = ExtResource("8_hktx2")
ignore_texture_size = true
stretch_mode = 4

[node name="Options" type="Button" parent="VBoxContainer"]
[node name="Credits" type="TextureButton" parent="Menu buttons"]
layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "Options"
size_flags_vertical = 3
focus_neighbor_top = NodePath("../Options")
focus_neighbor_bottom = NodePath("../Quit")
disabled = true
texture_normal = ExtResource("9_70yof")
texture_hover = ExtResource("10_vce0e")
texture_focused = ExtResource("10_vce0e")
ignore_texture_size = true
stretch_mode = 4

[node name="Quit" type="Button" parent="VBoxContainer"]
[node name="Quit" type="TextureButton" parent="Menu buttons"]
layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "Quit"
size_flags_vertical = 3
focus_neighbor_top = NodePath("../Credits")
focus_neighbor_bottom = NodePath("../Continue")
texture_normal = ExtResource("11_g0haw")
texture_hover = ExtResource("12_eqc6b")
texture_focused = ExtResource("12_eqc6b")
ignore_texture_size = true
stretch_mode = 4

[connection signal="pressed" from="VBoxContainer/Start" to="." method="_on_start_pressed"]
[connection signal="pressed" from="VBoxContainer/Options" to="." method="_on_options_pressed"]
[connection signal="pressed" from="VBoxContainer/Quit" to="." method="_on_quit_pressed"]
[connection signal="pressed" from="Menu buttons/New game" to="." method="_on_start_pressed"]
[connection signal="pressed" from="Menu buttons/Options" to="." method="_on_options_pressed"]
[connection signal="pressed" from="Menu buttons/Quit" to="." method="_on_quit_pressed"]
9 changes: 9 additions & 0 deletions #Scenes/SceneScripts/MainMenu.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
extends Control
## Control the flow from the main menu

#on opening the main menu we grab the focus of the start button
func _ready() -> void:
$"Menu buttons/Continue".grab_focus()
$"game version".text = ProjectSettings.get_setting("application/config/version")
for child in get_node("Menu buttons").get_children():
child.mouse_entered.connect(_on_button_hovered.bind(child))

## What happens when the start button is pressed
func _on_start_pressed() -> void:
if not PlayerManager.is_player_initial_position_set:
Expand All @@ -9,6 +16,8 @@ func _on_start_pressed() -> void:
# TODO : load the last scene the player was in
pass

func _on_button_hovered(button: TextureButton) -> void:
button.grab_focus()

## Scene to be loaded when option button is pressed
func _on_options_pressed() -> void:
Expand Down
3 changes: 3 additions & 0 deletions #Scenes/credits.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://cx0koj0qbu3k3"]

[node name="Credits" type="Node2D"]
Binary file added Art/Menus/Button_focused/continue-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/Menus/Button_focused/continue-1.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://drawyashi8bx0"
path="res://.godot/imported/continue-1.png-c833be4878ca4c7d8fcf5fc498f79d68.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Menus/Button_focused/continue-1.png"
dest_files=["res://.godot/imported/continue-1.png-c833be4878ca4c7d8fcf5fc498f79d68.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added Art/Menus/Button_focused/credits-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/Menus/Button_focused/credits-1.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cg7x1jklsh8pn"
path="res://.godot/imported/credits-1.png-c7e75e74f80fd1debeefa3578d715b42.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Menus/Button_focused/credits-1.png"
dest_files=["res://.godot/imported/credits-1.png-c7e75e74f80fd1debeefa3578d715b42.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added Art/Menus/Button_focused/new_game-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/Menus/Button_focused/new_game-1.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dqwvbpqsi6i5t"
path="res://.godot/imported/new_game-1.png-fbea821d6557267752a1f79e5be4ea16.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Menus/Button_focused/new_game-1.png"
dest_files=["res://.godot/imported/new_game-1.png-fbea821d6557267752a1f79e5be4ea16.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added Art/Menus/Button_focused/options-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/Menus/Button_focused/options-1.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dp0sfj3tdor8w"
path="res://.godot/imported/options-1.png-d5ad9f0f779cc3336d8053d99993935c.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Menus/Button_focused/options-1.png"
dest_files=["res://.godot/imported/options-1.png-d5ad9f0f779cc3336d8053d99993935c.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added Art/Menus/Button_focused/quit-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/Menus/Button_focused/quit-1.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cxnt3pjokwbjy"
path="res://.godot/imported/quit-1.png-77f3cdba03f1cce74cd5a87c26ad8539.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Menus/Button_focused/quit-1.png"
dest_files=["res://.godot/imported/quit-1.png-77f3cdba03f1cce74cd5a87c26ad8539.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added Art/Menus/Button_normal/continue-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/Menus/Button_normal/continue-0.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://b0qf2xlgmuhxo"
path="res://.godot/imported/continue-0.png-aadf7a062c05e71c423b3f1433a9eee9.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Menus/Button_normal/continue-0.png"
dest_files=["res://.godot/imported/continue-0.png-aadf7a062c05e71c423b3f1433a9eee9.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added Art/Menus/Button_normal/credits-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ae7d779

Please sign in to comment.