Skip to content

Commit

Permalink
Game|Resources: Added method of querying the logical status of a Game
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 4, 2014
1 parent 3b8e0b5 commit 82e3689
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 17 deletions.
37 changes: 30 additions & 7 deletions doomsday/client/include/game.h
Expand Up @@ -44,6 +44,13 @@ class ResourceManifest;
class Game : public de::game::Game
{
public:
/// Logical game status:
enum Status {
Loaded,
Complete,
Incomplete
};

typedef QMultiMap<resourceclassid_t, ResourceManifest *> Manifests;

public:
Expand All @@ -56,9 +63,31 @@ class Game : public de::game::Game

virtual ~Game();

/// @return Unique plugin identifier attributed to that which registered this.
/**
* Determines the status of the game.
*
* @see statusAsText()
*/
Status status() const;

/**
* Returns a textual representation of the current game status.
*
* @see status()
*/
String const &statusAsText() const;

/**
* Returns the unique identifier of the plugin which registered the game.
*/
pluginid_t pluginId() const;

/**
* Change the identfier of the plugin associated with this.
* @param newId New identifier.
*/
void setPluginId(pluginid_t newId);

/**
* Returns the unique identity key of the game.
*/
Expand All @@ -84,12 +113,6 @@ class Game : public de::game::Game
*/
de::Path const &bindingConfig() const;

/**
* Change the identfier of the plugin associated with this.
* @param newId New identifier.
*/
void setPluginId(pluginid_t newId);

/**
* Add a new manifest to the list of manifests.
*
Expand Down
32 changes: 26 additions & 6 deletions doomsday/client/src/game.cpp
Expand Up @@ -90,16 +90,39 @@ bool Game::allStartupFilesFound() const
return true;
}

void Game::setPluginId(pluginid_t newId)
Game::Status Game::status() const
{
d->pluginId = newId;
if(App_GameLoaded() && &App_CurrentGame() == this)
{
return Loaded;
}
if(allStartupFilesFound())
{
return Complete;
}
return Incomplete;
}

String const &Game::statusAsText() const
{
static String const statusTexts[] = {
"Loaded",
"Complete/Playable",
"Incomplete/Not playable",
};
return statusTexts[int(status())];
}

pluginid_t Game::pluginId() const
{
return d->pluginId;
}

void Game::setPluginId(pluginid_t newId)
{
d->pluginId = newId;
}

String const &Game::identityKey() const
{
return d->identityKey;
Expand Down Expand Up @@ -260,10 +283,7 @@ D_CMD(InspectGame)
LOG_MSG("Other resources:");
Game::printFiles(*game, 0, false);

LOG_MSG("Status: ")
<< ( &App_CurrentGame() == game? "Loaded" :
game->allStartupFilesFound()? "Complete/Playable" :
"Incomplete/Not playable");
LOG_MSG("Status: ") << game->statusAsText();

return true;
}
Expand Down
5 changes: 1 addition & 4 deletions doomsday/client/src/games.cpp
Expand Up @@ -227,10 +227,7 @@ static int locateAllResourcesWorker(void *context)
LOG_MSG("Startup resources:");
Game::printFiles(*game, FF_STARTUP);

LOG_MSG("Status: ")
<< (&App_CurrentGame() == game? "Loaded" :
game->allStartupFilesFound()? "Complete/Playable" :
"Incomplete/Not playable");
LOG_MSG("Status: ") << game->statusAsText();
)
++n;
}
Expand Down

0 comments on commit 82e3689

Please sign in to comment.