mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-22 15:29:27 +02:00
Enhanced container layout to support multi-language texts with proper line wrapping in menu-ui
This commit is contained in:
parent
d0ed24c216
commit
5b31347425
@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"unlinkGoogle": "Unlink Google",
|
"unlinkGoogle": "Unlink Google",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?",
|
"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;
|
} as const;
|
||||||
|
@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"unlinkGoogle": "Unlink Google",
|
"unlinkGoogle": "Unlink Google",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?",
|
"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;
|
} as const;
|
||||||
|
@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"unlinkGoogle": "Desconectar Google",
|
"unlinkGoogle": "Desconectar Google",
|
||||||
"cancel": "Cancelar",
|
"cancel": "Cancelar",
|
||||||
"losingProgressionWarning": "Perderás cualquier progreso desde el inicio de la batalla. ¿Continuar?",
|
"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;
|
} as const;
|
||||||
|
@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"unlinkGoogle": "Délier Google",
|
"unlinkGoogle": "Délier Google",
|
||||||
"cancel": "Retour",
|
"cancel": "Retour",
|
||||||
"losingProgressionWarning": "Vous allez perdre votre progression depuis le début du combat. Continuer ?",
|
"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;
|
} as const;
|
||||||
|
@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"unlinkGoogle": "Scollega Google",
|
"unlinkGoogle": "Scollega Google",
|
||||||
"cancel": "Annulla",
|
"cancel": "Annulla",
|
||||||
"losingProgressionWarning": "Perderai tutti i progressi dall'inizio della battaglia. Confermi?",
|
"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;
|
} as const;
|
||||||
|
@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"unlinkGoogle": "Unlink Google",
|
"unlinkGoogle": "Unlink Google",
|
||||||
"cancel": "キャンセル",
|
"cancel": "キャンセル",
|
||||||
"losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?",
|
"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;
|
} as const;
|
||||||
|
@ -25,5 +25,5 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"unlinkGoogle": "Desconectar Google",
|
"unlinkGoogle": "Desconectar Google",
|
||||||
"cancel": "Cancelar",
|
"cancel": "Cancelar",
|
||||||
"losingProgressionWarning": "Você vai perder todo o progresso desde o início da batalha. Confirmar?",
|
"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;
|
} as const;
|
||||||
|
@ -24,6 +24,6 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"linkGoogle": "关联Google",
|
"linkGoogle": "关联Google",
|
||||||
"unlinkGoogle": "解除关联Google",
|
"unlinkGoogle": "解除关联Google",
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"losingProgressionWarning": "你将失去自战斗开始以来的所有进度。\n是否继续?",
|
"losingProgressionWarning": "你将失去自战斗开始以来的所有进度。是否继续?",
|
||||||
"noEggs": "当前没有任何蛋\n正在孵化中!"
|
"noEggs": "当前没有任何蛋 正在孵化中!"
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -24,6 +24,6 @@ export const menuUiHandler: SimpleTranslationEntries = {
|
|||||||
"linkGoogle": "Link Google",
|
"linkGoogle": "Link Google",
|
||||||
"unlinkGoogle": "Unlink Google",
|
"unlinkGoogle": "Unlink Google",
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"losingProgressionWarning": "你將失去自戰鬥開始以來的所有進度。是否\n繼續?",
|
"losingProgressionWarning": "你將失去自戰鬥開始以來的所有進度。是否 繼續?",
|
||||||
"noEggs": "You are not hatching\nany eggs at the moment!"
|
"noEggs": "You are not hatching any eggs at the moment!"
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -33,6 +33,7 @@ const redditUrl = "https://www.reddit.com/r/pokerogue";
|
|||||||
export default class MenuUiHandler extends MessageUiHandler {
|
export default class MenuUiHandler extends MessageUiHandler {
|
||||||
private menuContainer: Phaser.GameObjects.Container;
|
private menuContainer: Phaser.GameObjects.Container;
|
||||||
private menuMessageBoxContainer: Phaser.GameObjects.Container;
|
private menuMessageBoxContainer: Phaser.GameObjects.Container;
|
||||||
|
private messageBoxBg: Phaser.GameObjects.NineSlice;
|
||||||
private menuOverlay: Phaser.GameObjects.Rectangle;
|
private menuOverlay: Phaser.GameObjects.Rectangle;
|
||||||
|
|
||||||
private menuBg: Phaser.GameObjects.NineSlice;
|
private menuBg: Phaser.GameObjects.NineSlice;
|
||||||
@ -50,7 +51,6 @@ export default class MenuUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
public bgmBar: BgmBar;
|
public bgmBar: BgmBar;
|
||||||
|
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
|
|
||||||
@ -134,16 +134,18 @@ export default class MenuUiHandler extends MessageUiHandler {
|
|||||||
this.menuMessageBoxContainer.setVisible(false);
|
this.menuMessageBoxContainer.setVisible(false);
|
||||||
this.menuContainer.add(this.menuMessageBoxContainer);
|
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);
|
menuMessageBox.setOrigin(0, 0);
|
||||||
this.menuMessageBoxContainer.add(menuMessageBox);
|
this.menuMessageBoxContainer.add(menuMessageBox);
|
||||||
|
this.messageBoxBg = menuMessageBox;
|
||||||
|
|
||||||
const menuMessageText = addTextObject(this.scene, 8, 8, "", TextStyle.WINDOW, { maxLines: 2 });
|
const menuMessageText = addTextObject(this.scene, 8, 8, "", TextStyle.WINDOW, { maxLines: 2 });
|
||||||
menuMessageText.setName("menu-message");
|
menuMessageText.setName("menu-message");
|
||||||
menuMessageText.setWordWrapWidth(1224);
|
|
||||||
menuMessageText.setOrigin(0, 0);
|
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.message = menuMessageText;
|
||||||
|
|
||||||
this.menuContainer.add(this.menuMessageBoxContainer);
|
this.menuContainer.add(this.menuMessageBoxContainer);
|
||||||
@ -253,7 +255,8 @@ export default class MenuUiHandler extends MessageUiHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.manageDataConfig = {
|
this.manageDataConfig = {
|
||||||
xOffset: 98,
|
xOffset: this.menuBg.width,
|
||||||
|
yOffset: 0,
|
||||||
options: manageDataOptions
|
options: manageDataOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -300,7 +303,7 @@ export default class MenuUiHandler extends MessageUiHandler {
|
|||||||
];
|
];
|
||||||
|
|
||||||
this.communityConfig = {
|
this.communityConfig = {
|
||||||
xOffset: 98,
|
xOffset: this.menuBg.width,
|
||||||
options: communityOptions
|
options: communityOptions
|
||||||
};
|
};
|
||||||
this.setCursor(0);
|
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.setOverlayMode(Mode.CONFIRM, () => this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true)), () => {
|
||||||
ui.revertMode();
|
ui.revertMode();
|
||||||
ui.showText("", 0);
|
ui.showText("", 0);
|
||||||
}, false, -98);
|
}, false, this.menuBg.width * -1);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true));
|
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.setOverlayMode(Mode.CONFIRM, doLogout, () => {
|
||||||
ui.revertMode();
|
ui.revertMode();
|
||||||
ui.showText("", 0);
|
ui.showText("", 0);
|
||||||
}, false, -98);
|
}, false, this.menuBg.width * -1);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
doLogout();
|
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 {
|
showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number): void {
|
||||||
this.menuMessageBoxContainer.setVisible(!!text);
|
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);
|
super.showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user