Skip to content

Commit

Permalink
Resources|UI: Custom data file only replaces “gamedata” packages
Browse files Browse the repository at this point in the history
The packages tagged “core” (such as doomsday.pk3) must still be loaded even though the normal “gamedata” package is replaced with a custom one.

IssueID #2271
  • Loading branch information
skyjake committed Nov 5, 2018
1 parent 6092019 commit 883009f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
8 changes: 4 additions & 4 deletions doomsday/apps/client/src/ui/dialogs/createprofiledialog.cpp
Expand Up @@ -205,9 +205,10 @@ CreateProfileDialog::CreateProfileDialog(String const &gameFamily)
form->add(d->gameChoice = new ChoiceWidget);
DoomsdayApp::games().forAll([this, &gameFamily] (Game &game)
{
if (game.isPlayable() && game.family() == gameFamily)
if (game.family() == gameFamily)
{
d->gameChoice->items() << new ChoiceItem(game.title(), game.id());
const char *labelColor = (!game.isPlayable() ? _E(F) : "");
d->gameChoice->items() << new ChoiceItem(labelColor + game.title(), game.id());
}
return LoopContinue;
});
Expand Down Expand Up @@ -348,7 +349,6 @@ void CreateProfileDialog::fetchFrom(GameProfile const &profile)
editor().setText(profile.name());
d->gameChoice->setSelected(d->gameChoice->items().findData(profile.gameId()));
d->tempProfile->setCustomDataFile(profile.customDataFile());
d->tempProfile->setUseGameRequirements(profile.customDataFile().isEmpty());
d->packages->setPackages(profile.packages());
d->updateDataFile();
d->autoStartMap->setSelected(d->autoStartMap->items().findData(profile.autoStartMap()));
Expand All @@ -363,7 +363,7 @@ void CreateProfileDialog::applyTo(GameProfile &profile) const
profile.setGame(d->gameChoice->selectedItem().data().toString());
}
profile.setCustomDataFile(d->tempProfile->customDataFile());
profile.setUseGameRequirements(d->tempProfile->customDataFile().isEmpty());
profile.setUseGameRequirements(true);
profile.setPackages(d->packages->packages());
profile.setAutoStartMap(d->autoStartMap->selectedItem().data().toString());
profile.setAutoStartSkill(d->autoStartSkill->selectedItem().data().toInt());
Expand Down
20 changes: 10 additions & 10 deletions doomsday/apps/client/src/ui/dialogs/packagesdialog.cpp
Expand Up @@ -307,15 +307,15 @@ DENG_GUI_PIMPL(PackagesDialog)
IdTech1Image::AlwaysTryLoad));
// List of the native required files.
StringList dataFiles;
if (gameProfile->customDataFile())
{
if (const auto *file = PackageLoader::get().select(gameProfile->customDataFile()))
{
dataFiles << file->source()->description(0);
}
}
else
{
// if (gameProfile->customDataFile())
// {
// if (const auto *file = PackageLoader::get().select(gameProfile->customDataFile()))
// {
// dataFiles << file->source()->description(0);
// }
// }
// else
// {
for (String packageId : gameProfile->allRequiredPackages())
{
if (const File *file = PackageLoader::get().select(packageId))
Expand All @@ -330,7 +330,7 @@ DENG_GUI_PIMPL(PackagesDialog)
}
}
}
}
// }
if (!dataFiles.isEmpty())
{
gameDataFiles->setText(_E(l) + String::format("Game data file%s: ", dataFiles.size() != 1? "s" : "") +
Expand Down
4 changes: 4 additions & 0 deletions doomsday/apps/libdoomsday/include/doomsday/gameprofiles.h
Expand Up @@ -35,6 +35,10 @@ class LIBDOOMSDAY_PUBLIC GameProfiles : public de::Profiles
/**
* Game profile. Identifies a specific Game and a set of packages to be loaded.
* Profiles are serialized as plain text in "/home/configs/game.dei".
*
* When a custom data file is set, any normally required packages with the "gamedata"
* tag are ignored. The assumption is that the custom data file provides everything
* that is provided by those default gamedata packages.
*/
class LIBDOOMSDAY_PUBLIC Profile : public AbstractProfile
{
Expand Down
23 changes: 19 additions & 4 deletions doomsday/apps/libdoomsday/src/gameprofiles.cpp
Expand Up @@ -385,14 +385,29 @@ Time GameProfiles::Profile::lastPlayedAt() const
StringList GameProfiles::Profile::allRequiredPackages() const
{
StringList list;
if (d->useGameRequirements)
{
list = DoomsdayApp::games()[d->gameId].requiredPackages();
}
if (d->customDataFile)
{
list += d->customDataFile;
}
if (d->useGameRequirements)
{
StringList reqs = DoomsdayApp::games()[d->gameId].requiredPackages();
if (d->customDataFile)
{
// Remove any normally required gamedata-tagged packages.
reqs = filter(reqs, [](const String &id) {
if (const auto *f = PackageLoader::get().select(id))
{
if (Package::matchTags(*f, QStringLiteral("\\bgamedata\\b")))
{
return false;
}
}
return true;
});
}
list += reqs;
}
return list + d->packages;
}

Expand Down

0 comments on commit 883009f

Please sign in to comment.