editor_about.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*************************************************************************/
  2. /* editor_about.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "editor_about.h"
  31. #include "editor_node.h"
  32. #include "core/authors.gen.h"
  33. #include "core/donors.gen.h"
  34. #include "core/license.gen.h"
  35. #include "core/version.h"
  36. #include "core/version_hash.gen.h"
  37. void EditorAbout::_notification(int p_what) {
  38. switch (p_what) {
  39. case NOTIFICATION_ENTER_TREE:
  40. case NOTIFICATION_THEME_CHANGED: {
  41. Control *base = EditorNode::get_singleton()->get_gui_base();
  42. Ref<Font> font = base->get_font("source", "EditorFonts");
  43. _tpl_text->add_font_override("normal_font", font);
  44. _tpl_text->add_constant_override("line_separation", 6 * EDSCALE);
  45. _license_text->add_font_override("normal_font", font);
  46. _license_text->add_constant_override("line_separation", 6 * EDSCALE);
  47. _logo->set_texture(base->get_icon("Logo", "EditorIcons"));
  48. } break;
  49. }
  50. }
  51. void EditorAbout::_license_tree_selected() {
  52. TreeItem *selected = _tpl_tree->get_selected();
  53. _tpl_text->scroll_to_line(0);
  54. _tpl_text->set_text(selected->get_metadata(0));
  55. }
  56. void EditorAbout::_bind_methods() {
  57. ClassDB::bind_method(D_METHOD("_license_tree_selected"), &EditorAbout::_license_tree_selected);
  58. }
  59. TextureRect *EditorAbout::get_logo() const {
  60. return _logo;
  61. }
  62. ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<String> &p_sections, const char *const *const p_src[], const int p_flag_single_column) {
  63. ScrollContainer *sc = memnew(ScrollContainer);
  64. sc->set_name(p_name);
  65. sc->set_v_size_flags(Control::SIZE_EXPAND);
  66. VBoxContainer *vbc = memnew(VBoxContainer);
  67. vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  68. sc->add_child(vbc);
  69. for (int i = 0; i < p_sections.size(); i++) {
  70. bool single_column = p_flag_single_column & 1 << i;
  71. const char *const *names_ptr = p_src[i];
  72. if (*names_ptr) {
  73. Label *lbl = memnew(Label);
  74. lbl->set_text(p_sections[i]);
  75. vbc->add_child(lbl);
  76. ItemList *il = memnew(ItemList);
  77. il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  78. il->set_same_column_width(true);
  79. il->set_auto_height(true);
  80. il->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
  81. il->add_constant_override("hseparation", 16 * EDSCALE);
  82. while (*names_ptr) {
  83. il->add_item(String::utf8(*names_ptr++), NULL, false);
  84. }
  85. il->set_max_columns(il->get_item_count() < 4 || single_column ? 1 : 16);
  86. vbc->add_child(il);
  87. HSeparator *hs = memnew(HSeparator);
  88. hs->set_modulate(Color(0, 0, 0, 0));
  89. vbc->add_child(hs);
  90. }
  91. }
  92. return sc;
  93. }
  94. EditorAbout::EditorAbout() {
  95. set_title(TTR("Thanks from the Godot community!"));
  96. set_hide_on_ok(true);
  97. set_resizable(true);
  98. VBoxContainer *vbc = memnew(VBoxContainer);
  99. HBoxContainer *hbc = memnew(HBoxContainer);
  100. hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  101. hbc->set_alignment(BoxContainer::ALIGN_CENTER);
  102. hbc->add_constant_override("separation", 30 * EDSCALE);
  103. add_child(vbc);
  104. vbc->add_child(hbc);
  105. _logo = memnew(TextureRect);
  106. hbc->add_child(_logo);
  107. String hash = String(VERSION_HASH);
  108. if (hash.length() != 0)
  109. hash = "." + hash.left(9);
  110. Label *about_text = memnew(Label);
  111. about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
  112. about_text->set_text(VERSION_FULL_NAME + hash +
  113. String::utf8("\n\xc2\xa9 2007-2021 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2021 ") +
  114. TTR("Godot Engine contributors") + "\n");
  115. hbc->add_child(about_text);
  116. TabContainer *tc = memnew(TabContainer);
  117. tc->set_custom_minimum_size(Size2(950, 400) * EDSCALE);
  118. tc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  119. vbc->add_child(tc);
  120. // Authors
  121. List<String> dev_sections;
  122. dev_sections.push_back(TTR("Project Founders"));
  123. dev_sections.push_back(TTR("Lead Developer"));
  124. // TRANSLATORS: This refers to a job title.
  125. // The trailing space is used to distinguish with the project list application,
  126. // you do not have to keep it in your translation.
  127. dev_sections.push_back(TTR("Project Manager "));
  128. dev_sections.push_back(TTR("Developers"));
  129. const char *const *dev_src[] = { AUTHORS_FOUNDERS, AUTHORS_LEAD_DEVELOPERS,
  130. AUTHORS_PROJECT_MANAGERS, AUTHORS_DEVELOPERS };
  131. tc->add_child(_populate_list(TTR("Authors"), dev_sections, dev_src, 1));
  132. // Donors
  133. List<String> donor_sections;
  134. donor_sections.push_back(TTR("Platinum Sponsors"));
  135. donor_sections.push_back(TTR("Gold Sponsors"));
  136. donor_sections.push_back(TTR("Silver Sponsors"));
  137. donor_sections.push_back(TTR("Bronze Sponsors"));
  138. donor_sections.push_back(TTR("Mini Sponsors"));
  139. donor_sections.push_back(TTR("Gold Donors"));
  140. donor_sections.push_back(TTR("Silver Donors"));
  141. donor_sections.push_back(TTR("Bronze Donors"));
  142. const char *const *donor_src[] = { DONORS_SPONSOR_PLATINUM, DONORS_SPONSOR_GOLD,
  143. DONORS_SPONSOR_SILVER, DONORS_SPONSOR_BRONZE, DONORS_SPONSOR_MINI,
  144. DONORS_GOLD, DONORS_SILVER, DONORS_BRONZE };
  145. tc->add_child(_populate_list(TTR("Donors"), donor_sections, donor_src, 3));
  146. // License
  147. _license_text = memnew(RichTextLabel);
  148. _license_text->set_name(TTR("License"));
  149. _license_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  150. _license_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  151. _license_text->set_text(String::utf8(GODOT_LICENSE_TEXT));
  152. tc->add_child(_license_text);
  153. // Thirdparty License
  154. VBoxContainer *license_thirdparty = memnew(VBoxContainer);
  155. license_thirdparty->set_name(TTR("Third-party Licenses"));
  156. license_thirdparty->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  157. tc->add_child(license_thirdparty);
  158. Label *tpl_label = memnew(Label);
  159. tpl_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  160. tpl_label->set_autowrap(true);
  161. tpl_label->set_text(TTR("Godot Engine relies on a number of third-party free and open source libraries, all compatible with the terms of its MIT license. The following is an exhaustive list of all such third-party components with their respective copyright statements and license terms."));
  162. tpl_label->set_size(Size2(630, 1) * EDSCALE);
  163. license_thirdparty->add_child(tpl_label);
  164. HSplitContainer *tpl_hbc = memnew(HSplitContainer);
  165. tpl_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  166. tpl_hbc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  167. tpl_hbc->set_split_offset(240 * EDSCALE);
  168. license_thirdparty->add_child(tpl_hbc);
  169. _tpl_tree = memnew(Tree);
  170. _tpl_tree->set_hide_root(true);
  171. TreeItem *root = _tpl_tree->create_item();
  172. TreeItem *tpl_ti_all = _tpl_tree->create_item(root);
  173. tpl_ti_all->set_text(0, TTR("All Components"));
  174. TreeItem *tpl_ti_tp = _tpl_tree->create_item(root);
  175. tpl_ti_tp->set_text(0, TTR("Components"));
  176. tpl_ti_tp->set_selectable(0, false);
  177. TreeItem *tpl_ti_lc = _tpl_tree->create_item(root);
  178. tpl_ti_lc->set_text(0, TTR("Licenses"));
  179. tpl_ti_lc->set_selectable(0, false);
  180. String long_text = "";
  181. for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) {
  182. const ComponentCopyright &component = COPYRIGHT_INFO[component_index];
  183. TreeItem *ti = _tpl_tree->create_item(tpl_ti_tp);
  184. String component_name = component.name;
  185. ti->set_text(0, component_name);
  186. String text = component_name + "\n";
  187. long_text += "- " + component_name + "\n";
  188. for (int part_index = 0; part_index < component.part_count; part_index++) {
  189. const ComponentCopyrightPart &part = component.parts[part_index];
  190. text += "\n Files:";
  191. for (int file_num = 0; file_num < part.file_count; file_num++) {
  192. text += "\n " + String(part.files[file_num]);
  193. }
  194. String copyright;
  195. for (int copyright_index = 0; copyright_index < part.copyright_count; copyright_index++) {
  196. copyright += String::utf8("\n \xc2\xa9 ") + String::utf8(part.copyright_statements[copyright_index]);
  197. }
  198. text += copyright;
  199. long_text += copyright;
  200. String license = "\n License: " + String(part.license) + "\n";
  201. text += license;
  202. long_text += license + "\n";
  203. }
  204. ti->set_metadata(0, text);
  205. }
  206. for (int i = 0; i < LICENSE_COUNT; i++) {
  207. TreeItem *ti = _tpl_tree->create_item(tpl_ti_lc);
  208. String licensename = String(LICENSE_NAMES[i]);
  209. ti->set_text(0, licensename);
  210. long_text += "- " + licensename + "\n\n";
  211. String licensebody = String(LICENSE_BODIES[i]);
  212. ti->set_metadata(0, licensebody);
  213. long_text += " " + licensebody.replace("\n", "\n ") + "\n\n";
  214. }
  215. tpl_ti_all->set_metadata(0, long_text);
  216. tpl_hbc->add_child(_tpl_tree);
  217. _tpl_text = memnew(RichTextLabel);
  218. _tpl_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  219. _tpl_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  220. tpl_hbc->add_child(_tpl_text);
  221. _tpl_tree->connect("item_selected", this, "_license_tree_selected");
  222. tpl_ti_all->select(0);
  223. _tpl_text->set_text(tpl_ti_all->get_metadata(0));
  224. }
  225. EditorAbout::~EditorAbout() {}