Fixed issues with adding custom project settings and added confirmation dialog when deleting settings.

This commit is contained in:
Eric M 2020-08-14 18:04:34 +10:00
parent ba1109a3b3
commit 8f54e8bfb5
3 changed files with 17 additions and 5 deletions

View file

@ -76,8 +76,8 @@ protected:
}; };
bool registering_order = true; bool registering_order = true;
int last_order = 0; int last_order = NO_BUILTIN_ORDER_BASE;
int last_builtin_order = NO_BUILTIN_ORDER_BASE; int last_builtin_order = 0;
Map<StringName, VariantContainer> props; Map<StringName, VariantContainer> props;
String resource_path; String resource_path;
Map<StringName, PropertyInfo> custom_prop_info; Map<StringName, PropertyInfo> custom_prop_info;

View file

@ -113,11 +113,17 @@ void ProjectSettingsEditor::_add_setting() {
inspector->set_current_section(setting.get_slice("/", 1)); inspector->set_current_section(setting.get_slice("/", 1));
} }
void ProjectSettingsEditor::_delete_setting() { void ProjectSettingsEditor::_delete_setting(bool p_confirmed) {
String setting = _get_setting_name(); String setting = _get_setting_name();
Variant value = ps->get(setting); Variant value = ps->get(setting);
int order = ps->get_order(setting); int order = ps->get_order(setting);
if (!p_confirmed) {
del_confirmation->set_text(vformat(TTR("Are you sure you want to delete '%s'?"), setting));
del_confirmation->popup_centered();
return;
}
undo_redo->create_action(TTR("Delete Item")); undo_redo->create_action(TTR("Delete Item"));
undo_redo->add_do_method(ps, "clear", setting); undo_redo->add_do_method(ps, "clear", setting);
@ -394,7 +400,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
del_button = memnew(Button); del_button = memnew(Button);
del_button->set_flat(true); del_button->set_flat(true);
del_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_delete_setting)); del_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_delete_setting), varray(false));
hbc->add_child(del_button); hbc->add_child(del_button);
error_label = memnew(Label); error_label = memnew(Label);
@ -466,6 +472,10 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
timer->set_one_shot(true); timer->set_one_shot(true);
add_child(timer); add_child(timer);
del_confirmation = memnew(ConfirmationDialog);
del_confirmation->connect("confirmed", callable_mp(this, &ProjectSettingsEditor::_delete_setting), varray(true));
add_child(del_confirmation);
get_ok()->set_text(TTR("Close")); get_ok()->set_text(TTR("Close"));
set_hide_on_ok(true); set_hide_on_ok(true);
} }

View file

@ -77,6 +77,8 @@ class ProjectSettingsEditor : public AcceptDialog {
OptionButton *feature_override; OptionButton *feature_override;
Label *error_label; Label *error_label;
ConfirmationDialog *del_confirmation;
Label *restart_label; Label *restart_label;
TextureRect *restart_icon; TextureRect *restart_icon;
PanelContainer *restart_container; PanelContainer *restart_container;
@ -94,7 +96,7 @@ class ProjectSettingsEditor : public AcceptDialog {
void _setting_edited(const String &p_name); void _setting_edited(const String &p_name);
void _setting_selected(const String &p_path); void _setting_selected(const String &p_path);
void _add_setting(); void _add_setting();
void _delete_setting(); void _delete_setting(bool p_confirmed);
void _editor_restart_request(); void _editor_restart_request();
void _editor_restart(); void _editor_restart();