aboutsummaryrefslogtreecommitdiff
path: root/game/src/Credits
diff options
context:
space:
mode:
author Brendan Griffiths <96725360+Orwellian-225@users.noreply.github.com>2023-03-01 17:00:24 +0100
committer GitHub <noreply@github.com>2023-03-01 17:00:24 +0100
commit4e099cf1d3f5fa37e9aa520d90aaf505fee3ce23 (patch)
tree5355285405336b55eeab21ca5ecc24c8e9ecf1d8 /game/src/Credits
parent2062aaf394ee6581161add4bcb23076475e236ac (diff)
add: credits.csv - req: FS4 (#16)
Requirements met by this PR: SS-17 SS-29 [1] UI-32 UI-34 UIFUN-36 UI-35 UI-38 UIFUN-37 FS-4
Diffstat (limited to 'game/src/Credits')
-rw-r--r--game/src/Credits/Credits.gd116
-rw-r--r--game/src/Credits/Credits.tscn49
-rw-r--r--game/src/Credits/PersonLabelSettings.tres5
-rw-r--r--game/src/Credits/ProjectLabelSettings.tres5
-rw-r--r--game/src/Credits/RoleLabelSettings.tres5
5 files changed, 180 insertions, 0 deletions
diff --git a/game/src/Credits/Credits.gd b/game/src/Credits/Credits.gd
new file mode 100644
index 0000000..902207b
--- /dev/null
+++ b/game/src/Credits/Credits.gd
@@ -0,0 +1,116 @@
+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
+
+# TODO: implement for theme instead
+# waiting for https://github.com/OpenVic2Project/OpenVic2/pull/48
+@export_group("Label Settings", "label_settings_")
+@export
+var label_settings_project : LabelSettings
+
+@export
+var label_settings_role : LabelSettings
+
+@export
+var label_settings_personel : LabelSettings
+
+@export
+var credits_list: VBoxContainer
+
+# REQUIREMENTS:
+# * 1.5 Credits Menu
+# * SS-17
+
+# REQUIREMENTS
+# * FS-4
+func load_credit_file(path):
+ var roles = {}
+ var core_credits = FileAccess.open(path, FileAccess.READ)
+
+ while not core_credits.eof_reached():
+ var line = core_credits.get_csv_line()
+
+ # If the line does not have an identifiable role or is empty then skip it
+ if line[0].is_empty():
+ continue
+
+ var role := line[0].to_upper()
+ var person : String = line[1] # Cannot infer with := as line[1] does not have a set type
+
+ if role not in roles.keys():
+ roles[role] = []
+ roles[role].push_back(person)
+ else:
+ roles[role].push_back(person)
+
+ return roles
+
+# REQUIREMENTS:
+# * UI-34, UI-35
+func make_project_credits(project):
+ var project_credits_list = VBoxContainer.new()
+ var project_credits_label = Label.new()
+
+
+ # Spartan has some suggestions here but for now its good enough. Refer
+ # to PR 16 resolved comments for further details
+ project_credits_list.name = 'Credits' + project['TITLE'][0]
+ project_credits_label.name = 'Label' + project['TITLE'][0]
+ project_credits_label.text = project['TITLE'][0]
+ project_credits_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
+ project_credits_label.label_settings = label_settings_project
+
+ for role in project.keys():
+ if role == 'TITLE':
+ continue
+
+ var role_parent = VBoxContainer.new()
+ var role_label = Label.new()
+
+ role_parent.name = 'Role' + role
+ role_label.name = 'Label' + role
+ role_label.text = role
+ role_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
+ role_label.label_settings = label_settings_role
+
+ for person in project[role]:
+ var person_label = Label.new()
+
+ person_label.name = 'Label' + person
+ person_label.text = person
+ person_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
+ person_label.label_settings = label_settings_personel
+ role_parent.add_child(person_label)
+
+ project_credits_list.add_child(role_label)
+ project_credits_list.add_child(role_parent)
+ project_credits_list.add_child(HSeparator.new())
+
+ credits_list.add_child(project_credits_list)
+
+# REQUIREMENTS:
+# * SS-17
+func _ready():
+ var core_credits = load_credit_file(core_credits_path)
+ make_project_credits(core_credits)
+
+# REQUIREMENTS:
+# * UI-38
+# * UIFUN-37
+func _on_back_button_pressed():
+ back_button_pressed.emit()
diff --git a/game/src/Credits/Credits.tscn b/game/src/Credits/Credits.tscn
new file mode 100644
index 0000000..7151aa8
--- /dev/null
+++ b/game/src/Credits/Credits.tscn
@@ -0,0 +1,49 @@
+[gd_scene load_steps=5 format=3 uid="uid://c8knthxkwj1uj"]
+
+[ext_resource type="Script" path="res://src/Credits/Credits.gd" id="1_csd7i"]
+[ext_resource type="LabelSettings" uid="uid://biqo8cmnvubow" path="res://src/Credits/ProjectLabelSettings.tres" id="2_u7onr"]
+[ext_resource type="LabelSettings" uid="uid://dm4km45avs13l" path="res://src/Credits/RoleLabelSettings.tres" id="3_y8oin"]
+[ext_resource type="LabelSettings" uid="uid://bwmyvoa3q0ve5" path="res://src/Credits/PersonLabelSettings.tres" id="4_004ma"]
+
+[node name="Credits" type="Control" node_paths=PackedStringArray("credits_list")]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_csd7i")
+core_credits_path = "res://common/credits.csv"
+label_settings_project = ExtResource("2_u7onr")
+label_settings_role = ExtResource("3_y8oin")
+label_settings_personel = ExtResource("4_004ma")
+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_override_constants/margin_left = 20
+theme_override_constants/margin_top = 10
+theme_override_constants/margin_right = 20
+theme_override_constants/margin_bottom = 10
+
+[node name="BackButton" type="Button" parent="ControlMargin"]
+layout_mode = 2
+text = "Back to Main Menu"
+
+[node name="Scroll" type="ScrollContainer" parent="."]
+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/Credits/PersonLabelSettings.tres b/game/src/Credits/PersonLabelSettings.tres
new file mode 100644
index 0000000..dda6436
--- /dev/null
+++ b/game/src/Credits/PersonLabelSettings.tres
@@ -0,0 +1,5 @@
+[gd_resource type="LabelSettings" format=3 uid="uid://bwmyvoa3q0ve5"]
+
+[resource]
+line_spacing = 10.0
+font_size = 20
diff --git a/game/src/Credits/ProjectLabelSettings.tres b/game/src/Credits/ProjectLabelSettings.tres
new file mode 100644
index 0000000..cad8acb
--- /dev/null
+++ b/game/src/Credits/ProjectLabelSettings.tres
@@ -0,0 +1,5 @@
+[gd_resource type="LabelSettings" format=3 uid="uid://biqo8cmnvubow"]
+
+[resource]
+line_spacing = 20.0
+font_size = 50
diff --git a/game/src/Credits/RoleLabelSettings.tres b/game/src/Credits/RoleLabelSettings.tres
new file mode 100644
index 0000000..3a8381b
--- /dev/null
+++ b/game/src/Credits/RoleLabelSettings.tres
@@ -0,0 +1,5 @@
+[gd_resource type="LabelSettings" format=3 uid="uid://dm4km45avs13l"]
+
+[resource]
+line_spacing = 10.0
+font_size = 30