Add UI reskin by LJ Birdman (WiP)

This commit is contained in:
Flashfyre committed 2024-03-31 16:49:53 -04:00
1 parent f789860e96
commit 0200a2688a
240 files changed
+2594 -149

No files matched your search

+16 -2
View File
@@ -55,6 +55,7 @@ import DamageNumberHandler from './field/damage-number-handler';
import PokemonInfoContainer from './ui/pokemon-info-container';
import { biomeDepths } from './data/biomes';
import { initTouchControls } from './touch-controls';
import { UiTheme } from './enums/ui-theme';
export const bypassLogin = false;
@@ -105,7 +106,8 @@ export default class BattleScene extends Phaser.Scene {
public damageNumbersMode: integer = 0;
public showLevelUpStats: boolean = true;
public enableTutorials: boolean = true;
public windowType: integer = 1;
public uiTheme: UiTheme = UiTheme.DEFAULT;
public windowType: integer = 9;
public experimentalSprites: boolean = false;
public fusionPaletteSwaps: boolean = true;
public enableTouchControls: boolean = false;
@@ -191,6 +193,10 @@ export default class BattleScene extends Phaser.Scene {
if (!filename)
filename = `${key}.png`;
this.load.image(key, `images/${folder}/${filename}`);
if (this.uiTheme && folder.startsWith('ui')) {
folder = folder.replace('ui', 'ui/legacy');
this.load.image(`${key}_legacy`, `images/${folder}/${filename}`);
}
}
loadAtlas(key: string, folder: string, filenameRoot?: string) {
@@ -199,6 +205,10 @@ export default class BattleScene extends Phaser.Scene {
if (folder)
folder += '/';
this.load.atlas(key, `images/${folder}${filenameRoot}.png`, `images/${folder}/${filenameRoot}.json`);
if (this.uiTheme && folder.startsWith('ui')) {
folder = folder.replace('ui', 'ui/legacy');
this.load.atlas(`${key}_legacy`, `images/${folder}${filenameRoot}.png`, `images/${folder}/${filenameRoot}.json`);
}
}
loadPokemonAtlas(key: string, atlasPath: string, experimental?: boolean) {
@@ -225,6 +235,10 @@ export default class BattleScene extends Phaser.Scene {
if (!filename)
filename = `${key}.png`;
this.load.spritesheet(key, `images/${folder}/${filename}`, { frameWidth: size, frameHeight: size });
if (this.uiTheme && folder.startsWith('ui')) {
folder = folder.replace('ui', 'ui/legacy');
this.load.spritesheet(`${key}_legacy`, `images/${folder}/${filename}`, { frameWidth: size, frameHeight: size });
}
}
loadSe(key: string, folder?: string, filenames?: string | string[]) {
@@ -401,7 +415,7 @@ export default class BattleScene extends Phaser.Scene {
this.loadImage('egg_list_bg', 'ui');
for (let i = 0; i < 10; i++)
this.loadAtlas(`pokemon_icons_${i}`, 'ui');
this.loadAtlas(`pokemon_icons_${i}`, '');
this.loadSe('select');
this.loadSe('menu_open');
+1 -1
View File
@@ -43,7 +43,7 @@ export function getNatureName(nature: Nature, includeStatEffects: boolean = fals
else if (multiplier < 1)
decreasedStat = stat;
}
const textStyle = forStarterSelect ? TextStyle.SUMMARY : TextStyle.WINDOW;
const textStyle = forStarterSelect ? TextStyle.SUMMARY_ALT : TextStyle.WINDOW;
if (increasedStat && decreasedStat)
ret = `${getBBCodeFrag(`${ret}${!forStarterSelect ? '\n' : ' '}(`, textStyle)}${getBBCodeFrag(`+${getStatName(increasedStat, true)}`, TextStyle.SUMMARY_PINK)}${getBBCodeFrag('/', textStyle)}${getBBCodeFrag(`-${getStatName(decreasedStat, true)}`, TextStyle.SUMMARY_BLUE)}${getBBCodeFrag(')', textStyle)}`;
else
-1
View File
@@ -1,4 +1,3 @@
export enum BattleSpec {
DEFAULT,
FINAL_BOSS
+4
View File
@@ -0,0 +1,4 @@
export enum UiTheme {
DEFAULT,
LEGACY
}
+6
View File
@@ -10,6 +10,7 @@ export enum Setting {
SE_Volume = "SE_VOLUME",
Damage_Numbers = "DAMAGE_NUMBERS",
Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS",
UI_Theme = "UI_THEME",
Window_Type = "WINDOW_TYPE",
Tutorials = "TUTORIALS",
Sprite_Set = "SPRITE_SET",
@@ -34,6 +35,7 @@ export const settingOptions: SettingOptions = {
[Setting.SE_Volume]: new Array(11).fill(null).map((_, i) => i ? (i * 10).toString() : 'Mute'),
[Setting.Damage_Numbers]: [ 'Off', 'Simple', 'Fancy' ],
[Setting.Show_Stats_on_Level_Up]: [ 'Off', 'On' ],
[Setting.UI_Theme]: [ 'Default', 'Legacy' ],
[Setting.Window_Type]: new Array(4).fill(null).map((_, i) => (i + 1).toString()),
[Setting.Tutorials]: [ 'Off', 'On' ],
[Setting.Sprite_Set]: [ 'Consistent', 'Prioritize Animation' ],
@@ -50,6 +52,7 @@ export const settingDefaults: SettingDefaults = {
[Setting.SE_Volume]: 10,
[Setting.Damage_Numbers]: 0,
[Setting.Show_Stats_on_Level_Up]: 1,
[Setting.UI_Theme]: 0,
[Setting.Window_Type]: 0,
[Setting.Tutorials]: 1,
[Setting.Sprite_Set]: 0,
@@ -82,6 +85,9 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
case Setting.Show_Stats_on_Level_Up:
scene.showLevelUpStats = settingOptions[setting][value] === 'On';
break;
case Setting.UI_Theme:
scene.uiTheme = parseInt(settingOptions[setting][value]);
break;
case Setting.Window_Type:
updateWindowType(scene, parseInt(settingOptions[setting][value]));
break;
+1 -1
View File
@@ -36,7 +36,7 @@ export default class AchvBar extends Phaser.GameObjects.Container {
this.scoreText.setOrigin(1, 0);
this.add(this.scoreText);
this.descriptionText = addTextObject(this.scene, 43, 16, '', TextStyle.WINDOW, { fontSize: '72px' });
this.descriptionText = addTextObject(this.scene, 43, 16, '', TextStyle.WINDOW_ALT, { fontSize: '72px' });
this.descriptionText.setOrigin(0, 0);
this.add(this.descriptionText);
+17 -6
View File
@@ -38,6 +38,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
private levelNumbersContainer: Phaser.GameObjects.Container;
private hpNumbersContainer: Phaser.GameObjects.Container;
private expBar: Phaser.GameObjects.Image;
private expMaskRect: Phaser.GameObjects.Graphics;
constructor(scene: Phaser.Scene, x: number, y: number, player: boolean) {
super(scene, x, y);
@@ -119,7 +120,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
this.hpBarSegmentDividers = [];
this.levelNumbersContainer = this.scene.add.container(9.5, 0);
this.levelNumbersContainer = this.scene.add.container(9.5, (this.scene as BattleScene).uiTheme ? 0 : -0.5);
this.levelContainer.add(this.levelNumbersContainer);
if (this.player) {
@@ -128,10 +129,20 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
const expBar = this.scene.add.image(-98, 18, 'overlay_exp');
expBar.setOrigin(0);
expBar.setScale(0, 1);
this.add(expBar);
const expMaskRect = this.scene.make.graphics({});
expMaskRect.setScale(6);
expMaskRect.fillStyle(0xFFFFFF);
expMaskRect.beginPath();
expMaskRect.fillRect(127, 126, 85, 2);
const expMask = expMaskRect.createGeometryMask();
expBar.setMask(expMask);
this.expBar = expBar;
this.expMaskRect = expMaskRect;
}
}
@@ -185,7 +196,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
this.shinyIcon.setVisible(pokemon.isShiny());
if (this.player) {
this.expBar.setScale(pokemon.levelExp / getLevelTotalExp(pokemon.level, pokemon.species.growthRate), 1);
this.expMaskRect.x = (pokemon.levelExp / getLevelTotalExp(pokemon.level, pokemon.species.growthRate)) * 510;
this.lastExp = pokemon.exp;
this.lastLevelExp = pokemon.levelExp;
}
@@ -402,9 +413,9 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
if (duration)
(this.scene as BattleScene).playSound('exp');
this.scene.tweens.add({
targets: this.expBar,
targets: this.expMaskRect,
ease: 'Sine.easeIn',
scaleX: ratio,
x: ratio * 510,
duration: duration,
onComplete: () => {
if (!this.scene)
@@ -415,7 +426,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
(this.scene as BattleScene).playSound('level_up');
this.setLevel(this.lastLevel);
this.scene.time.delayedCall(500 * levelDurationMultiplier, () => {
this.expBar.setScale(0, 1);
this.expMaskRect.x = 0;
this.updateInfo(pokemon, instant).then(() => resolve());
});
return;
+2 -2
View File
@@ -36,7 +36,7 @@ export default class EggListUiHandler extends MessageUiHandler {
bgColor.setOrigin(0, 0);
this.eggListContainer.add(bgColor);
const eggListBg = this.scene.add.image(1, 1, 'egg_list_bg');
const eggListBg = this.scene.add.image(0, 0, 'egg_list_bg');
eggListBg.setOrigin(0, 0);
this.eggListContainer.add(eggListBg);
@@ -48,7 +48,7 @@ export default class EggListUiHandler extends MessageUiHandler {
this.iconAnimHandler = new PokemonIconAnimHandler();
this.iconAnimHandler.setup(this.scene);
this.eggNameText = addTextObject(this.scene, 6, 66, '', TextStyle.SUMMARY);
this.eggNameText = addTextObject(this.scene, 8, 66, '', TextStyle.SUMMARY);
this.eggNameText.setOrigin(0, 0);
this.eggListContainer.add(this.eggNameText);
+2 -2
View File
@@ -66,8 +66,8 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
});
this.errorMessage = addTextObject(this.scene, 10, (hasTitle ? 31 : 5) + 20 * (fields.length - 1) + 16, '', TextStyle.TOOLTIP_CONTENT);
this.errorMessage.setColor(getTextColor(TextStyle.SUMMARY_PINK));
this.errorMessage.setShadowColor(getTextColor(TextStyle.SUMMARY_PINK, true));
this.errorMessage.setColor(this.getTextColor(TextStyle.SUMMARY_PINK));
this.errorMessage.setShadowColor(this.getTextColor(TextStyle.SUMMARY_PINK, true));
this.errorMessage.setVisible(false);
this.modalContainer.add(this.errorMessage);
}
+6 -5
View File
@@ -316,8 +316,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
const canReroll = this.scene.money >= this.rerollCost;
this.rerollCostText.setText(`₽${this.rerollCost.toLocaleString('en-US')}`);
this.rerollCostText.setColor(getTextColor(canReroll ? TextStyle.MONEY : TextStyle.PARTY_RED));
this.rerollCostText.setShadowColor(getTextColor(canReroll ? TextStyle.MONEY : TextStyle.PARTY_RED, true));
this.rerollCostText.setColor(this.getTextColor(canReroll ? TextStyle.MONEY : TextStyle.PARTY_RED));
this.rerollCostText.setShadowColor(this.getTextColor(canReroll ? TextStyle.MONEY : TextStyle.PARTY_RED, true));
}
clear() {
@@ -556,10 +556,11 @@ class ModifierOption extends Phaser.GameObjects.Container {
}
updateCostText(): void {
const textStyle = this.modifierTypeOption.cost <= (this.scene as BattleScene).money ? TextStyle.MONEY : TextStyle.PARTY_RED;
const scene = this.scene as BattleScene;
const textStyle = this.modifierTypeOption.cost <= scene.money ? TextStyle.MONEY : TextStyle.PARTY_RED;
this.itemCostText.setText(`₽${this.modifierTypeOption.cost.toLocaleString('en-US')}`);
this.itemCostText.setColor(getTextColor(textStyle));
this.itemCostText.setShadowColor(getTextColor(textStyle, true));
this.itemCostText.setColor(getTextColor(textStyle, false, scene.uiTheme));
this.itemCostText.setShadowColor(getTextColor(textStyle, true, scene.uiTheme));
}
}
+1 -1
View File
@@ -172,7 +172,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
let changed = super.setCursor(cursor);
if (!this.cursorObj) {
this.cursorObj = this.scene.add.nineslice(0, 0, 'select_cursor_highlight_thick', null, 296, 44, 2, 2, 2, 2);
this.cursorObj = this.scene.add.nineslice(0, 0, 'select_cursor_highlight_thick', null, 296, 44, 6, 6, 6, 6);
this.cursorObj.setOrigin(0, 0);
this.sessionSlotsContainer.add(this.cursorObj);
}
+11 -7
View File
@@ -1,7 +1,7 @@
import BattleScene, { Button } from "../battle-scene";
import { Setting, settingDefaults, settingOptions } from "../system/settings";
import { hasTouchscreen, isMobile } from "../touch-controls";
import { TextStyle, addTextObject, getTextColor } from "./text";
import { TextStyle, addTextObject } from "./text";
import { Mode } from "./ui";
import UiHandler from "./ui-handler";
import { addWindow } from "./window";
@@ -48,7 +48,11 @@ export default class SettingsUiHandler extends UiHandler {
this.optionValueLabels = [];
Object.keys(Setting).forEach((setting, s) => {
this.settingLabels[s] = addTextObject(this.scene, 8, 28 + s * 16, setting.replace(/\_/g, ' '), TextStyle.SETTINGS_LABEL);
let settingName = setting.replace(/\_/g, ' ');
if (Setting[setting] === Setting.UI_Theme)
settingName += ' (Requires Reload)';
this.settingLabels[s] = addTextObject(this.scene, 8, 28 + s * 16, settingName, TextStyle.SETTINGS_LABEL);
this.settingLabels[s].setOrigin(0, 0);
this.optionsContainer.add(this.settingLabels[s]);
@@ -157,7 +161,7 @@ export default class SettingsUiHandler extends UiHandler {
const ret = super.setCursor(cursor);
if (!this.cursorObj) {
this.cursorObj = this.scene.add.nineslice(0, 0, 'select_cursor_highlight', null, (this.scene.game.canvas.width / 6) - 10, 16, 1, 1, 1, 1);
this.cursorObj = this.scene.add.nineslice(0, 0, 'summary_moves_cursor', null, (this.scene.game.canvas.width / 6) - 10, 16, 1, 1, 1, 1);
this.cursorObj.setOrigin(0, 0);
this.optionsContainer.add(this.cursorObj);
}
@@ -178,14 +182,14 @@ export default class SettingsUiHandler extends UiHandler {
const lastCursor = this.optionCursors[settingIndex];
const lastValueLabel = this.optionValueLabels[settingIndex][lastCursor];
lastValueLabel.setColor(getTextColor(TextStyle.WINDOW));
lastValueLabel.setShadowColor(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(getTextColor(TextStyle.SETTINGS_SELECTED));
newValueLabel.setShadowColor(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);
+28 -23
View File
@@ -127,7 +127,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
bgColor.setOrigin(0, 0);
this.starterSelectContainer.add(bgColor);
const starterSelectBg = this.scene.add.image(1, 1, 'starter_select_bg');
const starterSelectBg = this.scene.add.image(0, 0, 'starter_select_bg');
starterSelectBg.setOrigin(0, 0);
this.starterSelectContainer.add(starterSelectBg);
@@ -136,10 +136,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.shinyOverlay.setVisible(false);
this.starterSelectContainer.add(this.shinyOverlay);
const starterContainerWindow = addWindow(this.scene, 141, 1, 178, 178);
this.starterSelectContainer.add(addWindow(this.scene, 107, 1, 34, 58));
this.starterSelectContainer.add(addWindow(this.scene, 107, 59, 34, 91));
this.starterSelectContainer.add(addWindow(this.scene, 107, 145, 34, 34, true));
this.starterSelectContainer.add(addWindow(this.scene, 141, 1, 178, 178));
this.starterSelectContainer.add(starterContainerWindow);
if (!this.scene.uiTheme)
starterContainerWindow.setVisible(false);
this.iconAnimHandler = new PokemonIconAnimHandler();
this.iconAnimHandler.setup(this.scene);
@@ -152,7 +157,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonNameText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonNameText);
this.pokemonGrowthRateLabelText = addTextObject(this.scene, 8, 106, 'Growth Rate:', TextStyle.SUMMARY, { fontSize: '36px' });
this.pokemonGrowthRateLabelText = addTextObject(this.scene, 8, 106, 'Growth Rate:', TextStyle.SUMMARY_ALT, { fontSize: '36px' });
this.pokemonGrowthRateLabelText.setOrigin(0, 0);
this.pokemonGrowthRateLabelText.setVisible(false);
this.starterSelectContainer.add(this.pokemonGrowthRateLabelText);
@@ -161,38 +166,38 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonGrowthRateText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonGrowthRateText);
this.pokemonGenderText = addTextObject(this.scene, 96, 112, '', TextStyle.SUMMARY);
this.pokemonGenderText = addTextObject(this.scene, 96, 112, '', TextStyle.SUMMARY_ALT);
this.pokemonGenderText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonGenderText);
this.pokemonUncaughtText = addTextObject(this.scene, 6, 126, 'Uncaught', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonUncaughtText = addTextObject(this.scene, 6, 126, 'Uncaught', TextStyle.SUMMARY_ALT, { fontSize: '56px' });
this.pokemonUncaughtText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonUncaughtText);
this.pokemonAbilityLabelText = addTextObject(this.scene, 6, 126, 'Ability:', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonAbilityLabelText = addTextObject(this.scene, 6, 126, 'Ability:', TextStyle.SUMMARY_ALT, { fontSize: '56px' });
this.pokemonAbilityLabelText.setOrigin(0, 0);
this.pokemonAbilityLabelText.setVisible(false);
this.starterSelectContainer.add(this.pokemonAbilityLabelText);
this.pokemonAbilityText = addTextObject(this.scene, 30, 126, '', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonAbilityText = addTextObject(this.scene, 30, 126, '', TextStyle.SUMMARY_ALT, { fontSize: '56px' });
this.pokemonAbilityText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonAbilityText);
this.pokemonNatureLabelText = addTextObject(this.scene, 6, 135, 'Nature:', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonNatureLabelText = addTextObject(this.scene, 6, 135, 'Nature:', TextStyle.SUMMARY_ALT, { fontSize: '56px' });
this.pokemonNatureLabelText.setOrigin(0, 0);
this.pokemonNatureLabelText.setVisible(false);
this.starterSelectContainer.add(this.pokemonNatureLabelText);
this.pokemonNatureText = addBBCodeTextObject(this.scene, 30, 135, '', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonNatureText = addBBCodeTextObject(this.scene, 30, 135, '', TextStyle.SUMMARY_ALT, { fontSize: '56px' });
this.pokemonNatureText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonNatureText);
this.pokemonCaughtCountLabelText = addTextObject(this.scene, 6, 144, 'Caught/Hatched:', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonCaughtCountLabelText = addTextObject(this.scene, 6, 144, 'Caught/Hatched:', TextStyle.SUMMARY_ALT, { fontSize: '56px' });
this.pokemonCaughtCountLabelText.setOrigin(0, 0);
this.pokemonCaughtCountLabelText.setVisible(false);
this.starterSelectContainer.add(this.pokemonCaughtCountLabelText);
this.pokemonCaughtCountText = addTextObject(this.scene, 58, 144, '0/0 (0)', TextStyle.SUMMARY, { fontSize: '56px' });
this.pokemonCaughtCountText = addTextObject(this.scene, 58, 144, '0/0 (0)', TextStyle.SUMMARY_ALT, { fontSize: '56px' });
this.pokemonCaughtCountText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonCaughtCountText);
@@ -256,7 +261,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
startLabel.setOrigin(0.5, 0);
this.starterSelectContainer.add(startLabel);
this.startCursorObj = this.scene.add.nineslice(111, 160, 'select_cursor', null, 26, 15, 1, 1, 1, 1);
this.startCursorObj = this.scene.add.nineslice(111, 160, 'select_cursor', null, 26, 15, 6, 6, 6, 6);
this.startCursorObj.setVisible(false);
this.startCursorObj.setOrigin(0, 0);
this.starterSelectContainer.add(this.startCursorObj);
@@ -355,7 +360,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonEggMovesContainer = this.scene.add.container(102, 85);
this.pokemonEggMovesContainer.setScale(0.375);
const eggMovesLabel = addTextObject(this.scene, -46, 0, 'Egg Moves', TextStyle.SUMMARY);
const eggMovesLabel = addTextObject(this.scene, -46, 0, 'Egg Moves', TextStyle.SUMMARY_ALT);
eggMovesLabel.setOrigin(0.5, 0);
this.pokemonEggMovesContainer.add(eggMovesLabel);
@@ -862,8 +867,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
textStyle = TextStyle.SUMMARY_GOLD;
break;
}
this.starterValueLabels[s].setColor(getTextColor(textStyle));
this.starterValueLabels[s].setShadowColor(getTextColor(textStyle, true));
this.starterValueLabels[s].setColor(this.getTextColor(textStyle));
this.starterValueLabels[s].setShadowColor(this.getTextColor(textStyle, true));
}
this.starterValueLabels[s].setVisible(slotVisible);
this.shinyIcons[s].setVisible(slotVisible && !!(this.scene.gameData.dexData[speciesId].caughtAttr & DexAttr.SHINY));
@@ -1056,8 +1061,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
}
this.shinyOverlay.setVisible(shiny);
this.pokemonNumberText.setColor(getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY));
this.pokemonNumberText.setShadowColor(getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, true));
this.pokemonNumberText.setColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, false));
this.pokemonNumberText.setShadowColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, true));
if (forSeen ? this.speciesStarterDexEntry?.seenAttr : this.speciesStarterDexEntry?.caughtAttr) {
let starterIndex = -1;
@@ -1111,8 +1116,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonAbilityText.setText(allAbilities[ability].name);
const isHidden = ability === this.lastSpecies.abilityHidden;
this.pokemonAbilityText.setColor(getTextColor(!isHidden ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD));
this.pokemonAbilityText.setShadowColor(getTextColor(!isHidden ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true));
this.pokemonAbilityText.setColor(this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD));
this.pokemonAbilityText.setShadowColor(this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD, true));
this.pokemonNatureText.setText(getNatureName(natureIndex as unknown as Nature, true, true));
@@ -1146,8 +1151,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
}
} else {
this.shinyOverlay.setVisible(false);
this.pokemonNumberText.setColor(getTextColor(TextStyle.SUMMARY));
this.pokemonNumberText.setShadowColor(getTextColor(TextStyle.SUMMARY, true));
this.pokemonNumberText.setColor(this.getTextColor(TextStyle.SUMMARY));
this.pokemonNumberText.setShadowColor(this.getTextColor(TextStyle.SUMMARY, true));
this.pokemonGenderText.setText('');
this.pokemonAbilityText.setText('');
this.pokemonNatureText.setText('');
@@ -1200,8 +1205,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
if (newValueStr.startsWith('0.'))
newValueStr = newValueStr.slice(1);
this.valueLimitLabel.setText(`${newValueStr}/10`);
this.valueLimitLabel.setColor(getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK));
this.valueLimitLabel.setShadowColor(getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK, true));
this.valueLimitLabel.setColor(this.getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK));
this.valueLimitLabel.setShadowColor(this.getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK, true));
if (overLimit) {
this.scene.time.delayedCall(Utils.fixedInt(500), () => this.tryUpdateValue());
return false;
+1 -1
View File
@@ -70,7 +70,7 @@ export class StatsContainer extends Phaser.GameObjects.Container {
let label = ivs[i].toString();
if (this.showDiff && originalIvs) {
if (originalIvs[i] < ivs[i])
label += ` ([color=${getTextColor(TextStyle.SUMMARY_BLUE)}][shadow=${getTextColor(TextStyle.SUMMARY_BLUE, true)}]+${ivs[i] - originalIvs[i]}[/shadow][/color])`;
label += ` ([color=${getTextColor(TextStyle.SUMMARY_BLUE, false, (this.scene as BattleScene).uiTheme)}][shadow=${getTextColor(TextStyle.SUMMARY_BLUE, true, (this.scene as BattleScene).uiTheme)}]+${ivs[i] - originalIvs[i]}[/shadow][/color])`;
else
label += ' (-)';
}
+20 -20
View File
@@ -8,7 +8,7 @@ import { TextStyle, addBBCodeTextObject, addTextObject, getBBCodeFrag, getTextCo
import Move, { MoveCategory } from "../data/move";
import { getPokeballAtlasKey } from "../data/pokeball";
import { getGenderColor, getGenderSymbol } from "../data/gender";
import { getLevelTotalExp } from "../data/exp";
import { getLevelRelExp, getLevelTotalExp } from "../data/exp";
import { Stat, getStatName } from "../data/pokemon-stat";
import { PokemonHeldItemModifier } from "../modifier/modifier";
import { StatusEffect } from "../data/status-effect";
@@ -119,11 +119,11 @@ export default class SummaryUiHandler extends UiHandler {
this.pokeball.setOrigin(0, 1);
this.summaryContainer.add(this.pokeball);
this.levelText = addTextObject(this.scene, 36, -18, '', TextStyle.SUMMARY);
this.levelText = addTextObject(this.scene, 36, -17, '', TextStyle.SUMMARY_ALT);
this.levelText.setOrigin(0, 1);
this.summaryContainer.add(this.levelText);
this.genderText = addTextObject(this.scene, 96, -18, '', TextStyle.SUMMARY);
this.genderText = addTextObject(this.scene, 96, -17, '', TextStyle.SUMMARY);
this.genderText.setOrigin(0, 1);
this.summaryContainer.add(this.genderText);
@@ -160,11 +160,11 @@ export default class SummaryUiHandler extends UiHandler {
this.moveEffectContainer.add(moveEffectLabels);
this.movePowerText = addTextObject(this.scene, 99, 27, '0', TextStyle.WINDOW);
this.movePowerText = addTextObject(this.scene, 99, 27, '0', TextStyle.WINDOW_ALT);
this.movePowerText.setOrigin(1, 1);
this.moveEffectContainer.add(this.movePowerText);
this.moveAccuracyText = addTextObject(this.scene, 99, 43, '0', TextStyle.WINDOW);
this.moveAccuracyText = addTextObject(this.scene, 99, 43, '0', TextStyle.WINDOW_ALT);
this.moveAccuracyText.setOrigin(1, 1);
this.moveEffectContainer.add(this.moveAccuracyText);
@@ -206,8 +206,8 @@ export default class SummaryUiHandler extends UiHandler {
this.shinyOverlay.setVisible(this.pokemon.isShiny());
this.numberText.setText(Utils.padInt(this.pokemon.species.speciesId, 4));
this.numberText.setColor(getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD));
this.numberText.setShadowColor(getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true));
this.numberText.setColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD));
this.numberText.setShadowColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true));
this.pokemonSprite.play(this.pokemon.getSpriteKey(true));
this.pokemonSprite.pipelineData['teraColor'] = getTypeRgb(this.pokemon.getTeraType());
@@ -502,7 +502,7 @@ export default class SummaryUiHandler extends UiHandler {
const profileContainer = this.scene.add.container(0, -pageBg.height);
pageContainer.add(profileContainer);
const trainerLabel = addTextObject(this.scene, 7, 12, 'OT/', TextStyle.SUMMARY);
const trainerLabel = addTextObject(this.scene, 7, 12, 'OT/', TextStyle.SUMMARY_ALT);
trainerLabel.setOrigin(0, 0);
profileContainer.add(trainerLabel);
@@ -511,11 +511,11 @@ export default class SummaryUiHandler extends UiHandler {
trainerText.setOrigin(0, 0);
profileContainer.add(trainerText);
const trainerIdText = addTextObject(this.scene, 174, 12, this.scene.gameData.trainerId.toString(), TextStyle.SUMMARY);
const trainerIdText = addTextObject(this.scene, 174, 12, this.scene.gameData.trainerId.toString(), TextStyle.SUMMARY_ALT);
trainerIdText.setOrigin(0, 0);
profileContainer.add(trainerIdText);
const typeLabel = addTextObject(this.scene, 7, 28, 'Type/', TextStyle.WINDOW);
const typeLabel = addTextObject(this.scene, 7, 28, 'Type/', TextStyle.WINDOW_ALT);
typeLabel.setOrigin(0, 0);
profileContainer.add(typeLabel);
@@ -542,11 +542,11 @@ export default class SummaryUiHandler extends UiHandler {
const ability = this.pokemon.getAbility(true);
const abilityNameText = addTextObject(this.scene, 7, 66, ability.name, TextStyle.SUMMARY);
const abilityNameText = addTextObject(this.scene, 7, 66, ability.name, TextStyle.SUMMARY_ALT);
abilityNameText.setOrigin(0, 1);
profileContainer.add(abilityNameText);
const abilityDescriptionText = addTextObject(this.scene, 7, 69, ability.description, TextStyle.WINDOW, { wordWrap: { width: 1224 } });
const abilityDescriptionText = addTextObject(this.scene, 7, 69, ability.description, TextStyle.WINDOW_ALT, { wordWrap: { width: 1224 } });
abilityDescriptionText.setOrigin(0, 0);
profileContainer.add(abilityDescriptionText);
@@ -574,9 +574,9 @@ export default class SummaryUiHandler extends UiHandler {
});
}
let memoString = `${getBBCodeFrag(Utils.toReadableString(Nature[this.pokemon.nature]), TextStyle.SUMMARY_RED)}${getBBCodeFrag(' nature,', TextStyle.WINDOW)}\n${getBBCodeFrag(`${this.pokemon.metBiome === -1 ? 'apparently ' : ''}met at Lv`, TextStyle.WINDOW)}${getBBCodeFrag(this.pokemon.metLevel.toString(), TextStyle.SUMMARY_RED)}${getBBCodeFrag(',', TextStyle.WINDOW)}\n${getBBCodeFrag(getBiomeName(this.pokemon.metBiome), TextStyle.SUMMARY_RED)}${getBBCodeFrag('.', TextStyle.WINDOW)}`;
let memoString = `${getBBCodeFrag(Utils.toReadableString(Nature[this.pokemon.nature]), TextStyle.SUMMARY_RED)}${getBBCodeFrag(' nature,', TextStyle.WINDOW_ALT)}\n${getBBCodeFrag(`${this.pokemon.metBiome === -1 ? 'apparently ' : ''}met at Lv`, TextStyle.WINDOW_ALT)}${getBBCodeFrag(this.pokemon.metLevel.toString(), TextStyle.SUMMARY_RED)}${getBBCodeFrag(',', TextStyle.WINDOW_ALT)}\n${getBBCodeFrag(getBiomeName(this.pokemon.metBiome), TextStyle.SUMMARY_RED)}${getBBCodeFrag('.', TextStyle.WINDOW_ALT)}`;
const memoText = addBBCodeTextObject(this.scene, 7, 113, memoString, TextStyle.WINDOW);
const memoText = addBBCodeTextObject(this.scene, 7, 113, memoString, TextStyle.WINDOW_ALT);
memoText.setOrigin(0, 0);
profileContainer.add(memoText);
break;
@@ -603,7 +603,7 @@ export default class SummaryUiHandler extends UiHandler {
? Utils.formatStat(this.pokemon.stats[s])
: `${Utils.formatStat(this.pokemon.hp, true)}/${Utils.formatStat(this.pokemon.getMaxHp(), true)}`;
const statValue = addTextObject(this.scene, 120 + 88 * colIndex, 56 + 16 * rowIndex, statValueText, TextStyle.WINDOW);
const statValue = addTextObject(this.scene, 120 + 88 * colIndex, 56 + 16 * rowIndex, statValueText, TextStyle.WINDOW_ALT);
statValue.setOrigin(1, 0);
statsContainer.add(statValue);
});
@@ -622,8 +622,8 @@ export default class SummaryUiHandler extends UiHandler {
icon.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip());
});
const totalLvExp = getLevelTotalExp(this.pokemon.level, this.pokemon.species.growthRate);
const expRatio = this.pokemon.level < this.scene.getMaxExpLevel() ? this.pokemon.levelExp / totalLvExp : 0;
const relLvExp = getLevelRelExp(this.pokemon.level + 1, this.pokemon.species.growthRate);
const expRatio = this.pokemon.level < this.scene.getMaxExpLevel() ? this.pokemon.levelExp / relLvExp : 0;
const expLabel = addTextObject(this.scene, 6, 112, 'EXP. Points', TextStyle.SUMMARY);
expLabel.setOrigin(0, 0);
@@ -633,14 +633,14 @@ export default class SummaryUiHandler extends UiHandler {
nextLvExpLabel.setOrigin(0, 0);
statsContainer.add(nextLvExpLabel);
const expText = addTextObject(this.scene, 208, 112, this.pokemon.exp.toString(), TextStyle.WINDOW);
const expText = addTextObject(this.scene, 208, 112, this.pokemon.exp.toString(), TextStyle.WINDOW_ALT);
expText.setOrigin(1, 0);
statsContainer.add(expText);
const nextLvExp = this.pokemon.level < this.scene.getMaxExpLevel()
? getLevelTotalExp(this.pokemon.level + 1, this.pokemon.species.growthRate) - this.pokemon.exp
: 0;
const nextLvExpText = addTextObject(this.scene, 208, 128, nextLvExp.toString(), TextStyle.WINDOW);
const nextLvExpText = addTextObject(this.scene, 208, 128, nextLvExp.toString(), TextStyle.WINDOW_ALT);
nextLvExpText.setOrigin(1, 0);
statsContainer.add(nextLvExpText);
@@ -724,7 +724,7 @@ export default class SummaryUiHandler extends UiHandler {
moveRowContainer.add(ppText);
}
this.moveDescriptionText = addTextObject(this.scene, 2, 84, '', TextStyle.WINDOW, { wordWrap: { width: 1212 } });
this.moveDescriptionText = addTextObject(this.scene, 2, 84, '', TextStyle.WINDOW_ALT, { wordWrap: { width: 1212 } });
this.movesContainer.add(this.moveDescriptionText);
const moveDescriptionTextMaskRect = this.scene.make.graphics({});
+22 -8
View File
@@ -2,14 +2,18 @@ import BBCodeText from "phaser3-rex-plugins/plugins/gameobjects/tagtext/bbcodete
import InputText from "phaser3-rex-plugins/plugins/inputtext";
import { ModifierTier } from "../modifier/modifier-tier";
import { EggTier } from "../data/enums/egg-type";
import BattleScene from "../battle-scene";
import { UiTheme } from "../enums/ui-theme";
export enum TextStyle {
MESSAGE,
WINDOW,
WINDOW_ALT,
BATTLE_INFO,
PARTY,
PARTY_RED,
SUMMARY,
SUMMARY_ALT,
SUMMARY_RED,
SUMMARY_BLUE,
SUMMARY_PINK,
@@ -22,7 +26,7 @@ export enum TextStyle {
};
export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text {
const [ styleOptions, shadowColor, shadowSize ] = getTextStyleOptions(style, extraStyleOptions);
const [ styleOptions, shadowColor, shadowSize ] = getTextStyleOptions(style, (scene as BattleScene).uiTheme, extraStyleOptions);
const ret = scene.add.text(x, y, content, styleOptions);
ret.setScale(0.1666666667);
@@ -34,7 +38,7 @@ export function addTextObject(scene: Phaser.Scene, x: number, y: number, content
}
export function addBBCodeTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): BBCodeText {
const [ styleOptions, shadowColor, shadowSize ] = getTextStyleOptions(style, extraStyleOptions);
const [ styleOptions, shadowColor, shadowSize ] = getTextStyleOptions(style, (scene as BattleScene).uiTheme, extraStyleOptions);
const ret = new BBCodeText(scene, x, y, content, styleOptions as BBCodeText.TextStyle);
scene.add.existing(ret);
@@ -47,7 +51,7 @@ export function addBBCodeTextObject(scene: Phaser.Scene, x: number, y: number, c
}
export function addTextInputObject(scene: Phaser.Scene, x: number, y: number, width: number, height: number, style: TextStyle, extraStyleOptions?: InputText.IConfig): InputText {
const [ styleOptions ] = getTextStyleOptions(style, extraStyleOptions);
const [ styleOptions ] = getTextStyleOptions(style, (scene as BattleScene).uiTheme, extraStyleOptions);
const ret = new InputText(scene, x, y, width, height, styleOptions as InputText.IConfig);
scene.add.existing(ret);
@@ -56,14 +60,14 @@ export function addTextInputObject(scene: Phaser.Scene, x: number, y: number, wi
return ret;
}
function getTextStyleOptions(style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): [ Phaser.Types.GameObjects.Text.TextStyle | InputText.IConfig, string, integer ] {
function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): [ Phaser.Types.GameObjects.Text.TextStyle | InputText.IConfig, string, integer ] {
let shadowColor: string;
let shadowSize = 6;
let styleOptions: Phaser.Types.GameObjects.Text.TextStyle = {
fontFamily: 'emerald',
fontSize: '96px',
color: getTextColor(style, false),
color: getTextColor(style, false, uiTheme),
padding: {
bottom: 6
}
@@ -97,7 +101,7 @@ function getTextStyleOptions(style: TextStyle, extraStyleOptions?: Phaser.Types.
break;
}
shadowColor = getTextColor(style, true);
shadowColor = getTextColor(style, true, uiTheme);
if (extraStyleOptions) {
if (extraStyleOptions.fontSize) {
@@ -114,21 +118,31 @@ export function getBBCodeFrag(content: string, textStyle: TextStyle): string {
return `[color=${getTextColor(textStyle)}][shadow=${getTextColor(textStyle, true)}]${content}`;
}
export function getTextColor(textStyle: TextStyle, shadow?: boolean): string {
export function getTextColor(textStyle: TextStyle, shadow?: boolean, uiTheme: UiTheme = UiTheme.DEFAULT): string {
switch (textStyle) {
case TextStyle.MESSAGE:
return !shadow ? '#f8f8f8' : '#6b5a73';
case TextStyle.WINDOW:
case TextStyle.TOOLTIP_CONTENT:
if (uiTheme)
return !shadow ? '#484848' : '#d0d0c8';
return !shadow ? '#f8f8f8' : '#6b5a73';
case TextStyle.WINDOW_ALT:
return !shadow ? '#484848' : '#d0d0c8';
case TextStyle.BATTLE_INFO:
return !shadow ? '#404040' : '#ded6b5';
if (uiTheme)
return !shadow ? '#404040' : '#ded6b5';
return !shadow ? '#f8f8f8' : '#6b5a73';
case TextStyle.PARTY:
return !shadow ? '#f8f8f8' : '#707070';
case TextStyle.PARTY_RED:
return !shadow ? '#f89890' : '#984038';
case TextStyle.SUMMARY:
return !shadow ? '#ffffff' : '#636363';
case TextStyle.SUMMARY_ALT:
if (uiTheme)
return !shadow ? '#ffffff' : '#636363';
return !shadow ? '#484848' : '#d0d0c8';
case TextStyle.SUMMARY_RED:
case TextStyle.TOOLTIP_TITLE:
return !shadow ? '#e70808' : '#ffbd73';
+5
View File
@@ -1,4 +1,5 @@
import BattleScene, { Button } from "../battle-scene";
import { TextStyle, getTextColor } from "./text";
import UI, { Mode } from "./ui";
export default abstract class UiHandler {
@@ -26,6 +27,10 @@ export default abstract class UiHandler {
return this.scene.ui;
}
getTextColor(style: TextStyle, shadow: boolean = false): string {
return getTextColor(style, shadow, this.scene.uiTheme);
}
getCursor(): integer {
return this.cursor;
}