Add setting for gamepad support

pull/153/head
Flashfyre 2024-04-15 20:13:58 -04:00
parent 0692a343a0
commit 1ff206287a
2 changed files with 7 additions and 1 deletions

View File

@ -128,6 +128,7 @@ export default class BattleScene extends SceneBase {
public moveAnimations: boolean = true;
public hpBarSpeed: integer = 0;
public fusionPaletteSwaps: boolean = true;
public gamepadSupport: boolean = true;
public enableTouchControls: boolean = false;
public enableVibration: boolean = false;
@ -1299,7 +1300,7 @@ export default class BattleScene extends SceneBase {
* again.
*/
gamepadButtonJustDown(button: Phaser.Input.Gamepad.Button) : boolean {
if (!button)
if (!button || !this.gamepadSupport)
return false;
let ret = false;

View File

@ -19,6 +19,7 @@ export enum Setting {
HP_Bar_Speed = "HP_BAR_SPEED",
Fusion_Palette_Swaps = "FUSION_PALETTE_SWAPS",
Player_Gender = "PLAYER_GENDER",
Gamepad_Support = "GAMEPAD_SUPPORT",
Touch_Controls = "TOUCH_CONTROLS",
Vibration = "VIBRATION"
}
@ -47,6 +48,7 @@ export const settingOptions: SettingOptions = {
[Setting.HP_Bar_Speed]: [ 'Normal', 'Fast', 'Faster', 'Instant' ],
[Setting.Fusion_Palette_Swaps]: [ 'Off', 'On' ],
[Setting.Player_Gender]: [ 'Boy', 'Girl' ],
[Setting.Gamepad_Support]: [ 'Auto', 'Disabled' ],
[Setting.Touch_Controls]: [ 'Auto', 'Disabled' ],
[Setting.Vibration]: [ 'Auto', 'Disabled' ]
};
@ -130,6 +132,9 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
} else
return false;
break;
case Setting.Gamepad_Support:
scene.gamepadSupport = settingOptions[setting][value] !== 'Disabled';
break;
case Setting.Touch_Controls:
scene.enableTouchControls = settingOptions[setting][value] !== 'Disabled' && hasTouchscreen();
const touchControls = document.getElementById('touchControls');