Drop Shadow Adjustments (#1197)

* Drop Shadow Adjustments

Adding support for x,y axis on dropshadow and adjusting the values to be less bad

* Further Refined New Shadow Positons

- Reverted MOVE_INFO_CONTENT to the old default
- Slight adjustments to other values
This commit is contained in:
zaccie 2024-05-22 03:00:33 +12:00 committed by GitHub
parent 8c01403630
commit 33f8365192
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 10 deletions

View File

@ -49,11 +49,11 @@ const languageSettings: { [key: string]: LanguageSetting } = {
} }
export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text { 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, (scene as BattleScene).uiTheme, extraStyleOptions); const [ styleOptions, shadowColor, shadowXpos, shadowYpos ] = getTextStyleOptions(style, (scene as BattleScene).uiTheme, extraStyleOptions);
const ret = scene.add.text(x, y, content, styleOptions); const ret = scene.add.text(x, y, content, styleOptions);
ret.setScale(0.1666666667); ret.setScale(0.1666666667);
ret.setShadow(shadowSize, shadowSize, shadowColor); ret.setShadow(shadowXpos, shadowYpos, shadowColor);
if (!(styleOptions as Phaser.Types.GameObjects.Text.TextStyle).lineSpacing) if (!(styleOptions as Phaser.Types.GameObjects.Text.TextStyle).lineSpacing)
ret.setLineSpacing(5); ret.setLineSpacing(5);
@ -61,12 +61,12 @@ 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 { 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, (scene as BattleScene).uiTheme, extraStyleOptions); const [ styleOptions, shadowColor, shadowXpos, shadowYpos ] = getTextStyleOptions(style, (scene as BattleScene).uiTheme, extraStyleOptions);
const ret = new BBCodeText(scene, x, y, content, styleOptions as BBCodeText.TextStyle); const ret = new BBCodeText(scene, x, y, content, styleOptions as BBCodeText.TextStyle);
scene.add.existing(ret); scene.add.existing(ret);
ret.setScale(0.1666666667); ret.setScale(0.1666666667);
ret.setShadow(shadowSize, shadowSize, shadowColor); ret.setShadow(shadowXpos, shadowYpos, shadowColor);
if (!(styleOptions as BBCodeText.TextStyle).lineSpacing) if (!(styleOptions as BBCodeText.TextStyle).lineSpacing)
ret.setLineSpacing(10); ret.setLineSpacing(10);
@ -86,7 +86,8 @@ export function addTextInputObject(scene: Phaser.Scene, x: number, y: number, wi
function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, 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 ] {
const lang = i18next.language; const lang = i18next.language;
let shadowColor: string; let shadowColor: string;
let shadowSize = 6; let shadowXpos = 4;
let shadowYpos = 5;
let styleOptions: Phaser.Types.GameObjects.Text.TextStyle = { let styleOptions: Phaser.Types.GameObjects.Text.TextStyle = {
fontFamily: 'emerald', fontFamily: 'emerald',
@ -117,7 +118,8 @@ function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraStyleOptio
case TextStyle.MONEY: case TextStyle.MONEY:
case TextStyle.TOOLTIP_TITLE: case TextStyle.TOOLTIP_TITLE:
styleOptions.fontSize = languageSettings[lang]?.battleInfoFontSize || '72px'; styleOptions.fontSize = languageSettings[lang]?.battleInfoFontSize || '72px';
shadowSize = 4.5; shadowXpos = 3.5;
shadowYpos = 3.5;
break; break;
case TextStyle.PARTY: case TextStyle.PARTY:
case TextStyle.PARTY_RED: case TextStyle.PARTY_RED:
@ -126,11 +128,13 @@ function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraStyleOptio
break; break;
case TextStyle.TOOLTIP_CONTENT: case TextStyle.TOOLTIP_CONTENT:
styleOptions.fontSize = languageSettings[lang]?.tooltipContentFontSize || '64px'; styleOptions.fontSize = languageSettings[lang]?.tooltipContentFontSize || '64px';
shadowSize = 4; shadowXpos = 3;
shadowYpos = 3;
break; break;
case TextStyle.MOVE_INFO_CONTENT: case TextStyle.MOVE_INFO_CONTENT:
styleOptions.fontSize = languageSettings[lang]?.moveInfoFontSize || '56px'; styleOptions.fontSize = languageSettings[lang]?.moveInfoFontSize || '56px';
shadowSize = 3; shadowXpos = 3;
shadowYpos = 3;
break; break;
} }
@ -139,12 +143,12 @@ function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraStyleOptio
if (extraStyleOptions) { if (extraStyleOptions) {
if (extraStyleOptions.fontSize) { if (extraStyleOptions.fontSize) {
const sizeRatio = parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / parseInt(styleOptions.fontSize.toString().slice(0, -2)); const sizeRatio = parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / parseInt(styleOptions.fontSize.toString().slice(0, -2));
shadowSize *= sizeRatio; shadowXpos *= sizeRatio;
} }
styleOptions = Object.assign(styleOptions, extraStyleOptions); styleOptions = Object.assign(styleOptions, extraStyleOptions);
} }
return [ styleOptions, shadowColor, shadowSize ]; return [ styleOptions, shadowColor, shadowXpos, shadowYpos ];
} }
export function getBBCodeFrag(content: string, textStyle: TextStyle, uiTheme: UiTheme = UiTheme.DEFAULT): string { export function getBBCodeFrag(content: string, textStyle: TextStyle, uiTheme: UiTheme = UiTheme.DEFAULT): string {