summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/set.h1
-rw-r--r--editor/editor_inspector.cpp61
-rw-r--r--editor/editor_inspector.h15
-rw-r--r--editor/editor_node.cpp3
-rw-r--r--editor/editor_node.h1
5 files changed, 81 insertions, 0 deletions
diff --git a/core/set.h b/core/set.h
index 744019d5b4..59aa54128e 100644
--- a/core/set.h
+++ b/core/set.h
@@ -595,6 +595,7 @@ public:
return e;
}
+ inline bool empty() const { return _data.size_cache == 0; }
inline int size() const { return _data.size_cache; }
int calculate_depth() const {
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 3ecaa2b136..892e6daae2 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -36,6 +36,50 @@
#include "multi_node_edit.h"
#include "scene/resources/packed_scene.h"
+EditorDefaultClassValueCache *EditorDefaultClassValueCache::singleton = NULL;
+
+EditorDefaultClassValueCache *EditorDefaultClassValueCache::get_singleton() {
+ return singleton;
+}
+
+Variant EditorDefaultClassValueCache::get_default_value(const StringName &p_class, const StringName &p_property) {
+
+ if (!default_values.has(p_class)) {
+
+ default_values[p_class] = Map<StringName, Variant>();
+
+ if (ClassDB::can_instance(p_class)) {
+
+ Object *c = ClassDB::instance(p_class);
+ List<PropertyInfo> plist;
+ c->get_property_list(&plist);
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
+ if (E->get().usage & PROPERTY_USAGE_EDITOR) {
+
+ Variant v = c->get(E->get().name);
+ default_values[p_class][E->get().name] = v;
+ }
+ }
+ memdelete(c);
+ }
+ }
+
+ if (!default_values.has(p_class)) {
+ return Variant();
+ }
+
+ if (!default_values[p_class].has(p_property)) {
+ return Variant();
+ }
+
+ return default_values[p_class][p_property];
+}
+
+EditorDefaultClassValueCache::EditorDefaultClassValueCache() {
+ ERR_FAIL_COND(singleton != NULL);
+ singleton = this;
+}
+
Size2 EditorProperty::get_minimum_size() const {
Size2 ms;
@@ -458,6 +502,12 @@ void EditorProperty::update_reload_status() {
bool has_reload = false;
+ if (EditorDefaultClassValueCache::get_singleton()) {
+ Variant default_value = EditorDefaultClassValueCache::get_singleton()->get_default_value(object->get_class_name(), property);
+ if (default_value != Variant() && default_value != object->get(property)) {
+ has_reload = true;
+ }
+ }
if (_is_instanced_node_with_original_property_different()) {
has_reload = true;
}
@@ -651,6 +701,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
Variant rev = object->call("property_get_revert", property);
emit_signal("property_changed", property, rev);
update_property();
+ return;
}
if (!object->get_script().is_null()) {
@@ -659,6 +710,16 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
if (scr->get_property_default_value(property, orig_value)) {
emit_signal("property_changed", property, orig_value);
update_property();
+ return;
+ }
+ }
+
+ if (EditorDefaultClassValueCache::get_singleton()) {
+ Variant default_value = EditorDefaultClassValueCache::get_singleton()->get_default_value(object->get_class_name(), property);
+ if (default_value != Variant()) {
+ emit_signal("property_changed", property, default_value);
+ update_property();
+ return;
}
}
}
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index dccbdb9a73..58511a17fe 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -37,6 +37,21 @@
class UndoRedo;
+class EditorDefaultClassValueCache : public Object {
+ GDCLASS(EditorDefaultClassValueCache,Object)
+
+ Map<StringName,Map<StringName,Variant> > default_values;
+
+ static EditorDefaultClassValueCache *singleton;
+public:
+
+ static EditorDefaultClassValueCache *get_singleton();
+
+ Variant get_default_value(const StringName& p_class,const StringName& p_property);
+ EditorDefaultClassValueCache();
+};
+
+
class EditorProperty : public Container {
GDCLASS(EditorProperty, Container)
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 7155905472..1b5b7be728 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4733,6 +4733,8 @@ EditorNode::EditorNode() {
ResourceLoader::set_timestamp_on_load(true);
ResourceSaver::set_timestamp_on_save(true);
+ default_value_cache = memnew( EditorDefaultClassValueCache );
+
{ //register importers at the beginning, so dialogs are created with the right extensions
Ref<ResourceImporterTexture> import_texture;
import_texture.instance();
@@ -5857,6 +5859,7 @@ EditorNode::~EditorNode() {
memdelete(editor_plugins_force_input_forwarding);
memdelete(file_server);
memdelete(progress_hb);
+ memdelete(default_value_cache);
EditorSettings::destroy();
}
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 0096748ed1..1021d88c25 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -271,6 +271,7 @@ private:
Ref<Theme> theme;
+ EditorDefaultClassValueCache *default_value_cache;
PopupMenu *recent_scenes;
SceneTreeDock *scene_tree_dock;
InspectorDock *inspector_dock;