fix icon
parent
ea4372e1f3
commit
5dd9e017ea
|
@ -72,19 +72,14 @@ export function swapCurrentKeys(config: InterfaceConfig, settingName, pressedBut
|
||||||
if (prevKey.key === nextKey.key) {
|
if (prevKey.key === nextKey.key) {
|
||||||
// special case when back to back and not enough info to get back to previous button
|
// special case when back to back and not enough info to get back to previous button
|
||||||
const toRestore = getKeyAndSettingNameFromCurrentKeysWithAction(config, prevKey.from.action);
|
const toRestore = getKeyAndSettingNameFromCurrentKeysWithAction(config, prevKey.from.action);
|
||||||
const iconToRestore = config.icons[toRestore.key];
|
|
||||||
config.custom[prevKey.key] = prevKey.from.action;
|
config.custom[prevKey.key] = prevKey.from.action;
|
||||||
config.icons[prevKey.key] = iconToRestore;
|
config.icons[prevKey.key] = prevKey.from.icon;
|
||||||
|
|
||||||
config.custom[toRestore.key] = prevKey.action;
|
config.custom[toRestore.key] = prevKey.action;
|
||||||
config.icons[toRestore.key] = prevKey.icon;
|
config.icons[toRestore.key] = prevKey.icon;
|
||||||
|
|
||||||
config.currentKeys[settingName].from = prevKey;
|
delete config.currentKeys[settingName].from;
|
||||||
config.currentKeys[toRestore.settingName].from = {
|
delete config.currentKeys[toRestore.settingName].from;
|
||||||
key: toRestore.key,
|
|
||||||
action: prevKey.from.action,
|
|
||||||
icon: iconToRestore,
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
config.custom[previousBind.key] = newBind.action;
|
config.custom[previousBind.key] = newBind.action;
|
||||||
config.custom[newBind.key] = previousBind.action;
|
config.custom[newBind.key] = previousBind.action;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
getKeyAndActionFromCurrentKeysWithSettingName,
|
getKeyAndActionFromCurrentKeysWithSettingName,
|
||||||
getKeyForSettingName,
|
getKeyForSettingName,
|
||||||
getKeyFromMapping,
|
getKeyFromMapping,
|
||||||
getKeyWithAction,
|
getKeyWithAction, regenerateCustom,
|
||||||
reloadCurrentKeys,
|
reloadCurrentKeys,
|
||||||
swapCurrentKeys,
|
swapCurrentKeys,
|
||||||
} from "#app/configs/gamepad-utils";
|
} from "#app/configs/gamepad-utils";
|
||||||
|
@ -183,4 +183,75 @@ describe('Test Keyboard', () => {
|
||||||
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].action).toEqual(Button.ACTION);
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].action).toEqual(Button.ACTION);
|
||||||
expect(iconB).toEqual('T_X_A_Color_Alt.png');
|
expect(iconB).toEqual('T_X_A_Color_Alt.png');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Check 4 swap back to back', () => {
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].key).toEqual("RC_S");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].action).toEqual(Button.ACTION);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].icon).toEqual('T_X_A_Color_Alt.png');
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].key).toEqual("RC_E");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].action).toEqual(Button.CANCEL);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].icon).toEqual('T_X_B_Color_Alt.png');
|
||||||
|
swapCurrentKeys(config, SettingInterfaceGamepad.Button_Action, 1); // cancel
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].key).toEqual("RC_S");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].action).toEqual(Button.CANCEL);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].icon).toEqual('T_X_B_Color_Alt.png');
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].key).toEqual("RC_E");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].action).toEqual(Button.ACTION);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].icon).toEqual('T_X_A_Color_Alt.png');
|
||||||
|
|
||||||
|
swapCurrentKeys(config, SettingInterfaceGamepad.Button_Action, 0); // cancel
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].key).toEqual("RC_S");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].action).toEqual(Button.ACTION);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].icon).toEqual('T_X_A_Color_Alt.png');
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].key).toEqual("RC_E");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].action).toEqual(Button.CANCEL);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].icon).toEqual('T_X_B_Color_Alt.png');
|
||||||
|
|
||||||
|
swapCurrentKeys(config, SettingInterfaceGamepad.Button_Action, 1); // cancel
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].key).toEqual("RC_S");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].action).toEqual(Button.CANCEL);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].icon).toEqual('T_X_B_Color_Alt.png');
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].key).toEqual("RC_E");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].action).toEqual(Button.ACTION);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].icon).toEqual('T_X_A_Color_Alt.png');
|
||||||
|
|
||||||
|
swapCurrentKeys(config, SettingInterfaceGamepad.Button_Action, 0); // cancel
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].key).toEqual("RC_S");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].action).toEqual(Button.ACTION);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].icon).toEqual('T_X_A_Color_Alt.png');
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].key).toEqual("RC_E");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].action).toEqual(Button.CANCEL);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].icon).toEqual('T_X_B_Color_Alt.png');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Custom scenario: B icon duplicate', () => {
|
||||||
|
config.currentKeys[SettingInterfaceGamepad.Button_Action] = {
|
||||||
|
"key": "RC_S",
|
||||||
|
"action": 6,
|
||||||
|
"icon": "T_X_B_Color_Alt.png",
|
||||||
|
"from": {
|
||||||
|
"key": "RC_S",
|
||||||
|
"action": 5,
|
||||||
|
"icon": "T_X_A_Color_Alt.png"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
config.currentKeys[SettingInterfaceGamepad.Button_Cancel] = {
|
||||||
|
"key": "RC_E",
|
||||||
|
"action": 5,
|
||||||
|
"icon": "T_X_A_Color_Alt.png",
|
||||||
|
"from": {
|
||||||
|
"key": "RC_E",
|
||||||
|
"action": 6,
|
||||||
|
"icon": "T_X_B_Color_Alt.png"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
regenerateCustom(config);
|
||||||
|
swapCurrentKeys(config, SettingInterfaceGamepad.Button_Action, 0); // cancel
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].key).toEqual("RC_S");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].action).toEqual(Button.ACTION);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Action].icon).toEqual('T_X_A_Color_Alt.png');
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].key).toEqual("RC_E");
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].action).toEqual(Button.CANCEL);
|
||||||
|
expect(config.currentKeys[SettingInterfaceGamepad.Button_Cancel].icon).toEqual('T_X_B_Color_Alt.png');
|
||||||
|
})
|
||||||
});
|
});
|
Loading…
Reference in New Issue