[Bug] Fix ME scrolling

This commit is contained in:
SmhMyHead 2025-06-03 12:48:50 +02:00
parent dd2f475ded
commit 5e2df13093

View File

@ -506,16 +506,18 @@ export default class MysteryEncounterUiHandler extends UiHandler {
// Sets up the mask that hides the description text to give an illusion of scrolling
const descriptionTextMaskRect = globalScene.make.graphics({});
const MaskHeight = 57;
descriptionTextMaskRect.setScale(6);
descriptionTextMaskRect.fillStyle(0xffffff);
descriptionTextMaskRect.beginPath();
descriptionTextMaskRect.fillRect(6, 53, 206, 57);
descriptionTextMaskRect.fillRect(6, 53, 206, MaskHeight);
const abilityDescriptionTextMask = descriptionTextMaskRect.createGeometryMask();
descriptionTextObject.setMask(abilityDescriptionTextMask);
const descriptionLineCount = Math.floor(descriptionTextObject.displayHeight / 10);
const displayHeight = descriptionTextObject.displayHeight;
const scrollAmount = displayHeight - MaskHeight;
if (this.descriptionScrollTween) {
this.descriptionScrollTween.remove();
@ -523,14 +525,14 @@ export default class MysteryEncounterUiHandler extends UiHandler {
}
// Animates the description text moving upwards
if (descriptionLineCount > 6) {
if (displayHeight > MaskHeight) {
this.descriptionScrollTween = globalScene.tweens.add({
targets: descriptionTextObject,
delay: fixedInt(2000),
loop: -1,
hold: fixedInt(2000),
duration: fixedInt((descriptionLineCount - 6) * 2000),
y: `-=${10 * (descriptionLineCount - 6)}`,
duration: fixedInt((scrollAmount / 10) * 2000),
y: `-=${scrollAmount}`,
});
}
@ -617,15 +619,17 @@ export default class MysteryEncounterUiHandler extends UiHandler {
// Sets up the mask that hides the description text to give an illusion of scrolling
const tooltipTextMaskRect = globalScene.make.graphics({});
const MaskHeight = 32;
tooltipTextMaskRect.setScale(6);
tooltipTextMaskRect.fillStyle(0xffffff);
tooltipTextMaskRect.beginPath();
tooltipTextMaskRect.fillRect(this.tooltipContainer.x, this.tooltipContainer.y + 188.5, 150, 32);
tooltipTextMaskRect.fillRect(this.tooltipContainer.x, this.tooltipContainer.y + 188.5, 150, MaskHeight);
const textMask = tooltipTextMaskRect.createGeometryMask();
tooltipTextObject.setMask(textMask);
const tooltipLineCount = Math.floor(tooltipTextObject.displayHeight / 11.2);
const displayHeight = tooltipTextObject.displayHeight;
const scrollAmount = displayHeight - MaskHeight;
if (this.tooltipScrollTween) {
this.tooltipScrollTween.remove();
@ -633,14 +637,14 @@ export default class MysteryEncounterUiHandler extends UiHandler {
}
// Animates the tooltip text moving upwards
if (tooltipLineCount > 3) {
if (displayHeight > MaskHeight) {
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)}`,
duration: fixedInt((scrollAmount / 11.2) * 1200),
y: `-=${scrollAmount}`,
});
}
}