On building of asset file directory, check for recognised assets without meta file and generate #200
|
@ -0,0 +1,3 @@
|
|||
Name: AIPrototype
|
||||
ID: 163215061
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: CameraControl
|
||||
ID: 158782344
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: CameraFix
|
||||
ID: 162231964
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: Item
|
||||
ID: 163145289
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: PhysicsTest
|
||||
ID: 159771801
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: PickAndThrow
|
||||
ID: 165331952
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: PlayerController
|
||||
ID: 164563088
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: PrintWhenActive
|
||||
ID: 162536221
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: RaccoonShowcase
|
||||
ID: 159969631
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: RaccoonSpin
|
||||
ID: 157367824
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: ThirdPersonCamera
|
||||
ID: 154161201
|
||||
Type: 9
|
|
@ -83,7 +83,7 @@ namespace SHADE
|
|||
|
||||
AssetPath SHAssetManager::GenerateLocalPath(AssetPath path) noexcept
|
||||
{
|
||||
if (!IsRecognised(path.extension().string().c_str()))
|
||||
if (!SHFileSystem::IsRecognised(path.extension().string().c_str()))
|
||||
{
|
||||
//TODO:ASSERT UNRECOGNISED FILE TYPE
|
||||
return std::filesystem::path();
|
||||
|
@ -380,19 +380,6 @@ namespace SHADE
|
|||
BuildAssetCollection();
|
||||
}
|
||||
|
||||
bool SHAssetManager::IsRecognised(char const* ext) noexcept
|
||||
{
|
||||
for (auto const& e : EXTENSIONS)
|
||||
{
|
||||
if (strcmp(ext, e.data()) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SHAsset SHAssetManager::CreateAssetFromPath(AssetPath path) noexcept
|
||||
{
|
||||
SHAsset result;
|
||||
|
@ -500,7 +487,7 @@ namespace SHADE
|
|||
{
|
||||
}
|
||||
|
||||
void SHAssetManager::GenerateNewMeta(AssetPath path) noexcept
|
||||
std::optional<AssetID> SHAssetManager::GenerateNewMeta(AssetPath path) noexcept
|
||||
{
|
||||
auto const ext = path.extension().string();
|
||||
if (ext == SHADER_BUILT_IN_EXTENSION.data())
|
||||
|
@ -561,11 +548,32 @@ namespace SHADE
|
|||
|
||||
SHAssetMetaHandler::WriteMetaData(assetCollection[newAsset.id]);
|
||||
}
|
||||
else if (ext == SCRIPT_EXTENSION)
|
||||
{
|
||||
SHAsset newAsset{
|
||||
path.stem().string(),
|
||||
GenerateAssetID(AssetType::SCRIPT),
|
||||
AssetType::SCRIPT,
|
||||
path,
|
||||
false
|
||||
};
|
||||
assetCollection.emplace(newAsset.id, newAsset);
|
||||
SHAssetMetaHandler::WriteMetaData(newAsset);
|
||||
|
||||
return newAsset.id;
|
||||
}
|
||||
}
|
||||
|
||||
void SHAssetManager::BuildAssetCollection() noexcept
|
||||
{
|
||||
SHFileSystem::BuildDirectory(ASSET_ROOT.data(), folderRoot, assetCollection);
|
||||
std::vector<SHFile*> toGenNew;
|
||||
SHFileSystem::BuildDirectory(ASSET_ROOT.data(), folderRoot, assetCollection, toGenNew);
|
||||
|
||||
for (auto& file : toGenNew)
|
||||
{
|
||||
auto newID{ GenerateNewMeta(file->path).value() };
|
||||
file->assetMeta = &assetCollection[newID];
|
||||
}
|
||||
|
||||
for (auto& asset : std::ranges::views::values(assetCollection))
|
||||
{
|
||||
|
|
|
@ -99,12 +99,10 @@ namespace SHADE
|
|||
static SHAssetData* LoadData(SHAsset const& asset) noexcept;
|
||||
static SHAssetData* LoadSubData(SHAsset const& asset) noexcept;
|
||||
static void LoadNewData(AssetPath path) noexcept;
|
||||
static void GenerateNewMeta(AssetPath path) noexcept;
|
||||
static std::optional<AssetID> GenerateNewMeta(AssetPath path) noexcept;
|
||||
|
||||
inline static void BuildAssetCollection() noexcept;
|
||||
|
||||
static bool IsRecognised(char const*) noexcept;
|
||||
|
||||
static SHAsset CreateAssetFromPath(AssetPath path) noexcept;
|
||||
|
||||
static bool DeleteLocalFile(AssetPath path) noexcept;
|
||||
|
|
|
@ -25,6 +25,19 @@ namespace SHADE
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SHFileSystem::IsRecognised(char const* ext) noexcept
|
||||
{
|
||||
for (auto const& e : EXTENSIONS)
|
||||
{
|
||||
if (strcmp(ext, e.data()) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SHFileSystem::IsCompilable(std::string ext) noexcept
|
||||
{
|
||||
for (auto const& external : EXTERNALS)
|
||||
|
@ -73,7 +86,11 @@ namespace SHADE
|
|||
return false;
|
||||
}
|
||||
|
||||
void SHFileSystem::BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept
|
||||
void SHFileSystem::BuildDirectory(
|
||||
FolderPath path,
|
||||
FolderPointer& root,
|
||||
std::unordered_map<AssetID, SHAsset>& assetCollection,
|
||||
std::vector<SHFile*>& toGenerate) noexcept
|
||||
{
|
||||
std::stack<FolderPointer> folderStack;
|
||||
root = new SHFolder("root");
|
||||
|
@ -117,22 +134,50 @@ namespace SHADE
|
|||
folderStack.push(newFolder);
|
||||
}
|
||||
|
||||
for (auto const& asset : assets)
|
||||
for (auto& file : folder->files)
|
||||
{
|
||||
assetCollection.emplace(asset.id, asset);
|
||||
for(auto& file : folder->files)
|
||||
if (!IsRecognised(file.ext.c_str()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool found{ false };
|
||||
for (auto const& asset : assets)
|
||||
{
|
||||
assetCollection.emplace(asset.id, asset);
|
||||
if (file.name == asset.name)
|
||||
{
|
||||
AssetPath path{ file.path };
|
||||
if (SHAssetMetaHandler::GetTypeFromExtension(path.extension().string()) == asset.type)
|
||||
{
|
||||
file.assetMeta = &assetCollection[asset.id];
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
toGenerate.push_back(&file);
|
||||
}
|
||||
}
|
||||
//for (auto const& asset : assets)
|
||||
//{
|
||||
// assetCollection.emplace(asset.id, asset);
|
||||
// for(auto& file : folder->files)
|
||||
// {
|
||||
// if (file.name == asset.name)
|
||||
// {
|
||||
// AssetPath path{ file.path };
|
||||
// if (SHAssetMetaHandler::GetTypeFromExtension(path.extension().string()) == asset.type)
|
||||
// {
|
||||
// file.assetMeta = &assetCollection[asset.id];
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
for (auto i {0}; i < folder->files.size(); ++i)
|
||||
{
|
||||
|
|
|
@ -19,8 +19,14 @@ namespace SHADE
|
|||
class SHFileSystem
|
||||
{
|
||||
public:
|
||||
static void BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept;
|
||||
static void BuildDirectory(
|
||||
FolderPath path,
|
||||
FolderPointer& root,
|
||||
std::unordered_map<AssetID, SHAsset>& assetCollection,
|
||||
std::vector<SHFile*>& toGenerate) noexcept;
|
||||
static void DestroyDirectory(FolderPointer root) noexcept;
|
||||
|
||||
static bool IsRecognised(char const*) noexcept;
|
||||
private:
|
||||
static bool DeleteFolder(FolderPointer location) noexcept;
|
||||
static bool IsCompilable(std::string ext) noexcept;
|
||||
|
|
Loading…
Reference in New Issue