Skip to content

Commit

Permalink
UI|Client: Simpler Data Files settings
Browse files Browse the repository at this point in the history
There is only one list of directories in the Data Files settings.

The configuration still needs to be updated so the old iwadFolder is moved over to packageFolder.
  • Loading branch information
skyjake committed Oct 28, 2018
1 parent 6abf671 commit c768c70
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 29 deletions.
36 changes: 20 additions & 16 deletions doomsday/apps/client/src/ui/dialogs/datafilesettingsdialog.cpp
Expand Up @@ -28,19 +28,21 @@ using namespace de;

DENG2_PIMPL_NOREF(DataFileSettingsDialog)
{
Variable &iwadFolders = Config::get("resource.iwadFolder");
// Variable &iwadFolders = Config::get("resource.iwadFolder");
Variable &pkgFolders = Config::get("resource.packageFolder");
Id iwadGroup;
Id pkgGroup;
// Id iwadGroup;
Id searchGroup;
bool modified = false;
};

DataFileSettingsDialog::DataFileSettingsDialog(String const &name)
: DirectoryListDialog(name)
, d(new Impl)
{
buttons().clear()
<< new DialogButtonItem(Default | Accept, tr("Close"));
buttons().remove(1);
/*buttons()
<< new DialogButtonItem(Default | Accept, tr("Close"));*/
buttons().at(0).setLabel("Apply");

title().setFont("heading");
title().setText(tr("Data Files"));
Expand All @@ -55,15 +57,17 @@ DataFileSettingsDialog::DataFileSettingsDialog(String const &name)
//dlg->title().setText(QObject::tr("IWAD Folders"));
//dlg->message().setText(QObject::tr("The following folders are searched for game data files:"));

d->iwadGroup = addGroup(tr("IWAD Folders"),
tr("The following folders are searched for game IWAD files. "
"Only these folders are checked, not their subfolders."));
setValue(d->iwadGroup, d->iwadFolders.value());
d->searchGroup = addGroup(
tr("Search Folders"),
tr("The following folders are searched for game IWAD files and mods like PWADs, PK3s, and "
"Doomsday packages. Toggle the " _E(b) "Subdirs" _E(.)
" option to include all subfolders as well."));
//setValue(d->iwadGroup, d->iwadFolders.value());

d->pkgGroup = addGroup(tr("Mod / Add-on Folders"),
tr("The following folders and all their subfolders are searched "
"for mods, resource packs, and other add-ons."));
setValue(d->pkgGroup, d->pkgFolders.value());
// d->pkgGroup = addGroup(tr("Mod / Add-on Folders"),
// tr("The following folders and all their subfolders are searched "
// "for mods, resource packs, and other add-ons."));
setValue(d->searchGroup, d->pkgFolders.value());

connect(this, &DirectoryListDialog::arrayChanged, [this] ()
{
Expand All @@ -77,14 +81,14 @@ void DataFileSettingsDialog::finish(int result)

if (d->modified)
{
d->iwadFolders.set(value(d->iwadGroup));
d->pkgFolders .set(value(d->pkgGroup));
//d->iwadFolders.set(value(d->iwadGroup));
d->pkgFolders.set(value(d->searchGroup));

// Reload packages and recheck for game availability.
auto &win = ClientWindow::main();
win.console().closeLogAndUnfocusCommandLine();
win.root().find("home-packages")->as<PackagesWidget>().showProgressIndicator();
DoomsdayApp::app().initWadFolders();
// DoomsdayApp::app().initWadFolders();
DoomsdayApp::app().initPackageFolders();
}
}
56 changes: 43 additions & 13 deletions doomsday/apps/libdoomsday/src/doomsdayapp.cpp
Expand Up @@ -162,7 +162,7 @@ DENG2_PIMPL(DoomsdayApp)
filesys::RemoteFeedRelay::get().defineLink(IdgamesLink::construct);
}

~Impl()
~Impl() override
{
if (initialized)
{
Expand All @@ -173,13 +173,36 @@ DENG2_PIMPL(DoomsdayApp)
Garbage_Recycle();
}

void attachWadFeed(String const &description, NativePath const &path)
DirectoryFeed::Flags directoryPopulationMode(const NativePath &path) const
{
const TextValue dir{path.toString()};
if (Config::get().has("resource.recursedFolders"))
{
const auto &elems = Config::get().getdt("resource.recursedFolders").elements();
auto i = elems.find(&dir);
if (i != elems.end())
{
return i->second->isTrue() ? DirectoryFeed::PopulateNativeSubfolders
: DirectoryFeed::OnlyThisFolder;
}
}
return DirectoryFeed::PopulateNativeSubfolders;
}

void attachWadFeed(const String & description,
const NativePath & path,
DirectoryFeed::Flags populationMode = DirectoryFeed::OnlyThisFolder)
{
if (!path.isEmpty())
{
if (path.exists())
{
LOG_RES_NOTE("Using %s WAD folder: %s") << description << path.pretty();
LOG_RES_NOTE("Using %s WAD folder%s: %s")
<< description
<< (populationMode == DirectoryFeed::OnlyThisFolder ? ""
: " (including subfolders)")
<< path.pretty();

Path folderPathBase = PATH_LOCAL_WADS;
if (path.segmentCount() >= 2)
{
Expand All @@ -188,14 +211,14 @@ DENG2_PIMPL(DoomsdayApp)
// Choose a unique folder name.
Path folderPath = folderPathBase;
int counter = 0;
while (FS::get().tryLocate<Folder>(folderPath))
while (FS::tryLocate<Folder>(folderPath))
{
folderPath = Path(String("%1-%2")
.arg(folderPathBase.toString())
.arg(++counter, 3, 10, QChar('0')));
}
FS::get().makeFolder(folderPath)
.attach(new DirectoryFeed(path, DirectoryFeed::OnlyThisFolder));
.attach(new DirectoryFeed(path, populationMode));
}
else
{
Expand All @@ -205,15 +228,21 @@ DENG2_PIMPL(DoomsdayApp)
}
}

void attachPacksFeed(String const &description, NativePath const &path)
void attachPacksFeed(String const &description, NativePath const &path,
DirectoryFeed::Flags populationMode)
{
if (!path.isEmpty())
{
if (path.exists())
{
LOG_RES_NOTE("Using %s package folder (including subfolders): %s")
<< description << path.pretty();
App::rootFolder().locate<Folder>(PATH_LOCAL_PACKS).attach(new DirectoryFeed(path));
LOG_RES_NOTE("Using %s package folder%s: %s")
<< description
<< (populationMode == DirectoryFeed::OnlyThisFolder ? ""
: " (including subfolders)")
<< path.pretty();
App::rootFolder()
.locate<Folder>(PATH_LOCAL_PACKS)
.attach(new DirectoryFeed(path, populationMode));
}
else
{
Expand Down Expand Up @@ -350,7 +379,7 @@ DENG2_PIMPL(DoomsdayApp)
// Configured via GUI.
for (String path : App::config().getStringList("resource.iwadFolder"))
{
attachWadFeed("user-selected", path);
attachWadFeed("user-selected", path, directoryPopulationMode(path));
}

wads.populate(Folder::PopulateAsyncFullTree);
Expand All @@ -369,7 +398,8 @@ DENG2_PIMPL(DoomsdayApp)
if (char *fn = UnixInfo_GetConfigValue("paths", "packsdir"))
{
attachPacksFeed("UnixInfo " _E(i) "paths.packsdir" _E(.),
cmdLine.startupPath() / fn);
cmdLine.startupPath() / fn,
DirectoryFeed::DefaultFlags);
free(fn);
}
#endif
Expand All @@ -382,14 +412,14 @@ DENG2_PIMPL(DoomsdayApp)
if (cmdLine.isOption(p)) break;

cmdLine.makeAbsolutePath(p);
attachPacksFeed("command-line", cmdLine.at(p));
attachPacksFeed("command-line", cmdLine.at(p), DirectoryFeed::DefaultFlags);
}
}

// Configured via GUI.
for (String path : App::config().getStringList("resource.packageFolder"))
{
attachPacksFeed("user-selected", path);
attachPacksFeed("user-selected", path, directoryPopulationMode(path));
}

packs.populate(Folder::PopulateAsyncFullTree);
Expand Down

0 comments on commit c768c70

Please sign in to comment.