first step to display button icon in the gamepad menu for current binding

pull/685/head
Greenlamp 2024-05-11 02:59:52 +02:00
parent 043216aa75
commit 635a2ea959
5 changed files with 75 additions and 43 deletions

View File

@ -60,6 +60,8 @@ const pad_dualshock = {
RB: Button.CYCLE_SHINY,
LT: Button.CYCLE_GENDER,
RT: Button.CYCLE_ABILITY,
LS: Button.SPEED_UP,
RS: Button.SLOW_DOWN,
LC_N: Button.UP,
LC_S: Button.DOWN,
LC_W: Button.LEFT,

View File

@ -59,6 +59,8 @@ const pad_generic = {
RB: Button.CYCLE_SHINY,
LT: Button.CYCLE_GENDER,
RT: Button.CYCLE_ABILITY,
LS: Button.SPEED_UP,
RS: Button.SLOW_DOWN,
LC_N: Button.UP,
LC_S: Button.DOWN,
LC_W: Button.LEFT,

View File

@ -46,6 +46,16 @@ const pad_xbox360 = {
setting: {
RC_S: SettingGamepad.Button_Action,
RC_E: SettingGamepad.Button_Cancel,
RC_W: SettingGamepad.Button_Cycle_Nature,
RC_N: SettingGamepad.Button_Cycle_Variant,
START: SettingGamepad.Button_Menu,
SELECT: SettingGamepad.Button_Stats,
LB: SettingGamepad.Button_Cycle_Form,
RB: SettingGamepad.Button_Cycle_Shiny,
LT: SettingGamepad.Button_Cycle_Gender,
RT: SettingGamepad.Button_Cycle_Ability,
LS: SettingGamepad.Button_Speed_Up,
RS: SettingGamepad.Button_Slow_Down,
},
default: {
RC_S: Button.ACTION,
@ -58,6 +68,8 @@ const pad_xbox360 = {
RB: Button.CYCLE_SHINY,
LT: Button.CYCLE_GENDER,
RT: Button.CYCLE_ABILITY,
LS: Button.SPEED_UP,
RS: Button.SLOW_DOWN,
LC_N: Button.UP,
LC_S: Button.DOWN,
LC_W: Button.LEFT,

View File

@ -11,16 +11,16 @@ export enum SettingGamepad {
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",
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 = {
@ -29,16 +29,16 @@ export const settingGamepadOptions: SettingOptions = {
[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']
[SettingGamepad.Button_Menu]: [`KEY ${Button.MENU.toString()}`, 'Change'],
[SettingGamepad.Button_Stats]: [`KEY ${Button.STATS.toString()}`, 'Change'],
[SettingGamepad.Button_Cycle_Shiny]: [`KEY ${Button.CYCLE_SHINY.toString()}`, 'Change'],
[SettingGamepad.Button_Cycle_Form]: [`KEY ${Button.CYCLE_FORM.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 = {
@ -47,21 +47,31 @@ export const settingGamepadDefaults: SettingDefaults = {
[SettingGamepad.Swap_A_and_B]: 1, // Set to 'Disabled' by default
[SettingGamepad.Button_Action]: 0,
[SettingGamepad.Button_Cancel]: 0,
// [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,
[SettingGamepad.Button_Menu]: 0,
[SettingGamepad.Button_Stats]: 0,
[SettingGamepad.Button_Cycle_Shiny]: 0,
[SettingGamepad.Button_Cycle_Form]: 0,
[SettingGamepad.Button_Cycle_Gender]: 0,
[SettingGamepad.Button_Cycle_Ability]: 0,
[SettingGamepad.Button_Cycle_Nature]: 0,
[SettingGamepad.Button_Cycle_Variant]: 0,
[SettingGamepad.Button_Speed_Up]: 0,
[SettingGamepad.Button_Slow_Down]: 0,
};
export const noOptionsCursors: Array<SettingGamepad> = [
SettingGamepad.Button_Action,
SettingGamepad.Button_Cancel,
SettingGamepad.Button_Menu,
SettingGamepad.Button_Stats,
SettingGamepad.Button_Cycle_Shiny,
SettingGamepad.Button_Cycle_Form,
SettingGamepad.Button_Cycle_Gender,
SettingGamepad.Button_Cycle_Ability,
SettingGamepad.Button_Cycle_Nature,
SettingGamepad.Button_Cycle_Variant,
SettingGamepad.Button_Speed_Up,
SettingGamepad.Button_Slow_Down,
];
export function setSettingGamepad(scene: BattleScene, setting: SettingGamepad, value: integer): boolean {
@ -76,16 +86,16 @@ export function setSettingGamepad(scene: BattleScene, setting: SettingGamepad, v
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:
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:
if (value) {
if (scene.ui) {
const cancelHandler = () => {

View File

@ -74,14 +74,20 @@ export default class SettingsGamepadUiHandler extends UiHandler {
this.optionsContainer.add(this.settingLabels[s]);
this.optionValueLabels.push(settingGamepadOptions[SettingGamepad[setting]].map((option, o) => {
const valueLabels = []
for (const [o, option] of settingGamepadOptions[SettingGamepad[setting]].entries()) {
if (noOptionsCursors.includes(SettingGamepad[setting])) {
// need to find a way to fetch icons and display, maybe a placeholder.
continue;
}
const valueLabel = addTextObject(this.scene, 0, 0, option, settingGamepadDefaults[SettingGamepad[setting]] === o ? TextStyle.SETTINGS_SELECTED : TextStyle.WINDOW);
valueLabel.setOrigin(0, 0);
this.optionsContainer.add(valueLabel);
return valueLabel;
}));
valueLabels.push(valueLabel);
}
this.optionValueLabels.push(valueLabels);
const totalWidth = this.optionValueLabels[s].map(o => o.width).reduce((total, width) => total += width, 0);