mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-29 11:42:21 +02:00
Passing a TextStyle to option select ui handler to allow for shadowed text
This commit is contained in:
parent
41841ace1b
commit
8d27907336
@ -1,5 +1,5 @@
|
|||||||
import BattleScene from "../battle-scene";
|
import BattleScene from "../battle-scene";
|
||||||
import { TextStyle, addBBCodeTextObject, getTextStyleOptions } from "./text";
|
import { TextStyle, addBBCodeTextObject, getTextColor, getTextStyleOptions } from "./text";
|
||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
import UiHandler from "./ui-handler";
|
import UiHandler from "./ui-handler";
|
||||||
import { addWindow } from "./ui-theme";
|
import { addWindow } from "./ui-theme";
|
||||||
@ -25,7 +25,7 @@ export interface OptionSelectItem {
|
|||||||
skip?: boolean;
|
skip?: boolean;
|
||||||
keepOpen?: boolean;
|
keepOpen?: boolean;
|
||||||
overrideSound?: boolean;
|
overrideSound?: boolean;
|
||||||
color?: string;
|
style?: TextStyle;
|
||||||
item?: string;
|
item?: string;
|
||||||
itemArgs?: any[];
|
itemArgs?: any[];
|
||||||
}
|
}
|
||||||
@ -52,6 +52,8 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||||||
|
|
||||||
protected unskippedIndices: number[] = [];
|
protected unskippedIndices: number[] = [];
|
||||||
|
|
||||||
|
protected defaultTextStyle: TextStyle = TextStyle.SETTINGS_VALUE;
|
||||||
|
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode: Mode | null) {
|
constructor(scene: BattleScene, mode: Mode | null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
@ -121,8 +123,8 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||||||
|
|
||||||
this.optionSelectText = addBBCodeTextObject(
|
this.optionSelectText = addBBCodeTextObject(
|
||||||
this.scene, 0, 0, options.map(o => o.item
|
this.scene, 0, 0, options.map(o => o.item
|
||||||
? `[color=${o.color || "white"}] ${o.label}[/color]`
|
? `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true)}][color=${getTextColor(o.style ?? TextStyle.SETTINGS_VALUE)}] ${o.label}[/color]`
|
||||||
: `[color=${o.color || "white"}]${o.label}[/color]`
|
: `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true)}][color=${getTextColor(o.style ?? TextStyle.SETTINGS_VALUE)}]${o.label}[/color]`
|
||||||
).join("\n"),
|
).join("\n"),
|
||||||
TextStyle.WINDOW, { maxLines: options.length, lineSpacing: 12 }
|
TextStyle.WINDOW, { maxLines: options.length, lineSpacing: 12 }
|
||||||
);
|
);
|
||||||
@ -135,8 +137,8 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||||||
|
|
||||||
if (this.config?.options && this.config?.options.length > (this.config?.maxOptions!)) { // TODO: is this bang correct?
|
if (this.config?.options && this.config?.options.length > (this.config?.maxOptions!)) { // TODO: is this bang correct?
|
||||||
this.optionSelectText.setText(this.getOptionsWithScroll().map(o => o.item
|
this.optionSelectText.setText(this.getOptionsWithScroll().map(o => o.item
|
||||||
? `[color=${o.color || "white"}] ${o.label}[/color]`
|
? `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true)}][color=${getTextColor(o.style ?? TextStyle.SETTINGS_VALUE)}] ${o.label}[/color]`
|
||||||
: `[color=${o.color || "white"}]${o.label}[/color]`
|
: `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true)}][color=${getTextColor(o.style ?? TextStyle.SETTINGS_VALUE)}]${o.label}[/color]`
|
||||||
).join("\n"));
|
).join("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,14 +307,14 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||||||
options.unshift({
|
options.unshift({
|
||||||
label: scrollUpLabel,
|
label: scrollUpLabel,
|
||||||
handler: () => true,
|
handler: () => true,
|
||||||
color: "#ffffff"
|
style: this.defaultTextStyle
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (optionEndIndex < optionsScrollTotal) {
|
if (optionEndIndex < optionsScrollTotal) {
|
||||||
options.push({
|
options.push({
|
||||||
label: scrollDownLabel,
|
label: scrollDownLabel,
|
||||||
handler: () => true,
|
handler: () => true,
|
||||||
color: "#ffffff"
|
style: this.defaultTextStyle
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1158,26 +1158,26 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
{
|
{
|
||||||
label: "Common:",
|
label: "Common:",
|
||||||
skip: true,
|
skip: true,
|
||||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
style: TextStyle.MONEY_WINDOW,
|
||||||
handler: () => false, // Non-selectable, but handler is required
|
handler: () => false, // Non-selectable, but handler is required
|
||||||
onHover: () => this.moveInfoOverlay.clear() // No hover behavior for titles
|
onHover: () => this.moveInfoOverlay.clear() // No hover behavior for titles
|
||||||
},
|
},
|
||||||
...this.eggMoves.slice(0, 3).map((m, i) => ({
|
...this.eggMoves.slice(0, 3).map((m, i) => ({
|
||||||
label: allMoves[m].name,
|
label: allMoves[m].name,
|
||||||
color: this.hasEggMoves[i] ? this.getTextColor(TextStyle.SETTINGS_VALUE) : this.getTextColor(TextStyle.SETTINGS_VALUE, true),
|
style: this.hasEggMoves[i] ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.moveInfoOverlay.show(allMoves[m])
|
onHover: () => this.moveInfoOverlay.show(allMoves[m])
|
||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
label: "Rare:",
|
label: "Rare:",
|
||||||
skip: true,
|
skip: true,
|
||||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
style: TextStyle.MONEY_WINDOW,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.moveInfoOverlay.clear()
|
onHover: () => this.moveInfoOverlay.clear()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: allMoves[this.eggMoves[3]].name,
|
label: allMoves[this.eggMoves[3]].name,
|
||||||
color: this.hasEggMoves[3] ? this.getTextColor(TextStyle.SETTINGS_VALUE) : this.getTextColor(TextStyle.SETTINGS_VALUE, true),
|
style: this.hasEggMoves[3] ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.moveInfoOverlay.show(allMoves[this.eggMoves[3]])
|
onHover: () => this.moveInfoOverlay.show(allMoves[this.eggMoves[3]])
|
||||||
},
|
},
|
||||||
@ -1262,7 +1262,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
if (this.ability1) {
|
if (this.ability1) {
|
||||||
options.push({
|
options.push({
|
||||||
label: allAbilities[this.ability1].name,
|
label: allAbilities[this.ability1].name,
|
||||||
color: this.hasAbilities[0] > 0 ? this.getTextColor(TextStyle.SETTINGS_VALUE) : this.getTextColor(TextStyle.SETTINGS_VALUE, true),
|
style: this.hasAbilities[0] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.infoOverlay.show(allAbilities[this.ability1].description)
|
onHover: () => this.infoOverlay.show(allAbilities[this.ability1].description)
|
||||||
});
|
});
|
||||||
@ -1271,7 +1271,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
const ability = allAbilities[this.ability2];
|
const ability = allAbilities[this.ability2];
|
||||||
options.push({
|
options.push({
|
||||||
label: ability?.name,
|
label: ability?.name,
|
||||||
color: this.hasAbilities[1] > 0 ? this.getTextColor(TextStyle.SETTINGS_VALUE) : this.getTextColor(TextStyle.SETTINGS_VALUE, true),
|
style: this.hasAbilities[1] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.infoOverlay.show(ability?.description)
|
onHover: () => this.infoOverlay.show(ability?.description)
|
||||||
});
|
});
|
||||||
@ -1281,14 +1281,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
options.push({
|
options.push({
|
||||||
label: "Hidden:",
|
label: "Hidden:",
|
||||||
skip: true,
|
skip: true,
|
||||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
style: TextStyle.MONEY_WINDOW,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.infoOverlay.clear()
|
onHover: () => this.infoOverlay.clear()
|
||||||
});
|
});
|
||||||
const ability = allAbilities[this.abilityHidden];
|
const ability = allAbilities[this.abilityHidden];
|
||||||
options.push({
|
options.push({
|
||||||
label: allAbilities[this.abilityHidden].name,
|
label: allAbilities[this.abilityHidden].name,
|
||||||
color: this.hasAbilities[2] > 0 ? this.getTextColor(TextStyle.SETTINGS_VALUE) : this.getTextColor(TextStyle.SETTINGS_VALUE, true),
|
style: this.hasAbilities[2] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.infoOverlay.show(ability?.description)
|
onHover: () => this.infoOverlay.show(ability?.description)
|
||||||
});
|
});
|
||||||
@ -1298,13 +1298,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
options.push({
|
options.push({
|
||||||
label: "Passive:",
|
label: "Passive:",
|
||||||
skip: true,
|
skip: true,
|
||||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
style: TextStyle.MONEY_WINDOW,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.infoOverlay.clear()
|
onHover: () => this.infoOverlay.clear()
|
||||||
});
|
});
|
||||||
options.push({
|
options.push({
|
||||||
label: allAbilities[this.passive].name,
|
label: allAbilities[this.passive].name,
|
||||||
color: this.hasPassive ? this.getTextColor(TextStyle.SETTINGS_VALUE) : this.getTextColor(TextStyle.SETTINGS_VALUE, true),
|
style: this.hasPassive ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => false,
|
handler: () => false,
|
||||||
onHover: () => this.infoOverlay.show(allAbilities[this.passive].description)
|
onHover: () => this.infoOverlay.show(allAbilities[this.passive].description)
|
||||||
});
|
});
|
||||||
@ -1433,7 +1433,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
label: pre.preFormKey ?
|
label: pre.preFormKey ?
|
||||||
this.getFormString(pre.preFormKey, preSpecies ?? this.lastSpecies, true) :
|
this.getFormString(pre.preFormKey, preSpecies ?? this.lastSpecies, true) :
|
||||||
this.getRegionName(preSpecies ?? this.lastSpecies),
|
this.getRegionName(preSpecies ?? this.lastSpecies),
|
||||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
style: TextStyle.MONEY_WINDOW,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
const newSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[pre.speciesId]);
|
const newSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[pre.speciesId]);
|
||||||
// Attempts to find the formIndex of the evolved species
|
// Attempts to find the formIndex of the evolved species
|
||||||
@ -1477,7 +1477,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
label: evo.evoFormKey ?
|
label: evo.evoFormKey ?
|
||||||
this.getFormString(evo.evoFormKey, evoSpecies ?? this.lastSpecies, true) :
|
this.getFormString(evo.evoFormKey, evoSpecies ?? this.lastSpecies, true) :
|
||||||
this.getRegionName(evoSpecies ?? this.lastSpecies),
|
this.getRegionName(evoSpecies ?? this.lastSpecies),
|
||||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
style: TextStyle.MONEY_WINDOW,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
const newSpecies = allSpecies.find(species => species.speciesId === evo.speciesId);
|
const newSpecies = allSpecies.find(species => species.speciesId === evo.speciesId);
|
||||||
// Attempts to find the formIndex of the evolved species
|
// Attempts to find the formIndex of the evolved species
|
||||||
@ -1523,7 +1523,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
options.push({
|
options.push({
|
||||||
label: label,
|
label: label,
|
||||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
style: TextStyle.MONEY_WINDOW,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
const newSpecies = this.lastSpecies;
|
const newSpecies = this.lastSpecies;
|
||||||
const newFormIndex = bf.formIndex;
|
const newFormIndex = bf.formIndex;
|
||||||
|
@ -42,6 +42,7 @@ export enum TextStyle {
|
|||||||
PERFECT_IV,
|
PERFECT_IV,
|
||||||
ME_OPTION_DEFAULT, // Default style for choices in ME
|
ME_OPTION_DEFAULT, // Default style for choices in ME
|
||||||
ME_OPTION_SPECIAL, // Style for choices with special requirements in ME
|
ME_OPTION_SPECIAL, // Style for choices with special requirements in ME
|
||||||
|
SHADOW_TEXT // To obscure unavailable options
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TextStyleOptions {
|
export interface TextStyleOptions {
|
||||||
@ -359,6 +360,11 @@ export function getTextColor(textStyle: TextStyle, shadow?: boolean, uiTheme: Ui
|
|||||||
return !shadow ? "#f8b050" : "#c07800"; // Gold
|
return !shadow ? "#f8b050" : "#c07800"; // Gold
|
||||||
}
|
}
|
||||||
return !shadow ? "#78c850" : "#306850"; // Green
|
return !shadow ? "#78c850" : "#306850"; // Green
|
||||||
|
case TextStyle.SHADOW_TEXT:
|
||||||
|
if (isLegacyTheme) {
|
||||||
|
return !shadow ? "#d0d0c8" : "#d0d0c8";
|
||||||
|
}
|
||||||
|
return !shadow ? "#6b5a73" : "#6b5a73";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user