mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
ObjLoading: Be able to load and index IWD files
This commit is contained in:
@ -1,13 +1,18 @@
|
||||
#include "ObjLoading.h"
|
||||
#include "IObjLoader.h"
|
||||
#include "Game/T6/ObjLoaderT6.h"
|
||||
#include "ObjContainer/ObjContainerRegistry.h"
|
||||
#include "ObjContainer/IWD/IWD.h"
|
||||
#include "SearchPath/SearchPaths.h"
|
||||
|
||||
ObjLoading::Configuration_t ObjLoading::Configuration;
|
||||
|
||||
IObjLoader* objLoaders[]
|
||||
{
|
||||
new ObjLoaderT6()
|
||||
};
|
||||
|
||||
SearchPaths iwdSearchPaths;
|
||||
|
||||
void ObjLoading::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone)
|
||||
{
|
||||
for (auto* loader : objLoaders)
|
||||
@ -34,5 +39,49 @@ void ObjLoading::LoadObjDataForZone(ISearchPath* searchPath, Zone* zone)
|
||||
|
||||
void ObjLoading::UnloadContainersOfZone(Zone* zone)
|
||||
{
|
||||
g_ObjContainerRegistry.RemoveContainerReferences(zone);
|
||||
for (auto* loader : objLoaders)
|
||||
{
|
||||
if (loader->SupportsZone(zone))
|
||||
{
|
||||
loader->UnloadContainersOfZone(zone);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObjLoading::LoadIWDsInSearchPath(ISearchPath* searchPath)
|
||||
{
|
||||
searchPath->Find(SearchPathSearchOptions().IncludeSubdirectories(false).FilterExtensions("iwd"),
|
||||
[searchPath](const std::string& path) -> void
|
||||
{
|
||||
auto file = FileAPI::Open(path, FileAPI::Mode::MODE_READ);
|
||||
|
||||
if (file.IsOpen())
|
||||
{
|
||||
const auto fileP = new FileAPI::File(std::move(file));
|
||||
IWD* iwd = new IWD(path, fileP);
|
||||
|
||||
if (iwd->Initialize())
|
||||
{
|
||||
IWD::Repository.AddContainer(iwd, searchPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete iwd;
|
||||
|
||||
fileP->Close();
|
||||
delete fileP;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ObjLoading::UnloadIWDsInSearchPath(ISearchPath* searchPath)
|
||||
{
|
||||
IWD::Repository.RemoveContainerReferences(searchPath);
|
||||
}
|
||||
|
||||
ISearchPath* ObjLoading::GetIWDSearchPaths()
|
||||
{
|
||||
return &iwdSearchPaths;
|
||||
}
|
||||
|
Reference in New Issue
Block a user