1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 12:42:11 +00:00
OpenMW/apps/openmw/mwgui/screenfader.hpp
2020-10-16 22:18:54 +04:00

73 lines
1.7 KiB
C++

#ifndef OPENMW_MWGUI_SCREENFADER_H
#define OPENMW_MWGUI_SCREENFADER_H
#include <deque>
#include <memory>
#include "windowbase.hpp"
namespace MWGui
{
class ScreenFader;
class FadeOp
{
public:
typedef std::shared_ptr<FadeOp> Ptr;
FadeOp(ScreenFader * fader, float time, float targetAlpha, float delay);
bool isRunning();
void start();
void update(float dt);
void finish();
private:
ScreenFader * mFader;
float mRemainingTime;
float mTargetTime;
float mTargetAlpha;
float mStartAlpha;
float mDelay;
bool mRunning;
};
class ScreenFader : public WindowBase
{
public:
ScreenFader(const std::string & texturePath, const std::string& layout = "openmw_screen_fader.layout", const MyGUI::FloatCoord& texCoordOverride = MyGUI::FloatCoord(0,0,1,1));
~ScreenFader();
void onFrameStart(float dt);
void fadeIn(const float time, float delay=0);
void fadeOut(const float time, float delay=0);
void fadeTo(const int percent, const float time, float delay=0);
void clear() override;
void setFactor (float factor);
void setRepeat(bool repeat);
void queue(float time, float targetAlpha, float delay);
bool isEmpty();
void clearQueue();
void notifyAlphaChanged(float alpha);
void notifyOperationFinished();
float getCurrentAlpha();
private:
void applyAlpha();
float mCurrentAlpha;
float mFactor;
bool mRepeat; // repeat queued operations without removing them
std::deque<FadeOp::Ptr> mQueue;
};
}
#endif