Use MyGUI frame events for ScreenFader

new-script-api
scrawl 7 years ago
parent e4f0f7157a
commit a4737d8417

@ -2,6 +2,7 @@
#include <MyGUI_RenderManager.h> #include <MyGUI_RenderManager.h>
#include <MyGUI_ImageBox.h> #include <MyGUI_ImageBox.h>
#include <MyGUI_Gui.h>
namespace MWGui namespace MWGui
{ {
@ -80,6 +81,8 @@ namespace MWGui
, mFactor(1.f) , mFactor(1.f)
, mRepeat(false) , mRepeat(false)
{ {
MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &ScreenFader::onFrameStart);
mMainWidget->setSize(MyGUI::RenderManager::getInstance().getViewSize()); mMainWidget->setSize(MyGUI::RenderManager::getInstance().getViewSize());
MyGUI::ImageBox* imageBox = mMainWidget->castType<MyGUI::ImageBox>(false); MyGUI::ImageBox* imageBox = mMainWidget->castType<MyGUI::ImageBox>(false);
@ -94,7 +97,12 @@ namespace MWGui
} }
} }
void ScreenFader::update(float dt) ScreenFader::~ScreenFader()
{
MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &ScreenFader::onFrameStart);
}
void ScreenFader::onFrameStart(float dt)
{ {
if (!mQueue.empty()) if (!mQueue.empty())
{ {

@ -36,8 +36,9 @@ namespace MWGui
{ {
public: 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(const std::string & texturePath, const std::string& layout = "openmw_screen_fader.layout", const MyGUI::FloatCoord& texCoordOverride = MyGUI::FloatCoord(0,0,1,1));
~ScreenFader();
void update(float dt); void onFrameStart(float dt);
void fadeIn(const float time, float delay=0); void fadeIn(const float time, float delay=0);
void fadeOut(const float time, float delay=0); void fadeOut(const float time, float delay=0);

@ -894,12 +894,6 @@ namespace MWGui
mHud->onFrame(frameDuration); mHud->onFrame(frameDuration);
if (mWerewolfFader)
mWerewolfFader->update(frameDuration);
mBlindnessFader->update(frameDuration);
mHitFader->update(frameDuration);
mScreenFader->update(frameDuration);
mDebugWindow->onFrame(frameDuration); mDebugWindow->onFrame(frameDuration);
if (mCharGen) if (mCharGen)

Loading…
Cancel
Save