mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-04-22 06:02:04 +02:00
Make bitmap animation functions properly check for disposal
This commit is contained in:
parent
41e7192e4e
commit
1cf56043cb
1 changed files with 31 additions and 0 deletions
|
@ -640,6 +640,7 @@ Bitmap::Bitmap(void *pixeldata, int width, int height)
|
||||||
// frame is -2 for "any and all", -1 for "current", anything else for a specific frame
|
// frame is -2 for "any and all", -1 for "current", anything else for a specific frame
|
||||||
Bitmap::Bitmap(const Bitmap &other, int frame)
|
Bitmap::Bitmap(const Bitmap &other, int frame)
|
||||||
{
|
{
|
||||||
|
other.guardDisposed();
|
||||||
other.ensureNonMega();
|
other.ensureNonMega();
|
||||||
if (frame > -2) other.ensureAnimated();
|
if (frame > -2) other.ensureAnimated();
|
||||||
|
|
||||||
|
@ -1830,6 +1831,8 @@ void Bitmap::ensureNotPlaying() const
|
||||||
|
|
||||||
void Bitmap::stop()
|
void Bitmap::stop()
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_UNANIMATED;
|
GUARD_UNANIMATED;
|
||||||
if (!p->animation.playing) return;
|
if (!p->animation.playing) return;
|
||||||
|
|
||||||
|
@ -1838,6 +1841,8 @@ void Bitmap::stop()
|
||||||
|
|
||||||
void Bitmap::play()
|
void Bitmap::play()
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_UNANIMATED;
|
GUARD_UNANIMATED;
|
||||||
if (p->animation.playing) return;
|
if (p->animation.playing) return;
|
||||||
p->animation.play();
|
p->animation.play();
|
||||||
|
@ -1845,6 +1850,8 @@ void Bitmap::play()
|
||||||
|
|
||||||
bool Bitmap::isPlaying() const
|
bool Bitmap::isPlaying() const
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
if (!p->animation.playing)
|
if (!p->animation.playing)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1856,6 +1863,8 @@ bool Bitmap::isPlaying() const
|
||||||
|
|
||||||
void Bitmap::gotoAndStop(int frame)
|
void Bitmap::gotoAndStop(int frame)
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_UNANIMATED;
|
GUARD_UNANIMATED;
|
||||||
|
|
||||||
p->animation.stop();
|
p->animation.stop();
|
||||||
|
@ -1863,6 +1872,8 @@ void Bitmap::gotoAndStop(int frame)
|
||||||
}
|
}
|
||||||
void Bitmap::gotoAndPlay(int frame)
|
void Bitmap::gotoAndPlay(int frame)
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_UNANIMATED;
|
GUARD_UNANIMATED;
|
||||||
|
|
||||||
p->animation.stop();
|
p->animation.stop();
|
||||||
|
@ -1872,18 +1883,24 @@ void Bitmap::gotoAndPlay(int frame)
|
||||||
|
|
||||||
int Bitmap::numFrames() const
|
int Bitmap::numFrames() const
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
if (!p->animation.enabled) return 1;
|
if (!p->animation.enabled) return 1;
|
||||||
return (int)p->animation.frames.size();
|
return (int)p->animation.frames.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Bitmap::currentFrameI() const
|
int Bitmap::currentFrameI() const
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
if (!p->animation.enabled) return 0;
|
if (!p->animation.enabled) return 0;
|
||||||
return p->animation.currentFrameI();
|
return p->animation.currentFrameI();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Bitmap::addFrame(Bitmap &source, int position)
|
int Bitmap::addFrame(Bitmap &source, int position)
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_MEGA;
|
GUARD_MEGA;
|
||||||
|
|
||||||
source.ensureNotPlaying();
|
source.ensureNotPlaying();
|
||||||
|
@ -1939,6 +1956,8 @@ int Bitmap::addFrame(Bitmap &source, int position)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bitmap::removeFrame(int position) {
|
void Bitmap::removeFrame(int position) {
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_UNANIMATED;
|
GUARD_UNANIMATED;
|
||||||
|
|
||||||
int pos = (position < 0) ? (int)p->animation.frames.size() - 1 : clamp(position, 0, (int)(p->animation.frames.size() - 1));
|
int pos = (position < 0) ? (int)p->animation.frames.size() - 1 : clamp(position, 0, (int)(p->animation.frames.size() - 1));
|
||||||
|
@ -1965,6 +1984,8 @@ void Bitmap::removeFrame(int position) {
|
||||||
|
|
||||||
void Bitmap::nextFrame()
|
void Bitmap::nextFrame()
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_UNANIMATED;
|
GUARD_UNANIMATED;
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
@ -1979,6 +2000,8 @@ void Bitmap::nextFrame()
|
||||||
|
|
||||||
void Bitmap::previousFrame()
|
void Bitmap::previousFrame()
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_UNANIMATED;
|
GUARD_UNANIMATED;
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
@ -1997,6 +2020,8 @@ void Bitmap::previousFrame()
|
||||||
|
|
||||||
void Bitmap::setAnimationFPS(float FPS)
|
void Bitmap::setAnimationFPS(float FPS)
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_MEGA;
|
GUARD_MEGA;
|
||||||
|
|
||||||
bool restart = p->animation.playing;
|
bool restart = p->animation.playing;
|
||||||
|
@ -2012,6 +2037,8 @@ std::vector<TEXFBO> &Bitmap::getFrames() const
|
||||||
|
|
||||||
float Bitmap::getAnimationFPS() const
|
float Bitmap::getAnimationFPS() const
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_MEGA;
|
GUARD_MEGA;
|
||||||
|
|
||||||
return p->animation.fps;
|
return p->animation.fps;
|
||||||
|
@ -2019,6 +2046,8 @@ float Bitmap::getAnimationFPS() const
|
||||||
|
|
||||||
void Bitmap::setLooping(bool loop)
|
void Bitmap::setLooping(bool loop)
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_MEGA;
|
GUARD_MEGA;
|
||||||
|
|
||||||
p->animation.loop = loop;
|
p->animation.loop = loop;
|
||||||
|
@ -2026,6 +2055,8 @@ void Bitmap::setLooping(bool loop)
|
||||||
|
|
||||||
bool Bitmap::getLooping() const
|
bool Bitmap::getLooping() const
|
||||||
{
|
{
|
||||||
|
guardDisposed();
|
||||||
|
|
||||||
GUARD_MEGA;
|
GUARD_MEGA;
|
||||||
|
|
||||||
return p->animation.loop;
|
return p->animation.loop;
|
||||||
|
|
Loading…
Add table
Reference in a new issue