From cef940108fe15752c3ef66f43f5169403fa2f71d Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sat, 3 Jun 2023 14:37:10 -0400 Subject: Reorganize the file structure of the files in `game/src` --- game/src/Game/Menu/MainMenu/MainMenu.gd | 50 ++++++++ game/src/Game/Menu/MainMenu/MainMenu.tscn | 150 ++++++++++++++++++++++++ game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd | 41 +++++++ game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn | 38 ++++++ 4 files changed, 279 insertions(+) create mode 100644 game/src/Game/Menu/MainMenu/MainMenu.gd create mode 100644 game/src/Game/Menu/MainMenu/MainMenu.tscn create mode 100644 game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd create mode 100644 game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn (limited to 'game/src/Game/Menu/MainMenu') diff --git a/game/src/Game/Menu/MainMenu/MainMenu.gd b/game/src/Game/Menu/MainMenu/MainMenu.gd new file mode 100644 index 0000000..9d0edc6 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/MainMenu.gd @@ -0,0 +1,50 @@ +extends Control + +signal options_button_pressed +signal new_game_button_pressed +signal credits_button_pressed + +@export +var _new_game_button : BaseButton + +# REQUIREMENTS: +# * SS-3 +func _ready(): + _on_new_game_button_visibility_changed() + +# REQUIREMENTS: +# * SS-14 +# * UIFUN-32 +func _on_new_game_button_pressed(): + print("Start a new game!") + new_game_button_pressed.emit() + + +func _on_continue_button_pressed(): + print("Continue last game!") + + +func _on_multi_player_button_pressed(): + print("Have fun with friends!") + + +func _on_options_button_pressed(): + print("Check out some options!") + options_button_pressed.emit() + +# REQUIREMENTS +# * UI-32 +# * UIFUN-36 +func _on_credits_button_pressed(): + credits_button_pressed.emit() + +# REQUIREMENTS +# * SS-4 +# * UIFUN-3 +func _on_exit_button_pressed(): + print("See you later!") + get_tree().quit() + +func _on_new_game_button_visibility_changed(): + if visible: + _new_game_button.grab_focus.call_deferred() diff --git a/game/src/Game/Menu/MainMenu/MainMenu.tscn b/game/src/Game/Menu/MainMenu/MainMenu.tscn new file mode 100644 index 0000000..0618fe8 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/MainMenu.tscn @@ -0,0 +1,150 @@ +[gd_scene load_steps=6 format=3 uid="uid://bp5n3mlu45ygw"] + +[ext_resource type="Theme" uid="uid://qoi3oec48jp0" path="res://theme/main_menu.tres" id="1_1yri4"] +[ext_resource type="Script" path="res://src/MainMenu/MainMenu.gd" id="2_nm1fq"] +[ext_resource type="Texture2D" uid="uid://dxys0wg0f0ic5" path="res://theme/assets/OpenVicFINALREALTRANS.png" id="3_58ess"] +[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="3_amonp"] +[ext_resource type="PackedScene" uid="uid://cen7wkmn6og66" path="res://src/MainMenu/ReleaseInfoBox.tscn" id="3_km0er"] + +[node name="MainMenu" type="Control" node_paths=PackedStringArray("_new_game_button")] +editor_description = "UI-13" +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_1yri4") +script = ExtResource("2_nm1fq") +_new_game_button = NodePath("MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton") + +[node name="MenuPanel" type="PanelContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_type_variation = &"BackgroundPanel" + +[node name="MenuList" type="VBoxContainer" parent="MenuPanel"] +layout_mode = 2 + +[node name="TitleIcon" type="TextureRect" parent="MenuPanel/MenuList"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 1.75 +texture = ExtResource("3_58ess") +expand_mode = 1 +stretch_mode = 5 + +[node name="ButtonListMargin" type="MarginContainer" parent="MenuPanel/MenuList"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_right = 12 + +[node name="ButtonList" type="HBoxContainer" parent="MenuPanel/MenuList/ButtonListMargin"] +custom_minimum_size = Vector2(500, 0) +layout_mode = 2 +theme_type_variation = &"HBox_MainMenu_ButtonList" +theme_override_constants/separation = 18 +alignment = 1 + +[node name="NewGameButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-26" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../ExitButton") +focus_neighbor_top = NodePath("../ExitButton") +focus_neighbor_right = NodePath("../ContinueButton") +focus_next = NodePath("../ContinueButton") +focus_previous = NodePath("../ExitButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_NEW_GAME" +clip_text = true + +[node name="ContinueButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../NewGameButton") +focus_neighbor_right = NodePath("../MultiplayerButton") +focus_next = NodePath("../MultiplayerButton") +focus_previous = NodePath("../NewGameButton") +theme_type_variation = &"TitleButton" +disabled = true +text = "MAINMENU_CONTINUE" +clip_text = true + +[node name="MultiplayerButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-27" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../ContinueButton") +focus_neighbor_right = NodePath("../OptionsButton") +focus_next = NodePath("../OptionsButton") +focus_previous = NodePath("../ContinueButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_MULTIPLAYER" +clip_text = true + +[node name="OptionsButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-5" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../MultiplayerButton") +focus_neighbor_right = NodePath("../CreditsButton") +focus_next = NodePath("../CreditsButton") +focus_previous = NodePath("../MultiplayerButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_OPTIONS" +clip_text = true + +[node name="CreditsButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-32" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../OptionsButton") +focus_neighbor_right = NodePath("../ExitButton") +focus_next = NodePath("../ExitButton") +focus_previous = NodePath("../OptionsButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_CREDITS" +clip_text = true + +[node name="ExitButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-3" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../OptionsButton") +focus_neighbor_right = NodePath("../NewGameButton") +focus_next = NodePath("../NewGameButton") +focus_previous = NodePath("../OptionsButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_EXIT" +clip_text = true + +[node name="BottomSpace" type="Control" parent="MenuPanel/MenuList"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.35 + +[node name="BottomMargin" type="MarginContainer" parent="MenuPanel/MenuList"] +layout_mode = 2 +theme_type_variation = &"BottomMargin" + +[node name="ReleaseInfoBox" parent="MenuPanel/MenuList/BottomMargin" instance=ExtResource("3_km0er")] +layout_mode = 2 + +[node name="LocaleButton" parent="MenuPanel/MenuList/BottomMargin" instance=ExtResource("3_amonp")] +layout_mode = 2 +size_flags_horizontal = 8 +alignment = 0 +text_overrun_behavior = 4 + +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton" to="." method="_on_new_game_button_pressed"] +[connection signal="visibility_changed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton" to="." method="_on_new_game_button_visibility_changed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/ContinueButton" to="." method="_on_continue_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/MultiplayerButton" to="." method="_on_multi_player_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/CreditsButton" to="." method="_on_credits_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/ExitButton" to="." method="_on_exit_button_pressed"] diff --git a/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd new file mode 100644 index 0000000..e363162 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd @@ -0,0 +1,41 @@ +extends HBoxContainer + +@export +var _version_label : Button + +@export +var _commit_label : Button + +@export +var _checksum_label : Button + +var _checksum : String = "????" + +# REQUIREMENTS: +# * UIFUN-97 +func _ready(): + _version_label.text = _GIT_INFO_.release_name + _version_label.tooltip_text = _GIT_INFO_.tag + _commit_label.text = _GIT_INFO_.short_hash + _commit_label.tooltip_text = _GIT_INFO_.commit_hash + # UI-111 + _checksum = Checksum.get_checksum_text() + _update_checksum_label_text() + +func _notification(what : int): + match what: + NOTIFICATION_TRANSLATION_CHANGED: + _update_checksum_label_text() + +func _update_checksum_label_text() -> void: + _checksum_label.tooltip_text = tr("MAINMENU_CHECKSUM").format({ "checksum": _checksum }) + _checksum_label.text = "(%s)" % _checksum.substr(0, 4) + +func _on_version_label_pressed(): + DisplayServer.clipboard_set(_GIT_INFO_.tag) + +func _on_commit_label_pressed(): + DisplayServer.clipboard_set(_GIT_INFO_.commit_hash) + +func _on_checksum_label_pressed(): + DisplayServer.clipboard_set(_checksum) diff --git a/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn new file mode 100644 index 0000000..821982b --- /dev/null +++ b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=2 format=3 uid="uid://cen7wkmn6og66"] + +[ext_resource type="Script" path="res://src/MainMenu/ReleaseInfoBox.gd" id="1_y2djw"] + +[node name="ReleaseInfoBox" type="HBoxContainer" node_paths=PackedStringArray("_version_label", "_commit_label", "_checksum_label")] +editor_description = "UI-31" +script = ExtResource("1_y2djw") +_version_label = NodePath("VersionLabel") +_commit_label = NodePath("CommitLabel") +_checksum_label = NodePath("ChecksumLabel") + +[node name="VersionLabel" type="Button" parent="."] +layout_mode = 2 +tooltip_text = "VERSION_MISSING" +theme_type_variation = &"VersionLabel" +text = "VERSION_MISSING" +flat = true +alignment = 0 + +[node name="CommitLabel" type="Button" parent="."] +layout_mode = 2 +theme_type_variation = &"CommitLabel" +text = "????????" +flat = true +alignment = 0 + +[node name="ChecksumLabel" type="Button" parent="."] +editor_description = "UI-111" +layout_mode = 2 +tooltip_text = "CHECKSUM_MISSING" +theme_type_variation = &"ChecksumLabel" +text = "(????)" +flat = true +alignment = 0 + +[connection signal="pressed" from="VersionLabel" to="." method="_on_version_label_pressed"] +[connection signal="pressed" from="CommitLabel" to="." method="_on_commit_label_pressed"] +[connection signal="pressed" from="ChecksumLabel" to="." method="_on_checksum_label_pressed"] -- cgit v1.2.3-56-ga3b1