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 { TextStyle, addBBCodeTextObject, getTextStyleOptions } from "./text";
|
||||
import { TextStyle, addBBCodeTextObject, getTextColor, getTextStyleOptions } from "./text";
|
||||
import { Mode } from "./ui";
|
||||
import UiHandler from "./ui-handler";
|
||||
import { addWindow } from "./ui-theme";
|
||||
|
@ -25,7 +25,7 @@ export interface OptionSelectItem {
|
|||
skip?: boolean;
|
||||
keepOpen?: boolean;
|
||||
overrideSound?: boolean;
|
||||
color?: string;
|
||||
style?: TextStyle;
|
||||
item?: string;
|
||||
itemArgs?: any[];
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||
|
||||
protected unskippedIndices: number[] = [];
|
||||
|
||||
protected defaultTextStyle: TextStyle = TextStyle.SETTINGS_VALUE;
|
||||
|
||||
|
||||
constructor(scene: BattleScene, mode: Mode | null) {
|
||||
super(scene, mode);
|
||||
|
@ -121,8 +123,8 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||
|
||||
this.optionSelectText = addBBCodeTextObject(
|
||||
this.scene, 0, 0, options.map(o => o.item
|
||||
? `[color=${o.color || "white"}] ${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]`
|
||||
: `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true)}][color=${getTextColor(o.style ?? TextStyle.SETTINGS_VALUE)}]${o.label}[/color]`
|
||||
).join("\n"),
|
||||
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?
|
||||
this.optionSelectText.setText(this.getOptionsWithScroll().map(o => o.item
|
||||
? `[color=${o.color || "white"}] ${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]`
|
||||
: `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true)}][color=${getTextColor(o.style ?? TextStyle.SETTINGS_VALUE)}]${o.label}[/color]`
|
||||
).join("\n"));
|
||||
}
|
||||
|
||||
|
@ -305,14 +307,14 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||
options.unshift({
|
||||
label: scrollUpLabel,
|
||||
handler: () => true,
|
||||
color: "#ffffff"
|
||||
style: this.defaultTextStyle
|
||||
});
|
||||
}
|
||||
if (optionEndIndex < optionsScrollTotal) {
|
||||
options.push({
|
||||
label: scrollDownLabel,
|
||||
handler: () => true,
|
||||
color: "#ffffff"
|
||||
style: this.defaultTextStyle
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1158,26 +1158,26 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||
{
|
||||
label: "Common:",
|
||||
skip: true,
|
||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
||||
style: TextStyle.MONEY_WINDOW,
|
||||
handler: () => false, // Non-selectable, but handler is required
|
||||
onHover: () => this.moveInfoOverlay.clear() // No hover behavior for titles
|
||||
},
|
||||
...this.eggMoves.slice(0, 3).map((m, i) => ({
|
||||
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,
|
||||
onHover: () => this.moveInfoOverlay.show(allMoves[m])
|
||||
})),
|
||||
{
|
||||
label: "Rare:",
|
||||
skip: true,
|
||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
||||
style: TextStyle.MONEY_WINDOW,
|
||||
handler: () => false,
|
||||
onHover: () => this.moveInfoOverlay.clear()
|
||||
},
|
||||
{
|
||||
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,
|
||||
onHover: () => this.moveInfoOverlay.show(allMoves[this.eggMoves[3]])
|
||||
},
|
||||
|
@ -1262,7 +1262,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||
if (this.ability1) {
|
||||
options.push({
|
||||
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,
|
||||
onHover: () => this.infoOverlay.show(allAbilities[this.ability1].description)
|
||||
});
|
||||
|
@ -1271,7 +1271,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||
const ability = allAbilities[this.ability2];
|
||||
options.push({
|
||||
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,
|
||||
onHover: () => this.infoOverlay.show(ability?.description)
|
||||
});
|
||||
|
@ -1281,14 +1281,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||
options.push({
|
||||
label: "Hidden:",
|
||||
skip: true,
|
||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
||||
style: TextStyle.MONEY_WINDOW,
|
||||
handler: () => false,
|
||||
onHover: () => this.infoOverlay.clear()
|
||||
});
|
||||
const ability = allAbilities[this.abilityHidden];
|
||||
options.push({
|
||||
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,
|
||||
onHover: () => this.infoOverlay.show(ability?.description)
|
||||
});
|
||||
|
@ -1298,13 +1298,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||
options.push({
|
||||
label: "Passive:",
|
||||
skip: true,
|
||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
||||
style: TextStyle.MONEY_WINDOW,
|
||||
handler: () => false,
|
||||
onHover: () => this.infoOverlay.clear()
|
||||
});
|
||||
options.push({
|
||||
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,
|
||||
onHover: () => this.infoOverlay.show(allAbilities[this.passive].description)
|
||||
});
|
||||
|
@ -1433,7 +1433,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||
label: pre.preFormKey ?
|
||||
this.getFormString(pre.preFormKey, preSpecies ?? this.lastSpecies, true) :
|
||||
this.getRegionName(preSpecies ?? this.lastSpecies),
|
||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
||||
style: TextStyle.MONEY_WINDOW,
|
||||
handler: () => {
|
||||
const newSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[pre.speciesId]);
|
||||
// Attempts to find the formIndex of the evolved species
|
||||
|
@ -1477,7 +1477,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||
label: evo.evoFormKey ?
|
||||
this.getFormString(evo.evoFormKey, evoSpecies ?? this.lastSpecies, true) :
|
||||
this.getRegionName(evoSpecies ?? this.lastSpecies),
|
||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
||||
style: TextStyle.MONEY_WINDOW,
|
||||
handler: () => {
|
||||
const newSpecies = allSpecies.find(species => species.speciesId === evo.speciesId);
|
||||
// Attempts to find the formIndex of the evolved species
|
||||
|
@ -1523,7 +1523,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||
}
|
||||
options.push({
|
||||
label: label,
|
||||
color: this.getTextColor(TextStyle.MONEY_WINDOW),
|
||||
style: TextStyle.MONEY_WINDOW,
|
||||
handler: () => {
|
||||
const newSpecies = this.lastSpecies;
|
||||
const newFormIndex = bf.formIndex;
|
||||
|
|
|
@ -42,6 +42,7 @@ export enum TextStyle {
|
|||
PERFECT_IV,
|
||||
ME_OPTION_DEFAULT, // Default style for choices in ME
|
||||
ME_OPTION_SPECIAL, // Style for choices with special requirements in ME
|
||||
SHADOW_TEXT // To obscure unavailable options
|
||||
}
|
||||
|
||||
export interface TextStyleOptions {
|
||||
|
@ -359,6 +360,11 @@ export function getTextColor(textStyle: TextStyle, shadow?: boolean, uiTheme: Ui
|
|||
return !shadow ? "#f8b050" : "#c07800"; // Gold
|
||||
}
|
||||
return !shadow ? "#78c850" : "#306850"; // Green
|
||||
case TextStyle.SHADOW_TEXT:
|
||||
if (isLegacyTheme) {
|
||||
return !shadow ? "#d0d0c8" : "#d0d0c8";
|
||||
}
|
||||
return !shadow ? "#6b5a73" : "#6b5a73";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue