Skip to content

Commit

Permalink
Refactor|libdeng2|SavedSession: Use pimpl-friendly audiences for game…
Browse files Browse the repository at this point in the history
…::SavedSession
  • Loading branch information
danij-deng committed Mar 5, 2014
1 parent d3951b1 commit aab5318
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions doomsday/libdeng2/include/de/game/savedsession.h
Expand Up @@ -39,10 +39,10 @@ class DENG2_PUBLIC SavedSession
{
public:
/// Notified whenever the status of the saved game session changes.
DENG2_DEFINE_AUDIENCE(StatusChange, void savedSessionStatusChanged(SavedSession &session))
DENG2_DEFINE_AUDIENCE2(StatusChange, void savedSessionStatusChanged(SavedSession &session))

/// Notified whenever the metadata of the saved game session changes.
DENG2_DEFINE_AUDIENCE(MetadataChange, void savedSessionMetadataChanged(SavedSession &session))
DENG2_DEFINE_AUDIENCE2(MetadataChange, void savedSessionMetadataChanged(SavedSession &session))

/// Required/referenced repository is missing. @ingroup errors
DENG2_ERROR(MissingRepositoryError);
Expand Down
13 changes: 10 additions & 3 deletions doomsday/libdeng2/src/game/savedsession.cpp
Expand Up @@ -62,7 +62,7 @@ DENG2_PIMPL(SavedSession)

void notifyMetadataChanged()
{
DENG2_FOR_PUBLIC_AUDIENCE(MetadataChange, i)
DENG2_FOR_PUBLIC_AUDIENCE2(MetadataChange, i)
{
i->savedSessionMetadataChanged(self);
}
Expand Down Expand Up @@ -90,14 +90,20 @@ DENG2_PIMPL(SavedSession)

if(status != oldStatus)
{
DENG2_FOR_PUBLIC_AUDIENCE(StatusChange, i)
DENG2_FOR_PUBLIC_AUDIENCE2(StatusChange, i)
{
i->savedSessionStatusChanged(self);
}
}
}

DENG2_PIMPL_AUDIENCE(StatusChange)
DENG2_PIMPL_AUDIENCE(MetadataChange)
};

DENG2_AUDIENCE_METHOD(SavedSession, StatusChange)
DENG2_AUDIENCE_METHOD(SavedSession, MetadataChange)

SavedSession::SavedSession(String const &fileName) : d(new Instance(this))
{
d->fileName = fileName;
Expand Down Expand Up @@ -236,11 +242,12 @@ void SavedSession::deleteFilesInRepository()
{
// Remove this file.
delete file;
d->needUpdateStatus = true;
}
}
}

// Force a status update.
/// Force a status update. @todo necessary?
updateFromRepository();
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/saveslots.cpp
Expand Up @@ -181,8 +181,8 @@ void SaveSlots::Slot::replaceSavedSession(SavedSession *newSession)
if(d->gameMenuWidgetId)
{
// We want notification of subsequent changes so that we can update the menu widget.
session.audienceForStatusChange += d;
session.audienceForMetadataChange += d;
session.audienceForStatusChange() += d;
session.audienceForMetadataChange() += d;
}
}

Expand Down

0 comments on commit aab5318

Please sign in to comment.