2010-10-18 18:08:59 +03:00
|
|
|
/*
|
2023-02-01 16:42:03 +02:00
|
|
|
* CFadeAnimation.h, part of VCMI engine
|
2010-10-18 18:08:59 +03:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
2020-05-05 14:05:15 +02:00
|
|
|
#ifdef IN
|
|
|
|
#undef IN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OUT
|
|
|
|
#undef OUT
|
|
|
|
#endif
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
2023-01-18 17:32:57 +02:00
|
|
|
class Point;
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
|
|
struct SDL_Surface;
|
2010-10-18 18:08:59 +03:00
|
|
|
|
2015-02-18 16:31:55 +02:00
|
|
|
const float DEFAULT_DELTA = 0.05f;
|
|
|
|
|
2015-01-31 00:37:28 +02:00
|
|
|
class CFadeAnimation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class EMode
|
|
|
|
{
|
|
|
|
NONE, IN, OUT
|
|
|
|
};
|
|
|
|
private:
|
|
|
|
float delta;
|
|
|
|
SDL_Surface * fadingSurface;
|
|
|
|
bool fading;
|
|
|
|
float fadingCounter;
|
|
|
|
bool shouldFreeSurface;
|
2016-01-29 16:16:14 +02:00
|
|
|
|
2015-01-31 00:37:28 +02:00
|
|
|
float initialCounter() const;
|
|
|
|
bool isFinished() const;
|
|
|
|
public:
|
|
|
|
EMode fadingMode;
|
|
|
|
|
|
|
|
CFadeAnimation();
|
|
|
|
~CFadeAnimation();
|
2015-02-02 18:42:42 +02:00
|
|
|
void init(EMode mode, SDL_Surface * sourceSurface, bool freeSurfaceAtEnd = false, float animDelta = DEFAULT_DELTA);
|
2015-01-31 00:37:28 +02:00
|
|
|
void update();
|
2023-01-17 22:01:35 +02:00
|
|
|
void draw(SDL_Surface * targetSurface, const Point & targetPoint);
|
2015-01-31 00:37:28 +02:00
|
|
|
bool isFading() const { return fading; }
|
|
|
|
};
|