Skip to content

Commit

Permalink
Refactor|Client|libdoomsday: Use de::FileIndex for savegames; renamed…
Browse files Browse the repository at this point in the history
… save classes

Most of the changes here are renamed classes. The only functional
difference is that the special-purpose SavedIndex has been replaced
with the GameStateFolder FileIndex, since that is already provided by
the file system without any additional work.
  • Loading branch information
skyjake committed Nov 25, 2016
1 parent 9b7c1a9 commit 4fecd87
Show file tree
Hide file tree
Showing 44 changed files with 682 additions and 756 deletions.
4 changes: 2 additions & 2 deletions doomsday/apps/client/include/ui/home/gamecolumnwidget.h
Expand Up @@ -23,15 +23,15 @@

#include <de/IPersistent>

class SavedSessionListData;
class SaveListData;

class GameColumnWidget : public ColumnWidget, public de::IPersistent
{
Q_OBJECT

public:
GameColumnWidget(de::String const &gameFamily,
SavedSessionListData const &savedItems);
SaveListData const &savedItems);

de::String tabHeading() const override;
de::String configVariableName() const override;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/include/ui/home/gamepanelbuttonwidget.h
Expand Up @@ -23,7 +23,7 @@

#include <doomsday/gameprofiles.h>

class SavedSessionListData;
class SaveListData;

/**
* Drawer button for a particular game. Also shows the list of saved games.
Expand All @@ -34,7 +34,7 @@ class GamePanelButtonWidget : public PanelButtonWidget

public:
GamePanelButtonWidget(GameProfile &game,
SavedSessionListData const &savedItems);
SaveListData const &savedItems);

void setSelected(bool selected) override;

Expand Down
@@ -1,4 +1,4 @@
/** @file savedsessionlistdata.h UI data items representing available saved games.
/** @file savelistdata.h UI data items representing available saved games.
*
* @authors Copyright (c) 2016 Jaakko Keränen <jaakko.keranen@iki.fi>
*
Expand All @@ -16,25 +16,25 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef DENG_CLIENT_UI_SAVEDSESSIONLISTDATA_H
#define DENG_CLIENT_UI_SAVEDSESSIONLISTDATA_H
#ifndef DENG_CLIENT_UI_SAVELISTDATA_H
#define DENG_CLIENT_UI_SAVELISTDATA_H

#include <de/ui/ListData>
#include <de/ui/ImageItem>
#include <doomsday/SavedSession>
#include <doomsday/GameStateFolder>

/**
* List data model for available saved sessions.
*/
class SavedSessionListData : public de::ui::ListData
class SaveListData : public de::ui::ListData
{
public:
struct SaveItem : public de::ui::ImageItem,
DENG2_OBSERVES(de::File, Deletion)
{
SavedSession const *session;
GameStateFolder const *saveFolder;

SaveItem(SavedSession const &session);
SaveItem(GameStateFolder const &saveFolder);
~SaveItem();

bool isValid() const;
Expand All @@ -48,7 +48,7 @@ class SavedSessionListData : public de::ui::ListData
};

public:
SavedSessionListData();
SaveListData();

SaveItem &at(Pos pos) override;
SaveItem const &at(Pos pos) const override;
Expand All @@ -57,4 +57,4 @@ class SavedSessionListData : public de::ui::ListData
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_UI_SAVEDSESSIONLISTDATA_H
#endif // DENG_CLIENT_UI_SAVELISTDATA_H
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -57,7 +57,7 @@
# include <de/texgamma.h>
# include <de/DisplayMode>
#endif
#include <doomsday/Session>
#include <doomsday/AbstractSession>
#include <doomsday/console/alias.h>
#include <doomsday/console/cmd.h>
#include <doomsday/console/exec.h>
Expand Down Expand Up @@ -1033,7 +1033,7 @@ static void initialize()
// An implicit game session profile has been defined.
// Add all resources specified using -file options on the command line
// to the list for the session.
Session::Profile &prof = Session::profile();
AbstractSession::Profile &prof = AbstractSession::profile();

for (dint p = 0; p < CommandLine_Count(); ++p)
{
Expand Down
12 changes: 7 additions & 5 deletions doomsday/apps/client/src/ui/home/gamecolumnwidget.cpp
Expand Up @@ -89,15 +89,15 @@ DENG_GUI_PIMPL(GameColumnWidget)

LoopCallback mainCall;
String gameFamily;
SavedSessionListData const &savedItems;
SaveListData const &savedItems;
HomeMenuWidget *menu;
ButtonWidget *newProfileButton;
int restoredSelected = -1;
bool gotSubheading = false;

Impl(Public *i,
String const &gameFamily,
SavedSessionListData const &savedItems)
SaveListData const &savedItems)
: Base(i)
, gameFamily(gameFamily)
, savedItems(savedItems)
Expand Down Expand Up @@ -171,8 +171,10 @@ DENG_GUI_PIMPL(GameColumnWidget)
int userProfileCount() const
{
int count = 0;
menu->items().forAll([this, &count] (ui::Item const &item) {
if (!item.semantics().testFlag(ui::Item::Separator)) {
menu->items().forAll([this, &count] (ui::Item const &item)
{
if (!item.semantics().testFlag(ui::Item::Separator))
{
auto const *profile = item.as<ProfileItem>().profile;
if (profile && profile->isUserCreated()) ++count;
}
Expand Down Expand Up @@ -483,7 +485,7 @@ DENG_GUI_PIMPL(GameColumnWidget)
};

GameColumnWidget::GameColumnWidget(String const &gameFamily,
SavedSessionListData const &savedItems)
SaveListData const &savedItems)
: ColumnWidget(gameFamily.isEmpty()? "other-column"
: (gameFamily.toLower() + "-column"))
, d(new Impl(this, gameFamily.toLower(), savedItems))
Expand Down
10 changes: 5 additions & 5 deletions doomsday/apps/client/src/ui/home/gamepanelbuttonwidget.cpp
Expand Up @@ -19,7 +19,7 @@
#include "ui/home/gamepanelbuttonwidget.h"
#include "ui/widgets/homemenuwidget.h"
#include "ui/home/savelistwidget.h"
#include "ui/savedsessionlistdata.h"
#include "ui/savelistdata.h"
#include "ui/dialogs/packagesdialog.h"
#include "ui/widgets/packagesbuttonwidget.h"
#include "resource/idtech1image.h"
Expand All @@ -43,7 +43,7 @@ using namespace de;
DENG_GUI_PIMPL(GamePanelButtonWidget)
{
GameProfile &gameProfile;
ui::FilteredDataT<SavedSessionListData::SaveItem> savedItems;
ui::FilteredDataT<SaveListData::SaveItem> savedItems;
SaveListWidget *saves;
PackagesButtonWidget *packagesButton;
ButtonWidget *playButton;
Expand All @@ -52,7 +52,7 @@ DENG_GUI_PIMPL(GamePanelButtonWidget)
LabelWidget *packagesCounter;
res::LumpCatalog catalog;

Impl(Public *i, GameProfile &profile, SavedSessionListData const &allSavedItems)
Impl(Public *i, GameProfile &profile, SaveListData const &allSavedItems)
: Base(i)
, gameProfile(profile)
, savedItems(allSavedItems)
Expand All @@ -61,7 +61,7 @@ DENG_GUI_PIMPL(GamePanelButtonWidget)
savedItems.setFilter([this] (ui::Item const &it)
{
// Only saved sessions for this game are to be included.
auto const &item = it.as<SavedSessionListData::SaveItem>();
auto const &item = it.as<SaveListData::SaveItem>();
if (item.gameId() != gameProfile.game())
{
return false;
Expand Down Expand Up @@ -241,7 +241,7 @@ DENG_GUI_PIMPL(GamePanelButtonWidget)
}
};

GamePanelButtonWidget::GamePanelButtonWidget(GameProfile &game, SavedSessionListData const &savedItems)
GamePanelButtonWidget::GamePanelButtonWidget(GameProfile &game, SaveListData const &savedItems)
: d(new Impl(this, game, savedItems))
{
connect(d->saves, SIGNAL(selectionChanged(de::ui::DataPos)), this, SLOT(saveSelected(de::ui::DataPos)));
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/ui/home/homewidget.cpp
Expand Up @@ -23,7 +23,7 @@
#include "ui/home/multiplayercolumnwidget.h"
#include "ui/home/packagescolumnwidget.h"
#include "ui/widgets/busywidget.h"
#include "ui/savedsessionlistdata.h"
#include "ui/savelistdata.h"
#include "ui/clientwindow.h"
#include "ui/widgets/taskbarwidget.h"

Expand Down Expand Up @@ -62,7 +62,7 @@ DENG_GUI_PIMPL(HomeWidget)
};

LoopCallback mainCall;
SavedSessionListData savedItems; ///< All the available save games as items.
SaveListData savedItems; ///< All the available save games as items.

dsize visibleColumnCount = 2;
QList<Column> allColumns; // not owned
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/ui/home/savelistwidget.cpp
Expand Up @@ -18,7 +18,7 @@

#include "ui/home/savelistwidget.h"
#include "ui/home/gamepanelbuttonwidget.h"
#include "ui/savedsessionlistdata.h"
#include "ui/savelistdata.h"

#include <doomsday/game.h>

Expand Down Expand Up @@ -79,7 +79,7 @@ DENG_GUI_PIMPL(SaveListWidget)
});
button.addEventHandler(new DoubleClickHandler(this));

auto const &saveItem = item.as<SavedSessionListData::SaveItem>();
auto const &saveItem = item.as<SaveListData::SaveItem>();
button.setImage(style().images().image(Game::logoImageForId(saveItem.gameId())));
button.setOverrideImageSize(style().fonts().font("default").height().value() * 1.4f);
}
Expand Down
167 changes: 0 additions & 167 deletions doomsday/apps/client/src/ui/savedsessionlistdata.cpp

This file was deleted.

0 comments on commit 4fecd87

Please sign in to comment.