mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-19 14:52:19 +02:00
Merge branch 'beta' into beta
This commit is contained in:
commit
95713db958
@ -28,17 +28,28 @@ export class MessagePhase extends Phase {
|
||||
super.start();
|
||||
|
||||
if (this.text.indexOf("$") > -1) {
|
||||
const pokename: string[] = [];
|
||||
const repname = [ "#POKEMON1", "#POKEMON2" ];
|
||||
for (let p = 0; p < globalScene.getPlayerField().length; p++) {
|
||||
pokename.push(globalScene.getPlayerField()[p].getNameToRender());
|
||||
this.text = this.text.split(pokename[p]).join(repname[p]);
|
||||
}
|
||||
const pageIndex = this.text.indexOf("$");
|
||||
globalScene.unshiftPhase(
|
||||
new MessagePhase(
|
||||
this.text.slice(pageIndex + 1),
|
||||
this.callbackDelay,
|
||||
this.prompt,
|
||||
this.promptDelay,
|
||||
this.speaker,
|
||||
),
|
||||
);
|
||||
this.text = this.text.slice(0, pageIndex).trim();
|
||||
for (let p = 0; p < globalScene.getPlayerField().length; p++) {
|
||||
this.text = this.text.split(repname[p]).join(pokename[p]);
|
||||
}
|
||||
if (pageIndex !== -1) {
|
||||
globalScene.unshiftPhase(
|
||||
new MessagePhase(
|
||||
this.text.slice(pageIndex + 1),
|
||||
this.callbackDelay,
|
||||
this.prompt,
|
||||
this.promptDelay,
|
||||
this.speaker,
|
||||
),
|
||||
);
|
||||
this.text = this.text.slice(0, pageIndex).trim();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.speaker) {
|
||||
|
@ -76,6 +76,12 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
|
||||
const fadeMap = new Map<number, number>();
|
||||
const actionPattern = /@(c|d|s|f)\{(.*?)\}/;
|
||||
let actionMatch: RegExpExecArray | null;
|
||||
const pokename: string[] = [];
|
||||
const repname = [ "#POKEMON1", "#POKEMON2" ];
|
||||
for (let p = 0; p < globalScene.getPlayerField().length; p++) {
|
||||
pokename.push(globalScene.getPlayerField()[p].getNameToRender());
|
||||
text = text.split(pokename[p]).join(repname[p]);
|
||||
}
|
||||
while ((actionMatch = actionPattern.exec(text))) {
|
||||
switch (actionMatch[1]) {
|
||||
case "c":
|
||||
@ -94,6 +100,9 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
|
||||
text = text.slice(0, actionMatch.index) + text.slice(actionMatch.index + actionMatch[2].length + 4);
|
||||
}
|
||||
|
||||
for (let p = 0; p < globalScene.getPlayerField().length; p++) {
|
||||
text = text.split(repname[p]).join(pokename[p]);
|
||||
}
|
||||
if (text) {
|
||||
// Predetermine overflow line breaks to avoid words breaking while displaying
|
||||
const textWords = text.split(" ");
|
||||
|
11
src/ui/ui.ts
11
src/ui/ui.ts
@ -328,17 +328,28 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||
prompt?: boolean | null,
|
||||
promptDelay?: number | null,
|
||||
): void {
|
||||
const pokename: string[] = [];
|
||||
const repname = [ "#POKEMON1", "#POKEMON2" ];
|
||||
for (let p = 0; p < globalScene.getPlayerField().length; p++) {
|
||||
pokename.push(globalScene.getPlayerField()[p].getNameToRender());
|
||||
text = text.split(pokename[p]).join(repname[p]);
|
||||
}
|
||||
if (prompt && text.indexOf("$") > -1) {
|
||||
const messagePages = text.split(/\$/g).map(m => m.trim());
|
||||
// biome-ignore lint/complexity/useOptionalChain: optional chain would change this to be null instead of undefined.
|
||||
let showMessageAndCallback = () => callback && callback();
|
||||
for (let p = messagePages.length - 1; p >= 0; p--) {
|
||||
const originalFunc = showMessageAndCallback;
|
||||
messagePages[p] = messagePages[p].split(repname[0]).join(pokename[0]);
|
||||
messagePages[p] = messagePages[p].split(repname[1]).join(pokename[1]);
|
||||
showMessageAndCallback = () => this.showText(messagePages[p], null, originalFunc, null, true);
|
||||
}
|
||||
showMessageAndCallback();
|
||||
} else {
|
||||
const handler = this.getHandler();
|
||||
for (let p = 0; p < globalScene.getPlayerField().length; p++) {
|
||||
text = text.split(repname[p]).join(pokename[p]);
|
||||
}
|
||||
if (handler instanceof MessageUiHandler) {
|
||||
(handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user