mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-15 21:02:18 +02:00
moved blacklisted setting on top and grey it
This commit is contained in:
parent
26eb89155e
commit
87fec224a0
@ -45,18 +45,20 @@ export enum SettingKeyboard {
|
||||
export const settingKeyboardOptions: SettingOptions = {
|
||||
// [SettingKeyboard.Default_Layout]: ['Default'],
|
||||
[SettingKeyboard.Button_Up]: [`KEY ${Button.UP.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Up]: [`KEY ${Button.UP.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Down]: [`KEY ${Button.DOWN.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Down]: [`KEY ${Button.DOWN.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Up]: [`KEY ${Button.UP.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Left]: [`KEY ${Button.LEFT.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Left]: [`KEY ${Button.LEFT.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Right]: [`KEY ${Button.RIGHT.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Right]: [`KEY ${Button.RIGHT.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Action]: [`KEY ${Button.ACTION.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Menu]: [`KEY ${Button.MENU.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Submit]: [`KEY ${Button.SUBMIT.toString()}`, 'Press action to assign'],
|
||||
|
||||
[SettingKeyboard.Alt_Button_Down]: [`KEY ${Button.DOWN.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Left]: [`KEY ${Button.LEFT.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Right]: [`KEY ${Button.RIGHT.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Action]: [`KEY ${Button.ACTION.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Cancel]: [`KEY ${Button.CANCEL.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Cancel]: [`KEY ${Button.CANCEL.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Menu]: [`KEY ${Button.MENU.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Menu]: [`KEY ${Button.MENU.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Stats]: [`KEY ${Button.STATS.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Stats]: [`KEY ${Button.STATS.toString()}`, 'Press action to assign'],
|
||||
@ -76,25 +78,26 @@ export const settingKeyboardOptions: SettingOptions = {
|
||||
[SettingKeyboard.Alt_Button_Speed_Up]: [`KEY ${Button.SPEED_UP.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Slow_Down]: [`KEY ${Button.SLOW_DOWN.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Slow_Down]: [`KEY ${Button.SLOW_DOWN.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Button_Submit]: [`KEY ${Button.SUBMIT.toString()}`, 'Press action to assign'],
|
||||
[SettingKeyboard.Alt_Button_Submit]: [`KEY ${Button.SUBMIT.toString()}`, 'Press action to assign'],
|
||||
};
|
||||
|
||||
export const settingKeyboardDefaults: SettingDefaults = {
|
||||
// [SettingKeyboard.Default_Layout]: 0,
|
||||
[SettingKeyboard.Button_Up]: 0,
|
||||
[SettingKeyboard.Alt_Button_Up]: 0,
|
||||
[SettingKeyboard.Button_Down]: 0,
|
||||
[SettingKeyboard.Alt_Button_Down]: 0,
|
||||
[SettingKeyboard.Button_Left]: 0,
|
||||
[SettingKeyboard.Alt_Button_Left]: 0,
|
||||
[SettingKeyboard.Button_Right]: 0,
|
||||
[SettingKeyboard.Alt_Button_Right]: 0,
|
||||
[SettingKeyboard.Button_Action]: 0,
|
||||
[SettingKeyboard.Button_Menu]: 0,
|
||||
[SettingKeyboard.Button_Submit]: 0,
|
||||
|
||||
[SettingKeyboard.Alt_Button_Up]: 0,
|
||||
[SettingKeyboard.Alt_Button_Down]: 0,
|
||||
[SettingKeyboard.Alt_Button_Left]: 0,
|
||||
[SettingKeyboard.Alt_Button_Right]: 0,
|
||||
[SettingKeyboard.Alt_Button_Action]: 0,
|
||||
[SettingKeyboard.Button_Cancel]: 0,
|
||||
[SettingKeyboard.Alt_Button_Cancel]: 0,
|
||||
[SettingKeyboard.Button_Menu]: 0,
|
||||
[SettingKeyboard.Alt_Button_Menu]: 0,
|
||||
[SettingKeyboard.Button_Stats]: 0,
|
||||
[SettingKeyboard.Alt_Button_Stats]: 0,
|
||||
@ -114,7 +117,6 @@ export const settingKeyboardDefaults: SettingDefaults = {
|
||||
[SettingKeyboard.Alt_Button_Speed_Up]: 0,
|
||||
[SettingKeyboard.Button_Slow_Down]: 0,
|
||||
[SettingKeyboard.Alt_Button_Slow_Down]: 0,
|
||||
[SettingKeyboard.Button_Submit]: 0,
|
||||
[SettingKeyboard.Alt_Button_Submit]: 0,
|
||||
};
|
||||
|
||||
|
@ -22,6 +22,23 @@ export interface LayoutConfig {
|
||||
bindingSettings: Array<String>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves elements in the blacklist to the top of the original array.
|
||||
* @param {string[]} originalArray - The original array of strings.
|
||||
* @param {string[]} blacklist - The array of strings to be moved to the top.
|
||||
* @returns {string[]} - The new array with blacklisted elements at the top.
|
||||
*/
|
||||
function moveBlacklistedToTop(originalArray, blacklist) {
|
||||
// Filter the original array to get blacklisted elements
|
||||
const blacklistedElements = originalArray.filter(element => blacklist.includes(element.toUpperCase()));
|
||||
|
||||
// Filter the original array to get non-blacklisted elements
|
||||
const nonBlacklistedElements = originalArray.filter(element => !blacklist.includes(element.toUpperCase()));
|
||||
|
||||
// Concatenate the blacklisted elements and the non-blacklisted elements
|
||||
return blacklistedElements.concat(nonBlacklistedElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract class for handling UI elements related to settings.
|
||||
*/
|
||||
@ -153,9 +170,9 @@ export default abstract class AbstractSettingsUiUiHandler extends UiHandler {
|
||||
const specificBindingKeys = [...commonSettingKeys, ...Object.keys(config.settings)];
|
||||
// Fetch default values for these settings and prepare to highlight selected options.
|
||||
const optionCursors = Object.values(Object.keys(this.settingDeviceDefaults).filter(s => specificBindingKeys.includes(s)).map(k => this.settingDeviceDefaults[k]));
|
||||
|
||||
// Filter out settings that are not relevant to the current gamepad configuration.
|
||||
const settingFiltered = Object.keys(this.settingDevice).filter(_key => specificBindingKeys.includes(this.settingDevice[_key]));
|
||||
const unsortedSettingFiltered = Object.keys(this.settingDevice).filter(_key => specificBindingKeys.includes(this.settingDevice[_key]))
|
||||
const settingFiltered = moveBlacklistedToTop(unsortedSettingFiltered, this.settingBlacklisted);
|
||||
// Loop through the filtered settings to manage display and options.
|
||||
|
||||
settingFiltered.forEach((setting, s) => {
|
||||
@ -163,7 +180,8 @@ export default abstract class AbstractSettingsUiUiHandler extends UiHandler {
|
||||
let settingName = setting.replace(/\_/g, ' ');
|
||||
|
||||
// Create and add a text object for the setting name to the scene.
|
||||
const labelStyle = this.settingBlacklisted.includes(this.settingDevice[setting]) ? TextStyle.SETTINGS_LOCKED : TextStyle.SETTINGS_LABEL
|
||||
const isLock = this.settingBlacklisted.includes(this.settingDevice[setting]);
|
||||
const labelStyle = isLock ? TextStyle.SETTINGS_LOCKED : TextStyle.SETTINGS_LABEL
|
||||
settingLabels[s] = addTextObject(this.scene, 8, 28 + s * 16, settingName, labelStyle);
|
||||
settingLabels[s].setOrigin(0, 0);
|
||||
optionsContainer.add(settingLabels[s]);
|
||||
@ -177,7 +195,7 @@ export default abstract class AbstractSettingsUiUiHandler extends UiHandler {
|
||||
if (bindingSettings.includes(this.settingDevice[setting])) {
|
||||
// Create a label for non-null options, typically indicating actionable options like 'change'.
|
||||
if (o) {
|
||||
const valueLabel = addTextObject(this.scene, 0, 0, option, TextStyle.WINDOW);
|
||||
const valueLabel = addTextObject(this.scene, 0, 0, isLock ? '' : option, TextStyle.WINDOW);
|
||||
valueLabel.setOrigin(0, 0);
|
||||
optionsContainer.add(valueLabel);
|
||||
valueLabels.push(valueLabel);
|
||||
|
Loading…
Reference in New Issue
Block a user