Skip to content

Commit

Permalink
Scripting|FS: Added a file system binding
Browse files Browse the repository at this point in the history
`FS.refreshPackageFolders()` re-initializes the /local/wads and /local/packs folders according to the configuration.
  • Loading branch information
skyjake committed Oct 28, 2018
1 parent fcd13a7 commit 0324707
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doomsday/apps/libdoomsday/src/doomsdayapp.cpp
Expand Up @@ -551,11 +551,13 @@ void DoomsdayApp::initialize()

void DoomsdayApp::initWadFolders()
{
d->dataBundles.waitForEverythingIdentified();
d->initWadFolders();
}

void DoomsdayApp::initPackageFolders()
{
d->dataBundles.waitForEverythingIdentified();
DENG2_FOR_AUDIENCE2(FileRefresh, i) i->aboutToRefreshFiles();
d->initPackageFolders();
}
Expand Down
14 changes: 14 additions & 0 deletions doomsday/apps/libdoomsday/src/doomsdayapp_bindings.cpp
Expand Up @@ -18,6 +18,7 @@

#include "doomsday/DoomsdayApp"

#include <de/Folder>
#include <de/ScriptSystem>

using namespace de;
Expand All @@ -36,8 +37,21 @@ static Value *Function_App_Download(Context &, Function::ArgumentValues const &a
return nullptr;
}

static Value *Function_FS_RefreshPackageFolders(Context &, const Function::ArgumentValues &)
{
LOG_SCR_MSG("Initializing package folders...");
Folder::afterPopulation([]() {
DoomsdayApp::app().initWadFolders();
DoomsdayApp::app().initPackageFolders();
});
return nullptr;
}

void DoomsdayApp::initBindings(Binder &binder)
{
binder.init(ScriptSystem::get().nativeModule("App"))
<< DENG2_FUNC(App_Download, "download", "packageId");

binder.init(ScriptSystem::get().nativeModule("FS"))
<< DENG2_FUNC_NOARG(FS_RefreshPackageFolders, "refreshPackageFolders");
}

0 comments on commit 0324707

Please sign in to comment.