Add credits roll

This commit is contained in:
kobewi
2024-03-16 21:35:49 +01:00
parent 7b9c5122fa
commit 336bf5269d
4 changed files with 351 additions and 5 deletions

View File

@@ -33,6 +33,8 @@
#include "core/authors.gen.h"
#include "core/donors.gen.h"
#include "core/license.gen.h"
#include "editor/credits_roll.h"
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_version_button.h"
#include "editor/themes/editor_scale.h"
@@ -80,6 +82,19 @@ void EditorAbout::_license_tree_selected() {
_tpl_text->set_text(selected->get_metadata(0));
}
void EditorAbout::_project_manager_clicked() {
if (!EditorNode::get_singleton()) {
// Don't allow in Project Manager.
return;
}
if (!credits_roll) {
credits_roll = memnew(CreditsRoll);
add_child(credits_roll);
}
credits_roll->roll_credits();
}
void EditorAbout::_item_with_website_selected(int p_id, ItemList *p_il) {
const String website = p_il->get_item_metadata(p_id);
if (!website.is_empty()) {
@@ -91,7 +106,7 @@ void EditorAbout::_item_list_resized(ItemList *p_il) {
p_il->set_fixed_column_width(p_il->get_size().x / 3.0 - 16 * EDSCALE * 2.5); // Weird. Should be 3.0 and that's it?.
}
ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<String> &p_sections, const char *const *const p_src[], const int p_single_column_flags, const bool p_allow_website) {
ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<String> &p_sections, const char *const *const p_src[], const int p_single_column_flags, const bool p_allow_website, const String &p_easter_egg_section) {
ScrollContainer *sc = memnew(ScrollContainer);
sc->set_name(p_name);
sc->set_v_size_flags(Control::SIZE_EXPAND);
@@ -107,9 +122,11 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
bool single_column = p_single_column_flags & (1 << i);
const char *const *names_ptr = p_src[i];
if (*names_ptr) {
const String &section_name = *itr;
Label *lbl = memnew(Label);
lbl->set_theme_type_variation("HeaderSmall");
lbl->set_text(*itr);
lbl->set_text(section_name);
vbc->add_child(lbl);
ItemList *il = memnew(ItemList);
@@ -151,6 +168,17 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
}
}
} else {
if (section_name == p_easter_egg_section) {
// Easter egg :D
il->set_focus_mode(Control::FOCUS_CLICK);
il->set_mouse_filter(Control::MOUSE_FILTER_PASS);
il->connect("item_activated", callable_mp(this, &EditorAbout::_project_manager_clicked).unbind(1), CONNECT_DEFERRED);
il->add_theme_style_override("focus", empty_stylebox);
il->add_theme_style_override("selected", empty_stylebox);
}
while (*names_ptr) {
il->add_item(String::utf8(*names_ptr++), nullptr, false);
}
@@ -217,7 +245,8 @@ EditorAbout::EditorAbout() {
dev_sections.push_back(TTR("Project Founders"));
dev_sections.push_back(TTR("Lead Developer"));
// TRANSLATORS: This refers to a job title.
dev_sections.push_back(TTR("Project Manager", "Job Title"));
const String project_manager = TTR("Project Manager", "Job Title");
dev_sections.push_back(project_manager);
dev_sections.push_back(TTR("Developers"));
const char *const *dev_src[] = {
AUTHORS_FOUNDERS,
@@ -225,7 +254,7 @@ EditorAbout::EditorAbout() {
AUTHORS_PROJECT_MANAGERS,
AUTHORS_DEVELOPERS,
};
tc->add_child(_populate_list(TTR("Authors"), dev_sections, dev_src, 0b1)); // First section (Project Founders) is always one column.
tc->add_child(_populate_list(TTR("Authors"), dev_sections, dev_src, 0b1, false, project_manager)); // First section (Project Founders) is always one column.
// Donors.