mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-17 05:42:18 +02:00
Refactor/assign instead swap (#2)
* tests updated * adjust the code to use assign instead of swap for the keyboard mapping
This commit is contained in:
parent
e8b6e588a5
commit
e1be1a3f82
@ -276,8 +276,6 @@ const cfg_keyboard_azerty = {
|
|||||||
KEY_SEMICOLON: -1,
|
KEY_SEMICOLON: -1,
|
||||||
KEY_ALT: -1
|
KEY_ALT: -1
|
||||||
},
|
},
|
||||||
main: [],
|
|
||||||
alt: [],
|
|
||||||
blacklist: [
|
blacklist: [
|
||||||
"KEY_ENTER",
|
"KEY_ENTER",
|
||||||
"KEY_ESC",
|
"KEY_ESC",
|
||||||
|
@ -80,34 +80,6 @@ export function getIconWithKey(config, key) {
|
|||||||
return config.icons[key];
|
return config.icons[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the icon for a special case where a key is bound to a different type of binding.
|
|
||||||
* This special case occurs when attempting to bind a key from either a main or alternate binding
|
|
||||||
* to a different type of binding, resulting in two main or two alternate bindings having the same action.
|
|
||||||
* In such cases, the two bindings are swapped to maintain uniqueness.
|
|
||||||
*
|
|
||||||
* @param config - The configuration object containing icons.
|
|
||||||
* @param keycode - The keycode to search for.
|
|
||||||
* @param settingName - The setting name to search for.
|
|
||||||
* @returns The icon associated with the special case or null if not found.
|
|
||||||
*/
|
|
||||||
export function getIconSpecialCase(config, keycode, settingName) {
|
|
||||||
const potentialKey = getKeySolvingConflict(config, keycode, settingName);
|
|
||||||
if (potentialKey) return getIconWithKey(config, potentialKey);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the button associated with the specified setting name.
|
|
||||||
*
|
|
||||||
* @param config - The configuration object containing settings.
|
|
||||||
* @param settingName - The setting name to search for.
|
|
||||||
* @returns The button associated with the specified setting name.
|
|
||||||
*/
|
|
||||||
export function getButtonWithSettingName(config, settingName) {
|
|
||||||
return config.settings[settingName];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the icon associated with the specified setting name.
|
* Retrieves the icon associated with the specified setting name.
|
||||||
*
|
*
|
||||||
@ -144,76 +116,11 @@ export function getSettingNameWithButton(config, button, alt = false) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export function assign(config, settingNameTarget, keycode): boolean {
|
||||||
* Retrieves the key associated with the specified button.
|
|
||||||
*
|
|
||||||
* @param config - The configuration object containing custom settings.
|
|
||||||
* @param button - The button to search for.
|
|
||||||
* @param alt - A flag indicating if the search is for an alternate setting.
|
|
||||||
* @returns The key associated with the specified button.
|
|
||||||
*/
|
|
||||||
export function getKeyWithButton(config, button, alt = false) {
|
|
||||||
const settingName = getSettingNameWithButton(config, button, alt);
|
|
||||||
return getKeyWithSettingName(config, settingName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identifies a key that resolves a binding conflict when attempting to bind a keycode to a specified setting name target.
|
|
||||||
* This function checks if the keycode is already bound to a different type of binding (main or alternate) and returns
|
|
||||||
* the conflicting key if found.
|
|
||||||
*
|
|
||||||
* @param config - The configuration object containing custom settings.
|
|
||||||
* @param keycode - The keycode to check.
|
|
||||||
* @param settingNameTarget - The setting name target to bind.
|
|
||||||
* @returns The conflicting key if found, or null if no conflict is found.
|
|
||||||
*/
|
|
||||||
export function getKeySolvingConflict(config, keycode, settingNameTarget) {
|
|
||||||
const key = getKeyWithKeycode(config, keycode);
|
|
||||||
const isMain = config.main.includes(key);
|
|
||||||
|
|
||||||
const isTargetMain = !settingNameTarget.includes("ALT_");
|
|
||||||
const potentialExistingButton = getButtonWithSettingName(config, settingNameTarget);
|
|
||||||
const potentialExistingKey = getKeyWithButton(config, potentialExistingButton, !isMain);
|
|
||||||
|
|
||||||
if (potentialExistingKey && isMain !== isTargetMain) return potentialExistingKey;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Swaps the binding of a keycode with the specified setting name target.
|
|
||||||
* If the target setting is deleted, it directly binds the keycode to the target setting.
|
|
||||||
* Otherwise, it handles any potential conflicts by swapping the bindings.
|
|
||||||
*
|
|
||||||
* @param config - The configuration object containing custom settings.
|
|
||||||
* @param settingNameTarget - The setting name target to swap.
|
|
||||||
* @param keycode - The keycode to swap.
|
|
||||||
*/
|
|
||||||
export function swap(config, settingNameTarget, keycode) {
|
|
||||||
// Check if the setting name target is already deleted (i.e., not bound to any key).
|
|
||||||
const isDeleted = !getKeyWithSettingName(config, settingNameTarget);
|
|
||||||
// If the setting name target is deleted, bind the new key to the setting name target and return.
|
|
||||||
if (isDeleted) {
|
|
||||||
const new_key = getKeyWithKeycode(config, keycode);
|
|
||||||
config.custom[new_key] = settingNameTarget;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Check for any potential conflict with existing bindings.
|
|
||||||
const potentialExistingKey = getKeySolvingConflict(config, keycode, settingNameTarget);
|
|
||||||
|
|
||||||
const prev_key = potentialExistingKey || getKeyWithSettingName(config, settingNameTarget);
|
|
||||||
const prev_settingName = getSettingNameWithKey(config, prev_key);
|
|
||||||
|
|
||||||
const new_key = getKeyWithKeycode(config, keycode);
|
|
||||||
const new_settingName = getSettingNameWithKey(config, new_key);
|
|
||||||
|
|
||||||
config.custom[prev_key] = new_settingName;
|
|
||||||
config.custom[new_key] = prev_settingName;
|
|
||||||
regenerateIdentifiers(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function assign(config, settingNameTarget, keycode) {
|
|
||||||
// first, we need to check if this keycode is already used on another settingName
|
// first, we need to check if this keycode is already used on another settingName
|
||||||
const previousSettingName = getSettingNameWithKeycode(config, keycode);
|
const previousSettingName = getSettingNameWithKeycode(config, keycode);
|
||||||
|
const key = getKeyWithSettingName(config, previousSettingName);
|
||||||
|
if (!canIAssignThisKey(config, key)) return false;
|
||||||
// if it was already bound, we delete the bind
|
// if it was already bound, we delete the bind
|
||||||
if (previousSettingName) {
|
if (previousSettingName) {
|
||||||
const previousKey = getKeyWithSettingName(config, previousSettingName);
|
const previousKey = getKeyWithSettingName(config, previousSettingName);
|
||||||
@ -226,6 +133,20 @@ export function assign(config, settingNameTarget, keycode) {
|
|||||||
// then, the new key is assigned to the new settingName
|
// then, the new key is assigned to the new settingName
|
||||||
const newKey = getKeyWithKeycode(config, keycode);
|
const newKey = getKeyWithKeycode(config, keycode);
|
||||||
config.custom[newKey] = settingNameTarget;
|
config.custom[newKey] = settingNameTarget;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function swap(config, settingNameTarget, keycode) {
|
||||||
|
// only for gamepad
|
||||||
|
if (config.padType === 'keyboard') return false;
|
||||||
|
const prev_key = getKeyWithSettingName(config, settingNameTarget);
|
||||||
|
const prev_settingName = getSettingNameWithKey(config, prev_key);
|
||||||
|
|
||||||
|
const new_key = getKeyWithKeycode(config, keycode);
|
||||||
|
const new_settingName = getSettingNameWithKey(config, new_key);
|
||||||
|
|
||||||
|
config.custom[prev_key] = new_settingName;
|
||||||
|
config.custom[new_key] = prev_settingName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,23 +157,24 @@ export function assign(config, settingNameTarget, keycode) {
|
|||||||
*/
|
*/
|
||||||
export function deleteBind(config, settingName) {
|
export function deleteBind(config, settingName) {
|
||||||
const key = getKeyWithSettingName(config, settingName);
|
const key = getKeyWithSettingName(config, settingName);
|
||||||
|
if (config.blacklist.includes(key) || isTheLatestBind(config, settingName)) return false;
|
||||||
config.custom[key] = -1;
|
config.custom[key] = -1;
|
||||||
regenerateIdentifiers(config);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export function canIAssignThisKey(config, key) {
|
||||||
* Deletes the binding of the specified setting name. but prevent the deletion of keys in the blacklist
|
const settingName = getSettingNameWithKey(config, key);
|
||||||
*
|
if (settingName === -1) return true;
|
||||||
* @param config - The configuration object containing custom settings.
|
if (config.blacklist?.includes(key) || isTheLatestBind(config, settingName)) return false;
|
||||||
* @param settingName - The setting name to delete.
|
return true;
|
||||||
*/
|
}
|
||||||
export function safeDeleteBind(config, settingName) {
|
|
||||||
const key = getKeyWithSettingName(config, settingName);
|
export function canIDeleteThisKey(config, key) {
|
||||||
if (config.blacklist.includes(key) || isTheLatestBind(config, settingName)) return;
|
return canIAssignThisKey(config, key);
|
||||||
config.custom[key] = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isTheLatestBind(config, settingName) {
|
export function isTheLatestBind(config, settingName) {
|
||||||
|
if (config.padType !== 'keyboard') return false;
|
||||||
const isAlt = settingName.includes("ALT_");
|
const isAlt = settingName.includes("ALT_");
|
||||||
let altSettingName;
|
let altSettingName;
|
||||||
if (isAlt)
|
if (isAlt)
|
||||||
@ -261,22 +183,4 @@ export function isTheLatestBind(config, settingName) {
|
|||||||
altSettingName = `ALT_${settingName}`;
|
altSettingName = `ALT_${settingName}`;
|
||||||
const secondButton = getKeyWithSettingName(config, altSettingName);
|
const secondButton = getKeyWithSettingName(config, altSettingName);
|
||||||
return secondButton === undefined;
|
return secondButton === undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Regenerates the identifiers for main and alternate settings.
|
|
||||||
* This allows distinguishing between main and alternate bindings.
|
|
||||||
*
|
|
||||||
* @param config - The configuration object containing custom settings.
|
|
||||||
*/
|
|
||||||
export function regenerateIdentifiers(config) {
|
|
||||||
config.main = Object.keys(config.custom).filter(key => {
|
|
||||||
const value = config.custom[key];
|
|
||||||
return value !== -1 && !value.includes("ALT_");
|
|
||||||
});
|
|
||||||
|
|
||||||
config.alt = Object.keys(config.custom).filter(key => {
|
|
||||||
const value = config.custom[key];
|
|
||||||
return value !== -1 && value.includes("ALT_");
|
|
||||||
});
|
|
||||||
}
|
|
@ -83,8 +83,6 @@ const pad_dualshock = {
|
|||||||
RS: SettingGamepad.Button_Slow_Down,
|
RS: SettingGamepad.Button_Slow_Down,
|
||||||
TOUCH: SettingGamepad.Button_Submit,
|
TOUCH: SettingGamepad.Button_Submit,
|
||||||
},
|
},
|
||||||
main: [],
|
|
||||||
alt: [],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default pad_dualshock;
|
export default pad_dualshock;
|
||||||
|
@ -79,8 +79,6 @@ const pad_generic = {
|
|||||||
LS: SettingGamepad.Button_Speed_Up,
|
LS: SettingGamepad.Button_Speed_Up,
|
||||||
RS: SettingGamepad.Button_Slow_Down
|
RS: SettingGamepad.Button_Slow_Down
|
||||||
},
|
},
|
||||||
main: [],
|
|
||||||
alt: [],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default pad_generic;
|
export default pad_generic;
|
||||||
|
@ -71,8 +71,6 @@ const pad_unlicensedSNES = {
|
|||||||
LS: -1,
|
LS: -1,
|
||||||
RS: -1
|
RS: -1
|
||||||
},
|
},
|
||||||
main: [],
|
|
||||||
alt: [],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default pad_unlicensedSNES;
|
export default pad_unlicensedSNES;
|
||||||
|
@ -79,8 +79,6 @@ const pad_xbox360 = {
|
|||||||
LS: SettingGamepad.Button_Speed_Up,
|
LS: SettingGamepad.Button_Speed_Up,
|
||||||
RS: SettingGamepad.Button_Slow_Down
|
RS: SettingGamepad.Button_Slow_Down
|
||||||
},
|
},
|
||||||
main: [],
|
|
||||||
alt: [],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default pad_xbox360;
|
export default pad_xbox360;
|
||||||
|
@ -11,7 +11,11 @@ import SettingsGamepadUiHandler from "./ui/settings/settings-gamepad-ui-handler"
|
|||||||
import SettingsKeyboardUiHandler from "./ui/settings/settings-keyboard-ui-handler";
|
import SettingsKeyboardUiHandler from "./ui/settings/settings-keyboard-ui-handler";
|
||||||
import cfg_keyboard_azerty from "./configs/cfg_keyboard_azerty";
|
import cfg_keyboard_azerty from "./configs/cfg_keyboard_azerty";
|
||||||
import {Device} from "#app/enums/devices";
|
import {Device} from "#app/enums/devices";
|
||||||
import {getButtonWithKeycode, getIconForLatestInput, regenerateIdentifiers, swap} from "#app/configs/configHandler";
|
import {
|
||||||
|
assign,
|
||||||
|
getButtonWithKeycode,
|
||||||
|
getIconForLatestInput, swap,
|
||||||
|
} from "#app/configs/configHandler";
|
||||||
|
|
||||||
export interface DeviceMapping {
|
export interface DeviceMapping {
|
||||||
[key: string]: number;
|
[key: string]: number;
|
||||||
@ -685,9 +689,6 @@ export class InputsController {
|
|||||||
injectConfig(selectedDevice: string, mappingConfigs): void {
|
injectConfig(selectedDevice: string, mappingConfigs): void {
|
||||||
if (!this.configs[selectedDevice]) this.configs[selectedDevice] = {};
|
if (!this.configs[selectedDevice]) this.configs[selectedDevice] = {};
|
||||||
this.configs[selectedDevice].custom = mappingConfigs.custom;
|
this.configs[selectedDevice].custom = mappingConfigs.custom;
|
||||||
this.configs[selectedDevice].main = mappingConfigs.main;
|
|
||||||
this.configs[selectedDevice].alt = mappingConfigs.alt;
|
|
||||||
regenerateIdentifiers(this.configs[selectedDevice]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -697,9 +698,11 @@ export class InputsController {
|
|||||||
* @param settingName The name of the setting to swap.
|
* @param settingName The name of the setting to swap.
|
||||||
* @param pressedButton The button that was pressed.
|
* @param pressedButton The button that was pressed.
|
||||||
*/
|
*/
|
||||||
swapBinding(config, settingName, pressedButton): void {
|
assignBinding(config, settingName, pressedButton): boolean {
|
||||||
this.pauseUpdate = true;
|
this.pauseUpdate = true;
|
||||||
swap(config, settingName, pressedButton);
|
|
||||||
setTimeout(() => this.pauseUpdate = false, 500);
|
setTimeout(() => this.pauseUpdate = false, 500);
|
||||||
|
if (config.padType === 'keyboard')
|
||||||
|
return assign(config, settingName, pressedButton);
|
||||||
|
else return swap(config, settingName, pressedButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -65,6 +65,7 @@ export class InGameManip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
weShouldTriggerTheButton(settingName) {
|
weShouldTriggerTheButton(settingName) {
|
||||||
|
if (!settingName.includes("Button_")) settingName = "Button_" + settingName;
|
||||||
this.settingName = SettingInterface[this.normalizeSettingNameString(settingName)];
|
this.settingName = SettingInterface[this.normalizeSettingNameString(settingName)];
|
||||||
expect(getSettingNameWithKeycode(this.config, this.keycode)).toEqual(this.settingName);
|
expect(getSettingNameWithKeycode(this.config, this.keycode)).toEqual(this.settingName);
|
||||||
return this;
|
return this;
|
||||||
|
@ -3,10 +3,12 @@ import {expect} from "vitest";
|
|||||||
import {Button} from "#app/enums/buttons";
|
import {Button} from "#app/enums/buttons";
|
||||||
import {
|
import {
|
||||||
deleteBind,
|
deleteBind,
|
||||||
getIconWithKey,
|
|
||||||
getIconWithKeycode,
|
getIconWithKeycode,
|
||||||
getIconWithSettingName,
|
getIconWithSettingName,
|
||||||
getKeyWithKeycode, getKeyWithSettingName, getKeySolvingConflict, swap, assign, safeDeleteBind
|
getKeyWithKeycode,
|
||||||
|
getKeyWithSettingName,
|
||||||
|
assign,
|
||||||
|
getSettingNameWithKeycode, canIAssignThisKey, canIDeleteThisKey
|
||||||
} from "#app/configs/configHandler";
|
} from "#app/configs/configHandler";
|
||||||
|
|
||||||
export class MenuManip {
|
export class MenuManip {
|
||||||
@ -51,6 +53,7 @@ export class MenuManip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
iconDisplayedIs(icon) {
|
iconDisplayedIs(icon) {
|
||||||
|
if (!(icon.toUpperCase().includes("KEY_"))) icon = "KEY_" + icon.toUpperCase();
|
||||||
this.iconDisplayed = this.config.icons[icon];
|
this.iconDisplayed = this.config.icons[icon];
|
||||||
expect(getIconWithSettingName(this.config, this.settingName)).toEqual(this.iconDisplayed);
|
expect(getIconWithSettingName(this.config, this.settingName)).toEqual(this.iconDisplayed);
|
||||||
return this;
|
return this;
|
||||||
@ -66,6 +69,12 @@ export class MenuManip {
|
|||||||
return this.thereShouldBeNoIconAnymore();
|
return this.thereShouldBeNoIconAnymore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nothingShouldHappen() {
|
||||||
|
const settingName = getSettingNameWithKeycode(this.config, this.keycode);
|
||||||
|
expect(settingName).toEqual(-1);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
weWantThisBindInstead(keycode) {
|
weWantThisBindInstead(keycode) {
|
||||||
this.keycode = Phaser.Input.Keyboard.KeyCodes[keycode];
|
this.keycode = Phaser.Input.Keyboard.KeyCodes[keycode];
|
||||||
const icon = getIconWithKeycode(this.config, this.keycode);
|
const icon = getIconWithKeycode(this.config, this.keycode);
|
||||||
@ -76,25 +85,17 @@ export class MenuManip {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
OopsSpecialCaseIcon(icon) {
|
|
||||||
this.specialCaseIcon = this.config.icons[icon];
|
|
||||||
const potentialExistingKey = getKeySolvingConflict(this.config, this.keycode, this.settingName);
|
|
||||||
const prev_key = potentialExistingKey || getKeyWithSettingName(this.config, this.settingName);
|
|
||||||
expect(getIconWithKey(this.config, prev_key)).toEqual(this.specialCaseIcon);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
whenWeDelete(settingName?: string) {
|
whenWeDelete(settingName?: string) {
|
||||||
this.settingName = SettingInterface[settingName] || this.settingName;
|
this.settingName = SettingInterface[settingName] || this.settingName;
|
||||||
const key = getKeyWithSettingName(this.config, this.settingName);
|
const key = getKeyWithSettingName(this.config, this.settingName);
|
||||||
deleteBind(this.config, this.settingName);
|
deleteBind(this.config, this.settingName);
|
||||||
expect(this.config.custom[key]).toEqual(-1);
|
// expect(this.config.custom[key]).toEqual(-1);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
whenWeTryToDelete(settingName?: string) {
|
whenWeTryToDelete(settingName?: string) {
|
||||||
this.settingName = SettingInterface[settingName] || this.settingName;
|
this.settingName = SettingInterface[settingName] || this.settingName;
|
||||||
safeDeleteBind(this.config, this.settingName);
|
deleteBind(this.config, this.settingName);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +103,24 @@ export class MenuManip {
|
|||||||
assign(this.config, this.settingName, this.keycode);
|
assign(this.config, this.settingName, this.keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
butLetsForceIt() {
|
||||||
|
this.confirm();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
swap(this.config, this.settingName, this.keycode);
|
assign(this.config, this.settingName, this.keycode);
|
||||||
|
}
|
||||||
|
|
||||||
|
weCantConfirm() {
|
||||||
|
const key = getKeyWithKeycode(this.config, this.keycode);
|
||||||
|
expect(canIAssignThisKey(this.config, key)).toEqual(false);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
weCantDelete() {
|
||||||
|
const key = getKeyWithSettingName(this.config, this.settingName);
|
||||||
|
expect(canIDeleteThisKey(this.config, key)).toEqual(false);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,8 @@ import {SettingInterface} from "#app/test/cfg_keyboard.example";
|
|||||||
import {Button} from "#app/enums/buttons";
|
import {Button} from "#app/enums/buttons";
|
||||||
import {deepCopy} from "#app/utils";
|
import {deepCopy} from "#app/utils";
|
||||||
import {
|
import {
|
||||||
getButtonWithSettingName,
|
|
||||||
getIconWithSettingName,
|
|
||||||
getKeyWithKeycode,
|
getKeyWithKeycode,
|
||||||
getKeyWithSettingName,
|
getKeyWithSettingName,
|
||||||
getSettingNameWithKeycode,
|
|
||||||
regenerateIdentifiers,
|
|
||||||
swap
|
|
||||||
} from "#app/configs/configHandler";
|
} from "#app/configs/configHandler";
|
||||||
import {MenuManip} from "#app/test/helpers/menuManip";
|
import {MenuManip} from "#app/test/helpers/menuManip";
|
||||||
import {InGameManip} from "#app/test/helpers/inGameManip";
|
import {InGameManip} from "#app/test/helpers/inGameManip";
|
||||||
@ -31,7 +26,6 @@ describe('Test Rebinding', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
config = deepCopy(cfg_keyboard_azerty);
|
config = deepCopy(cfg_keyboard_azerty);
|
||||||
config.custom = {...config.default}
|
config.custom = {...config.default}
|
||||||
regenerateIdentifiers(config);
|
|
||||||
configs.default = config;
|
configs.default = config;
|
||||||
inGame = new InGameManip(configs, config, selectedDevice);
|
inGame = new InGameManip(configs, config, selectedDevice);
|
||||||
inTheSettingMenu = new MenuManip(config);
|
inTheSettingMenu = new MenuManip(config);
|
||||||
@ -97,85 +91,137 @@ describe('Test Rebinding', () => {
|
|||||||
const icon = config.icons[key];
|
const icon = config.icons[key];
|
||||||
expect(icon).toEqual('T_Q_Key_Dark.png');
|
expect(icon).toEqual('T_Q_Key_Dark.png');
|
||||||
});
|
});
|
||||||
it('Check if is working', () => {
|
|
||||||
const settingNameA = SettingInterface.Button_Left;
|
it('Check if is working', () => {
|
||||||
const settingNameB = SettingInterface.Button_Right;
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("Q")
|
||||||
swap(config, SettingInterface.Button_Left, Phaser.Input.Keyboard.KeyCodes.RIGHT);
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Right").iconDisplayedIs("D")
|
||||||
expect(getButtonWithSettingName(config, settingNameA)).toEqual(Button.LEFT);
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("Q").weWantThisBindInstead("D").confirm();
|
||||||
expect(getSettingNameWithKeycode(config, Phaser.Input.Keyboard.KeyCodes.RIGHT)).toEqual(SettingInterface.Button_Left)
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
expect(getButtonWithSettingName(config, settingNameB)).toEqual(Button.RIGHT);
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
expect(getSettingNameWithKeycode(config, Phaser.Input.Keyboard.KeyCodes.LEFT)).toEqual(SettingInterface.Button_Right)
|
|
||||||
expect(getIconWithSettingName(config, settingNameA)).toEqual(config.icons.KEY_ARROW_RIGHT);
|
|
||||||
expect(getIconWithSettingName(config, settingNameB)).toEqual(config.icons.KEY_ARROW_LEFT);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check if double swap is working', () => {
|
it('Check prevent rebind indirectly the d-pad buttons', () => {
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("Q")
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Right").iconDisplayedIs("D")
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("Q").weWantThisBindInstead("LEFT").weCantConfirm().butLetsForceIt();
|
||||||
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Left");
|
||||||
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Check if double assign d-pad is blocked', () => {
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").weCantConfirm().butLetsForceIt();
|
||||||
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_RIGHT").weWantThisBindInstead("UP").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("UP").weCantConfirm().butLetsForceIt();
|
||||||
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_UP").weWantThisBindInstead("RIGHT").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").weCantConfirm().butLetsForceIt();
|
||||||
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Check if double assign is working', () => {
|
||||||
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
|
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_Q").weWantThisBindInstead("D").confirm();
|
||||||
|
|
||||||
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
|
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_D").weWantThisBindInstead("Z").confirm();
|
||||||
|
|
||||||
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("D").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_Z").weWantThisBindInstead("D").confirm();
|
||||||
|
|
||||||
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("Z").nothingShouldHappen();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Check if triple swap d-pad is prevented', () => {
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").weCantConfirm().butLetsForceIt();
|
||||||
|
|
||||||
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
|
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Right").iconDisplayedIs("KEY_ARROW_RIGHT").weWantThisBindInstead("UP").weCantConfirm().butLetsForceIt();
|
||||||
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
|
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("LEFT").weCantConfirm().butLetsForceIt();
|
||||||
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Check if triple swap is working', () => {
|
it('Check if triple swap is working', () => {
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").confirm();
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Right");
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_Q").weWantThisBindInstead("D").confirm();
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Right").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("UP").confirm();
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Right");
|
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_RIGHT").weWantThisBindInstead("LEFT").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Right").thereShouldBeNoIcon().weWantThisBindInstead("Z").confirm();
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
|
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_D").weWantThisBindInstead("Q").confirm();
|
||||||
|
|
||||||
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("D").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Swap alt with another main', () => {
|
it('Swap alt with a main', () => {
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("R").weShouldTriggerTheButton("Cycle_Shiny");
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
inTheSettingMenu.whenCursorIsOnSetting("Cycle_Shiny").iconDisplayedIs("KEY_R").weWantThisBindInstead("D").confirm();
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("D").OopsSpecialCaseIcon("KEY_Q").confirm();
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Cycle_Shiny");
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left");
|
inGame.whenWePressOnKeyboard("R").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Right");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('multiple Swap alt with another main', () => {
|
it('multiple Swap alt with another main', () => {
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("R").weShouldTriggerTheButton("Button_Cycle_Shiny");
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("F").weShouldTriggerTheButton("Button_Cycle_Form");
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("D").OopsSpecialCaseIcon("KEY_Q").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Shiny").iconDisplayedIs("KEY_R").weWantThisBindInstead("D").confirm();
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny");
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("R").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Right");
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("F").weShouldTriggerTheButton("Button_Cycle_Form");
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Up").iconDisplayedIs("KEY_ARROW_UP").weWantThisBindInstead("LEFT").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Form").iconDisplayedIs("KEY_F").weWantThisBindInstead("R").confirm();
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny");
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("R").weShouldTriggerTheButton("Button_Cycle_Form");
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Right");
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("F").nothingShouldHappen();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Swap alt with a key not binded yet', () => {
|
it('Swap alt with a key not binded yet', () => {
|
||||||
@ -184,84 +230,96 @@ describe('Test Rebinding', () => {
|
|||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_Z").weWantThisBindInstead("B").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_Z").weWantThisBindInstead("B").confirm();
|
||||||
inGame.whenWePressOnKeyboard("Z").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("Z").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Up");
|
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Delete blacklisted bind', () => {
|
||||||
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
|
inTheSettingMenu.whenWeDelete("Button_Left").weCantDelete().iconDisplayedIs("KEY_ARROW_LEFT");
|
||||||
|
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Delete bind', () => {
|
it('Delete bind', () => {
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inTheSettingMenu.whenWeDelete("Button_Left").thereShouldBeNoIconAnymore();
|
inTheSettingMenu.whenWeDelete("Alt_Button_Left").thereShouldBeNoIconAnymore();
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Delete bind then assign a not yet binded button', () => {
|
it('Delete bind then assign a not yet binded button', () => {
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
inTheSettingMenu.whenWeDelete("Alt_Button_Left").thereShouldBeNoIconAnymore();
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
||||||
inTheSettingMenu.whenWeDelete("Button_Left").thereShouldBeNoIconAnymore();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("B").confirm();
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("B").confirm();
|
|
||||||
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Delete bind then assign a not yet binded button', () => {
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
|
||||||
inTheSettingMenu.whenWeDelete("Button_Left").thereShouldBeNoIconAnymore();
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("RIGHT").confirm();
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('swap 2 bind, than delete 1 bind than assign another bind', () => {
|
it('swap 2 bind, than delete 1 bind than assign another bind', () => {
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
inGame.whenWePressOnKeyboard("R").weShouldTriggerTheButton("Button_Cycle_Shiny");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("F").weShouldTriggerTheButton("Button_Cycle_Form");
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").confirm();
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Left");
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Shiny").iconDisplayedIs("KEY_R").weWantThisBindInstead("D").confirm();
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").whenWeDelete().thereShouldBeNoIconAnymore();
|
inGame.whenWePressOnKeyboard("R").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("F").weShouldTriggerTheButton("Button_Cycle_Form");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_Z").weWantThisBindInstead("B").confirm();
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny");
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Right");
|
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").nothingShouldHappen();
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Form").iconDisplayedIs("KEY_F").weWantThisBindInstead("Z").confirm();
|
||||||
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Up");
|
inGame.whenWePressOnKeyboard("R").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("F").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Button_Cycle_Form");
|
||||||
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny");
|
||||||
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
|
||||||
|
inTheSettingMenu.whenWeDelete("Alt_Button_Left").thereShouldBeNoIconAnymore();
|
||||||
|
inGame.whenWePressOnKeyboard("R").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("F").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Button_Cycle_Form");
|
||||||
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny");
|
||||||
|
inGame.whenWePressOnKeyboard("S").weShouldTriggerTheButton("Alt_Button_Down");
|
||||||
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
||||||
|
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Down").iconDisplayedIs("KEY_S").weWantThisBindInstead("B").confirm();
|
||||||
|
inGame.whenWePressOnKeyboard("R").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("F").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Button_Cycle_Form");
|
||||||
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny");
|
||||||
|
inGame.whenWePressOnKeyboard("S").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Down");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Delete bind then assign not already existing button', () => {
|
it('Delete bind then assign not already existing button', () => {
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
||||||
inTheSettingMenu.whenWeDelete("Button_Left").thereShouldBeNoIconAnymore();
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
inTheSettingMenu.whenWeDelete("Alt_Button_Left").thereShouldBeNoIconAnymore();
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("L").confirm();
|
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("L").weShouldTriggerTheButton("Button_Left");
|
|
||||||
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("B").confirm();
|
||||||
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('change alt bind to not already existing button, than another one alt bind with another not already existing button', () => {
|
it('change alt bind to not already existing button, than another one alt bind with another not already existing button', () => {
|
||||||
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("S").weShouldTriggerTheButton("Alt_Button_Down");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("T").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_Z").weWantThisBindInstead("T").confirm();
|
|
||||||
inGame.whenWePressOnKeyboard("T").weShouldTriggerTheButton("Alt_Button_Up");
|
|
||||||
inGame.whenWePressOnKeyboard("Z").nothingShouldHappen();
|
|
||||||
inGame.whenWePressOnKeyboard("U").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("U").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("S").weShouldTriggerTheButton("Alt_Button_Down");
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_Q").weWantThisBindInstead("B").confirm();
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Down").iconDisplayedIs("KEY_S").weWantThisBindInstead("U").confirm();
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("T").weShouldTriggerTheButton("Alt_Button_Up");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("Z").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("U").weShouldTriggerTheButton("Alt_Button_Down");
|
inGame.whenWePressOnKeyboard("U").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("S").nothingShouldHappen();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Right").iconDisplayedIs("KEY_D").weWantThisBindInstead("U").confirm();
|
||||||
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("D").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
|
inGame.whenWePressOnKeyboard("U").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Swap multiple touch alt and main', () => {
|
it('Swap multiple touch alt and main', () => {
|
||||||
@ -269,45 +327,40 @@ describe('Test Rebinding', () => {
|
|||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Up").iconDisplayedIs("KEY_ARROW_UP").weWantThisBindInstead("RIGHT").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Up").iconDisplayedIs("KEY_ARROW_UP").weWantThisBindInstead("RIGHT").weCantConfirm().butLetsForceIt();
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_Z").weWantThisBindInstead("D").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_Z").weWantThisBindInstead("D").confirm();
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Right");
|
inGame.whenWePressOnKeyboard("Z").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Up");
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_D").weWantThisBindInstead("Z").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_D").weWantThisBindInstead("Z").confirm();
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
inGame.whenWePressOnKeyboard("Z").weShouldTriggerTheButton("Alt_Button_Up");
|
||||||
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
inGame.whenWePressOnKeyboard("D").nothingShouldHappen();
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Delete 2 bind then reassign one of them', () => {
|
it('Delete 2 bind then reassign one of them', () => {
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
|
||||||
|
|
||||||
inTheSettingMenu.whenWeDelete("Button_Left").thereShouldBeNoIconAnymore();
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
|
|
||||||
inTheSettingMenu.whenWeDelete("Alt_Button_Left").thereShouldBeNoIconAnymore();
|
inTheSettingMenu.whenWeDelete("Alt_Button_Left").thereShouldBeNoIconAnymore();
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
|
||||||
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right");
|
||||||
|
|
||||||
|
inTheSettingMenu.whenWeDelete("Alt_Button_Right").thereShouldBeNoIconAnymore();
|
||||||
|
inGame.whenWePressOnKeyboard("Q").nothingShouldHappen();
|
||||||
|
inGame.whenWePressOnKeyboard("D").nothingShouldHappen();
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("Q").confirm();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("Q").confirm();
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
|
||||||
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
inGame.whenWePressOnKeyboard("Q").weShouldTriggerTheButton("Alt_Button_Left");
|
||||||
inGame.whenWePressOnKeyboard("B").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("D").nothingShouldHappen();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("test keyboard listener", () => {
|
it("test keyboard listener", () => {
|
||||||
@ -317,6 +370,7 @@ describe('Test Rebinding', () => {
|
|||||||
const buttonDown = config.settings[settingName];
|
const buttonDown = config.settings[settingName];
|
||||||
expect(buttonDown).toEqual(Button.DOWN);
|
expect(buttonDown).toEqual(Button.DOWN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("retrieve the correct icon for a given source", () => {
|
it("retrieve the correct icon for a given source", () => {
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Cycle_Shiny").iconDisplayedIs("KEY_R");
|
inTheSettingMenu.whenCursorIsOnSetting("Cycle_Shiny").iconDisplayedIs("KEY_R");
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Cycle_Form").iconDisplayedIs("KEY_F");
|
inTheSettingMenu.whenCursorIsOnSetting("Cycle_Form").iconDisplayedIs("KEY_F");
|
||||||
@ -324,17 +378,6 @@ describe('Test Rebinding', () => {
|
|||||||
inGame.forTheSource("keyboard").forTheWantedBind("Cycle_Form").weShouldSeeTheIcon("F")
|
inGame.forTheSource("keyboard").forTheWantedBind("Cycle_Form").weShouldSeeTheIcon("F")
|
||||||
});
|
});
|
||||||
|
|
||||||
it("test new assign feature to delete the bind from the previous action instead of swaping it", () => {
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").confirmAssignment();
|
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
|
||||||
|
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_RIGHT").weWantThisBindInstead("RIGHT").confirmAssignment();
|
|
||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Left");
|
|
||||||
inGame.whenWePressOnKeyboard("LEFT").nothingShouldHappen();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("check the key displayed on confirm", () => {
|
it("check the key displayed on confirm", () => {
|
||||||
inGame.whenWePressOnKeyboard("ENTER").weShouldTriggerTheButton("Button_Submit");
|
inGame.whenWePressOnKeyboard("ENTER").weShouldTriggerTheButton("Button_Submit");
|
||||||
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up");
|
||||||
@ -343,19 +386,19 @@ describe('Test Rebinding', () => {
|
|||||||
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right");
|
||||||
inGame.whenWePressOnKeyboard("ESC").weShouldTriggerTheButton("Button_Menu");
|
inGame.whenWePressOnKeyboard("ESC").weShouldTriggerTheButton("Button_Menu");
|
||||||
inGame.whenWePressOnKeyboard("HOME").nothingShouldHappen();
|
inGame.whenWePressOnKeyboard("HOME").nothingShouldHappen();
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Submit").iconDisplayedIs("KEY_ENTER").whenWeTryToDelete().iconDisplayedIs("KEY_ENTER")
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Submit").iconDisplayedIs("KEY_ENTER").whenWeDelete().iconDisplayedIs("KEY_ENTER")
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Up").iconDisplayedIs("KEY_ARROW_UP").whenWeTryToDelete().iconDisplayedIs("KEY_ARROW_UP")
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Up").iconDisplayedIs("KEY_ARROW_UP").whenWeDelete().iconDisplayedIs("KEY_ARROW_UP")
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Down").iconDisplayedIs("KEY_ARROW_DOWN").whenWeTryToDelete().iconDisplayedIs("KEY_ARROW_DOWN")
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Down").iconDisplayedIs("KEY_ARROW_DOWN").whenWeDelete().iconDisplayedIs("KEY_ARROW_DOWN")
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").whenWeTryToDelete().iconDisplayedIs("KEY_ARROW_LEFT")
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").whenWeDelete().iconDisplayedIs("KEY_ARROW_LEFT")
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Right").iconDisplayedIs("KEY_ARROW_RIGHT").whenWeTryToDelete().iconDisplayedIs("KEY_ARROW_RIGHT")
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Right").iconDisplayedIs("KEY_ARROW_RIGHT").whenWeDelete().iconDisplayedIs("KEY_ARROW_RIGHT")
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Menu").iconDisplayedIs("KEY_ESC").whenWeTryToDelete().iconDisplayedIs("KEY_ESC")
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Menu").iconDisplayedIs("KEY_ESC").whenWeDelete().iconDisplayedIs("KEY_ESC")
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_Z").whenWeTryToDelete().thereShouldBeNoIconAnymore();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_Z").whenWeDelete().thereShouldBeNoIconAnymore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("check to delete all the binds of an action", () => {
|
it("check to delete all the binds of an action", () => {
|
||||||
inGame.whenWePressOnKeyboard("V").weShouldTriggerTheButton("Button_Cycle_Variant");
|
inGame.whenWePressOnKeyboard("V").weShouldTriggerTheButton("Button_Cycle_Variant");
|
||||||
inGame.whenWePressOnKeyboard("K").weShouldTriggerTheButton("Alt_Button_Cycle_Variant");
|
inGame.whenWePressOnKeyboard("K").weShouldTriggerTheButton("Alt_Button_Cycle_Variant");
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Cycle_Variant").iconDisplayedIs("KEY_K").whenWeTryToDelete().thereShouldBeNoIconAnymore();
|
inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Cycle_Variant").iconDisplayedIs("KEY_K").whenWeDelete().thereShouldBeNoIconAnymore();
|
||||||
inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Variant").iconDisplayedIs("KEY_V").whenWeTryToDelete().iconDisplayedIs("KEY_V")
|
inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Variant").iconDisplayedIs("KEY_V").whenWeDelete().iconDisplayedIs("KEY_V")
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@ import BattleScene from "../../battle-scene";
|
|||||||
import AbstractBindingUiHandler from "../settings/abrast-binding-ui-handler";
|
import AbstractBindingUiHandler from "../settings/abrast-binding-ui-handler";
|
||||||
import {Mode} from "../ui";
|
import {Mode} from "../ui";
|
||||||
import {Device} from "#app/enums/devices";
|
import {Device} from "#app/enums/devices";
|
||||||
import {getIconSpecialCase, getIconWithSettingName, getKeyWithKeycode} from "#app/configs/configHandler";
|
import {getIconWithSettingName, getKeyWithKeycode} from "#app/configs/configHandler";
|
||||||
|
|
||||||
|
|
||||||
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
||||||
@ -27,15 +27,16 @@ export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
|||||||
const buttonIcon = activeConfig.icons[key];
|
const buttonIcon = activeConfig.icons[key];
|
||||||
if (!buttonIcon) return;
|
if (!buttonIcon) return;
|
||||||
this.buttonPressed = button.index;
|
this.buttonPressed = button.index;
|
||||||
const specialCaseIcon = getIconSpecialCase(activeConfig, button.index, this.target);
|
|
||||||
const assignedButtonIcon = getIconWithSettingName(activeConfig, this.target);
|
const assignedButtonIcon = getIconWithSettingName(activeConfig, this.target);
|
||||||
this.onInputDown(buttonIcon, specialCaseIcon || assignedButtonIcon, type);
|
this.onInputDown(buttonIcon, assignedButtonIcon, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
swapAction(): boolean {
|
swapAction(): boolean {
|
||||||
const activeConfig = this.scene.inputController.getActiveConfig(Device.GAMEPAD);
|
const activeConfig = this.scene.inputController.getActiveConfig(Device.GAMEPAD);
|
||||||
this.scene.inputController.swapBinding(activeConfig, this.target, this.buttonPressed)
|
if(this.scene.inputController.assignBinding(activeConfig, this.target, this.buttonPressed)) {
|
||||||
this.scene.gameData.saveMappingConfigs(this.getSelectedDevice(), activeConfig);
|
this.scene.gameData.saveMappingConfigs(this.getSelectedDevice(), activeConfig);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
import BattleScene from "../../battle-scene";
|
import BattleScene from "../../battle-scene";
|
||||||
import AbstractBindingUiHandler from "../settings/abrast-binding-ui-handler";
|
import AbstractBindingUiHandler from "../settings/abrast-binding-ui-handler";
|
||||||
import {Mode} from "../ui";
|
import {Mode} from "../ui";
|
||||||
import {getIconSpecialCase, getIconWithSettingName, getKeyWithKeycode} from "#app/configs/configHandler";
|
import { getIconWithSettingName, getKeyWithKeycode} from "#app/configs/configHandler";
|
||||||
import {Device} from "#app/enums/devices";
|
import {Device} from "#app/enums/devices";
|
||||||
|
|
||||||
|
|
||||||
@ -26,16 +26,17 @@ export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {
|
|||||||
const buttonIcon = activeConfig.icons[_key];
|
const buttonIcon = activeConfig.icons[_key];
|
||||||
if (!buttonIcon) return;
|
if (!buttonIcon) return;
|
||||||
this.buttonPressed = key;
|
this.buttonPressed = key;
|
||||||
const specialCaseIcon = getIconSpecialCase(activeConfig, key, this.target);
|
|
||||||
const assignedButtonIcon = getIconWithSettingName(activeConfig, this.target);
|
const assignedButtonIcon = getIconWithSettingName(activeConfig, this.target);
|
||||||
this.onInputDown(buttonIcon, specialCaseIcon || assignedButtonIcon, 'keyboard');
|
this.onInputDown(buttonIcon, assignedButtonIcon, 'keyboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
swapAction(): boolean {
|
swapAction(): boolean {
|
||||||
const activeConfig = this.scene.inputController.getActiveConfig(Device.KEYBOARD);
|
const activeConfig = this.scene.inputController.getActiveConfig(Device.KEYBOARD);
|
||||||
this.scene.inputController.swapBinding(activeConfig, this.target, this.buttonPressed)
|
if (this.scene.inputController.assignBinding(activeConfig, this.target, this.buttonPressed)) {
|
||||||
this.scene.gameData.saveMappingConfigs(this.getSelectedDevice(), activeConfig);
|
this.scene.gameData.saveMappingConfigs(this.getSelectedDevice(), activeConfig);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -62,11 +62,13 @@ export default class SettingsKeyboardUiHandler extends AbstractSettingsUiUiHandl
|
|||||||
const cursor = this.cursor + this.scrollCursor; // Calculate the absolute cursor position.
|
const cursor = this.cursor + this.scrollCursor; // Calculate the absolute cursor position.
|
||||||
const selection = this.settingLabels[cursor].text;
|
const selection = this.settingLabels[cursor].text;
|
||||||
const key = reverseValueToKeySetting(selection);
|
const key = reverseValueToKeySetting(selection);
|
||||||
const setting = SettingKeyboard[key];
|
const settingName = SettingKeyboard[key];
|
||||||
const activeConfig = this.getActiveConfig();
|
const activeConfig = this.getActiveConfig();
|
||||||
deleteBind(this.getActiveConfig(), setting);
|
const success = deleteBind(this.getActiveConfig(), settingName);
|
||||||
this.saveCustomKeyboardMappingToLocalStorage(activeConfig);
|
if (success) {
|
||||||
this.updateBindings();
|
this.saveCustomKeyboardMappingToLocalStorage(activeConfig);
|
||||||
|
this.updateBindings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user