diff --git a/.gitignore b/.gitignore index 82d24424..33814229 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .import/ +.godot/ .idea/ .DS_Store exports/ diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index b5384962..d51de1b0 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -1,19 +1,10 @@ # Attribution ## Collaborators -### Role -Person 1 -Person 2 -[Person w/ Link]() - - -## Sourced / Unaffiliated -### Asset Type -#### Use Case -Author: [Name]() -Source: [Domain : webpage.html]() -License: [License]() - +### Godot Game Template +Author: [Marek](https://github.com/Maaack) +Source: [github: Godot-Game-Template](https://github.com/Maaack/Godot-Game-Template) +License: [MIT License](LICENSE.txt) ## Tools #### Godot diff --git a/ATTRIBUTION_example.md b/ATTRIBUTION_example.md new file mode 100644 index 00000000..b5384962 --- /dev/null +++ b/ATTRIBUTION_example.md @@ -0,0 +1,27 @@ +# Attribution +## Collaborators + +### Role +Person 1 +Person 2 +[Person w/ Link]() + + +## Sourced / Unaffiliated +### Asset Type +#### Use Case +Author: [Name]() +Source: [Domain : webpage.html]() +License: [License]() + + +## Tools +#### Godot +Author: [Juan Linietsky, Ariel Manzur, and contributors](https://godotengine.org/contact) +Source: [godotengine.org](https://godotengine.org/) +License: [MIT License](https://github.com/godotengine/godot/blob/master/LICENSE.txt) + +#### Git +Author: [Linus Torvalds](https://github.com/torvalds) +Source: [git-scm.com](https://git-scm.com/downloads) +License: [GNU General Public License version 2](https://opensource.org/licenses/GPL-2.0) \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..4cca2b65 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (c) 2022-present Marek Belski. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index e8b06054..8f6fbb60 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ -# Project Name -Made in Godot 3.5.0 +# Godot Game Template +For Godot 4.1.2 + +This template has a dynamic main menu, pause menu, and credits scene. Multiple options menus to choose from with key rebinding and persistent config settings. + +## Links +[Attribution](ATTRIBUTION.md) +[License](LICENSE.txt) \ No newline at end of file diff --git a/Scenes/Credits/Credits.gd b/Scenes/Credits/Credits.gd index 9d9cc1b2..f5e21599 100644 --- a/Scenes/Credits/Credits.gd +++ b/Scenes/Credits/Credits.gd @@ -1,29 +1,26 @@ +@tool extends Control - signal end_reached -onready var scroll_container = $ScrollContainer -onready var rich_text_label = $ScrollContainer/VBoxContainer/RichTextLabel +@onready var scroll_container = $ScrollContainer +@onready var rich_text_label = $ScrollContainer/VBoxContainer/RichTextLabel -export(String) var attribution_file_path : String = "res://ATTRIBUTION.md" setget set_file_path -export(DynamicFont) var h1_font -export(DynamicFont) var h2_font -export(DynamicFont) var h3_font -export(DynamicFont) var h4_font -export(float) var current_speed : float = 1.0 -export var scroll_active : bool = true +@export_file("*.md") var attribution_file_path: String = "res://ATTRIBUTION.md": set = set_file_path +@export var h1_font_size: int +@export var h2_font_size: int +@export var h3_font_size: int +@export var h4_font_size: int +@export var current_speed: float = 1.0 +@export var scroll_active : bool = true var scroll_paused : bool = false func load_file(file_path): - var file : File = File.new() - var open_error : int = file.open(file_path, File.READ) - if open_error: - print("load file failed with error %d" % open_error) - var text : String = file.get_as_text() - file.close() - return text + var file_string = FileAccess.get_file_as_string(file_path) + if file_string == null: + print("File open error: %s" % FileAccess.get_open_error()) + return file_string func regex_replace_urls(credits:String): var regex = RegEx.new() @@ -34,30 +31,30 @@ func regex_replace_urls(credits:String): func regex_replace_titles(credits:String): var iter = 0 - var heading_fonts : Array = [h1_font, h2_font, h3_font, h4_font] - for heading_font in heading_fonts: - if heading_font is DynamicFont: - iter += 1 - var regex = RegEx.new() - var match_string : String = "([^#])#{%d}\\s([^\n]*)" % iter - var replace_string : String = "$1[font=%s]$2[/font]" % [heading_font.resource_path] - regex.compile(match_string) - credits = regex.sub(credits, replace_string, true) + var heading_font_sizes : Array[int] = [h1_font_size, h2_font_size, h3_font_size, h4_font_size] + for heading_font_size in heading_font_sizes: + iter += 1 + var regex = RegEx.new() + var match_string : String = "([^#])#{%d}\\s([^\n]*)" % iter + var replace_string : String = "$1[font_size=%d]$2[/font_size]" % [heading_font_size] + regex.compile(match_string) + credits = regex.sub(credits, replace_string, true) return credits -func set_file_path(value:String): - var text : String = load_file(value) +func set_file_path(file_path:String): + attribution_file_path = file_path + var text : String = load_file(attribution_file_path) if text == "": return - text = text.right(text.find("\n")) # Trims first line "ATTRIBUTION" + text = text.right(-text.find("\n")) # Trims first line "ATTRIBUTION" text = regex_replace_urls(text) text = regex_replace_titles(text) - $ScrollContainer/VBoxContainer/RichTextLabel.bbcode_text = "[center]%s[/center]" % [text] + $ScrollContainer/VBoxContainer/RichTextLabel.text = "[center]%s[/center]" % [text] func set_header_and_footer(): - $ScrollContainer/VBoxContainer/HeaderSpace.rect_min_size.y = rect_size.y - $ScrollContainer/VBoxContainer/FooterSpace.rect_min_size.y = rect_size.y - $ScrollContainer/VBoxContainer/RichTextLabel.rect_min_size.x = rect_size.x + $ScrollContainer/VBoxContainer/HeaderSpace.custom_minimum_size.y = size.y + $ScrollContainer/VBoxContainer/FooterSpace.custom_minimum_size.y = size.y + $ScrollContainer/VBoxContainer/RichTextLabel.custom_minimum_size.x = size.x func reset(): $ScrollContainer.scroll_vertical = 0 @@ -68,24 +65,30 @@ func _ready(): set_file_path(attribution_file_path) set_header_and_footer() -func end_reached(): +func _end_reached(): scroll_active = false emit_signal("end_reached") func _check_end_reached(previous_scroll): if previous_scroll != $ScrollContainer.scroll_vertical: return - end_reached() + _end_reached() -func _scroll_container() -> void: - if not scroll_active or scroll_paused or round(current_speed) == 0: +func _scroll_container(amount : float) -> void: + if not scroll_active or scroll_paused or round(amount) == 0: return var previous_scroll = $ScrollContainer.scroll_vertical - $ScrollContainer.scroll_vertical += round(current_speed) + $ScrollContainer.scroll_vertical += round(amount) _check_end_reached(previous_scroll) func _process(_delta): - _scroll_container() + if Engine.is_editor_hint(): + return + var input_axis = Input.get_axis("move_up", "move_down") + if input_axis != 0: + _scroll_container(10 * input_axis) + else: + _scroll_container(current_speed) func _on_RichTextLabel_gui_input(event): if event is InputEventMouseButton: @@ -94,7 +97,7 @@ func _on_RichTextLabel_gui_input(event): func _start_scroll_timer(): var timer = get_tree().create_timer(1.5) - yield(timer, "timeout") + await timer.timeout set_header_and_footer() scroll_paused = false diff --git a/Scenes/Credits/Credits.tscn b/Scenes/Credits/Credits.tscn index 047a2d00..7e21571e 100644 --- a/Scenes/Credits/Credits.tscn +++ b/Scenes/Credits/Credits.tscn @@ -1,47 +1,67 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=2 format=3 uid="uid://t2dui8ppm3a4"] -[ext_resource path="res://Scenes/Credits/Credits.gd" type="Script" id=4] -[ext_resource path="res://Scenes/Credits/HiddenScrollBar.tres" type="Theme" id=6] +[ext_resource type="Script" path="res://Scenes/Credits/Credits.gd" id="4"] [node name="Credits" type="Control"] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -script = ExtResource( 4 ) +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("4") +h1_font_size = 64 +h2_font_size = 48 +h3_font_size = 32 +h4_font_size = 24 +scroll_active = false [node name="ScrollContainer" type="ScrollContainer" parent="."] +layout_mode = 0 anchor_right = 1.0 anchor_bottom = 1.0 -theme = ExtResource( 6 ) -scroll_horizontal_enabled = false +scroll_vertical = 100 +horizontal_scroll_mode = 0 +vertical_scroll_mode = 3 [node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] -margin_right = 1024.0 -margin_bottom = 2071.0 +layout_mode = 2 size_flags_horizontal = 3 [node name="HeaderSpace" type="Control" parent="ScrollContainer/VBoxContainer"] -margin_right = 1024.0 -margin_bottom = 1024.0 -rect_min_size = Vector2( 0, 1024 ) +custom_minimum_size = Vector2(0, 648) +layout_mode = 2 [node name="RichTextLabel" type="RichTextLabel" parent="ScrollContainer/VBoxContainer"] -margin_top = 1028.0 -margin_right = 1024.0 -margin_bottom = 1043.0 -rect_min_size = Vector2( 1024, 0 ) -focus_mode = 2 +custom_minimum_size = Vector2(1152, 0) +layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 5 bbcode_enabled = true -fit_content_height = true +text = "[center] +[font_size=48]Collaborators[/font_size] + +[font_size=32]Godot Game Template[/font_size] +Author: [url=https://github.com/Maaack]Marek[/url] +Source: [url=https://github.com/Maaack/Godot-Game-Template]github: Godot-Game-Template[/url] +License: [url=LICENSE.txt]MIT License[/url] + +[font_size=48]Tools[/font_size] +[font_size=24]Godot[/font_size] +Author: [url=https://godotengine.org/contact]Juan Linietsky, Ariel Manzur, and contributors[/url] +Source: [url=https://godotengine.org/]godotengine.org[/url] +License: [url=https://github.com/godotengine/godot/blob/master/LICENSE.txt]MIT License[/url] + +[font_size=24]Git[/font_size] +Author: [url=https://github.com/torvalds]Linus Torvalds[/url] +Source: [url=https://git-scm.com/downloads]git-scm.com[/url] +License: [url=https://opensource.org/licenses/GPL-2.0]GNU General Public License version 2[/url][/center]" +fit_content = true scroll_active = false -selection_enabled = true [node name="FooterSpace" type="Control" parent="ScrollContainer/VBoxContainer"] -margin_top = 1047.0 -margin_right = 1024.0 -margin_bottom = 2071.0 -rect_min_size = Vector2( 0, 1024 ) +custom_minimum_size = Vector2(0, 648) +layout_mode = 2 [node name="ScrollResetTimer" type="Timer" parent="."] wait_time = 1.5 diff --git a/Scenes/Credits/EndCredits.gd b/Scenes/Credits/EndCredits.gd index 6391ed13..e74a31ef 100644 --- a/Scenes/Credits/EndCredits.gd +++ b/Scenes/Credits/EndCredits.gd @@ -7,7 +7,7 @@ func end_reached(): node.show() func _on_MenuButton_pressed(): - get_tree().change_scene("res://Scenes/MainMenu/MainMenu.tscn") + get_tree().change_scene_to_file("res://Scenes/MainMenu/MainMenu.tscn") func _on_ExitButton_pressed(): diff --git a/Scenes/Credits/EndCredits.tscn b/Scenes/Credits/EndCredits.tscn index 7d57d22f..6a7c3a71 100644 --- a/Scenes/Credits/EndCredits.tscn +++ b/Scenes/Credits/EndCredits.tscn @@ -1,74 +1,61 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=4 format=3 uid="uid://djoy112dkgjda"] -[ext_resource path="res://Scenes/Credits/Credits.tscn" type="PackedScene" id=1] -[ext_resource path="res://Themes/MainMenuTheme.tres" type="Theme" id=2] -[ext_resource path="res://Scenes/Credits/EndCredits.gd" type="Script" id=4] +[ext_resource type="PackedScene" uid="uid://t2dui8ppm3a4" path="res://Scenes/Credits/Credits.tscn" id="1"] +[ext_resource type="Theme" path="res://Themes/MainMenuTheme.tres" id="2"] +[ext_resource type="Script" path="res://Scenes/Credits/EndCredits.gd" id="4"] -[node name="EndCredits" instance=ExtResource( 1 )] -theme = ExtResource( 2 ) -script = ExtResource( 4 ) - -[node name="RichTextLabel" parent="ScrollContainer/VBoxContainer" index="1"] -focus_mode = 0 +[node name="EndCredits" instance=ExtResource("1")] +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("2") +script = ExtResource("4") [node name="CenterContainer" type="CenterContainer" parent="." index="1"] +layout_mode = 0 anchor_right = 1.0 anchor_bottom = 1.0 -mouse_filter = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +mouse_filter = 2 [node name="EndMessagePanel" type="Panel" parent="CenterContainer" index="0"] unique_name_in_owner = true visible = false -margin_left = 332.0 -margin_top = 240.0 -margin_right = 692.0 -margin_bottom = 360.0 -rect_min_size = Vector2( 360, 120 ) +custom_minimum_size = Vector2(360, 120) +layout_mode = 2 [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/EndMessagePanel" index="0"] +layout_mode = 0 anchor_right = 1.0 anchor_bottom = 1.0 [node name="ThankPlayer" type="Label" parent="CenterContainer/EndMessagePanel/VBoxContainer" index="0"] -margin_right = 360.0 -margin_bottom = 58.0 +layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 text = "Thanks for playing" -align = 1 -valign = 1 [node name="CenterContainer" type="CenterContainer" parent="CenterContainer/EndMessagePanel/VBoxContainer" index="1"] -margin_top = 62.0 -margin_right = 360.0 -margin_bottom = 120.0 +layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 [node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer" index="0"] -margin_left = 108.0 -margin_top = 19.0 -margin_right = 252.0 -margin_bottom = 39.0 +layout_mode = 2 size_flags_vertical = 3 -custom_constants/separation = 24 +theme_override_constants/separation = 24 [node name="MenuButton" type="Button" parent="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer/HBoxContainer" index="0"] -margin_right = 60.0 -margin_bottom = 28.0 -rect_min_size = Vector2( 60, 0 ) +custom_minimum_size = Vector2(60, 0) +layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 text = "Menu" [node name="ExitButton" type="Button" parent="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer/HBoxContainer" index="1"] unique_name_in_owner = true -margin_left = 84.0 -margin_right = 144.0 -margin_bottom = 28.0 -rect_min_size = Vector2( 60, 0 ) +custom_minimum_size = Vector2(60, 0) +layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 text = "Exit" diff --git a/Scenes/ExampleGameScene/ExampleGameUI.gd b/Scenes/ExampleGameScene/ExampleGameUI.gd new file mode 100644 index 00000000..03588f2b --- /dev/null +++ b/Scenes/ExampleGameScene/ExampleGameUI.gd @@ -0,0 +1,5 @@ +extends Control + +func _gui_input(event): + if event is InputEventMouseButton and Input.mouse_mode != Input.MOUSE_MODE_CAPTURED: + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) diff --git a/Scenes/ExampleGameScene/ExampleGameUI.tscn b/Scenes/ExampleGameScene/ExampleGameUI.tscn new file mode 100644 index 00000000..e1343c1c --- /dev/null +++ b/Scenes/ExampleGameScene/ExampleGameUI.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=3 uid="uid://dxkq10mmjl517"] + +[ext_resource type="Script" path="res://Scenes/ExampleGameScene/ExampleGameUI.gd" id="1_1a5jn"] +[ext_resource type="Script" path="res://Scripts/PauseMenuController.gd" id="2_ub818"] +[ext_resource type="PackedScene" uid="uid://cdwvtbtwmrqbn" path="res://Scenes/PauseMenu/PauseMenu.tscn" id="3_peepb"] + +[node name="ExampleGameUI" 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_1a5jn") + +[node name="PauseMenuController" type="Node" parent="."] +script = ExtResource("2_ub818") +pause_menu_packed = ExtResource("3_peepb") diff --git a/Scenes/InitApp/InitApp.gd b/Scenes/InitApp/InitApp.gd index 456b63cc..d31c8b66 100644 --- a/Scenes/InitApp/InitApp.gd +++ b/Scenes/InitApp/InitApp.gd @@ -1,7 +1,7 @@ extends Node -export(String, FILE, "*.tscn") var next_scene : String +@export var next_scene : String # (String, FILE, "*.tscn") func _ready(): - AppSettings.initialize_from_config() + AppSettings.initialize_from_config(get_window()) SceneLoader.load_scene(next_scene) diff --git a/Scenes/InitApp/InitApp.tscn b/Scenes/InitApp/InitApp.tscn index 079a2339..d64f03c0 100644 --- a/Scenes/InitApp/InitApp.tscn +++ b/Scenes/InitApp/InitApp.tscn @@ -1,7 +1,7 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://brp0f5m041sho"] -[ext_resource path="res://Scenes/InitApp/InitApp.gd" type="Script" id=1] +[ext_resource type="Script" path="res://Scenes/InitApp/InitApp.gd" id="1"] [node name="InitApp" type="Node"] -script = ExtResource( 1 ) +script = ExtResource("1") next_scene = "res://Scenes/MainMenu/MainMenu.tscn" diff --git a/Scenes/LoadingScreen/LoadingScreen.gd b/Scenes/LoadingScreen/LoadingScreen.gd index 0bfc347d..8b929680 100644 --- a/Scenes/LoadingScreen/LoadingScreen.gd +++ b/Scenes/LoadingScreen/LoadingScreen.gd @@ -3,29 +3,30 @@ extends CanvasLayer const LOADING_COMPLETE_TEXT = "Loading Complete!" func set_new_scene(scene_resource : Resource): - var scene_instance : Node = scene_resource.instance() - var _err = scene_instance.connect("ready", self, "queue_free") + var scene_instance : Node = scene_resource.instantiate() + var _err = scene_instance.connect("ready", Callable(self, "queue_free")) get_node("/root").add_child(scene_instance) get_tree().current_scene = scene_instance func _process(_delta): - var err = SceneLoader.loader.poll() - if err == OK: - $Control/VBoxContainer/ProgressBar.value = SceneLoader.loader.get_stage() * 100 / SceneLoader.loader.get_stage_count() - elif err == ERR_FILE_EOF: - $Control/VBoxContainer/ProgressBar.value = 100 - $Control/VBoxContainer/Title.text = LOADING_COMPLETE_TEXT - set_process(false) - yield(get_tree().create_timer(0.1), "timeout") - var resource = SceneLoader.loader.get_resource() - set_new_scene(resource) - else: - $Control/ErrorMsg.dialog_text = "Loading Error: %d" % err - $Control/ErrorMsg.popup_centered() - set_process(false) + var status = SceneLoader.get_status() + match(status): + ResourceLoader.THREAD_LOAD_IN_PROGRESS: + $Control/VBoxContainer/ProgressBar.value = SceneLoader.get_progress() + ResourceLoader.THREAD_LOAD_LOADED: + $Control/VBoxContainer/ProgressBar.value = 1.0 + $Control/VBoxContainer/Title.text = LOADING_COMPLETE_TEXT + set_process(false) + await get_tree().create_timer(0.1).timeout + var resource = SceneLoader.get_resource() + set_new_scene(resource) + ResourceLoader.THREAD_LOAD_FAILED, ResourceLoader.THREAD_LOAD_INVALID_RESOURCE: + $Control/ErrorMsg.dialog_text = "Loading Error: %d" % status + $Control/ErrorMsg.popup_centered() + set_process(false) -func _on_ErrorMsg_confirmed(): - var err = get_tree().change_scene(ProjectSettings.get_setting("application/run/main_scene")) +func _on_error_msg_confirmed(): + var err = get_tree().change_scene_to_file(ProjectSettings.get_setting("application/run/main_scene")) if err: print("failed to load main scene: %d" % err) get_tree().quit() diff --git a/Scenes/LoadingScreen/LoadingScreen.tscn b/Scenes/LoadingScreen/LoadingScreen.tscn index 4ef5e3ef..cc2d2a89 100644 --- a/Scenes/LoadingScreen/LoadingScreen.tscn +++ b/Scenes/LoadingScreen/LoadingScreen.tscn @@ -1,47 +1,47 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=3 format=3 uid="uid://cd0jbh4metflb"] -[ext_resource path="res://Themes/MainMenuTheme.tres" type="Theme" id=1] -[ext_resource path="res://Scenes/LoadingScreen/LoadingScreen.gd" type="Script" id=3] +[ext_resource type="Theme" path="res://Themes/BaseTheme.tres" id="2_24ab6"] +[ext_resource type="Script" path="res://Scenes/LoadingScreen/LoadingScreen.gd" id="3"] [node name="LoadingScreen" type="CanvasLayer"] layer = 20 -script = ExtResource( 3 ) +script = ExtResource("3") [node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -theme = ExtResource( 1 ) +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("2_24ab6") [node name="Panel" type="Panel" parent="Control"] +layout_mode = 0 anchor_right = 1.0 anchor_bottom = 1.0 [node name="VBoxContainer" type="VBoxContainer" parent="Control"] +layout_mode = 0 anchor_top = 0.5 anchor_right = 1.0 anchor_bottom = 0.5 -margin_left = 30.0 -margin_top = -23.0 -margin_right = -30.0 -margin_bottom = 98.0 -custom_constants/separation = 50 +offset_left = 30.0 +offset_top = -23.0 +offset_right = -30.0 +offset_bottom = 98.0 +theme_override_constants/separation = 50 [node name="Title" type="Label" parent="Control/VBoxContainer"] -margin_right = 964.0 -margin_bottom = 21.0 +layout_mode = 2 text = "Loading" -align = 1 +horizontal_alignment = 1 [node name="ProgressBar" type="ProgressBar" parent="Control/VBoxContainer"] -margin_top = 71.0 -margin_right = 964.0 -margin_bottom = 121.0 -rect_min_size = Vector2( 0, 50 ) +custom_minimum_size = Vector2(0, 50) +layout_mode = 2 +max_value = 1.0 [node name="ErrorMsg" type="AcceptDialog" parent="Control"] -margin_right = 136.0 -margin_bottom = 72.0 -popup_exclusive = true -window_title = "Alerte !" -[connection signal="confirmed" from="Control/ErrorMsg" to="Control" method="_on_ErrorMsg_confirmed"] +[connection signal="confirmed" from="Control/ErrorMsg" to="." method="_on_error_msg_confirmed"] diff --git a/Scenes/MainMenu/MainMenu.gd b/Scenes/MainMenu/MainMenu.gd index e8f79254..2dbc0034 100644 --- a/Scenes/MainMenu/MainMenu.gd +++ b/Scenes/MainMenu/MainMenu.gd @@ -1,10 +1,14 @@ extends Control -export(String, FILE, "*.tscn") var game_scene : String -export(String) var version_name = '0.0.0' +@export_file("*.tscn") var game_scene_path : String +@export var options_packed_scene : PackedScene +@export var credits_packed_scene : PackedScene +@export var version_name: String = '0.0.0' var animation_state_machine : AnimationNodeStateMachinePlayback +var options_scene +var credits_scene var sub_menu func load_scene(scene_path : String): @@ -12,7 +16,7 @@ func load_scene(scene_path : String): func play_game(): GameLog.game_started() - SceneLoader.load_scene(game_scene) + SceneLoader.load_scene(game_scene_path) func _open_sub_menu(menu : Control): menu.visible = true @@ -27,27 +31,8 @@ func _close_sub_menu(): sub_menu = null animation_state_machine.travel("MainMenuOpen") -func _on_PlayButton_pressed(): - play_game() - -func _on_TutorialButton_pressed(): - pass - -func _on_OptionsButton_pressed(): - _open_sub_menu($MasterOptionsMenu) - -func _on_CreditsButton_pressed(): - _open_sub_menu($CreditsContainer/Credits) - $CreditsContainer/Credits.reset() - -func _on_ExitButton_pressed(): - get_tree().quit() - -func _on_BackButton_pressed(): - _close_sub_menu() - func intro_done(): - $MenuAnimationTree.set("parameters/conditions/intro_done", true) + animation_state_machine.travel("MainMenuOpen") func _input(event): if animation_state_machine.get_current_node() == "Intro" and \ @@ -56,16 +41,57 @@ func _input(event): func _setup_for_web(): if OS.has_feature("web"): - $MenuContainer/MainMenuButtons/ButtonsContainer/ExitButton.hide() + %ExitButton.hide() func _setup_version_name(): AppLog.version_opened(version_name) $"%VersionNameLabel".text = "v%s" % version_name +func _setup_play(): + if game_scene_path.is_empty(): + %PlayButton.hide() + +func _setup_options(): + if options_packed_scene == null: + %OptionsButton.hide() + else: + options_scene = options_packed_scene.instantiate() + options_scene.hide() + %OptionsContainer.call_deferred("add_child", options_scene) + +func _setup_credits(): + if credits_packed_scene == null: + %CreditsButton.hide() + else: + credits_scene = credits_packed_scene.instantiate() + credits_scene.hide() + if credits_scene.has_signal("end_reached"): + credits_scene.connect("end_reached", _on_credits_end_reached) + %CreditsContainer.call_deferred("add_child", credits_scene) + func _ready(): _setup_for_web() _setup_version_name() + _setup_options() + _setup_credits() + _setup_play() animation_state_machine = $MenuAnimationTree.get("parameters/playback") -func _on_Credits_end_reached(): +func _on_play_button_pressed(): + play_game() + +func _on_options_button_pressed(): + _open_sub_menu(options_scene) + +func _on_credits_button_pressed(): + _open_sub_menu(credits_scene) + credits_scene.reset() + +func _on_exit_button_pressed(): + get_tree().quit() + +func _on_credits_end_reached(): + _close_sub_menu() + +func _on_back_button_pressed(): _close_sub_menu() diff --git a/Scenes/MainMenu/MainMenu.tscn b/Scenes/MainMenu/MainMenu.tscn index c5ce4dfa..7d4c3b0d 100644 --- a/Scenes/MainMenu/MainMenu.tscn +++ b/Scenes/MainMenu/MainMenu.tscn @@ -1,428 +1,476 @@ -[gd_scene load_steps=23 format=2] +[gd_scene load_steps=23 format=3 uid="uid://c6k5nnpbypshi"] -[ext_resource path="res://Scenes/MainMenu/MainMenu.gd" type="Script" id=1] -[ext_resource path="res://Scenes/MainMenu/MainMenuButtons.tscn" type="PackedScene" id=2] -[ext_resource path="res://Scenes/OptionsMenu/MasterOptionsMenu.tscn" type="PackedScene" id=3] -[ext_resource path="res://Themes/MainMenuTheme.tres" type="Theme" id=4] -[ext_resource path="res://Scenes/UI/SoundButton/SoundButton.tscn" type="PackedScene" id=5] -[ext_resource path="res://Scenes/Credits/Credits.tscn" type="PackedScene" id=8] +[ext_resource type="Script" path="res://Scenes/MainMenu/MainMenu.gd" id="1"] +[ext_resource type="PackedScene" uid="uid://bvwl11s2p0hd" path="res://Scenes/OptionsMenu/MasterOptionsMenu.tscn" id="3"] +[ext_resource type="Theme" path="res://Themes/BaseTheme.tres" id="4"] +[ext_resource type="PackedScene" uid="uid://doj1dmgtf0a71" path="res://Scenes/UI/SoundButton/SoundButton.tscn" id="5"] +[ext_resource type="PackedScene" uid="uid://t2dui8ppm3a4" path="res://Scenes/Credits/Credits.tscn" id="8"] -[sub_resource type="Animation" id=5] +[sub_resource type="Animation" id="5"] resource_name = "CloseSubMenu" length = 0.2 tracks/0/type = "value" -tracks/0/path = NodePath("MenuContainer/MainMenuButtons:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true +tracks/0/path = NodePath("FlowControlContainer/FlowControl/BackButton:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 1, -"values": [ true ] +"values": [false] } tracks/1/type = "value" -tracks/1/path = NodePath("FlowControlContainer/FlowControl/BackButton:visible") -tracks/1/interp = 1 -tracks/1/loop_wrap = true tracks/1/imported = false tracks/1/enabled = true +tracks/1/path = NodePath("MarginContainer/VBoxContainer/MenuMargin/MenuButtons:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 1, -"values": [ false ] +"values": [true] } -[sub_resource type="Animation" id=1] +[sub_resource type="Animation" id="1"] resource_name = "Intro" length = 2.4 tracks/0/type = "method" +tracks/0/imported = false +tracks/0/enabled = true tracks/0/path = NodePath(".") tracks/0/interp = 1 tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 2.4 ), -"transitions": PoolRealArray( 1 ), -"values": [ { -"args": [ ], -"method": "intro_done" -} ] +"times": PackedFloat32Array(2.4), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"intro_done" +}] } tracks/1/type = "value" -tracks/1/path = NodePath("TitleContainer/Titles/TitlesContainer/Title:modulate") -tracks/1/interp = 1 -tracks/1/loop_wrap = true tracks/1/imported = false tracks/1/enabled = true +tracks/1/path = NodePath("MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer/Title:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true tracks/1/keys = { -"times": PoolRealArray( 0, 0.8 ), -"transitions": PoolRealArray( 1, 1 ), +"times": PackedFloat32Array(0, 0.8), +"transitions": PackedFloat32Array(1, 1), "update": 0, -"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] } tracks/2/type = "value" -tracks/2/path = NodePath("TitleContainer/Titles/TitlesContainer/SubTitle:modulate") -tracks/2/interp = 1 -tracks/2/loop_wrap = true tracks/2/imported = false tracks/2/enabled = true +tracks/2/path = NodePath("MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer/SubTitle:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true tracks/2/keys = { -"times": PoolRealArray( 0, 0.8, 1.6 ), -"transitions": PoolRealArray( 1, 1, 1 ), +"times": PackedFloat32Array(0, 0.8, 1.6), +"transitions": PackedFloat32Array(1, 1, 1), "update": 0, -"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 0), Color(1, 1, 1, 1)] } tracks/3/type = "value" -tracks/3/path = NodePath("MenuContainer/MainMenuButtons:modulate") -tracks/3/interp = 1 -tracks/3/loop_wrap = true tracks/3/imported = false tracks/3/enabled = true +tracks/3/path = NodePath("MarginContainer/VBoxContainer/MenuMargin/MenuButtons:visible") +tracks/3/interp = 1 +tracks/3/loop_wrap = true tracks/3/keys = { -"times": PoolRealArray( 0, 1.6, 2.4 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] +"times": PackedFloat32Array(0, 1.6), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [false, true] } tracks/4/type = "value" -tracks/4/path = NodePath("MenuContainer/MainMenuButtons:visible") -tracks/4/interp = 1 -tracks/4/loop_wrap = true tracks/4/imported = false tracks/4/enabled = true +tracks/4/path = NodePath("MarginContainer/VBoxContainer/MenuMargin/MenuButtons:modulate") +tracks/4/interp = 1 +tracks/4/loop_wrap = true tracks/4/keys = { -"times": PoolRealArray( 0, 1.6 ), -"transitions": PoolRealArray( 1, 1 ), -"update": 1, -"values": [ false, true ] +"times": PackedFloat32Array(1.6, 2.4), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] } -[sub_resource type="Animation" id=6] +[sub_resource type="Animation" id="6"] resource_name = "MainMenuOpen" length = 0.1 tracks/0/type = "value" -tracks/0/path = NodePath("TitleContainer/Titles/TitlesContainer/Title:modulate") -tracks/0/interp = 1 -tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true +tracks/0/path = NodePath("MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer/Title:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 0, -"values": [ Color( 1, 1, 1, 1 ) ] +"values": [Color(1, 1, 1, 1)] } tracks/1/type = "value" -tracks/1/path = NodePath("TitleContainer/Titles/TitlesContainer/SubTitle:modulate") -tracks/1/interp = 1 -tracks/1/loop_wrap = true tracks/1/imported = false tracks/1/enabled = true +tracks/1/path = NodePath("MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer/SubTitle:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 0, -"values": [ Color( 1, 1, 1, 1 ) ] +"values": [Color(1, 1, 1, 1)] } tracks/2/type = "value" -tracks/2/path = NodePath("MenuContainer/MainMenuButtons:modulate") -tracks/2/interp = 1 -tracks/2/loop_wrap = true tracks/2/imported = false tracks/2/enabled = true +tracks/2/path = NodePath("MarginContainer/VBoxContainer/MenuMargin/MenuButtons:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true tracks/2/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 1 ) ] +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] } tracks/3/type = "value" -tracks/3/path = NodePath("MenuContainer/MainMenuButtons:visible") -tracks/3/interp = 1 -tracks/3/loop_wrap = true tracks/3/imported = false tracks/3/enabled = true +tracks/3/path = NodePath("MarginContainer/VBoxContainer/MenuMargin/MenuButtons:modulate") +tracks/3/interp = 1 +tracks/3/loop_wrap = true tracks/3/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ true ] +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] } -[sub_resource type="Animation" id=4] +[sub_resource type="Animation" id="4"] resource_name = "OpenSubMenu" length = 0.2 tracks/0/type = "value" -tracks/0/path = NodePath("MenuContainer/MainMenuButtons:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true +tracks/0/path = NodePath("FlowControlContainer/FlowControl/BackButton:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 1, -"values": [ false ] +"values": [true] } tracks/1/type = "value" -tracks/1/path = NodePath("FlowControlContainer/FlowControl/BackButton:visible") -tracks/1/interp = 1 -tracks/1/loop_wrap = true tracks/1/imported = false tracks/1/enabled = true +tracks/1/path = NodePath("MarginContainer/VBoxContainer/MenuMargin/MenuButtons:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 1, -"values": [ true ] +"values": [false] } -[sub_resource type="Animation" id=3] +[sub_resource type="Animation" id="3"] resource_name = "Outro" length = 0.5 -[sub_resource type="Animation" id=2] +[sub_resource type="Animation" id="2"] length = 0.001 tracks/0/type = "value" -tracks/0/path = NodePath("MenuContainer/MainMenuButtons:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true +tracks/0/path = NodePath("FlowControlContainer/FlowControl/BackButton:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 0, -"values": [ true ] +"values": [false] } tracks/1/type = "value" -tracks/1/path = NodePath("FlowControlContainer/FlowControl/BackButton:visible") -tracks/1/interp = 1 -tracks/1/loop_wrap = true tracks/1/imported = false tracks/1/enabled = true +tracks/1/path = NodePath("MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer/Title:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 0, -"values": [ false ] +"values": [Color(1, 1, 1, 0)] } tracks/2/type = "value" -tracks/2/path = NodePath("TitleContainer/Titles/TitlesContainer/Title:modulate") -tracks/2/interp = 1 -tracks/2/loop_wrap = true tracks/2/imported = false tracks/2/enabled = true +tracks/2/path = NodePath("MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer/SubTitle:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true tracks/2/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 0, -"values": [ Color( 1, 1, 1, 1 ) ] +"values": [Color(1, 1, 1, 0)] } tracks/3/type = "value" -tracks/3/path = NodePath("TitleContainer/Titles/TitlesContainer/SubTitle:modulate") -tracks/3/interp = 1 -tracks/3/loop_wrap = true tracks/3/imported = false tracks/3/enabled = true +tracks/3/path = NodePath("MarginContainer/VBoxContainer/MenuMargin/MenuButtons:visible") +tracks/3/interp = 1 +tracks/3/loop_wrap = true tracks/3/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 1 ) ] +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] } tracks/4/type = "value" -tracks/4/path = NodePath("MenuContainer/MainMenuButtons:modulate") -tracks/4/interp = 1 -tracks/4/loop_wrap = true tracks/4/imported = false tracks/4/enabled = true +tracks/4/path = NodePath("MarginContainer/VBoxContainer/MenuMargin/MenuButtons:modulate") +tracks/4/interp = 1 +tracks/4/loop_wrap = true tracks/4/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 0, -"values": [ Color( 1, 1, 1, 1 ) ] +"values": [Color(1, 1, 1, 0)] } -[sub_resource type="AnimationNodeAnimation" id=12] -animation = "CloseSubMenu" +[sub_resource type="AnimationLibrary" id="AnimationLibrary_2kqig"] +_data = { +"CloseSubMenu": SubResource("5"), +"Intro": SubResource("1"), +"MainMenuOpen": SubResource("6"), +"OpenSubMenu": SubResource("4"), +"Outro": SubResource("3"), +"RESET": SubResource("2") +} -[sub_resource type="AnimationNodeAnimation" id=7] -animation = "Intro" +[sub_resource type="AnimationNodeAnimation" id="12"] +animation = &"CloseSubMenu" -[sub_resource type="AnimationNodeAnimation" id=10] -animation = "MainMenuOpen" +[sub_resource type="AnimationNodeAnimation" id="7"] +animation = &"Intro" -[sub_resource type="AnimationNodeAnimation" id=13] -animation = "OpenSubMenu" +[sub_resource type="AnimationNodeAnimation" id="10"] +animation = &"MainMenuOpen" -[sub_resource type="AnimationNodeStateMachineTransition" id=11] -advance_condition = "intro_done" +[sub_resource type="AnimationNodeAnimation" id="13"] +animation = &"OpenSubMenu" -[sub_resource type="AnimationNodeStateMachineTransition" id=14] +[sub_resource type="AnimationNodeStateMachineTransition" id="11"] +advance_condition = &"intro_done" -[sub_resource type="AnimationNodeStateMachineTransition" id=15] -switch_mode = 2 +[sub_resource type="AnimationNodeStateMachineTransition" id="14"] -[sub_resource type="AnimationNodeStateMachineTransition" id=16] +[sub_resource type="AnimationNodeStateMachineTransition" id="15"] switch_mode = 2 -[sub_resource type="AnimationNodeStateMachine" id=8] -states/CloseSubMenu/node = SubResource( 12 ) -states/CloseSubMenu/position = Vector2( 700, 232 ) -states/Intro/node = SubResource( 7 ) -states/Intro/position = Vector2( 230, 123 ) -states/MainMenuOpen/node = SubResource( 10 ) -states/MainMenuOpen/position = Vector2( 461, 123 ) -states/OpenSubMenu/node = SubResource( 13 ) -states/OpenSubMenu/position = Vector2( 700, 123 ) -transitions = [ "Intro", "MainMenuOpen", SubResource( 11 ), "MainMenuOpen", "OpenSubMenu", SubResource( 14 ), "OpenSubMenu", "CloseSubMenu", SubResource( 15 ), "CloseSubMenu", "MainMenuOpen", SubResource( 16 ) ] -start_node = "Intro" +[sub_resource type="AnimationNodeStateMachineTransition" id="16"] +switch_mode = 2 -[sub_resource type="AnimationNodeStateMachinePlayback" id=9] +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_j0orr"] +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachine" id="8"] +states/CloseSubMenu/node = SubResource("12") +states/CloseSubMenu/position = Vector2(700, 232) +states/Intro/node = SubResource("7") +states/Intro/position = Vector2(230, 123) +states/MainMenuOpen/node = SubResource("10") +states/MainMenuOpen/position = Vector2(461, 123) +states/OpenSubMenu/node = SubResource("13") +states/OpenSubMenu/position = Vector2(700, 123) +states/Start/position = Vector2(82, 123) +transitions = ["Intro", "MainMenuOpen", SubResource("11"), "MainMenuOpen", "OpenSubMenu", SubResource("14"), "OpenSubMenu", "CloseSubMenu", SubResource("15"), "CloseSubMenu", "MainMenuOpen", SubResource("16"), "Start", "Intro", SubResource("AnimationNodeStateMachineTransition_j0orr")] [node name="MainMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -theme = ExtResource( 4 ) -script = ExtResource( 1 ) - -[node name="Panel" type="Panel" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("4") +script = ExtResource("1") +game_scene_path = "res://Scenes/ExampleGameScene/ExampleGameScene.tscn" +options_packed_scene = ExtResource("3") +credits_packed_scene = ExtResource("8") [node name="MenuAnimationPlayer" type="AnimationPlayer" parent="."] -anims/CloseSubMenu = SubResource( 5 ) -anims/Intro = SubResource( 1 ) -anims/MainMenuOpen = SubResource( 6 ) -anims/OpenSubMenu = SubResource( 4 ) -anims/Outro = SubResource( 3 ) -anims/RESET = SubResource( 2 ) +libraries = { +"": SubResource("AnimationLibrary_2kqig") +} [node name="MenuAnimationTree" type="AnimationTree" parent="."] -tree_root = SubResource( 8 ) +tree_root = SubResource("8") anim_player = NodePath("../MenuAnimationPlayer") active = true -parameters/playback = SubResource( 9 ) parameters/conditions/intro_done = false -[node name="TitleContainer" type="MarginContainer" parent="."] +[node name="VersionNameLabel" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -mouse_filter = 2 -custom_constants/margin_right = 32 -custom_constants/margin_top = 64 -custom_constants/margin_left = 32 -custom_constants/margin_bottom = 16 - -[node name="Titles" type="Control" parent="TitleContainer"] -margin_left = 32.0 -margin_top = 64.0 -margin_right = 992.0 -margin_bottom = 584.0 -mouse_filter = 2 +offset_left = -96.0 +offset_top = -33.0 +offset_right = -8.0 +offset_bottom = -7.0 +grow_horizontal = 0 +grow_vertical = 0 +horizontal_alignment = 2 + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 -[node name="TitlesContainer" type="VBoxContainer" parent="TitleContainer/Titles"] -anchor_left = 0.5 -anchor_right = 0.5 -margin_left = -416.0 -margin_right = 416.0 -margin_bottom = 97.0 -custom_constants/separation = 24 - -[node name="Title" type="Label" parent="TitleContainer/Titles/TitlesContainer"] -margin_right = 832.0 -margin_bottom = 14.0 +[node name="TitlesMargin" type="MarginContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 16 +theme_override_constants/margin_bottom = 16 + +[node name="TitlesContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/TitlesMargin"] +layout_mode = 2 + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer"] +modulate = Color(1, 1, 1, 0) +layout_mode = 2 +theme_override_font_sizes/font_size = 48 text = "Title" -align = 1 +horizontal_alignment = 1 +vertical_alignment = 1 -[node name="SubTitle" type="Label" parent="TitleContainer/Titles/TitlesContainer"] -margin_top = 38.0 -margin_right = 832.0 -margin_bottom = 52.0 +[node name="SubTitle" type="Label" parent="MarginContainer/VBoxContainer/TitlesMargin/TitlesContainer"] +modulate = Color(1, 1, 1, 0) +layout_mode = 2 +theme_override_font_sizes/font_size = 32 text = "Subtitle" -align = 1 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="MenuMargin" type="MarginContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 16 +theme_override_constants/margin_bottom = 16 + +[node name="MenuButtons" type="VBoxContainer" parent="MarginContainer/VBoxContainer/MenuMargin"] +visible = false +modulate = Color(1, 1, 1, 0) +layout_mode = 2 -[node name="VersionNameLabel" type="Label" parent="TitleContainer/Titles"] +[node name="PlayButton" parent="MarginContainer/VBoxContainer/MenuMargin/MenuButtons" instance=ExtResource("5")] unique_name_in_owner = true -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = -40.0 -margin_top = -14.0 +layout_mode = 2 +text = "Play" -[node name="MenuContainer" type="MarginContainer" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -custom_constants/margin_right = 128 -custom_constants/margin_top = 128 -custom_constants/margin_left = 128 -custom_constants/margin_bottom = 128 +[node name="OptionsButton" parent="MarginContainer/VBoxContainer/MenuMargin/MenuButtons" instance=ExtResource("5")] +unique_name_in_owner = true +layout_mode = 2 +text = "Options" -[node name="MainMenuButtons" parent="MenuContainer" instance=ExtResource( 2 )] +[node name="CreditsButton" parent="MarginContainer/VBoxContainer/MenuMargin/MenuButtons" instance=ExtResource("5")] +unique_name_in_owner = true +layout_mode = 2 +text = "Credits" -[node name="MasterOptionsMenu" parent="." instance=ExtResource( 3 )] -visible = false -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -200.0 -margin_top = -240.0 -margin_right = 200.0 -margin_bottom = 240.0 +[node name="ExitButton" parent="MarginContainer/VBoxContainer/MenuMargin/MenuButtons" instance=ExtResource("5")] +unique_name_in_owner = true +layout_mode = 2 +text = "Exit" -[node name="CreditsContainer" type="MarginContainer" parent="."] +[node name="OptionsContainer" type="MarginContainer" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 mouse_filter = 2 -custom_constants/margin_top = 128 -custom_constants/margin_bottom = 32 -[node name="Credits" parent="CreditsContainer" instance=ExtResource( 8 )] -visible = false -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 128.0 -margin_right = 1024.0 -margin_bottom = 568.0 -scroll_active = false +[node name="CreditsContainer" type="MarginContainer" parent="."] +unique_name_in_owner = true +layout_mode = 0 +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +theme_override_constants/margin_left = 16 +theme_override_constants/margin_top = 32 +theme_override_constants/margin_right = 16 +theme_override_constants/margin_bottom = 32 [node name="FlowControlContainer" type="MarginContainer" parent="."] +layout_mode = 0 anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 -custom_constants/margin_right = 16 -custom_constants/margin_top = 16 -custom_constants/margin_left = 16 -custom_constants/margin_bottom = 16 +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="FlowControl" type="Control" parent="FlowControlContainer"] -margin_left = 16.0 -margin_top = 16.0 -margin_right = 1008.0 -margin_bottom = 584.0 +layout_mode = 2 mouse_filter = 2 -[node name="BackButton" parent="FlowControlContainer/FlowControl" instance=ExtResource( 5 )] +[node name="BackButton" parent="FlowControlContainer/FlowControl" instance=ExtResource("5")] +unique_name_in_owner = true visible = false +layout_mode = 0 anchor_top = 1.0 anchor_bottom = 1.0 -margin_top = -40.0 -margin_right = 62.0 +offset_top = -40.0 +offset_right = 62.0 text = "Back" -[connection signal="pressed" from="MenuContainer/MainMenuButtons/ButtonsContainer/PlayButton" to="." method="_on_PlayButton_pressed"] -[connection signal="pressed" from="MenuContainer/MainMenuButtons/ButtonsContainer/TutorialButton" to="." method="_on_TutorialButton_pressed"] -[connection signal="pressed" from="MenuContainer/MainMenuButtons/ButtonsContainer/OptionsButton" to="." method="_on_OptionsButton_pressed"] -[connection signal="pressed" from="MenuContainer/MainMenuButtons/ButtonsContainer/CreditsButton" to="." method="_on_CreditsButton_pressed"] -[connection signal="pressed" from="MenuContainer/MainMenuButtons/ButtonsContainer/ExitButton" to="." method="_on_ExitButton_pressed"] -[connection signal="end_reached" from="CreditsContainer/Credits" to="." method="_on_Credits_end_reached"] -[connection signal="pressed" from="FlowControlContainer/FlowControl/BackButton" to="." method="_on_BackButton_pressed"] - -[editable path="MenuContainer/MainMenuButtons"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/MenuMargin/MenuButtons/PlayButton" to="." method="_on_play_button_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/MenuMargin/MenuButtons/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/MenuMargin/MenuButtons/CreditsButton" to="." method="_on_credits_button_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/MenuMargin/MenuButtons/ExitButton" to="." method="_on_exit_button_pressed"] +[connection signal="pressed" from="FlowControlContainer/FlowControl/BackButton" to="." method="_on_back_button_pressed"] diff --git a/Scenes/MainMenu/MainMenuButtons.tscn b/Scenes/MainMenu/MainMenuButtons.tscn index 3697e063..fe6f6c64 100644 --- a/Scenes/MainMenu/MainMenuButtons.tscn +++ b/Scenes/MainMenu/MainMenuButtons.tscn @@ -1,49 +1,43 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://ccxeuojnphgyo"] -[ext_resource path="res://Scenes/UI/SoundButton/SoundButton.tscn" type="PackedScene" id=2] +[ext_resource type="PackedScene" path="res://Scenes/UI/SoundButton/SoundButton.tscn" id="2"] [node name="MainMenuButtons" type="Control"] -margin_left = 128.0 -margin_top = 128.0 -margin_right = 896.0 -margin_bottom = 472.0 +layout_mode = 3 +anchors_preset = 0 +offset_left = 128.0 +offset_top = 128.0 +offset_right = 896.0 +offset_bottom = 472.0 [node name="ButtonsContainer" type="VBoxContainer" parent="."] +layout_mode = 0 anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -margin_left = -96.0 -margin_top = -128.0 -margin_right = 96.0 -margin_bottom = 128.0 -custom_constants/separation = 16 - -[node name="PlayButton" parent="ButtonsContainer" instance=ExtResource( 2 )] -margin_right = 192.0 -margin_bottom = 40.0 +offset_left = -96.0 +offset_top = -128.0 +offset_right = 96.0 +offset_bottom = 128.0 +theme_override_constants/separation = 16 + +[node name="PlayButton" parent="ButtonsContainer" instance=ExtResource("2")] +layout_mode = 2 text = "play" -[node name="TutorialButton" parent="ButtonsContainer" instance=ExtResource( 2 )] -margin_top = 56.0 -margin_right = 192.0 -margin_bottom = 96.0 +[node name="TutorialButton" parent="ButtonsContainer" instance=ExtResource("2")] +layout_mode = 2 text = "tutorial" -[node name="OptionsButton" parent="ButtonsContainer" instance=ExtResource( 2 )] -margin_top = 112.0 -margin_right = 192.0 -margin_bottom = 152.0 +[node name="OptionsButton" parent="ButtonsContainer" instance=ExtResource("2")] +layout_mode = 2 text = "options" -[node name="CreditsButton" parent="ButtonsContainer" instance=ExtResource( 2 )] -margin_top = 168.0 -margin_right = 192.0 -margin_bottom = 208.0 +[node name="CreditsButton" parent="ButtonsContainer" instance=ExtResource("2")] +layout_mode = 2 text = "credits" -[node name="ExitButton" parent="ButtonsContainer" instance=ExtResource( 2 )] -margin_top = 224.0 -margin_right = 192.0 -margin_bottom = 264.0 +[node name="ExitButton" parent="ButtonsContainer" instance=ExtResource("2")] +layout_mode = 2 text = "exit" diff --git a/Scenes/OptionsMenu/Audio/AudioOptionsMenu.gd b/Scenes/OptionsMenu/Audio/AudioOptionsMenu.gd index cd46f380..c67cf418 100644 --- a/Scenes/OptionsMenu/Audio/AudioOptionsMenu.gd +++ b/Scenes/OptionsMenu/Audio/AudioOptionsMenu.gd @@ -1,10 +1,10 @@ extends Control -onready var master_slider = $VBoxContainer/MasterControl/MasterHSlider -onready var sfx_slider = $VBoxContainer/SFXControl/SFXHSlider -onready var voice_slider = $VBoxContainer/VoiceControl/VoiceHSlider -onready var music_slider = $VBoxContainer/MusicControl/MusicHSlider -onready var mute_button = $VBoxContainer/MuteControl/MuteButton +@onready var master_slider = $VBoxContainer/MasterControl/MasterHSlider +@onready var sfx_slider = $VBoxContainer/SFXControl/SFXHSlider +@onready var voice_slider = $VBoxContainer/VoiceControl/VoiceHSlider +@onready var music_slider = $VBoxContainer/MusicControl/MusicHSlider +@onready var mute_button = $VBoxContainer/MuteControl/MuteButton var play_audio_streams : bool = false @@ -22,7 +22,7 @@ func _update_ui(): sfx_slider.value = AppSettings.get_bus_volume(AppSettings.SFX_AUDIO_BUS) voice_slider.value = AppSettings.get_bus_volume(AppSettings.VOICE_AUDIO_BUS) music_slider.value = AppSettings.get_bus_volume(AppSettings.MUSIC_AUDIO_BUS) - mute_button.pressed = AppSettings.is_muted() + mute_button.button_pressed = AppSettings.is_muted() func _ready(): AppSettings.init_audio_config() @@ -47,4 +47,4 @@ func _on_MuteButton_toggled(button_pressed): func _unhandled_key_input(event): if event.is_action_released('ui_mute'): - mute_button.pressed = !(mute_button.pressed) + mute_button.button_pressed = !(mute_button.pressed) diff --git a/Scenes/OptionsMenu/Audio/AudioOptionsMenu.tscn b/Scenes/OptionsMenu/Audio/AudioOptionsMenu.tscn index fe06be54..19e18a37 100644 --- a/Scenes/OptionsMenu/Audio/AudioOptionsMenu.tscn +++ b/Scenes/OptionsMenu/Audio/AudioOptionsMenu.tscn @@ -1,168 +1,107 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://c8vnncjwqcpab"] -[ext_resource path="res://Scenes/OptionsMenu/Audio/AudioOptionsMenu.gd" type="Script" id=1] +[ext_resource type="Script" path="res://Scenes/OptionsMenu/Audio/AudioOptionsMenu.gd" id="1"] [node name="Audio" type="CenterContainer"] +custom_minimum_size = Vector2(305, 0) +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -rect_min_size = Vector2( 305, 0 ) -script = ExtResource( 1 ) +script = ExtResource("1") [node name="VBoxContainer" type="VBoxContainer" parent="."] -margin_left = 362.0 -margin_top = 223.0 -margin_right = 662.0 -margin_bottom = 377.0 -rect_min_size = Vector2( 300, 0 ) -custom_constants/separation = 8 +custom_minimum_size = Vector2(300, 0) +layout_mode = 2 +theme_override_constants/separation = 8 [node name="MasterControl" type="HBoxContainer" parent="VBoxContainer"] -margin_right = 300.0 -margin_bottom = 30.0 -rect_min_size = Vector2( 0, 30 ) +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 [node name="MasterLabel" type="Label" parent="VBoxContainer/MasterControl"] -margin_top = 8.0 -margin_right = 96.0 -margin_bottom = 22.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Master :" -__meta__ = { -"_edit_use_anchors_": false -} [node name="MasterHSlider" type="HSlider" parent="VBoxContainer/MasterControl"] -margin_left = 100.0 -margin_top = 7.0 -margin_right = 300.0 -margin_bottom = 23.0 -rect_min_size = Vector2( 200, 0 ) +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 size_flags_vertical = 4 max_value = 1.0 step = 0.05 value = 1.0 tick_count = 11 ticks_on_borders = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="SFXControl" type="HBoxContainer" parent="VBoxContainer"] -margin_top = 38.0 -margin_right = 300.0 -margin_bottom = 68.0 -rect_min_size = Vector2( 0, 30 ) +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 [node name="SFXLabel" type="Label" parent="VBoxContainer/SFXControl"] -margin_top = 8.0 -margin_right = 96.0 -margin_bottom = 22.0 +layout_mode = 2 size_flags_horizontal = 3 text = "SFX :" -__meta__ = { -"_edit_use_anchors_": false -} [node name="SFXHSlider" type="HSlider" parent="VBoxContainer/SFXControl"] -margin_left = 100.0 -margin_top = 7.0 -margin_right = 300.0 -margin_bottom = 23.0 -rect_min_size = Vector2( 200, 0 ) +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 size_flags_vertical = 4 max_value = 1.0 step = 0.05 value = 1.0 tick_count = 11 ticks_on_borders = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="VoiceControl" type="HBoxContainer" parent="VBoxContainer"] visible = false -margin_top = 72.0 -margin_right = 305.0 -margin_bottom = 102.0 -rect_min_size = Vector2( 0, 30 ) +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 [node name="VoiceLabel" type="Label" parent="VBoxContainer/VoiceControl"] -margin_top = 1.0 -margin_right = 101.0 -margin_bottom = 15.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Voice :" -__meta__ = { -"_edit_use_anchors_": false -} [node name="VoiceHSlider" type="HSlider" parent="VBoxContainer/VoiceControl"] -margin_left = 105.0 -margin_right = 305.0 -margin_bottom = 16.0 -rect_min_size = Vector2( 200, 0 ) +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 size_flags_vertical = 4 max_value = 1.0 step = 0.05 value = 1.0 tick_count = 11 ticks_on_borders = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="MusicControl" type="HBoxContainer" parent="VBoxContainer"] -margin_top = 76.0 -margin_right = 300.0 -margin_bottom = 106.0 -rect_min_size = Vector2( 0, 30 ) +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 [node name="MusicLabel" type="Label" parent="VBoxContainer/MusicControl"] -margin_top = 8.0 -margin_right = 96.0 -margin_bottom = 22.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Music :" -__meta__ = { -"_edit_use_anchors_": false -} [node name="MusicHSlider" type="HSlider" parent="VBoxContainer/MusicControl"] -margin_left = 100.0 -margin_top = 7.0 -margin_right = 300.0 -margin_bottom = 23.0 -rect_min_size = Vector2( 200, 0 ) +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 size_flags_vertical = 4 max_value = 1.0 step = 0.05 value = 1.0 tick_count = 11 ticks_on_borders = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="MuteControl" type="HBoxContainer" parent="VBoxContainer"] -margin_top = 114.0 -margin_right = 300.0 -margin_bottom = 154.0 -rect_min_size = Vector2( 0, 40 ) +custom_minimum_size = Vector2(0, 40) +layout_mode = 2 [node name="MuteLabel" type="Label" parent="VBoxContainer/MuteControl"] -margin_top = 13.0 -margin_right = 220.0 -margin_bottom = 27.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Mute :" [node name="MuteButton" type="CheckButton" parent="VBoxContainer/MuteControl"] -margin_left = 224.0 -margin_right = 300.0 -margin_bottom = 40.0 -__meta__ = { -"_edit_use_anchors_": false -} +layout_mode = 2 [node name="VocalAudioStreamPlayers" type="Node" parent="."] diff --git a/Scenes/OptionsMenu/Game/GameOptionsMenu.tscn b/Scenes/OptionsMenu/Game/GameOptionsMenu.tscn index 3d11b8aa..b3dfd592 100644 --- a/Scenes/OptionsMenu/Game/GameOptionsMenu.tscn +++ b/Scenes/OptionsMenu/Game/GameOptionsMenu.tscn @@ -1,23 +1,19 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=3 format=3 uid="uid://d2mir68lswbox"] -[ext_resource path="res://Scenes/OptionsMenu/Game/GameOptionsMenu.gd" type="Script" id=1] -[ext_resource path="res://Scenes/UI/ResetGameControl/ResetGameControl.tscn" type="PackedScene" id=2] +[ext_resource type="Script" path="res://Scenes/OptionsMenu/Game/GameOptionsMenu.gd" id="1"] +[ext_resource type="PackedScene" uid="uid://cay00igbuqtfa" path="res://Scenes/UI/ResetGameControl/ResetGameControl.tscn" id="2"] [node name="Game" type="CenterContainer"] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -script = ExtResource( 1 ) +script = ExtResource("1") [node name="VBoxContainer" type="VBoxContainer" parent="."] -margin_left = 362.0 -margin_top = 284.0 -margin_right = 662.0 -margin_bottom = 316.0 -rect_min_size = Vector2( 300, 0 ) +custom_minimum_size = Vector2(300, 0) +layout_mode = 2 -[node name="ResetGameControl" parent="VBoxContainer" instance=ExtResource( 2 )] -margin_top = 0.0 -margin_right = 300.0 -margin_bottom = 32.0 +[node name="ResetGameControl" parent="VBoxContainer" instance=ExtResource("2")] +layout_mode = 2 [connection signal="reset_confirmed" from="VBoxContainer/ResetGameControl" to="." method="_on_ResetGameControl_reset_confirmed"] diff --git a/Scenes/OptionsMenu/Input/InputOptionsMenu.gd b/Scenes/OptionsMenu/Input/InputOptionsMenu.gd index cedc8d60..dc7cf561 100644 --- a/Scenes/OptionsMenu/Input/InputOptionsMenu.gd +++ b/Scenes/OptionsMenu/Input/InputOptionsMenu.gd @@ -1,25 +1,22 @@ extends Control -onready var placeholder_text = $KeyAssignmentDialog.dialog_text +@onready var placeholder_text = $KeyAssignmentDialog.dialog_text var key_binding_control_scene = preload("res://Scenes/UI/KeyBindingControl/KeyBindingControl.tscn") var input_node_map : Dictionary = {} var editing_action_name : String = "" var last_input_event : InputEventWithModifiers -func is_editing_key_binding(): - return editing_action_name != "" - func _edit_key(action_name : String) -> void: editing_action_name = action_name - $KeyAssignmentDialog.window_title = AppSettings.INPUT_MAP[action_name] + $KeyAssignmentDialog.title = AppSettings.INPUT_MAP[action_name] $KeyAssignmentDialog.dialog_text = placeholder_text - $KeyAssignmentDialog.get_ok().disabled = true - $KeyAssignmentDialog.get_label().align = Label.ALIGN_CENTER + $KeyAssignmentDialog.get_ok_button().disabled = true + $KeyAssignmentDialog.get_label().horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER $KeyAssignmentDialog.popup_centered() func _update_ui(): for action_name in AppSettings.INPUT_MAP.keys(): - var input_events = InputMap.get_action_list(action_name) + var input_events = InputMap.action_get_events(action_name) if input_events.size() < 1: print("%s is empty" % action_name) continue @@ -27,17 +24,17 @@ func _update_ui(): var readable_name = AppSettings.INPUT_MAP[action_name] var control_instance if not action_name in input_node_map: - control_instance = key_binding_control_scene.instance() + control_instance = key_binding_control_scene.instantiate() control_instance.action_name = readable_name - control_instance.connect("edit_button_pressed", self, "_edit_key", [action_name]) + control_instance.connect("edit_button_pressed", Callable(self, "_edit_key").bind(action_name)) input_node_map[action_name] = control_instance $VBoxContainer.add_child(control_instance) else: control_instance = input_node_map[action_name] - control_instance.scancode = AppSettings.get_input_event_scancode(input_event) + control_instance.keycode = AppSettings.get_input_event_scancode(input_event) func _assign_key_to_action(action_event : InputEventKey, action_name : String) -> void: - for old_event in InputMap.get_action_list(action_name): + for old_event in InputMap.action_get_events(action_name): InputMap.action_erase_event(action_name, old_event) InputMap.action_add_event(action_name, action_event) AppSettings.set_action_scancode(action_name, AppSettings.get_input_event_scancode(action_event)) @@ -47,14 +44,11 @@ func _ready(): AppSettings.set_inputs_from_config() _update_ui() -func _input(event): - if not event.is_pressed() or not is_editing_key_binding(): - return - if event is InputEventKey: - last_input_event = event - $KeyAssignmentDialog.dialog_text = OS.get_scancode_string(event.get_scancode_with_modifiers()) - $KeyAssignmentDialog.get_ok().disabled = false func _on_KeyAssignmentDialog_confirmed(): - _assign_key_to_action(last_input_event, editing_action_name) + if $KeyAssignmentDialog.last_input_event != null: + _assign_key_to_action($KeyAssignmentDialog.last_input_event, editing_action_name) + editing_action_name = "" + +func _on_key_assignment_dialog_canceled(): editing_action_name = "" diff --git a/Scenes/OptionsMenu/Input/InputOptionsMenu.tscn b/Scenes/OptionsMenu/Input/InputOptionsMenu.tscn index 09cf7663..9dee45a4 100644 --- a/Scenes/OptionsMenu/Input/InputOptionsMenu.tscn +++ b/Scenes/OptionsMenu/Input/InputOptionsMenu.tscn @@ -1,28 +1,24 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=3 uid="uid://dp3rgqaehb3xu"] -[ext_resource path="res://Scenes/OptionsMenu/Input/InputOptionsMenu.gd" type="Script" id=1] -[ext_resource path="res://Themes/MainMenuTheme.tres" type="Theme" id=2] +[ext_resource type="Script" path="res://Scenes/OptionsMenu/Input/InputOptionsMenu.gd" id="1"] +[ext_resource type="Theme" path="res://Themes/BaseTheme.tres" id="2"] +[ext_resource type="Script" path="res://Scenes/OptionsMenu/Input/KeyAssignmentDialog.gd" id="3_wsh2h"] [node name="Input" type="CenterContainer"] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -script = ExtResource( 1 ) +script = ExtResource("1") [node name="VBoxContainer" type="VBoxContainer" parent="."] -margin_left = 362.0 -margin_top = 300.0 -margin_right = 662.0 -margin_bottom = 300.0 -rect_min_size = Vector2( 300, 0 ) -custom_constants/separation = 8 +custom_minimum_size = Vector2(300, 0) +layout_mode = 2 +theme_override_constants/separation = 8 [node name="KeyAssignmentDialog" type="ConfirmationDialog" parent="."] -margin_left = 412.0 -margin_top = 265.0 -margin_right = 612.0 -margin_bottom = 335.0 -theme = ExtResource( 2 ) -popup_exclusive = true +theme = ExtResource("2") dialog_text = "Press a key..." +script = ExtResource("3_wsh2h") +[connection signal="canceled" from="KeyAssignmentDialog" to="." method="_on_key_assignment_dialog_canceled"] [connection signal="confirmed" from="KeyAssignmentDialog" to="." method="_on_KeyAssignmentDialog_confirmed"] diff --git a/Scenes/OptionsMenu/Input/KeyAssignmentDialog.gd b/Scenes/OptionsMenu/Input/KeyAssignmentDialog.gd new file mode 100644 index 00000000..9a5ff536 --- /dev/null +++ b/Scenes/OptionsMenu/Input/KeyAssignmentDialog.gd @@ -0,0 +1,11 @@ +extends ConfirmationDialog + +var last_input_event : InputEventWithModifiers + +func _input(event): + if not visible: + return + if event is InputEventKey: + last_input_event = event + dialog_text = OS.get_keycode_string(event.get_keycode_with_modifiers()) + get_ok_button().disabled = false diff --git a/Scenes/OptionsMenu/MasterOptionsMenu.tscn b/Scenes/OptionsMenu/MasterOptionsMenu.tscn index 44987ec0..e4c83823 100644 --- a/Scenes/OptionsMenu/MasterOptionsMenu.tscn +++ b/Scenes/OptionsMenu/MasterOptionsMenu.tscn @@ -1,35 +1,34 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=5 format=3 uid="uid://bvwl11s2p0hd"] -[ext_resource path="res://Scenes/OptionsMenu/Audio/AudioOptionsMenu.tscn" type="PackedScene" id=1] -[ext_resource path="res://Scenes/OptionsMenu/Video/VideoOptionsMenu.tscn" type="PackedScene" id=2] -[ext_resource path="res://Scenes/OptionsMenu/Game/GameOptionsMenu.tscn" type="PackedScene" id=3] -[ext_resource path="res://Scenes/OptionsMenu/Input/InputOptionsMenu.tscn" type="PackedScene" id=4] +[ext_resource type="PackedScene" uid="uid://c8vnncjwqcpab" path="res://Scenes/OptionsMenu/Audio/AudioOptionsMenu.tscn" id="1"] +[ext_resource type="PackedScene" path="res://Scenes/OptionsMenu/Video/VideoOptionsMenu.tscn" id="2"] +[ext_resource type="PackedScene" uid="uid://d2mir68lswbox" path="res://Scenes/OptionsMenu/Game/GameOptionsMenu.tscn" id="3"] +[ext_resource type="PackedScene" uid="uid://dp3rgqaehb3xu" path="res://Scenes/OptionsMenu/Input/InputOptionsMenu.tscn" id="4"] [node name="MasterOptionsMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 [node name="TabContainer" type="TabContainer" parent="."] +layout_mode = 0 anchor_right = 1.0 anchor_bottom = 1.0 -[node name="Input" parent="TabContainer" instance=ExtResource( 4 )] -margin_left = 4.0 -margin_top = 32.0 -margin_right = -4.0 -margin_bottom = -4.0 +[node name="Input" parent="TabContainer" instance=ExtResource("4")] +layout_mode = 2 -[node name="Audio" parent="TabContainer" instance=ExtResource( 1 )] +[node name="Audio" parent="TabContainer" instance=ExtResource("1")] visible = false -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 359.0 -margin_top = 237.0 -margin_right = 664.0 -margin_bottom = 391.0 +layout_mode = 2 -[node name="Video" parent="TabContainer" instance=ExtResource( 2 )] +[node name="Video" parent="TabContainer" instance=ExtResource("2")] visible = false +layout_mode = 2 -[node name="Game" parent="TabContainer" instance=ExtResource( 3 )] +[node name="Game" parent="TabContainer" instance=ExtResource("3")] visible = false +layout_mode = 2 diff --git a/Scenes/OptionsMenu/OptionsMenu.gd b/Scenes/OptionsMenu/OptionsMenu.gd index fbc16ce7..b5692bcc 100644 --- a/Scenes/OptionsMenu/OptionsMenu.gd +++ b/Scenes/OptionsMenu/OptionsMenu.gd @@ -1,7 +1,5 @@ extends Control -signal return_button_pressed - const MASTER_AUDIO_BUS = 'Master' const VOICE_AUDIO_BUS = 'Voice' const SFX_AUDIO_BUS = 'SFX' @@ -11,12 +9,12 @@ const FULLSCREEN_ENABLED = 'FullscreenEnabled' const AUDIO_SECTION = 'AudioSettings' const VIDEO_SECTION = 'VideoSettings' -onready var master_slider = $MasterControl/MasterHSlider -onready var sfx_slider = $SFXControl/SFXHSlider -onready var voice_slider = $VoiceControl/VoiceHSlider -onready var music_slider = $MusicControl/MusicHSlider -onready var mute_button = $MuteControl/MuteButton -onready var fullscreen_button = $FullscreenControl/FullscreenButton +@onready var master_slider = $MasterControl/MasterHSlider +@onready var sfx_slider = $SFXControl/SFXHSlider +@onready var voice_slider = $VoiceControl/VoiceHSlider +@onready var music_slider = $MusicControl/MusicHSlider +@onready var mute_button = $MuteControl/MuteButton +@onready var fullscreen_button = $FullscreenControl/FullscreenButton var play_audio_streams : bool = false @@ -25,13 +23,13 @@ func _get_bus_volume_2_linear(bus_name : String) -> float: if bus_index < 0: return 0.0 var volume_db : float = AudioServer.get_bus_volume_db(bus_index) - return db2linear(volume_db) + return db_to_linear(volume_db) func _set_bus_linear_2_volume(bus_name : String, linear : float) -> void: var bus_index : int = AudioServer.get_bus_index(bus_name) if bus_index < 0: return - var volume_db : float = linear2db(linear) + var volume_db : float = linear_to_db(linear) AudioServer.set_bus_volume_db(bus_index, volume_db) Config.set_config(AUDIO_SECTION, bus_name, linear) @@ -44,26 +42,17 @@ func _set_mute(mute_flag : bool) -> void: AudioServer.set_bus_mute(bus_index, mute_flag) Config.set_config(AUDIO_SECTION, MUTE_SETTING, mute_flag) -func _play_next_audio_stream(_stream_parent : Node) -> void: - pass - -func _play_next_vocal_audio_stream() -> void: - _play_next_audio_stream($VocalAudioStreamPlayers) - -func _play_next_sfx_audio_stream() -> void: - _play_next_audio_stream($SFXAudioStreamPlayers) - func _update_ui(): master_slider.value = _get_bus_volume_2_linear(MASTER_AUDIO_BUS) sfx_slider.value = _get_bus_volume_2_linear(SFX_AUDIO_BUS) voice_slider.value = _get_bus_volume_2_linear(VOICE_AUDIO_BUS) music_slider.value = _get_bus_volume_2_linear(MUSIC_AUDIO_BUS) - mute_button.pressed = _is_muted() - fullscreen_button.pressed = OS.window_fullscreen + mute_button.button_pressed = _is_muted() + fullscreen_button.button_pressed = ((get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (get_window().mode == Window.MODE_FULLSCREEN)) func _set_init_config_if_empty() -> void: if not Config.has_section(VIDEO_SECTION): - Config.set_config(VIDEO_SECTION, FULLSCREEN_ENABLED, OS.window_fullscreen) + Config.set_config(VIDEO_SECTION, FULLSCREEN_ENABLED, ((get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (get_window().mode == Window.MODE_FULLSCREEN))) if not Config.has_section(AUDIO_SECTION): Config.set_config(AUDIO_SECTION, MASTER_AUDIO_BUS, _get_bus_volume_2_linear(MASTER_AUDIO_BUS)) Config.set_config(AUDIO_SECTION, SFX_AUDIO_BUS, _get_bus_volume_2_linear(SFX_AUDIO_BUS)) @@ -80,12 +69,12 @@ func _set_init_config(): Config.set_config(AUDIO_SECTION, MUTE_SETTING, _is_muted()) func _set_fullscreen_enabled_from_config() -> void: - var fullscreen_enabled : bool = OS.window_fullscreen + var fullscreen_enabled : bool = ((get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (get_window().mode == Window.MODE_FULLSCREEN)) fullscreen_enabled = Config.get_config(VIDEO_SECTION, FULLSCREEN_ENABLED, fullscreen_enabled) - OS.window_fullscreen = fullscreen_enabled + get_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (fullscreen_enabled) else Window.MODE_WINDOWED func _set_fullscreen_enabled(value : bool) -> void: - OS.window_fullscreen = value + get_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (value) else Window.MODE_WINDOWED Config.set_config(VIDEO_SECTION, FULLSCREEN_ENABLED, value) func _set_audio_buses_from_config(): @@ -116,32 +105,23 @@ func _sync_with_config() -> void: func _ready(): _sync_with_config() -func _on_ReturnButton_pressed(): - emit_signal("return_button_pressed") - -func _on_MasterHSlider_value_changed(value): +func _on_master_h_slider_value_changed(value): _set_bus_linear_2_volume(MASTER_AUDIO_BUS, value) -func _on_SFXHSlider_value_changed(value): +func _on_sfxh_slider_value_changed(value): _set_bus_linear_2_volume(SFX_AUDIO_BUS, value) - _play_next_sfx_audio_stream() -func _on_VoiceHSlider_value_changed(value): +func _on_voice_h_slider_value_changed(value): _set_bus_linear_2_volume(VOICE_AUDIO_BUS, value) - _play_next_vocal_audio_stream() -func _on_MusicHSlider_value_changed(value): +func _on_music_h_slider_value_changed(value): _set_bus_linear_2_volume(MUSIC_AUDIO_BUS, value) -func _on_MuteButton_toggled(button_pressed): +func _on_mute_button_toggled(button_pressed): _set_mute(button_pressed) -func _on_FullscreenButton_toggled(button_pressed): +func _on_fullscreen_button_toggled(button_pressed): _set_fullscreen_enabled(button_pressed) -func _on_ResetGameControl_reset_confirmed(): +func _on_reset_game_control_reset_confirmed(): GameLog.reset_game_data() - -func _unhandled_key_input(event): - if event.is_action_released('ui_mute'): - mute_button.pressed = !(mute_button.pressed) diff --git a/Scenes/OptionsMenu/OptionsMenu.tscn b/Scenes/OptionsMenu/OptionsMenu.tscn index 3207853f..e29c9fcc 100644 --- a/Scenes/OptionsMenu/OptionsMenu.tscn +++ b/Scenes/OptionsMenu/OptionsMenu.tscn @@ -1,200 +1,130 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=3 format=3 uid="uid://vh1ucj2rfbby"] -[ext_resource path="res://Scenes/UI/ResetGameControl/ResetGameControl.tscn" type="PackedScene" id=1] -[ext_resource path="res://Scenes/OptionsMenu/OptionsMenu.gd" type="Script" id=2] +[ext_resource type="PackedScene" uid="uid://cay00igbuqtfa" path="res://Scenes/UI/ResetGameControl/ResetGameControl.tscn" id="1"] +[ext_resource type="Script" path="res://Scenes/OptionsMenu/OptionsMenu.gd" id="2"] [node name="OptionsMenu" type="VBoxContainer"] +custom_minimum_size = Vector2(305, 260) +anchors_preset = 8 anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -margin_left = -152.5 -margin_top = -150.0 -margin_right = 152.5 -margin_bottom = 110.0 -rect_min_size = Vector2( 305, 260 ) -custom_constants/separation = 8 -script = ExtResource( 2 ) +offset_left = -152.5 +offset_top = -150.0 +offset_right = 152.5 +offset_bottom = 110.0 +theme_override_constants/separation = 8 +script = ExtResource("2") [node name="MasterControl" type="HBoxContainer" parent="."] -margin_right = 305.0 -margin_bottom = 30.0 -rect_min_size = Vector2( 0, 30 ) +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 [node name="MasterLabel" type="Label" parent="MasterControl"] -margin_top = 8.0 -margin_right = 101.0 -margin_bottom = 22.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Master :" -__meta__ = { -"_edit_use_anchors_": false -} [node name="MasterHSlider" type="HSlider" parent="MasterControl"] -margin_left = 105.0 -margin_top = 7.0 -margin_right = 305.0 -margin_bottom = 23.0 -rect_min_size = Vector2( 200, 0 ) +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 size_flags_vertical = 4 max_value = 1.0 step = 0.05 value = 1.0 tick_count = 11 ticks_on_borders = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="SFXControl" type="HBoxContainer" parent="."] -margin_top = 38.0 -margin_right = 305.0 -margin_bottom = 68.0 -rect_min_size = Vector2( 0, 30 ) +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 [node name="SFXLabel" type="Label" parent="SFXControl"] -margin_top = 8.0 -margin_right = 101.0 -margin_bottom = 22.0 +layout_mode = 2 size_flags_horizontal = 3 text = "SFX :" -__meta__ = { -"_edit_use_anchors_": false -} [node name="SFXHSlider" type="HSlider" parent="SFXControl"] -margin_left = 105.0 -margin_top = 7.0 -margin_right = 305.0 -margin_bottom = 23.0 -rect_min_size = Vector2( 200, 0 ) +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 size_flags_vertical = 4 max_value = 1.0 step = 0.05 value = 1.0 tick_count = 11 ticks_on_borders = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="VoiceControl" type="HBoxContainer" parent="."] visible = false -margin_top = 72.0 -margin_right = 305.0 -margin_bottom = 88.0 -rect_min_size = Vector2( 0, 30 ) +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 [node name="VoiceLabel" type="Label" parent="VoiceControl"] -margin_top = 1.0 -margin_right = 101.0 -margin_bottom = 15.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Voice :" -__meta__ = { -"_edit_use_anchors_": false -} [node name="VoiceHSlider" type="HSlider" parent="VoiceControl"] -margin_left = 105.0 -margin_right = 305.0 -margin_bottom = 16.0 -rect_min_size = Vector2( 200, 0 ) +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 size_flags_vertical = 4 max_value = 1.0 step = 0.05 value = 1.0 tick_count = 11 ticks_on_borders = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="MusicControl" type="HBoxContainer" parent="."] -margin_top = 76.0 -margin_right = 305.0 -margin_bottom = 106.0 -rect_min_size = Vector2( 0, 30 ) +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 [node name="MusicLabel" type="Label" parent="MusicControl"] -margin_top = 8.0 -margin_right = 101.0 -margin_bottom = 22.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Music :" -__meta__ = { -"_edit_use_anchors_": false -} [node name="MusicHSlider" type="HSlider" parent="MusicControl"] -margin_left = 105.0 -margin_top = 7.0 -margin_right = 305.0 -margin_bottom = 23.0 -rect_min_size = Vector2( 200, 0 ) +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 size_flags_vertical = 4 max_value = 1.0 step = 0.05 value = 1.0 tick_count = 11 ticks_on_borders = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="MuteControl" type="HBoxContainer" parent="."] -margin_top = 114.0 -margin_right = 305.0 -margin_bottom = 154.0 -rect_min_size = Vector2( 0, 40 ) +custom_minimum_size = Vector2(0, 40) +layout_mode = 2 [node name="MuteLabel" type="Label" parent="MuteControl"] -margin_top = 13.0 -margin_right = 225.0 -margin_bottom = 27.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Mute :" [node name="MuteButton" type="CheckButton" parent="MuteControl"] -margin_left = 229.0 -margin_right = 305.0 -margin_bottom = 40.0 -__meta__ = { -"_edit_use_anchors_": false -} +layout_mode = 2 [node name="FullscreenControl" type="HBoxContainer" parent="."] -margin_top = 162.0 -margin_right = 305.0 -margin_bottom = 202.0 -rect_min_size = Vector2( 0, 40 ) +custom_minimum_size = Vector2(0, 40) +layout_mode = 2 [node name="FullscreenLabel" type="Label" parent="FullscreenControl"] -margin_top = 13.0 -margin_right = 225.0 -margin_bottom = 27.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Fullscreen :" [node name="FullscreenButton" type="CheckButton" parent="FullscreenControl"] -margin_left = 229.0 -margin_right = 305.0 -margin_bottom = 40.0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="ResetGameControl" parent="." instance=ExtResource( 1 )] - -[node name="VocalAudioStreamPlayers" type="Node" parent="."] - -[node name="SFXAudioStreamPlayers" type="Node" parent="."] - -[connection signal="value_changed" from="MasterControl/MasterHSlider" to="." method="_on_MasterHSlider_value_changed"] -[connection signal="value_changed" from="SFXControl/SFXHSlider" to="." method="_on_SFXHSlider_value_changed"] -[connection signal="value_changed" from="VoiceControl/VoiceHSlider" to="." method="_on_VoiceHSlider_value_changed"] -[connection signal="value_changed" from="MusicControl/MusicHSlider" to="." method="_on_MusicHSlider_value_changed"] -[connection signal="toggled" from="MuteControl/MuteButton" to="." method="_on_MuteButton_toggled"] -[connection signal="toggled" from="FullscreenControl/FullscreenButton" to="." method="_on_FullscreenButton_toggled"] -[connection signal="reset_confirmed" from="ResetGameControl" to="." method="_on_ResetGameControl_reset_confirmed"] +layout_mode = 2 + +[node name="ResetGameControl" parent="." instance=ExtResource("1")] +layout_mode = 2 + +[connection signal="value_changed" from="MasterControl/MasterHSlider" to="." method="_on_master_h_slider_value_changed"] +[connection signal="value_changed" from="SFXControl/SFXHSlider" to="." method="_on_sfxh_slider_value_changed"] +[connection signal="value_changed" from="VoiceControl/VoiceHSlider" to="." method="_on_voice_h_slider_value_changed"] +[connection signal="value_changed" from="MusicControl/MusicHSlider" to="." method="_on_music_h_slider_value_changed"] +[connection signal="toggled" from="MuteControl/MuteButton" to="." method="_on_mute_button_toggled"] +[connection signal="toggled" from="FullscreenControl/FullscreenButton" to="." method="_on_fullscreen_button_toggled"] +[connection signal="reset_confirmed" from="ResetGameControl" to="." method="_on_reset_game_control_reset_confirmed"] diff --git a/Scenes/OptionsMenu/Video/VideoOptionsMenu.gd b/Scenes/OptionsMenu/Video/VideoOptionsMenu.gd index 3d5d8aed..5ae445c5 100644 --- a/Scenes/OptionsMenu/Video/VideoOptionsMenu.gd +++ b/Scenes/OptionsMenu/Video/VideoOptionsMenu.gd @@ -3,15 +3,15 @@ extends Control const FULLSCREEN_ENABLED = 'FullscreenEnabled' const VIDEO_SECTION = 'VideoSettings' -onready var fullscreen_button = $VBoxContainer/FullscreenControl/FullscreenButton +@onready var fullscreen_button = $VBoxContainer/FullscreenControl/FullscreenButton func _update_ui(): - fullscreen_button.pressed = OS.window_fullscreen + fullscreen_button.button_pressed = ((get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (get_window().mode == Window.MODE_FULLSCREEN)) func _ready(): - AppSettings.init_video_config() + AppSettings.init_video_config(get_window()) _update_ui() func _on_FullscreenButton_toggled(button_pressed): - AppSettings.set_fullscreen_enabled(button_pressed) + AppSettings.set_fullscreen_enabled(button_pressed, get_window()) diff --git a/Scenes/OptionsMenu/Video/VideoOptionsMenu.tscn b/Scenes/OptionsMenu/Video/VideoOptionsMenu.tscn index 3465de44..619ecfd8 100644 --- a/Scenes/OptionsMenu/Video/VideoOptionsMenu.tscn +++ b/Scenes/OptionsMenu/Video/VideoOptionsMenu.tscn @@ -8,28 +8,28 @@ anchor_bottom = 1.0 script = ExtResource( 1 ) [node name="VBoxContainer" type="VBoxContainer" parent="."] -margin_left = 362.0 -margin_top = 280.0 -margin_right = 662.0 -margin_bottom = 320.0 -rect_min_size = Vector2( 300, 0 ) +offset_left = 362.0 +offset_top = 280.0 +offset_right = 662.0 +offset_bottom = 320.0 +custom_minimum_size = Vector2( 300, 0 ) [node name="FullscreenControl" type="HBoxContainer" parent="VBoxContainer"] -margin_right = 300.0 -margin_bottom = 40.0 -rect_min_size = Vector2( 0, 40 ) +offset_right = 300.0 +offset_bottom = 40.0 +custom_minimum_size = Vector2( 0, 40 ) [node name="FullscreenLabel" type="Label" parent="VBoxContainer/FullscreenControl"] -margin_top = 13.0 -margin_right = 220.0 -margin_bottom = 27.0 +offset_top = 13.0 +offset_right = 220.0 +offset_bottom = 27.0 size_flags_horizontal = 3 text = "Fullscreen :" [node name="FullscreenButton" type="CheckButton" parent="VBoxContainer/FullscreenControl"] -margin_left = 224.0 -margin_right = 300.0 -margin_bottom = 40.0 +offset_left = 224.0 +offset_right = 300.0 +offset_bottom = 40.0 __meta__ = { "_edit_use_anchors_": false } diff --git a/Scenes/PauseMenu/PauseMenu.gd b/Scenes/PauseMenu/PauseMenu.gd index b20fda3c..3359f956 100644 --- a/Scenes/PauseMenu/PauseMenu.gd +++ b/Scenes/PauseMenu/PauseMenu.gd @@ -1,45 +1,74 @@ extends CanvasLayer -func _input(event): +@export var options_packed_scene : PackedScene +@export_file("*.tscn") var main_menu_scene : String + +var popup_open + +func close_popup(): + if popup_open != null and popup_open.visible: + popup_open.hide() + popup_open == null + +func close_options_menu(): + %SubMenuContainer.hide() + %MenuButtons.show() + +func open_options_menu(): + %SubMenuContainer.show() + %MenuButtons.hide() + +func _unhandled_key_input(event): if event.is_action_pressed("ui_cancel"): - if $Control/ConfirmExit.visible: - $Control/ConfirmExit.hide() - elif $Control/ConfirmMainMenu.visible: - $Control/ConfirmMainMenu.hide() - elif $Control/OptionsMenu.visible: - $Control/OptionsMenu.visible = false - $Control/ButtonsContainer.visible = true - else: + if popup_open == null: InGameMenuController.close_menu() + else: + close_popup() + close_options_menu() + +func _setup_options(): + if options_packed_scene == null: + %OptionsButton.hide() + else: + var options_scene = options_packed_scene.instantiate() + %OptionsContainer.call_deferred("add_child", options_scene) +func _setup_main_menu(): + if main_menu_scene.is_empty(): + %MainMenuButton.hide() -func _on_ResumeBtn_pressed(): +func _ready(): + if OS.has_feature("web"): + %ExitButton.hide() + _setup_options() + _setup_main_menu() + +func _on_resume_button_pressed(): InGameMenuController.close_menu() -func _on_RestartBtn_pressed(): - $Control/ConfirmRestart.popup_centered() +func _on_restart_button_pressed(): + %ConfirmRestart.popup_centered() -func _on_OptionsBtn_pressed(): - $Control/ButtonsContainer.visible = false - $Control/OptionsMenu.visible = true +func _on_options_button_pressed(): + open_options_menu() -func _on_MainMenuBtn_pressed(): - $Control/ConfirmMainMenu.popup_centered() +func _on_main_menu_button_pressed(): + %ConfirmMainMenu.popup_centered() -func _on_ExitBtn_pressed(): - $Control/ConfirmExit.popup_centered() +func _on_exit_button_pressed(): + %ConfirmExit.popup_centered() -func _on_ConfirmRestart_confirmed(): +func _on_confirm_restart_confirmed(): SceneLoader.reload_current_scene() - -func _on_ConfirmMainMenu_confirmed(): InGameMenuController.close_menu() + +func _on_confirm_main_menu_confirmed(): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - get_tree().change_scene("res://Scenes/MainMenu/MainMenu.tscn") + SceneLoader.load_scene(main_menu_scene) + InGameMenuController.close_menu() -func _on_ConfirmExit_confirmed(): +func _on_confirm_exit_confirmed(): get_tree().quit() -func _ready(): - if OS.has_feature("web"): - $Control/ButtonsContainer/ExitBtn.hide() +func _on_back_button_pressed(): + close_options_menu() diff --git a/Scenes/PauseMenu/PauseMenu.tscn b/Scenes/PauseMenu/PauseMenu.tscn index 119a92e8..43635465 100644 --- a/Scenes/PauseMenu/PauseMenu.tscn +++ b/Scenes/PauseMenu/PauseMenu.tscn @@ -1,106 +1,124 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=5 format=3 uid="uid://cdwvtbtwmrqbn"] -[ext_resource path="res://Scenes/OptionsMenu/OptionsMenu.tscn" type="PackedScene" id=1] -[ext_resource path="res://Scenes/PauseMenu/PauseMenu.gd" type="Script" id=2] -[ext_resource path="res://Themes/MainMenuTheme.tres" type="Theme" id=3] -[ext_resource path="res://Scenes/UI/SoundButton/SoundButton.tscn" type="PackedScene" id=4] +[ext_resource type="PackedScene" uid="uid://vh1ucj2rfbby" path="res://Scenes/OptionsMenu/OptionsMenu.tscn" id="1"] +[ext_resource type="Script" path="res://Scenes/PauseMenu/PauseMenu.gd" id="2"] +[ext_resource type="Theme" path="res://Themes/BaseTheme.tres" id="2_wxnmy"] +[ext_resource type="PackedScene" uid="uid://doj1dmgtf0a71" path="res://Scenes/UI/SoundButton/SoundButton.tscn" id="4"] [node name="PauseMenu" type="CanvasLayer"] -pause_mode = 2 +process_mode = 3 layer = 10 -script = ExtResource( 2 ) +script = ExtResource("2") +options_packed_scene = ExtResource("1") +main_menu_scene = "res://Scenes/MainMenu/MainMenu.tscn" -[node name="Control" type="Control" parent="."] +[node name="Background" type="ColorRect" parent="."] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -theme = ExtResource( 3 ) +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 1) -[node name="Background" type="ColorRect" parent="Control"] +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = 256.0 -margin_right = -256.0 -color = Color( 0, 0, 0, 1 ) - -[node name="Title" type="Label" parent="Control"] -anchor_left = 0.5 -anchor_right = 0.5 -margin_left = -93.5 -margin_top = 50.0 -margin_right = 93.5 -margin_bottom = 131.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 +theme = ExtResource("2_wxnmy") + +[node name="MarginContainer" type="MarginContainer" parent="Control"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="Control/MarginContainer"] +layout_mode = 2 + +[node name="Title" type="Label" parent="Control/MarginContainer/VBoxContainer"] +layout_mode = 2 text = "Pause" -align = 1 - -[node name="ButtonsContainer" type="VBoxContainer" parent="Control"] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -116.5 -margin_top = -116.0 -margin_right = 116.5 -margin_bottom = 116.0 -custom_constants/separation = 24 - -[node name="ResumeBtn" parent="Control/ButtonsContainer" instance=ExtResource( 4 )] -margin_right = 233.0 -margin_bottom = 40.0 +horizontal_alignment = 1 + +[node name="MenuButtons" type="VBoxContainer" parent="Control/MarginContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +theme_override_constants/separation = 24 + +[node name="ResumeButton" parent="Control/MarginContainer/VBoxContainer/MenuButtons" instance=ExtResource("4")] +layout_mode = 2 text = "Resume" -[node name="RestartBtn" parent="Control/ButtonsContainer" instance=ExtResource( 4 )] -margin_top = 64.0 -margin_right = 233.0 -margin_bottom = 104.0 +[node name="RestartButton" parent="Control/MarginContainer/VBoxContainer/MenuButtons" instance=ExtResource("4")] +layout_mode = 2 text = "Restart" -[node name="OptionsBtn" parent="Control/ButtonsContainer" instance=ExtResource( 4 )] -margin_top = 128.0 -margin_right = 233.0 -margin_bottom = 168.0 +[node name="OptionsButton" parent="Control/MarginContainer/VBoxContainer/MenuButtons" instance=ExtResource("4")] +unique_name_in_owner = true +layout_mode = 2 text = "Options" -[node name="MainMenuBtn" parent="Control/ButtonsContainer" instance=ExtResource( 4 )] -margin_top = 192.0 -margin_right = 233.0 -margin_bottom = 232.0 +[node name="MainMenuButton" parent="Control/MarginContainer/VBoxContainer/MenuButtons" instance=ExtResource("4")] +unique_name_in_owner = true +layout_mode = 2 text = "Return to Main Menu" -[node name="ExitBtn" parent="Control/ButtonsContainer" instance=ExtResource( 4 )] -margin_top = 256.0 -margin_right = 233.0 -margin_bottom = 296.0 +[node name="ExitButton" parent="Control/MarginContainer/VBoxContainer/MenuButtons" instance=ExtResource("4")] +unique_name_in_owner = true +layout_mode = 2 text = "Exit Game" +[node name="CenterContainer" type="CenterContainer" parent="Control"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="SubMenuContainer" type="VBoxContainer" parent="Control/CenterContainer"] +unique_name_in_owner = true +visible = false +layout_mode = 2 + +[node name="OptionsContainer" type="MarginContainer" parent="Control/CenterContainer/SubMenuContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 3 + +[node name="HBoxContainer" type="HBoxContainer" parent="Control/CenterContainer/SubMenuContainer"] +layout_mode = 2 +alignment = 1 + +[node name="BackButton" type="Button" parent="Control/CenterContainer/SubMenuContainer/HBoxContainer"] +layout_mode = 2 +text = "back" + [node name="ConfirmRestart" type="ConfirmationDialog" parent="Control"] -margin_right = 266.0 -margin_bottom = 72.0 -popup_exclusive = true -window_title = "Confirm" +unique_name_in_owner = true dialog_text = "Restart the game?" [node name="ConfirmMainMenu" type="ConfirmationDialog" parent="Control"] -margin_right = 200.0 -margin_bottom = 70.0 -popup_exclusive = true -window_title = "Confirm" +unique_name_in_owner = true dialog_text = "Go back to main menu?" [node name="ConfirmExit" type="ConfirmationDialog" parent="Control"] -margin_right = 200.0 -margin_bottom = 70.0 -popup_exclusive = true -window_title = "Confirm" +unique_name_in_owner = true dialog_text = "Quit the game?" -[node name="OptionsMenu" parent="Control" instance=ExtResource( 1 )] -visible = false - -[connection signal="pressed" from="Control/ButtonsContainer/ResumeBtn" to="." method="_on_ResumeBtn_pressed"] -[connection signal="pressed" from="Control/ButtonsContainer/RestartBtn" to="." method="_on_RestartBtn_pressed"] -[connection signal="pressed" from="Control/ButtonsContainer/OptionsBtn" to="." method="_on_OptionsBtn_pressed"] -[connection signal="pressed" from="Control/ButtonsContainer/MainMenuBtn" to="." method="_on_MainMenuBtn_pressed"] -[connection signal="pressed" from="Control/ButtonsContainer/ExitBtn" to="." method="_on_ExitBtn_pressed"] -[connection signal="confirmed" from="Control/ConfirmRestart" to="." method="_on_ConfirmRestart_confirmed"] -[connection signal="confirmed" from="Control/ConfirmMainMenu" to="." method="_on_ConfirmMainMenu_confirmed"] -[connection signal="confirmed" from="Control/ConfirmExit" to="." method="_on_ConfirmExit_confirmed"] +[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/MenuButtons/ResumeButton" to="." method="_on_resume_button_pressed"] +[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/MenuButtons/RestartButton" to="." method="_on_restart_button_pressed"] +[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/MenuButtons/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/MenuButtons/MainMenuButton" to="." method="_on_main_menu_button_pressed"] +[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/MenuButtons/ExitButton" to="." method="_on_exit_button_pressed"] +[connection signal="pressed" from="Control/CenterContainer/SubMenuContainer/HBoxContainer/BackButton" to="." method="_on_back_button_pressed"] +[connection signal="confirmed" from="Control/ConfirmRestart" to="." method="_on_confirm_restart_confirmed"] +[connection signal="confirmed" from="Control/ConfirmMainMenu" to="." method="_on_confirm_main_menu_confirmed"] +[connection signal="confirmed" from="Control/ConfirmExit" to="." method="_on_confirm_exit_confirmed"] diff --git a/Scenes/UI/KeyBindingControl/KeyBindingControl.gd b/Scenes/UI/KeyBindingControl/KeyBindingControl.gd index 2adf6fa3..e6bf5b18 100644 --- a/Scenes/UI/KeyBindingControl/KeyBindingControl.gd +++ b/Scenes/UI/KeyBindingControl/KeyBindingControl.gd @@ -1,10 +1,10 @@ -tool +@tool extends HBoxContainer signal edit_button_pressed -export(String) var action_name : String = "Action" setget set_action_name -export(int) var scancode : int = 0 setget set_scancode +@export var action_name: String = "Action": set = set_action_name +@export var keycode: int = 0: set = set_keycode func set_action_name(value : String) -> void: action_name = value @@ -13,12 +13,12 @@ func set_action_name(value : String) -> void: return node.text = "%s :" % action_name -func set_scancode(value : int) -> void: - scancode = value +func set_keycode(value : int) -> void: + keycode = value var node = get_node_or_null("AssignedKeyLabel") if node == null: return - node.text = OS.get_scancode_string(scancode) + node.text = OS.get_keycode_string(keycode) func _on_EditButton_pressed(): emit_signal("edit_button_pressed") diff --git a/Scenes/UI/KeyBindingControl/KeyBindingControl.tscn b/Scenes/UI/KeyBindingControl/KeyBindingControl.tscn index 2c8c9a25..ec920f6b 100644 --- a/Scenes/UI/KeyBindingControl/KeyBindingControl.tscn +++ b/Scenes/UI/KeyBindingControl/KeyBindingControl.tscn @@ -1,34 +1,26 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://b3cfalxu0jjtr"] -[ext_resource path="res://Scenes/UI/KeyBindingControl/KeyBindingControl.gd" type="Script" id=1] +[ext_resource type="Script" path="res://Scenes/UI/KeyBindingControl/KeyBindingControl.gd" id="1"] [node name="KeyBindingControl" type="HBoxContainer"] -margin_right = 300.0 -margin_bottom = 40.0 -rect_min_size = Vector2( 0, 40 ) -script = ExtResource( 1 ) -scancode = 69 +custom_minimum_size = Vector2(0, 40) +offset_right = 300.0 +offset_bottom = 40.0 +script = ExtResource("1") +keycode = 69 [node name="ActionLabel" type="Label" parent="."] -margin_top = 13.0 -margin_right = 80.0 -margin_bottom = 27.0 -rect_min_size = Vector2( 80, 0 ) +custom_minimum_size = Vector2(80, 0) +layout_mode = 2 text = "Action :" [node name="AssignedKeyLabel" type="Label" parent="."] -margin_left = 84.0 -margin_top = 13.0 -margin_right = 259.0 -margin_bottom = 27.0 +layout_mode = 2 size_flags_horizontal = 3 text = "E" -align = 1 [node name="EditButton" type="Button" parent="."] -margin_left = 263.0 -margin_right = 300.0 -margin_bottom = 40.0 +layout_mode = 2 text = "edit" [connection signal="pressed" from="EditButton" to="." method="_on_EditButton_pressed"] diff --git a/Scenes/UI/ResetGameControl/ResetGameControl.gd b/Scenes/UI/ResetGameControl/ResetGameControl.gd index 65955c29..b3d4b98b 100644 --- a/Scenes/UI/ResetGameControl/ResetGameControl.gd +++ b/Scenes/UI/ResetGameControl/ResetGameControl.gd @@ -10,5 +10,5 @@ func _on_ResetButton_pressed(): func _on_ConfirmResetDialog_confirmed(): emit_signal("reset_confirmed") -func _on_ConfirmResetDialog_popup_hide(): +func _on_confirm_reset_dialog_canceled(): $ResetButton.disabled = false diff --git a/Scenes/UI/ResetGameControl/ResetGameControl.tscn b/Scenes/UI/ResetGameControl/ResetGameControl.tscn index 70c5fae0..377d9698 100644 --- a/Scenes/UI/ResetGameControl/ResetGameControl.tscn +++ b/Scenes/UI/ResetGameControl/ResetGameControl.tscn @@ -1,35 +1,27 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://cay00igbuqtfa"] -[ext_resource path="res://Scenes/UI/ResetGameControl/ResetGameControl.gd" type="Script" id=1] +[ext_resource type="Script" path="res://Scenes/UI/ResetGameControl/ResetGameControl.gd" id="1"] [node name="ResetGameControl" type="HBoxContainer"] -margin_top = 210.0 -margin_right = 305.0 -margin_bottom = 242.0 -rect_min_size = Vector2( 0, 32 ) -script = ExtResource( 1 ) +custom_minimum_size = Vector2(0, 32) +offset_top = 210.0 +offset_right = 305.0 +offset_bottom = 242.0 +script = ExtResource("1") [node name="ResetLabel" type="Label" parent="."] -margin_top = 9.0 -margin_right = 229.0 -margin_bottom = 23.0 +layout_mode = 2 size_flags_horizontal = 3 text = "Reset Game :" [node name="ResetButton" type="Button" parent="."] -margin_left = 233.0 -margin_right = 305.0 -margin_bottom = 32.0 -rect_min_size = Vector2( 72, 32 ) +custom_minimum_size = Vector2(72, 32) +layout_mode = 2 text = "reset" [node name="ConfirmResetDialog" type="ConfirmationDialog" parent="."] -margin_right = 200.0 -margin_bottom = 70.0 -popup_exclusive = true -window_title = "Confirm" dialog_text = "Do you want to reset your game data?" [connection signal="pressed" from="ResetButton" to="." method="_on_ResetButton_pressed"] +[connection signal="canceled" from="ConfirmResetDialog" to="." method="_on_confirm_reset_dialog_canceled"] [connection signal="confirmed" from="ConfirmResetDialog" to="." method="_on_ConfirmResetDialog_confirmed"] -[connection signal="popup_hide" from="ConfirmResetDialog" to="." method="_on_ConfirmResetDialog_popup_hide"] diff --git a/Scenes/UI/SoundButton/SoundButton.tscn b/Scenes/UI/SoundButton/SoundButton.tscn index 98188c5e..8b4b8736 100644 --- a/Scenes/UI/SoundButton/SoundButton.tscn +++ b/Scenes/UI/SoundButton/SoundButton.tscn @@ -1,27 +1,27 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=4 format=3 uid="uid://doj1dmgtf0a71"] -[ext_resource path="res://Scenes/UI/SoundButton/SoundButton.gd" type="Script" id=1] +[ext_resource type="Script" path="res://Scenes/UI/SoundButton/SoundButton.gd" id="1"] -[sub_resource type="AudioStreamRandomPitch" id=1] +[sub_resource type="AudioStreamRandomizer" id="1"] random_pitch = 1.05 -[sub_resource type="AudioStreamRandomPitch" id=2] +[sub_resource type="AudioStreamRandomizer" id="2"] random_pitch = 1.05 [node name="SoundButton" type="Button"] -rect_min_size = Vector2( 0, 40 ) -script = ExtResource( 1 ) +custom_minimum_size = Vector2(0, 40) +script = ExtResource("1") [node name="AudioStreamPlayers" type="Node" parent="."] [node name="HoverSound" type="AudioStreamPlayer" parent="AudioStreamPlayers"] -stream = SubResource( 1 ) +stream = SubResource("1") volume_db = -16.0 -bus = "SFX" +bus = &"SFX" [node name="ClickSound" type="AudioStreamPlayer" parent="AudioStreamPlayers"] -stream = SubResource( 2 ) +stream = SubResource("2") volume_db = -8.0 -bus = "SFX" +bus = &"SFX" [connection signal="mouse_entered" from="." to="." method="_on_SoundButton_mouse_entered"] diff --git a/Scripts/AppSettings.gd b/Scripts/AppSettings.gd index e41b278c..483017ff 100644 --- a/Scripts/AppSettings.gd +++ b/Scripts/AppSettings.gd @@ -17,9 +17,8 @@ const INPUT_MAP_2D : Dictionary = { "move_down" : "Down", "move_left" : "Left", "move_right" : "Right", - "run" : "Run", + "dash" : "Dash", "interact" : "Interact", - "skip_turn" : "Skip Turn", } const INPUT_MAP_3D : Dictionary = { @@ -31,27 +30,27 @@ const INPUT_MAP_3D : Dictionary = { "jump" : "Jump", "interact" : "Interact", } -const INPUT_MAP = INPUT_MAP_3D +const INPUT_MAP = INPUT_MAP_2D # Input static func get_action_scancode(action_name : String, default = null) -> int: return Config.get_config(INPUT_SECTION, action_name, default) -static func set_action_scancode(action_name : String, scancode : int) -> void: - Config.set_config(INPUT_SECTION, action_name, scancode) +static func set_action_scancode(action_name : String, keycode : int) -> void: + Config.set_config(INPUT_SECTION, action_name, keycode) static func get_input_actions() -> Array: return Config.get_section_keys(INPUT_SECTION) static func get_input_event_scancode(action_event : InputEventKey) -> int: - if action_event.scancode != 0: - return action_event.get_scancode_with_modifiers() + if action_event.keycode != 0: + return action_event.get_keycode_with_modifiers() else: - return OS.keyboard_get_scancode_from_physical(action_event.get_physical_scancode_with_modifiers()) + return action_event.get_physical_keycode_with_modifiers() static func reset_input_config() -> void: for action_name in INPUT_MAP.keys(): - var action_events : Array = InputMap.get_action_list(action_name) + var action_events : Array = InputMap.action_get_events(action_name) if action_events.size() == 0: continue var action_event : InputEventWithModifiers = action_events[0] @@ -59,10 +58,10 @@ static func reset_input_config() -> void: set_action_scancode(action_name, get_input_event_scancode(action_event)) static func set_input_from_config(action_name : String) -> void: - var scancode = get_action_scancode(action_name) + var keycode = get_action_scancode(action_name) var event = InputEventKey.new() - event.scancode = scancode - for old_event in InputMap.get_action_list(action_name): + event.keycode = keycode + for old_event in InputMap.action_get_events(action_name): if old_event is InputEventKey: InputMap.action_erase_event(action_name, old_event) InputMap.action_add_event(action_name, event) @@ -84,13 +83,13 @@ static func get_bus_volume(bus_name : String) -> float: if bus_index < 0: return 0.0 var volume_db : float = AudioServer.get_bus_volume_db(bus_index) - return db2linear(volume_db) + return db_to_linear(volume_db) static func set_bus_volume(bus_name : String, linear : float) -> void: var bus_index : int = AudioServer.get_bus_index(bus_name) if bus_index < 0: return - var volume_db : float = linear2db(linear) + var volume_db : float = linear_to_db(linear) AudioServer.set_bus_volume_db(bus_index, volume_db) Config.set_config(AUDIO_SECTION, bus_name, linear) @@ -135,27 +134,27 @@ static func init_audio_config() -> void: # Video -static func set_fullscreen_enabled(value : bool) -> void: - OS.window_fullscreen = value +static func set_fullscreen_enabled(value : bool, window : Window) -> void: + window.mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (value) else Window.MODE_WINDOWED Config.set_config(VIDEO_SECTION, FULLSCREEN_ENABLED, value) -static func reset_video_config() -> void: - Config.set_config(VIDEO_SECTION, FULLSCREEN_ENABLED, OS.window_fullscreen) +static func reset_video_config(window : Window) -> void: + Config.set_config(VIDEO_SECTION, FULLSCREEN_ENABLED, ((window.mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (window.mode == Window.MODE_FULLSCREEN))) -static func set_video_from_config() -> void: - var fullscreen_enabled : bool = OS.window_fullscreen +static func set_video_from_config(window : Window) -> void: + var fullscreen_enabled : bool = (window.mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (window.mode == Window.MODE_FULLSCREEN) fullscreen_enabled = Config.get_config(VIDEO_SECTION, FULLSCREEN_ENABLED, fullscreen_enabled) - OS.window_fullscreen = fullscreen_enabled + window.mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (fullscreen_enabled) else Window.MODE_WINDOWED -static func init_video_config() -> void: +static func init_video_config(window : Window) -> void: if not Config.has_section(VIDEO_SECTION): # reset_video_config() return - set_video_from_config() + set_video_from_config(window) # All -static func initialize_from_config() -> void: +static func initialize_from_config(window : Window) -> void: init_input_config() init_audio_config() - init_video_config() + init_video_config(window) diff --git a/Scripts/Config.gd b/Scripts/Config.gd index 944e4f1d..a5e4b477 100644 --- a/Scripts/Config.gd +++ b/Scripts/Config.gd @@ -40,4 +40,4 @@ func get_section_keys(section: String): load_config_file() if config_file.has_section(section): return config_file.get_section_keys(section) - return PoolStringArray() + return PackedStringArray() diff --git a/Scripts/InGameMenuController.gd b/Scripts/InGameMenuController.gd index 99777f52..f25ca785 100644 --- a/Scripts/InGameMenuController.gd +++ b/Scripts/InGameMenuController.gd @@ -8,8 +8,8 @@ func open_menu(menu_scene : PackedScene, set_pause : bool = true) -> void: return saved_mouse_mode = Input.get_mouse_mode() Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - current_menu = menu_scene.instance() - get_tree().current_scene.add_child(current_menu) + current_menu = menu_scene.instantiate() + get_tree().current_scene.call_deferred("add_child", current_menu) get_tree().paused = set_pause func close_menu() -> void: diff --git a/Scripts/PauseMenuController.gd b/Scripts/PauseMenuController.gd index c8c02af0..6d44d7f1 100644 --- a/Scripts/PauseMenuController.gd +++ b/Scripts/PauseMenuController.gd @@ -1,16 +1,7 @@ -extends Control +extends Node -var pause_menu_packed = preload("res://Scenes/PauseMenu/PauseMenu.tscn") - -var can_pause = true # to prevent from instantly repausing after unpaused from the pause menu by pressing ui_cancel - -func _gui_input(event): - if event is InputEventMouseButton and Input.mouse_mode != Input.MOUSE_MODE_CAPTURED: - Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) +@export var pause_menu_packed : PackedScene func _input(event): - if event is InputEventKey and event.is_action_pressed("ui_cancel") and can_pause: - can_pause = false + if event is InputEventKey and event.is_action_pressed("ui_cancel"): InGameMenuController.open_menu(pause_menu_packed) - else: - can_pause = true diff --git a/Scripts/SceneLoader.gd b/Scripts/SceneLoader.gd index b2538238..5834d18c 100644 --- a/Scripts/SceneLoader.gd +++ b/Scripts/SceneLoader.gd @@ -2,20 +2,36 @@ extends Node var loading_screen = preload("res://Scenes/LoadingScreen/LoadingScreen.tscn") -var loader : ResourceInteractiveLoader var scene_to_load : String func reload_current_scene() -> void: - load_scene(scene_to_load) + get_tree().reload_current_scene() func load_scene(path : String) -> void: if path == "": return - if scene_to_load != path or loader == null: + if scene_to_load != path: scene_to_load = path - loader = ResourceLoader.load_interactive(scene_to_load) + ResourceLoader.load_threaded_request(scene_to_load) get_tree().paused = false - var err = get_tree().change_scene_to(loading_screen) + var err = get_tree().change_scene_to_packed(loading_screen) if err: print("failed to load loading screen: %d" % err) get_tree().quit() + +func get_status(): + if scene_to_load == null or scene_to_load == "": + return ResourceLoader.THREAD_LOAD_INVALID_RESOURCE + return ResourceLoader.load_threaded_get_status(scene_to_load) + +func get_progress(): + if scene_to_load == null or scene_to_load == "": + return + var progress_array : Array = [] + ResourceLoader.load_threaded_get_status(scene_to_load, progress_array) + return progress_array.pop_back() + +func get_resource(): + if scene_to_load == null or scene_to_load == "": + return ResourceLoader.THREAD_LOAD_INVALID_RESOURCE + return ResourceLoader.load_threaded_get(scene_to_load) diff --git a/Themes/MainMenuTheme.tres b/Themes/BaseTheme.tres similarity index 100% rename from Themes/MainMenuTheme.tres rename to Themes/BaseTheme.tres diff --git a/default_env.tres b/default_env.tres index 20207a4a..d49911ea 100644 --- a/default_env.tres +++ b/default_env.tres @@ -1,7 +1,7 @@ -[gd_resource type="Environment" load_steps=2 format=2] +[gd_resource type="Environment" load_steps=2 format=3 uid="uid://dg6gkweta8kyo"] -[sub_resource type="ProceduralSky" id=1] +[sub_resource type="Sky" id="1"] [resource] background_mode = 2 -background_sky = SubResource( 1 ) +sky = SubResource("1") diff --git a/project.godot b/project.godot index 73de7551..52994d73 100644 --- a/project.godot +++ b/project.godot @@ -6,34 +6,13 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 - -_global_script_classes=[ { -"base": "Node", -"class": "AppLog", -"language": "GDScript", -"path": "res://Scripts/AppLog.gd" -}, { -"base": "Node", -"class": "AppSettings", -"language": "GDScript", -"path": "res://Scripts/AppSettings.gd" -}, { -"base": "Node", -"class": "GameLog", -"language": "GDScript", -"path": "res://Scripts/GameLog.gd" -} ] -_global_script_class_icons={ -"AppLog": "", -"AppSettings": "", -"GameLog": "" -} +config_version=5 [application] config/name="Game Template" run/main_scene="res://Scenes/InitApp/InitApp.tscn" +config/features=PackedStringArray("4.1") config/icon="res://icon.png" [autoload] @@ -49,45 +28,41 @@ common/drop_mouse_on_gui_input_disabled=true [input] -ui_mute={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":77,"unicode":0,"echo":false,"script":null) - ] -} -move_forward={ +move_up={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null) +] } -move_backward={ +move_down={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null) +] } move_left={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":65,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null) +] } move_right={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":68,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null) +] } -run={ +dash={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777237,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) +, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null) +] } -jump={ +shoot={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":32,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) +] } interact={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":69,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null) +] } [physics] @@ -96,4 +71,4 @@ common/enable_pause_aware_picking=true [rendering] -environment/default_environment="res://default_env.tres" +environment/defaults/default_environment="res://default_env.tres"