mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
Add 'delay' argument for screen fading operations
This commit is contained in:
parent
c035548f37
commit
d78e822833
@ -317,11 +317,11 @@ namespace MWBase
|
||||
virtual void pinWindow (MWGui::GuiWindow window) = 0;
|
||||
|
||||
/// Fade the screen in, over \a time seconds
|
||||
virtual void fadeScreenIn(const float time, bool clearQueue=true) = 0;
|
||||
virtual void fadeScreenIn(const float time, bool clearQueue=true, float delay=0.f) = 0;
|
||||
/// Fade the screen out to black, over \a time seconds
|
||||
virtual void fadeScreenOut(const float time, bool clearQueue=true) = 0;
|
||||
virtual void fadeScreenOut(const float time, bool clearQueue=true, float delay=0.f) = 0;
|
||||
/// Fade the screen to a specified percentage of black, over \a time seconds
|
||||
virtual void fadeScreenTo(const int percent, const float time, bool clearQueue=true) = 0;
|
||||
virtual void fadeScreenTo(const int percent, const float time, bool clearQueue=true, float delay=0.f) = 0;
|
||||
/// Darken the screen to a specified percentage
|
||||
virtual void setBlindness(const int percent) = 0;
|
||||
|
||||
|
@ -6,12 +6,13 @@
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
FadeOp::FadeOp(ScreenFader * fader, float time, float targetAlpha)
|
||||
FadeOp::FadeOp(ScreenFader * fader, float time, float targetAlpha, float delay)
|
||||
: mFader(fader),
|
||||
mRemainingTime(time),
|
||||
mRemainingTime(time+delay),
|
||||
mTargetTime(time),
|
||||
mTargetAlpha(targetAlpha),
|
||||
mStartAlpha(0.f),
|
||||
mDelay(delay),
|
||||
mRunning(false)
|
||||
{
|
||||
}
|
||||
@ -26,7 +27,7 @@ namespace MWGui
|
||||
if (mRunning)
|
||||
return;
|
||||
|
||||
mRemainingTime = mTargetTime;
|
||||
mRemainingTime = mTargetTime + mDelay;
|
||||
mStartAlpha = mFader->getCurrentAlpha();
|
||||
mRunning = true;
|
||||
}
|
||||
@ -42,6 +43,12 @@ namespace MWGui
|
||||
return;
|
||||
}
|
||||
|
||||
if (mRemainingTime > mTargetTime)
|
||||
{
|
||||
mRemainingTime -= dt;
|
||||
return;
|
||||
}
|
||||
|
||||
float currentAlpha = mFader->getCurrentAlpha();
|
||||
if (mStartAlpha > mTargetAlpha)
|
||||
{
|
||||
@ -103,19 +110,19 @@ namespace MWGui
|
||||
mMainWidget->setAlpha(1.f-((1.f-mCurrentAlpha) * mFactor));
|
||||
}
|
||||
|
||||
void ScreenFader::fadeIn(float time)
|
||||
void ScreenFader::fadeIn(float time, float delay)
|
||||
{
|
||||
queue(time, 1.f);
|
||||
queue(time, 1.f, delay);
|
||||
}
|
||||
|
||||
void ScreenFader::fadeOut(const float time)
|
||||
void ScreenFader::fadeOut(const float time, float delay)
|
||||
{
|
||||
queue(time, 0.f);
|
||||
queue(time, 0.f, delay);
|
||||
}
|
||||
|
||||
void ScreenFader::fadeTo(const int percent, const float time)
|
||||
void ScreenFader::fadeTo(const int percent, const float time, float delay)
|
||||
{
|
||||
queue(time, percent/100.f);
|
||||
queue(time, percent/100.f, delay);
|
||||
}
|
||||
|
||||
void ScreenFader::clear()
|
||||
@ -135,7 +142,7 @@ namespace MWGui
|
||||
mRepeat = repeat;
|
||||
}
|
||||
|
||||
void ScreenFader::queue(float time, float targetAlpha)
|
||||
void ScreenFader::queue(float time, float targetAlpha, float delay)
|
||||
{
|
||||
if (time < 0.f)
|
||||
return;
|
||||
@ -147,7 +154,7 @@ namespace MWGui
|
||||
return;
|
||||
}
|
||||
|
||||
mQueue.push_back(FadeOp::Ptr(new FadeOp(this, time, targetAlpha)));
|
||||
mQueue.push_back(FadeOp::Ptr(new FadeOp(this, time, targetAlpha, delay)));
|
||||
}
|
||||
|
||||
bool ScreenFader::isEmpty()
|
||||
|
@ -14,7 +14,7 @@ namespace MWGui
|
||||
public:
|
||||
typedef std::shared_ptr<FadeOp> Ptr;
|
||||
|
||||
FadeOp(ScreenFader * fader, float time, float targetAlpha);
|
||||
FadeOp(ScreenFader * fader, float time, float targetAlpha, float delay);
|
||||
|
||||
bool isRunning();
|
||||
|
||||
@ -28,6 +28,7 @@ namespace MWGui
|
||||
float mTargetTime;
|
||||
float mTargetAlpha;
|
||||
float mStartAlpha;
|
||||
float mDelay;
|
||||
bool mRunning;
|
||||
};
|
||||
|
||||
@ -38,16 +39,16 @@ namespace MWGui
|
||||
|
||||
void update(float dt);
|
||||
|
||||
void fadeIn(const float time);
|
||||
void fadeOut(const float time);
|
||||
void fadeTo(const int percent, const float time);
|
||||
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();
|
||||
|
||||
void setFactor (float factor);
|
||||
void setRepeat(bool repeat);
|
||||
|
||||
void queue(float time, float targetAlpha);
|
||||
void queue(float time, float targetAlpha, float delay);
|
||||
bool isEmpty();
|
||||
void clearQueue();
|
||||
|
||||
|
@ -40,7 +40,6 @@ namespace MWGui
|
||||
|
||||
TrainingWindow::TrainingWindow()
|
||||
: WindowBase("openmw_trainingwindow.layout")
|
||||
, mFadeTimeRemaining(0)
|
||||
, mTimeAdvancer(0.05f)
|
||||
{
|
||||
getWidget(mTrainingOptions, "TrainingOptions");
|
||||
@ -183,7 +182,7 @@ namespace MWGui
|
||||
mTimeAdvancer.run(2);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.25);
|
||||
mFadeTimeRemaining = 0.5;
|
||||
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.25, false, 0.25);
|
||||
}
|
||||
|
||||
void TrainingWindow::onTrainingProgressChanged(int cur, int total)
|
||||
@ -204,13 +203,5 @@ namespace MWGui
|
||||
{
|
||||
checkReferenceAvailable();
|
||||
mTimeAdvancer.onFrame(dt);
|
||||
|
||||
if (mFadeTimeRemaining <= 0)
|
||||
return;
|
||||
|
||||
mFadeTimeRemaining -= dt;
|
||||
|
||||
if (mFadeTimeRemaining <= 0)
|
||||
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.25);
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,6 @@ namespace MWGui
|
||||
MyGUI::Button* mCancelButton;
|
||||
MyGUI::TextBox* mPlayerGold;
|
||||
|
||||
float mFadeTimeRemaining;
|
||||
|
||||
WaitDialogProgressBar mProgressBar;
|
||||
TimeAdvancer mTimeAdvancer;
|
||||
};
|
||||
|
@ -1788,25 +1788,25 @@ namespace MWGui
|
||||
updateVisible();
|
||||
}
|
||||
|
||||
void WindowManager::fadeScreenIn(const float time, bool clearQueue)
|
||||
void WindowManager::fadeScreenIn(const float time, bool clearQueue, float delay)
|
||||
{
|
||||
if (clearQueue)
|
||||
mScreenFader->clearQueue();
|
||||
mScreenFader->fadeOut(time);
|
||||
mScreenFader->fadeOut(time, delay);
|
||||
}
|
||||
|
||||
void WindowManager::fadeScreenOut(const float time, bool clearQueue)
|
||||
void WindowManager::fadeScreenOut(const float time, bool clearQueue, float delay)
|
||||
{
|
||||
if (clearQueue)
|
||||
mScreenFader->clearQueue();
|
||||
mScreenFader->fadeIn(time);
|
||||
mScreenFader->fadeIn(time, delay);
|
||||
}
|
||||
|
||||
void WindowManager::fadeScreenTo(const int percent, const float time, bool clearQueue)
|
||||
void WindowManager::fadeScreenTo(const int percent, const float time, bool clearQueue, float delay)
|
||||
{
|
||||
if (clearQueue)
|
||||
mScreenFader->clearQueue();
|
||||
mScreenFader->fadeTo(percent, time);
|
||||
mScreenFader->fadeTo(percent, time, delay);
|
||||
}
|
||||
|
||||
void WindowManager::setBlindness(const int percent)
|
||||
|
@ -344,11 +344,11 @@ namespace MWGui
|
||||
virtual void pinWindow (MWGui::GuiWindow window);
|
||||
|
||||
/// Fade the screen in, over \a time seconds
|
||||
virtual void fadeScreenIn(const float time, bool clearQueue);
|
||||
virtual void fadeScreenIn(const float time, bool clearQueue, float delay);
|
||||
/// Fade the screen out to black, over \a time seconds
|
||||
virtual void fadeScreenOut(const float time, bool clearQueue);
|
||||
virtual void fadeScreenOut(const float time, bool clearQueue, float delay);
|
||||
/// Fade the screen to a specified percentage of black, over \a time seconds
|
||||
virtual void fadeScreenTo(const int percent, const float time, bool clearQueue);
|
||||
virtual void fadeScreenTo(const int percent, const float time, bool clearQueue, float delay);
|
||||
/// Darken the screen to a specified percentage
|
||||
virtual void setBlindness(const int percent);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user