summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorIbrahn Sahir <ibrahn.sahir@gmail.com>2018-05-16 05:54:22 +0100
committerIbrahn Sahir <ibrahn.sahir@gmail.com>2018-05-19 00:40:16 +0100
commit1433c2cbbb89df1edb0b727c9781481af5705f59 (patch)
tree275b605dc53f680129baf19e1b954feaf35b75a4 /core
parentedc3e6b0daf4acfeb3565f0f799d304d945e5a0a (diff)
GDScript access to copyright, license, author and donor information.
Adds following functions to the Engine singleton: get_author_info - names of Godot authors get_copyright_info - detailed source copyright get_license_info get_donor_info - donor names get_license_info - full text of licenses used, indexed by license names get_license_text - the text of the Godot Expat license
Diffstat (limited to 'core')
-rw-r--r--core/SCsub13
-rw-r--r--core/bind/core_bind.cpp25
-rw-r--r--core/bind/core_bind.h5
-rw-r--r--core/engine.cpp75
-rw-r--r--core/engine.h5
5 files changed, 123 insertions, 0 deletions
diff --git a/core/SCsub b/core/SCsub
index 383aaf0e12..c4f1cdbe97 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -2,6 +2,8 @@
Import('env')
+import methods
+
env.core_sources = []
@@ -93,6 +95,17 @@ env.add_source_files(env.core_sources, "*.cpp")
import make_binders
env.Command(['method_bind.gen.inc', 'method_bind_ext.gen.inc'], 'make_binders.py', make_binders.run)
+# Authors
+env.Depends('#core/authors.gen.h', "../AUTHORS.md")
+env.Command('#core/authors.gen.h', "../AUTHORS.md", methods.make_authors_header)
+
+# Donors
+env.Depends('#core/donors.gen.h', "../DONORS.md")
+env.Command('#core/donors.gen.h', "../DONORS.md", methods.make_donors_header)
+
+# License
+env.Depends('#core/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"])
+env.Command('#core/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], methods.make_license_header)
# Chain load SCsubs
SConscript('os/SCsub')
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 3270b33f1c..14e3804840 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -2710,6 +2710,26 @@ Dictionary _Engine::get_version_info() const {
return Engine::get_singleton()->get_version_info();
}
+Dictionary _Engine::get_author_info() const {
+ return Engine::get_singleton()->get_author_info();
+}
+
+Array _Engine::get_copyright_info() const {
+ return Engine::get_singleton()->get_copyright_info();
+}
+
+Dictionary _Engine::get_donor_info() const {
+ return Engine::get_singleton()->get_donor_info();
+}
+
+Dictionary _Engine::get_license_info() const {
+ return Engine::get_singleton()->get_license_info();
+}
+
+String _Engine::get_license_text() const {
+ return Engine::get_singleton()->get_license_text();
+}
+
bool _Engine::is_in_physics_frame() const {
return Engine::get_singleton()->is_in_physics_frame();
}
@@ -2752,6 +2772,11 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_main_loop"), &_Engine::get_main_loop);
ClassDB::bind_method(D_METHOD("get_version_info"), &_Engine::get_version_info);
+ ClassDB::bind_method(D_METHOD("get_author_info"), &_Engine::get_author_info);
+ ClassDB::bind_method(D_METHOD("get_copyright_info"), &_Engine::get_copyright_info);
+ ClassDB::bind_method(D_METHOD("get_donor_info"), &_Engine::get_donor_info);
+ ClassDB::bind_method(D_METHOD("get_license_info"), &_Engine::get_license_info);
+ ClassDB::bind_method(D_METHOD("get_license_text"), &_Engine::get_license_text);
ClassDB::bind_method(D_METHOD("is_in_physics_frame"), &_Engine::is_in_physics_frame);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index a363f5970f..1de5e43b27 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -689,6 +689,11 @@ public:
MainLoop *get_main_loop() const;
Dictionary get_version_info() const;
+ Dictionary get_author_info() const;
+ Array get_copyright_info() const;
+ Dictionary get_donor_info() const;
+ Dictionary get_license_info() const;
+ String get_license_text() const;
bool is_in_physics_frame() const;
diff --git a/core/engine.cpp b/core/engine.cpp
index b2c34a853c..7c8024b946 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -30,6 +30,9 @@
#include "engine.h"
+#include "authors.gen.h"
+#include "donors.gen.h"
+#include "license.gen.h"
#include "version.h"
#include "version_hash.gen.h"
@@ -111,6 +114,78 @@ Dictionary Engine::get_version_info() const {
return dict;
}
+static Array array_from_info(const char *const *info_list) {
+ Array arr;
+ for (int i = 0; info_list[i] != NULL; i++) {
+ arr.push_back(info_list[i]);
+ }
+ return arr;
+}
+
+static Array array_from_info_count(const char *const *info_list, int info_count) {
+ Array arr;
+ for (int i = 0; i < info_count; i++) {
+ arr.push_back(info_list[i]);
+ }
+ return arr;
+}
+
+Dictionary Engine::get_author_info() const {
+ Dictionary dict;
+
+ dict["lead_developers"] = array_from_info(AUTHORS_LEAD_DEVELOPERS);
+ dict["project_managers"] = array_from_info(AUTHORS_PROJECT_MANAGERS);
+ dict["founders"] = array_from_info(AUTHORS_FOUNDERS);
+ dict["developers"] = array_from_info(AUTHORS_DEVELOPERS);
+
+ return dict;
+}
+
+Array Engine::get_copyright_info() const {
+ Array components;
+ for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) {
+ const ComponentCopyright &cp_info = COPYRIGHT_INFO[component_index];
+ Dictionary component_dict;
+ component_dict["name"] = cp_info.name;
+ Array parts;
+ for (int i = 0; i < cp_info.part_count; i++) {
+ const ComponentCopyrightPart &cp_part = cp_info.parts[i];
+ Dictionary part_dict;
+ part_dict["files"] = array_from_info_count(cp_part.files, cp_part.file_count);
+ part_dict["copyright"] = array_from_info_count(cp_part.copyright_statements, cp_part.copyright_count);
+ part_dict["license"] = cp_part.license;
+ parts.push_back(part_dict);
+ }
+ component_dict["parts"] = parts;
+
+ components.push_back(component_dict);
+ }
+ return components;
+}
+
+Dictionary Engine::get_donor_info() const {
+ Dictionary donors;
+ donors["platinum_sponsors"] = array_from_info(DONORS_SPONSOR_PLAT);
+ donors["gold_sponsors"] = array_from_info(DONORS_SPONSOR_GOLD);
+ donors["mini_sponsors"] = array_from_info(DONORS_SPONSOR_MINI);
+ donors["gold_donors"] = array_from_info(DONORS_GOLD);
+ donors["silver_donors"] = array_from_info(DONORS_SILVER);
+ donors["bronze_donors"] = array_from_info(DONORS_BRONZE);
+ return donors;
+}
+
+Dictionary Engine::get_license_info() const {
+ Dictionary licenses;
+ for (int i = 0; i < LICENSE_COUNT; i++) {
+ licenses[LICENSE_NAMES[i]] = LICENSE_BODIES[i];
+ }
+ return licenses;
+}
+
+String Engine::get_license_text() const {
+ return String(GODOT_LICENSE_TEXT);
+}
+
void Engine::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
diff --git a/core/engine.h b/core/engine.h
index 665992699a..031ba29cd6 100644
--- a/core/engine.h
+++ b/core/engine.h
@@ -118,6 +118,11 @@ public:
#endif
Dictionary get_version_info() const;
+ Dictionary get_author_info() const;
+ Array get_copyright_info() const;
+ Dictionary get_donor_info() const;
+ Dictionary get_license_info() const;
+ String get_license_text() const;
Engine();
};