mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 07:23:24 +02:00
Changes to MEs, incorporated #5925
This commit is contained in:
parent
1408dead4e
commit
4ccabeeeb2
@ -44,7 +44,11 @@ import { Variant } from "#sprites/variant";
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
const overrides = {} satisfies Partial<InstanceType<OverridesType>>;
|
||||
const overrides = {
|
||||
MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType.SHADY_VITAMIN_DEALER,
|
||||
MYSTERY_ENCOUNTER_RATE_OVERRIDE: 255,
|
||||
STARTING_WAVE_OVERRIDE: 32,
|
||||
} satisfies Partial<InstanceType<OverridesType>>;
|
||||
|
||||
/**
|
||||
* If you need to add Overrides values for local testing do that inside {@linkcode overrides}
|
||||
|
@ -16,6 +16,7 @@ import { addWindow, WindowVariant } from "#ui/ui-theme";
|
||||
import { fixedInt, isNullOrUndefined } from "#utils/common";
|
||||
import i18next from "i18next";
|
||||
import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
||||
import ScrollingText from "./scrolling-text";
|
||||
|
||||
export class MysteryEncounterUiHandler extends UiHandler {
|
||||
private cursorContainer: Phaser.GameObjects.Container;
|
||||
@ -46,6 +47,8 @@ export class MysteryEncounterUiHandler extends UiHandler {
|
||||
protected viewPartyXPosition = 0;
|
||||
|
||||
protected blockInput = true;
|
||||
desc: ScrollingText;
|
||||
tooltipDesc: ScrollingText;
|
||||
|
||||
constructor() {
|
||||
super(UiMode.MYSTERY_ENCOUNTER);
|
||||
@ -503,41 +506,21 @@ export class MysteryEncounterUiHandler extends UiHandler {
|
||||
const ballType = getPokeballAtlasKey(index);
|
||||
this.rarityBall.setTexture("pb", ballType);
|
||||
|
||||
const descriptionTextObject = addBBCodeTextObject(6, 25, descriptionText ?? "", TextStyle.TOOLTIP_CONTENT, {
|
||||
wordWrap: { width: 830 },
|
||||
});
|
||||
|
||||
// Sets up the mask that hides the description text to give an illusion of scrolling
|
||||
const descriptionTextMaskRect = globalScene.make.graphics({});
|
||||
descriptionTextMaskRect.setScale(6);
|
||||
descriptionTextMaskRect.fillStyle(0xffffff);
|
||||
descriptionTextMaskRect.beginPath();
|
||||
descriptionTextMaskRect.fillRect(6, 53, 206, 57);
|
||||
|
||||
const abilityDescriptionTextMask = descriptionTextMaskRect.createGeometryMask();
|
||||
|
||||
descriptionTextObject.setMask(abilityDescriptionTextMask);
|
||||
|
||||
const descriptionLineCount = Math.floor(descriptionTextObject.displayHeight / 9.2);
|
||||
|
||||
if (this.descriptionScrollTween) {
|
||||
this.descriptionScrollTween.remove();
|
||||
this.descriptionScrollTween = undefined;
|
||||
}
|
||||
|
||||
// Animates the description text moving upwards
|
||||
if (descriptionLineCount > 6) {
|
||||
this.descriptionScrollTween = globalScene.tweens.add({
|
||||
targets: descriptionTextObject,
|
||||
delay: fixedInt(2000),
|
||||
loop: -1,
|
||||
hold: fixedInt(2000),
|
||||
duration: fixedInt((descriptionLineCount - 6) * 2000),
|
||||
y: `-=${10 * (descriptionLineCount - 6)}`,
|
||||
});
|
||||
}
|
||||
|
||||
this.descriptionContainer.add(descriptionTextObject);
|
||||
// prepare the description box
|
||||
this.desc = new ScrollingText(
|
||||
globalScene,
|
||||
6,
|
||||
22,
|
||||
830 / 6,
|
||||
62,
|
||||
6, // maxLineCount
|
||||
descriptionText ?? "", // initial content
|
||||
TextStyle.TOOLTIP_CONTENT,
|
||||
false,
|
||||
);
|
||||
this.desc.createMask(globalScene, 6, 50);
|
||||
this.descriptionContainer.add(this.desc);
|
||||
this.desc.activate();
|
||||
|
||||
const queryTextObject = addBBCodeTextObject(0, 0, queryText ?? "", TextStyle.TOOLTIP_CONTENT, {
|
||||
wordWrap: { width: 830 },
|
||||
@ -612,42 +595,25 @@ export class MysteryEncounterUiHandler extends UiHandler {
|
||||
}
|
||||
|
||||
if (text) {
|
||||
const tooltipTextObject = addBBCodeTextObject(6, 7, text, TextStyle.TOOLTIP_CONTENT, {
|
||||
wordWrap: { width: 600 },
|
||||
fontSize: "72px",
|
||||
padding: { top: 8 },
|
||||
lineSpacing: 1.25,
|
||||
});
|
||||
this.tooltipContainer.add(tooltipTextObject);
|
||||
|
||||
// Sets up the mask that hides the description text to give an illusion of scrolling
|
||||
const tooltipTextMaskRect = globalScene.make.graphics({});
|
||||
tooltipTextMaskRect.setScale(6);
|
||||
tooltipTextMaskRect.fillStyle(0xffffff);
|
||||
tooltipTextMaskRect.beginPath();
|
||||
tooltipTextMaskRect.fillRect(this.tooltipContainer.x, this.tooltipContainer.y + 188.5, 150, 32);
|
||||
|
||||
const textMask = tooltipTextMaskRect.createGeometryMask();
|
||||
tooltipTextObject.setMask(textMask);
|
||||
|
||||
const tooltipLineCount = Math.floor(tooltipTextObject.displayHeight / 10.2);
|
||||
|
||||
if (this.tooltipScrollTween) {
|
||||
this.tooltipScrollTween.remove();
|
||||
this.tooltipScrollTween = undefined;
|
||||
}
|
||||
|
||||
// Animates the tooltip text moving upwards
|
||||
if (tooltipLineCount > 3) {
|
||||
this.tooltipScrollTween = globalScene.tweens.add({
|
||||
targets: tooltipTextObject,
|
||||
delay: fixedInt(1200),
|
||||
loop: -1,
|
||||
hold: fixedInt(1200),
|
||||
duration: fixedInt((tooltipLineCount - 3) * 1200),
|
||||
y: `-=${11.2 * (tooltipLineCount - 3)}`,
|
||||
});
|
||||
}
|
||||
this.tooltipDesc = new ScrollingText(
|
||||
globalScene,
|
||||
6,
|
||||
5,
|
||||
96,
|
||||
32,
|
||||
3, // maxLineCount
|
||||
text ?? "", // initial content
|
||||
TextStyle.TOOLTIP_CONTENT,
|
||||
false,
|
||||
{
|
||||
fontSize: "72px",
|
||||
padding: { top: 8 },
|
||||
lineSpacing: 1.25,
|
||||
},
|
||||
);
|
||||
this.tooltipDesc.createMask(globalScene, this.tooltipContainer.x, this.tooltipContainer.y + 188.5);
|
||||
this.tooltipContainer.add(this.tooltipDesc);
|
||||
this.tooltipDesc.activate();
|
||||
}
|
||||
|
||||
// Dex progress indicator
|
||||
|
@ -2,7 +2,8 @@ import { globalScene } from "#app/global-scene";
|
||||
import { fixedInt } from "#app/utils/common";
|
||||
import type { TextStyle } from "#enums/text-style";
|
||||
import i18next from "i18next";
|
||||
import { addTextObject } from "./text";
|
||||
import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
||||
import { addBBCodeTextObject } from "./text";
|
||||
import { addWindow } from "./ui-theme";
|
||||
|
||||
/*
|
||||
@ -14,16 +15,16 @@ which takes as input the _global_ coordinates of scrolling text object. This is
|
||||
*/
|
||||
|
||||
const BORDER = 8;
|
||||
const SCALE_PROPERTY = 96 / 72 / 14.83;
|
||||
|
||||
export default class ScrollingText extends Phaser.GameObjects.Container {
|
||||
private descBg: Phaser.GameObjects.NineSlice;
|
||||
public text: Phaser.GameObjects.Text;
|
||||
public text: BBCodeText;
|
||||
private descScroll: Phaser.Tweens.Tween | null = null;
|
||||
private maxLineCount: number;
|
||||
|
||||
private offsetX: number;
|
||||
private offsetY: number;
|
||||
maskHeight: number;
|
||||
|
||||
constructor(
|
||||
scene: Phaser.Scene,
|
||||
@ -35,6 +36,7 @@ export default class ScrollingText extends Phaser.GameObjects.Container {
|
||||
content: string,
|
||||
style: TextStyle,
|
||||
hasBackground = false,
|
||||
extraStyleOptions: Phaser.Types.GameObjects.Text.TextStyle = {},
|
||||
) {
|
||||
super(scene, x, y);
|
||||
|
||||
@ -50,10 +52,11 @@ export default class ScrollingText extends Phaser.GameObjects.Container {
|
||||
// Adding the text element
|
||||
const wrapWidth = (width - (this.offsetX - 2) * 2) * 6;
|
||||
|
||||
this.text = addTextObject(this.offsetX, this.offsetY, content, style, {
|
||||
this.text = addBBCodeTextObject(this.offsetX, this.offsetY, content, style, {
|
||||
wordWrap: {
|
||||
width: wrapWidth,
|
||||
},
|
||||
...extraStyleOptions,
|
||||
});
|
||||
this.maxLineCount = maxLineCount;
|
||||
// TODO: change this based on which text is being used, etc
|
||||
@ -67,7 +70,8 @@ export default class ScrollingText extends Phaser.GameObjects.Container {
|
||||
const globalMaskY = globalY + this.offsetY;
|
||||
|
||||
const visibleWidth = this.descBg.width - (this.offsetX - 2) * 2;
|
||||
const visibleHeight = this.descBg.height - this.offsetY * 2;
|
||||
this.maskHeight = (this.text.style.lineHeight / 6) * this.maxLineCount;
|
||||
const visibleHeight = this.maskHeight;
|
||||
|
||||
const maskGraphics = scene.make.graphics({ x: 0, y: 0 });
|
||||
maskGraphics.fillRect(globalMaskX, globalMaskY, visibleWidth, visibleHeight);
|
||||
@ -88,17 +92,19 @@ export default class ScrollingText extends Phaser.GameObjects.Container {
|
||||
|
||||
// determine if we need to add new scrolling effects
|
||||
// TODO: The scale property may need to be adjusted based on the height of the font
|
||||
const lineCount = Math.floor(this.text.displayHeight * SCALE_PROPERTY);
|
||||
const displayHeight = this.text.displayHeight;
|
||||
const scrollAmount = displayHeight - this.maskHeight;
|
||||
const lineHeight = this.text.style.lineHeight / 6;
|
||||
|
||||
if (lineCount > this.maxLineCount) {
|
||||
if (scrollAmount) {
|
||||
// generate scrolling effects
|
||||
this.descScroll = globalScene.tweens.add({
|
||||
targets: this.text,
|
||||
delay: fixedInt(2000),
|
||||
loop: -1,
|
||||
hold: fixedInt(2000),
|
||||
duration: fixedInt((lineCount - this.maxLineCount) * 2000),
|
||||
y: `-=${(lineCount - this.maxLineCount) / SCALE_PROPERTY}`,
|
||||
duration: fixedInt((scrollAmount / lineHeight) * 2000),
|
||||
y: `-=${scrollAmount}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user