diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-06-03 20:37:10 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2023-06-03 20:37:10 +0200 |
commit | cef940108fe15752c3ef66f43f5169403fa2f71d (patch) | |
tree | fe4de5a05830e3bddeae78f74f729503b7cee1e9 /game/src/Game/Menu | |
parent | 73e29d02e48739aba5ca5db1b9575c67e795400f (diff) |
Reorganize the file structure of the files in `game/src`
Diffstat (limited to 'game/src/Game/Menu')
42 files changed, 2377 insertions, 0 deletions
diff --git a/game/src/Game/Menu/CreditsMenu/CreditsMenu.gd b/game/src/Game/Menu/CreditsMenu/CreditsMenu.gd new file mode 100644 index 0000000..0db4d7d --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/CreditsMenu.gd @@ -0,0 +1,200 @@ +extends Control + +signal back_button_pressed + +############### +# Credits CSV format +# The project title row is the only requirement within the csv file, however +# it can be on any row, so long as it exists. +# ---------------------- +# title,project-title +# role-name,person-name +# role-name,person-name +# role-name,person-name +# ... +############### + +@export_file("*.csv") +var core_credits_path : String + +@export +var godot_engine_scene : PackedScene + +@export_group("Label Variants", "label_variants_") +@export +var label_variants_project : StringName + +@export +var label_variants_role : StringName + +@export +var label_variants_person : StringName + +@export +var credits_list: VBoxContainer + +const title_key : String = "TITLE" + +# REQUIREMENTS: +# * 1.5 Credits Menu +# * SS-17 + +# REQUIREMENTS +# * FS-4 +func _load_credit_file(path : String) -> Dictionary: + var roles := {} + var core_credits = FileAccess.open(path, FileAccess.READ) + if core_credits == null: + push_error("Failed to open credits file %s (error code %d)" % [path, FileAccess.get_open_error()]) + return roles + + while not core_credits.eof_reached(): + var line := core_credits.get_csv_line() + var role := line[0].strip_edges().to_upper() + + # If the line does not have an identifiable role or is empty then skip it + if role.is_empty() or line.size() < 2: + if not (role.is_empty() and line.size() < 2): + push_warning("Incorrectly formatted credit line %s in %s" % [line, path]) + continue + + var person := line[1].strip_edges() + + if person.is_empty(): + push_warning("Incorrectly formatted credit line %s in %s" % [line, path]) + continue + if line.size() > 2: + push_warning("Extra entries ignored in credit line %s in %s" % [line, path]) + + if role not in roles: + roles[role] = [person] + else: + if person in roles[role]: + push_warning("Duplicate person %s for role %s in %s" % [person, role, path]) + else: + roles[role].push_back(person) + if title_key in roles: + if roles[title_key].size() > 1: + push_warning("More than one %s: %s in %s" % [title_key, roles[title_key], path]) + roles[title_key] = [roles[title_key][0]] + else: + push_warning("Credits file %s missing %s" % [path, title_key]) + for role_list in roles.values(): + role_list.sort_custom(func(a : String, b : String) -> bool: return a.naturalnocasecmp_to(b) < 0) + return roles + +func _add_label(node : Node, text : String, type_variation : StringName) -> void: + var label := Label.new() + label.name = 'Label' + text + label.text = text + label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + label.theme_type_variation = type_variation + node.add_child(label) + +# REQUIREMENTS: +# * UI-34, UI-35 +func _add_project_credits(project : Dictionary) -> void: + var project_credits_list = VBoxContainer.new() + project_credits_list.name = 'Credits' + if title_key in project: + var title : String = project[title_key][0] + project_credits_list.name += title + _add_label(project_credits_list, title, label_variants_project) + project_credits_list.add_child(HSeparator.new()) + + for role in project: + if role == title_key: + continue + + var role_parent = VBoxContainer.new() + + for person in project[role]: + _add_label(role_parent, person, label_variants_person) + + _add_label(project_credits_list, role, label_variants_role) + project_credits_list.add_child(role_parent) + project_credits_list.add_child(HSeparator.new()) + + credits_list.add_child(project_credits_list) + +func _add_godot_credits() -> void: + var godot_credits_list = VBoxContainer.new() + godot_credits_list.name = 'CreditsGodot' + var godot_engine = godot_engine_scene.instantiate() + godot_credits_list.add_child(godot_engine) + godot_credits_list.add_child(HSeparator.new()) + + var author_dict := Engine.get_author_info() + _add_label(godot_credits_list, "Contributors", label_variants_role) + + for role in author_dict: + var role_parent = VBoxContainer.new() + + for person in author_dict[role]: + _add_label(role_parent, person, label_variants_person) + + _add_label(godot_credits_list, role.replace("_", " ").capitalize(), label_variants_role) + godot_credits_list.add_child(role_parent) + godot_credits_list.add_child(HSeparator.new()) + + var donor_dict := Engine.get_donor_info() + _add_label(godot_credits_list, "Donors", label_variants_role) + + for role in donor_dict: + if donor_dict[role].size() == 0 or donor_dict[role][0].begins_with("None"): continue + var role_parent = VBoxContainer.new() + + for person in donor_dict[role]: + _add_label(role_parent, person, label_variants_person) + + _add_label(godot_credits_list, role.replace("_", " ").capitalize(), label_variants_role) + godot_credits_list.add_child(role_parent) + godot_credits_list.add_child(HSeparator.new()) + + credits_list.add_child(godot_credits_list) + +func _add_link_button(node : Node, text : String, url: String, type_variation : StringName) -> void: + var button := LinkButton.new() + button.name = 'LinkButton' + text + button.text = text + button.uri = url + button.size_flags_horizontal = SIZE_SHRINK_CENTER + button.theme_type_variation = type_variation + node.add_child(button) + +func _add_licenses() -> void: + var license_list = VBoxContainer.new() + license_list.name = 'Licenses' + _add_label(license_list, "Third-Party Licenses", label_variants_project) + license_list.add_child(HSeparator.new()) + + var license_info := { + "OpenVic": ["GPLv3", "https://github.com/OpenVicProject/OpenVic/blob/main/LICENSE.md"], + "Godot": ["MIT", "https://github.com/godotengine/godot/blob/master/LICENSE.txt"], + "FreeType": ["FreeType License", "https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/docs/FTL.TXT"], + "ENet": ["MIT", "http://enet.bespin.org/License.html"], + "mbed TLS": ["APLv2", "https://github.com/Mbed-TLS/mbedtls/blob/development/LICENSE"] + } + # Add additional licenses required for attribution here + # These licenses should also either be displayed or exported alongside this project + + for project in license_info: + _add_label(license_list, project, label_variants_role) + _add_link_button(license_list, license_info[project][0], license_info[project][1], label_variants_person) + license_list.add_child(HSeparator.new()) + + credits_list.add_child(license_list) + + +# REQUIREMENTS: +# * SS-17 +func _ready(): + _add_project_credits(_load_credit_file(core_credits_path)) + _add_godot_credits() + _add_licenses() + +# REQUIREMENTS: +# * UI-38 +# * UIFUN-37 +func _on_back_button_pressed() -> void: + back_button_pressed.emit() diff --git a/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn b/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn new file mode 100644 index 0000000..2d10d2e --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn @@ -0,0 +1,50 @@ +[gd_scene load_steps=4 format=3 uid="uid://c8knthxkwj1uj"] + +[ext_resource type="Theme" uid="uid://stfxt4hpsify" path="res://theme/credits_menu.tres" id="1_7y4l8"] +[ext_resource type="Script" path="res://src/CreditsMenu/CreditsMenu.gd" id="1_csd7i"] +[ext_resource type="PackedScene" uid="uid://ddjbee5gj6bkv" path="res://src/CreditsMenu/GodotEngineButton.tscn" id="3_fl02a"] + +[node name="CreditsMenu" type="Control" node_paths=PackedStringArray("credits_list")] +editor_description = "UI-34" +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_7y4l8") +script = ExtResource("1_csd7i") +core_credits_path = "res://common/credits.csv" +godot_engine_scene = ExtResource("3_fl02a") +label_variants_project = &"ProjectLabel" +label_variants_role = &"RoleLabel" +label_variants_person = &"PersonLabel" +credits_list = NodePath("Scroll/CreditsList") + +[node name="ControlMargin" type="MarginContainer" parent="."] +layout_mode = 2 +anchor_right = 1.0 +anchor_bottom = 0.071 +offset_bottom = -0.120003 +theme_type_variation = &"BackButtonsMargin" + +[node name="BackButton" type="Button" parent="ControlMargin"] +editor_description = "UI-38" +layout_mode = 2 +text = "CREDITS_BACK" + +[node name="Scroll" type="ScrollContainer" parent="."] +editor_description = "UI-35" +layout_mode = 2 +anchor_top = 0.071 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -0.120003 +offset_bottom = -6.0 + +[node name="CreditsList" type="VBoxContainer" parent="Scroll"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[connection signal="pressed" from="ControlMargin/BackButton" to="." method="_on_back_button_pressed"] diff --git a/game/src/Game/Menu/CreditsMenu/GodotEngineButton.gd b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.gd new file mode 100644 index 0000000..ca3a958 --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.gd @@ -0,0 +1,4 @@ +extends Button + +func _on_pressed(): + OS.shell_open("https://godotengine.org") diff --git a/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn new file mode 100644 index 0000000..8b0c46b --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=3 uid="uid://ddjbee5gj6bkv"] + +[ext_resource type="Texture2D" uid="uid://rh7l4xuh4ali" path="res://src/CreditsMenu/logo_vertical_color_dark.svg" id="1_b0brk"] +[ext_resource type="Script" path="res://src/CreditsMenu/GodotEngineButton.gd" id="3_gi8fv"] + +[node name="GodotEngineButton" type="Button"] +custom_minimum_size = Vector2(0, 200) +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_vertical = 3 +icon = ExtResource("1_b0brk") +flat = true +icon_alignment = 1 +expand_icon = true +script = ExtResource("3_gi8fv") + +[connection signal="pressed" from="." to="." method="_on_pressed"] diff --git a/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg new file mode 100644 index 0000000..00e50cd --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg @@ -0,0 +1 @@ +<svg height="713.37085" viewBox="0 0 584.81677 668.78517" width="623.80457" xmlns="http://www.w3.org/2000/svg"><g fill="#eee" transform="matrix(1.25 0 0 -1.25 -469.43319 897.49284)"><path d="m0 0c-3.611 0-6.636-1.659-9.09-4.967-2.441-3.311-3.668-7.958-3.668-13.938 0-5.993 1.166-10.581 3.503-13.778 2.333-3.207 5.398-4.804 9.2-4.804 3.8 0 6.887 1.617 9.258 4.862 2.371 3.233 3.559 7.861 3.559 13.886 0 6.02-1.227 10.654-3.673 13.89-2.443 3.232-5.473 4.849-9.089 4.849m-.055-59.493c-10.573 0-19.195 3.46-25.859 10.379-6.655 6.925-9.984 17.03-9.984 30.314 0 13.292 3.367 23.356 10.101 30.209 6.736 6.844 15.431 10.269 26.082 10.269 10.649 0 19.251-3.363 25.794-10.109 6.555-6.733 9.827-16.94 9.827-30.591 0-13.661-3.348-23.822-10.05-30.49-6.702-6.654-15.333-9.981-25.911-9.981" transform="matrix(1.1310535 0 0 1.1310535 531.44953 355.31567)"/><path d="m0 0v-33.768c0-1.577.116-2.571.342-2.988.224-.415.903-.623 2.029-.623 4.144 0 7.283 1.548 9.429 4.634 2.151 3.083 3.215 8.216 3.215 15.405 0 7.192-1.113 11.878-3.325 14.055-2.223 2.183-5.744 3.285-10.561 3.285zm-21.675-52.392v67.735c0 1.883.468 3.369 1.413 4.471.939 1.085 2.161 1.636 3.671 1.636h18.854c11.965 0 21.053-3.018 27.257-9.04 6.215-6.02 9.322-15.499 9.322-28.447 0-27.7-11.821-41.547-35.456-41.547h-19.302c-3.836 0-5.759 1.727-5.759 5.192" transform="matrix(1.1310535 0 0 1.1310535 607.8515 354.43097)"/><path d="m0 0c-3.612 0-6.645-1.659-9.095-4.967-2.44-3.311-3.662-7.958-3.662-13.938 0-5.993 1.169-10.581 3.499-13.778 2.33-3.207 5.398-4.804 9.2-4.804 3.801 0 6.89 1.617 9.258 4.862 2.372 3.233 3.56 7.861 3.56 13.886 0 6.02-1.225 10.654-3.671 13.89-2.447 3.232-5.473 4.849-9.089 4.849m-.058-59.493c-10.577 0-19.193 3.46-25.851 10.379-6.663 6.925-9.993 17.03-9.993 30.314 0 13.292 3.367 23.356 10.1 30.209 6.741 6.844 15.431 10.269 26.086 10.269 10.651 0 19.246-3.363 25.797-10.109 6.55-6.733 9.822-16.94 9.822-30.591 0-13.661-3.349-23.822-10.05-30.49-6.699-6.654-15.338-9.981-25.911-9.981" transform="matrix(1.1310535 0 0 1.1310535 700.81066 355.31567)"/><path d="m0 0c0-1.496-3.721-2.255-11.176-2.255-7.448 0-11.18.759-11.18 2.255v56.681h-13.545c-1.281 0-2.185 1.727-2.71 5.198-.226 1.652-.334 3.343-.334 5.077 0 1.724.108 3.422.334 5.077.525 3.462 1.429 5.202 2.71 5.202h49.112c1.279 0 2.179-1.74 2.712-5.202.221-1.655.335-3.353.335-5.077 0-1.734-.114-3.425-.335-5.077-.533-3.471-1.433-5.198-2.712-5.198h-13.211z" transform="matrix(1.1310535 0 0 1.1310535 789.01132 291.33514)"/><path d="m0 0c-6.078.094-13.034-1.173-13.034-1.173v-11.863h6.995l-.078-5.288c0-1.959-1.942-2.943-5.815-2.943-3.878 0-7.303 1.642-10.274 4.917-2.978 3.279-4.459 8.072-4.459 14.388 0 6.329 1.447 10.995 4.345 14.006 2.892 3.008 6.683 4.517 11.346 4.517 1.959 0 3.987-.316 6.096-.961 2.11-.639 3.519-1.238 4.238-1.799.713-.577 1.391-.85 2.032-.85.638 0 1.671.746 3.1 2.255 1.431 1.505 2.713 3.786 3.844 6.827 1.126 3.057 1.69 5.4 1.69 7.062 0 1.649-.036 2.786-.109 3.386-1.581 1.73-4.499 3.102-8.755 4.122-4.248 1.017-9.011 1.522-14.28 1.522-11.594 0-20.66-3.65-27.207-10.95-6.552-7.303-9.822-16.783-9.822-28.452 0-13.701 3.347-24.087 10.041-31.162 6.706-7.074 15.51-10.607 26.425-10.607 5.87 0 11.08.505 15.632 1.522 4.557 1.013 7.586 2.053 9.093 3.105l.452 35.33c0 2.053-5.418 2.985-11.496 3.089" transform="matrix(1.1310535 0 0 1.1310535 468.26549 336.71278)"/></g><g fill="#ddd" transform="matrix(1.25 0 0 -1.25 -392.9327 897.49284)"><path d="m0 0c-.624-1.28-1.771-2.454-3.449-3.516-1.676-1.069-3.805-1.6-6.391-1.6-3.412 0-6.156 1.075-8.24 3.249-2.076 2.157-3.116 5.266-3.116 9.323v10.116c0 3.969.98 7.013 2.946 9.138 1.962 2.108 4.59 3.177 7.872 3.177 3.208 0 5.695-.844 7.455-2.513 1.755-1.675 2.677-4.015 2.757-7.003l-.044-.133h-2.619c-.094 2.29-.759 4.057-2.01 5.305-1.244 1.238-3.095 1.864-5.539 1.864-2.473 0-4.432-.837-5.866-2.516-1.43-1.675-2.143-4.103-2.143-7.293v-10.174c0-3.308.771-5.83 2.311-7.567 1.54-1.724 3.616-2.588 6.236-2.588 1.913 0 3.451.339 4.602 1.033 1.155.684 1.956 1.519 2.409 2.51v8.861h-7.06v2.463h9.889z" transform="matrix(1.1310535 0 0 1.1310535 441.34721 235.75121)"/><path d="m0 0c1.553 0 2.936.44 4.144 1.336 1.21.9 2.058 2.037 2.561 3.422v5.468h-4.492c-1.91 0-3.44-.541-4.585-1.623-1.148-1.075-1.716-2.418-1.716-4.015 0-1.349.355-2.457 1.074-3.311.718-.857 1.722-1.277 3.014-1.277m7.124-2.04c-.14.876-.249 1.587-.318 2.144-.067.567-.101 1.131-.101 1.704-.767-1.254-1.757-2.294-2.98-3.109-1.221-.821-2.579-1.228-4.075-1.228-2.092 0-3.701.648-4.84 1.946-1.132 1.303-1.704 3.059-1.704 5.276 0 2.343.823 4.223 2.473 5.618 1.649 1.395 3.89 2.092 6.709 2.092h4.417v3.106c0 1.786-.456 3.193-1.351 4.21-.914 1.004-2.17 1.512-3.791 1.512-1.508 0-2.752-.479-3.728-1.45-.973-.965-1.456-2.144-1.456-3.549l-2.623.023-.046.137c-.074 1.906.647 3.591 2.168 5.084 1.515 1.489 3.459 2.229 5.825 2.229 2.338 0 4.22-.711 5.657-2.128 1.429-1.431 2.146-3.471 2.146-6.124v-12.396c0-.903.042-1.78.121-2.617.081-.848.212-1.665.417-2.48z" transform="matrix(1.1310535 0 0 1.1310535 456.01527 232.82495)"/><path d="m0 0 .24-3.923c.664 1.404 1.554 2.486 2.657 3.255 1.107.759 2.41 1.138 3.906 1.138 1.527 0 2.814-.444 3.852-1.343 1.039-.896 1.805-2.252 2.292-4.074.623 1.682 1.505 3.011 2.65 3.973 1.145.964 2.534 1.444 4.143 1.444 2.217 0 3.937-.897 5.156-2.692 1.224-1.799 1.834-4.559 1.834-8.288v-14.765h-2.823v14.814c0 3.1-.429 5.283-1.263 6.538-.839 1.257-2.042 1.89-3.598 1.89-1.637 0-2.915-.691-3.834-2.096-.914-1.405-1.478-3.161-1.683-5.282v-.655-15.209h-2.809v14.798c0 3.027-.424 5.194-1.292 6.488-.864 1.294-2.066 1.936-3.609 1.936-1.475 0-2.668-.45-3.562-1.342-.9-.897-1.54-2.125-1.928-3.683v-18.197h-2.806v25.275z" transform="matrix(1.1310535 0 0 1.1310535 476.7303 259.10521)"/><path d="m0 0c-1.758 0-3.202-.802-4.334-2.402-1.133-1.606-1.718-3.585-1.765-5.944h11.66v1.082c0 2.086-.489 3.823-1.469 5.201-.986 1.379-2.347 2.063-4.092 2.063m.397-23.76c-2.725 0-4.954 1.026-6.685 3.073-1.726 2.043-2.591 4.657-2.591 7.841v4.197c0 3.19.867 5.85 2.602 7.965 1.739 2.105 3.828 3.158 6.277 3.158 2.648 0 4.699-.939 6.164-2.823 1.468-1.887 2.201-4.422 2.201-7.603v-2.773h-14.464v-2.102c0-2.447.586-4.484 1.752-6.11 1.168-1.63 2.755-2.438 4.744-2.438 1.382 0 2.585.244 3.588.724 1.003.491 1.863 1.179 2.578 2.082l1.149-1.988c-.763-.968-1.752-1.75-2.959-2.33-1.204-.577-2.659-.873-4.356-.873" transform="matrix(1.1310535 0 0 1.1310535 522.82277 256.83868)"/><path d="m0 0c-1.763 0-3.21-.802-4.341-2.402-1.126-1.606-1.712-3.585-1.763-5.944h11.663v1.082c0 2.086-.488 3.823-1.474 5.201-.981 1.379-2.341 2.063-4.085 2.063m.394-23.76c-2.726 0-4.951 1.026-6.679 3.073-1.733 2.043-2.6 4.657-2.6 7.841v4.197c0 3.19.871 5.85 2.602 7.965 1.744 2.105 3.834 3.158 6.283 3.158 2.643 0 4.703-.939 6.164-2.823 1.463-1.887 2.197-4.422 2.197-7.603v-2.773h-14.465v-2.102c0-2.447.587-4.484 1.76-6.11 1.162-1.63 2.742-2.438 4.738-2.438 1.387 0 2.585.244 3.585.724 1.007.491 1.866 1.179 2.589 2.082l1.141-1.988c-.764-.968-1.75-1.75-2.959-2.33-1.204-.577-2.658-.873-4.356-.873" transform="matrix(1.1310535 0 0 1.1310535 558.0805 256.83868)"/><path d="m0 0 .23-4.178c.674 1.483 1.564 2.634 2.682 3.435 1.108.805 2.413 1.213 3.914 1.213 2.258 0 3.988-.835 5.189-2.513 1.214-1.675 1.815-4.279 1.815-7.812v-15.42h-2.825v15.394c0 2.888-.423 4.905-1.264 6.075-.836 1.17-2.065 1.753-3.665 1.753-1.435 0-2.638-.466-3.603-1.414-.969-.939-1.691-2.19-2.172-3.767v-18.041h-2.805v25.275z" transform="matrix(1.1310535 0 0 1.1310535 575.91679 259.10521)"/><path d="m0 0c0-2.565.486-4.605 1.472-6.123.974-1.532 2.457-2.288 4.436-2.288 1.356 0 2.498.361 3.435 1.101.934.74 1.672 1.77 2.218 3.077v12.52c-.525 1.346-1.246 2.434-2.157 3.272-.91.824-2.062 1.238-3.448 1.238-1.975 0-3.468-.86-4.46-2.587-.999-1.73-1.496-3.986-1.496-6.756zm-2.833 3.454c0 3.582.723 6.459 2.177 8.627 1.442 2.157 3.448 3.239 6.004 3.239 1.419 0 2.664-.346 3.728-1.04 1.066-.681 1.947-1.678 2.654-2.946l.274 3.516h2.381v-25.298c0-3.239-.751-5.749-2.26-7.525-1.511-1.769-3.657-2.665-6.428-2.665-.996 0-2.067.156-3.212.459-1.147.303-2.162.701-3.052 1.2l.776 2.463c.759-.492 1.608-.873 2.548-1.141.932-.277 1.895-.41 2.894-.41 2.009 0 3.498.645 4.46 1.932.966 1.304 1.45 3.19 1.45 5.687v3.057c-.717-1.138-1.597-2.011-2.64-2.614-1.039-.606-2.253-.909-3.622-.909-2.539 0-4.53.994-5.968 2.982-1.441 1.984-2.164 4.631-2.164 7.932z" transform="matrix(1.1310535 0 0 1.1310535 600.8685 242.30884)"/><path d="m627.82321 230.5176h-3.20089v28.58738h3.20089zm0 36.72644h-3.20089v4.50385h3.20089z"/><path d="m0 0 .23-4.178c.676 1.483 1.562 2.634 2.678 3.435 1.115.805 2.422 1.213 3.916 1.213 2.258 0 3.995-.835 5.199-2.513 1.211-1.675 1.807-4.279 1.807-7.812v-15.42h-2.825v15.394c0 2.888-.422 4.905-1.261 6.075-.843 1.17-2.063 1.753-3.668 1.753-1.434 0-2.635-.466-3.599-1.414-.967-.939-1.692-2.19-2.171-3.767v-18.041h-2.809v25.275z" transform="matrix(1.1310535 0 0 1.1310535 638.15379 259.10521)"/><path d="m0 0c-1.763 0-3.208-.802-4.334-2.402-1.129-1.606-1.718-3.585-1.768-5.944h11.662v1.082c0 2.086-.486 3.823-1.47 5.201-.981 1.379-2.343 2.063-4.09 2.063m.401-23.76c-2.733 0-4.958 1.026-6.681 3.073-1.73 2.043-2.595 4.657-2.595 7.841v4.197c0 3.19.865 5.85 2.6 7.965 1.739 2.105 3.831 3.158 6.275 3.158 2.646 0 4.706-.939 6.172-2.823 1.462-1.887 2.195-4.422 2.195-7.603v-2.773h-14.469v-2.102c0-2.447.59-4.484 1.757-6.11 1.166-1.63 2.748-2.438 4.746-2.438 1.382 0 2.579.244 3.578.724 1.012.491 1.869 1.179 2.591 2.082l1.147-1.988c-.769-.968-1.755-1.75-2.962-2.33-1.203-.577-2.658-.873-4.354-.873" transform="matrix(1.1310535 0 0 1.1310535 669.70883 256.83868)"/></g><g stroke-width="1.41382" transform="translate(89.812354 -.891698)"><path d="m340.91387 248.41524s-.45949-2.81915-.72812-2.7937l-51.15472 4.93563c-4.07038.39304-7.23167 3.63917-7.51726 7.71803l-1.40534 20.14265-39.57556 2.82339-2.69191-18.2552c-.59946-4.06049-4.14531-7.1214-8.24962-7.1214h-53.99084c-4.1029 0-7.64875 3.06091-8.24821 7.1214l-2.69332 18.2552-39.57556-2.82339-1.40533-20.14265c-.2856-4.08028-3.44689-7.3264-7.51727-7.71944l-51.180171-4.93422c-.264383-.0255-.458076 2.79653-.72246 2.79653l-.06928 11.07018 43.344801 6.98991 1.41947 20.32221c.28701 4.11421 3.60665 7.44092 7.72368 7.7364l54.50406 3.888c.20642.0141.41001.0226.6136.0226 4.09582 0 7.63602-3.06232 8.23548-7.12281l2.76967-18.78397h39.59394l2.76967 18.78397c.59804 4.05907 4.14248 7.1214 8.24396 7.1214.20076 0 .40153-.007.59805-.0212l54.51112-3.888c4.11562-.29548 7.43668-3.62219 7.72368-7.7364l1.41806-20.32221 43.32642-7.02101z" fill="#fff"/><path d="m64.257603 164.94208v67.1761 8.53238 7.76468c.152692.001.305384.007.456663.0212l51.174514 4.93422c2.6806.25873 4.78153 2.41621 4.96815 5.10247l1.57782 22.58996 44.63986 3.18533 3.07505-20.84955c.3987-2.70322 2.71736-4.7066 5.45168-4.7066h53.99084c2.73291 0 5.05157 2.00338 5.45026 4.7066l3.07505 20.84955 44.64127-3.18533 1.57641-22.58996c.18804-2.68626 2.28756-4.84233 4.96815-5.10247l51.15472-4.93422c.15128-.0141.30256-.0198.45525-.0212v-6.66049l.0212-.007v-76.8056c7.20611-9.07172 14.02963-19.07834 19.2576-27.49732-7.98948-13.60092-17.77875-25.75551-28.24241-37.01656-9.70443 4.88474-19.13035 10.41842-28.03316 16.30697-4.45493-4.42808-9.47257-8.05028-14.40114-11.83648-4.84232-3.88941-10.29965-6.741079-15.47564-10.063549 1.54107-11.475951 2.30311-22.773762 2.60991-34.564995-13.35491-6.721286-27.59629-11.177637-42.00167-14.378518-5.75141 9.666266-11.01081 20.134166-15.59157 30.367373-5.43189-.90767-10.88922-1.244159-16.35362-1.309194v-.0085c-.0382 0-.0735.0085-.10604.0085-.0339 0-.0693-.0085-.10321-.0085v.0085c-5.4743.06503-10.92739.401524-16.36069 1.309194-4.57794-10.233207-9.83451-20.701107-15.5944-30.367373-14.39831 3.200881-28.6411 7.657232-41.9946 14.378518.30538 11.791233 1.06743 23.089044 2.61273 34.564995-5.18588 3.32247-10.63614 6.174139-15.47988 10.063549-4.9215 3.7862-9.94762 7.4084-14.40397 11.83648-8.902802-5.88855-18.325891-11.42223-28.033158-16.30697-10.463659 11.26105-20.247272 23.41564-28.239579 37.01656 6.281105 9.85952 13.018384 19.76924 19.2576 27.49732z" fill="#478cbf"/><path d="m295.00412 263.89328-1.58489 22.71014c-.19086 2.73715-2.36814 4.91584-5.10529 5.11236l-54.50971 3.88941c-.1329.01-.2658.0141-.39728.0141-2.70888 0-5.04592-1.98783-5.44603-4.70801l-3.12595-21.19877h-44.47726l-3.12595 21.19877c-.41991 2.85308-2.97043 4.90453-5.84331 4.69387l-54.50971-3.88941c-2.73715-.19652-4.91442-2.37521-5.10529-5.11236l-1.58489-22.71014-46.015498-4.43656c.02121 4.94553.08483 10.36328.08483 11.44202 0 48.59854 61.649488 71.95763 138.244428 72.22625h.0933.0947c76.59494-.26862 138.22322-23.62771 138.22322-72.22625 0-1.09853.0664-6.49366.0891-11.44202z" fill="#478cbf"/><path d="m160.89242 198.8266c0 17.03932-13.80592 30.84242-30.83959 30.84242-17.02518 0-30.835345-13.8031-30.835345-30.84242 0-17.02801 13.810165-30.82404 30.835345-30.82404 17.03367 0 30.83959 13.79603 30.83959 30.82404" fill="#fff"/><path d="m153.47185 200.6558c0 11.30205-9.16012 20.46217-20.47065 20.46217-11.30488 0-20.47066-9.16012-20.47066-20.46217s9.16578-20.47065 20.47066-20.47065c11.31053 0 20.47065 9.1686 20.47065 20.47065" fill="#414042"/><path d="m202.59379 232.47488c-5.48278 0-9.92641-4.04069-9.92641-9.02157v-28.39085c0-4.97664 4.44363-9.02157 9.92641-9.02157s9.93631 4.04493 9.93631 9.02157v28.39085c0 4.98088-4.45353 9.02157-9.93631 9.02157" fill="#fff"/><path d="m244.30027 198.8266c0 17.03932 13.80592 30.84242 30.84242 30.84242 17.02376 0 30.83251-13.8031 30.83251-30.84242 0-17.02801-13.80875-30.82404-30.83251-30.82404-17.0365 0-30.84242 13.79603-30.84242 30.82404" fill="#fff"/><path d="m251.72267 200.6558c0 11.30205 9.15729 20.46217 20.45934 20.46217 11.31337 0 20.47066-9.16012 20.47066-20.46217s-9.15729-20.47065-20.47066-20.47065c-11.30205 0-20.45934 9.1686-20.45934 20.47065" fill="#414042"/></g></svg> diff --git a/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import new file mode 100644 index 0000000..a4fb09a --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://rh7l4xuh4ali" +path="res://.godot/imported/logo_vertical_color_dark.svg-1167b3ce62f0747c0e76b17bdbb9f218.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/CreditsMenu/logo_vertical_color_dark.svg" +dest_files=["res://.godot/imported/logo_vertical_color_dark.svg-1167b3ce62f0747c0e76b17bdbb9f218.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd b/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd new file mode 100644 index 0000000..db4f2ce --- /dev/null +++ b/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd @@ -0,0 +1,165 @@ +extends HBoxContainer + +# REQUIREMENTS: +# * 1.4 Game Lobby Menu +# * SS-12 + +signal back_button_pressed +signal save_game_selected(save : SaveResource) +signal start_date_selected(index : int) + +@export var lobby_panel_button : PackedScene +@export var save_scene : PackedScene + +@export_group("Nodes") +@export var game_select_start_date : BoxContainer +@export var game_select_save_tab : TabBar +@export var game_select_save_list : BoxContainer +@export var start_button : BaseButton +@export var session_tag_line_edit : LineEdit +@export var session_tag_dialog : ConfirmationDialog +@export var delete_dialog : ConfirmationDialog + +func filter_for_tag(tag : StringName) -> void: + for child in game_select_save_list.get_children(): + if tag == &"": + child.show() + else: + if tag == child.resource.session_tag: + child.show() + else: + child.hide() + +func _build_date_list() -> void: + var start_date := lobby_panel_button.instantiate() + start_date.set_text(&"1836") + start_date.pressed.connect(_on_start_date_panel_button_pressed.bind(start_date)) + game_select_start_date.add_child(start_date) + start_date = lobby_panel_button.instantiate() + start_date.set_text(&"1863") + start_date.pressed.connect(_on_start_date_panel_button_pressed.bind(start_date)) + game_select_start_date.add_child(start_date) + +var _id_to_tag : Array[StringName] = [] + +# Requirements +# * FS-8 +func _build_save_list() -> void: + game_select_save_tab.add_tab("GAMELOBBY_SELECT_ALL") + for save_name in SaveManager._save_dictionary: + var save : SaveResource = SaveManager._save_dictionary[save_name] + var save_node := _create_save_node(save) + game_select_save_list.add_child(save_node) + if not _id_to_tag.has(save.session_tag): + _id_to_tag.append(save.session_tag) + game_select_save_tab.add_tab(save.session_tag) + +func _create_save_node(resource : SaveResource) -> Control: + var save_node = save_scene.instantiate() + save_node.resource = resource + save_node.pressed.connect(_on_save_node_pressed.bind(save_node)) + save_node.request_to_delete.connect(_on_save_node_delete_requested.bind(save_node)) + return save_node + +func _queue_clear_lists() -> void: + var full_list = game_select_start_date.get_children() + full_list.append_array(game_select_save_list.get_children()) + for child in full_list: + child.queue_free() + game_select_save_tab.clear_tabs() + _id_to_tag.clear() + +# REQUIREMENTS: +# * SS-16 +# * UIFUN-40 +func _on_back_button_button_down(): + print("Returning to Main Menu.") + SaveManager.current_session_tag = "" + SaveManager.current_save = null + back_button_pressed.emit() + +# REQUIREMENTS: +# * SS-21 +func _on_start_button_pressed(): + print("Starting new game.") + if SaveManager.current_session_tag == "": + # TODO: Get country tag as well + var datetime := Time.get_datetime_dict_from_system() + SaveManager.current_session_tag = "%s/%s/%s-%s:%s:%s" % [ + datetime["day"], + datetime["month"], + datetime["year"], + datetime["hour"], + datetime["minute"], + datetime["second"] + ] + if SaveManager.current_save == null and SaveManager.current_session_tag in _id_to_tag: + session_tag_dialog.dialog_text = tr("GAMELOBBY_SESSIONTAG_DIALOG_TEXT").format({ "session_tag": SaveManager.current_session_tag }) + session_tag_dialog.title = tr("GAMELOBBY_SESSIONTAG_DIALOG_TITLE").format({ "session_tag": SaveManager.current_session_tag }) + session_tag_dialog.popup_centered() + else: + _on_session_tag_dialog_confirmed() + +# REQUIREMENTS: +# * SS-19 +func _on_game_select_list_item_selected(index): + print("Selected save game: ", index) + save_game_selected.emit(index) + +# If the date is double-clicked, start the game! +func _on_game_select_list_item_activated(index): + _on_game_select_list_item_selected(index) + _on_start_button_pressed() + +func _on_session_tag_edit_text_submitted(new_text): + SaveManager.current_session_tag = new_text + _on_start_button_pressed() + +func _on_session_tag_dialog_confirmed(): + get_tree().change_scene_to_file("res://src/GameSession/GameSession.tscn") + +var _requested_node_to_delete : Control +func _on_save_node_delete_requested(node : Control) -> void: + _requested_node_to_delete = node + delete_dialog.dialog_text = tr("GAMELOBBY_DELETE_DIALOG_TEXT").format({ "file_name": _requested_node_to_delete.resource.save_name }) + delete_dialog.title = tr("GAMELOBBY_DELETE_DIALOG_TITLE").format({ "file_name": _requested_node_to_delete.resource.save_name }) + delete_dialog.popup_centered() + +var _start_date_index := -1 +func _on_start_date_panel_button_pressed(node : Control) -> void: + if node is LobbyPanelButton and node.get_index(true) == _start_date_index: + _on_start_button_pressed() + return + _start_date_index = node.get_index(true) + start_button.disabled = false + start_date_selected.emit(_start_date_index) + +func _on_save_node_pressed(node : Control) -> void: + if SaveManager.current_save != null and SaveManager.current_save == node.resource: + SaveManager.current_session_tag = SaveManager.current_save.session_tag + _on_start_button_pressed() + return + SaveManager.current_save = node.resource + if SaveManager.current_save != null: + session_tag_line_edit.text = SaveManager.current_save.session_tag + else: + session_tag_line_edit.text = "" + start_button.disabled = false + save_game_selected.emit(SaveManager.current_save) + +func _on_game_select_save_tab_tab_changed(tab) -> void: + if tab == 0: + filter_for_tag(&"") + else: + filter_for_tag(_id_to_tag[tab - 1]) + +func _on_delete_dialog_confirmed(): + _requested_node_to_delete.resource.delete() + _requested_node_to_delete.queue_free() + +func _on_visibility_changed(): + if visible: + _build_date_list() + _build_save_list() + else: + _queue_clear_lists() diff --git a/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn b/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn new file mode 100644 index 0000000..3b5796e --- /dev/null +++ b/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn @@ -0,0 +1,138 @@ +[gd_scene load_steps=4 format=3 uid="uid://do60kx0d3nrh4"] + +[ext_resource type="Script" path="res://src/LobbyMenu/LobbyMenu.gd" id="1_cvwum"] +[ext_resource type="PackedScene" uid="uid://k71f5gibwmtc" path="res://src/LobbyMenu/LobbyPanelButton.tscn" id="2_exh17"] +[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="3_4otj7"] + +[node name="LobbyMenu" type="HBoxContainer" node_paths=PackedStringArray("game_select_start_date", "game_select_save_tab", "game_select_save_list", "start_button", "session_tag_line_edit", "session_tag_dialog", "delete_dialog")] +editor_description = "UI-36" +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_cvwum") +lobby_panel_button = ExtResource("2_exh17") +save_scene = ExtResource("3_4otj7") +game_select_start_date = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectStartDate") +game_select_save_tab = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveTab") +game_select_save_list = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveList") +start_button = NodePath("GameStartPanel/VBoxContainer/StartButton") +session_tag_line_edit = NodePath("GameStartPanel/VBoxContainer/SessionTagEdit") +session_tag_dialog = NodePath("SessionTagDialog") +delete_dialog = NodePath("DeleteDialog") + +[node name="GameSelectPanel" type="PanelContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="GameSelectPanel"] +layout_mode = 2 + +[node name="GameSelectScroll" type="ScrollContainer" parent="GameSelectPanel/VBoxContainer"] +editor_description = "UI-39" +layout_mode = 2 +size_flags_vertical = 3 +horizontal_scroll_mode = 0 + +[node name="GameSelectList" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="GameSelectStartDate" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] +layout_mode = 2 + +[node name="GameSelectSaveTab" type="TabBar" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] +layout_mode = 2 +tab_count = 1 +tab_0/title = "GAMELOBBY_SELECT_ALL" + +[node name="GameSelectSaveList" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="GameSelectList" type="ItemList" parent="GameSelectPanel/VBoxContainer"] +visible = false +layout_mode = 2 +size_flags_vertical = 3 +item_count = 2 +item_0/text = "1836" +item_1/text = "1863" + +[node name="Spacer" type="Control" parent="GameSelectPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 150) +layout_mode = 2 +size_flags_vertical = 3 + +[node name="BackButton" type="Button" parent="GameSelectPanel/VBoxContainer"] +editor_description = "UI-37" +layout_mode = 2 +text = "GAMELOBBY_BACK" + +[node name="Spacer2" type="Control" parent="GameSelectPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 33) +layout_mode = 2 + +[node name="Spacer" type="Control" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 2.75 +mouse_filter = 2 + +[node name="GameStartPanel" type="PanelContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="GameStartPanel"] +layout_mode = 2 + +[node name="Spacer" type="Control" parent="GameStartPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 50) +layout_mode = 2 + +[node name="SelectedCountryNameLabel" type="Label" parent="GameStartPanel/VBoxContainer"] +layout_mode = 2 +text = "France" +horizontal_alignment = 1 + +[node name="Spacer2" type="Control" parent="GameStartPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 150) +layout_mode = 2 +size_flags_vertical = 3 + +[node name="SessionTagEdit" type="LineEdit" parent="GameStartPanel/VBoxContainer"] +layout_mode = 2 +placeholder_text = "GAMELOBBY_SESSION_TAG" + +[node name="StartButton" type="Button" parent="GameStartPanel/VBoxContainer"] +editor_description = "UI-43" +layout_mode = 2 +disabled = true +text = "GAMELOBBY_START" + +[node name="Spacer3" type="Control" parent="GameStartPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 33) +layout_mode = 2 + +[node name="SessionTagDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "GAMELOBBY_SESSIONTAG_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "GAMELOBBY_SESSIONTAG_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[node name="DeleteDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "GAMELOBBY_DELETE_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "GAMELOBBY_DELETE_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] +[connection signal="tab_changed" from="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveTab" to="." method="_on_game_select_save_tab_tab_changed"] +[connection signal="button_down" from="GameSelectPanel/VBoxContainer/BackButton" to="." method="_on_back_button_button_down"] +[connection signal="text_submitted" from="GameStartPanel/VBoxContainer/SessionTagEdit" to="." method="_on_session_tag_edit_text_submitted"] +[connection signal="pressed" from="GameStartPanel/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"] +[connection signal="confirmed" from="SessionTagDialog" to="." method="_on_session_tag_dialog_confirmed"] +[connection signal="confirmed" from="DeleteDialog" to="." method="_on_delete_dialog_confirmed"] diff --git a/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd new file mode 100644 index 0000000..5f3ea46 --- /dev/null +++ b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd @@ -0,0 +1,102 @@ +@tool +class_name LobbyPanelButton +extends Container + +signal button_down +signal button_up +signal pressed +signal toggled(button_pressed : bool) + +var is_start_date : bool: + get = _is_start_date + +func _is_start_date() -> bool: + return true + +@export_group("Nodes") +@export var background_button : BaseButton +@export var name_label : Label + +var text : StringName: + get = get_text, + set = set_text + +func get_text() -> StringName: + return name_label.text + +func set_text(value : StringName) -> void: + name_label.text = value + +func _get_minimum_size() -> Vector2: + var result := Vector2() + for child in get_children(): + child = child as Control + if child == null or not child.visible: + continue + if child.top_level: + continue + + var minsize : Vector2 = child.get_combined_minimum_size() + result.x = max(result.x, minsize.x) + result.y = max(result.y, minsize.y) + + var draw_style := _get_draw_mode_style() + if draw_style != null: + result += draw_style.get_minimum_size() + + return result + +func _get_draw_mode_name(support_rtl : bool = true) -> StringName: + var rtl := support_rtl and background_button != null and background_button.is_layout_rtl() + match background_button.get_draw_mode() if background_button != null else BaseButton.DrawMode.DRAW_NORMAL: + BaseButton.DrawMode.DRAW_NORMAL: + if rtl: return &"normal_mirrored" + return &"normal" + BaseButton.DrawMode.DRAW_PRESSED: + if rtl: return &"pressed_mirrored" + return &"pressed" + BaseButton.DrawMode.DRAW_HOVER: + if rtl: return &"hover_mirrored" + return &"hover" + BaseButton.DrawMode.DRAW_DISABLED: + if rtl: return &"disabled_mirrored" + return &"disabled" + BaseButton.DrawMode.DRAW_HOVER_PRESSED: + if rtl: return &"hover_pressed_mirrored" + return &"hover_pressed" + return &"" + +func _get_draw_mode_style() -> StyleBox: + if background_button == null: return null + var result := background_button.get_theme_stylebox(_get_draw_mode_name()) + if result == null: + return background_button.get_theme_stylebox(_get_draw_mode_name(false)) + return result + +func _notification(what) -> void: + if what == NOTIFICATION_SORT_CHILDREN: + var _size := size + var offset := Vector2() + var style := _get_draw_mode_style() + if style != null: + _size -= style.get_minimum_size() + offset += style.get_offset() + + for child in get_children(): + child = child as Control + if child == null or not child.is_visible_in_tree() or child.top_level: + continue + + fit_child_in_rect(child, Rect2(offset, _size)) + +func _on_background_button_button_down(): + button_down.emit() + +func _on_background_button_button_up(): + button_up.emit() + +func _on_background_button_pressed(): + pressed.emit() + +func _on_background_button_toggled(button_pressed : bool): + toggled.emit(button_pressed) diff --git a/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn new file mode 100644 index 0000000..f409a2e --- /dev/null +++ b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn @@ -0,0 +1,31 @@ +[gd_scene load_steps=2 format=3 uid="uid://k71f5gibwmtc"] + +[ext_resource type="Script" path="res://src/LobbyMenu/LobbyPanelButton.gd" id="1_327u2"] + +[node name="LobbyPanelButton" type="Container" node_paths=PackedStringArray("background_button", "name_label")] +editor_description = "UI-41" +offset_right = 113.0 +offset_bottom = 48.0 +script = ExtResource("1_327u2") +background_button = NodePath("BackgroundButton") +name_label = NodePath("SaveList/NameLabel") + +[node name="BackgroundButton" type="Button" parent="."] +layout_mode = 2 +theme_type_variation = &"ButtonContainer" + +[node name="SaveList" type="HBoxContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 0 +mouse_filter = 2 + +[node name="NameLabel" type="Label" parent="SaveList"] +layout_mode = 2 +size_flags_vertical = 1 +text = "PLACEHOLDER" +vertical_alignment = 1 + +[connection signal="button_down" from="BackgroundButton" to="." method="_on_background_button_button_down"] +[connection signal="button_up" from="BackgroundButton" to="." method="_on_background_button_button_up"] +[connection signal="pressed" from="BackgroundButton" to="." method="_on_background_button_pressed"] +[connection signal="toggled" from="BackgroundButton" to="." method="_on_background_button_toggled"] diff --git a/game/src/Game/Menu/MainMenu/MainMenu.gd b/game/src/Game/Menu/MainMenu/MainMenu.gd new file mode 100644 index 0000000..9d0edc6 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/MainMenu.gd @@ -0,0 +1,50 @@ +extends Control + +signal options_button_pressed +signal new_game_button_pressed +signal credits_button_pressed + +@export +var _new_game_button : BaseButton + +# REQUIREMENTS: +# * SS-3 +func _ready(): + _on_new_game_button_visibility_changed() + +# REQUIREMENTS: +# * SS-14 +# * UIFUN-32 +func _on_new_game_button_pressed(): + print("Start a new game!") + new_game_button_pressed.emit() + + +func _on_continue_button_pressed(): + print("Continue last game!") + + +func _on_multi_player_button_pressed(): + print("Have fun with friends!") + + +func _on_options_button_pressed(): + print("Check out some options!") + options_button_pressed.emit() + +# REQUIREMENTS +# * UI-32 +# * UIFUN-36 +func _on_credits_button_pressed(): + credits_button_pressed.emit() + +# REQUIREMENTS +# * SS-4 +# * UIFUN-3 +func _on_exit_button_pressed(): + print("See you later!") + get_tree().quit() + +func _on_new_game_button_visibility_changed(): + if visible: + _new_game_button.grab_focus.call_deferred() diff --git a/game/src/Game/Menu/MainMenu/MainMenu.tscn b/game/src/Game/Menu/MainMenu/MainMenu.tscn new file mode 100644 index 0000000..0618fe8 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/MainMenu.tscn @@ -0,0 +1,150 @@ +[gd_scene load_steps=6 format=3 uid="uid://bp5n3mlu45ygw"] + +[ext_resource type="Theme" uid="uid://qoi3oec48jp0" path="res://theme/main_menu.tres" id="1_1yri4"] +[ext_resource type="Script" path="res://src/MainMenu/MainMenu.gd" id="2_nm1fq"] +[ext_resource type="Texture2D" uid="uid://dxys0wg0f0ic5" path="res://theme/assets/OpenVicFINALREALTRANS.png" id="3_58ess"] +[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="3_amonp"] +[ext_resource type="PackedScene" uid="uid://cen7wkmn6og66" path="res://src/MainMenu/ReleaseInfoBox.tscn" id="3_km0er"] + +[node name="MainMenu" type="Control" node_paths=PackedStringArray("_new_game_button")] +editor_description = "UI-13" +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_1yri4") +script = ExtResource("2_nm1fq") +_new_game_button = NodePath("MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton") + +[node name="MenuPanel" type="PanelContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_type_variation = &"BackgroundPanel" + +[node name="MenuList" type="VBoxContainer" parent="MenuPanel"] +layout_mode = 2 + +[node name="TitleIcon" type="TextureRect" parent="MenuPanel/MenuList"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 1.75 +texture = ExtResource("3_58ess") +expand_mode = 1 +stretch_mode = 5 + +[node name="ButtonListMargin" type="MarginContainer" parent="MenuPanel/MenuList"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_right = 12 + +[node name="ButtonList" type="HBoxContainer" parent="MenuPanel/MenuList/ButtonListMargin"] +custom_minimum_size = Vector2(500, 0) +layout_mode = 2 +theme_type_variation = &"HBox_MainMenu_ButtonList" +theme_override_constants/separation = 18 +alignment = 1 + +[node name="NewGameButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-26" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../ExitButton") +focus_neighbor_top = NodePath("../ExitButton") +focus_neighbor_right = NodePath("../ContinueButton") +focus_next = NodePath("../ContinueButton") +focus_previous = NodePath("../ExitButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_NEW_GAME" +clip_text = true + +[node name="ContinueButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../NewGameButton") +focus_neighbor_right = NodePath("../MultiplayerButton") +focus_next = NodePath("../MultiplayerButton") +focus_previous = NodePath("../NewGameButton") +theme_type_variation = &"TitleButton" +disabled = true +text = "MAINMENU_CONTINUE" +clip_text = true + +[node name="MultiplayerButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-27" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../ContinueButton") +focus_neighbor_right = NodePath("../OptionsButton") +focus_next = NodePath("../OptionsButton") +focus_previous = NodePath("../ContinueButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_MULTIPLAYER" +clip_text = true + +[node name="OptionsButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-5" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../MultiplayerButton") +focus_neighbor_right = NodePath("../CreditsButton") +focus_next = NodePath("../CreditsButton") +focus_previous = NodePath("../MultiplayerButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_OPTIONS" +clip_text = true + +[node name="CreditsButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-32" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../OptionsButton") +focus_neighbor_right = NodePath("../ExitButton") +focus_next = NodePath("../ExitButton") +focus_previous = NodePath("../OptionsButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_CREDITS" +clip_text = true + +[node name="ExitButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-3" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../OptionsButton") +focus_neighbor_right = NodePath("../NewGameButton") +focus_next = NodePath("../NewGameButton") +focus_previous = NodePath("../OptionsButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_EXIT" +clip_text = true + +[node name="BottomSpace" type="Control" parent="MenuPanel/MenuList"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.35 + +[node name="BottomMargin" type="MarginContainer" parent="MenuPanel/MenuList"] +layout_mode = 2 +theme_type_variation = &"BottomMargin" + +[node name="ReleaseInfoBox" parent="MenuPanel/MenuList/BottomMargin" instance=ExtResource("3_km0er")] +layout_mode = 2 + +[node name="LocaleButton" parent="MenuPanel/MenuList/BottomMargin" instance=ExtResource("3_amonp")] +layout_mode = 2 +size_flags_horizontal = 8 +alignment = 0 +text_overrun_behavior = 4 + +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton" to="." method="_on_new_game_button_pressed"] +[connection signal="visibility_changed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton" to="." method="_on_new_game_button_visibility_changed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/ContinueButton" to="." method="_on_continue_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/MultiplayerButton" to="." method="_on_multi_player_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/CreditsButton" to="." method="_on_credits_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/ExitButton" to="." method="_on_exit_button_pressed"] diff --git a/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd new file mode 100644 index 0000000..e363162 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd @@ -0,0 +1,41 @@ +extends HBoxContainer + +@export +var _version_label : Button + +@export +var _commit_label : Button + +@export +var _checksum_label : Button + +var _checksum : String = "????" + +# REQUIREMENTS: +# * UIFUN-97 +func _ready(): + _version_label.text = _GIT_INFO_.release_name + _version_label.tooltip_text = _GIT_INFO_.tag + _commit_label.text = _GIT_INFO_.short_hash + _commit_label.tooltip_text = _GIT_INFO_.commit_hash + # UI-111 + _checksum = Checksum.get_checksum_text() + _update_checksum_label_text() + +func _notification(what : int): + match what: + NOTIFICATION_TRANSLATION_CHANGED: + _update_checksum_label_text() + +func _update_checksum_label_text() -> void: + _checksum_label.tooltip_text = tr("MAINMENU_CHECKSUM").format({ "checksum": _checksum }) + _checksum_label.text = "(%s)" % _checksum.substr(0, 4) + +func _on_version_label_pressed(): + DisplayServer.clipboard_set(_GIT_INFO_.tag) + +func _on_commit_label_pressed(): + DisplayServer.clipboard_set(_GIT_INFO_.commit_hash) + +func _on_checksum_label_pressed(): + DisplayServer.clipboard_set(_checksum) diff --git a/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn new file mode 100644 index 0000000..821982b --- /dev/null +++ b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=2 format=3 uid="uid://cen7wkmn6og66"] + +[ext_resource type="Script" path="res://src/MainMenu/ReleaseInfoBox.gd" id="1_y2djw"] + +[node name="ReleaseInfoBox" type="HBoxContainer" node_paths=PackedStringArray("_version_label", "_commit_label", "_checksum_label")] +editor_description = "UI-31" +script = ExtResource("1_y2djw") +_version_label = NodePath("VersionLabel") +_commit_label = NodePath("CommitLabel") +_checksum_label = NodePath("ChecksumLabel") + +[node name="VersionLabel" type="Button" parent="."] +layout_mode = 2 +tooltip_text = "VERSION_MISSING" +theme_type_variation = &"VersionLabel" +text = "VERSION_MISSING" +flat = true +alignment = 0 + +[node name="CommitLabel" type="Button" parent="."] +layout_mode = 2 +theme_type_variation = &"CommitLabel" +text = "????????" +flat = true +alignment = 0 + +[node name="ChecksumLabel" type="Button" parent="."] +editor_description = "UI-111" +layout_mode = 2 +tooltip_text = "CHECKSUM_MISSING" +theme_type_variation = &"ChecksumLabel" +text = "(????)" +flat = true +alignment = 0 + +[connection signal="pressed" from="VersionLabel" to="." method="_on_version_label_pressed"] +[connection signal="pressed" from="CommitLabel" to="." method="_on_commit_label_pressed"] +[connection signal="pressed" from="ChecksumLabel" to="." method="_on_checksum_label_pressed"] diff --git a/game/src/Game/Menu/OptionMenu/AutosaveIntervalSelector.gd b/game/src/Game/Menu/OptionMenu/AutosaveIntervalSelector.gd new file mode 100644 index 0000000..2c55862 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/AutosaveIntervalSelector.gd @@ -0,0 +1,2 @@ +extends SettingOptionButton + diff --git a/game/src/Game/Menu/OptionMenu/ControlsTab.tscn b/game/src/Game/Menu/OptionMenu/ControlsTab.tscn new file mode 100644 index 0000000..b84dc85 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/ControlsTab.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=2 format=3 uid="uid://cdwymd51i4b2f"] + +[ext_resource type="PackedScene" uid="uid://by4gggse2nsdx" path="res://addons/keychain/ShortcutEdit.tscn" id="1_fv8sh"] + +[node name="Controls" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="ShortcutEdit" parent="." instance=ExtResource("1_fv8sh")] +layout_mode = 1 diff --git a/game/src/Game/Menu/OptionMenu/GeneralTab.gd b/game/src/Game/Menu/OptionMenu/GeneralTab.gd new file mode 100644 index 0000000..3d98678 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/GeneralTab.gd @@ -0,0 +1,9 @@ +extends HBoxContainer + +@export var initial_focus: Control + +func _notification(what : int) -> void: + match(what): + NOTIFICATION_VISIBILITY_CHANGED: + if visible and is_inside_tree(): + initial_focus.grab_focus() diff --git a/game/src/Game/Menu/OptionMenu/GeneralTab.tscn b/game/src/Game/Menu/OptionMenu/GeneralTab.tscn new file mode 100644 index 0000000..4e9ff6a --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/GeneralTab.tscn @@ -0,0 +1,81 @@ +[gd_scene load_steps=5 format=3 uid="uid://duwjal7sd7p6w"] + +[ext_resource type="Script" path="res://src/OptionMenu/GeneralTab.gd" id="1_gbutn"] +[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="2_5cfd7"] +[ext_resource type="Script" path="res://src/OptionMenu/SettingNodes/SettingOptionButton.gd" id="2_msx2u"] +[ext_resource type="Script" path="res://src/OptionMenu/AutosaveIntervalSelector.gd" id="2_t06tb"] + +[node name="GeneralTab" type="HBoxContainer" node_paths=PackedStringArray("initial_focus")] +editor_description = "UI-48, UIFUN-45" +alignment = 1 +script = ExtResource("1_gbutn") +initial_focus = NodePath("VBoxContainer/GridContainer/SavegameFormatSelector") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="Control" type="Control" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.1 + +[node name="GridContainer" type="GridContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +columns = 2 + +[node name="SavegameFormatLabel" type="Label" parent="VBoxContainer/GridContainer"] +layout_mode = 2 +text = "OPTIONS_GENERAL_SAVEFORMAT" + +[node name="SavegameFormatSelector" type="OptionButton" parent="VBoxContainer/GridContainer"] +editor_description = "UI-50" +layout_mode = 2 +focus_neighbor_bottom = NodePath("../AutosaveIntervalSelector") +item_count = 2 +selected = 0 +popup/item_0/text = "OPTIONS_GENERAL_BINARY" +popup/item_0/id = 0 +popup/item_1/text = "OPTIONS_GENERAL_TEXT" +popup/item_1/id = 1 +script = ExtResource("2_msx2u") +section_name = "general" +setting_name = "savegame_format" +default_selected = 0 + +[node name="AutosaveIntervalLabel" type="Label" parent="VBoxContainer/GridContainer"] +layout_mode = 2 +text = "OPTIONS_GENERAL_AUTOSAVE" + +[node name="AutosaveIntervalSelector" type="OptionButton" parent="VBoxContainer/GridContainer"] +editor_description = "UI-15, UIFUN-19" +layout_mode = 2 +focus_neighbor_top = NodePath("../SavegameFormatSelector") +focus_neighbor_bottom = NodePath("../LocaleButton") +item_count = 5 +selected = 0 +popup/item_0/text = "OPTIONS_GENERAL_AUTOSAVE_MONTHLY" +popup/item_0/id = 0 +popup/item_1/text = "OPTIONS_GENERAL_AUTOSAVE_BIMONTHLY" +popup/item_1/id = 1 +popup/item_2/text = "OPTIONS_GENERAL_AUTOSAVE_YEARLY" +popup/item_2/id = 2 +popup/item_3/text = "OPTIONS_GENERAL_AUTOSAVE_BIYEARLY" +popup/item_3/id = 3 +popup/item_4/text = "OPTIONS_GENERAL_AUTOSAVE_NEVER" +popup/item_4/id = 4 +script = ExtResource("2_t06tb") +section_name = "general" +setting_name = "autosave_interval" +default_selected = 0 + +[node name="LocaleLabel" type="Label" parent="VBoxContainer/GridContainer"] +layout_mode = 2 +text = "OPTIONS_GENERAL_LANGUAGE" + +[node name="LocaleButton" parent="VBoxContainer/GridContainer" instance=ExtResource("2_5cfd7")] +editor_description = "UI-79" +layout_mode = 2 +focus_neighbor_top = NodePath("../AutosaveIntervalSelector") +alignment = 0 +text_overrun_behavior = 4 diff --git a/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd b/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd new file mode 100644 index 0000000..4dd86e1 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd @@ -0,0 +1,64 @@ +extends SettingOptionButton + +# REQUIREMENTS +# * UIFUN-24 +# * UIFUN-31 + +@export +var default_value : float = GuiScale.error_guiscale + +func _find_guiscale_index_by_value(value : float) -> int: + for item_index in item_count: + if get_item_metadata(item_index) == value: + return item_index + return -1 + +func _sync_guiscales(to_select : float = GuiScale.get_current_guiscale()) -> void: + clear() + default_selected = -1 + selected = -1 + for guiscale_value in GuiScale.get_guiscale_value_list(): + add_item(GuiScale.get_guiscale_display_name(guiscale_value)) + set_item_metadata(item_count - 1, guiscale_value) + + if guiscale_value == default_value: + default_selected = item_count - 1 + + if guiscale_value == to_select: + selected = item_count - 1 + + if default_selected == -1: + default_selected = item_count - 1 + + if selected == -1: + selected = default_selected + +func _setup_button(): + if default_value <= 0: + default_value = ProjectSettings.get_setting("display/window/stretch/scale") + GuiScale.add_guiscale(default_value, &"default") + _sync_guiscales() + +func _get_value_for_file(select_value : int): + if _valid_index(select_value): + return get_item_metadata(select_value) + else: + return null + +func _set_value_from_file(load_value): + if typeof(load_value) == TYPE_FLOAT: + var target_guiscale : float = load_value + selected = _find_guiscale_index_by_value(target_guiscale) + if selected != -1: return + if GuiScale.add_guiscale(target_guiscale): + _sync_guiscales(target_guiscale) + return + push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name]) + selected = default_selected + +func _on_option_selected(index : int, by_user : bool): + if _valid_index(index): + GuiScale.set_guiscale(get_item_metadata(index)) + else: + push_error("Invalid GuiScaleSelector index: %d" % index) + reset_setting(not by_user) diff --git a/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd b/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd new file mode 100644 index 0000000..7de033a --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd @@ -0,0 +1,18 @@ +extends SettingOptionButton + +func _setup_button() -> void: + clear() + for screen_index in DisplayServer.get_screen_count(): + add_item("Monitor %d" % (screen_index + 1)) + default_selected = get_viewport().get_window().current_screen + +func _on_option_selected(index : int, by_user : bool) -> void: + if _valid_index(index): + var window := get_viewport().get_window() + var mode := window.mode + window.mode = Window.MODE_WINDOWED + get_viewport().get_window().set_current_screen(index) + window.mode = mode + else: + push_error("Invalid MonitorDisplaySelector index: %d" % index) + reset_setting(not by_user) diff --git a/game/src/Game/Menu/OptionMenu/OptionsMenu.gd b/game/src/Game/Menu/OptionMenu/OptionsMenu.gd new file mode 100644 index 0000000..5f6a088 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/OptionsMenu.gd @@ -0,0 +1,68 @@ +extends Control + +# REQUIREMENTS +# * SS-13 + +signal back_button_pressed + +func _ready(): + # Prepare options menu before loading user settings + var tab_bar : TabBar = $Margin/Tab.get_child(0, true) + + # This ends up easier to manage then trying to manually recreate the TabContainer's behavior + # These buttons can be accessed regardless of the tab + var button_list := HBoxContainer.new() + button_list.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) + button_list.alignment = BoxContainer.ALIGNMENT_END + tab_bar.add_child(button_list) + + # REQUIREMENTS + # * UI-12 + # * UIFUN-14 + var reset_button := Button.new() + reset_button.text = "OPTIONS_RESET" + reset_button.pressed.connect(Events.Options.try_reset_settings) + button_list.add_child(reset_button) + + # REQUIREMENTS + # * UI-11 + # * UIFUN-17 + var back_button := Button.new() + back_button.text = "OPTIONS_BACK" + back_button.pressed.connect(_on_back_button_pressed) + button_list.add_child(back_button) + get_viewport().get_window().close_requested.connect(_on_window_close_requested) + _save_overrides.call_deferred() + Events.Options.save_settings.connect(func(_f): self._save_overrides.call_deferred()) + +func _notification(what): + match what: + NOTIFICATION_CRASH: + _on_window_close_requested() + +func _input(event): + if self.is_visible_in_tree(): + if event.is_action_pressed("ui_cancel"): + _on_back_button_pressed() + +func _on_back_button_pressed(): + Events.Options.save_settings_to_file() + back_button_pressed.emit() + +func _on_window_close_requested() -> void: + if visible: + Events.Options.save_settings_to_file() + +func _save_overrides() -> void: + var override_path : String = ProjectSettings.get_setting("application/config/project_settings_override", "") + if override_path.is_empty(): + override_path = ProjectSettings.get_setting(Events.Options.settings_file_path_setting, Events.Options.settings_file_path_default) + var file := ConfigFile.new() + var err_ret := file.load(override_path) + if err_ret != OK: push_error("Failed to load overrides from %s" % override_path) + file.set_value("display", "window/size/mode", get_viewport().get_window().mode) + var resolution : Vector2i = Resolution.get_current_resolution() + file.set_value("display", "window/size/viewport_width", resolution.x) + file.set_value("display", "window/size/viewport_height", resolution.y) + err_ret = file.save(override_path) + if err_ret != OK: push_error("Failed to save overrides to %s" % override_path) diff --git a/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn b/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn new file mode 100644 index 0000000..3156e33 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=8 format=3 uid="uid://cnbfxjy1m6wja"] + +[ext_resource type="Theme" uid="uid://fbxssqcg1s0m" path="res://theme/options_menu.tres" id="1_0up1d"] +[ext_resource type="Script" path="res://src/OptionMenu/OptionsMenu.gd" id="1_tlein"] +[ext_resource type="PackedScene" uid="uid://bq3awxxjn1tuw" path="res://src/OptionMenu/VideoTab.tscn" id="2_ji8xr"] +[ext_resource type="PackedScene" uid="uid://cbtgwpx2wxi33" path="res://src/OptionMenu/SoundTab.tscn" id="3_4w35t"] +[ext_resource type="PackedScene" uid="uid://duwjal7sd7p6w" path="res://src/OptionMenu/GeneralTab.tscn" id="3_6gvf6"] +[ext_resource type="PackedScene" uid="uid://bq7ibhm0txl5p" path="res://addons/keychain/ShortcutEdit.tscn" id="4_vdhjp"] +[ext_resource type="PackedScene" uid="uid://dp2grvybtecqu" path="res://src/OptionMenu/OtherTab.tscn" id="5_ahefp"] + +[node name="OptionsMenu" type="PanelContainer"] +editor_description = "UI-25" +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_0up1d") +theme_type_variation = &"BackgroundPanel" +script = ExtResource("1_tlein") + +[node name="Margin" type="MarginContainer" parent="."] +layout_mode = 2 +theme_type_variation = &"TabMargin" + +[node name="Tab" type="TabContainer" parent="Margin"] +editor_description = "UI-45" +layout_mode = 2 +tab_alignment = 1 +use_hidden_tabs_for_min_size = true + +[node name="General" parent="Margin/Tab" instance=ExtResource("3_6gvf6")] +layout_mode = 2 + +[node name="Video" parent="Margin/Tab" instance=ExtResource("2_ji8xr")] +editor_description = "UI-46, UIFUN-43" +visible = false +layout_mode = 2 + +[node name="Sound" parent="Margin/Tab" instance=ExtResource("3_4w35t")] +editor_description = "UI-47, UIFUN-44" +visible = false +layout_mode = 2 + +[node name="Controls" parent="Margin/Tab" instance=ExtResource("4_vdhjp")] +editor_description = "SS-27, UI-49, UIFUN-46" +visible = false +layout_mode = 2 +alignment = 1 + +[node name="Other" parent="Margin/Tab" instance=ExtResource("5_ahefp")] +layout_mode = 2 diff --git a/game/src/Game/Menu/OptionMenu/OtherTab.tscn b/game/src/Game/Menu/OptionMenu/OtherTab.tscn new file mode 100644 index 0000000..0ffc92d --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/OtherTab.tscn @@ -0,0 +1,18 @@ +[gd_scene format=3 uid="uid://dp2grvybtecqu"] + +[node name="Other" type="Control"] +visible = false +layout_mode = 3 +anchors_preset = 0 + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="Label" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "Spinbox Example :)" + +[node name="SpinBox" type="SpinBox" parent="HBoxContainer"] +layout_mode = 2 diff --git a/game/src/Game/Menu/OptionMenu/QualityPresetSelector.gd b/game/src/Game/Menu/OptionMenu/QualityPresetSelector.gd new file mode 100644 index 0000000..57ba4ab --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/QualityPresetSelector.gd @@ -0,0 +1,4 @@ +extends SettingOptionButton + +func _setup_button(): + pass diff --git a/game/src/Game/Menu/OptionMenu/RefreshRateSelector.gd b/game/src/Game/Menu/OptionMenu/RefreshRateSelector.gd new file mode 100644 index 0000000..31b115b --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/RefreshRateSelector.gd @@ -0,0 +1,5 @@ +extends SettingOptionButton + + +func _setup_button(): + pass diff --git a/game/src/Game/Menu/OptionMenu/ResolutionRevertDialog.gd b/game/src/Game/Menu/OptionMenu/ResolutionRevertDialog.gd new file mode 100644 index 0000000..4d2b8f2 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/ResolutionRevertDialog.gd @@ -0,0 +1,35 @@ +extends ConfirmationDialog +class_name ResolutionRevertDialog + +signal dialog_accepted(button : SettingRevertButton) +signal dialog_reverted(button : SettingRevertButton) + +@export_group("Nodes") +@export var timer : Timer + +var _revert_node : SettingRevertButton = null + +func show_dialog(button : SettingRevertButton, time : float = 0) -> void: + timer.start(time) + popup_centered(Vector2(1,1)) + _revert_node = button + +func _notification(what): + if what == NOTIFICATION_VISIBILITY_CHANGED: + set_process(visible) + if not visible: _revert_node = null + +func _process(_delta) -> void: + dialog_text = tr("OPTIONS_VIDEO_RESOLUTION_DIALOG_TEXT").format({ "time": int(timer.time_left) }) + +func _on_canceled_or_close_requested() -> void: + timer.stop() + dialog_reverted.emit(_revert_node) + +func _on_confirmed() -> void: + timer.stop() + dialog_accepted.emit(_revert_node) + +func _on_resolution_revert_timer_timeout() -> void: + dialog_reverted.emit(_revert_node) + hide() diff --git a/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd new file mode 100644 index 0000000..ebdf718 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd @@ -0,0 +1,91 @@ +extends SettingRevertButton + +# REQUIREMENTS +# * UIFUN-21 +# * UIFUN-28 +# * UIFUN-301 +# * UIFUN-302 + +@export var default_value : Vector2i = Resolution.error_resolution + +func _find_resolution_index_by_value(value : Vector2i) -> int: + for item_index in item_count: + if get_item_metadata(item_index) == value: + return item_index + return -1 + +func _sync_resolutions( + value : Vector2i = Resolution.error_resolution, + _resolution_name = null, + _resolution_display_name = null +) -> void: + clear() + default_selected = -1 + selected = -1 + var resolution_list := Resolution.get_resolution_value_list() + if value != Resolution.error_resolution: + resolution_list.append(value) + for resolution_value in resolution_list: + var display_name := "%sx%s" % [resolution_value.x, resolution_value.y] + var resolution_name := Resolution.get_resolution_name(resolution_value) + if resolution_name == &"Default": + display_name = "Default (%s)" % resolution_name + if not resolution_name.is_empty(): + display_name = "%s (%s)" % [display_name, resolution_name + (", Default" if resolution_value == default_value else "")] + add_item(display_name) + set_item_metadata(item_count - 1, resolution_value) + + if resolution_value == default_value: + default_selected = item_count - 1 + + if resolution_value == Resolution.get_current_resolution(): + selected = item_count - 1 + + if default_selected == -1: + default_selected = item_count - 1 + + if selected == -1: + selected = default_selected + +func _setup_button() -> void: + Resolution.resolution_added.connect(_sync_resolutions) + if default_value.x <= 0: + default_value.x = ProjectSettings.get_setting("display/window/size/viewport_width") + if default_value.y <= 0: + default_value.y = ProjectSettings.get_setting("display/window/size/viewport_height") + if not Resolution.has_resolution(default_value): + Resolution.add_resolution(default_value, &"Default") + else: + _sync_resolutions() + +func _get_value_for_file(select_value : int) -> Variant: + if _valid_index(select_value): + return get_item_metadata(select_value) + else: + return null + +func _set_value_from_file(load_value) -> void: + var target_resolution := Resolution.error_resolution + match typeof(load_value): + TYPE_VECTOR2I: target_resolution = load_value + TYPE_STRING, TYPE_STRING_NAME: target_resolution = Resolution.get_resolution_value_from_string(load_value) + if target_resolution != Resolution.error_resolution: + selected = _find_resolution_index_by_value(target_resolution) + if selected != -1: return + if Resolution.add_resolution(target_resolution): + Resolution.set_resolution(target_resolution) + return + push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name]) + selected = default_selected + +func _on_option_selected(index : int, by_user : bool) -> void: + if _valid_index(index): + if by_user: + print("Start Revert Countdown!") + revert_dialog.show_dialog.call_deferred(self) + previous_index = _find_resolution_index_by_value(Resolution.get_current_resolution()) + + Resolution.set_resolution(get_item_metadata(index)) + else: + push_error("Invalid ResolutionSelector index: %d" % index) + reset_setting(not by_user) diff --git a/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd b/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd new file mode 100644 index 0000000..af95901 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd @@ -0,0 +1,48 @@ +extends SettingRevertButton + +# REQUIREMENTS +# * UIFUN-42 + +enum ScreenMode { Unknown = -1, Fullscreen, Borderless, Windowed } + +func get_screen_mode_from_window_mode(window_mode : int) -> ScreenMode: + match window_mode: + Window.MODE_EXCLUSIVE_FULLSCREEN: + return ScreenMode.Fullscreen + Window.MODE_FULLSCREEN: + return ScreenMode.Borderless + Window.MODE_WINDOWED: + return ScreenMode.Windowed + _: + return ScreenMode.Unknown + +func get_window_mode_from_screen_mode(screen_mode : int) -> Window.Mode: + match screen_mode: + ScreenMode.Fullscreen: + return Window.MODE_EXCLUSIVE_FULLSCREEN + ScreenMode.Borderless: + return Window.MODE_FULLSCREEN + ScreenMode.Windowed: + return Window.MODE_WINDOWED + _: + return Window.MODE_EXCLUSIVE_FULLSCREEN + +func _setup_button(): + default_selected = get_screen_mode_from_window_mode(get_viewport().get_window().mode) + selected = default_selected + +func _on_option_selected(index : int, by_user : bool) -> void: + if _valid_index(index): + if by_user: + print("Start Revert Countdown!") + revert_dialog.show_dialog.call_deferred(self) + previous_index = get_screen_mode_from_window_mode(get_viewport().get_window().mode) + + var current_resolution := Resolution.get_current_resolution() + var window_mode := get_window_mode_from_screen_mode(index) + Resolution.window_mode_changed.emit(window_mode) + get_viewport().get_window().mode = window_mode + Resolution.set_resolution(current_resolution) + else: + push_error("Invalid ScreenModeSelector index: %d" % index) + reset_setting(not by_user) diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd new file mode 100644 index 0000000..6fa30ed --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd @@ -0,0 +1,41 @@ +extends HSlider +class_name SettingHSlider + +@export +var section_name : String = "setting" + +@export +var setting_name : String = "setting_hslider" + +@export +var default_value : float = 0 + +func _ready(): + Events.Options.load_settings.connect(load_setting) + Events.Options.save_settings.connect(save_setting) + Events.Options.reset_settings.connect(reset_setting) + +func load_setting(file : ConfigFile): + if file == null: return + var load_value = file.get_value(section_name, setting_name, default_value) + match typeof(load_value): + TYPE_FLOAT, TYPE_INT: + if value == load_value: value_changed.emit(value) + value = load_value + return + TYPE_STRING, TYPE_STRING_NAME: + var load_string := load_value as String + if load_string.is_valid_float(): + load_value = load_string.to_float() + if value == load_value: value_changed.emit(value) + value = load_value + return + push_error("Setting value '%s' invalid for setting [%s] \"%s\"" % [load_value, section_name, setting_name]) + value = default_value + +func save_setting(file : ConfigFile): + if file == null: return + file.set_value(section_name, setting_name, value) + +func reset_setting(): + value = default_value diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd new file mode 100644 index 0000000..c5a805e --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd @@ -0,0 +1,77 @@ +extends OptionButton +class_name SettingOptionButton + +signal option_selected(index : int, by_user : bool) + +@export +var section_name : String = "setting" + +@export +var setting_name : String = "setting_optionbutton" + +@export +var default_selected : int = -1: + get: return default_selected + set(v): + if v < 0 or item_count == 0: + default_selected = -1 + return + default_selected = v % item_count + +func _valid_index(index : int) -> bool: + return 0 <= index and index < item_count + +func _get_value_for_file(select_value : int): + if _valid_index(select_value): + return select_value + else: + return null + +func _set_value_from_file(load_value) -> void: + match typeof(load_value): + TYPE_INT: + if _valid_index(load_value): + selected = load_value + return + TYPE_STRING, TYPE_STRING_NAME: + var load_string := load_value as String + if load_string.is_valid_int(): + var load_int := load_string.to_int() + if _valid_index(load_int): + selected = load_int + return + for item_index in item_count: + if load_string == get_item_text(item_index): + selected = item_index + return + push_error("Setting value '%s' invalid for setting [%s] \"%s\"" % [load_value, section_name, setting_name]) + selected = default_selected + +func _setup_button() -> void: + pass + +func _ready(): + Events.Options.load_settings.connect(load_setting) + Events.Options.save_settings.connect(save_setting) + Events.Options.reset_settings.connect(reset_setting) + item_selected.connect(func(index : int): option_selected.emit(index, true)) + _setup_button() + if not _valid_index(default_selected) or selected == -1: + var msg := "Failed to generate %s %s options." % [setting_name, section_name] + push_error(msg) + OS.alert(msg, "%s Options Error" % section_name) + get_tree().quit() + +func load_setting(file : ConfigFile) -> void: + if file == null: return + _set_value_from_file(file.get_value(section_name, setting_name, _get_value_for_file(default_selected))) + option_selected.emit(selected, false) + +func save_setting(file : ConfigFile) -> void: + if file == null: return + file.set_value(section_name, setting_name, _get_value_for_file(selected)) + +func reset_setting(no_emit : bool = false) -> void: + selected = default_selected + if not no_emit: + option_selected.emit(selected, false) diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd new file mode 100644 index 0000000..945d35b --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd @@ -0,0 +1,27 @@ +extends SettingOptionButton +class_name SettingRevertButton + +@export_group("Nodes") +@export var revert_dialog : ResolutionRevertDialog + +var previous_index : int = -1 + +func _ready(): + super() + if revert_dialog != null: + revert_dialog.visibility_changed.connect(_on_revert_dialog_visibility_changed) + revert_dialog.dialog_accepted.connect(_on_accepted) + revert_dialog.dialog_reverted.connect(_on_reverted) + +func _on_revert_dialog_visibility_changed() -> void: + disabled = revert_dialog.visible + if not revert_dialog.visible: + previous_index = -1 + +func _on_reverted(button : SettingRevertButton) -> void: + if button != self: return + selected = previous_index + option_selected.emit(selected, false) + +func _on_accepted(button : SettingRevertButton) -> void: + if button != self: return diff --git a/game/src/Game/Menu/OptionMenu/SoundTab.gd b/game/src/Game/Menu/OptionMenu/SoundTab.gd new file mode 100644 index 0000000..c707605 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SoundTab.gd @@ -0,0 +1,4 @@ +extends HBoxContainer + +func _on_ear_exploder_toggled(button_pressed): + print("KABOOM!!!" if button_pressed else "DEFUSED!!!") diff --git a/game/src/Game/Menu/OptionMenu/SoundTab.tscn b/game/src/Game/Menu/OptionMenu/SoundTab.tscn new file mode 100644 index 0000000..10d7f10 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SoundTab.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=3 format=3 uid="uid://cbtgwpx2wxi33"] + +[ext_resource type="Script" path="res://src/OptionMenu/SoundTab.gd" id="1_a7k0s"] +[ext_resource type="PackedScene" uid="uid://dy4si8comamnv" path="res://src/OptionMenu/VolumeGrid.tscn" id="1_okpft"] + +[node name="Sound" type="HBoxContainer"] +alignment = 1 +script = ExtResource("1_a7k0s") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="Control" type="Control" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.1 + +[node name="VolumeGrid" parent="VBoxContainer" instance=ExtResource("1_okpft")] +layout_mode = 2 + +[node name="ButtonGrid" type="GridContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 2 +columns = 2 + +[node name="Spacer" type="Control" parent="VBoxContainer/ButtonGrid"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="EarExploder" type="CheckButton" parent="VBoxContainer/ButtonGrid"] +layout_mode = 2 +text = "Explode Eardrums on Startup?" + +[connection signal="toggled" from="VBoxContainer/ButtonGrid/EarExploder" to="." method="_on_ear_exploder_toggled"] diff --git a/game/src/Game/Menu/OptionMenu/VideoTab.gd b/game/src/Game/Menu/OptionMenu/VideoTab.gd new file mode 100644 index 0000000..3d98678 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/VideoTab.gd @@ -0,0 +1,9 @@ +extends HBoxContainer + +@export var initial_focus: Control + +func _notification(what : int) -> void: + match(what): + NOTIFICATION_VISIBILITY_CHANGED: + if visible and is_inside_tree(): + initial_focus.grab_focus() diff --git a/game/src/Game/Menu/OptionMenu/VideoTab.tscn b/game/src/Game/Menu/OptionMenu/VideoTab.tscn new file mode 100644 index 0000000..244f481 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/VideoTab.tscn @@ -0,0 +1,181 @@ +[gd_scene load_steps=9 format=3 uid="uid://bq3awxxjn1tuw"] + +[ext_resource type="Script" path="res://src/OptionMenu/ResolutionSelector.gd" id="1_i8nro"] +[ext_resource type="Script" path="res://src/OptionMenu/VideoTab.gd" id="1_jvv62"] +[ext_resource type="Script" path="res://src/OptionMenu/ScreenModeSelector.gd" id="2_wa7vw"] +[ext_resource type="Script" path="res://src/OptionMenu/GuiScaleSelector.gd" id="3_pgc5d"] +[ext_resource type="Script" path="res://src/OptionMenu/MonitorDisplaySelector.gd" id="3_y6lyb"] +[ext_resource type="Script" path="res://src/OptionMenu/RefreshRateSelector.gd" id="4_381mg"] +[ext_resource type="Script" path="res://src/OptionMenu/QualityPresetSelector.gd" id="5_srg4v"] +[ext_resource type="Script" path="res://src/OptionMenu/ResolutionRevertDialog.gd" id="8_802cr"] + +[node name="Video" type="HBoxContainer" node_paths=PackedStringArray("initial_focus")] +editor_description = "UI-46" +alignment = 1 +script = ExtResource("1_jvv62") +initial_focus = NodePath("VideoSettingList/VideoSettingGrid/ResolutionSelector") + +[node name="VideoSettingList" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="Control" type="Control" parent="VideoSettingList"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.1 + +[node name="VideoSettingGrid" type="GridContainer" parent="VideoSettingList"] +layout_mode = 2 +size_flags_vertical = 3 +columns = 2 + +[node name="ResolutionLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_RESOLUTION" + +[node name="ResolutionSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid" node_paths=PackedStringArray("revert_dialog")] +editor_description = "UI-19" +layout_mode = 2 +focus_neighbor_bottom = NodePath("../ScreenModeSelector") +item_count = 1 +selected = 0 +popup/item_0/text = "MISSING" +popup/item_0/id = 0 +script = ExtResource("1_i8nro") +revert_dialog = NodePath("../../../ResolutionRevertDialog") +section_name = "video" +setting_name = "resolution" + +[node name="GuiScaleLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_GUI_SCALE" + +[node name="GuiScaleSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] +editor_description = "UI-23" +layout_mode = 2 +focus_neighbor_bottom = NodePath("../ScreenModeSelector") +item_count = 1 +selected = 0 +popup/item_0/text = "MISSING" +popup/item_0/id = 0 +script = ExtResource("3_pgc5d") +section_name = "video" +setting_name = "gui_scale" + +[node name="ScreenModeLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +editor_description = "UI-44" +layout_mode = 2 +text = "OPTIONS_VIDEO_SCREEN_MODE" + +[node name="ScreenModeSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid" node_paths=PackedStringArray("revert_dialog")] +layout_mode = 2 +focus_neighbor_top = NodePath("../ResolutionSelector") +focus_neighbor_bottom = NodePath("../MonitorDisplaySelector") +item_count = 3 +selected = 0 +popup/item_0/text = "OPTIONS_VIDEO_FULLSCREEN" +popup/item_0/id = 0 +popup/item_1/text = "OPTIONS_VIDEO_BORDERLESS" +popup/item_1/id = 1 +popup/item_2/text = "OPTIONS_VIDEO_WINDOWED" +popup/item_2/id = 2 +script = ExtResource("2_wa7vw") +revert_dialog = NodePath("../../../ResolutionRevertDialog") +section_name = "video" +setting_name = "mode_selected" + +[node name="MonitorSelectionLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_MONITOR_SELECTION" + +[node name="MonitorDisplaySelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +focus_neighbor_top = NodePath("../ScreenModeSelector") +focus_neighbor_bottom = NodePath("../RefreshRateSelector") +item_count = 1 +selected = 0 +popup/item_0/text = "MISSING" +popup/item_0/id = 0 +script = ExtResource("3_y6lyb") +section_name = "video" +setting_name = "current_screen" + +[node name="RefreshRateLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_REFRESH_RATE" + +[node name="RefreshRateSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] +editor_description = "UI-18, UIFUN-20" +layout_mode = 2 +tooltip_text = "OPTIONS_VIDEO_REFRESH_RATE_TOOLTIP" +focus_neighbor_top = NodePath("../MonitorDisplaySelector") +focus_neighbor_bottom = NodePath("../QualityPresetSelector") +item_count = 8 +selected = 0 +popup/item_0/text = "VSYNC" +popup/item_0/id = 0 +popup/item_1/text = "30hz" +popup/item_1/id = 1 +popup/item_2/text = "60hz" +popup/item_2/id = 2 +popup/item_3/text = "90hz" +popup/item_3/id = 3 +popup/item_4/text = "120hz" +popup/item_4/id = 4 +popup/item_5/text = "144hz" +popup/item_5/id = 5 +popup/item_6/text = "365hz" +popup/item_6/id = 6 +popup/item_7/text = "Unlimited" +popup/item_7/id = 7 +script = ExtResource("4_381mg") +section_name = "video" +setting_name = "refresh_rate" +default_selected = 0 + +[node name="QualityPresetLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_QUALITY" + +[node name="QualityPresetSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] +editor_description = "UI-21, UIFUN-22" +layout_mode = 2 +focus_neighbor_top = NodePath("../RefreshRateSelector") +item_count = 5 +selected = 1 +popup/item_0/text = "Low" +popup/item_0/id = 0 +popup/item_1/text = "Medium" +popup/item_1/id = 1 +popup/item_2/text = "High" +popup/item_2/id = 2 +popup/item_3/text = "Ultra" +popup/item_3/id = 3 +popup/item_4/text = "Custom" +popup/item_4/id = 4 +script = ExtResource("5_srg4v") +section_name = "video" +setting_name = "quality_preset" +default_selected = 1 + +[node name="ResolutionRevertDialog" type="ConfirmationDialog" parent="." node_paths=PackedStringArray("timer")] +editor_description = "UI-873" +disable_3d = true +title = "OPTIONS_VIDEO_RESOLUTION_DIALOG_TITLE" +size = Vector2i(730, 100) +ok_button_text = "DIALOG_OK" +cancel_button_text = "DIALOG_CANCEL" +script = ExtResource("8_802cr") +timer = NodePath("ResolutionRevertTimer") + +[node name="ResolutionRevertTimer" type="Timer" parent="ResolutionRevertDialog"] +wait_time = 5.0 +one_shot = true + +[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/ResolutionSelector" to="VideoSettingList/VideoSettingGrid/ResolutionSelector" method="_on_option_selected"] +[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/GuiScaleSelector" to="VideoSettingList/VideoSettingGrid/GuiScaleSelector" method="_on_option_selected"] +[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/ScreenModeSelector" to="VideoSettingList/VideoSettingGrid/ScreenModeSelector" method="_on_option_selected"] +[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/MonitorDisplaySelector" to="VideoSettingList/VideoSettingGrid/MonitorDisplaySelector" method="_on_option_selected"] +[connection signal="canceled" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_canceled_or_close_requested"] +[connection signal="close_requested" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_canceled_or_close_requested"] +[connection signal="confirmed" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_confirmed"] +[connection signal="timeout" from="ResolutionRevertDialog/ResolutionRevertTimer" to="ResolutionRevertDialog" method="_on_resolution_revert_timer_timeout"] diff --git a/game/src/Game/Menu/OptionMenu/VolumeGrid.gd b/game/src/Game/Menu/OptionMenu/VolumeGrid.gd new file mode 100644 index 0000000..46613b4 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/VolumeGrid.gd @@ -0,0 +1,70 @@ +extends GridContainer + +const RATIO_FOR_LINEAR : float = 100 + +var _slider_dictionary : Dictionary + +var initial_focus : Control + +func get_db_as_volume_value(db : float) -> float: + # db_to_linear produces a float between 0 and 1 from a db value + return db_to_linear(db) * RATIO_FOR_LINEAR + +func get_volume_value_as_db(value : float) -> float: + # linear_to_db consumes a float between 0 and 1 to produce the db value + return linear_to_db(value / RATIO_FOR_LINEAR) + +func add_volume_row(bus_name : String, bus_index : int) -> HSlider: + var volume_label := Label.new() + if bus_name == "Master": + volume_label.text = "MASTER_BUS" + else: + volume_label.text = bus_name + add_child(volume_label) + + var volume_slider := SettingHSlider.new() + volume_slider.section_name = "audio" + volume_slider.setting_name = volume_label.text + volume_slider.custom_minimum_size = Vector2(290, 0) + volume_slider.size_flags_vertical = Control.SIZE_FILL + volume_slider.min_value = 0 + volume_slider.default_value = 100 + volume_slider.max_value = 120 # 120 so volume can be boosted somewhat + volume_slider.value_changed.connect(_on_slider_value_changed.bind(bus_index)) + add_child(volume_slider) + + _slider_dictionary[volume_label.text] = volume_slider + if not initial_focus: initial_focus = volume_slider + return volume_slider + +# REQUIREMENTS +# * UI-22 +func _ready(): + for bus_index in AudioServer.bus_count: + add_volume_row(AudioServer.get_bus_name(bus_index), bus_index) + +func _notification(what : int) -> void: + match(what): + NOTIFICATION_VISIBILITY_CHANGED: + if visible and is_inside_tree() and initial_focus: initial_focus.grab_focus() + +# REQUIREMENTS +# * UIFUN-30 +func _on_slider_value_changed(value : float, bus_index : int) -> void: + AudioServer.set_bus_volume_db(bus_index, get_volume_value_as_db(value)) + + +func _on_options_menu_load_settings(load_file : ConfigFile): + for volume_slider in _slider_dictionary.values(): + volume_slider.load_setting(load_file) + +# REQUIREMENTS +# * UIFUN-23 +func _on_options_menu_save_settings(save_file : ConfigFile): + for volume_slider in _slider_dictionary.values(): + volume_slider.save_setting(save_file) + + +func _on_options_menu_reset_settings(): + for volume_slider in _slider_dictionary.values(): + volume_slider.reset_setting() diff --git a/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn b/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn new file mode 100644 index 0000000..6d4de3c --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://dy4si8comamnv"] + +[ext_resource type="Script" path="res://src/OptionMenu/VolumeGrid.gd" id="1_wb64h"] + +[node name="VolumeGrid" type="GridContainer"] +size_flags_vertical = 0 +columns = 2 +script = ExtResource("1_wb64h") diff --git a/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd new file mode 100644 index 0000000..bff0bb5 --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd @@ -0,0 +1,123 @@ +extends Control + +@export var _save_scene : PackedScene + +@export_group("Nodes") +@export var _label : Label +@export var _scroll_list : BoxContainer +@export var _save_line_edit : LineEdit +@export var _save_load_button : Button +@export var _tag_selection_tab : TabBar +@export var _delete_dialog : ConfirmationDialog +@export var _overwrite_dialog : ConfirmationDialog + +var is_save_menu : bool = true +var _id_to_tag : Array[StringName] = [] + +func filter_for_tag(tag : StringName) -> void: + for child in _scroll_list.get_children(): + if tag == &"": + child.show() + else: + if tag == child.resource.session_tag: + child.show() + else: + child.hide() + +# Requirements +# * UIFUN-78 +func show_for_load() -> void: + _label.text = "SAVELOADMENU_LOAD_TITLE" + _save_load_button.text = "SAVELOADMENU_LOAD_BUTTON" + _save_line_edit.editable = false + is_save_menu = false + show() + +# Requirements +# * UIFUN-77 +func show_for_save() -> void: + _label.text = "SAVELOADMENU_SAVE_TITLE" + _save_load_button.text = "SAVELOADMENU_SAVE_BUTTON" + _save_line_edit.editable = true + is_save_menu = true + show() + +func _build_save_list() -> void: + _tag_selection_tab.add_tab("SAVELOADMENU_TABSELECTIONTABBAR_ALL") + for save_name in SaveManager._save_dictionary: + var save : SaveResource = SaveManager._save_dictionary[save_name] + var save_node := _create_save_node(save) + _scroll_list.add_child(save_node) + if not _id_to_tag.has(save.session_tag): + _id_to_tag.append(save.session_tag) + _tag_selection_tab.add_tab(save.session_tag) + +func _create_save_node(resource : SaveResource) -> Control: + var save_node = _save_scene.instantiate() + save_node.resource = resource + save_node.pressed.connect(_on_save_node_pressed.bind(save_node)) + save_node.request_to_delete.connect(_on_save_node_delete_requested.bind(save_node)) + return save_node + +func _queue_clear_scroll_list() -> void: + for child in _scroll_list.get_children(): + child.queue_free() + _tag_selection_tab.clear_tabs() + _id_to_tag.clear() + +# REQUIREMENTS: +# * UIFUN-84 +# * UIFUN-89 +func _on_close_button_pressed() -> void: + hide() + +func _on_delete_dialog_confirmed() -> void: + _requested_node_to_delete.resource.delete() + _requested_node_to_delete.queue_free() + +# REQUIREMENTS: +# * UIFUN-83 +func _on_overwrite_dialog_confirmed() -> void: + SaveManager.add_or_replace_save(SaveManager.make_new_save(_submitted_text)) + _on_close_button_pressed() + +var _submitted_text : String = "" +func _on_save_line_edit_text_submitted(new_text) -> void: + _submitted_text = new_text + if SaveManager.has_save(new_text): + _overwrite_dialog.dialog_text = tr("SAVELOADMENU_OVERWRITE_DIALOG_TEXT").format({ "file_name": _submitted_text }) + _overwrite_dialog.title = tr("SAVELOADMENU_OVERWRITE_DIALOG_TITLE").format({ "file_name": _submitted_text }) + _overwrite_dialog.popup_centered() + return + _on_overwrite_dialog_confirmed() + +func _on_save_load_button_pressed() -> void: + if is_save_menu: + _save_line_edit.text_submitted.emit(_save_line_edit.text) + +var _requested_node_to_delete : Control +func _on_save_node_delete_requested(node : Control) -> void: + _requested_node_to_delete = node + _delete_dialog.dialog_text = tr("SAVELOADMENU_DELETE_DIALOG_TEXT").format({ "file_name": _requested_node_to_delete.resource.save_name }) + _delete_dialog.title = tr("SAVELOADMENU_DELETE_DIALOG_TITLE").format({ "file_name": _requested_node_to_delete.resource.save_name }) + _delete_dialog.popup_centered() + +# REQUIREMENTS: +# * UIFUN-81 +# * UIFUN-86 +func _on_save_node_pressed(node : Control) -> void: + if is_save_menu: + _save_line_edit.text = node.resource.save_name + +func _on_tag_selection_tab_bar_tab_changed(tab) -> void: + if tab == 0: + filter_for_tag(&"") + else: + filter_for_tag(_id_to_tag[tab - 1]) + +func _on_visibility_changed() -> void: + if visible: + _build_save_list() + else: + _queue_clear_scroll_list() + SaveManager.flush_save() diff --git a/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn new file mode 100644 index 0000000..e9f068e --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn @@ -0,0 +1,109 @@ +[gd_scene load_steps=5 format=3 uid="uid://d3g6wbvwflmyk"] + +[ext_resource type="Script" path="res://src/SaveLoadMenu/SaveLoadMenu.gd" id="1_3jkds"] +[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="2_fc6r3"] + +[sub_resource type="InputEventAction" id="InputEventAction_8vo2t"] +action = &"ui_accept" +pressed = true + +[sub_resource type="Shortcut" id="Shortcut_o1f2l"] +events = [SubResource("InputEventAction_8vo2t")] + +[node name="SaveLoadMenu" type="MarginContainer" node_paths=PackedStringArray("_label", "_scroll_list", "_save_line_edit", "_save_load_button", "_tag_selection_tab", "_delete_dialog", "_overwrite_dialog")] +editor_description = "UI-82, UI-89" +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 250 +theme_override_constants/margin_top = 100 +theme_override_constants/margin_right = 250 +theme_override_constants/margin_bottom = 100 +script = ExtResource("1_3jkds") +_save_scene = ExtResource("2_fc6r3") +_label = NodePath("SaveLoadPanel/SaveLoadList/TitleBarList/SaveLoadLabel") +_scroll_list = NodePath("SaveLoadPanel/SaveLoadList/SaveLoadScroll/SaveLoadScrollList") +_save_line_edit = NodePath("SaveLoadPanel/SaveLoadList/SaveLineEdit") +_save_load_button = NodePath("SaveLoadPanel/SaveLoadList/SaveLoadButton") +_tag_selection_tab = NodePath("SaveLoadPanel/SaveLoadList/TagSelectionList/TagSelectionTabBar") +_delete_dialog = NodePath("DeleteDialog") +_overwrite_dialog = NodePath("OverwriteDialog") + +[node name="SaveLoadPanel" type="PanelContainer" parent="."] +layout_mode = 2 + +[node name="SaveLoadList" type="VBoxContainer" parent="SaveLoadPanel"] +layout_mode = 2 + +[node name="TitleBarList" type="HBoxContainer" parent="SaveLoadPanel/SaveLoadList"] +layout_mode = 2 +alignment = 2 + +[node name="SaveLoadLabel" type="Label" parent="SaveLoadPanel/SaveLoadList/TitleBarList"] +layout_mode = 2 +size_flags_horizontal = 6 +text = "SAVELOADMENU_SAVE_TITLE" + +[node name="CloseButton" type="Button" parent="SaveLoadPanel/SaveLoadList/TitleBarList"] +editor_description = "UI-87, UI-94" +layout_mode = 2 +text = "X" + +[node name="TagSelectionList" type="HBoxContainer" parent="SaveLoadPanel/SaveLoadList"] +layout_mode = 2 + +[node name="TagSelectionLabel" type="Label" parent="SaveLoadPanel/SaveLoadList/TagSelectionList"] +layout_mode = 2 +text = "SAVELOADMENU_SESSION" + +[node name="TagSelectionTabBar" type="TabBar" parent="SaveLoadPanel/SaveLoadList/TagSelectionList"] +layout_mode = 2 +size_flags_horizontal = 3 +tab_count = 1 +tab_0/title = "SAVELOADMENU_TABSELECTIONTABBAR_ALL" + +[node name="SaveLoadScroll" type="ScrollContainer" parent="SaveLoadPanel/SaveLoadList"] +editor_description = "UI-83, UI-90" +layout_mode = 2 +size_flags_vertical = 3 + +[node name="SaveLoadScrollList" type="VBoxContainer" parent="SaveLoadPanel/SaveLoadList/SaveLoadScroll"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="SaveLineEdit" type="LineEdit" parent="SaveLoadPanel/SaveLoadList"] +editor_description = "UI-85, UI-92" +layout_mode = 2 + +[node name="SaveLoadButton" type="Button" parent="SaveLoadPanel/SaveLoadList"] +editor_description = "UIFUN-82, UIFUN-87" +layout_mode = 2 +size_flags_horizontal = 4 +shortcut = SubResource("Shortcut_o1f2l") +shortcut_feedback = false +text = "SAVELOADMENU_SAVE_BUTTON" + +[node name="DeleteDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "SAVELOADMENU_DELETE_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "SAVELOADMENU_DELETE_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[node name="OverwriteDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "SAVELOADMENU_OVERWRITE_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "SAVELOADMENU_OVERWRITE_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] +[connection signal="pressed" from="SaveLoadPanel/SaveLoadList/TitleBarList/CloseButton" to="." method="_on_close_button_pressed"] +[connection signal="tab_changed" from="SaveLoadPanel/SaveLoadList/TagSelectionList/TagSelectionTabBar" to="." method="_on_tag_selection_tab_bar_tab_changed"] +[connection signal="text_submitted" from="SaveLoadPanel/SaveLoadList/SaveLineEdit" to="." method="_on_save_line_edit_text_submitted"] +[connection signal="pressed" from="SaveLoadPanel/SaveLoadList/SaveLoadButton" to="." method="_on_save_load_button_pressed"] +[connection signal="confirmed" from="DeleteDialog" to="." method="_on_delete_dialog_confirmed"] +[connection signal="confirmed" from="OverwriteDialog" to="." method="_on_overwrite_dialog_confirmed"] diff --git a/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.gd b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.gd new file mode 100644 index 0000000..5fe4917 --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.gd @@ -0,0 +1,41 @@ +@tool +extends LobbyPanelButton + +signal request_to_delete + +@export_group("Nodes") +@export var country_flag : TextureRect +@export var date_label : Label +@export var delete_button : BaseButton + +var resource : SaveResource: + get: + return resource + set(value): + if resource != null: + resource.changed.disconnect(_resource_changed) + resource = value + if resource != null: + resource.changed.connect(_resource_changed) + _resource_changed() + +func get_text() -> StringName: + return resource.save_name + +func set_text(value : StringName) -> void: + if resource != null: + resource.save_name = value + +func _ready(): + _resource_changed() + +func _is_start_date() -> bool: + return false + +func _resource_changed() -> void: + if resource == null: return + name_label.text = resource.save_name + date_label.text = Time.get_datetime_string_from_unix_time(resource.get_save_file_time(), true) + +func _on_delete_button_pressed() -> void: + request_to_delete.emit() diff --git a/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn new file mode 100644 index 0000000..d2d0a41 --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn @@ -0,0 +1,58 @@ +[gd_scene load_steps=2 format=3 uid="uid://d2s7roinx2or7"] + +[ext_resource type="Script" path="res://src/SaveLoadMenu/SavePanelButton.gd" id="1_rtuo6"] + +[node name="SavePanelButton" type="Container" node_paths=PackedStringArray("country_flag", "date_label", "delete_button", "background_button", "name_label")] +editor_description = "SS-18, UI-40, UI-84, UI-86, UI-91, UI-93" +offset_right = 276.0 +offset_bottom = 48.0 +script = ExtResource("1_rtuo6") +country_flag = NodePath("SaveList/CountryFlag") +date_label = NodePath("SaveList/DateLabel") +delete_button = NodePath("SaveList/DeleteButton") +background_button = NodePath("BackgroundButton") +name_label = NodePath("SaveList/NameLabel") + +[node name="BackgroundButton" type="Button" parent="."] +layout_mode = 2 +theme_type_variation = &"ButtonContainer" + +[node name="SaveList" type="HBoxContainer" parent="."] +layout_mode = 2 +mouse_filter = 2 + +[node name="CountryFlag" type="TextureRect" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 4 +mouse_filter = 2 + +[node name="NameLabel" type="Label" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 1 +text = "PLACEHOLDER" +vertical_alignment = 1 + +[node name="DateLabel" type="Label" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 1 +text = "00.00.0000" +vertical_alignment = 1 + +[node name="Separator" type="Control" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 3 +mouse_filter = 2 + +[node name="DeleteButton" type="Button" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 8 +text = "x" + +[connection signal="button_down" from="BackgroundButton" to="." method="_on_background_button_button_down"] +[connection signal="button_up" from="BackgroundButton" to="." method="_on_background_button_button_up"] +[connection signal="pressed" from="BackgroundButton" to="." method="_on_background_button_pressed"] +[connection signal="toggled" from="BackgroundButton" to="." method="_on_background_button_toggled"] +[connection signal="pressed" from="SaveList/DeleteButton" to="." method="_on_delete_button_pressed"] diff --git a/game/src/Game/Menu/SaveLoadMenu/SaveResource.gd b/game/src/Game/Menu/SaveLoadMenu/SaveResource.gd new file mode 100644 index 0000000..5e7faa6 --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SaveResource.gd @@ -0,0 +1,59 @@ +extends Resource +class_name SaveResource + +signal file_flushed(path : String) +signal file_loaded +signal file_moved_to_trash +signal file_deleted +signal trash_moved +signal deleted + +var save_name : StringName: + get: return save_name + set(v): + save_name = v + file.set_value("Save", "name", save_name) + emit_changed() +var session_tag : StringName: + get: return session_tag + set(v): + session_tag = v + file.set_value("Save", "session_tag", v) + emit_changed() +var file_path : String: + get: return file_path + set(v): + file_path = v + emit_changed() +var file : ConfigFile = ConfigFile.new() + +func set_file_path(name : StringName, path : String): + file_path = path + save_name = name + +func flush_save() -> Error: + file_flushed.emit(file_path) + var result := file.save(file_path) + file.clear() + return result + +func load_save(path : String = file_path) -> Error: + file_loaded.emit() + var result := file.load(path) + session_tag = file.get_value("Save", "session_tag", session_tag) + if path != file_path: + set_file_path(file.get_value("Save", "name", save_name), path) + return result + +func get_save_file_time() -> int: + return FileAccess.get_modified_time(file_path) + +func move_to_trash() -> Error: + trash_moved.emit() + file_moved_to_trash.emit() + return OS.move_to_trash(file_path) + +func delete() -> Error: + deleted.emit() + file_deleted.emit() + return DirAccess.remove_absolute(file_path) |