added basic key settings
parent
c5decd5cc1
commit
80e8d43c56
|
@ -36,6 +36,8 @@ export class InputsController {
|
|||
private time: Time;
|
||||
private player: Map<String, GamepadMapping> = new Map();
|
||||
|
||||
public customGamepadMapping = new Map();
|
||||
|
||||
constructor(scene: Phaser.Scene) {
|
||||
this.scene = scene;
|
||||
this.time = this.scene.time;
|
||||
|
|
|
@ -1,19 +1,56 @@
|
|||
import BattleScene from "../battle-scene";
|
||||
import {SettingDefaults, SettingOptions} from "#app/system/settings";
|
||||
import {Button} from "../enums/buttons";
|
||||
|
||||
export enum SettingGamepad {
|
||||
Gamepad_Support = "GAMEPAD_SUPPORT",
|
||||
Swap_A_and_B = "SWAP_A_B", // Swaps which gamepad button handles ACTION and CANCEL
|
||||
Button_Action = "BUTTON_ACTION",
|
||||
Button_Cancel = "BUTTON_CANCEL",
|
||||
Button_Menu = "BUTTON_MENU",
|
||||
Button_Stats = "BUTTON_STATS",
|
||||
Button_Cycle_Shiny = "BUTTON_CYCLE_SHINY",
|
||||
Button_Cycle_Form = "BUTTON_CYCLE_FORM",
|
||||
Button_Cycle_Gender = "BUTTON_CYCLE_GENDER",
|
||||
Button_Cycle_Ability = "BUTTON_CYCLE_ABILITY",
|
||||
Button_Cycle_Nature = "BUTTON_CYCLE_NATURE",
|
||||
Button_Cycle_Variant = "BUTTON_CYCLE_VARIANT",
|
||||
Button_Speed_Up = "BUTTON_SPEED_UP",
|
||||
Button_Slow_Down = "BUTTON_SLOW_DOWN",
|
||||
}
|
||||
|
||||
export const settingGamepadOptions: SettingOptions = {
|
||||
[SettingGamepad.Gamepad_Support]: [ 'Auto', 'Disabled' ],
|
||||
[SettingGamepad.Swap_A_and_B]: [ 'Enabled', 'Disabled' ],
|
||||
[SettingGamepad.Button_Action]: [`KEY ${Button.ACTION.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Cancel]: [`KEY ${Button.CANCEL.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Menu]: [`KEY ${Button.MENU.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Stats]: [`KEY ${Button.STATS.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Cycle_Shiny]: [`KEY ${Button.RB.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Cycle_Form]: [`KEY ${Button.LB.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Cycle_Gender]: [`KEY ${Button.CYCLE_GENDER.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Cycle_Ability]: [`KEY ${Button.CYCLE_ABILITY.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Cycle_Nature]: [`KEY ${Button.CYCLE_NATURE.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Cycle_Variant]: [`KEY ${Button.CYCLE_VARIANT.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Speed_Up]: [`KEY ${Button.SPEED_UP.toString()}`, 'Change'],
|
||||
[SettingGamepad.Button_Slow_Down]: [`KEY ${Button.SLOW_DOWN.toString()}`, 'Change']
|
||||
};
|
||||
|
||||
export const settingGamepadDefaults: SettingDefaults = {
|
||||
[SettingGamepad.Gamepad_Support]: 0,
|
||||
[SettingGamepad.Swap_A_and_B]: 1, // Set to 'Disabled' by default
|
||||
[SettingGamepad.Button_Action]: Button.ACTION,
|
||||
[SettingGamepad.Button_Cancel]: Button.CANCEL,
|
||||
[SettingGamepad.Button_Menu]: Button.MENU,
|
||||
[SettingGamepad.Button_Stats]: Button.STATS,
|
||||
[SettingGamepad.Button_Cycle_Shiny]: Button.RB,
|
||||
[SettingGamepad.Button_Cycle_Form]: Button.LB,
|
||||
[SettingGamepad.Button_Cycle_Gender]: Button.CYCLE_GENDER,
|
||||
[SettingGamepad.Button_Cycle_Ability]: Button.CYCLE_ABILITY,
|
||||
[SettingGamepad.Button_Cycle_Nature]: Button.CYCLE_NATURE,
|
||||
[SettingGamepad.Button_Cycle_Variant]: Button.CYCLE_VARIANT,
|
||||
[SettingGamepad.Button_Speed_Up]: Button.SPEED_UP,
|
||||
[SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN,
|
||||
};
|
||||
|
||||
export function setSettingGamepad(scene: BattleScene, setting: SettingGamepad, value: integer): boolean {
|
||||
|
@ -24,6 +61,20 @@ export function setSettingGamepad(scene: BattleScene, setting: SettingGamepad, v
|
|||
case SettingGamepad.Swap_A_and_B:
|
||||
scene.abSwapped = settingGamepadOptions[setting][value] !== 'Disabled';
|
||||
break;
|
||||
case SettingGamepad.Button_Action:
|
||||
case SettingGamepad.Button_Cancel:
|
||||
case SettingGamepad.Button_Menu:
|
||||
case SettingGamepad.Button_Stats:
|
||||
case SettingGamepad.Button_Cycle_Shiny:
|
||||
case SettingGamepad.Button_Cycle_Form:
|
||||
case SettingGamepad.Button_Cycle_Gender:
|
||||
case SettingGamepad.Button_Cycle_Ability:
|
||||
case SettingGamepad.Button_Cycle_Nature:
|
||||
case SettingGamepad.Button_Cycle_Variant:
|
||||
case SettingGamepad.Button_Speed_Up:
|
||||
case SettingGamepad.Button_Slow_Down:
|
||||
scene.inputController.customGamepadMapping[setting] = value;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -194,14 +194,14 @@ export default class SettingsGamepadUiHandler extends UiHandler {
|
|||
const lastCursor = this.optionCursors[settingIndex];
|
||||
|
||||
const lastValueLabel = this.optionValueLabels[settingIndex][lastCursor];
|
||||
lastValueLabel.setColor(this.getTextColor(TextStyle.WINDOW));
|
||||
lastValueLabel.setShadowColor(this.getTextColor(TextStyle.WINDOW, true));
|
||||
lastValueLabel?.setColor(this.getTextColor(TextStyle.WINDOW));
|
||||
lastValueLabel?.setShadowColor(this.getTextColor(TextStyle.WINDOW, true));
|
||||
|
||||
this.optionCursors[settingIndex] = cursor;
|
||||
|
||||
const newValueLabel = this.optionValueLabels[settingIndex][cursor];
|
||||
newValueLabel.setColor(this.getTextColor(TextStyle.SETTINGS_SELECTED));
|
||||
newValueLabel.setShadowColor(this.getTextColor(TextStyle.SETTINGS_SELECTED, true));
|
||||
newValueLabel?.setColor(this.getTextColor(TextStyle.SETTINGS_SELECTED));
|
||||
newValueLabel?.setShadowColor(this.getTextColor(TextStyle.SETTINGS_SELECTED, true));
|
||||
|
||||
if (save) {
|
||||
this.scene.gameData.saveSetting(setting, cursor)
|
||||
|
|
Loading…
Reference in New Issue