editor_about.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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::_theme_changed() {
  38. Control *base = EditorNode::get_singleton()->get_gui_base();
  39. Ref<Font> font = base->get_theme_font("source", "EditorFonts");
  40. int font_size = base->get_theme_font_size("source_size", "EditorFonts");
  41. _tpl_text->add_theme_font_override("normal_font", font);
  42. _tpl_text->add_theme_font_size_override("normal_font_size", font_size);
  43. _tpl_text->add_theme_constant_override("line_separation", 6 * EDSCALE);
  44. _license_text->add_theme_font_override("normal_font", font);
  45. _license_text->add_theme_font_size_override("normal_font_size", font_size);
  46. _license_text->add_theme_constant_override("line_separation", 6 * EDSCALE);
  47. _logo->set_texture(base->get_theme_icon("Logo", "EditorIcons"));
  48. }
  49. void EditorAbout::_notification(int p_what) {
  50. switch (p_what) {
  51. case NOTIFICATION_ENTER_TREE: {
  52. _theme_changed();
  53. } break;
  54. }
  55. }
  56. void EditorAbout::_license_tree_selected() {
  57. TreeItem *selected = _tpl_tree->get_selected();
  58. _tpl_text->scroll_to_line(0);
  59. _tpl_text->set_text(selected->get_metadata(0));
  60. }
  61. void EditorAbout::_bind_methods() {
  62. }
  63. TextureRect *EditorAbout::get_logo() const {
  64. return _logo;
  65. }
  66. 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) {
  67. ScrollContainer *sc = memnew(ScrollContainer);
  68. sc->set_name(p_name);
  69. sc->set_v_size_flags(Control::SIZE_EXPAND);
  70. VBoxContainer *vbc = memnew(VBoxContainer);
  71. vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  72. sc->add_child(vbc);
  73. for (int i = 0; i < p_sections.size(); i++) {
  74. bool single_column = p_flag_single_column & 1 << i;
  75. const char *const *names_ptr = p_src[i];
  76. if (*names_ptr) {
  77. Label *lbl = memnew(Label);
  78. lbl->set_text(p_sections[i]);
  79. vbc->add_child(lbl);
  80. ItemList *il = memnew(ItemList);
  81. il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  82. il->set_same_column_width(true);
  83. il->set_auto_height(true);
  84. il->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
  85. il->add_theme_constant_override("hseparation", 16 * EDSCALE);
  86. while (*names_ptr) {
  87. il->add_item(String::utf8(*names_ptr++), nullptr, false);
  88. }
  89. il->set_max_columns(il->get_item_count() < 4 || single_column ? 1 : 16);
  90. vbc->add_child(il);
  91. HSeparator *hs = memnew(HSeparator);
  92. hs->set_modulate(Color(0, 0, 0, 0));
  93. vbc->add_child(hs);
  94. }
  95. }
  96. return sc;
  97. }
  98. EditorAbout::EditorAbout() {
  99. set_title(TTR("Thanks from the Godot community!"));
  100. set_hide_on_ok(true);
  101. VBoxContainer *vbc = memnew(VBoxContainer);
  102. vbc->connect("theme_changed", callable_mp(this, &EditorAbout::_theme_changed));
  103. HBoxContainer *hbc = memnew(HBoxContainer);
  104. hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  105. hbc->set_alignment(BoxContainer::ALIGN_CENTER);
  106. hbc->add_theme_constant_override("separation", 30 * EDSCALE);
  107. add_child(vbc);
  108. vbc->add_child(hbc);
  109. _logo = memnew(TextureRect);
  110. hbc->add_child(_logo);
  111. String hash = String(VERSION_HASH);
  112. if (hash.length() != 0) {
  113. hash = "." + hash.left(9);
  114. }
  115. Label *about_text = memnew(Label);
  116. about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
  117. about_text->set_text(VERSION_FULL_NAME + hash +
  118. String::utf8("\n\xc2\xa9 2007-2021 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2021 ") +
  119. TTR("Godot Engine contributors") + "\n");
  120. hbc->add_child(about_text);
  121. TabContainer *tc = memnew(TabContainer);
  122. tc->set_custom_minimum_size(Size2(950, 400) * EDSCALE);
  123. tc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  124. vbc->add_child(tc);
  125. // Authors
  126. List<String> dev_sections;
  127. dev_sections.push_back(TTR("Project Founders"));
  128. dev_sections.push_back(TTR("Lead Developer"));
  129. // TRANSLATORS: This refers to a job title.
  130. // The trailing space is used to distinguish with the project list application,
  131. // you do not have to keep it in your translation.
  132. dev_sections.push_back(TTR("Project Manager "));
  133. dev_sections.push_back(TTR("Developers"));
  134. const char *const *dev_src[] = { AUTHORS_FOUNDERS, AUTHORS_LEAD_DEVELOPERS,
  135. AUTHORS_PROJECT_MANAGERS, AUTHORS_DEVELOPERS };
  136. tc->add_child(_populate_list(TTR("Authors"), dev_sections, dev_src, 1));
  137. // Donors
  138. List<String> donor_sections;
  139. donor_sections.push_back(TTR("Platinum Sponsors"));
  140. donor_sections.push_back(TTR("Gold Sponsors"));
  141. donor_sections.push_back(TTR("Silver Sponsors"));
  142. donor_sections.push_back(TTR("Bronze Sponsors"));
  143. donor_sections.push_back(TTR("Mini Sponsors"));
  144. donor_sections.push_back(TTR("Gold Donors"));
  145. donor_sections.push_back(TTR("Silver Donors"));
  146. donor_sections.push_back(TTR("Bronze Donors"));
  147. const char *const *donor_src[] = { DONORS_SPONSOR_PLATINUM, DONORS_SPONSOR_GOLD,
  148. DONORS_SPONSOR_SILVER, DONORS_SPONSOR_BRONZE, DONORS_SPONSOR_MINI,
  149. DONORS_GOLD, DONORS_SILVER, DONORS_BRONZE };
  150. tc->add_child(_populate_list(TTR("Donors"), donor_sections, donor_src, 3));
  151. // License
  152. _license_text = memnew(RichTextLabel);
  153. _license_text->set_name(TTR("License"));
  154. _license_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  155. _license_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  156. _license_text->set_text(String::utf8(GODOT_LICENSE_TEXT));
  157. tc->add_child(_license_text);
  158. // Thirdparty License
  159. VBoxContainer *license_thirdparty = memnew(VBoxContainer);
  160. license_thirdparty->set_name(TTR("Third-party Licenses"));
  161. license_thirdparty->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  162. tc->add_child(license_thirdparty);
  163. Label *tpl_label = memnew(Label);
  164. tpl_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  165. tpl_label->set_autowrap(true);
  166. 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."));
  167. tpl_label->set_size(Size2(630, 1) * EDSCALE);
  168. license_thirdparty->add_child(tpl_label);
  169. HSplitContainer *tpl_hbc = memnew(HSplitContainer);
  170. tpl_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  171. tpl_hbc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  172. tpl_hbc->set_split_offset(240 * EDSCALE);
  173. license_thirdparty->add_child(tpl_hbc);
  174. _tpl_tree = memnew(Tree);
  175. _tpl_tree->set_hide_root(true);
  176. TreeItem *root = _tpl_tree->create_item();
  177. TreeItem *tpl_ti_all = _tpl_tree->create_item(root);
  178. tpl_ti_all->set_text(0, TTR("All Components"));
  179. TreeItem *tpl_ti_tp = _tpl_tree->create_item(root);
  180. tpl_ti_tp->set_text(0, TTR("Components"));
  181. tpl_ti_tp->set_selectable(0, false);
  182. TreeItem *tpl_ti_lc = _tpl_tree->create_item(root);
  183. tpl_ti_lc->set_text(0, TTR("Licenses"));
  184. tpl_ti_lc->set_selectable(0, false);
  185. String long_text = "";
  186. for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) {
  187. const ComponentCopyright &component = COPYRIGHT_INFO[component_index];
  188. TreeItem *ti = _tpl_tree->create_item(tpl_ti_tp);
  189. String component_name = String::utf8(component.name);
  190. ti->set_text(0, component_name);
  191. String text = component_name + "\n";
  192. long_text += "- " + component_name + "\n";
  193. for (int part_index = 0; part_index < component.part_count; part_index++) {
  194. const ComponentCopyrightPart &part = component.parts[part_index];
  195. text += "\n Files:";
  196. for (int file_num = 0; file_num < part.file_count; file_num++) {
  197. text += "\n " + String::utf8(part.files[file_num]);
  198. }
  199. String copyright;
  200. for (int copyright_index = 0; copyright_index < part.copyright_count; copyright_index++) {
  201. copyright += String::utf8("\n \xc2\xa9 ") + String::utf8(part.copyright_statements[copyright_index]);
  202. }
  203. text += copyright;
  204. long_text += copyright;
  205. String license = "\n License: " + String::utf8(part.license) + "\n";
  206. text += license;
  207. long_text += license + "\n";
  208. }
  209. ti->set_metadata(0, text);
  210. }
  211. for (int i = 0; i < LICENSE_COUNT; i++) {
  212. TreeItem *ti = _tpl_tree->create_item(tpl_ti_lc);
  213. String licensename = String::utf8(LICENSE_NAMES[i]);
  214. ti->set_text(0, licensename);
  215. long_text += "- " + licensename + "\n\n";
  216. String licensebody = String::utf8(LICENSE_BODIES[i]);
  217. ti->set_metadata(0, licensebody);
  218. long_text += " " + licensebody.replace("\n", "\n ") + "\n\n";
  219. }
  220. tpl_ti_all->set_metadata(0, long_text);
  221. tpl_hbc->add_child(_tpl_tree);
  222. _tpl_text = memnew(RichTextLabel);
  223. _tpl_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  224. _tpl_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  225. tpl_hbc->add_child(_tpl_text);
  226. _tpl_tree->connect("item_selected", callable_mp(this, &EditorAbout::_license_tree_selected));
  227. tpl_ti_all->select(0);
  228. _tpl_text->set_text(tpl_ti_all->get_metadata(0));
  229. }
  230. EditorAbout::~EditorAbout() {}