small fix for undo redo

This commit is contained in:
Juan Linietsky 2015-12-16 00:42:34 -03:00
parent d3cd1250bd
commit fb01d18251
3 changed files with 20 additions and 5 deletions

View File

@ -671,10 +671,14 @@ void ProjectSettings::_action_rename(const String &p_name) {
void ProjectSettings::_item_checked(const String& p_item, bool p_check) { void ProjectSettings::_item_checked(const String& p_item, bool p_check) {
undo_redo->create_action("Toggle Persisting"); undo_redo->create_action("Toggle Persisting");
undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",p_item,p_check); String full_item = globals_editor->get_full_item_path(p_item);
undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",p_item,!p_check);
undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",full_item,p_check);
undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",full_item,!p_check);
undo_redo->add_do_method(this,"_settings_changed"); undo_redo->add_do_method(this,"_settings_changed");
undo_redo->add_undo_method(this,"_settings_changed"); undo_redo->add_undo_method(this,"_settings_changed");
undo_redo->add_do_method(globals_editor->get_property_editor(),"update_tree");
undo_redo->add_undo_method(globals_editor->get_property_editor(),"update_tree");
undo_redo->commit_action(); undo_redo->commit_action();
} }
@ -692,8 +696,8 @@ void ProjectSettings::_save() {
void ProjectSettings::_settings_prop_edited(const String& p_name) { void ProjectSettings::_settings_prop_edited(const String& p_name) {
if (!Globals::get_singleton()->is_persisting(p_name)) { if (!Globals::get_singleton()->is_persisting(p_name)) {
String full_item = globals_editor->get_full_item_path(p_name);
Globals::get_singleton()->set_persisting(p_name,true); Globals::get_singleton()->set_persisting(full_item,true);
// globals_editor->update_property(p_name); // globals_editor->update_property(p_name);
globals_editor->get_property_editor()->update_tree(); globals_editor->get_property_editor()->update_tree();
} }
@ -1405,7 +1409,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
globals_editor->get_property_editor()->register_text_enter(search_box); globals_editor->get_property_editor()->register_text_enter(search_box);
globals_editor->get_property_editor()->set_capitalize_paths(false); globals_editor->get_property_editor()->set_capitalize_paths(false);
globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected",this,"_item_selected"); globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected",this,"_item_selected");
globals_editor->get_property_editor()->connect("property_toggled",this,"_item_checked"); globals_editor->get_property_editor()->connect("property_toggled",this,"_item_checked",varray(),CONNECT_DEFERRED);
globals_editor->get_property_editor()->connect("property_edited",this,"_settings_prop_edited"); globals_editor->get_property_editor()->connect("property_edited",this,"_settings_prop_edited");
/* /*

View File

@ -3486,6 +3486,7 @@ void PropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method( "_draw_flags",&PropertyEditor::_draw_flags); ObjectTypeDB::bind_method( "_draw_flags",&PropertyEditor::_draw_flags);
ObjectTypeDB::bind_method( "_set_range_def",&PropertyEditor::_set_range_def); ObjectTypeDB::bind_method( "_set_range_def",&PropertyEditor::_set_range_def);
ObjectTypeDB::bind_method( "_filter_changed",&PropertyEditor::_filter_changed); ObjectTypeDB::bind_method( "_filter_changed",&PropertyEditor::_filter_changed);
ObjectTypeDB::bind_method( "update_tree",&PropertyEditor::update_tree);
ADD_SIGNAL( MethodInfo("property_toggled",PropertyInfo( Variant::STRING, "property"),PropertyInfo( Variant::BOOL, "value"))); ADD_SIGNAL( MethodInfo("property_toggled",PropertyInfo( Variant::STRING, "property"),PropertyInfo( Variant::BOOL, "value")));
ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) ); ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
@ -3738,6 +3739,15 @@ void SectionedPropertyEditor::_section_selected(int p_which) {
filter->set_section( sections->get_item_metadata(p_which) ); filter->set_section( sections->get_item_metadata(p_which) );
} }
String SectionedPropertyEditor::get_full_item_path(const String& p_item) {
String base = sections->get_item_metadata( sections->get_current() );
if (base!="")
return base+"/"+p_item;
else
return p_item;
}
void SectionedPropertyEditor::edit(Object* p_object) { void SectionedPropertyEditor::edit(Object* p_object) {
List<PropertyInfo> pinfo; List<PropertyInfo> pinfo;

View File

@ -267,6 +267,7 @@ public:
PropertyEditor *get_property_editor(); PropertyEditor *get_property_editor();
void edit(Object* p_object); void edit(Object* p_object);
String get_full_item_path(const String& p_item);
SectionedPropertyEditor(); SectionedPropertyEditor();
~SectionedPropertyEditor(); ~SectionedPropertyEditor();