Cleanup CControllerConfigManager deletion a bit

This commit is contained in:
Sergeanur 2020-08-20 19:56:02 +03:00
parent b5ccc721ae
commit 73dd29ea3a

View File

@ -1613,30 +1613,25 @@ bool CControllerConfigManager::GetIsMouseButtonUp(RsKeyCodes keycode)
return false; return false;
} }
#define CLEAR_ACTION_IF_NEEDED(action) \
if (key == GetControllerKeyAssociatedWithAction(action, type))\
ClearSettingsAssociatedWithAction(action, type);
void CControllerConfigManager::DeleteMatchingCommonControls(e_ControllerAction action, int32 key, eControllerType type) void CControllerConfigManager::DeleteMatchingCommonControls(e_ControllerAction action, int32 key, eControllerType type)
{ {
if (!GetIsKeyBlank(key, type)) if (!GetIsKeyBlank(key, type))
{ {
if (key == GetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS,type)) CLEAR_ACTION_IF_NEEDED(CAMERA_CHANGE_VIEW_ALL_SITUATIONS);
ClearSettingsAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, type);
#ifndef BIND_VEHICLE_FIREWEAPON #ifndef BIND_VEHICLE_FIREWEAPON
if (key == GetControllerKeyAssociatedWithAction(PED_FIREWEAPON, type)) CLEAR_ACTION_IF_NEEDED(PED_FIREWEAPON);
ClearSettingsAssociatedWithAction(PED_FIREWEAPON, type);
#endif #endif
if (key == GetControllerKeyAssociatedWithAction(GO_LEFT, type)) CLEAR_ACTION_IF_NEEDED(GO_LEFT);
ClearSettingsAssociatedWithAction(GO_LEFT, type); CLEAR_ACTION_IF_NEEDED(GO_RIGHT);
if (key == GetControllerKeyAssociatedWithAction(GO_RIGHT, type)) CLEAR_ACTION_IF_NEEDED(NETWORK_TALK);
ClearSettingsAssociatedWithAction(GO_RIGHT, type); CLEAR_ACTION_IF_NEEDED(SWITCH_DEBUG_CAM_ON);
if (key == GetControllerKeyAssociatedWithAction(NETWORK_TALK, type)) CLEAR_ACTION_IF_NEEDED(TOGGLE_DPAD);
ClearSettingsAssociatedWithAction(NETWORK_TALK, type); CLEAR_ACTION_IF_NEEDED(TAKE_SCREEN_SHOT);
if (key == GetControllerKeyAssociatedWithAction(SWITCH_DEBUG_CAM_ON, type)) CLEAR_ACTION_IF_NEEDED(SHOW_MOUSE_POINTER_TOGGLE);
ClearSettingsAssociatedWithAction(SWITCH_DEBUG_CAM_ON, type);
if (key == GetControllerKeyAssociatedWithAction(TOGGLE_DPAD, type))
ClearSettingsAssociatedWithAction(TOGGLE_DPAD, type);
if (key == GetControllerKeyAssociatedWithAction(TAKE_SCREEN_SHOT, type))
ClearSettingsAssociatedWithAction(TAKE_SCREEN_SHOT, type);
if (key == GetControllerKeyAssociatedWithAction(SHOW_MOUSE_POINTER_TOGGLE, type))
ClearSettingsAssociatedWithAction(SHOW_MOUSE_POINTER_TOGGLE, type);
} }
} }
@ -1644,25 +1639,17 @@ void CControllerConfigManager::DeleteMatching3rdPersonControls(e_ControllerActio
{ {
if (!GetIsKeyBlank(key, type)) if (!GetIsKeyBlank(key, type))
{ {
if (key == GetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, type)) CLEAR_ACTION_IF_NEEDED(PED_LOOKBEHIND);
ClearSettingsAssociatedWithAction(PED_LOOKBEHIND, type); CLEAR_ACTION_IF_NEEDED(PED_CYCLE_WEAPON_LEFT);
if (key == GetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, type)) CLEAR_ACTION_IF_NEEDED(PED_CYCLE_WEAPON_RIGHT);
ClearSettingsAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, type); CLEAR_ACTION_IF_NEEDED(PED_JUMPING);
if (key == GetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, type)) CLEAR_ACTION_IF_NEEDED(PED_SPRINT);
ClearSettingsAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, type);
if (key == GetControllerKeyAssociatedWithAction(PED_JUMPING, type))
ClearSettingsAssociatedWithAction(PED_JUMPING, type);
if (key == GetControllerKeyAssociatedWithAction(PED_SPRINT, type))
ClearSettingsAssociatedWithAction(PED_SPRINT, type);
if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC)
{ {
if (key == GetControllerKeyAssociatedWithAction(PED_CYCLE_TARGET_LEFT, type)) CLEAR_ACTION_IF_NEEDED(PED_CYCLE_TARGET_LEFT);
ClearSettingsAssociatedWithAction(PED_CYCLE_TARGET_LEFT, type); CLEAR_ACTION_IF_NEEDED(PED_CYCLE_TARGET_RIGHT);
if (key == GetControllerKeyAssociatedWithAction(PED_CYCLE_TARGET_RIGHT, type)) CLEAR_ACTION_IF_NEEDED(PED_CENTER_CAMERA_BEHIND_PLAYER);
ClearSettingsAssociatedWithAction(PED_CYCLE_TARGET_RIGHT, type);
if (key == GetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, type))
ClearSettingsAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, type);
} }
} }
} }
@ -1672,26 +1659,18 @@ void CControllerConfigManager::DeleteMatching1rst3rdPersonControls(e_ControllerA
if (!GetIsKeyBlank(key, type)) if (!GetIsKeyBlank(key, type))
{ {
#ifdef BIND_VEHICLE_FIREWEAPON #ifdef BIND_VEHICLE_FIREWEAPON
if (key == GetControllerKeyAssociatedWithAction(PED_FIREWEAPON, type)) CLEAR_ACTION_IF_NEEDED(PED_FIREWEAPON);
ClearSettingsAssociatedWithAction(PED_FIREWEAPON, type);
#endif #endif
if (key == GetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, type)) CLEAR_ACTION_IF_NEEDED(PED_LOCK_TARGET);
ClearSettingsAssociatedWithAction(PED_LOCK_TARGET, type); CLEAR_ACTION_IF_NEEDED(GO_FORWARD);
if (key == GetControllerKeyAssociatedWithAction(GO_FORWARD, type)) CLEAR_ACTION_IF_NEEDED(GO_BACK);
ClearSettingsAssociatedWithAction(GO_FORWARD, type);
if (key == GetControllerKeyAssociatedWithAction(GO_BACK, type))
ClearSettingsAssociatedWithAction(GO_BACK, type);
if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC)
{ {
if (key == GetControllerKeyAssociatedWithAction(PED_1RST_PERSON_LOOK_LEFT, type)) CLEAR_ACTION_IF_NEEDED(PED_1RST_PERSON_LOOK_LEFT);
ClearSettingsAssociatedWithAction(PED_1RST_PERSON_LOOK_LEFT, type); CLEAR_ACTION_IF_NEEDED(PED_1RST_PERSON_LOOK_RIGHT);
if (key == GetControllerKeyAssociatedWithAction(PED_1RST_PERSON_LOOK_RIGHT, type)) CLEAR_ACTION_IF_NEEDED(PED_1RST_PERSON_LOOK_DOWN);
ClearSettingsAssociatedWithAction(PED_1RST_PERSON_LOOK_RIGHT, type); CLEAR_ACTION_IF_NEEDED(PED_1RST_PERSON_LOOK_UP);
if (key == GetControllerKeyAssociatedWithAction(PED_1RST_PERSON_LOOK_DOWN, type))
ClearSettingsAssociatedWithAction(PED_1RST_PERSON_LOOK_DOWN, type);
if (key == GetControllerKeyAssociatedWithAction(PED_1RST_PERSON_LOOK_UP, type))
ClearSettingsAssociatedWithAction(PED_1RST_PERSON_LOOK_UP, type);
} }
} }
} }
@ -1701,37 +1680,22 @@ void CControllerConfigManager::DeleteMatchingVehicleControls(e_ControllerAction
if (!GetIsKeyBlank(key, type)) if (!GetIsKeyBlank(key, type))
{ {
#ifdef BIND_VEHICLE_FIREWEAPON #ifdef BIND_VEHICLE_FIREWEAPON
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, type)) CLEAR_ACTION_IF_NEEDED(VEHICLE_FIREWEAPON);
ClearSettingsAssociatedWithAction(VEHICLE_FIREWEAPON, type);
#endif #endif
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_LOOKBEHIND, type)) CLEAR_ACTION_IF_NEEDED(VEHICLE_LOOKBEHIND);
ClearSettingsAssociatedWithAction(VEHICLE_LOOKBEHIND, type); CLEAR_ACTION_IF_NEEDED(VEHICLE_LOOKLEFT);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, type)) CLEAR_ACTION_IF_NEEDED(VEHICLE_LOOKRIGHT);
ClearSettingsAssociatedWithAction(VEHICLE_LOOKLEFT, type); CLEAR_ACTION_IF_NEEDED(VEHICLE_LOOKBEHIND); // note: duplicate
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, type)) CLEAR_ACTION_IF_NEEDED(VEHICLE_HORN);
ClearSettingsAssociatedWithAction(VEHICLE_LOOKRIGHT, type); CLEAR_ACTION_IF_NEEDED(VEHICLE_HANDBRAKE);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_LOOKBEHIND, type)) // note: dublicate CLEAR_ACTION_IF_NEEDED(VEHICLE_ACCELERATE);
ClearSettingsAssociatedWithAction(VEHICLE_LOOKBEHIND, type); CLEAR_ACTION_IF_NEEDED(VEHICLE_BRAKE);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_HORN, type)) CLEAR_ACTION_IF_NEEDED(VEHICLE_CHANGE_RADIO_STATION);
ClearSettingsAssociatedWithAction(VEHICLE_HORN, type); CLEAR_ACTION_IF_NEEDED(TOGGLE_SUBMISSIONS);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, type)) CLEAR_ACTION_IF_NEEDED(VEHICLE_TURRETLEFT);
ClearSettingsAssociatedWithAction(VEHICLE_HANDBRAKE, type); CLEAR_ACTION_IF_NEEDED(VEHICLE_TURRETRIGHT);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, type)) CLEAR_ACTION_IF_NEEDED(VEHICLE_TURRETUP);
ClearSettingsAssociatedWithAction(VEHICLE_ACCELERATE, type); CLEAR_ACTION_IF_NEEDED(VEHICLE_TURRETDOWN);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, type))
ClearSettingsAssociatedWithAction(VEHICLE_BRAKE, type);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, type))
ClearSettingsAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, type);
if (key == GetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, type))
ClearSettingsAssociatedWithAction(TOGGLE_SUBMISSIONS, type);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_TURRETLEFT, type))
ClearSettingsAssociatedWithAction(VEHICLE_TURRETLEFT, type);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_TURRETRIGHT, type))
ClearSettingsAssociatedWithAction(VEHICLE_TURRETRIGHT, type);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_TURRETUP, type))
ClearSettingsAssociatedWithAction(VEHICLE_TURRETUP, type);
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_TURRETDOWN, type))
ClearSettingsAssociatedWithAction(VEHICLE_TURRETDOWN, type);
} }
} }
@ -1739,8 +1703,7 @@ void CControllerConfigManager::DeleteMatchingVehicle_3rdPersonControls(e_Control
{ {
if (!GetIsKeyBlank(key, type)) if (!GetIsKeyBlank(key, type))
{ {
if (key == GetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, type)) CLEAR_ACTION_IF_NEEDED(VEHICLE_ENTER_EXIT);
ClearSettingsAssociatedWithAction(VEHICLE_ENTER_EXIT, type);
} }
} }
@ -1748,13 +1711,13 @@ void CControllerConfigManager::DeleteMatching1rstPersonControls(e_ControllerActi
{ {
if (!GetIsKeyBlank(key, type)) if (!GetIsKeyBlank(key, type))
{ {
if (key == GetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, type)) CLEAR_ACTION_IF_NEEDED(PED_SNIPER_ZOOM_IN);
ClearSettingsAssociatedWithAction(PED_SNIPER_ZOOM_IN, type); CLEAR_ACTION_IF_NEEDED(PED_SNIPER_ZOOM_OUT);
if (key == GetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, type))
ClearSettingsAssociatedWithAction(PED_SNIPER_ZOOM_OUT, type);
} }
} }
#undef CLEAR_ACTION_IF_NEEDED
void CControllerConfigManager::DeleteMatchingActionInitiators(e_ControllerAction action, int32 key, eControllerType type) void CControllerConfigManager::DeleteMatchingActionInitiators(e_ControllerAction action, int32 key, eControllerType type)
{ {
if (!GetIsKeyBlank(key, type)) if (!GetIsKeyBlank(key, type))