1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-01 16:38:31 +00:00

Fix Project Settings array/dicts initial value being shared instances of the current value.

This commit is contained in:
Eric M
2023-01-13 21:36:44 +10:00
parent 3c9bf4bc21
commit 7c73b6c71c
4 changed files with 27 additions and 13 deletions

View File

@@ -198,6 +198,14 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i
emit_signal(SNAME("action_edited"), action_name, action);
} break;
case ActionMapEditor::BUTTON_REVERT_ACTION: {
ERR_FAIL_COND_MSG(!item->has_meta("__action_initial"), "Tree Item for action which can be reverted is expected to have meta value with initial value of action.");
Dictionary action = item->get_meta("__action_initial").duplicate();
String action_name = item->get_meta("__name");
emit_signal(SNAME("action_edited"), action_name, action);
} break;
default:
break;
}
@@ -431,6 +439,13 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
action_item->set_range(1, deadzone);
// Third column - buttons
if (action_info.has_initial) {
bool deadzone_eq = action_info.action_initial["deadzone"] == action_info.action["deadzone"];
bool events_eq = Shortcut::is_event_array_equal(action_info.action_initial["events"], action_info.action["events"]);
bool action_eq = deadzone_eq && events_eq;
action_item->set_meta("__action_initial", action_info.action_initial);
action_item->add_button(2, action_tree->get_theme_icon(SNAME("ReloadSmall"), SNAME("EditorIcons")), BUTTON_REVERT_ACTION, action_eq, action_eq ? TTR("Cannot Revert - Action is same as initial") : TTR("Revert Action"));
}
action_item->add_button(2, action_tree->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), BUTTON_ADD_EVENT, false, TTR("Add Event"));
action_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_ACTION, !action_info.editable, action_info.editable ? TTR("Remove Action") : TTR("Cannot Remove Action"));