DemoStore Class Reference

#include <gamedemo.h>

Public Member Functions

 DemoStore ()
 
 DemoStore (QDir root)
 
bool ensureStorageExists (QWidget *parent)
 
bool importDemo (const GameDemo &demo)
 
QStringList listManagedDemos ()
 
GameDemo loadManagedGameDemo (const QString &name)
 
QString mkDemoFullPath (DemoRecord::Control control, const EnginePlugin &plugin, const bool isMultiplayer)
 
bool removeManagedDemo (const QString &name)
 
const QDir & root () const
 
void saveDemoMetaData (const QString &demoName, const EnginePlugin &plugin, const QString &iwad, const QList< PWad > &pwads, const bool isMultiplayer, const QString &gameVersion=QString())
 

Static Public Member Functions

static QStringList demoFileFilters ()
 
static GameDemo loadGameDemo (const QString &path)
 
static QString metafile (const QString &path)
 

Detailed Description

Managed demo storage, organizes the demos and decorates them with metadata.

Definition at line 154 of file gamedemo.h.

Constructor & Destructor Documentation

DemoStore::DemoStore ( )

Create a DemoStore pointing to the program's default managed demo storage.

Definition at line 289 of file gamedemo.cpp.

DemoStore::DemoStore ( QDir  root)

Create a DemoStore where demos are stored in the passed-in directory.

Definition at line 294 of file gamedemo.cpp.

Member Function Documentation

QStringList DemoStore::demoFileFilters ( )
static

Demo filename filters in format applicable for QFileDialog.

Definition at line 299 of file gamedemo.cpp.

bool DemoStore::ensureStorageExists ( QWidget *  parent)

Create the managed store for the DemoStore.

This method shows UI error pop-ups if something fails that informs the user about what was the cause of the failure. That's why it accepts a QWidget to use as a parent for the QMessageBox.

Returns
true if it was created, false if creation failed.

Definition at line 307 of file gamedemo.cpp.

bool DemoStore::importDemo ( const GameDemo demo)

Import demo described by GameDemo to the managed demos store.

GameDemo::filepath must point to a valid demo file and it's also expected that the other attributes of GameDemo will be filled with proper info about the demo.

The demo file is copied to Doomseeker's store and the metadata is saved next to it. Such imported demo then becomes indistinguishable from a normally recorded demo.

If it happens that a demo with the exactly same filename already exists in the store, then the existing demo is REMOVED.

Definition at line 369 of file gamedemo.cpp.

QStringList DemoStore::listManagedDemos ( )

List all the demo files managed by Doomseeker.

The returned elements should be treated as names that exist and are unique within the DemoStore. If the managed demos need to be removed or otherwise manipulated, they should be referred to by the names returned here.

Returns
All names/paths to the demos within the DemoStore.

Definition at line 355 of file gamedemo.cpp.

GameDemo DemoStore::loadGameDemo ( const QString &  path)
static

Populate GameDemo struct with the demo metadata at path.

Try to parse some of the metadata from the filename first. Then, look for the .ini file with the same name and try to read more metadata from that. If these fail, the returned GameDemo may be partially populated only.

If GameDemo::port in the returned struct is empty, the path may not be pointing to a demo file at all, or it's a demo but lacks the Doomseeker metadata. The GameDemo::filepath is guaranteed to be populated at least (it's set to the path param).

The demo doesn't need to be in the managed demo storage (hence the method is static).

Parameters
pathDirect path to either the demo file or its metadata file.
Returns
GameDemo struct populated with info about the demo at path.

Definition at line 587 of file gamedemo.cpp.

GameDemo DemoStore::loadManagedGameDemo ( const QString &  name)

Load the GameDemo metadata for a managed demo by its name.

Managed demos can be listed with listManagedDemos(). If demo is not found, an empty GameDemo struct is returned – the GameDemo::filepath attribute will also be empty.

Parameters
nameName of the demo as returned by listManagedDemos().
Returns
GameDemo struct populated with info about the demo.

Definition at line 598 of file gamedemo.cpp.

QString DemoStore::metafile ( const QString &  path)
static

Given the path to a demo, return the path to the metadata file.

Either path may not exist.

Definition at line 393 of file gamedemo.cpp.

QString DemoStore::mkDemoFullPath ( DemoRecord::Control  control,
const EnginePlugin plugin,
const bool  isMultiplayer 
)

Create a demo name, with optional full path, basing on the passed-in parameters.

Parameters
controlDecides if the demo is to be stored in DemoStore and affects if DemoStore's root path is prepended to the returned filename. This happens when control is DemoRecord::Control::Managed.
pluginThe game with which this demo is recorded.
isMultiplayerIs the game running in the multiplayer mode (true), or singleplayer (false).
Returns
The path (or just the filename) to where the recorded demo should be saved.
See Also
saveDemoMetaData()

Definition at line 398 of file gamedemo.cpp.

bool DemoStore::removeManagedDemo ( const QString &  name)

Remove the managed demo by its name.

It also removes the metadata file if it exists.

Parameters
nameName of the demo as returned by listManagedDemos().
Returns
true if the demo was removed successfully (or if it didn't exist in the first place). false if removal failed.

Definition at line 435 of file gamedemo.cpp.

const QDir & DemoStore::root ( ) const

The dir where demos are saved.

Definition at line 451 of file gamedemo.cpp.

void DemoStore::saveDemoMetaData ( const QString &  demoName,
const EnginePlugin plugin,
const QString &  iwad,
const QList< PWad > &  pwads,
const bool  isMultiplayer,
const QString &  gameVersion = QString() 
)

Save the demo's metadata in the store basing on the passed-in parameters.

Parameters
demoNameName of the demo, previously generated with mkDemoFullPath().
pluginThe game with which this demo is recorded.
iwadThe IWAD used in the demo recording.
pwadsList of PWADs and other mod files used in the demo recording, provided in the game-load order.
isMultiplayerIs the game running in the multiplayer mode (true), or singleplayer (false).
gameVersionThe version of the game that was used to record the demo.

Definition at line 456 of file gamedemo.cpp.


The documentation for this class was generated from the following files: