Skip to content

Commit

Permalink
Refactor|libdeng2: Moved "saved session" components into the game nam…
Browse files Browse the repository at this point in the history
…espace

These are hardly 'core' components.
  • Loading branch information
danij-deng committed Mar 5, 2014
1 parent 46ea34b commit 87f0099
Show file tree
Hide file tree
Showing 30 changed files with 100 additions and 86 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/include/resource/resourcesystem.h
Expand Up @@ -42,7 +42,7 @@
#include "resource/zip.h"
#include "uri.hh"
#include <de/Error>
#include <de/SavedSessionRepository>
#include <de/game/SavedSessionRepository>
#include <de/String>
#include <de/System>
#include <QList>
Expand Down Expand Up @@ -868,7 +868,7 @@ class ResourceSystem : public de::System
/**
* Returns the SavedSessionRepository.
*/
de::SavedSessionRepository &savedSessionRepository() const;
de::game::SavedSessionRepository &savedSessionRepository() const;

public: /// @todo Should be private:
void initCompositeTextures();
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -318,7 +318,7 @@ DENG2_PIMPL(ResourceSystem)
typedef QMap<spritenum_t, SpriteGroup> SpriteGroups;
SpriteGroups spriteGroups;

SavedSessionRepository saveRepo;
game::SavedSessionRepository saveRepo;

Instance(Public *i)
: Base(i)
Expand Down Expand Up @@ -3810,7 +3810,7 @@ void ResourceSystem::cacheForCurrentMap()

#endif // __CLIENT__

SavedSessionRepository &ResourceSystem::savedSessionRepository() const
game::SavedSessionRepository &ResourceSystem::savedSessionRepository() const
{
return d->saveRepo;
}
Expand Down
12 changes: 9 additions & 3 deletions doomsday/libdeng2/game.pri
@@ -1,10 +1,16 @@
HEADERS += \
include/de/game/Game \
include/de/game/IGameStateReader
include/de/game/IGameStateReader \
include/de/game/SavedSession \
include/de/game/SavedSessionRepository

HEADERS += \
include/de/game/game.h \
include/de/game/igamestatereader.h
include/de/game/igamestatereader.h \
include/de/game/savedsession.h \
include/de/game/savedsessionrepository.h

SOURCES += \
src/game/game.cpp
src/game/game.cpp \
src/game/savedsession.cpp \
src/game/savedsessionrepository.cpp
1 change: 0 additions & 1 deletion doomsday/libdeng2/include/de/SavedSession

This file was deleted.

1 change: 0 additions & 1 deletion doomsday/libdeng2/include/de/SavedSessionRepository

This file was deleted.

1 change: 1 addition & 0 deletions doomsday/libdeng2/include/de/game/SavedSession
@@ -0,0 +1 @@
#include "savedsession.h"
1 change: 1 addition & 0 deletions doomsday/libdeng2/include/de/game/SavedSessionRepository
@@ -0,0 +1 @@
#include "savedsessionrepository.h"
6 changes: 5 additions & 1 deletion doomsday/libdeng2/include/de/game/igamestatereader.h
Expand Up @@ -23,12 +23,15 @@
#include <de/Error>
#include <de/Path>
#include <de/Record>
#include <de/SavedSession>
#include <de/game/SavedSession>

namespace de {
namespace game {

/**
* Interface for serialized game state (savegame) readers.
*
* @ingroup game
*/
class DENG2_PUBLIC IGameStateReader
{
Expand All @@ -55,6 +58,7 @@ class DENG2_PUBLIC IGameStateReader
SavedSession::Metadata const &metadata) = 0;
};

} // namespace game
} // namespace de

#endif // LIBDENG2_IGAMESTATEREADER_H
Expand Up @@ -26,14 +26,15 @@
#include "../String"

namespace de {
namespace game {

class IGameStateReader;
class SavedSessionRepository;

/**
* Logical component representing a serialized game state on disk.
*
* @ingroup core
* @ingroup game
*/
class DENG2_PUBLIC SavedSession
{
Expand Down Expand Up @@ -150,6 +151,7 @@ class DENG2_PUBLIC SavedSession

typedef SavedSession::Metadata SessionMetadata;

} // namespace game
} // namespace de

#endif // LIBDENG2_SAVEDSESSION_H
Expand Up @@ -23,8 +23,8 @@
#include "../Error"
#include "../Folder"
#include "../game/IGameStateReader"
#include "../game/SavedSession"
#include "../Path"
#include "../SavedSession"
#include "../String"

/**
Expand All @@ -35,18 +35,19 @@
*
* @param metadata The read metadata is written here.
*/
typedef bool (*GameStateRecognizeFunc)(de::Path const &stateFilePath, de::SessionMetadata &metadata);
typedef bool (*GameStateRecognizeFunc)(de::Path const &stateFilePath, de::game::SessionMetadata &metadata);

/// Game state reader instantiator function ptr.
typedef de::IGameStateReader *(*GameStateReaderMakeFunc)();
typedef de::game::IGameStateReader *(*GameStateReaderMakeFunc)();

namespace de {
namespace game {

/**
* Centralized saved session repository. The saved game state file structure is automatically
* initialized when the current game changes.
*
* @ingroup core
* @ingroup game
*/
class DENG2_PUBLIC SavedSessionRepository
{
Expand Down Expand Up @@ -130,6 +131,7 @@ class DENG2_PUBLIC SavedSessionRepository
DENG2_PRIVATE(d)
};

} // namespace game
} // namespace de

#endif // LIBDENG2_SAVEDSESSIONREPOSITORY_H
6 changes: 0 additions & 6 deletions doomsday/libdeng2/libdeng2.pro
Expand Up @@ -93,8 +93,6 @@ HEADERS += \
include/de/MonospaceLogSinkFormatter \
include/de/Range \
include/de/Rectangle \
include/de/SavedSession \
include/de/SavedSessionRepository \
include/de/System \
include/de/TextApp \
include/de/TextStreamLogSink \
Expand Down Expand Up @@ -130,8 +128,6 @@ HEADERS += \
include/de/core/monospacelogsinkformatter.h \
include/de/core/range.h \
include/de/core/rectangle.h \
include/de/core/savedsession.h \
include/de/core/savedsessionrepository.h \
include/de/core/system.h \
include/de/core/textapp.h \
include/de/core/textstreamlogsink.h \
Expand Down Expand Up @@ -168,8 +164,6 @@ SOURCES += \
src/core/loop.cpp \
src/core/memorylogsink.cpp \
src/core/monospacelogsinkformatter.cpp \
src/core/savedsession.cpp \
src/core/savedsessionrepository.cpp \
src/core/system.cpp \
src/core/textapp.cpp \
src/core/textstreamlogsink.cpp \
Expand Down
Expand Up @@ -17,19 +17,18 @@
* 02110-1301 USA</small>
*/

#include "de/Savedsession"
#include "de/game/Savedsession"

#include "de/App"
#include "de/game/Game"
#include "de/game/SavedSessionRepository"
#include "de/ArrayValue"
#include "de/Log"
#include "de/NumberValue"
#include "de/NativePath"
#include "de/SavedSessionRepository"

namespace de {

using namespace internal;
namespace game {

DENG2_PIMPL(SavedSession)
{
Expand Down Expand Up @@ -270,4 +269,5 @@ std::auto_ptr<IGameStateReader> SavedSession::gameStateReader()
return p;
}

} // namespace game
} // namespace de
Expand Up @@ -17,7 +17,7 @@
* 02110-1301 USA</small>
*/

#include "de/SavedSessionRepository"
#include "de/game/SavedSessionRepository"

#include "de/App"
#include "de/game/Game"
Expand All @@ -29,6 +29,7 @@
#include <map>

namespace de {
namespace game {

DENG2_PIMPL(SavedSessionRepository)
, DENG2_OBSERVES(App, GameUnload)
Expand Down Expand Up @@ -198,4 +199,5 @@ IGameStateReader *SavedSessionRepository::recognizeAndMakeReader(SavedSession &s
return 0; // Unrecognized
}

} // namespace game
} // namespace de
4 changes: 2 additions & 2 deletions doomsday/plugins/common/include/g_common.h
Expand Up @@ -239,7 +239,7 @@ bool G_LoadSession(de::String slotId);
/**
* @return New SessionMetadata (record). Ownership is given to the caller.
*/
de::SessionMetadata *G_CurrentSessionMetadata();
de::game::SessionMetadata *G_CurrentSessionMetadata();

/**
* Returns the game's SaveSlots.
Expand All @@ -249,7 +249,7 @@ SaveSlots &G_SaveSlots();
/**
* Returns the game's (i.e., the app's) SavedSessionRepository.
*/
de::SavedSessionRepository &G_SavedSessionRepository();
de::game::SavedSessionRepository &G_SavedSessionRepository();

/**
* Parse @a str and determine whether it references a logical game-save slot.
Expand Down
8 changes: 4 additions & 4 deletions doomsday/plugins/common/include/gamestatereader.h
Expand Up @@ -28,17 +28,17 @@
* @ingroup libcommon
* @see GameStateWriter
*/
class GameStateReader : public de::IGameStateReader
class GameStateReader : public de::game::IGameStateReader
{
public:
GameStateReader();
~GameStateReader();

static de::IGameStateReader *make();
static bool recognize(de::Path const &stateFilePath, de::SessionMetadata &metadata);
static de::game::IGameStateReader *make();
static bool recognize(de::Path const &stateFilePath, de::game::SessionMetadata &metadata);

void read(de::Path const &stateFilePath, de::Path const &mapStateFilePath,
de::SessionMetadata const &metadata);
de::game::SessionMetadata const &metadata);

private:
DENG2_PRIVATE(d)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/gamestatewriter.h
Expand Up @@ -41,7 +41,7 @@ class GameStateWriter
GameStateWriter();

void write(de::Path const &stateFilePath, de::Path const &mapStateFilePath,
de::SessionMetadata const &metadata);
de::game::SessionMetadata const &metadata);

private:
DENG2_PRIVATE(d)
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/common/include/p_saveio.h
Expand Up @@ -21,8 +21,8 @@
#ifndef LIBCOMMON_SAVESTATE_INPUT_OUTPUT_H
#define LIBCOMMON_SAVESTATE_INPUT_OUTPUT_H

#include <de/game/SavedSession>
#include <de/Path>
#include <de/SavedSession>
#include <de/reader.h>
#include <de/writer.h>
#include "lzss.h"
Expand Down Expand Up @@ -89,8 +89,8 @@ void SV_BeginSegment(int segmentId);

void SV_EndSegment();

void SV_WriteSessionMetadata(de::SessionMetadata const &metadata, Writer *writer);
void SV_ReadSessionMetadata(de::SessionMetadata &metadata, Reader *reader);
void SV_WriteSessionMetadata(de::game::SessionMetadata const &metadata, Writer *writer);
void SV_ReadSessionMetadata(de::game::SessionMetadata &metadata, Reader *reader);

void SV_WriteConsistencyBytes();

Expand Down
8 changes: 4 additions & 4 deletions doomsday/plugins/common/include/saveslots.h
Expand Up @@ -23,8 +23,8 @@

#include "common.h"
#include <de/Error>
#include <de/game/SavedSession>
#include <de/Path>
#include <de/SavedSession>
#include <de/String>

/**
Expand Down Expand Up @@ -77,7 +77,7 @@ class SaveSlots
/**
* Convenient method of looking up the deserialized session metadata for the logical save slot.
*/
de::SessionMetadata const &saveMetadata() const;
de::game::SessionMetadata const &saveMetadata() const;

/**
* Returns the saved session game state file path (in the repository).
Expand All @@ -98,7 +98,7 @@ class SaveSlots
/**
* Returns the saved session for the logical save slot.
*/
de::SavedSession &savedSession() const;
de::game::SavedSession &savedSession() const;

/**
* Deletes all saved session state files associated for the logical save slot.
Expand All @@ -110,7 +110,7 @@ class SaveSlots
*
* @param newSession New SavedSession to replace with. Ownership is given.
*/
void replaceSavedSession(de::SavedSession *newSession);
void replaceSavedSession(de::game::SavedSession *newSession);

private:
DENG2_PRIVATE(d)
Expand Down

0 comments on commit 87f0099

Please sign in to comment.