updated engine initialization logic;

fade manager is now time-based instead of frame-based;
wiImage moved to namespace instead of static class;
refactors;
editor updates;
contributing updates;
This commit is contained in:
turanszkij
2018-10-26 18:35:11 +01:00
parent cde0cb5fcd
commit 9f056b4cfe
49 changed files with 1630 additions and 1653 deletions
+22 -15
View File
@@ -3,41 +3,48 @@
void wiFadeManager::Clear()
{
opacity = 0;
frame = 0;
state = FADE_FINISHED;
color = wiColor(0, 0, 0, 1);
}
void wiFadeManager::Update()
void wiFadeManager::Update(float dt)
{
if (!IsActive())
return;
opacity = wiMath::Lerp(0.0f, 1.0f, (float)frame / (float)targetFrames);
if (targetFadeTimeInSeconds <= 0)
{
// skip fade, just launch the job
onFade();
state = FADE_FINISHED;
}
float t = timer / targetFadeTimeInSeconds;
timer += wiMath::Clamp(dt, 0, 0.033f);
if (state == FADE_IN)
{
frame++;
if (frame >= targetFrames)
opacity = wiMath::Lerp(0.0f, 1.0f, t);
if (t >= 1.0f)
{
state = FADE_MID;
opacity = 1.0f;
}
}
else if (state == FADE_OUT)
{
frame--;
if (frame <= 0)
{
state = FADE_FINISHED;
opacity = 0.0f;
}
}
else if (state == FADE_MID)
{
state = FADE_OUT;
opacity = 1.0f;
onFade();
timer = 0;
}
else if (state == FADE_OUT)
{
opacity = wiMath::Lerp(1.0f, 0.0f, t);
if (t >= 1.0f)
{
state = FADE_FINISHED;
opacity = 0.0f;
}
}
else if (state == FADE_FINISHED)
{