mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 09:02:47 +02:00
Cleanup text.ts file
This commit is contained in:
parent
c353f54a42
commit
6030dd6462
10
src/@types/ui.ts
Normal file
10
src/@types/ui.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import type Phaser from "phaser";
|
||||||
|
import type InputText from "phaser3-rex-plugins/plugins/gameobjects/dom/inputtext/InputText";
|
||||||
|
|
||||||
|
export interface TextStyleOptions {
|
||||||
|
scale: number;
|
||||||
|
styleOptions: Phaser.Types.GameObjects.Text.TextStyle | InputText.IConfig;
|
||||||
|
shadowColor: string;
|
||||||
|
shadowXpos: number;
|
||||||
|
shadowYpos: number;
|
||||||
|
}
|
@ -7,14 +7,7 @@ import { globalScene } from "#app/global-scene";
|
|||||||
import { ModifierTier } from "../enums/modifier-tier";
|
import { ModifierTier } from "../enums/modifier-tier";
|
||||||
import i18next from "#app/plugins/i18n";
|
import i18next from "#app/plugins/i18n";
|
||||||
import { TextStyle } from "#enums/text-style";
|
import { TextStyle } from "#enums/text-style";
|
||||||
|
import type { TextStyleOptions } from "#app/@types/ui";
|
||||||
export interface TextStyleOptions {
|
|
||||||
scale: number;
|
|
||||||
styleOptions: Phaser.Types.GameObjects.Text.TextStyle | InputText.IConfig;
|
|
||||||
shadowColor: string;
|
|
||||||
shadowXpos: number;
|
|
||||||
shadowYpos: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addTextObject(
|
export function addTextObject(
|
||||||
x: number,
|
x: number,
|
||||||
@ -29,9 +22,10 @@ export function addTextObject(
|
|||||||
extraStyleOptions,
|
extraStyleOptions,
|
||||||
);
|
);
|
||||||
|
|
||||||
const ret = globalScene.add.text(x, y, content, styleOptions);
|
const ret = globalScene.add
|
||||||
ret.setScale(scale);
|
.text(x, y, content, styleOptions)
|
||||||
ret.setShadow(shadowXpos, shadowYpos, shadowColor);
|
.setScale(scale)
|
||||||
|
.setShadow(shadowXpos, shadowYpos, shadowColor);
|
||||||
if (!(styleOptions as Phaser.Types.GameObjects.Text.TextStyle).lineSpacing) {
|
if (!(styleOptions as Phaser.Types.GameObjects.Text.TextStyle).lineSpacing) {
|
||||||
ret.setLineSpacing(scale * 30);
|
ret.setLineSpacing(scale * 30);
|
||||||
}
|
}
|
||||||
@ -53,8 +47,7 @@ export function setTextStyle(
|
|||||||
globalScene.uiTheme,
|
globalScene.uiTheme,
|
||||||
extraStyleOptions,
|
extraStyleOptions,
|
||||||
);
|
);
|
||||||
obj.setScale(scale);
|
obj.setScale(scale).setShadow(shadowXpos, shadowYpos, shadowColor);
|
||||||
obj.setShadow(shadowXpos, shadowYpos, shadowColor);
|
|
||||||
if (!(styleOptions as Phaser.Types.GameObjects.Text.TextStyle).lineSpacing) {
|
if (!(styleOptions as Phaser.Types.GameObjects.Text.TextStyle).lineSpacing) {
|
||||||
obj.setLineSpacing(scale * 30);
|
obj.setLineSpacing(scale * 30);
|
||||||
}
|
}
|
||||||
@ -79,8 +72,7 @@ export function addBBCodeTextObject(
|
|||||||
|
|
||||||
const ret = new BBCodeText(globalScene, x, y, content, styleOptions as BBCodeText.TextStyle);
|
const ret = new BBCodeText(globalScene, x, y, content, styleOptions as BBCodeText.TextStyle);
|
||||||
globalScene.add.existing(ret);
|
globalScene.add.existing(ret);
|
||||||
ret.setScale(scale);
|
ret.setScale(scale).setShadow(shadowXpos, shadowYpos, shadowColor);
|
||||||
ret.setShadow(shadowXpos, shadowYpos, shadowColor);
|
|
||||||
if (!(styleOptions as BBCodeText.TextStyle).lineSpacing) {
|
if (!(styleOptions as BBCodeText.TextStyle).lineSpacing) {
|
||||||
ret.setLineSpacing(scale * 60);
|
ret.setLineSpacing(scale * 60);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user