diff --git a/doomsday/apps/libdoomsday/include/doomsday/gameprofiles.h b/doomsday/apps/libdoomsday/include/doomsday/gameprofiles.h index dc989a5010..a487c47086 100644 --- a/doomsday/apps/libdoomsday/include/doomsday/gameprofiles.h +++ b/doomsday/apps/libdoomsday/include/doomsday/gameprofiles.h @@ -44,10 +44,12 @@ class LIBDOOMSDAY_PUBLIC GameProfiles : public de::Profiles void setGame(de::String const &id); void setPackages(de::StringList const &packagesInOrder); void setUserCreated(bool userCreated); + void setUseGameRequirements(bool useGameRequirements); de::String game() const; de::StringList packages() const; bool isUserCreated() const; + bool isUsingGameRequirements() const; /** * Returns a list of the game's packages in addition to the profile's @@ -57,6 +59,8 @@ class LIBDOOMSDAY_PUBLIC GameProfiles : public de::Profiles de::StringList packagesAffectingGameplay() const; + de::StringList unavailablePackages() const; + bool isCompatibleWithPackages(de::StringList const &ids) const; bool isPlayable() const; diff --git a/doomsday/apps/libdoomsday/src/gameprofiles.cpp b/doomsday/apps/libdoomsday/src/gameprofiles.cpp index 8b57e708d1..1202e0914f 100644 --- a/doomsday/apps/libdoomsday/src/gameprofiles.cpp +++ b/doomsday/apps/libdoomsday/src/gameprofiles.cpp @@ -32,6 +32,7 @@ using namespace de; static String const VAR_GAME ("game"); static String const VAR_PACKAGES ("packages"); static String const VAR_USER_CREATED("userCreated"); +static String const VAR_USE_GAME_REQUIREMENTS("useGameRequirements"); static GameProfile nullGameProfile; @@ -126,6 +127,11 @@ Profiles::AbstractProfile *GameProfiles::profileFromInfoBlock(Info::BlockElement } prof->setUserCreated(!block.keyValue(VAR_USER_CREATED).text.compareWithoutCase("True")); + if (block.contains(VAR_USE_GAME_REQUIREMENTS)) + { + prof->setUseGameRequirements(!block.keyValue(VAR_USE_GAME_REQUIREMENTS) + .text.compareWithoutCase("True")); + } return prof.release(); } @@ -137,13 +143,15 @@ DENG2_PIMPL_NOREF(GameProfiles::Profile) String gameId; StringList packages; bool userCreated = false; + bool useGameRequirements = true; Impl() {} Impl(Impl const &other) - : gameId (other.gameId) - , packages (other.packages) - , userCreated(other.userCreated) + : gameId (other.gameId) + , packages (other.packages) + , userCreated (other.userCreated) + , useGameRequirements(other.useGameRequirements) {} }; @@ -173,6 +181,11 @@ void GameProfiles::Profile::setUserCreated(bool userCreated) d->userCreated = userCreated; } +void GameProfiles::Profile::setUseGameRequirements(bool useGameRequirements) +{ + d->useGameRequirements = useGameRequirements; +} + String GameProfiles::Profile::game() const { return d->gameId; @@ -188,9 +201,19 @@ bool GameProfiles::Profile::isUserCreated() const return d->userCreated; } +bool GameProfiles::Profile::isUsingGameRequirements() const +{ + return d->useGameRequirements; +} + StringList GameProfiles::Profile::allRequiredPackages() const { - return DoomsdayApp::games()[d->gameId].requiredPackages() + d->packages; + StringList list; + if (d->useGameRequirements) + { + list = DoomsdayApp::games()[d->gameId].requiredPackages(); + } + return list + d->packages; } StringList GameProfiles::Profile::packagesAffectingGameplay() const @@ -207,6 +230,19 @@ StringList GameProfiles::Profile::packagesAffectingGameplay() const return ids; } +StringList GameProfiles::Profile::unavailablePackages() const +{ + StringList ids; + for (String const &pkg : allRequiredPackages()) + { + if (!App::packageLoader().isAvailable(pkg)) + { + ids << pkg; + } + } + return ids; +} + bool GameProfiles::Profile::isCompatibleWithPackages(StringList const &ids) const { return GameProfiles::arePackageListsCompatible(packagesAffectingGameplay(), ids); @@ -255,7 +291,8 @@ String GameProfiles::Profile::toInfoSource() const os << VAR_GAME << ": " << d->gameId << "\n" << VAR_PACKAGES << " <" << String::join(d->packages, ", ") << ">\n" - << VAR_USER_CREATED << ": " << (d->userCreated? "True" : "False"); + << VAR_USER_CREATED << ": " << (d->userCreated? "True" : "False") + << VAR_USE_GAME_REQUIREMENTS << ": " << (d->useGameRequirements? "True" : "False"); return info; }