mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-13 11:52:18 +02:00
get missmatch function call
This commit is contained in:
parent
e5e100990e
commit
83a26d8e58
@ -29,10 +29,18 @@ export function getKeyForRebindedAction(config: GamepadConfig, action: Button):
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getKeyForAction(config: GamepadConfig, action: Button): String {
|
||||||
|
for (const key of Object.keys(config.custom)) {
|
||||||
|
if (config.custom[key] === action) return key;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export function getKeyForRebindedSettingName(config: GamepadConfig, settingName: SettingGamepad): String {
|
export function getKeyForRebindedSettingName(config: GamepadConfig, settingName: SettingGamepad): String {
|
||||||
const oldKey = getKeyForSettingName(config, settingName)
|
const oldKey = getKeyForSettingName(config, settingName)
|
||||||
const action = config.custom[oldKey];
|
const action = config.custom[oldKey];
|
||||||
return getKeyForRebindedAction(config, action);
|
const key = getKeyForRebindedAction(config, action);
|
||||||
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getIconForRebindedKey(config: GamepadConfig, _key): String {
|
export function getIconForRebindedKey(config: GamepadConfig, _key): String {
|
||||||
@ -48,3 +56,10 @@ export function getKeyForSettingName(config: GamepadConfig, settingName: Setting
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getIconForSettingName(config: GamepadConfig, settingName: SettingGamepad) {
|
||||||
|
const key = getKeyForSettingName(config, settingName);
|
||||||
|
const action = config.default[key];
|
||||||
|
const rebindedKey = getKeyForAction(config, action);
|
||||||
|
return config.icons[rebindedKey];
|
||||||
|
}
|
||||||
|
@ -58,8 +58,8 @@ const pad_generic = {
|
|||||||
RS: SettingGamepad.Button_Slow_Down,
|
RS: SettingGamepad.Button_Slow_Down,
|
||||||
},
|
},
|
||||||
default: {
|
default: {
|
||||||
RC_S: Button.ACTION,
|
RC_S: Button.ACTION, //5
|
||||||
RC_E: Button.CANCEL,
|
RC_E: Button.CANCEL, // 6
|
||||||
RC_W: Button.CYCLE_NATURE,
|
RC_W: Button.CYCLE_NATURE,
|
||||||
RC_N: Button.CYCLE_VARIANT,
|
RC_N: Button.CYCLE_VARIANT,
|
||||||
START: Button.MENU,
|
START: Button.MENU,
|
||||||
|
@ -59,7 +59,7 @@ const pad_xbox360 = {
|
|||||||
},
|
},
|
||||||
default: {
|
default: {
|
||||||
RC_S: Button.ACTION, //5
|
RC_S: Button.ACTION, //5
|
||||||
RC_E: Button.CANCEL,
|
RC_E: Button.CANCEL, // 6
|
||||||
RC_W: Button.CYCLE_NATURE,
|
RC_W: Button.CYCLE_NATURE,
|
||||||
RC_N: Button.CYCLE_VARIANT, //14
|
RC_N: Button.CYCLE_VARIANT, //14
|
||||||
START: Button.MENU, //7
|
START: Button.MENU, //7
|
||||||
|
@ -307,8 +307,9 @@ export class InputsController {
|
|||||||
// for each gamepad, we set its mapping in this.configs
|
// for each gamepad, we set its mapping in this.configs
|
||||||
const gamepadID = gamepad.toLowerCase();
|
const gamepadID = gamepad.toLowerCase();
|
||||||
const config = this.getConfig(gamepadID);
|
const config = this.getConfig(gamepadID);
|
||||||
config.custom = this.configs[gamepad]?.custom || config.default;
|
config.custom = this.configs[gamepad]?.custom || {...config.default};
|
||||||
this.configs[gamepad] = config;
|
this.configs[gamepad] = config;
|
||||||
|
this.scene.gameData?.saveCustomMapping(this.chosenGamepad, this.configs[gamepad]?.custom);
|
||||||
}
|
}
|
||||||
if (this.chosenGamepad === thisGamepad.id) this.initChosenGamepad(this.chosenGamepad)
|
if (this.chosenGamepad === thisGamepad.id) this.initChosenGamepad(this.chosenGamepad)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,10 @@ import {
|
|||||||
settingGamepadOptions
|
settingGamepadOptions
|
||||||
} from "../system/settings-gamepad";
|
} from "../system/settings-gamepad";
|
||||||
import {truncateString} from "../utils";
|
import {truncateString} from "../utils";
|
||||||
import {getIconForRebindedKey, getKeyForSettingName} from "#app/configs/gamepad-utils";
|
import {
|
||||||
|
getIconForSettingName,
|
||||||
|
getKeyForSettingName
|
||||||
|
} from "#app/configs/gamepad-utils";
|
||||||
|
|
||||||
export default class SettingsGamepadUiHandler extends UiHandler {
|
export default class SettingsGamepadUiHandler extends UiHandler {
|
||||||
private settingsContainer: Phaser.GameObjects.Container;
|
private settingsContainer: Phaser.GameObjects.Container;
|
||||||
@ -141,7 +144,7 @@ export default class SettingsGamepadUiHandler extends UiHandler {
|
|||||||
const activeConfig = this.scene.inputController.getActiveConfig();
|
const activeConfig = this.scene.inputController.getActiveConfig();
|
||||||
for (const elm of noOptionsCursors) {
|
for (const elm of noOptionsCursors) {
|
||||||
const key = getKeyForSettingName(activeConfig, elm);
|
const key = getKeyForSettingName(activeConfig, elm);
|
||||||
const icon = getIconForRebindedKey(activeConfig, key);
|
const icon = getIconForSettingName(activeConfig, elm);
|
||||||
this.inputsIcons[key].setFrame(icon);
|
this.inputsIcons[key].setFrame(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user