bool TrySetKeyInOther(KeySettingItem itemToSet, KeyCode newKey, IKeyJoyAccessor accessor, int cur) { tmpIdx[cur] = accessor.FindInArray(mKeySettingLists[cur], newKey); if (tmpIdx[cur] < 0) { return(false); // Can not set because locked } KeyCode oldKey = accessor.Get(itemToSet); if (tmpIdx[cur] > 0) { accessor.Set(mKeySettingLists[cur][tmpIdx[cur] - 1], oldKey); } else { tmpIdx[0] = accessor.FindInArray(mKeySettingLists[0], newKey); if (tmpIdx[0] < 0) { return(false); // Can not set because locked } if (tmpIdx[0] > 0) { if (!TrySetKeyInCommon(mKeySettingLists[0][tmpIdx[0] - 1], oldKey, accessor, (-1 & ~(1 << cur)))) { return(false); } } } accessor.Set(itemToSet, newKey); return(true); }
bool TrySetKeyInCommon(KeySettingItem itemToSet, KeyCode newKey, IKeyJoyAccessor accessor, int conflictMask = -1) { tmpIdx[0] = accessor.FindInArray(mKeySettingLists[0], newKey); if (tmpIdx[0] < 0) { return(false); // Can not set because locked } KeyCode oldKey = accessor.Get(itemToSet); if (tmpIdx[0] > 0) { accessor.Set(mKeySettingLists[0][tmpIdx[0] - 1], oldKey); } else { for (int i = 1; i < 4; i++) { if (((1 << i) & conflictMask) == 0) { tmpIdx[i] = 0; continue; } tmpIdx[i] = accessor.FindInArray(mKeySettingLists[i], newKey); if (tmpIdx[i] < 0) { return(false); // Can not set because locked } } for (int i = 1; i < 4; i++) { if (tmpIdx[i] > 0) { accessor.Set(mKeySettingLists[i][tmpIdx[i] - 1], oldKey); } } } accessor.Set(itemToSet, newKey); return(true); }