Skip to content

Commit

Permalink
-Renamed GlobalConfig to ProjectSettings, makes more sense.
Browse files Browse the repository at this point in the history
-Added system for feature overrides, it's pretty cool :)
  • Loading branch information
reduz committed Jul 19, 2017
1 parent 89588d4 commit 25678b1
Show file tree
Hide file tree
Showing 162 changed files with 1,298 additions and 833 deletions.
6 changes: 3 additions & 3 deletions core/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ for x in env.global_defaults:
gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n'
gd_call += "\tregister_" + x + "_global_defaults();\n"

gd_cpp = '#include "global_config.h"\n'
gd_cpp = '#include "project_settings.h"\n'
gd_cpp += gd_inc
gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n"
gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n"

f = open("global_defaults.gen.cpp", "wb")
f.write(gd_cpp)
Expand Down Expand Up @@ -48,7 +48,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
print("Invalid AES256 encryption key, not 64 bits hex: " + e)

f = open("script_encryption_key.gen.cpp", "wb")
f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.close()


Expand Down
4 changes: 2 additions & 2 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/*************************************************************************/
#include "core_bind.h"

#include "core/global_config.h"
#include "core/project_settings.h"
#include "geometry.h"
#include "io/file_access_compressed.h"
#include "io/file_access_encrypted.h"
Expand Down Expand Up @@ -106,7 +106,7 @@ PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {

bool _ResourceLoader::has(const String &p_path) {

String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
return ResourceCache::has(local_path);
};

Expand Down
1 change: 1 addition & 0 deletions core/core_string_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ CoreStringNames::CoreStringNames() {
_iter_next = StaticCString::create("_iter_next");
_iter_get = StaticCString::create("_iter_get");
get_rid = StaticCString::create("get_rid");
_custom_features = StaticCString::create("_custom_features");
#ifdef TOOLS_ENABLED
_sections_unfolded = StaticCString::create("_sections_unfolded");
#endif
Expand Down
1 change: 1 addition & 0 deletions core/core_string_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class CoreStringNames {
StringName _iter_next;
StringName _iter_get;
StringName get_rid;
StringName _custom_features;
#ifdef TOOLS_ENABLED
StringName _sections_unfolded;
#endif
Expand Down
6 changes: 3 additions & 3 deletions core/input_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/*************************************************************************/
#include "input_map.h"

#include "global_config.h"
#include "project_settings.h"
#include "os/keyboard.h"

InputMap *InputMap::singleton = NULL;
Expand Down Expand Up @@ -189,7 +189,7 @@ void InputMap::load_from_globals() {
input_map.clear();

List<PropertyInfo> pinfo;
GlobalConfig::get_singleton()->get_property_list(&pinfo);
ProjectSettings::get_singleton()->get_property_list(&pinfo);

for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
Expand All @@ -201,7 +201,7 @@ void InputMap::load_from_globals() {

add_action(name);

Array va = GlobalConfig::get_singleton()->get(pi.name);
Array va = ProjectSettings::get_singleton()->get(pi.name);

for (int i = 0; i < va.size(); i++) {

Expand Down
2 changes: 1 addition & 1 deletion core/io/compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "compression.h"
#include "global_config.h"
#include "project_settings.h"
#include "os/copymem.h"
#include "zip_io.h"

Expand Down
6 changes: 3 additions & 3 deletions core/io/file_access_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/*************************************************************************/
#include "file_access_memory.h"

#include "global_config.h"
#include "project_settings.h"
#include "map.h"
#include "os/copymem.h"
#include "os/dir_access.h"
Expand All @@ -43,8 +43,8 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
}

String name;
if (GlobalConfig::get_singleton())
name = GlobalConfig::get_singleton()->globalize_path(p_name);
if (ProjectSettings::get_singleton())
name = ProjectSettings::get_singleton()->globalize_path(p_name);
else
name = p_name;
//name = DirAccess::normalize_path(name);
Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_access_network.h"
#include "global_config.h"
#include "project_settings.h"
#include "io/ip.h"
#include "marshalls.h"
#include "os/os.h"
Expand Down
2 changes: 1 addition & 1 deletion core/io/packet_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/*************************************************************************/
#include "packet_peer.h"

#include "global_config.h"
#include "project_settings.h"
#include "io/marshalls.h"
/* helpers / binders */

Expand Down
16 changes: 8 additions & 8 deletions core/io/resource_format_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_binary.h"
#include "global_config.h"
#include "project_settings.h"
#include "image.h"
#include "io/file_access_compressed.h"
#include "io/marshalls.h"
Expand Down Expand Up @@ -317,7 +317,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {

if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}

if (remaps.find(path)) {
Expand Down Expand Up @@ -346,7 +346,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {

if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}

RES res = ResourceLoader::load(path, type);
Expand Down Expand Up @@ -1017,7 +1017,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons
}

Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->open(f);
Expand Down Expand Up @@ -1065,7 +1065,7 @@ void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<Str
ERR_FAIL_COND(!f);

Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->get_dependencies(f, p_dependencies, p_add_types);
Expand Down Expand Up @@ -1152,7 +1152,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
}

Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
ria->remaps = p_map;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
Expand Down Expand Up @@ -1281,7 +1281,7 @@ String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const
}

Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
Expand Down Expand Up @@ -1984,7 +1984,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p

Error ResourceFormatSaverBinary::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {

String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ResourceFormatSaverBinaryInstance saver;
return saver.save(local_path, p_resource, p_flags);
}
Expand Down
7 changes: 5 additions & 2 deletions core/io/resource_import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy

int lines = 0;
String error_text;
bool path_found = false; //first match must have priority
while (true) {

assign = Variant();
Expand All @@ -66,14 +67,16 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
}

if (assign != String()) {
if (assign.begins_with("path.") && r_path_and_type.path == String()) {
if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) {
String feature = assign.get_slicec('.', 1);
if (OS::get_singleton()->check_feature_support(feature)) {
r_path_and_type.path = value;
path_found = true; //first match must have priority
}

} else if (assign == "path") {
} else if (!path_found && assign == "path") {
r_path_and_type.path = value;
path_found = true; //first match must have priority
} else if (assign == "type") {
r_path_and_type.type = value;
}
Expand Down
14 changes: 7 additions & 7 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_loader.h"
#include "global_config.h"
#include "project_settings.h"
#include "io/resource_import.h"
#include "os/file_access.h"
#include "os/os.h"
Expand Down Expand Up @@ -166,7 +166,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
local_path = ProjectSettings::get_singleton()->localize_path(p_path);

bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
Expand Down Expand Up @@ -233,7 +233,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
local_path = ProjectSettings::get_singleton()->localize_path(p_path);

bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
Expand Down Expand Up @@ -304,7 +304,7 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe
if (path.is_rel_path())
local_path = "res://" + path;
else
local_path = GlobalConfig::get_singleton()->localize_path(path);
local_path = ProjectSettings::get_singleton()->localize_path(path);

for (int i = 0; i < loader_count; i++) {

Expand All @@ -327,7 +327,7 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String
if (path.is_rel_path())
local_path = "res://" + path;
else
local_path = GlobalConfig::get_singleton()->localize_path(path);
local_path = ProjectSettings::get_singleton()->localize_path(path);

for (int i = 0; i < loader_count; i++) {

Expand All @@ -350,7 +350,7 @@ String ResourceLoader::get_resource_type(const String &p_path) {
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
local_path = ProjectSettings::get_singleton()->localize_path(p_path);

for (int i = 0; i < loader_count; i++) {

Expand Down Expand Up @@ -430,7 +430,7 @@ void ResourceLoader::reload_translation_remaps() {

void ResourceLoader::load_translation_remaps() {

Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
List<Variant> keys;
remaps.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_saver.h"
#include "global_config.h"
#include "project_settings.h"
#include "os/file_access.h"
#include "resource_loader.h"
#include "script_language.h"
Expand Down Expand Up @@ -64,7 +64,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t

String old_path = p_resource->get_path();

String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);

RES rwcopy = p_resource;
if (p_flags & FLAG_CHANGE_PATH)
Expand Down
2 changes: 1 addition & 1 deletion core/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/*************************************************************************/
#include "message_queue.h"

#include "global_config.h"
#include "project_settings.h"
#include "script_language.h"

MessageQueue *MessageQueue::singleton = NULL;
Expand Down
8 changes: 4 additions & 4 deletions core/os/dir_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "dir_access.h"
#include "global_config.h"
#include "project_settings.h"
#include "os/file_access.h"
#include "os/memory.h"
#include "os/os.h"
Expand All @@ -37,7 +37,7 @@ String DirAccess::_get_root_path() const {

switch (_access_type) {

case ACCESS_RESOURCES: return GlobalConfig::get_singleton()->get_resource_path();
case ACCESS_RESOURCES: return ProjectSettings::get_singleton()->get_resource_path();
case ACCESS_USERDATA: return OS::get_singleton()->get_data_dir();
default: return "";
}
Expand Down Expand Up @@ -200,10 +200,10 @@ String DirAccess::fix_path(String p_path) const {

case ACCESS_RESOURCES: {

if (GlobalConfig::get_singleton()) {
if (ProjectSettings::get_singleton()) {
if (p_path.begins_with("res://")) {

String resource_path = GlobalConfig::get_singleton()->get_resource_path();
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {

return p_path.replace_first("res:/", resource_path);
Expand Down
6 changes: 3 additions & 3 deletions core/os/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "core/io/file_access_pack.h"
#include "core/io/marshalls.h"
#include "global_config.h"
#include "project_settings.h"
#include "os/os.h"

#include "thirdparty/misc/md5.h"
Expand Down Expand Up @@ -135,10 +135,10 @@ String FileAccess::fix_path(const String &p_path) const {

case ACCESS_RESOURCES: {

if (GlobalConfig::get_singleton()) {
if (ProjectSettings::get_singleton()) {
if (r_path.begins_with("res://")) {

String resource_path = GlobalConfig::get_singleton()->get_resource_path();
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {

return r_path.replace("res:/", resource_path);
Expand Down
4 changes: 2 additions & 2 deletions core/os/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "input.h"
#include "global_config.h"
#include "project_settings.h"
#include "input_map.h"
#include "os/os.h"
Input *Input::singleton = NULL;
Expand Down Expand Up @@ -101,7 +101,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released")) {

List<PropertyInfo> pinfo;
GlobalConfig::get_singleton()->get_property_list(&pinfo);
ProjectSettings::get_singleton()->get_property_list(&pinfo);

for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
Expand Down
2 changes: 1 addition & 1 deletion core/os/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool InputEvent::is_action_type() const {
if (String(p_method) == "is_action" && p_argidx == 0) {

List<PropertyInfo> pinfo;
GlobalConfig::get_singleton()->get_property_list(&pinfo);
ProjectSettings::get_singleton()->get_property_list(&pinfo);

for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
Expand Down
Loading

0 comments on commit 25678b1

Please sign in to comment.