Skip to content

Commit

Permalink
UI|Client: After startup busy mode, do a fade from black
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Aug 24, 2015
1 parent c42cc6f commit f368661
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doomsday/apps/client/include/ui/clientwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <de/PersistentCanvasWindow>
#include <de/BaseWindow>
#include <de/NotificationAreaWidget>
#include <de/FadeToBlackWidget>

#include "ui/clientrootwidget.h"
#include "resource/image.h"
Expand Down Expand Up @@ -150,6 +151,9 @@ class ClientWindow : public de::BaseWindow,
*/
void drawGameContent();

void fadeContentFromBlack(de::TimeDelta const &duration);
de::FadeToBlackWidget *contentFade();

void fadeInTaskBarBlur(de::TimeDelta span);
void fadeOutTaskBarBlur(de::TimeDelta span);

Expand Down
12 changes: 12 additions & 0 deletions doomsday/apps/client/src/busyrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ DENG2_PIMPL_NOREF(BusyRunner)
timespan_t busyTime = 0;
bool busyWillAnimateTransition = false;
bool busyWasIgnoringInput = false;
bool fadeFromBlack = false;

Instance()
{
Expand All @@ -80,13 +81,19 @@ DENG2_PIMPL_NOREF(BusyRunner)

void busyModeWillBegin(BusyTask &firstTask)
{
if(auto *fader = ClientWindow::main().contentFade())
{
fader->cancel();
}

// Are we doing a transition effect?
busyWillAnimateTransition = animatedTransitionActive(firstTask.mode);
if(busyWillAnimateTransition)
{
Con_TransitionConfigure();
}

fadeFromBlack = (firstTask.mode & BUSYF_STARTUP) != 0;
busyWasIgnoringInput = ClientApp::inputSystem().ignoreEvents();

// Limit frame rate to 60, no point pushing it any faster while busy.
Expand Down Expand Up @@ -136,6 +143,11 @@ DENG2_PIMPL_NOREF(BusyRunner)
busyThread = nullptr;

eventLoop->exit(result);

if(fadeFromBlack)
{
ClientWindow::main().fadeContentFromBlack(2);
}
}
};

Expand Down
37 changes: 36 additions & 1 deletion doomsday/apps/client/src/ui/clientwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
#include <de/Drawable>
#include <de/CompositorWidget>
#include <de/NotificationAreaWidget>
#include <de/FadeToBlackWidget>
#include <de/SignalAction>
#include <de/VRWindowTransform>
#include <de/GuiWidgetRef>
#include <de/concurrency.h>
#include <doomsday/console/exec.h>
#include "api_console.h"
Expand Down Expand Up @@ -96,8 +98,9 @@ DENG2_PIMPL(ClientWindow)
LabelWidget *background = nullptr;
GuiWidget *iwadNotice = nullptr;
GameSelectionWidget *gameSelMenu = nullptr;
GuiWidgetRef<FadeToBlackWidget> fader;
BusyWidget *busy = nullptr;
GuiWidget *sidebar = nullptr;
GuiWidget *sidebar = nullptr;
PrivilegedLogWidget *privLog = nullptr;
LabelWidget *cursor = nullptr;
ConstantRule *cursorX;
Expand Down Expand Up @@ -824,6 +827,27 @@ DENG2_PIMPL(ClientWindow)
cursorHasBeenHidden = false;
}
}

void setupFadeFromBlack(TimeDelta const &span)
{
if(!fader)
{
fader.reset(new FadeToBlackWidget);
fader->rule().setRect(root.viewRule());
root.add(fader); // on top of everything else
}
fader->initFadeFromBlack(span);
fader->start();
}

void completeFade()
{
// Check if the fade is done.
if(fader)
{
fader->disposeIfDone();
}
}
};

ClientWindow::ClientWindow(String const &id)
Expand Down Expand Up @@ -999,6 +1023,7 @@ void ClientWindow::postDraw()

ClientApp::app().postFrame(); /// @todo what about multiwindow?
d->updateFpsNotification(frameRate());
d->completeFade();
}

void ClientWindow::canvasGLResized(Canvas &canvas)
Expand Down Expand Up @@ -1214,6 +1239,16 @@ bool ClientWindow::handleFallbackEvent(Event const &event)
return d->handleFallbackEvent(event);
}

void ClientWindow::fadeContentFromBlack(TimeDelta const &duration)
{
d->setupFadeFromBlack(duration);
}

FadeToBlackWidget *ClientWindow::contentFade()
{
return d->fader;
}

#if defined(UNIX) && !defined(MACOSX)
void GL_AssertContextActive()
{
Expand Down

0 comments on commit f368661

Please sign in to comment.