get missmatch function call
parent
e5e100990e
commit
83a26d8e58
|
@ -29,10 +29,18 @@ export function getKeyForRebindedAction(config: GamepadConfig, action: Button):
|
|||
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 {
|
||||
const oldKey = getKeyForSettingName(config, settingName)
|
||||
const action = config.custom[oldKey];
|
||||
return getKeyForRebindedAction(config, action);
|
||||
const key = getKeyForRebindedAction(config, action);
|
||||
return key;
|
||||
}
|
||||
|
||||
export function getIconForRebindedKey(config: GamepadConfig, _key): String {
|
||||
|
@ -48,3 +56,10 @@ export function getKeyForSettingName(config: GamepadConfig, settingName: Setting
|
|||
}
|
||||
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,
|
||||
},
|
||||
default: {
|
||||
RC_S: Button.ACTION,
|
||||
RC_E: Button.CANCEL,
|
||||
RC_S: Button.ACTION, //5
|
||||
RC_E: Button.CANCEL, // 6
|
||||
RC_W: Button.CYCLE_NATURE,
|
||||
RC_N: Button.CYCLE_VARIANT,
|
||||
START: Button.MENU,
|
||||
|
|
|
@ -59,7 +59,7 @@ const pad_xbox360 = {
|
|||
},
|
||||
default: {
|
||||
RC_S: Button.ACTION, //5
|
||||
RC_E: Button.CANCEL,
|
||||
RC_E: Button.CANCEL, // 6
|
||||
RC_W: Button.CYCLE_NATURE,
|
||||
RC_N: Button.CYCLE_VARIANT, //14
|
||||
START: Button.MENU, //7
|
||||
|
|
|
@ -307,8 +307,9 @@ export class InputsController {
|
|||
// for each gamepad, we set its mapping in this.configs
|
||||
const gamepadID = gamepad.toLowerCase();
|
||||
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.scene.gameData?.saveCustomMapping(this.chosenGamepad, this.configs[gamepad]?.custom);
|
||||
}
|
||||
if (this.chosenGamepad === thisGamepad.id) this.initChosenGamepad(this.chosenGamepad)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,10 @@ import {
|
|||
settingGamepadOptions
|
||||
} from "../system/settings-gamepad";
|
||||
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 {
|
||||
private settingsContainer: Phaser.GameObjects.Container;
|
||||
|
@ -141,7 +144,7 @@ export default class SettingsGamepadUiHandler extends UiHandler {
|
|||
const activeConfig = this.scene.inputController.getActiveConfig();
|
||||
for (const elm of noOptionsCursors) {
|
||||
const key = getKeyForSettingName(activeConfig, elm);
|
||||
const icon = getIconForRebindedKey(activeConfig, key);
|
||||
const icon = getIconForSettingName(activeConfig, elm);
|
||||
this.inputsIcons[key].setFrame(icon);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue