Ability to revert any property, not just from inherited scenes or scripts.
This commit is contained in:
parent
35e4783f7b
commit
6cc116d415
@ -595,6 +595,7 @@ public:
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool empty() const { return _data.size_cache == 0; }
|
||||||
inline int size() const { return _data.size_cache; }
|
inline int size() const { return _data.size_cache; }
|
||||||
|
|
||||||
int calculate_depth() const {
|
int calculate_depth() const {
|
||||||
|
@ -36,6 +36,50 @@
|
|||||||
#include "multi_node_edit.h"
|
#include "multi_node_edit.h"
|
||||||
#include "scene/resources/packed_scene.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 EditorProperty::get_minimum_size() const {
|
||||||
|
|
||||||
Size2 ms;
|
Size2 ms;
|
||||||
@ -458,6 +502,12 @@ void EditorProperty::update_reload_status() {
|
|||||||
|
|
||||||
bool has_reload = false;
|
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()) {
|
if (_is_instanced_node_with_original_property_different()) {
|
||||||
has_reload = true;
|
has_reload = true;
|
||||||
}
|
}
|
||||||
@ -651,6 +701,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
|
|||||||
Variant rev = object->call("property_get_revert", property);
|
Variant rev = object->call("property_get_revert", property);
|
||||||
emit_signal("property_changed", property, rev);
|
emit_signal("property_changed", property, rev);
|
||||||
update_property();
|
update_property();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object->get_script().is_null()) {
|
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)) {
|
if (scr->get_property_default_value(property, orig_value)) {
|
||||||
emit_signal("property_changed", property, orig_value);
|
emit_signal("property_changed", property, orig_value);
|
||||||
update_property();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,21 @@
|
|||||||
|
|
||||||
class UndoRedo;
|
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 {
|
class EditorProperty : public Container {
|
||||||
|
|
||||||
GDCLASS(EditorProperty, Container)
|
GDCLASS(EditorProperty, Container)
|
||||||
|
@ -4733,6 +4733,8 @@ EditorNode::EditorNode() {
|
|||||||
ResourceLoader::set_timestamp_on_load(true);
|
ResourceLoader::set_timestamp_on_load(true);
|
||||||
ResourceSaver::set_timestamp_on_save(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
|
{ //register importers at the beginning, so dialogs are created with the right extensions
|
||||||
Ref<ResourceImporterTexture> import_texture;
|
Ref<ResourceImporterTexture> import_texture;
|
||||||
import_texture.instance();
|
import_texture.instance();
|
||||||
@ -5857,6 +5859,7 @@ EditorNode::~EditorNode() {
|
|||||||
memdelete(editor_plugins_force_input_forwarding);
|
memdelete(editor_plugins_force_input_forwarding);
|
||||||
memdelete(file_server);
|
memdelete(file_server);
|
||||||
memdelete(progress_hb);
|
memdelete(progress_hb);
|
||||||
|
memdelete(default_value_cache);
|
||||||
EditorSettings::destroy();
|
EditorSettings::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,6 +271,7 @@ private:
|
|||||||
|
|
||||||
Ref<Theme> theme;
|
Ref<Theme> theme;
|
||||||
|
|
||||||
|
EditorDefaultClassValueCache *default_value_cache;
|
||||||
PopupMenu *recent_scenes;
|
PopupMenu *recent_scenes;
|
||||||
SceneTreeDock *scene_tree_dock;
|
SceneTreeDock *scene_tree_dock;
|
||||||
InspectorDock *inspector_dock;
|
InspectorDock *inspector_dock;
|
||||||
|
Loading…
Reference in New Issue
Block a user