diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-05 09:16:00 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-01-05 09:16:00 -0300 |
commit | 0f7af4ea51744cda23c4d3c7481f9c332973d1d4 (patch) | |
tree | 27b8914062558b5648655ccf3db13251d217af98 /core | |
parent | 9e477babb3bf0ce5179395c2a5155a3f3cd36798 (diff) |
-Changed most project settings in the engine, so they have major and minor categories.
-Changed SectionedPropertyEditor to support this
-Renamed Globals singleton to GlobalConfig, makes more sense.
-Changed the logic behind persisten global settings, instead of the persist checkbox, a revert button is now available
Diffstat (limited to 'core')
-rw-r--r-- | core/SCsub | 2 | ||||
-rw-r--r-- | core/bind/core_bind.cpp | 2 | ||||
-rw-r--r-- | core/globals.cpp | 197 | ||||
-rw-r--r-- | core/globals.h | 21 | ||||
-rw-r--r-- | core/input_map.cpp | 6 | ||||
-rw-r--r-- | core/io/file_access_memory.cpp | 4 | ||||
-rw-r--r-- | core/io/file_access_network.cpp | 14 | ||||
-rw-r--r-- | core/io/file_access_network.h | 2 | ||||
-rw-r--r-- | core/io/packet_peer.cpp | 3 | ||||
-rw-r--r-- | core/io/packet_peer.h | 2 | ||||
-rw-r--r-- | core/io/resource_format_binary.cpp | 16 | ||||
-rw-r--r-- | core/io/resource_format_xml.cpp | 18 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 14 | ||||
-rw-r--r-- | core/io/resource_saver.cpp | 2 | ||||
-rw-r--r-- | core/message_queue.cpp | 2 | ||||
-rw-r--r-- | core/os/dir_access.cpp | 6 | ||||
-rw-r--r-- | core/os/file_access.cpp | 4 | ||||
-rw-r--r-- | core/os/input.cpp | 2 | ||||
-rw-r--r-- | core/os/os.cpp | 4 | ||||
-rw-r--r-- | core/path_remap.cpp | 8 | ||||
-rw-r--r-- | core/register_core_types.cpp | 33 | ||||
-rw-r--r-- | core/register_core_types.h | 1 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 8 | ||||
-rw-r--r-- | core/translation.cpp | 6 | ||||
-rw-r--r-- | core/undo_redo.cpp | 9 | ||||
-rw-r--r-- | core/undo_redo.h | 1 |
26 files changed, 215 insertions, 172 deletions
diff --git a/core/SCsub b/core/SCsub index caae3a1c9b..8d89f6427b 100644 --- a/core/SCsub +++ b/core/SCsub @@ -15,7 +15,7 @@ for x in env.global_defaults: gd_cpp = '#include "globals.h"\n' gd_cpp += gd_inc -gd_cpp += "void Globals::register_global_defaults() {\n" + gd_call + "\n}\n" +gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n" f = open("global_defaults.cpp", "wb") f.write(gd_cpp) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 02f3c4c5f3..0d89659cef 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -102,7 +102,7 @@ StringArray _ResourceLoader::get_dependencies(const String& p_path) { bool _ResourceLoader::has(const String &p_path) { - String local_path = Globals::get_singleton()->localize_path(p_path); + String local_path = GlobalConfig::get_singleton()->localize_path(p_path); return ResourceCache::has(local_path); }; diff --git a/core/globals.cpp b/core/globals.cpp index 8b335b8a0d..6609b47147 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -37,19 +37,19 @@ #include "io/file_access_pack.h" #include "io/file_access_network.h" -Globals *Globals::singleton=NULL; +GlobalConfig *GlobalConfig::singleton=NULL; -Globals *Globals::get_singleton() { +GlobalConfig *GlobalConfig::get_singleton() { return singleton; } -String Globals::get_resource_path() const { +String GlobalConfig::get_resource_path() const { return resource_path; }; -String Globals::localize_path(const String& p_path) const { +String GlobalConfig::localize_path(const String& p_path) const { if (resource_path=="") return p_path; //not initialied yet @@ -96,21 +96,14 @@ String Globals::localize_path(const String& p_path) const { } -void Globals::set_persisting(const String& p_name, bool p_persist) { +void GlobalConfig::set_initial_value(const String& p_name, const Variant & p_value) { ERR_FAIL_COND(!props.has(p_name)); - props[p_name].persist=p_persist; + props[p_name].initial=p_value; } -bool Globals::is_persisting(const String& p_name) const { - ERR_FAIL_COND_V(!props.has(p_name),false); - return props[p_name].persist; - -} - - -String Globals::globalize_path(const String& p_path) const { +String GlobalConfig::globalize_path(const String& p_path) const { if (p_path.begins_with("res://")) { @@ -125,7 +118,7 @@ String Globals::globalize_path(const String& p_path) const { } -bool Globals::_set(const StringName& p_name, const Variant& p_value) { +bool GlobalConfig::_set(const StringName& p_name, const Variant& p_value) { _THREAD_SAFE_METHOD_ @@ -169,7 +162,7 @@ bool Globals::_set(const StringName& p_name, const Variant& p_value) { return true; } -bool Globals::_get(const StringName& p_name,Variant &r_ret) const { +bool GlobalConfig::_get(const StringName& p_name,Variant &r_ret) const { _THREAD_SAFE_METHOD_ @@ -190,7 +183,7 @@ struct _VCSort { bool operator<(const _VCSort& p_vcs) const{ return order==p_vcs.order?name<p_vcs.name:order< p_vcs.order; } }; -void Globals::_get_property_list(List<PropertyInfo> *p_list) const { +void GlobalConfig::_get_property_list(List<PropertyInfo> *p_list) const { _THREAD_SAFE_METHOD_ @@ -208,13 +201,9 @@ void Globals::_get_property_list(List<PropertyInfo> *p_list) const { vc.order=v->order; vc.type=v->variant.get_type(); if (vc.name.begins_with("input/") || vc.name.begins_with("import/") || vc.name.begins_with("export/") || vc.name.begins_with("/remap") || vc.name.begins_with("/locale") || vc.name.begins_with("/autoload")) - vc.flags=PROPERTY_USAGE_CHECKABLE|PROPERTY_USAGE_STORAGE; + vc.flags=PROPERTY_USAGE_STORAGE; else - vc.flags=PROPERTY_USAGE_CHECKABLE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_STORAGE; - - if (v->persist) { - vc.flags|=PROPERTY_USAGE_CHECKED; - } + vc.flags=PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_STORAGE; vclist.insert(vc); } @@ -233,7 +222,7 @@ void Globals::_get_property_list(List<PropertyInfo> *p_list) const { -bool Globals::_load_resource_pack(const String& p_pack) { +bool GlobalConfig::_load_resource_pack(const String& p_pack) { if (PackedData::get_singleton()->is_disabled()) return false; @@ -250,7 +239,7 @@ bool Globals::_load_resource_pack(const String& p_pack) { return true; } -Error Globals::setup(const String& p_path,const String & p_main_pack) { +Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { //an absolute mess of a function, must be cleaned up and reorganized somehow at some point @@ -397,7 +386,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) { return OK; } -bool Globals::has(String p_var) const { +bool GlobalConfig::has(String p_var) const { _THREAD_SAFE_METHOD_ @@ -751,12 +740,12 @@ static Variant _decode_variant(const String& p_string) { return Variant(); } -void Globals::set_registering_order(bool p_enable) { +void GlobalConfig::set_registering_order(bool p_enable) { registering_order=p_enable; } -Error Globals::_load_settings_binary(const String p_path) { +Error GlobalConfig::_load_settings_binary(const String p_path) { Error err; FileAccess *f= FileAccess::open(p_path,FileAccess::READ,&err); @@ -797,7 +786,7 @@ Error Globals::_load_settings_binary(const String p_path) { ERR_EXPLAIN("Error decoding property: "+key); ERR_CONTINUE(err!=OK); set(key,value); - set_persisting(key,true); + } set_registering_order(true); @@ -805,7 +794,7 @@ Error Globals::_load_settings_binary(const String p_path) { return OK; } -Error Globals::_load_settings(const String p_path) { +Error GlobalConfig::_load_settings(const String p_path) { Error err; @@ -884,8 +873,10 @@ Error Globals::_load_settings(const String p_path) { Variant val = _decode_variant(value); - set(subpath+var,val); - set_persisting(subpath+var,true); + StringName path = subpath+var; + + set(path,val); + //props[subpath+var]=VariantContainer(val,last_order++,true); } else { @@ -1062,31 +1053,31 @@ static String _encode_variant(const Variant& p_variant) { } -int Globals::get_order(const String& p_name) const { +int GlobalConfig::get_order(const String& p_name) const { ERR_FAIL_COND_V(!props.has(p_name),-1); return props[p_name].order; } -void Globals::set_order(const String& p_name, int p_order){ +void GlobalConfig::set_order(const String& p_name, int p_order){ ERR_FAIL_COND(!props.has(p_name)); props[p_name].order=p_order; } -void Globals::clear(const String& p_name) { +void GlobalConfig::clear(const String& p_name) { ERR_FAIL_COND(!props.has(p_name)); props.erase(p_name); } -Error Globals::save() { +Error GlobalConfig::save() { return save_custom(get_resource_path()+"/engine.cfg"); } -Error Globals::_save_settings_binary(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom) { +Error GlobalConfig::_save_settings_binary(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom) { Error err; @@ -1155,7 +1146,7 @@ Error Globals::_save_settings_binary(const String& p_file,const Map<String,List< } -Error Globals::_save_settings_text(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom) { +Error GlobalConfig::_save_settings_text(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom) { Error err; FileAccess *file = FileAccess::open(p_file,FileAccess::WRITE,&err); @@ -1194,12 +1185,12 @@ Error Globals::_save_settings_text(const String& p_file,const Map<String,List<St return OK; } -Error Globals::_save_custom_bnd(const String &p_file) { // add other params as dictionary and array? +Error GlobalConfig::_save_custom_bnd(const String &p_file) { // add other params as dictionary and array? return save_custom(p_file); }; -Error Globals::save_custom(const String& p_path,const CustomMap& p_custom,const Set<String>& p_ignore_masks) { +Error GlobalConfig::save_custom(const String& p_path,const CustomMap& p_custom,const Set<String>& p_ignore_masks) { ERR_FAIL_COND_V(p_path=="",ERR_INVALID_PARAMETER); @@ -1232,8 +1223,8 @@ Error Globals::save_custom(const String& p_path,const CustomMap& p_custom,const vc.name=G->key();//*k; vc.order=v->order; vc.type=v->variant.get_type(); - vc.flags=PROPERTY_USAGE_CHECKABLE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_STORAGE; - if (!v->persist) + vc.flags=PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_STORAGE; + if (v->variant==v->initial) continue; @@ -1327,20 +1318,23 @@ Error Globals::save_custom(const String& p_path,const CustomMap& p_custom,const Variant _GLOBAL_DEF( const String& p_var, const Variant& p_default) { - if (Globals::get_singleton()->has(p_var)) - return Globals::get_singleton()->get(p_var); - Globals::get_singleton()->set(p_var,p_default); + if (GlobalConfig::get_singleton()->has(p_var)) { + GlobalConfig::get_singleton()->set_initial_value(p_var,p_default); + return GlobalConfig::get_singleton()->get(p_var); + } + GlobalConfig::get_singleton()->set(p_var,p_default); + GlobalConfig::get_singleton()->set_initial_value(p_var,p_default); return p_default; } -void Globals::add_singleton(const Singleton &p_singleton) { +void GlobalConfig::add_singleton(const Singleton &p_singleton) { singletons.push_back(p_singleton); singleton_ptrs[p_singleton.name]=p_singleton.ptr; } -Object* Globals::get_singleton_object(const String& p_name) const { +Object* GlobalConfig::get_singleton_object(const String& p_name) const { const Map<StringName,Object*>::Element *E=singleton_ptrs.find(p_name); @@ -1351,21 +1345,21 @@ Object* Globals::get_singleton_object(const String& p_name) const { }; -bool Globals::has_singleton(const String& p_name) const { +bool GlobalConfig::has_singleton(const String& p_name) const { return get_singleton_object(p_name) != NULL; }; -void Globals::get_singletons(List<Singleton> *p_singletons) { +void GlobalConfig::get_singletons(List<Singleton> *p_singletons) { for(List<Singleton>::Element *E=singletons.front();E;E=E->next()) p_singletons->push_back(E->get()); } -Vector<String> Globals::get_optimizer_presets() const { +Vector<String> GlobalConfig::get_optimizer_presets() const { List<PropertyInfo> pi; - Globals::get_singleton()->get_property_list(&pi); + GlobalConfig::get_singleton()->get_property_list(&pi); Vector<String> names; for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) { @@ -1381,7 +1375,7 @@ Vector<String> Globals::get_optimizer_presets() const { } -void Globals::_add_property_info_bind(const Dictionary& p_info) { +void GlobalConfig::_add_property_info_bind(const Dictionary& p_info) { ERR_FAIL_COND(!p_info.has("name")); ERR_FAIL_COND(!p_info.has("type")); @@ -1400,7 +1394,7 @@ void Globals::_add_property_info_bind(const Dictionary& p_info) { set_custom_property_info(pinfo.name, pinfo); } -void Globals::set_custom_property_info(const String& p_prop,const PropertyInfo& p_info) { +void GlobalConfig::set_custom_property_info(const String& p_prop,const PropertyInfo& p_info) { ERR_FAIL_COND(!props.has(p_prop)); custom_prop_info[p_prop]=p_info; @@ -1408,37 +1402,55 @@ void Globals::set_custom_property_info(const String& p_prop,const PropertyInfo& } -void Globals::set_disable_platform_override(bool p_disable) { +void GlobalConfig::set_disable_platform_override(bool p_disable) { disable_platform_override=p_disable; } -bool Globals::is_using_datapack() const { +bool GlobalConfig::is_using_datapack() const { return using_datapack; } -void Globals::_bind_methods() { +bool GlobalConfig::property_can_revert(const String& p_name) { - ClassDB::bind_method(_MD("has","name"),&Globals::has); - ClassDB::bind_method(_MD("set_order","name","pos"),&Globals::set_order); - ClassDB::bind_method(_MD("get_order","name"),&Globals::get_order); - ClassDB::bind_method(_MD("set_persisting","name","enable"),&Globals::set_persisting); - ClassDB::bind_method(_MD("is_persisting","name"),&Globals::is_persisting); - ClassDB::bind_method(_MD("add_property_info", "hint"),&Globals::_add_property_info_bind); - ClassDB::bind_method(_MD("clear","name"),&Globals::clear); - ClassDB::bind_method(_MD("localize_path","path"),&Globals::localize_path); - ClassDB::bind_method(_MD("globalize_path","path"),&Globals::globalize_path); - ClassDB::bind_method(_MD("save"),&Globals::save); - ClassDB::bind_method(_MD("has_singleton","name"),&Globals::has_singleton); - ClassDB::bind_method(_MD("get_singleton","name"),&Globals::get_singleton_object); - ClassDB::bind_method(_MD("load_resource_pack","pack"),&Globals::_load_resource_pack); + if (!props.has(p_name)) + return false; + + return props[p_name].initial!=props[p_name].variant; + +} + +Variant GlobalConfig::property_get_revert(const String& p_name) { + + if (!props.has(p_name)) + return Variant(); + + return props[p_name].initial; +} - ClassDB::bind_method(_MD("save_custom","file"),&Globals::_save_custom_bnd); +void GlobalConfig::_bind_methods() { + + ClassDB::bind_method(_MD("has","name"),&GlobalConfig::has); + ClassDB::bind_method(_MD("set_order","name","pos"),&GlobalConfig::set_order); + ClassDB::bind_method(_MD("get_order","name"),&GlobalConfig::get_order); + ClassDB::bind_method(_MD("set_initial_value","name","value"),&GlobalConfig::set_initial_value); + ClassDB::bind_method(_MD("add_property_info", "hint"),&GlobalConfig::_add_property_info_bind); + ClassDB::bind_method(_MD("clear","name"),&GlobalConfig::clear); + ClassDB::bind_method(_MD("localize_path","path"),&GlobalConfig::localize_path); + ClassDB::bind_method(_MD("globalize_path","path"),&GlobalConfig::globalize_path); + ClassDB::bind_method(_MD("save"),&GlobalConfig::save); + ClassDB::bind_method(_MD("has_singleton","name"),&GlobalConfig::has_singleton); + ClassDB::bind_method(_MD("get_singleton","name"),&GlobalConfig::get_singleton_object); + ClassDB::bind_method(_MD("load_resource_pack","pack"),&GlobalConfig::_load_resource_pack); + ClassDB::bind_method(_MD("property_can_revert","name"),&GlobalConfig::property_can_revert); + ClassDB::bind_method(_MD("property_get_revert","name"),&GlobalConfig::property_get_revert); + + ClassDB::bind_method(_MD("save_custom","file"),&GlobalConfig::_save_custom_bnd); } -Globals::Globals() { +GlobalConfig::GlobalConfig() { singleton=this; @@ -1454,11 +1466,11 @@ Globals::Globals() { joyb.type=InputEvent::JOYSTICK_BUTTON; - set("application/name","" ); - set("application/main_scene",""); + GLOBAL_DEF("application/name","" ); + GLOBAL_DEF("application/main_scene",""); custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"tscn,scn,xscn,xml,res"); - set("application/disable_stdout",false); - set("application/use_shared_user_dir",true); + GLOBAL_DEF("application/disable_stdout",false); + GLOBAL_DEF("application/use_shared_user_dir",true); key.key.scancode=KEY_RETURN; @@ -1469,7 +1481,7 @@ Globals::Globals() { va.push_back(key); joyb.joy_button.button_index=JOY_BUTTON_0; va.push_back(joyb); - set("input/ui_accept",va); + GLOBAL_DEF("input/ui_accept",va); input_presets.push_back("input/ui_accept"); va=Array(); @@ -1477,7 +1489,7 @@ Globals::Globals() { va.push_back(key); joyb.joy_button.button_index=JOY_BUTTON_3; va.push_back(joyb); - set("input/ui_select",va); + GLOBAL_DEF("input/ui_select",va); input_presets.push_back("input/ui_select"); va=Array(); @@ -1485,20 +1497,20 @@ Globals::Globals() { va.push_back(key); joyb.joy_button.button_index=JOY_BUTTON_1; va.push_back(joyb); - set("input/ui_cancel",va); + GLOBAL_DEF("input/ui_cancel",va); input_presets.push_back("input/ui_cancel"); va=Array(); key.key.scancode=KEY_TAB; va.push_back(key); - set("input/ui_focus_next",va); + GLOBAL_DEF("input/ui_focus_next",va); input_presets.push_back("input/ui_focus_next"); va=Array(); key.key.scancode=KEY_TAB; key.key.mod.shift=true; va.push_back(key); - set("input/ui_focus_prev",va); + GLOBAL_DEF("input/ui_focus_prev",va); input_presets.push_back("input/ui_focus_prev"); key.key.mod.shift=false; @@ -1507,7 +1519,7 @@ Globals::Globals() { va.push_back(key); joyb.joy_button.button_index=JOY_DPAD_LEFT; va.push_back(joyb); - set("input/ui_left",va); + GLOBAL_DEF("input/ui_left",va); input_presets.push_back("input/ui_left"); va=Array(); @@ -1515,7 +1527,7 @@ Globals::Globals() { va.push_back(key); joyb.joy_button.button_index=JOY_DPAD_RIGHT; va.push_back(joyb); - set("input/ui_right",va); + GLOBAL_DEF("input/ui_right",va); input_presets.push_back("input/ui_right"); va=Array(); @@ -1523,7 +1535,7 @@ Globals::Globals() { va.push_back(key); joyb.joy_button.button_index=JOY_DPAD_UP; va.push_back(joyb); - set("input/ui_up",va); + GLOBAL_DEF("input/ui_up",va); input_presets.push_back("input/ui_up"); va=Array(); @@ -1531,36 +1543,35 @@ Globals::Globals() { va.push_back(key); joyb.joy_button.button_index=JOY_DPAD_DOWN; va.push_back(joyb); - set("input/ui_down",va); + GLOBAL_DEF("input/ui_down",va); input_presets.push_back("input/ui_down"); va=Array(); key.key.scancode=KEY_PAGEUP; va.push_back(key); - set("input/ui_page_up",va); + GLOBAL_DEF("input/ui_page_up",va); input_presets.push_back("input/ui_page_up"); va=Array(); key.key.scancode=KEY_PAGEDOWN; va.push_back(key); - set("input/ui_page_down",va); + GLOBAL_DEF("input/ui_page_down",va); input_presets.push_back("input/ui_page_down"); -// set("display/orientation", "landscape"); +// GLOBAL_DEF("display/handheld/orientation", "landscape"); - custom_prop_info["display/orientation"]=PropertyInfo(Variant::STRING,"display/orientation",PROPERTY_HINT_ENUM,"landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor"); - custom_prop_info["render/mipmap_policy"]=PropertyInfo(Variant::INT,"render/mipmap_policy",PROPERTY_HINT_ENUM,"Allow,Allow For Po2,Disallow"); - custom_prop_info["render/thread_model"]=PropertyInfo(Variant::INT,"render/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded"); - custom_prop_info["physics_2d/thread_model"]=PropertyInfo(Variant::INT,"physics_2d/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded"); + custom_prop_info["display/handheld/orientation"]=PropertyInfo(Variant::STRING,"display/handheld/orientation",PROPERTY_HINT_ENUM,"landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor"); + custom_prop_info["rendering/threads/thread_model"]=PropertyInfo(Variant::INT,"rendering/threads/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded"); + custom_prop_info["physics/2d/thread_model"]=PropertyInfo(Variant::INT,"physics/2d/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded"); - set("debug/profiler_max_functions",16384); + GLOBAL_DEF("debug/profiler/max_functions",16384); using_datapack=false; } -Globals::~Globals() { +GlobalConfig::~GlobalConfig() { singleton=NULL; } diff --git a/core/globals.h b/core/globals.h index 67937c56d8..faf077f2a5 100644 --- a/core/globals.h +++ b/core/globals.h @@ -37,9 +37,9 @@ */ -class Globals : public Object { +class GlobalConfig : public Object { - GDCLASS( Globals, Object ); + GDCLASS( GlobalConfig, Object ); _THREAD_SAFE_CLASS_ public: @@ -62,6 +62,7 @@ protected: int order; bool persist; Variant variant; + Variant initial; bool hide_from_editor; bool overrided; VariantContainer(){ order=0; hide_from_editor=false; persist=false; overrided=false; } @@ -82,7 +83,7 @@ protected: bool _get(const StringName& p_name,Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; - static Globals *singleton; + static GlobalConfig *singleton; Error _load_settings(const String p_path); Error _load_settings_binary(const String p_path); @@ -109,12 +110,14 @@ public: String localize_path(const String& p_path) const; String globalize_path(const String& p_path) const; - void set_persisting(const String& p_name, bool p_persist); - bool is_persisting(const String& p_name) const; + + void set_initial_value(const String& p_name, const Variant & p_value); + bool property_can_revert(const String& p_name); + Variant property_get_revert(const String& p_name); String get_resource_path() const; - static Globals *get_singleton(); + static GlobalConfig *get_singleton(); void clear(const String& p_name); int get_order(const String& p_name) const; @@ -144,12 +147,14 @@ public: void set_registering_order(bool p_registering); - Globals(); - ~Globals(); + GlobalConfig(); + ~GlobalConfig(); }; //not a macro any longer Variant _GLOBAL_DEF( const String& p_var, const Variant& p_default); #define GLOBAL_DEF(m_var,m_value) _GLOBAL_DEF(m_var,m_value) +#define GLOBAL_GET(m_var) GlobalConfig::get_singleton()->get(m_var) + #endif diff --git a/core/input_map.cpp b/core/input_map.cpp index 439bf4b766..27cd0f5596 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -241,7 +241,7 @@ void InputMap::load_from_globals() { input_map.clear();; List<PropertyInfo> pinfo; - Globals::get_singleton()->get_property_list(&pinfo); + GlobalConfig::get_singleton()->get_property_list(&pinfo); for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) { const PropertyInfo &pi=E->get(); @@ -253,7 +253,7 @@ void InputMap::load_from_globals() { add_action(name); - Array va = Globals::get_singleton()->get(pi.name);; + Array va = GlobalConfig::get_singleton()->get(pi.name);; for(int i=0;i<va.size();i++) { @@ -324,7 +324,7 @@ void InputMap::load_default() { key.key.scancode=KEY_PAGEDOWN; action_add_event("ui_page_down",key); -// set("display/orientation", "landscape"); +// set("display/handheld/orientation", "landscape"); } diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index e1f6831f7b..a9dbf56c15 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -42,8 +42,8 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) { } String name; - if (Globals::get_singleton()) - name = Globals::get_singleton()->globalize_path(p_name); + if (GlobalConfig::get_singleton()) + name = GlobalConfig::get_singleton()->globalize_path(p_name); else name = p_name; //name = DirAccess::normalize_path(name); diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 3516ad8808..19076b57be 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -528,6 +528,14 @@ uint64_t FileAccessNetwork::_get_modified_time(const String& p_file){ } +void FileAccessNetwork::configure() { + + GLOBAL_DEF("network/remote_fs/page_size",65536); + GLOBAL_DEF("network/remote_fs/page_read_ahead",4); + GLOBAL_DEF("network/remote_fs/max_pages",20); + +} + FileAccessNetwork::FileAccessNetwork() { eof_flag=false; @@ -541,9 +549,9 @@ FileAccessNetwork::FileAccessNetwork() { id=nc->last_id++; nc->accesses[id]=this; nc->unlock_mutex(); - page_size = GLOBAL_DEF("remote_fs/page_size",65536); - read_ahead = GLOBAL_DEF("remote_fs/page_read_ahead",4); - max_pages = GLOBAL_DEF("remote_fs/max_pages",20); + page_size = GLOBAL_GET("network/remote_fs/page_size"); + read_ahead = GLOBAL_GET("network/remote_fs/page_read_ahead"); + max_pages = GLOBAL_GET("network/remote_fs/max_pages"); last_activity_val=0; waiting_on_page=-1; last_page=-1; diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 867991bcbe..4dbfb04b10 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -162,6 +162,8 @@ public: virtual uint64_t _get_modified_time(const String& p_file); + static void configure(); + FileAccessNetwork(); ~FileAccessNetwork(); }; diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 1d05e95010..720e912e71 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -265,7 +265,8 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) { PacketPeerStream::PacketPeerStream() { - int rbsize=GLOBAL_DEF( "core/packet_stream_peer_max_buffer_po2",(16)); + int rbsize=GLOBAL_GET( "network/packets/packet_stream_peer_max_buffer_po2"); + ring_buffer.resize(rbsize); temp_buffer.resize(1<<rbsize); diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index 7aa8d8d456..c67cfb943e 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -92,6 +92,8 @@ public: virtual int get_max_packet_size() const; + + void set_stream_peer(const Ref<StreamPeer>& p_peer); void set_input_buffer_max_size(int p_max_size); PacketPeerStream(); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 5328bb68fe..512031b128 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -355,7 +355,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=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path)); + path=GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path)); } @@ -385,7 +385,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=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path)); + path=GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path)); } @@ -1047,7 +1047,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons } Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::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); @@ -1102,7 +1102,7 @@ Error ResourceFormatLoaderBinary::load_import_metadata(const String &p_path, Ref } Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path); ria->res_path=ria->local_path; // ria->set_local_path( Globals::get_singleton()->localize_path(p_path) ); ria->recognize(f); @@ -1147,7 +1147,7 @@ void ResourceFormatLoaderBinary::get_dependencies(const String& p_path,List<Stri ERR_FAIL_COND(!f); Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::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); @@ -1237,7 +1237,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path,const } Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::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) ); @@ -1372,7 +1372,7 @@ String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const } Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::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); @@ -2192,7 +2192,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 = Globals::get_singleton()->localize_path(p_path); + String local_path = GlobalConfig::get_singleton()->localize_path(p_path); ResourceFormatSaverBinaryInstance saver; return saver.save(local_path,p_resource,p_flags); diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 7bb9e2efb7..d4808d4741 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -467,7 +467,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) path=path.replace("local://",local_path+"::"); else if (path.find("://")==-1 && path.is_rel_path()) { // path is relative to file being loaded, so convert to a resource path - path=Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); + path=GlobalConfig::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); } @@ -1425,7 +1425,7 @@ Error ResourceInteractiveLoaderXML::poll() { if (path.find("://")==-1 && path.is_rel_path()) { // path is relative to file being loaded, so convert to a resource path - path=Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); + path=GlobalConfig::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); } if (remaps.has(path)) { @@ -1622,7 +1622,7 @@ void ResourceInteractiveLoaderXML::get_dependencies(FileAccess *f,List<String> * if (path.find("://")==-1 && path.is_rel_path()) { // path is relative to file being loaded, so convert to a resource path - path=Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); + path=GlobalConfig::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); } if (path.ends_with("*")) { @@ -1760,7 +1760,7 @@ Error ResourceInteractiveLoaderXML::rename_dependencies(FileAccess *p_f, const S } Ref<ResourceInteractiveLoaderXML> ria = memnew( ResourceInteractiveLoaderXML ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::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) ); @@ -1924,7 +1924,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderXML::load_interactive(const S } Ref<ResourceInteractiveLoaderXML> ria = memnew( ResourceInteractiveLoaderXML ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::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); @@ -1989,7 +1989,7 @@ String ResourceFormatLoaderXML::get_resource_type(const String &p_path) const{ } Ref<ResourceInteractiveLoaderXML> ria = memnew( ResourceInteractiveLoaderXML ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::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); @@ -2006,7 +2006,7 @@ void ResourceFormatLoaderXML::get_dependencies(const String& p_path,List<String> } Ref<ResourceInteractiveLoaderXML> ria = memnew( ResourceInteractiveLoaderXML ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::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); @@ -2023,7 +2023,7 @@ Error ResourceFormatLoaderXML::rename_dependencies(const String &p_path,const Ma } Ref<ResourceInteractiveLoaderXML> ria = memnew( ResourceInteractiveLoaderXML ); - ria->local_path=Globals::get_singleton()->localize_path(p_path); + ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path); ria->res_path=ria->local_path; // ria->set_local_path( Globals::get_singleton()->localize_path(p_path) ); return ria->rename_dependencies(f,p_path,p_map); @@ -2716,7 +2716,7 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res ERR_FAIL_COND_V( err, ERR_CANT_OPEN ); FileAccessRef _fref(f); - local_path = Globals::get_singleton()->localize_path(p_path); + local_path = GlobalConfig::get_singleton()->localize_path(p_path); relative_paths=p_flags&ResourceSaver::FLAG_RELATIVE_PATHS; skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index f299a75d85..cc3c8ce006 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -164,7 +164,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 = Globals::get_singleton()->localize_path(p_path); + local_path = GlobalConfig::get_singleton()->localize_path(p_path); local_path=find_complete_path(local_path,p_type_hint); ERR_FAIL_COND_V(local_path=="",RES()); @@ -228,7 +228,7 @@ Ref<ResourceImportMetadata> ResourceLoader::load_import_metadata(const String &p if (p_path.is_rel_path()) local_path="res://"+p_path; else - local_path = Globals::get_singleton()->localize_path(p_path); + local_path = GlobalConfig::get_singleton()->localize_path(p_path); String extension=p_path.extension(); Ref<ResourceImportMetadata> ret; @@ -307,7 +307,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_ if (p_path.is_rel_path()) local_path="res://"+p_path; else - local_path = Globals::get_singleton()->localize_path(p_path); + local_path = GlobalConfig::get_singleton()->localize_path(p_path); local_path=find_complete_path(local_path,p_type_hint); ERR_FAIL_COND_V(local_path=="",Ref<ResourceInteractiveLoader>()); @@ -381,7 +381,7 @@ void ResourceLoader::get_dependencies(const String& p_path, List<String> *p_depe if (p_path.is_rel_path()) local_path="res://"+p_path; else - local_path = Globals::get_singleton()->localize_path(p_path); + local_path = GlobalConfig::get_singleton()->localize_path(p_path); String remapped_path = PathRemap::get_singleton()->get_remap(local_path); @@ -406,7 +406,7 @@ Error ResourceLoader::rename_dependencies(const String &p_path,const Map<String, if (p_path.is_rel_path()) local_path="res://"+p_path; else - local_path = Globals::get_singleton()->localize_path(p_path); + local_path = GlobalConfig::get_singleton()->localize_path(p_path); String remapped_path = PathRemap::get_singleton()->get_remap(local_path); @@ -434,7 +434,7 @@ String ResourceLoader::guess_full_filename(const String &p_path,const String& p_ if (p_path.is_rel_path()) local_path="res://"+p_path; else - local_path = Globals::get_singleton()->localize_path(p_path); + local_path = GlobalConfig::get_singleton()->localize_path(p_path); return find_complete_path(local_path,p_type); @@ -446,7 +446,7 @@ String ResourceLoader::get_resource_type(const String &p_path) { if (p_path.is_rel_path()) local_path="res://"+p_path; else - local_path = Globals::get_singleton()->localize_path(p_path); + local_path = GlobalConfig::get_singleton()->localize_path(p_path); String remapped_path = PathRemap::get_singleton()->get_remap(local_path); String extension=remapped_path.extension(); diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 704603f9ff..9081adaa8f 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -64,7 +64,7 @@ Error ResourceSaver::save(const String &p_path,const RES& p_resource,uint32_t p_ String old_path=p_resource->get_path(); - String local_path=Globals::get_singleton()->localize_path(p_path); + String local_path=GlobalConfig::get_singleton()->localize_path(p_path); RES rwcopy = p_resource; if (p_flags&FLAG_CHANGE_PATH) diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 11fe2337f6..fe46e1671c 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -398,7 +398,7 @@ MessageQueue::MessageQueue() { buffer_end=0; buffer_max_used=0; - buffer_size=GLOBAL_DEF( "core/message_queue_size_kb", DEFAULT_QUEUE_SIZE_KB ); + buffer_size=GLOBAL_DEF( "memory/buffers/message_queue_max_size_kb", DEFAULT_QUEUE_SIZE_KB ); buffer_size*=1024; buffer = memnew_arr( uint8_t, buffer_size ); } diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 7b60baeeb7..804fe15c39 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -37,7 +37,7 @@ String DirAccess::_get_root_path() const { switch(_access_type) { - case ACCESS_RESOURCES: return Globals::get_singleton()->get_resource_path(); + case ACCESS_RESOURCES: return GlobalConfig::get_singleton()->get_resource_path(); case ACCESS_USERDATA: return OS::get_singleton()->get_data_dir(); default: return ""; } @@ -204,10 +204,10 @@ String DirAccess::fix_path(String p_path) const { case ACCESS_RESOURCES: { - if (Globals::get_singleton()) { + if (GlobalConfig::get_singleton()) { if (p_path.begins_with("res://")) { - String resource_path = Globals::get_singleton()->get_resource_path(); + String resource_path = GlobalConfig::get_singleton()->get_resource_path(); if (resource_path != "") { return p_path.replace_first("res:/",resource_path); diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 388c598ac3..06723c5131 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -139,10 +139,10 @@ String FileAccess::fix_path(const String& p_path) const { case ACCESS_RESOURCES: { - if (Globals::get_singleton()) { + if (GlobalConfig::get_singleton()) { if (r_path.begins_with("res://")) { - String resource_path = Globals::get_singleton()->get_resource_path(); + String resource_path = GlobalConfig::get_singleton()->get_resource_path(); if (resource_path != "") { return r_path.replace("res:/",resource_path); diff --git a/core/os/input.cpp b/core/os/input.cpp index c662fafe79..259108802f 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -97,7 +97,7 @@ void Input::get_argument_options(const StringName& p_function,int p_idx,List<Str 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; - Globals::get_singleton()->get_property_list(&pinfo); + GlobalConfig::get_singleton()->get_property_list(&pinfo); for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) { const PropertyInfo &pi=E->get(); diff --git a/core/os/os.cpp b/core/os/os.cpp index f615e54430..75773a9076 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -297,7 +297,7 @@ String OS::get_locale() const { String OS::get_resource_dir() const { - return Globals::get_singleton()->get_resource_path(); + return GlobalConfig::get_singleton()->get_resource_path(); } @@ -307,7 +307,7 @@ String OS::get_system_dir(SystemDir p_dir) const { } String OS::get_safe_application_name() const { - String an = Globals::get_singleton()->get("application/name"); + String an = GlobalConfig::get_singleton()->get("application/name"); Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" "); for (int i=0;i<invalid_char.size();i++) { an = an.replace(invalid_char[i],"-"); diff --git a/core/path_remap.cpp b/core/path_remap.cpp index c0bed76ac8..92a2ab9af7 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -124,7 +124,7 @@ void PathRemap::clear_remaps() { void PathRemap::load_remaps() { // default remaps first - DVector<String> remaps = Globals::get_singleton()->get("remap/all"); + DVector<String> remaps = GlobalConfig::get_singleton()->get("remap/all"); { int rlen = remaps.size(); @@ -141,7 +141,7 @@ void PathRemap::load_remaps() { // platform remaps second, so override - remaps = Globals::get_singleton()->get("remap/"+OS::get_singleton()->get_name()); + remaps = GlobalConfig::get_singleton()->get("remap/"+OS::get_singleton()->get_name()); // remaps = Globals::get_singleton()->get("remap/PSP"); { int rlen = remaps.size(); @@ -160,9 +160,9 @@ void PathRemap::load_remaps() { //locale based remaps - if (Globals::get_singleton()->has("locale/translation_remaps")) { + if (GlobalConfig::get_singleton()->has("locale/translation_remaps")) { - Dictionary remaps = Globals::get_singleton()->get("locale/translation_remaps"); + Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps"); List<Variant> rk; remaps.get_key_list(&rk); for(List<Variant>::Element *E=rk.front();E;E=E->next()) { diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 0e1dec075b..e3c18217e9 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -172,21 +172,28 @@ void register_core_types() { } +void register_core_settings() { + //since in register core types, globals may not e present + GLOBAL_DEF( "network/packets/packet_stream_peer_max_buffer_po2",(16)); + +} + void register_core_singletons() { - Globals::get_singleton()->add_singleton( Globals::Singleton("Globals",Globals::get_singleton()) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("IP",IP::get_singleton()) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("Geometry",_Geometry::get_singleton()) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("ResourceLoader",_ResourceLoader::get_singleton()) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("ResourceSaver",_ResourceSaver::get_singleton()) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("PathRemap",PathRemap::get_singleton() ) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("OS",_OS::get_singleton() ) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("ClassDB",_classdb ) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("Marshalls",_Marshalls::get_singleton() ) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("TranslationServer",TranslationServer::get_singleton() ) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("TS",TranslationServer::get_singleton() ) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("Input",Input::get_singleton() ) ); - Globals::get_singleton()->add_singleton( Globals::Singleton("InputMap",InputMap::get_singleton() ) ); + + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("GlobalConfig",GlobalConfig::get_singleton()) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("IP",IP::get_singleton()) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Geometry",_Geometry::get_singleton()) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ResourceLoader",_ResourceLoader::get_singleton()) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ResourceSaver",_ResourceSaver::get_singleton()) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("PathRemap",PathRemap::get_singleton() ) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("OS",_OS::get_singleton() ) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ClassDB",_classdb ) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Marshalls",_Marshalls::get_singleton() ) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("TranslationServer",TranslationServer::get_singleton() ) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("TS",TranslationServer::get_singleton() ) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Input",Input::get_singleton() ) ); + GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("InputMap",InputMap::get_singleton() ) ); } diff --git a/core/register_core_types.h b/core/register_core_types.h index c9e0d27686..c664d0ebf4 100644 --- a/core/register_core_types.h +++ b/core/register_core_types.h @@ -34,6 +34,7 @@ */ void register_core_types(); +void register_core_settings(); void register_core_singletons(); void unregister_core_types(); diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index c1d78f129a..62fcd5247f 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -134,7 +134,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) { ERR_FAIL(); } - OS::get_singleton()->enable_for_stealing_focus(Globals::get_singleton()->get("editor_pid")); + OS::get_singleton()->enable_for_stealing_focus(GlobalConfig::get_singleton()->get("editor_pid")); packet_peer_stream->put_var("debug_enter"); packet_peer_stream->put_var(2); @@ -1009,12 +1009,12 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() { phl.userdata=this; add_print_handler(&phl); requested_quit=false; - performance = Globals::get_singleton()->get_singleton_object("Performance"); + performance = GlobalConfig::get_singleton()->get_singleton_object("Performance"); last_perf_time=0; poll_every=0; request_scene_tree=NULL; live_edit_funcs=NULL; - max_cps = GLOBAL_DEF("debug/max_remote_stdout_chars_per_second",2048); + max_cps = GLOBAL_DEF("network/debug/max_remote_stdout_chars_per_second",2048); char_count=0; msec_count=0; last_msec=0; @@ -1024,7 +1024,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() { eh.userdata=this; add_error_handler(&eh); - profile_info.resize(CLAMP(int(Globals::get_singleton()->get("debug/profiler_max_functions")),128,65535)); + profile_info.resize(CLAMP(int(GlobalConfig::get_singleton()->get("debug/profiler/max_functions")),128,65535)); profile_info_ptrs.resize(profile_info.size()); profiling=false; max_frame_functions=16; diff --git a/core/translation.cpp b/core/translation.cpp index 9ac1d6a31e..8e58b45565 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -1047,8 +1047,8 @@ TranslationServer *TranslationServer::singleton=NULL; bool TranslationServer::_load_translations(const String& p_from) { - if (Globals::get_singleton()->has(p_from)) { - DVector<String> translations=Globals::get_singleton()->get(p_from); + if (GlobalConfig::get_singleton()->has(p_from)) { + DVector<String> translations=GlobalConfig::get_singleton()->get(p_from); int tcount=translations.size(); @@ -1089,7 +1089,7 @@ void TranslationServer::setup() { options+=locale_list[idx]; idx++; } - Globals::get_singleton()->set_custom_property_info("locale/fallback",PropertyInfo(Variant::STRING,"locale/fallback",PROPERTY_HINT_ENUM,options)); + GlobalConfig::get_singleton()->set_custom_property_info("locale/fallback",PropertyInfo(Variant::STRING,"locale/fallback",PROPERTY_HINT_ENUM,options)); } #endif //load translations diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 5bdc8ef72d..acb262d400 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "undo_redo.h" - +#include "os/os.h" void UndoRedo::_discard_redo() { @@ -54,12 +54,14 @@ void UndoRedo::_discard_redo() { void UndoRedo::create_action(const String& p_name,MergeMode p_mode) { + uint32_t ticks = OS::get_singleton()->get_ticks_msec(); + if (action_level==0) { _discard_redo(); // Check if the merge operation is valid - if (p_mode!=MERGE_DISABLE && actions.size() && actions[actions.size()-1].name==p_name) { + if (p_mode!=MERGE_DISABLE && actions.size() && actions[actions.size()-1].name==p_name && actions[actions.size()-1].last_tick+800 > ticks) { current_action=actions.size()-2; @@ -83,12 +85,15 @@ void UndoRedo::create_action(const String& p_name,MergeMode p_mode) { } } + actions[actions.size()-1].last_tick=ticks; + merge_mode=p_mode; } else { Action new_action; new_action.name=p_name; + new_action.last_tick=ticks; actions.push_back(new_action); merge_mode=MERGE_DISABLE; diff --git a/core/undo_redo.h b/core/undo_redo.h index 3d14dd9ee2..7664cf7cb5 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -76,6 +76,7 @@ private: String name; List<Operation> do_ops; List<Operation> undo_ops; + uint64_t last_tick; }; Vector<Action> actions; |