diff options
Diffstat (limited to 'core/global_config.h')
-rw-r--r-- | core/global_config.h | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/core/global_config.h b/core/global_config.h index 471f1ff885..7bdf356129 100644 --- a/core/global_config.h +++ b/core/global_config.h @@ -30,32 +30,32 @@ #define GLOBAL_CONFIG_H #include "object.h" -#include "set.h" #include "os/thread_safe.h" +#include "set.h" /** @author Juan Linietsky <reduzio@gmail.com> */ - class GlobalConfig : public Object { - GDCLASS( GlobalConfig, Object ); + GDCLASS(GlobalConfig, Object); _THREAD_SAFE_CLASS_ public: - - typedef Map<String,Variant> CustomMap; + typedef Map<String, Variant> CustomMap; struct Singleton { StringName name; Object *ptr; - Singleton(const StringName& p_name=StringName(), Object *p_ptr=NULL) { name=p_name; ptr=p_ptr; } + Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) { + name = p_name; + ptr = p_ptr; + } }; protected: - enum { - NO_ORDER_BASE=1<<18 + NO_ORDER_BASE = 1 << 18 }; struct VariantContainer { @@ -65,22 +65,32 @@ protected: Variant initial; bool hide_from_editor; bool overrided; - VariantContainer(){ order=0; hide_from_editor=false; persist=false; overrided=false; } - VariantContainer(const Variant& p_variant, int p_order, bool p_persist=false) { variant=p_variant; order=p_order; hide_from_editor=false; persist=p_persist; overrided=false; } + VariantContainer() { + order = 0; + hide_from_editor = false; + persist = false; + overrided = false; + } + VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) { + variant = p_variant; + order = p_order; + hide_from_editor = false; + persist = p_persist; + overrided = false; + } }; bool registering_order; int last_order; - Map<StringName,VariantContainer> props; + Map<StringName, VariantContainer> props; String resource_path; - Map<StringName,PropertyInfo> custom_prop_info; + Map<StringName, PropertyInfo> custom_prop_info; bool disable_platform_override; bool using_datapack; List<String> input_presets; - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; static GlobalConfig *singleton; @@ -88,58 +98,55 @@ protected: Error _load_settings(const String p_path); Error _load_settings_binary(const String p_path); - Error _save_settings_text(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom=CustomMap()); - Error _save_settings_binary(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom=CustomMap()); + Error _save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap()); + Error _save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap()); List<Singleton> singletons; - Map<StringName,Object*> singleton_ptrs; + Map<StringName, Object *> singleton_ptrs; - Error _save_custom_bnd(const String& p_file); + Error _save_custom_bnd(const String &p_file); - bool _load_resource_pack(const String& p_pack); + bool _load_resource_pack(const String &p_pack); - void _add_property_info_bind(const Dictionary& p_info); + void _add_property_info_bind(const Dictionary &p_info); protected: - static void _bind_methods(); -public: - +public: bool has(String p_var) const; - String localize_path(const String& p_path) const; - String globalize_path(const String& p_path) const; - + String localize_path(const String &p_path) const; + String globalize_path(const String &p_path) 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); + 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 GlobalConfig *get_singleton(); - void clear(const String& p_name); - int get_order(const String& p_name) const; - void set_order(const String& p_name, int p_order); + void clear(const String &p_name); + int get_order(const String &p_name) const; + void set_order(const String &p_name, int p_order); - Error setup(const String& p_path, const String &p_main_pack); + Error setup(const String &p_path, const String &p_main_pack); - Error save_custom(const String& p_path="",const CustomMap& p_custom=CustomMap(),const Set<String>& p_ignore_masks=Set<String>()); + Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Set<String> &p_ignore_masks = Set<String>()); Error save(); - void set_custom_property_info(const String& p_prop,const PropertyInfo& p_info); + void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info); void add_singleton(const Singleton &p_singleton); void get_singletons(List<Singleton> *p_singletons); - bool has_singleton(const String& p_name) const; + bool has_singleton(const String &p_name) const; Vector<String> get_optimizer_presets() const; List<String> get_input_presets() const { return input_presets; } void set_disable_platform_override(bool p_disable); - Object* get_singleton_object(const String& p_name) const; + Object *get_singleton_object(const String &p_name) const; void register_global_defaults(); @@ -149,12 +156,11 @@ public: 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) +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 |