Merge pull request #10933 from Noshyaar/pr-donor

EditorAbout: add donors tab
This commit is contained in:
Rémi Verschelde 2017-09-04 08:11:26 +02:00 committed by GitHub
commit 0f5e575d60
3 changed files with 110 additions and 35 deletions

View File

@ -155,31 +155,71 @@ def make_authors_header(target, source, env):
g.write("#define _EDITOR_AUTHORS_H\n") g.write("#define _EDITOR_AUTHORS_H\n")
current_section = "" current_section = ""
name_count = -1 reading = False
def close_section(): def close_section():
g.write("\t0\n") g.write("\t0\n")
g.write("};\n") g.write("};\n")
g.write("#define " + current_section.upper() + "_COUNT " + str(name_count) + "\n")
for line in f: for line in f:
if name_count >= 0: if reading:
if line.startswith(" "): if line.startswith(" "):
g.write("\t\"" + line.strip() + "\",\n") g.write("\t\"" + line.strip() + "\",\n")
name_count += 1
continue continue
if line.startswith("## "): if line.startswith("## "):
if name_count >= 0: if reading:
close_section() close_section()
name_count = -1 reading = False
for i in range(len(sections)): for i in range(len(sections)):
if line.strip().endswith(sections[i]): if line.strip().endswith(sections[i]):
current_section = sections_id[i] current_section = sections_id[i]
name_count = 0 reading = True
g.write("static const char *" + current_section + "[] = {\n") g.write("static const char *" + current_section + "[] = {\n")
break break
if name_count >= 0: if reading:
close_section()
g.write("#endif\n")
def make_donors_header(target, source, env):
sections = ["Platinum sponsors", "Gold sponsors", "Mini sponsors", "Gold donors", "Silver donors", "Bronze donors"]
sections_id = ["donor_s_plat", "donor_s_gold", "donor_s_mini", "donor_gold", "donor_silver", "donor_bronze"]
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
f = open_utf8(src, "r")
g = open_utf8(dst, "w")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _EDITOR_DONORS_H\n")
g.write("#define _EDITOR_DONORS_H\n")
current_section = ""
reading = False
def close_section():
g.write("\t0\n")
g.write("};\n")
for line in f:
if reading >= 0:
if line.startswith(" "):
g.write("\t\"" + line.strip() + "\",\n")
continue
if line.startswith("## "):
if reading:
close_section()
reading = False
for i in range(len(sections)):
if line.strip().endswith(sections[i]):
current_section = sections_id[i]
reading = True
g.write("static const char *" + current_section + "[] = {\n")
break
if reading:
close_section() close_section()
g.write("#endif\n") g.write("#endif\n")
@ -393,6 +433,10 @@ if (env["tools"] == "yes"):
env.Depends('#editor/authors.gen.h', "../AUTHORS.md") env.Depends('#editor/authors.gen.h', "../AUTHORS.md")
env.Command('#editor/authors.gen.h', "../AUTHORS.md", make_authors_header) env.Command('#editor/authors.gen.h', "../AUTHORS.md", make_authors_header)
# Donors
env.Depends('#editor/donors.gen.h', "../DONORS.md")
env.Command('#editor/donors.gen.h', "../DONORS.md", make_donors_header)
# License # License
env.Depends('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"]) env.Depends('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"])
env.Command('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], make_license_header) env.Command('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], make_license_header)

View File

@ -30,6 +30,7 @@
#include "editor_about.h" #include "editor_about.h"
#include "authors.gen.h" #include "authors.gen.h"
#include "donors.gen.h"
#include "license.gen.h" #include "license.gen.h"
#include "version.h" #include "version.h"
#include "version_hash.gen.h" #include "version_hash.gen.h"
@ -51,6 +52,47 @@ TextureRect *EditorAbout::get_logo() const {
return _logo; return _logo;
} }
ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<String> &p_sections, const char **p_src[]) {
ScrollContainer *sc = memnew(ScrollContainer);
sc->set_name(p_name);
sc->set_v_size_flags(Control::SIZE_EXPAND);
VBoxContainer *vbc = memnew(VBoxContainer);
vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
sc->add_child(vbc);
for (int i = 0; i < p_sections.size(); i++) {
const char **names_ptr = p_src[i];
if (*names_ptr) {
Label *lbl = memnew(Label);
lbl->set_text(p_sections[i]);
vbc->add_child(lbl);
ItemList *il = memnew(ItemList);
il->set_max_columns(16);
il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
il->set_same_column_width(true);
il->set_auto_height(true);
while (*names_ptr) {
il->add_item(String::utf8(*names_ptr++));
}
vbc->add_child(il);
if (il->get_item_count() == 2) {
il->set_fixed_column_width(200 * EDSCALE);
}
HSeparator *hs = memnew(HSeparator);
hs->set_modulate(Color(0, 0, 0, 0));
vbc->add_child(hs);
}
}
return sc;
}
EditorAbout::EditorAbout() { EditorAbout::EditorAbout() {
set_title(TTR("Thanks from the Godot community!")); set_title(TTR("Thanks from the Godot community!"));
@ -84,43 +126,29 @@ EditorAbout::EditorAbout() {
tc->set_v_size_flags(Control::SIZE_EXPAND_FILL); tc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(tc); vbc->add_child(tc);
ScrollContainer *dev_base = memnew(ScrollContainer); // Authors
dev_base->set_name(TTR("Authors"));
dev_base->set_v_size_flags(Control::SIZE_EXPAND);
tc->add_child(dev_base);
VBoxContainer *dev_vbc = memnew(VBoxContainer);
dev_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
dev_base->add_child(dev_vbc);
List<String> dev_sections; List<String> dev_sections;
dev_sections.push_back(TTR("Project Founders")); dev_sections.push_back(TTR("Project Founders"));
dev_sections.push_back(TTR("Lead Developer")); dev_sections.push_back(TTR("Lead Developer"));
dev_sections.push_back(TTR("Project Manager")); dev_sections.push_back(TTR("Project Manager"));
dev_sections.push_back(TTR("Developers")); dev_sections.push_back(TTR("Developers"));
const char **dev_src[] = { dev_founders, dev_lead, dev_manager, dev_names }; const char **dev_src[] = { dev_founders, dev_lead, dev_manager, dev_names };
tc->add_child(_populate_list(TTR("Authors"), dev_sections, dev_src));
for (int i = 0; i < dev_sections.size(); i++) { // Donors
Label *lbl = memnew(Label); List<String> donor_sections;
lbl->set_text(dev_sections[i]); donor_sections.push_back(TTR("Platinum Sponsors"));
dev_vbc->add_child(lbl); donor_sections.push_back(TTR("Gold Sponsors"));
donor_sections.push_back(TTR("Mini Sponsors"));
donor_sections.push_back(TTR("Gold Donors"));
donor_sections.push_back(TTR("Silver Donors"));
donor_sections.push_back(TTR("Bronze Donors"));
const char **donor_src[] = { donor_s_plat, donor_s_gold, donor_s_mini, donor_gold, donor_silver, donor_bronze };
tc->add_child(_populate_list(TTR("Donors"), donor_sections, donor_src));
ItemList *il = memnew(ItemList); // License
il->set_max_columns(16);
il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
il->set_fixed_column_width(230 * EDSCALE);
il->set_auto_height(true);
const char **dev_names_ptr = dev_src[i];
while (*dev_names_ptr)
il->add_item(String::utf8(*dev_names_ptr++), NULL, false);
dev_vbc->add_child(il);
HSeparator *hs = memnew(HSeparator);
hs->set_modulate(Color(0, 0, 0, 0));
dev_vbc->add_child(hs);
}
TextEdit *license = memnew(TextEdit); TextEdit *license = memnew(TextEdit);
license->set_name(TTR("License")); license->set_name(TTR("License"));
@ -131,6 +159,8 @@ EditorAbout::EditorAbout() {
license->set_text(String::utf8(about_license)); license->set_text(String::utf8(about_license));
tc->add_child(license); tc->add_child(license);
// Thirdparty License
VBoxContainer *license_thirdparty = memnew(VBoxContainer); VBoxContainer *license_thirdparty = memnew(VBoxContainer);
license_thirdparty->set_name(TTR("Thirdparty License")); license_thirdparty->set_name(TTR("Thirdparty License"));
license_thirdparty->set_h_size_flags(Control::SIZE_EXPAND_FILL); license_thirdparty->set_h_size_flags(Control::SIZE_EXPAND_FILL);

View File

@ -52,6 +52,7 @@ class EditorAbout : public AcceptDialog {
private: private:
void _license_tree_selected(); void _license_tree_selected();
ScrollContainer *_populate_list(const String &p_name, const List<String> &p_sections, const char **p_src[]);
Tree *_tpl_tree; Tree *_tpl_tree;
TextEdit *_tpl_text; TextEdit *_tpl_text;