Skip to content

Commit

Permalink
UI|SavegameSelectionWidget: Added a basic UI widget for saved session…
Browse files Browse the repository at this point in the history
… management

I'm not at all happy with how this works from a usability perspective.
The main point was to get something working that can improved further
once automatic conversion of legacy saved games is working.

Note that is (heavily) based on the MPSelectionWidget.
  • Loading branch information
danij-deng committed Mar 16, 2014
1 parent 05dc05e commit 4b1b58e
Show file tree
Hide file tree
Showing 5 changed files with 389 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/client.pro
Expand Up @@ -404,6 +404,7 @@ DENG_HEADERS += \
include/ui/widgets/mpselectionwidget.h \
include/ui/widgets/multiplayermenuwidget.h \
include/ui/widgets/profilepickerwidget.h \
include/ui/widgets/savegameselectionwidget.h \
include/ui/widgets/taskbarwidget.h \
include/ui/widgets/tutorialwidget.h \
include/ui/fi_main.h \
Expand Down Expand Up @@ -741,6 +742,7 @@ SOURCES += \
src/ui/widgets/mpselectionwidget.cpp \
src/ui/widgets/multiplayermenuwidget.cpp \
src/ui/widgets/profilepickerwidget.cpp \
src/ui/widgets/savegameselectionwidget.cpp \
src/ui/widgets/taskbarwidget.cpp \
src/ui/widgets/tutorialwidget.cpp \
src/ui/zonedebug.cpp \
Expand Down
78 changes: 78 additions & 0 deletions doomsday/client/include/ui/widgets/savegameselectionwidget.h
@@ -0,0 +1,78 @@
/** @file savegameselectionwidget.h
*
* @authors Copyright © 2014 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2014 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef DENG_CLIENT_SAVEGAMESELECTIONWIDGET_H
#define DENG_CLIENT_SAVEGAMESELECTIONWIDGET_H

#include <de/MenuWidget>
#include <de/game/SavedSession>

/**
* Menu that populates itself with available saved game sessions.
*
* @ingroup ui
*/
class SavegameSelectionWidget : public de::MenuWidget
{
Q_OBJECT

public:
DENG2_DEFINE_AUDIENCE(Selection, void gameSelected(de::game::SavedSession const &session))

/**
* Action for loading a saved session.
*/
class LoadAction : public de::Action
{
public:
LoadAction(de::game::SavedSession const &session);
void trigger();

private:
DENG2_PRIVATE(d)
};

public:
SavegameSelectionWidget();

/**
* Enables or disables loading saved game sessions by pressing the menu items in the
* widget. By default, this is enabled. If disabled, one will only get a notification
* about the selection.
*
* @param enableLoad @c true to allow automatic loading, @c false to disallow.
*/
void setLoadGameWhenSelected(bool enableLoad);

void setColumns(int numberOfColumns);

de::game::SavedSession const &savedSession(de::ui::DataPos pos) const;

// Events.
void update();

signals:
void availabilityChanged();
void gameSelected();

private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_SAVEGAMESELECTIONWIDGET_H
1 change: 1 addition & 0 deletions doomsday/client/src/game.cpp
Expand Up @@ -25,6 +25,7 @@
#include "filesys/manifest.h"

#include <de/Error>
#include <de/game/SavedSession>
#include <de/Log>
#include <de/charsymbols.h>
#include <QtAlgorithms>
Expand Down
28 changes: 23 additions & 5 deletions doomsday/client/src/ui/widgets/gameselectionwidget.cpp
@@ -1,6 +1,7 @@
/** @file gameselectionwidget.cpp
*
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2013-2014 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2014 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -20,6 +21,7 @@
#include "ui/widgets/gamesessionwidget.h"
#include "ui/widgets/mpselectionwidget.h"
#include "ui/widgets/gamefilterwidget.h"
#include "ui/widgets/savegameselectionwidget.h"
#include "CommandAction"
#include "clientapp.h"
#include "games.h"
Expand Down Expand Up @@ -79,7 +81,8 @@ DENG_GUI_PIMPL(GameSelectionWidget)
{
enum Type {
NormalGames,
MultiplayerGames
MultiplayerGames,
SavedGames
};

String titleText;
Expand Down Expand Up @@ -113,6 +116,12 @@ DENG_GUI_PIMPL(GameSelectionWidget)
QObject::connect(menu, SIGNAL(gameSelected()), owner->thisPublic, SIGNAL(gameSessionSelected()));
QObject::connect(menu, SIGNAL(availabilityChanged()), owner->thisPublic, SLOT(updateSubsetLayout()));
break;

case SavedGames:
menu = new SavegameSelectionWidget;
QObject::connect(menu, SIGNAL(gameSelected()), owner->thisPublic, SIGNAL(gameSessionSelected()));
QObject::connect(menu, SIGNAL(availabilityChanged()), owner->thisPublic, SLOT(updateSubsetLayout()));
break;
}

menu->items().audienceForAddition() += this;
Expand Down Expand Up @@ -210,6 +219,7 @@ DENG_GUI_PIMPL(GameSelectionWidget)
SubsetWidget *available;
SubsetWidget *incomplete;
SubsetWidget *multi;
SubsetWidget *saved;
QList<SubsetWidget *> subsets; // not owned

Instance(Public *i)
Expand All @@ -229,8 +239,12 @@ DENG_GUI_PIMPL(GameSelectionWidget)
self.add(multi = new SubsetWidget("multi", SubsetWidget::MultiplayerGames,
tr("Multiplayer Games"), this));

// Menu of saved games.
self.add(saved = new SubsetWidget("saved", SubsetWidget::SavedGames,
tr("Saved Games"), this));

// Keep all sets in a handy list.
subsets << available << incomplete << multi;
subsets << available << incomplete << multi << saved;

self.add(filter = new GameFilterWidget);

Expand Down Expand Up @@ -263,6 +277,9 @@ DENG_GUI_PIMPL(GameSelectionWidget)
incomplete->show(sp);
incomplete->title().show(sp);

saved->show(sp);
saved->title().show(sp);

multi->show(mp);
multi->title().show(mp);
}
Expand All @@ -278,11 +295,11 @@ DENG_GUI_PIMPL(GameSelectionWidget)
QList<SubsetWidget *> order;
if(!App_GameLoaded())
{
order << available << multi << incomplete;
order << available << multi << saved << incomplete;
}
else
{
order << multi << available << incomplete;
order << saved << multi << available << incomplete;
}

updateSubsetVisibility();
Expand All @@ -293,6 +310,7 @@ DENG_GUI_PIMPL(GameSelectionWidget)
{
order.removeOne(available);
order.removeOne(incomplete);
order.removeOne(saved);
}
if(!flt.testFlag(GameFilterWidget::Multiplayer))
{
Expand Down

0 comments on commit 4b1b58e

Please sign in to comment.