summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/globals.cpp20
-rw-r--r--core/globals.h2
-rw-r--r--doc/base/classes.xml38
-rw-r--r--tools/editor/editor_settings.cpp21
-rw-r--r--tools/editor/editor_settings.h2
5 files changed, 83 insertions, 0 deletions
diff --git a/core/globals.cpp b/core/globals.cpp
index e760bc00d4..3f0edd68f4 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -1375,6 +1375,25 @@ Vector<String> Globals::get_optimizer_presets() const {
}
+void Globals::_add_property_info_bind(const Dictionary& p_info) {
+
+ ERR_FAIL_COND(!p_info.has("name"));
+ ERR_FAIL_COND(!p_info.has("type"));
+
+ PropertyInfo pinfo;
+ pinfo.name = p_info["name"];
+ ERR_FAIL_COND(!props.has(pinfo.name));
+ pinfo.type = Variant::Type(p_info["type"].operator int());
+ ERR_FAIL_INDEX(pinfo.type, Variant::VARIANT_MAX);
+
+ if (p_info.has("hint"))
+ pinfo.hint = PropertyHint(p_info["hint"].operator int());
+ if (p_info.has("hint_string"))
+ pinfo.hint_string = p_info["hint_string"];
+
+ set_custom_property_info(pinfo.name, pinfo);
+}
+
void Globals::set_custom_property_info(const String& p_prop,const PropertyInfo& p_info) {
ERR_FAIL_COND(!props.has(p_prop));
@@ -1399,6 +1418,7 @@ void Globals::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_order","name"),&Globals::get_order);
ObjectTypeDB::bind_method(_MD("set_persisting","name","enable"),&Globals::set_persisting);
ObjectTypeDB::bind_method(_MD("is_persisting","name"),&Globals::is_persisting);
+ ObjectTypeDB::bind_method(_MD("add_property_info", "hint"),&Globals::_add_property_info_bind);
ObjectTypeDB::bind_method(_MD("clear","name"),&Globals::clear);
ObjectTypeDB::bind_method(_MD("localize_path","path"),&Globals::localize_path);
ObjectTypeDB::bind_method(_MD("globalize_path","path"),&Globals::globalize_path);
diff --git a/core/globals.h b/core/globals.h
index 68bb859ace..f24b2daf79 100644
--- a/core/globals.h
+++ b/core/globals.h
@@ -96,6 +96,8 @@ protected:
bool _load_resource_pack(const String& p_pack);
+ void _add_property_info_bind(const Dictionary& p_info);
+
protected:
static void _bind_methods();
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 9400d7de03..9c6b9742b3 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -11738,6 +11738,24 @@
[/codeblock]
</description>
<methods>
+ <method name="add_property_info">
+ <argument index="0" name="info" type="Dictionary">
+ </argument>
+ <description>
+ Add a custom property info to a property. The dictionary must contain: name:[String](the name of the property) and type:[int](see TYPE_* in [@Global Scope]), and optionally hint:[int](see PROPERTY_HINT_* in [@Global Scope]), hint_string:[String].
+ Example:[codeblock]
+ editor_settings.set("category/property_name", 0)
+
+ var property_info = {
+ "name": "category/property_name",
+ "type": TYPE_INT,
+ "hint": PROPERTY_HINT_ENUM,
+ "hint_string": "one,two,three"
+ }
+
+ editor_settings.add_property_info(property_info)[/codeblock]
+ </description>
+ </method>
<method name="erase">
<argument index="0" name="property" type="String">
</argument>
@@ -13754,6 +13772,26 @@
Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in engine.cfg are also loaded into globals, making this object very useful for reading custom game configuration options.
</description>
<methods>
+ <method name="add_property_info">
+ <argument index="0" name="hint" type="Dictionary">
+ </argument>
+ <description>
+ Add a custom property info to a property. The dictionary must contain: name:[String](the name of the property) and type:[int](see TYPE_* in [@Global Scope]), and optionally hint:[int](see PROPERTY_HINT_* in [@Global Scope]), hint_string:[String].
+ Example:
+ [codeblock]
+ Globals.set("category/property_name", 0)
+
+ var property_info = {
+ "name": "category/property_name",
+ "type": TYPE_INT,
+ "hint": PROPERTY_HINT_ENUM,
+ "hint_string": "one,two,three"
+ }
+
+ Globals.add_property_info(property_info)
+ [/codeblock]
+ </description>
+ </method>
<method name="clear">
<argument index="0" name="name" type="String">
</argument>
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 582462aa19..d77234bece 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -731,6 +731,25 @@ void EditorSettings::notify_changes() {
}
+void EditorSettings::_add_property_info_bind(const Dictionary& p_info) {
+
+ ERR_FAIL_COND(!p_info.has("name"));
+ ERR_FAIL_COND(!p_info.has("type"));
+
+ PropertyInfo pinfo;
+ pinfo.name = p_info["name"];
+ ERR_FAIL_COND(!props.has(pinfo.name));
+ pinfo.type = Variant::Type(p_info["type"].operator int());
+ ERR_FAIL_INDEX(pinfo.type, Variant::VARIANT_MAX);
+
+ if (p_info.has("hint"))
+ pinfo.hint = PropertyHint(p_info["hint"].operator int());
+ if (p_info.has("hint_string"))
+ pinfo.hint_string = p_info["hint_string"];
+
+ add_property_hint(pinfo);
+}
+
void EditorSettings::add_property_hint(const PropertyInfo& p_hint) {
_THREAD_SAFE_METHOD_
@@ -1001,6 +1020,8 @@ void EditorSettings::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_settings_path"),&EditorSettings::get_settings_path);
ObjectTypeDB::bind_method(_MD("get_project_settings_path"),&EditorSettings::get_project_settings_path);
+ ObjectTypeDB::bind_method(_MD("add_property_info", "info"),&EditorSettings::_add_property_info_bind);
+
ObjectTypeDB::bind_method(_MD("set_favorite_dirs","dirs"),&EditorSettings::set_favorite_dirs);
ObjectTypeDB::bind_method(_MD("get_favorite_dirs"),&EditorSettings::get_favorite_dirs);
diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h
index 937956a366..2a7d3bb4f0 100644
--- a/tools/editor/editor_settings.h
+++ b/tools/editor/editor_settings.h
@@ -104,6 +104,8 @@ private:
Map<String,Ref<ShortCut> > shortcuts;
+ void _add_property_info_bind(const Dictionary& p_info);
+
protected:
static void _bind_methods();