diff --git a/src/locales/ca_ES/menu-ui-handler.ts b/src/locales/ca_ES/menu-ui-handler.ts index 1014c161f84..bcf49e51220 100644 --- a/src/locales/ca_ES/menu-ui-handler.ts +++ b/src/locales/ca_ES/menu-ui-handler.ts @@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = { "unlinkGoogle": "Unlink Google", "cancel": "Cancel", "losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?", - "noEggs": "You are not hatching\nany eggs at the moment!" + "noEggs": "You are not hatching any eggs at the moment!" } as const; diff --git a/src/locales/en/menu-ui-handler.ts b/src/locales/en/menu-ui-handler.ts index 1014c161f84..bcf49e51220 100644 --- a/src/locales/en/menu-ui-handler.ts +++ b/src/locales/en/menu-ui-handler.ts @@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = { "unlinkGoogle": "Unlink Google", "cancel": "Cancel", "losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?", - "noEggs": "You are not hatching\nany eggs at the moment!" + "noEggs": "You are not hatching any eggs at the moment!" } as const; diff --git a/src/locales/es/menu-ui-handler.ts b/src/locales/es/menu-ui-handler.ts index 3f3b3703166..c59a53738c2 100644 --- a/src/locales/es/menu-ui-handler.ts +++ b/src/locales/es/menu-ui-handler.ts @@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = { "unlinkGoogle": "Desconectar Google", "cancel": "Cancelar", "losingProgressionWarning": "Perderás cualquier progreso desde el inicio de la batalla. ¿Continuar?", - "noEggs": "You are not hatching\nany eggs at the moment!" + "noEggs": "You are not hatching any eggs at the moment!" } as const; diff --git a/src/locales/fr/menu-ui-handler.ts b/src/locales/fr/menu-ui-handler.ts index 823001f9e94..88e1158d9f4 100644 --- a/src/locales/fr/menu-ui-handler.ts +++ b/src/locales/fr/menu-ui-handler.ts @@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = { "unlinkGoogle": "Délier Google", "cancel": "Retour", "losingProgressionWarning": "Vous allez perdre votre progression depuis le début du combat. Continuer ?", - "noEggs": "Vous ne faites actuellement\néclore aucun Œuf !" + "noEggs": "Vous ne faitesactuellement éclore aucun Œuf !" } as const; diff --git a/src/locales/it/menu-ui-handler.ts b/src/locales/it/menu-ui-handler.ts index 0cfea8d67b7..71c3f379ed2 100644 --- a/src/locales/it/menu-ui-handler.ts +++ b/src/locales/it/menu-ui-handler.ts @@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = { "unlinkGoogle": "Scollega Google", "cancel": "Annulla", "losingProgressionWarning": "Perderai tutti i progressi dall'inizio della battaglia. Confermi?", - "noEggs": "You are not hatching\nany eggs at the moment!" + "noEggs": "You are not hatching any eggs at the moment!" } as const; diff --git a/src/locales/ja/menu-ui-handler.ts b/src/locales/ja/menu-ui-handler.ts index 5923052cb62..21e7f93d08a 100644 --- a/src/locales/ja/menu-ui-handler.ts +++ b/src/locales/ja/menu-ui-handler.ts @@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = { "unlinkGoogle": "Unlink Google", "cancel": "キャンセル", "losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?", - "noEggs": "You are not hatching\nany eggs at the moment!", + "noEggs": "You are not hatching any eggs at the moment!", } as const; diff --git a/src/locales/pt_BR/menu-ui-handler.ts b/src/locales/pt_BR/menu-ui-handler.ts index 431bb64310e..c8d9e0fad94 100644 --- a/src/locales/pt_BR/menu-ui-handler.ts +++ b/src/locales/pt_BR/menu-ui-handler.ts @@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = { "unlinkGoogle": "Desconectar Google", "cancel": "Cancelar", "losingProgressionWarning": "Você vai perder todo o progresso desde o início da batalha. Confirmar?", - "noEggs": "Você não está chocando\nnenhum ovo no momento!" + "noEggs": "Você não está chocando nenhum ovo no momento!" } as const; diff --git a/src/locales/zh_CN/menu-ui-handler.ts b/src/locales/zh_CN/menu-ui-handler.ts index 467099ddbed..c49c5dc7ebb 100644 --- a/src/locales/zh_CN/menu-ui-handler.ts +++ b/src/locales/zh_CN/menu-ui-handler.ts @@ -24,6 +24,6 @@ export const menuUiHandler: SimpleTranslationEntries = { "linkGoogle": "关联Google", "unlinkGoogle": "解除关联Google", "cancel": "取消", - "losingProgressionWarning": "你将失去自战斗开始以来的所有进度。\n是否继续?", - "noEggs": "当前没有任何蛋\n正在孵化中!" + "losingProgressionWarning": "你将失去自战斗开始以来的所有进度。是否继续?", + "noEggs": "当前没有任何蛋 正在孵化中!" } as const; diff --git a/src/locales/zh_TW/menu-ui-handler.ts b/src/locales/zh_TW/menu-ui-handler.ts index ab70fd9af33..27c0e943482 100644 --- a/src/locales/zh_TW/menu-ui-handler.ts +++ b/src/locales/zh_TW/menu-ui-handler.ts @@ -24,6 +24,6 @@ export const menuUiHandler: SimpleTranslationEntries = { "linkGoogle": "Link Google", "unlinkGoogle": "Unlink Google", "cancel": "取消", - "losingProgressionWarning": "你將失去自戰鬥開始以來的所有進度。是否\n繼續?", - "noEggs": "You are not hatching\nany eggs at the moment!" + "losingProgressionWarning": "你將失去自戰鬥開始以來的所有進度。是否 繼續?", + "noEggs": "You are not hatching any eggs at the moment!" } as const; diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 24e76035972..cff0f9ce3be 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -33,6 +33,7 @@ const redditUrl = "https://www.reddit.com/r/pokerogue"; export default class MenuUiHandler extends MessageUiHandler { private menuContainer: Phaser.GameObjects.Container; private menuMessageBoxContainer: Phaser.GameObjects.Container; + private messageBoxBg: Phaser.GameObjects.NineSlice; private menuOverlay: Phaser.GameObjects.Rectangle; private menuBg: Phaser.GameObjects.NineSlice; @@ -50,7 +51,6 @@ export default class MenuUiHandler extends MessageUiHandler { public bgmBar: BgmBar; - constructor(scene: BattleScene, mode: Mode | null = null) { super(scene, mode); @@ -134,16 +134,18 @@ export default class MenuUiHandler extends MessageUiHandler { this.menuMessageBoxContainer.setVisible(false); this.menuContainer.add(this.menuMessageBoxContainer); - const menuMessageBox = addWindow(this.scene, 0, -0, 220, 48); + const menuMessageBox = addWindow(this.scene, 0, -0, (this.scene.game.canvas.width / 6) - this.menuBg.width - 1, 48); menuMessageBox.setOrigin(0, 0); this.menuMessageBoxContainer.add(menuMessageBox); + this.messageBoxBg = menuMessageBox; const menuMessageText = addTextObject(this.scene, 8, 8, "", TextStyle.WINDOW, { maxLines: 2 }); menuMessageText.setName("menu-message"); - menuMessageText.setWordWrapWidth(1224); menuMessageText.setOrigin(0, 0); - this.menuMessageBoxContainer.add(menuMessageText); + menuMessageText.setWordWrapWidth(menuMessageBox.getBounds().width * 0.96); + menuMessageText.setData("originalFont",menuMessageText.style.fontSize); + this.menuMessageBoxContainer.add(menuMessageText); this.message = menuMessageText; this.menuContainer.add(this.menuMessageBoxContainer); @@ -253,7 +255,8 @@ export default class MenuUiHandler extends MessageUiHandler { }); this.manageDataConfig = { - xOffset: 98, + xOffset: this.menuBg.width, + yOffset: 0, options: manageDataOptions }; @@ -300,7 +303,7 @@ export default class MenuUiHandler extends MessageUiHandler { ]; this.communityConfig = { - xOffset: 98, + xOffset: this.menuBg.width, options: communityOptions }; this.setCursor(0); @@ -445,7 +448,7 @@ export default class MenuUiHandler extends MessageUiHandler { ui.setOverlayMode(Mode.CONFIRM, () => this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true)), () => { ui.revertMode(); ui.showText("", 0); - }, false, -98); + }, false, this.menuBg.width * -1); }); } else { this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true)); @@ -470,7 +473,7 @@ export default class MenuUiHandler extends MessageUiHandler { ui.setOverlayMode(Mode.CONFIRM, doLogout, () => { ui.revertMode(); ui.showText("", 0); - }, false, -98); + }, false, this.menuBg.width * -1); }); } else { doLogout(); @@ -514,6 +517,24 @@ export default class MenuUiHandler extends MessageUiHandler { showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number): void { this.menuMessageBoxContainer.setVisible(!!text); + const messageText = this.message; + const messageBox = this.messageBoxBg; + if (messageBox && messageText) { + const fontSizeToNumber = (fs:number|string):number=>(parseInt(fs.toString().replace("px",""))); + const fontSize = fontSizeToNumber(messageText.getData("originalFont")); + const textSize = Phaser.GameObjects.GetTextSize(messageText,messageText.style.getTextMetrics(),messageText.getWrappedText(text)); + messageText.setFontSize(fontSize); + + if (messageText.getWrappedText(text).length > messageText.style.maxLines || textSize.width > messageBox.getBounds().width) { + let fontDecrement = fontSize; + while (messageText.getWrappedText(text).length > messageText.style.maxLines || Phaser.GameObjects.GetTextSize(messageText,messageText.style.getTextMetrics(),messageText.getWrappedText(text)).width > messageBox.getBounds().width) { + fontDecrement -= 1; + messageText.setFontSize(fontDecrement); + } + const padding = messageText.x / 2; + messageText.setFontSize(fontDecrement - padding); + } + } super.showText(text, delay, callback, callbackDelay, prompt, promptDelay); }