added a message instead of nothing in the keyboard menu if playing on mobile
parent
b75bea7402
commit
ac9a011da4
|
@ -389,10 +389,14 @@ export class InputsController {
|
|||
}
|
||||
}
|
||||
|
||||
keyboardKeyDown(event): void {
|
||||
const keyDown = event.keyCode;
|
||||
checkIfKeyboardIsInit(): void {
|
||||
if (!this.keyboardConfigs[this.chosenKeyboard]?.padID)
|
||||
this.setupKeyboard();
|
||||
}
|
||||
|
||||
keyboardKeyDown(event): void {
|
||||
const keyDown = event.keyCode;
|
||||
this.checkIfKeyboardIsInit();
|
||||
if (this.keys.includes(keyDown)) return;
|
||||
this.keys.push(keyDown);
|
||||
const key = getKeyFromMapping(this.keyboardConfigs[this.chosenKeyboard], keyDown);
|
||||
|
@ -410,8 +414,7 @@ export class InputsController {
|
|||
keyboardKeyUp(event): void {
|
||||
const keyDown = event.keyCode;
|
||||
this.keys = this.keys.filter(k => k !== keyDown);
|
||||
if (!this.keyboardConfigs[this.chosenKeyboard]?.padID)
|
||||
this.setupKeyboard();
|
||||
this.checkIfKeyboardIsInit()
|
||||
const key = getKeyFromMapping(this.keyboardConfigs[this.chosenKeyboard], keyDown);
|
||||
const buttonUp = this.keyboardConfigs[this.chosenKeyboard].custom[key];
|
||||
if (buttonUp !== undefined) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import {reverseValueToKeySetting, truncateString} from "#app/utils";
|
|||
import AbstractSettingsUiUiHandler from "#app/ui/settings/abstract-settings-ui-handler";
|
||||
import {InterfaceConfig} from "#app/inputs-controller";
|
||||
import {deleteBind} from "#app/configs/gamepad-utils";
|
||||
import {addTextObject, TextStyle} from "#app/ui/text";
|
||||
|
||||
|
||||
export default class SettingsKeyboardUiHandler extends AbstractSettingsUiUiHandler {
|
||||
|
@ -24,6 +25,22 @@ export default class SettingsKeyboardUiHandler extends AbstractSettingsUiUiHandl
|
|||
deleteEvent.on('up', this.onDeleteDown, this);
|
||||
}
|
||||
|
||||
setup() {
|
||||
super.setup();
|
||||
// If no gamepads are detected, set up a default UI prompt in the settings container.
|
||||
this.layout['noKeyboard'] = new Map();
|
||||
const optionsContainer = this.scene.add.container(0, 0);
|
||||
optionsContainer.setVisible(false); // Initially hide the container as no gamepads are connected.
|
||||
const label = addTextObject(this.scene, 8, 28, 'Please press a key on your keyboard', TextStyle.SETTINGS_LABEL);
|
||||
label.setOrigin(0, 0);
|
||||
optionsContainer.add(label);
|
||||
this.settingsContainer.add(optionsContainer);
|
||||
|
||||
// Map the 'noKeyboard' layout options for easy access.
|
||||
this.layout['noKeyboard'].optionsContainer = optionsContainer;
|
||||
this.layout['noKeyboard'].label = label;
|
||||
}
|
||||
|
||||
onDeleteDown(): void {
|
||||
const cursor = this.cursor + this.scrollCursor; // Calculate the absolute cursor position.
|
||||
const selection = this.settingLabels[cursor].text;
|
||||
|
@ -45,6 +62,20 @@ export default class SettingsKeyboardUiHandler extends AbstractSettingsUiUiHandl
|
|||
return settings;
|
||||
}
|
||||
|
||||
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.
|
||||
const layout = this.layout['noKeyboard'];
|
||||
// Make the options container visible to show message.
|
||||
layout.optionsContainer.setVisible(true);
|
||||
// Return false indicating the layout application was not successful due to lack of gamepad.
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.setLayout(activeConfig);
|
||||
}
|
||||
|
||||
navigateMenuLeft(): boolean {
|
||||
this.scene.ui.setMode(Mode.SETTINGS_GAMEPAD)
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue