Minor UI changes

This commit is contained in:
Flashfyre 2024-02-06 23:11:00 -05:00
parent e62bb6e225
commit 05f114c8a4
9 changed files with 34 additions and 74 deletions

View File

@ -1128,7 +1128,6 @@ export default class BattleScene extends Phaser.Scene {
case Mode.BIOME_SELECT:
case Mode.STARTER_SELECT:
case Mode.CONFIRM:
case Mode.GAME_MODE_SELECT:
this.ui.setOverlayMode(Mode.MENU);
inputSuccess = true;
break;

View File

@ -676,7 +676,7 @@ export class GameData {
}, () => {
this.scene.ui.revertMode();
this.scene.ui.showText(null, 0);
}, false, 98);
}, false, -98);
});
};
})((e.target as any).files[0]);

View File

@ -6,6 +6,7 @@ import { addWindow } from "./window";
export interface OptionSelectConfig {
xOffset?: number;
yOffset?: number;
options: OptionSelectItem[];
}
@ -58,7 +59,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
this.optionSelectText = addTextObject(this.scene, 0, 0, options.map(o => o.label).join('\n'), TextStyle.WINDOW, { maxLines: options.length });
this.optionSelectText.setLineSpacing(12);
this.optionSelectContainer.add(this.optionSelectText);
this.optionSelectContainer.x = (this.scene.game.canvas.width / 6) - 1 - (this.config?.xOffset || 0);
this.optionSelectContainer.setPosition((this.scene.game.canvas.width / 6) - 1 - (this.config?.xOffset || 0), -48 + (this.config?.yOffset || 0));
this.optionSelectBg.width = Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth());
this.optionSelectBg.height = this.getWindowHeight();

View File

@ -31,11 +31,12 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
super.show([ config ]);
this.switchCheck = args.length >= 3 && args[2] as boolean;
this.switchCheck = args.length >= 3 && args[2] !== null && args[2] as boolean;
const xOffset = (args.length >= 4 ? -args[3] as number : 0);
const xOffset = (args.length >= 4 && args[3] !== null ? args[3] as number : 0);
const yOffset = (args.length >= 5 && args[4] !== null ? args[4] as number : 0);
this.optionSelectContainer.x = (this.scene.game.canvas.width / 6) - 1 + xOffset;
this.optionSelectContainer.setPosition((this.scene.game.canvas.width / 6) - 1 + xOffset, -48 + yOffset);
this.setCursor(this.switchCheck ? this.switchCheckCursor : 0);

View File

@ -1,58 +0,0 @@
import BattleScene from "../battle-scene";
import { GameMode, gameModeNames } from "../game-mode";
import { Unlockables } from "../system/unlockables";
import AbstractOptionSelectUiHandler, { OptionSelectConfig, OptionSelectItem } from "./abstact-option-select-ui-handler";
import { Mode } from "./ui";
export default class GameModeSelectUiHandler extends AbstractOptionSelectUiHandler {
constructor(scene: BattleScene) {
super(scene, Mode.GAME_MODE_SELECT);
}
getWindowWidth(): integer {
return 104;
}
show(args: any[]): boolean {
if (args.length === 2 && args[0] instanceof Function && args[1] instanceof Function) {
const options: OptionSelectItem[] = [
{
label: gameModeNames[GameMode.CLASSIC],
handler: () => args[0](GameMode.CLASSIC)
}
];
if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
options.push({
label: gameModeNames[GameMode.ENDLESS],
handler: () => args[0](GameMode.ENDLESS)
});
if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) {
options.push({
label: gameModeNames[GameMode.SPLICED_ENDLESS],
handler: () => args[0](GameMode.SPLICED_ENDLESS)
});
}
}
options.push({
label: 'Cancel',
handler: args[1]
})
const config: OptionSelectConfig = {
options: options
};
super.show([ config ]);
this.optionSelectContainer.setVisible(true);
this.setCursor(0);
return true;
}
return false;
}
}

View File

@ -198,7 +198,7 @@ export default class MenuUiHandler extends MessageUiHandler {
ui.setOverlayMode(Mode.CONFIRM, doLogout, () => {
ui.revertMode();
ui.showText(null, 0);
}, false, 98);
}, false, -98);
});
} else
doLogout();

View File

@ -6,7 +6,7 @@ import { Mode } from "./ui";
import MessageUiHandler from "./message-ui-handler";
import { Gender, getGenderColor, getGenderSymbol } from "../data/gender";
import { allAbilities } from "../data/ability";
import { GameMode } from "../game-mode";
import { GameMode, gameModeNames } from "../game-mode";
import { Unlockables } from "../system/unlockables";
import { GrowthRate, getGrowthRateColor } from "../data/exp";
import { DexAttr, DexEntry } from "../system/game-data";
@ -463,7 +463,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
ui.setMode(Mode.STARTER_SELECT);
}
}
]
],
yOffset: 47
});
success = true;
}
@ -925,10 +926,30 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
};
if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
ui.setMode(Mode.STARTER_SELECT);
ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.GAME_MODE_SELECT, startRun, cancel));
const options = [
{
label: gameModeNames[GameMode.CLASSIC],
handler: () => startRun(GameMode.CLASSIC)
},
{
label: gameModeNames[GameMode.ENDLESS],
handler: () => startRun(GameMode.ENDLESS)
}
];
if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) {
options.push({
label: gameModeNames[GameMode.SPLICED_ENDLESS],
handler: () => startRun(GameMode.SPLICED_ENDLESS)
});
}
options.push({
label: 'Cancel',
handler: () => cancel()
});
ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, yOffset: 19 }));
} else
startRun(GameMode.CLASSIC);
}, cancel);
}, cancel, null, null, 19);
});
return true;

View File

@ -100,7 +100,7 @@ function getTextStyleOptions(style: TextStyle, extraStyleOptions?: Phaser.Types.
if (extraStyleOptions) {
if (extraStyleOptions.fontSize) {
const sizeRatio = parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / parseInt(styleOptions.fontSize.slice(0, -2));
const sizeRatio = parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / parseInt(styleOptions.fontSize.toString().slice(0, -2));
shadowSize *= sizeRatio;
}
styleOptions = Object.assign(styleOptions, extraStyleOptions);

View File

@ -13,7 +13,6 @@ import StarterSelectUiHandler from './starter-select-ui-handler';
import EvolutionSceneHandler from './evolution-scene-handler';
import BiomeSelectUiHandler from './biome-select-ui-handler';
import TargetSelectUiHandler from './target-select-ui-handler';
import GameModeSelectUiHandler from './game-mode-select-ui-handler';
import SettingsUiHandler from './settings-ui-handler';
import { TextStyle, addTextObject } from './text';
import AchvBar from './achv-bar';
@ -46,7 +45,6 @@ export enum Mode {
EGG_HATCH_SCENE,
CONFIRM,
OPTION_SELECT,
GAME_MODE_SELECT,
MENU,
SETTINGS,
ACHIEVEMENTS,
@ -72,7 +70,6 @@ const transitionModes = [
const noTransitionModes = [
Mode.CONFIRM,
Mode.OPTION_SELECT,
Mode.GAME_MODE_SELECT,
Mode.MENU,
Mode.SETTINGS,
Mode.ACHIEVEMENTS,
@ -117,7 +114,6 @@ export default class UI extends Phaser.GameObjects.Container {
new EggHatchSceneHandler(scene),
new ConfirmUiHandler(scene),
new OptionSelectUiHandler(scene),
new GameModeSelectUiHandler(scene),
new MenuUiHandler(scene),
new SettingsUiHandler(scene),
new AchvsUiHandler(scene),