Skip to content

Commit

Permalink
Resources|Client|libdoomsday: Clearing the metadata cache
Browse files Browse the repository at this point in the history
One can now clear the cached data via the DE menu.
  • Loading branch information
skyjake committed Feb 15, 2017
1 parent 5df522d commit 4255a6e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -1382,7 +1382,7 @@ static dint DD_StartupWorker(void * /*context*/)

// Release all cached uncompressed entries. If the contents of the compressed
// files are needed, they will be decompressed and cached again.
DoomsdayApp::app().uncacheFiles();
DoomsdayApp::app().uncacheFilesFromMemory();

#ifdef WIN32
// This thread has finished using COM.
Expand Down
15 changes: 8 additions & 7 deletions doomsday/apps/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -71,8 +71,7 @@ static TimeDelta OPEN_CLOSE_SPAN = 0.2;
enum MenuItemPositions
{
// DE menu:
//POS_GAMES = 1,
POS_MULTIPLAYER = 1,
POS_HOME = 1,
POS_UNLOAD = 2,
POS_GAMES_SEPARATOR = 3,
POS_CONNECT = 4,
Expand Down Expand Up @@ -278,7 +277,7 @@ DENG_GUI_PIMPL(TaskBarWidget)
itemWidget(mainMenu, POS_GAMES_SEPARATOR) .show(!game.isNull());
itemWidget(mainMenu, POS_PACKAGES) .show(!game.isNull());
//itemWidget(mainMenu, POS_IWAD_FOLDER) .show(game.isNull());
itemWidget(mainMenu, POS_MULTIPLAYER) .show(!game.isNull());
itemWidget(mainMenu, POS_HOME) .show(!game.isNull());
//itemWidget(mainMenu, POS_CONNECT) .show(game.isNull());

itemWidget(configMenu, POS_RENDERER_SETTINGS).show(!game.isNull());
Expand Down Expand Up @@ -334,11 +333,11 @@ DENG_GUI_PIMPL(TaskBarWidget)
{
if (self().root().window().as<ClientWindow>().isGameMinimized())
{
mainMenu->items().at(POS_MULTIPLAYER).setLabel(tr("Hide Home"));
mainMenu->items().at(POS_HOME).setLabel(tr("Hide Home"));
}
else
{
mainMenu->items().at(POS_MULTIPLAYER).setLabel(tr("Show Home"));
mainMenu->items().at(POS_HOME).setLabel(tr("Show Home"));
}
}
};
Expand Down Expand Up @@ -501,9 +500,11 @@ TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Impl(this))
<< new ui::Item(ui::Item::Separator)
<< new ui::ActionItem(tr("Connect to Server..."), new SignalAction(this, SLOT(connectToServerManually())))
<< new ui::Item(ui::Item::Separator)
<< new ui::Item(ui::Item::Separator, tr("Resources"))
<< new ui::ActionItem(tr("Browse Packages..."), new SignalAction(this, SLOT(openPackagesSidebar())))
<< new ui::ActionItem(tr("Clear Cache"), new CallbackAction([] () { DoomsdayApp::app().clearCache(); }))
<< new ui::Item(ui::Item::Separator)
<< new ui::Item(ui::Item::Separator, tr("Doomsday"))
<< new ui::ActionItem(tr("Packages..."), new SignalAction(this, SLOT(openPackagesSidebar())))
//<< new ui::ActionItem(tr("IWAD Folder..."), new SignalAction(this, SLOT(chooseIWADFolder())))
<< new ui::ActionItem(tr("Check for Updates"), new CommandAction("updateandnotify"))
<< new ui::ActionItem(tr("About Doomsday"), new SignalAction(this, SLOT(showAbout())))
<< helpMenu
Expand Down
7 changes: 6 additions & 1 deletion doomsday/apps/libdoomsday/include/doomsday/doomsdayapp.h
Expand Up @@ -102,7 +102,12 @@ class LIBDOOMSDAY_PUBLIC DoomsdayApp
* Release all cached uncompressed entries. If the contents of the compressed
* files are needed, they will be decompressed and cached again.
*/
void uncacheFiles();
void uncacheFilesFromMemory();

/**
* Deletes the contents of the /home/cache folder.
*/
void clearCache();

enum Behavior
{
Expand Down
11 changes: 9 additions & 2 deletions doomsday/apps/libdoomsday/src/doomsdayapp.cpp
Expand Up @@ -45,6 +45,7 @@
#include <de/Folder>
#include <de/Garbage>
#include <de/Loop>
#include <de/MetadataBank>
#include <de/NativeFile>
#include <de/PackageLoader>
#include <de/ScriptSystem>
Expand Down Expand Up @@ -734,19 +735,25 @@ void DoomsdayApp::unloadGame(GameProfile const &/*upcomingGame*/)
world::Materials::get().clearAllMaterialSchemes();
}

void DoomsdayApp::uncacheFiles()
void DoomsdayApp::uncacheFilesFromMemory()
{
ArchiveFeed::uncacheAllEntries(StringList({ DENG2_TYPE_NAME(Folder),
DENG2_TYPE_NAME(ArchiveFolder),
DENG2_TYPE_NAME(DataFolder),
DENG2_TYPE_NAME(GameStateFolder) }));
}

void DoomsdayApp::clearCache()
{
LOG_RES_NOTE("Clearing metadata cache contents");
MetadataBank::get().clear();
}

void DoomsdayApp::reset()
{
// Reset the world back to it's initial state (unload the map, reset players, etc...).
World::get().reset();
uncacheFiles();
uncacheFilesFromMemory();

Z_FreeTags(PU_GAMESTATIC, PU_PURGELEVEL - 1);

Expand Down

0 comments on commit 4255a6e

Please sign in to comment.