mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-22 15:29:27 +02:00
Supports multilingual with proper line wrapping in actionMessage text in command phase
This commit is contained in:
parent
fa6d81b78e
commit
f57245d26f
@ -5,5 +5,5 @@ export const commandUiHandler: SimpleTranslationEntries = {
|
|||||||
"ball": "Ball",
|
"ball": "Ball",
|
||||||
"pokemon": "Pokémon",
|
"pokemon": "Pokémon",
|
||||||
"run": "Run",
|
"run": "Run",
|
||||||
"actionMessage": "What will\n{{pokemonName}} do?",
|
"actionMessage": "What will {{pokemonName}} do?",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -5,5 +5,5 @@ export const commandUiHandler: SimpleTranslationEntries = {
|
|||||||
"ball": "Ball",
|
"ball": "Ball",
|
||||||
"pokemon": "Pokémon",
|
"pokemon": "Pokémon",
|
||||||
"run": "Fliehen",
|
"run": "Fliehen",
|
||||||
"actionMessage": "Was soll\n{{pokemonName}} tun?",
|
"actionMessage": "Was soll {{pokemonName}} tun?",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -5,5 +5,5 @@ export const commandUiHandler: SimpleTranslationEntries = {
|
|||||||
"ball": "Ball",
|
"ball": "Ball",
|
||||||
"pokemon": "Pokémon",
|
"pokemon": "Pokémon",
|
||||||
"run": "Run",
|
"run": "Run",
|
||||||
"actionMessage": "What will\n{{pokemonName}} do?",
|
"actionMessage": "What will {{pokemonName}} do?",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -5,5 +5,5 @@ export const commandUiHandler: SimpleTranslationEntries = {
|
|||||||
"ball": "Balls",
|
"ball": "Balls",
|
||||||
"pokemon": "Pokémon",
|
"pokemon": "Pokémon",
|
||||||
"run": "Huir",
|
"run": "Huir",
|
||||||
"actionMessage": "¿Qué debería\nhacer {{pokemonName}}?",
|
"actionMessage": "¿Qué debería hacer {{pokemonName}}?",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -5,5 +5,5 @@ export const commandUiHandler: SimpleTranslationEntries = {
|
|||||||
"ball": "Ball",
|
"ball": "Ball",
|
||||||
"pokemon": "Pokémon",
|
"pokemon": "Pokémon",
|
||||||
"run": "Fuite",
|
"run": "Fuite",
|
||||||
"actionMessage": "Que doit faire\n{{pokemonName}} ?",
|
"actionMessage": "Que doit faire {{pokemonName}} ?",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -5,5 +5,5 @@ export const commandUiHandler: SimpleTranslationEntries = {
|
|||||||
"ball": "Bolas",
|
"ball": "Bolas",
|
||||||
"pokemon": "Pokémon",
|
"pokemon": "Pokémon",
|
||||||
"run": "Fugir",
|
"run": "Fugir",
|
||||||
"actionMessage": "O que {{pokemonName}}\ndeve fazer?",
|
"actionMessage": "O que {{pokemonName}} deve fazer?",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -5,5 +5,5 @@ export const commandUiHandler: SimpleTranslationEntries = {
|
|||||||
"ball": "精灵球",
|
"ball": "精灵球",
|
||||||
"pokemon": "宝可梦",
|
"pokemon": "宝可梦",
|
||||||
"run": "逃跑",
|
"run": "逃跑",
|
||||||
"actionMessage": "要让\n{{pokemonName}} 做什么?",
|
"actionMessage": "要让 {{pokemonName}} 做什么?",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -5,5 +5,5 @@ export const commandUiHandler: SimpleTranslationEntries = {
|
|||||||
"ball": "精靈球",
|
"ball": "精靈球",
|
||||||
"pokemon": "寶可夢",
|
"pokemon": "寶可夢",
|
||||||
"run": "逃跑",
|
"run": "逃跑",
|
||||||
"actionMessage": "要讓\n{{pokemonName}} 做甚麼?",
|
"actionMessage": "要讓 {{pokemonName}} 做甚麼?",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -66,8 +66,32 @@ export default class CommandUiHandler extends UiHandler {
|
|||||||
messageHandler.bg.setVisible(true);
|
messageHandler.bg.setVisible(true);
|
||||||
messageHandler.commandWindow.setVisible(true);
|
messageHandler.commandWindow.setVisible(true);
|
||||||
messageHandler.movesWindowContainer.setVisible(false);
|
messageHandler.movesWindowContainer.setVisible(false);
|
||||||
messageHandler.message.setWordWrapWidth(1110);
|
const currentLanguage = i18next.resolvedLanguage!;
|
||||||
messageHandler.showText(i18next.t("commandUiHandler:actionMessage", {pokemonName: getPokemonNameWithAffix(commandPhase.getPokemon())}), 0);
|
const ignoreBalanceText = [];
|
||||||
|
const messageMaxWidth = this.scene.game.canvas.width - messageHandler.commandWindow.getBounds().width - messageHandler.message.getBounds().x;
|
||||||
|
messageHandler.message.setWordWrapWidth(messageMaxWidth);
|
||||||
|
const commandMessage = i18next.t("commandUiHandler:actionMessage", {pokemonName: getPokemonNameWithAffix(commandPhase.getPokemon())});
|
||||||
|
const textWrapped = messageHandler.message.getWrappedText(commandMessage);
|
||||||
|
const fontSizeToNumber = (fs:number|string):number=>(parseInt(fs.toString().replace("px","")));
|
||||||
|
const fontSize = fontSizeToNumber(messageHandler.message.getData("originalFontSize") ?? messageHandler.message.style.fontSize);
|
||||||
|
messageHandler.message.setFontSize(fontSize);
|
||||||
|
messageHandler.message.setData("originalFontSize",messageHandler.message.getData("originalFontSize") ?? fontSize);
|
||||||
|
|
||||||
|
// Text Balance
|
||||||
|
if (!ignoreBalanceText.some(localKey=>localKey===currentLanguage) && textWrapped[1] && textWrapped.length <= messageHandler.message.style.maxLines && textWrapped[0].replace(" ","").length * 0.25 > textWrapped[1].replace(" ","").length) {
|
||||||
|
messageHandler.message.setWordWrapWidth((this.scene.game.canvas.width - messageHandler.commandWindow.getBounds().width - messageHandler.message.parentContainer.getBounds().x) * 0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajust Text
|
||||||
|
if (messageHandler.message.getWrappedText(commandMessage).length > messageHandler.message.style.maxLines) {
|
||||||
|
let fontDecrement = fontSize;
|
||||||
|
while (messageHandler.message.getWrappedText(commandMessage).length > messageHandler.message.style.maxLines) {
|
||||||
|
fontDecrement -= 1;
|
||||||
|
messageHandler.message.setFontSize(fontDecrement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
messageHandler.showText(commandMessage, 0);
|
||||||
this.setCursor(this.getCursor());
|
this.setCursor(this.getCursor());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user