|
@@ -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;
|
|
|
}
|
|
@@ -427,6 +435,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"));
|
|
|
|