Skip to content

Commit

Permalink
Updater|UI|Client: Usability improvements; cleanup
Browse files Browse the repository at this point in the history
The game is automatically paused when a background download completes
and the dialog is shown.

Added the option to abort the installation of an update even after
the download has finished.
  • Loading branch information
skyjake committed Aug 22, 2013
1 parent ddccbdd commit a6d1d0d
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 248 deletions.
Binary file modified doomsday/client/data/defaultstyle.pack/graphics/gear.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions doomsday/client/include/ui/widgets/taskbarwidget.h
Expand Up @@ -45,16 +45,14 @@ class TaskBarWidget : public GuiWidget
bool isOpen() const;
de::Rule const &shift();

void setOpeningAction(de::Action *action);
void setClosingAction(de::Action *action);

// Events.
void viewResized();
void drawContent();
bool handleEvent(de::Event const &event);

public slots:
void open(bool doAction = true);
void open();
void openAndPauseGame();
void close();
void openMainMenu();
void unloadGame();
Expand Down
8 changes: 5 additions & 3 deletions doomsday/client/include/updater/downloaddialog.h
Expand Up @@ -50,6 +50,11 @@ class DownloadDialog : public DialogWidget
bool isReadyToInstall() const;
bool isFailed() const;

public:
static bool isDownloadInProgress();
static DownloadDialog &currentDownload();
static void showCompletedDownload();

signals:
void downloadProgress(int percentage);
void downloadFailed(QString uri);
Expand All @@ -64,7 +69,4 @@ public slots:
DENG2_PRIVATE(d)
};

int Updater_IsDownloadInProgress(void);
void Updater_RaiseCompletedDownloadDialog(void);

#endif // DENG_CLIENT_DOWNLOADDIALOG_H
4 changes: 3 additions & 1 deletion doomsday/client/src/con_main.cpp
Expand Up @@ -2383,9 +2383,11 @@ D_CMD(Quit)
DENG2_UNUSED2(src, argc);

#ifdef __CLIENT__
if(Updater_IsDownloadInProgress())
if(DownloadDialog::isDownloadInProgress())
{
Con_Message("Cannot quit while downloading update.");
ClientWindow::main().taskBar().openAndPauseGame();
DownloadDialog::currentDownload().open();
return false;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/dd_plugin.cpp
Expand Up @@ -312,7 +312,7 @@ DENG_EXTERN_C void Plug_Notify(int notification, void* param)
// re-show the dialog now that the user has saved the game as
// prompted.
DEBUG_Message(("Plug_Notify: Game saved.\n"));
Updater_RaiseCompletedDownloadDialog();
DownloadDialog::showCompletedDownload();
break;
}
#else
Expand Down
10 changes: 6 additions & 4 deletions doomsday/client/src/ui/widgets/dialogwidget.cpp
Expand Up @@ -361,11 +361,13 @@ bool DialogWidget::handleEvent(Event const &event)
key.ddKey() == DDKEY_RETURN ||
key.ddKey() == ' ')
{
ui::ActionItem const *defaultAction = d->findDefaultAction();
ButtonWidget const &but = d->buttonWidget(*defaultAction);
if(but.action())
if(ui::ActionItem const *defaultAction = d->findDefaultAction())
{
but.action()->trigger();
ButtonWidget const &but = d->buttonWidget(*defaultAction);
if(but.action())
{
but.action()->trigger();
}
}
return true;
}
Expand Down
38 changes: 11 additions & 27 deletions doomsday/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -28,6 +28,7 @@
#include "ui/clientwindow.h"
#include "ui/commandaction.h"
#include "ui/signalaction.h"
#include "client/cl_def.h" // clientPaused

#include "ui/ui_main.h"
#include "con_main.h"
Expand Down Expand Up @@ -60,9 +61,6 @@ public IGameChangeObserver
LabelWidget *status;
PopupMenuWidget *mainMenu;
ScalarRule *vertShift;

QScopedPointer<Action> openAction;
QScopedPointer<Action> closeAction;
bool mouseWasTrappedWhenOpening;

// GL objects:
Expand Down Expand Up @@ -295,16 +293,6 @@ Rule const &TaskBarWidget::shift()
return *d->vertShift;
}

void TaskBarWidget::setOpeningAction(Action *action)
{
d->openAction.reset(action);
}

void TaskBarWidget::setClosingAction(Action *action)
{
d->closeAction.reset(action);
}

void TaskBarWidget::glInit()
{
LOG_AS("TaskBarWidget");
Expand Down Expand Up @@ -395,7 +383,7 @@ bool TaskBarWidget::handleEvent(Event const &event)
return false;
}

void TaskBarWidget::open(bool doAction)
void TaskBarWidget::open()
{
if(!d->opened)
{
Expand All @@ -410,14 +398,6 @@ void TaskBarWidget::open(bool doAction)

emit opened();

if(doAction)
{
if(!d->openAction.isNull())
{
d->openAction->trigger();
}
}

// Untrap the mouse if it is trapped.
if(hasRoot())
{
Expand All @@ -436,6 +416,15 @@ void TaskBarWidget::open(bool doAction)
}
}

void TaskBarWidget::openAndPauseGame()
{
if(App_GameLoaded() && !clientPaused)
{
Con_Execute(CMDS_DDAY, "pause", true, false);
}
open();
}

void TaskBarWidget::close()
{
if(d->opened)
Expand All @@ -459,11 +448,6 @@ void TaskBarWidget::close()

emit closed();

if(!d->closeAction.isNull())
{
d->closeAction->trigger();
}

// Retrap the mouse if it was trapped when opening.
if(hasRoot() && App_GameLoaded())
{
Expand Down

0 comments on commit a6d1d0d

Please sign in to comment.