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,
|
2023-10-22 01:23:43 +01:00
|
|
|
SUMMARY_GOLD,
|
|
|
|
MONEY
|
2023-03-28 19:54:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle) {
|
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',
|
|
|
|
color: getTextColor(style, false),
|
|
|
|
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:
|
|
|
|
case TextStyle.SUMMARY_GOLD:
|
2023-03-28 19:54:52 +01:00
|
|
|
case TextStyle.WINDOW:
|
|
|
|
case TextStyle.MESSAGE:
|
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-04-24 00:41:32 +01:00
|
|
|
styleOptions.fontSize = '72px';
|
2023-04-02 01:06:44 +01:00
|
|
|
shadowSize = 4;
|
|
|
|
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-03-28 19:54:52 +01:00
|
|
|
}
|
|
|
|
|
2023-04-24 00:41:32 +01:00
|
|
|
shadowColor = getTextColor(style, true);
|
|
|
|
|
2023-04-26 17:50:21 +01:00
|
|
|
if (extraStyleOptions) {
|
|
|
|
if (extraStyleOptions.fontSize) {
|
|
|
|
const sizeRatio = parseInt(extraStyleOptions.fontSize.slice(0, -2)) / parseInt(styleOptions.fontSize.slice(0, -2));
|
|
|
|
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
|
|
|
|
|
|
|
const ret = scene.add.text(x, y, content, styleOptions);
|
|
|
|
ret.setScale(0.1666666667);
|
2023-04-02 01:06:44 +01:00
|
|
|
ret.setShadow(shadowSize, shadowSize, shadowColor);
|
2023-03-28 19:54:52 +01:00
|
|
|
ret.setLineSpacing(5);
|
|
|
|
|
|
|
|
return ret;
|
2023-04-24 00:41:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getTextColor(textStyle: TextStyle, shadow?: boolean) {
|
|
|
|
switch (textStyle) {
|
|
|
|
case TextStyle.MESSAGE:
|
|
|
|
return !shadow ? '#f8f8f8' : '#6b5a73';
|
|
|
|
case TextStyle.WINDOW:
|
|
|
|
return !shadow ? '#484848' : '#d0d0c8';
|
|
|
|
case TextStyle.BATTLE_INFO:
|
|
|
|
return !shadow ? '#404040' : '#ded6b5';
|
|
|
|
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:
|
|
|
|
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-03-28 19:54:52 +01:00
|
|
|
}
|