mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
Disable egg gacha in rewards (#3304)
* chore: Refactor excludedMenus logic in MenuUiHandler * Refactor excludedMenus logic in MenuUiHandler * Update src/ui/menu-ui-handler.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Refactor excludedMenus logic in MenuUiHandler * chore: Add setup method to MenuUiHandler * Refactor excludedMenus logic in MenuUiHandler --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
This commit is contained in:
parent
52ef92ae78
commit
3a87c8657f
@ -40,8 +40,8 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
|
||||
private cursorObj: Phaser.GameObjects.Image;
|
||||
|
||||
protected ignoredMenuOptions: MenuOptions[];
|
||||
protected menuOptions: MenuOptions[];
|
||||
private excludedMenus: () => ConditionalMenu[];
|
||||
private menuOptions: MenuOptions[];
|
||||
|
||||
protected manageDataConfig: OptionSelectConfig;
|
||||
protected communityConfig: OptionSelectConfig;
|
||||
@ -52,13 +52,19 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode);
|
||||
|
||||
this.ignoredMenuOptions = !bypassLogin
|
||||
? [ ]
|
||||
: [ MenuOptions.LOG_OUT ];
|
||||
this.menuOptions = Utils.getEnumKeys(MenuOptions).map(m => parseInt(MenuOptions[m]) as MenuOptions).filter(m => !this.ignoredMenuOptions.includes(m));
|
||||
this.excludedMenus = () => [
|
||||
{ condition: [Mode.COMMAND, Mode.TITLE].includes(mode ?? Mode.TITLE), options: [ MenuOptions.EGG_GACHA, MenuOptions.EGG_LIST] },
|
||||
{ condition: bypassLogin, options: [ MenuOptions.LOG_OUT ] }
|
||||
];
|
||||
|
||||
this.menuOptions = Utils.getEnumKeys(MenuOptions)
|
||||
.map(m => parseInt(MenuOptions[m]) as MenuOptions)
|
||||
.filter(m => {
|
||||
return !this.excludedMenus().some(exclusion => exclusion.condition && exclusion.options.includes(m));
|
||||
});
|
||||
}
|
||||
|
||||
setup() {
|
||||
setup(): void {
|
||||
const ui = this.getUi();
|
||||
// wiki url directs based on languges available on wiki
|
||||
const lang = i18next.resolvedLanguage.substring(0,2);
|
||||
@ -80,10 +86,25 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
this.menuOverlay.setOrigin(0,0);
|
||||
this.menuContainer.add(this.menuOverlay);
|
||||
|
||||
const menuMessageText = addTextObject(this.scene, 8, 8, "", TextStyle.WINDOW, { maxLines: 2 });
|
||||
menuMessageText.setName("menu-message");
|
||||
menuMessageText.setWordWrapWidth(1224);
|
||||
menuMessageText.setOrigin(0, 0);
|
||||
this.menuContainer.add(this.bgmBar);
|
||||
|
||||
this.menuContainer.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
const ui = this.getUi();
|
||||
this.excludedMenus = () => [
|
||||
{ condition: ![Mode.COMMAND, Mode.TITLE].includes(ui.getModeChain()[0]), options: [ MenuOptions.EGG_GACHA, MenuOptions.EGG_LIST] },
|
||||
{ condition: bypassLogin, options: [ MenuOptions.LOG_OUT ] }
|
||||
];
|
||||
|
||||
this.menuOptions = Utils.getEnumKeys(MenuOptions)
|
||||
.map(m => parseInt(MenuOptions[m]) as MenuOptions)
|
||||
.filter(m => {
|
||||
return !this.excludedMenus().some(exclusion => exclusion.condition && exclusion.options.includes(m));
|
||||
});
|
||||
|
||||
this.optionSelectText = addTextObject(this.scene, 0, 0, this.menuOptions.map(o => `${i18next.t(`menuUiHandler:${MenuOptions[o]}`)}`).join("\n"), TextStyle.WINDOW, { maxLines: this.menuOptions.length });
|
||||
this.optionSelectText.setLineSpacing(12);
|
||||
@ -108,10 +129,12 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
menuMessageBox.setOrigin(0, 0);
|
||||
this.menuMessageBoxContainer.add(menuMessageBox);
|
||||
|
||||
const menuMessageText = addTextObject(this.scene, 8, 8, "", TextStyle.WINDOW, { maxLines: 2 });
|
||||
menuMessageText.setName("menu-message");
|
||||
menuMessageText.setWordWrapWidth(1224);
|
||||
menuMessageText.setOrigin(0, 0);
|
||||
this.menuMessageBoxContainer.add(menuMessageText);
|
||||
|
||||
this.menuContainer.add(this.bgmBar);
|
||||
|
||||
this.message = menuMessageText;
|
||||
|
||||
this.menuContainer.add(this.menuMessageBoxContainer);
|
||||
@ -270,16 +293,19 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
xOffset: 98,
|
||||
options: communityOptions
|
||||
};
|
||||
|
||||
this.setCursor(0);
|
||||
|
||||
this.menuContainer.setVisible(false);
|
||||
}
|
||||
|
||||
show(args: any[]): boolean {
|
||||
|
||||
this.render();
|
||||
super.show(args);
|
||||
|
||||
this.menuOptions = Utils.getEnumKeys(MenuOptions)
|
||||
.map(m => parseInt(MenuOptions[m]) as MenuOptions)
|
||||
.filter(m => {
|
||||
return !this.excludedMenus().some(exclusion => exclusion.condition && exclusion.options.includes(m));
|
||||
});
|
||||
|
||||
this.menuContainer.setVisible(true);
|
||||
this.setCursor(0);
|
||||
|
||||
@ -305,7 +331,7 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
|
||||
if (button === Button.ACTION) {
|
||||
let adjustedCursor = this.cursor;
|
||||
for (const imo of this.ignoredMenuOptions) {
|
||||
for (const imo of this.excludedMenus().find(e => e.condition).options.sort()) {
|
||||
if (adjustedCursor >= imo) {
|
||||
adjustedCursor++;
|
||||
} else {
|
||||
@ -506,3 +532,8 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
this.cursorObj = null;
|
||||
}
|
||||
}
|
||||
|
||||
interface ConditionalMenu {
|
||||
condition: boolean;
|
||||
options: MenuOptions[];
|
||||
}
|
||||
|
@ -536,4 +536,8 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||
this.revertMode().then(success => Utils.executeIf(success, this.revertModes).then(() => resolve()));
|
||||
});
|
||||
}
|
||||
|
||||
public getModeChain(): Mode[] {
|
||||
return this.modeChain;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user