2023-12-20 04:51:48 +00:00
|
|
|
import BBCodeText from "phaser3-rex-plugins/plugins/gameobjects/tagtext/bbcodetext/BBCodeText";
|
2023-12-30 23:41:25 +00:00
|
|
|
import InputText from "phaser3-rex-plugins/plugins/inputtext";
|
2024-01-13 17:24:24 +00:00
|
|
|
import { ModifierTier } from "../modifier/modifier-tier";
|
2024-02-29 04:13:05 +00:00
|
|
|
import { EggTier } from "../data/enums/egg-type";
|
2023-12-20 04:51:48 +00:00
|
|
|
|
2023-03-28 19:54:52 +01:00
|
|
|
export enum TextStyle {
|
|
|
|
MESSAGE,
|
|
|
|
WINDOW,
|
2023-04-02 01:06:44 +01:00
|
|
|
BATTLE_INFO,
|
2023-04-07 03:24:13 +01:00
|
|
|
PARTY,
|
2023-10-03 17:50:31 +01:00
|
|
|
PARTY_RED,
|
2023-04-07 03:24:13 +01:00
|
|
|
SUMMARY,
|
2023-04-24 00:41:32 +01:00
|
|
|
SUMMARY_RED,
|
2024-01-06 03:24:05 +00:00
|
|
|
SUMMARY_BLUE,
|
2024-01-05 16:29:34 +00:00
|
|
|
SUMMARY_PINK,
|
2023-10-22 01:23:43 +01:00
|
|
|
SUMMARY_GOLD,
|
2023-10-26 21:33:59 +01:00
|
|
|
MONEY,
|
|
|
|
SETTINGS_LABEL,
|
2023-11-02 04:55:20 +00:00
|
|
|
SETTINGS_SELECTED,
|
|
|
|
TOOLTIP_TITLE,
|
|
|
|
TOOLTIP_CONTENT
|
2023-03-28 19:54:52 +01:00
|
|
|
};
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text {
|
2024-03-31 21:51:53 +01:00
|
|
|
const [ styleOptions, shadowColor, shadowSize ] = getTextStyleOptions(style, extraStyleOptions);
|
2023-12-20 04:51:48 +00:00
|
|
|
|
|
|
|
const ret = scene.add.text(x, y, content, styleOptions);
|
|
|
|
ret.setScale(0.1666666667);
|
|
|
|
ret.setShadow(shadowSize, shadowSize, shadowColor);
|
2023-12-30 23:41:25 +00:00
|
|
|
if (!(styleOptions as Phaser.Types.GameObjects.Text.TextStyle).lineSpacing)
|
2023-12-20 04:51:48 +00:00
|
|
|
ret.setLineSpacing(5);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addBBCodeTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): BBCodeText {
|
2024-03-31 21:51:53 +01:00
|
|
|
const [ styleOptions, shadowColor, shadowSize ] = getTextStyleOptions(style, extraStyleOptions);
|
2023-12-20 04:51:48 +00:00
|
|
|
|
|
|
|
const ret = new BBCodeText(scene, x, y, content, styleOptions as BBCodeText.TextStyle);
|
|
|
|
scene.add.existing(ret);
|
|
|
|
ret.setScale(0.1666666667);
|
|
|
|
ret.setShadow(shadowSize, shadowSize, shadowColor);
|
2024-03-15 01:49:49 +00:00
|
|
|
if (!(styleOptions as BBCodeText.TextStyle).lineSpacing)
|
|
|
|
ret.setLineSpacing(10);
|
2023-12-20 04:51:48 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-12-30 23:41:25 +00:00
|
|
|
export function addTextInputObject(scene: Phaser.Scene, x: number, y: number, width: number, height: number, style: TextStyle, extraStyleOptions?: InputText.IConfig): InputText {
|
2024-03-31 21:51:53 +01:00
|
|
|
const [ styleOptions ] = getTextStyleOptions(style, extraStyleOptions);
|
2023-12-30 23:41:25 +00:00
|
|
|
|
|
|
|
const ret = new InputText(scene, x, y, width, height, styleOptions as InputText.IConfig);
|
|
|
|
scene.add.existing(ret);
|
|
|
|
ret.setScale(0.1666666667);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-03-31 21:51:53 +01:00
|
|
|
function getTextStyleOptions(style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): [ Phaser.Types.GameObjects.Text.TextStyle | InputText.IConfig, string, integer ] {
|
2023-04-09 01:35:45 +01:00
|
|
|
let shadowColor: string;
|
2023-04-02 01:06:44 +01:00
|
|
|
let shadowSize = 6;
|
2023-03-28 19:54:52 +01:00
|
|
|
|
2023-04-24 00:41:32 +01:00
|
|
|
let styleOptions: Phaser.Types.GameObjects.Text.TextStyle = {
|
|
|
|
fontFamily: 'emerald',
|
|
|
|
fontSize: '96px',
|
2024-03-31 21:51:53 +01:00
|
|
|
color: getTextColor(style, false),
|
2023-04-24 00:41:32 +01:00
|
|
|
padding: {
|
|
|
|
bottom: 6
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-03-28 19:54:52 +01:00
|
|
|
switch (style) {
|
2023-04-24 00:41:32 +01:00
|
|
|
case TextStyle.SUMMARY:
|
|
|
|
case TextStyle.SUMMARY_RED:
|
2024-01-05 16:29:34 +00:00
|
|
|
case TextStyle.SUMMARY_PINK:
|
2023-04-24 00:41:32 +01:00
|
|
|
case TextStyle.SUMMARY_GOLD:
|
2023-03-28 19:54:52 +01:00
|
|
|
case TextStyle.WINDOW:
|
|
|
|
case TextStyle.MESSAGE:
|
2023-10-26 21:33:59 +01:00
|
|
|
case TextStyle.SETTINGS_LABEL:
|
|
|
|
case TextStyle.SETTINGS_SELECTED:
|
2023-04-24 00:41:32 +01:00
|
|
|
styleOptions.fontSize = '96px';
|
2023-03-28 19:54:52 +01:00
|
|
|
break;
|
2023-04-02 01:06:44 +01:00
|
|
|
case TextStyle.BATTLE_INFO:
|
2023-10-22 01:23:43 +01:00
|
|
|
case TextStyle.MONEY:
|
2023-11-02 04:55:20 +00:00
|
|
|
case TextStyle.TOOLTIP_TITLE:
|
2023-04-24 00:41:32 +01:00
|
|
|
styleOptions.fontSize = '72px';
|
2023-11-02 04:55:20 +00:00
|
|
|
shadowSize = 4.5;
|
2023-04-02 01:06:44 +01:00
|
|
|
break;
|
2023-03-28 19:54:52 +01:00
|
|
|
case TextStyle.PARTY:
|
2023-10-03 17:50:31 +01:00
|
|
|
case TextStyle.PARTY_RED:
|
2023-04-24 00:41:32 +01:00
|
|
|
styleOptions.fontFamily = 'pkmnems';
|
|
|
|
styleOptions.fontSize = '66px';
|
2023-04-07 03:24:13 +01:00
|
|
|
break;
|
2023-11-02 04:55:20 +00:00
|
|
|
case TextStyle.TOOLTIP_CONTENT:
|
|
|
|
styleOptions.fontSize = '64px';
|
|
|
|
shadowSize = 4;
|
|
|
|
break;
|
2023-03-28 19:54:52 +01:00
|
|
|
}
|
|
|
|
|
2024-03-31 21:51:53 +01:00
|
|
|
shadowColor = getTextColor(style, true);
|
2023-04-24 00:41:32 +01:00
|
|
|
|
2023-04-26 17:50:21 +01:00
|
|
|
if (extraStyleOptions) {
|
|
|
|
if (extraStyleOptions.fontSize) {
|
2024-02-07 04:11:00 +00:00
|
|
|
const sizeRatio = parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / parseInt(styleOptions.fontSize.toString().slice(0, -2));
|
2023-04-26 17:50:21 +01:00
|
|
|
shadowSize *= sizeRatio;
|
|
|
|
}
|
2023-03-28 19:54:52 +01:00
|
|
|
styleOptions = Object.assign(styleOptions, extraStyleOptions);
|
2023-04-26 17:50:21 +01:00
|
|
|
}
|
2023-03-28 19:54:52 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
return [ styleOptions, shadowColor, shadowSize ];
|
2023-04-24 00:41:32 +01:00
|
|
|
}
|
|
|
|
|
2024-01-05 16:29:34 +00:00
|
|
|
export function getBBCodeFrag(content: string, textStyle: TextStyle): string {
|
2024-01-08 04:17:24 +00:00
|
|
|
return `[color=${getTextColor(textStyle)}][shadow=${getTextColor(textStyle, true)}]${content}`;
|
2024-01-05 16:29:34 +00:00
|
|
|
}
|
|
|
|
|
2024-03-31 21:51:53 +01:00
|
|
|
export function getTextColor(textStyle: TextStyle, shadow?: boolean): string {
|
2023-04-24 00:41:32 +01:00
|
|
|
switch (textStyle) {
|
|
|
|
case TextStyle.MESSAGE:
|
|
|
|
return !shadow ? '#f8f8f8' : '#6b5a73';
|
|
|
|
case TextStyle.WINDOW:
|
2023-11-02 04:55:20 +00:00
|
|
|
case TextStyle.TOOLTIP_CONTENT:
|
2023-04-24 00:41:32 +01:00
|
|
|
return !shadow ? '#484848' : '#d0d0c8';
|
|
|
|
case TextStyle.BATTLE_INFO:
|
2024-03-31 21:51:53 +01:00
|
|
|
return !shadow ? '#404040' : '#ded6b5';
|
2023-04-24 00:41:32 +01:00
|
|
|
case TextStyle.PARTY:
|
|
|
|
return !shadow ? '#f8f8f8' : '#707070';
|
2023-10-03 17:50:31 +01:00
|
|
|
case TextStyle.PARTY_RED:
|
|
|
|
return !shadow ? '#f89890' : '#984038';
|
2023-04-24 00:41:32 +01:00
|
|
|
case TextStyle.SUMMARY:
|
|
|
|
return !shadow ? '#ffffff' : '#636363';
|
|
|
|
case TextStyle.SUMMARY_RED:
|
2023-11-02 04:55:20 +00:00
|
|
|
case TextStyle.TOOLTIP_TITLE:
|
2024-01-05 16:29:34 +00:00
|
|
|
return !shadow ? '#e70808' : '#ffbd73';
|
2024-01-06 03:24:05 +00:00
|
|
|
case TextStyle.SUMMARY_BLUE:
|
|
|
|
return !shadow ? '#40c8f8' : '#006090';
|
2024-01-05 16:29:34 +00:00
|
|
|
case TextStyle.SUMMARY_PINK:
|
2023-04-24 00:41:32 +01:00
|
|
|
return !shadow ? '#f89890' : '#984038';
|
|
|
|
case TextStyle.SUMMARY_GOLD:
|
2023-10-22 01:23:43 +01:00
|
|
|
case TextStyle.MONEY:
|
2023-04-24 00:41:32 +01:00
|
|
|
return !shadow ? '#e8e8a8' : '#a0a060'
|
2023-10-26 21:33:59 +01:00
|
|
|
case TextStyle.SETTINGS_LABEL:
|
|
|
|
return !shadow ? '#f8b050' : '#c07800';
|
|
|
|
case TextStyle.SETTINGS_SELECTED:
|
|
|
|
return !shadow ? '#f88880' : '#f83018';
|
2023-04-24 00:41:32 +01:00
|
|
|
}
|
2023-11-02 04:55:20 +00:00
|
|
|
}
|
|
|
|
|
2024-02-29 04:13:05 +00:00
|
|
|
export function getModifierTierTextTint(tier: ModifierTier): integer {
|
2023-11-02 04:55:20 +00:00
|
|
|
switch (tier) {
|
2024-01-13 17:24:24 +00:00
|
|
|
case ModifierTier.COMMON:
|
2023-11-02 04:55:20 +00:00
|
|
|
return 0xffffff;
|
2024-01-13 17:24:24 +00:00
|
|
|
case ModifierTier.GREAT:
|
2023-11-02 04:55:20 +00:00
|
|
|
return 0x3890f8;
|
2024-01-13 17:24:24 +00:00
|
|
|
case ModifierTier.ULTRA:
|
2023-11-12 05:31:40 +00:00
|
|
|
return 0xf8d038;
|
2024-02-29 04:13:05 +00:00
|
|
|
case ModifierTier.ROGUE:
|
|
|
|
return 0xd52929;
|
2024-01-13 17:24:24 +00:00
|
|
|
case ModifierTier.MASTER:
|
2023-11-02 04:55:20 +00:00
|
|
|
return 0xe020c0;
|
2024-01-13 17:24:24 +00:00
|
|
|
case ModifierTier.LUXURY:
|
2023-11-02 04:55:20 +00:00
|
|
|
return 0xe64a18;
|
|
|
|
}
|
2024-02-29 04:13:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getEggTierTextTint(tier: EggTier): integer {
|
|
|
|
switch (tier) {
|
|
|
|
case EggTier.COMMON:
|
|
|
|
return getModifierTierTextTint(ModifierTier.COMMON);
|
|
|
|
case EggTier.GREAT:
|
|
|
|
return getModifierTierTextTint(ModifierTier.GREAT);
|
|
|
|
case EggTier.ULTRA:
|
|
|
|
return getModifierTierTextTint(ModifierTier.ULTRA);
|
|
|
|
case EggTier.MASTER:
|
|
|
|
return getModifierTierTextTint(ModifierTier.MASTER);
|
|
|
|
}
|
2023-03-28 19:54:52 +01:00
|
|
|
}
|