fix imports

pull/685/head
Greenlamp 2024-05-13 02:03:06 +02:00
parent 627a6cb66f
commit e798f72a63
7 changed files with 47 additions and 48 deletions

View File

@ -1,16 +1,15 @@
import {GamepadConfig} from "../inputs-controller";
import {SettingGamepad} from "#app/system/settings-gamepad";
import {InterfaceConfig} from "../inputs-controller";
import {Button} from "#app/enums/buttons";
// Given a button index from an input event, return its naming from the mapping config
export function getKeyFromInputIndex(config: GamepadConfig, index: number): String | null {
export function getKeyFromInputIndex(config: InterfaceConfig, index: number): String | null {
for (const key of Object.keys(config.gamepadMapping)) {
if (config.gamepadMapping[key] === index) return key;
}
return null;
}
export function getKeyFromKeyboardKey(config: GamepadConfig, key): String | null {
export function getKeyFromKeyboardKey(config: InterfaceConfig, key): String | null {
for (const _key of Object.keys(config.gamepadMapping)) {
if (config.gamepadMapping[_key] === key) return _key;
}
@ -18,7 +17,7 @@ export function getKeyFromKeyboardKey(config: GamepadConfig, key): String | null
}
// Given a setting name, return the key assigned to it from the config file
export function getKeyForSettingName(config: GamepadConfig, settingName: string): String | null {
export function getKeyForSettingName(config: InterfaceConfig, settingName: string): String | null {
for (const key of Object.keys(config.setting)) {
if (config.setting[key] === settingName) return key;
}
@ -26,7 +25,7 @@ export function getKeyForSettingName(config: GamepadConfig, settingName: string)
}
// Given a Button, return the custom key assigned to it from the config file
export function getCurrenlyAssignedKeyToAction(config: GamepadConfig, action: Button): String | null {
export function getCurrenlyAssignedKeyToAction(config: InterfaceConfig, action: Button): String | null {
for (const key of Object.keys(config.custom)) {
if (config.custom[key] === action) return key;
}
@ -34,7 +33,7 @@ export function getCurrenlyAssignedKeyToAction(config: GamepadConfig, action: Bu
}
// Given a setting name, return the custom key for the default action from the config file
export function getCurrentlyAssignedToSettingName(config: GamepadConfig, settingName: string): String {
export function getCurrentlyAssignedToSettingName(config: InterfaceConfig, settingName: string): String {
const oldKey = getKeyForSettingName(config, settingName)
const action = config.default[oldKey];
const key = getCurrenlyAssignedKeyToAction(config, action);
@ -42,18 +41,18 @@ export function getCurrentlyAssignedToSettingName(config: GamepadConfig, setting
}
// Given a button index from an input event, return its icon from the config file
export function getCurrenlyAssignedIconFromInputIndex(config: GamepadConfig, index: number): String {
export function getCurrenlyAssignedIconFromInputIndex(config: InterfaceConfig, index: number): String {
const key = getKeyFromInputIndex(config, index);
return config.icons[key];
}
export function getCurrenlyAssignedIconFromKeyboardKey(config: GamepadConfig, key): String {
export function getCurrenlyAssignedIconFromKeyboardKey(config: InterfaceConfig, key): String {
const _key = getKeyFromKeyboardKey(config, key);
return config.icons[_key];
}
// Given a setting name, return the icon currently assigned to this setting name
export function getCurrentlyAssignedIconToSettingName(config: GamepadConfig, settingName: string): string {
export function getCurrentlyAssignedIconToSettingName(config: InterfaceConfig, settingName: string): string {
const key = getCurrentlyAssignedToSettingName(config, settingName);
return config.icons[key];
}

View File

@ -12,9 +12,9 @@ import {
getCurrenlyAssignedIconFromInputIndex, getCurrentlyAssignedIconToSettingName,
getKeyFromInputIndex, getCurrentlyAssignedToSettingName, getCurrenlyAssignedIconFromKeyboardKey
} from "./configs/gamepad-utils";
import SettingsKeyboardUiHandler from "#app/ui/settings/settings-keyboard-ui-handler";
import cfg_keyboard_azerty from "#app/configs/cfg_keyboard_azerty";
import {SettingKeyboard} from "#app/system/settings-keyboard";
import SettingsKeyboardUiHandler from "./ui/settings/settings-keyboard-ui-handler";
import cfg_keyboard_azerty from "./configs/cfg_keyboard_azerty";
import {SettingKeyboard} from "./system/settings-keyboard";
export interface GamepadMapping {
[key: string]: number;
@ -32,7 +32,7 @@ export interface MappingLayout {
[key: string]: Button;
}
export interface GamepadConfig {
export interface InterfaceConfig {
padID: string;
padType: string;
gamepadMapping: GamepadMapping;
@ -76,8 +76,8 @@ export class InputsController {
private buttonLock2: Button;
private interactions: Map<Button, Map<string, boolean>> = new Map();
private time: Phaser.Time.Clock;
private configs: Map<string, GamepadConfig> = new Map();
private keyboardConfigs: Map<string, GamepadConfig> = new Map();
private configs: Map<string, InterfaceConfig> = new Map();
private keyboardConfigs: Map<string, InterfaceConfig> = new Map();
private gamepadSupport: boolean = true;
@ -204,6 +204,7 @@ export class InputsController {
this.deactivatePressedKey();
this.initChosenGamepad(gamepad)
}
setChosenKeyboardLayout(layoutKeyboard: String): void {
this.deactivatePressedKey();
this.initChosenLayoutKeyboard(layoutKeyboard)
@ -532,9 +533,9 @@ export class InputsController {
* If no specific configuration matches, it defaults to a generic gamepad configuration.
*
* @param id The identifier string of the gamepad.
* @returns GamepadConfig The configuration object corresponding to the identified gamepad type.
* @returns InterfaceConfig The configuration object corresponding to the identified gamepad type.
*/
getConfig(id: string): GamepadConfig {
getConfig(id: string): InterfaceConfig {
id = id.toLowerCase();
if (id.includes('081f') && id.includes('e401')) {
@ -548,7 +549,7 @@ export class InputsController {
return pad_generic;
}
getConfigKeyboard(id: string): GamepadConfig {
getConfigKeyboard(id: string): InterfaceConfig {
if (id === 'azerty')
return cfg_keyboard_azerty;
@ -699,9 +700,9 @@ export class InputsController {
* Retrieves the active configuration for the currently chosen gamepad.
* It checks if a specific gamepad ID is stored under the chosen gamepad's configurations and returns it.
*
* @returns GamepadConfig The configuration object for the active gamepad, or null if not set.
* @returns InterfaceConfig The configuration object for the active gamepad, or null if not set.
*/
getActiveConfig(): GamepadConfig | null {
getActiveConfig(): InterfaceConfig | null {
if (this.configs[this.chosenGamepad]?.padID) return this.configs[this.chosenGamepad]
return null;
}
@ -710,9 +711,9 @@ export class InputsController {
* Retrieves the active configuration for the currently chosen gamepad.
* It checks if a specific gamepad ID is stored under the chosen gamepad's configurations and returns it.
*
* @returns GamepadConfig The configuration object for the active gamepad, or null if not set.
* @returns InterfaceConfig The configuration object for the active gamepad, or null if not set.
*/
getActiveKeyboardConfig(): GamepadConfig | null {
getActiveKeyboardConfig(): InterfaceConfig | null {
if (this.keyboardConfigs[this.chosenKeyboard]?.padID) return this.keyboardConfigs[this.chosenKeyboard]
return null;
}

View File

@ -1,10 +1,9 @@
import UiHandler from "#app/ui/ui-handler";
import Phaser from "phaser";
import BattleScene from "#app/battle-scene";
import {Mode} from "#app/ui/ui";
import {addWindow} from "#app/ui/ui-theme";
import {addTextObject, TextStyle} from "#app/ui/text";
import {Button} from "#app/enums/buttons";
import UiHandler from "../ui-handler";
import BattleScene from "../../battle-scene";
import {Mode} from "../ui";
import {addWindow} from "../ui-theme";
import {addTextObject, TextStyle} from "../text";
import {Button} from "../../enums/buttons";
export default abstract class AbstractBindingUiHandler extends UiHandler {
@ -116,7 +115,7 @@ export default abstract class AbstractBindingUiHandler extends UiHandler {
this.getUi().bringToTop(this.actionsContainer);
this.optionSelectContainer.setVisible(true);
setTimeout(() => this.listening = true, 150);
setTimeout(() => this.listening = true, 300);
return true;
}
@ -177,6 +176,7 @@ export default abstract class AbstractBindingUiHandler extends UiHandler {
clear() {
super.clear();
this.listening = false;
this.target = null;
this.cancelFn = null;
this.optionSelectContainer.setVisible(false);

View File

@ -1,11 +1,11 @@
import UiHandler from "#app/ui/ui-handler";
import BattleScene from "#app/battle-scene";
import {Mode} from "#app/ui/ui";
import {GamepadConfig} from "#app/inputs-controller";
import {addWindow} from "#app/ui/ui-theme";
import {addTextObject, TextStyle} from "#app/ui/text";
import {getCurrentlyAssignedIconToSettingName, getKeyForSettingName} from "#app/configs/gamepad-utils";
import {Button} from "#app/enums/buttons";
import UiHandler from "../ui-handler";
import BattleScene from "../../battle-scene";
import {Mode} from "../ui";
import {InterfaceConfig} from "../../inputs-controller";
import {addWindow} from "../ui-theme";
import {addTextObject, TextStyle} from "../text";
import {getCurrentlyAssignedIconToSettingName, getKeyForSettingName} from "../../configs/gamepad-utils";
import {Button} from "../../enums/buttons";
export interface InputsIcons {
[key: string]: Phaser.GameObjects.Sprite;
@ -151,7 +151,7 @@ export default abstract class AbstractSettingsUiUiHandler extends UiHandler {
continue;
}
// For null options, add an icon for the key.
const key = getKeyForSettingName(config as GamepadConfig, this.settingDevice[setting]);
const key = getKeyForSettingName(config as InterfaceConfig, this.settingDevice[setting]);
const icon = this.scene.add.sprite(0, 0, this.textureOverride ? this.textureOverride : config.padType);
icon.setScale(0.1);
icon.setOrigin(0, -0.1);
@ -270,7 +270,7 @@ export default abstract class AbstractSettingsUiUiHandler extends UiHandler {
return true;
}
setLayout(activeConfig: GamepadConfig): boolean {
setLayout(activeConfig: InterfaceConfig): boolean {
// Check if there is no active configuration (e.g., no gamepad connected).
if (!activeConfig) {
// Retrieve the layout for when no gamepads are connected.

View File

@ -1,7 +1,6 @@
import BattleScene from "#app/battle-scene";
import Phaser from "phaser";
import AbstractBindingUiHandler from "#app/ui/settings/abrast-binding-ui-handler";
import {Mode} from "#app/ui/ui";
import BattleScene from "../../battle-scene";
import AbstractBindingUiHandler from "../settings/abrast-binding-ui-handler";
import {Mode} from "../ui";
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {

View File

@ -1,6 +1,6 @@
import BattleScene from "../../battle-scene";
import AbstractBindingUiHandler from "../settings/abrast-binding-ui-handler";
import {Mode} from "../ui";
import AbstractBindingUiHandler from "#app/ui/settings/abrast-binding-ui-handler";
export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {

View File

@ -6,7 +6,7 @@ import {truncateString} from "../../utils";
import pad_xbox360 from "#app/configs/pad_xbox360";
import pad_dualshock from "#app/configs/pad_dualshock";
import pad_unlicensedSNES from "#app/configs/pad_unlicensedSNES";
import {GamepadConfig} from "#app/inputs-controller";
import {InterfaceConfig} from "#app/inputs-controller";
import AbstractSettingsUiUiHandler from "#app/ui/settings/abstract-settings-ui-handler";
export default class SettingsGamepadUiHandler extends AbstractSettingsUiUiHandler {
@ -48,7 +48,7 @@ export default class SettingsGamepadUiHandler extends AbstractSettingsUiUiHandle
return settings;
}
setLayout(activeConfig: GamepadConfig): boolean {
setLayout(activeConfig: InterfaceConfig): boolean {
// Check if there is no active configuration (e.g., no gamepad connected).
if (!activeConfig) {
// Retrieve the layout for when no gamepads are connected.