Merge pull request #5584 from TheHX/project-settings
Implement undo/redo for adding and deleting global properties
This commit is contained in:
commit
06eef730c0
2 changed files with 33 additions and 5 deletions
|
@ -606,10 +606,26 @@ void ProjectSettings::_item_add() {
|
|||
|
||||
String name = catname!="" ? catname+"/"+propname : propname;
|
||||
|
||||
Globals::get_singleton()->set(name,value);
|
||||
undo_redo->create_action("Add Global Property");
|
||||
|
||||
undo_redo->add_do_property(Globals::get_singleton(), name, value);
|
||||
undo_redo->add_do_method(Globals::get_singleton(), "set_persisting", name, true);
|
||||
|
||||
if (Globals::get_singleton()->has(name)) {
|
||||
undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name));
|
||||
} else {
|
||||
undo_redo->add_undo_property(Globals::get_singleton(), name, Variant());
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(globals_editor, "update_category_list");
|
||||
undo_redo->add_undo_method(globals_editor, "update_category_list");
|
||||
|
||||
undo_redo->add_do_method(this, "_settings_changed");
|
||||
undo_redo->add_undo_method(this, "_settings_changed");
|
||||
|
||||
undo_redo->commit_action();
|
||||
|
||||
globals_editor->set_current_section(catname);
|
||||
globals_editor->update_category_list();
|
||||
|
||||
_settings_changed();
|
||||
}
|
||||
|
@ -623,10 +639,20 @@ void ProjectSettings::_item_del() {
|
|||
|
||||
String name = catname!="" ? catname+"/"+propname : propname;
|
||||
|
||||
Globals::get_singleton()->set(name,Variant());
|
||||
undo_redo->create_action("Delete Global Property");
|
||||
|
||||
globals_editor->set_current_section(catname);
|
||||
globals_editor->update_category_list();
|
||||
undo_redo->add_do_property(Globals::get_singleton(), name, Variant());
|
||||
|
||||
undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name));
|
||||
undo_redo->add_undo_method(Globals::get_singleton(), "set_persisting", name, Globals::get_singleton()->is_persisting(name));
|
||||
|
||||
undo_redo->add_do_method(globals_editor, "update_category_list");
|
||||
undo_redo->add_undo_method(globals_editor, "update_category_list");
|
||||
|
||||
undo_redo->add_do_method(this, "_settings_changed");
|
||||
undo_redo->add_undo_method(this, "_settings_changed");
|
||||
|
||||
undo_redo->commit_action();
|
||||
|
||||
_settings_changed();
|
||||
}
|
||||
|
|
|
@ -4187,6 +4187,8 @@ public:
|
|||
void SectionedPropertyEditor::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method("_section_selected",&SectionedPropertyEditor::_section_selected);
|
||||
|
||||
ObjectTypeDB::bind_method("update_category_list", &SectionedPropertyEditor::update_category_list);
|
||||
}
|
||||
|
||||
void SectionedPropertyEditor::_section_selected(int p_which) {
|
||||
|
|
Loading…
Reference in a new issue