Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Refactor] Consolidate all try/catch for animations in a single place #378

Draft
wants to merge 4 commits into
base: beta
Choose a base branch
from

Conversation

DayKev
Copy link
Contributor

@DayKev DayKev commented Jan 27, 2025

What are the changes the user will see?

N/A

Why am I making these changes?

To simplify development.

What are the changes from a developer perspective?

All try/catch statements around sprite animations are removed, and centralized into the existing replacement function in src/ui/ui-theme.ts. Important changes are in src/field/pokemon.ts and src/ui/ui-theme.ts.

Try/catch removed in: src/data/mystery-encounters/encounters/global-trade-system-encounter.ts, src/data/mystery-encounters/utils/encounter-transformation-sequence.ts, src/phases/abstract-form-change-base-phase.ts, src/phases/egg-hatch-phase.ts, src/phases/evolution-phase.ts, src/phases/form-change-phase.ts, src/phases/quiet-form-change-phase.ts, src/ui/summary-ui-handler.ts.

Screenshots/Videos

missing.sprite.animation.test.mp4

Checklist

  • I'm using beta as my base branch
  • There is no overlap with another PR?
  • The PR is self-contained and cannot be split into smaller PRs?
  • Have I provided a clear explanation of the changes?
  • Have I tested the changes manually?
  • Are all unit tests still passing? (npm run test:silent)
  • Have I provided screenshots/videos of the changes (if applicable)?

@DayKev DayKev added the Refactor For refactoring code label Jan 27, 2025
@DayKev DayKev marked this pull request as ready for review January 27, 2025 02:25
} catch (err: unknown) {
console.error(`Failed to play animation for ${spriteKey}`, err);
}
sprite.play(spriteKey).stop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on some playtesting, the stop() function can still crash here. This can be fixed by also overriding stop() to use a try-catch.

@MokaStitcher
Copy link
Contributor

The merge of #419 means that the globalScene.add functions overrides are no longer present on beta

So not sure where to go from there for this PR. Maybe keep the current solution but put it elsewhere, or try to make things a bit cleaner with our own custom sprite object.
I think it should be possible to extend Sprite with our own custom class and replace all scene.add.Sprite(..) with sprite = new PktySprite(..); scene.add.existing(sprite). Or make a new scene.add.PktySprite that does this
That is, assuming this is all that scene.add.sprite does. Which I'm sadly not 100% sure of

@DayKev DayKev marked this pull request as draft February 15, 2025 01:02
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Refactor For refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants