2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-10 21:21:50 +00:00

refactor: extract material name into common source file

This commit is contained in:
Jan
2025-06-25 19:34:09 +01:00
parent dceca0ec9a
commit 6c114fe58a
4 changed files with 34 additions and 36 deletions

View File

@ -0,0 +1,22 @@
#include "MaterialCommon.h"
#include <algorithm>
#include <format>
namespace material
{
std::string GetFileNameForAssetName(const std::string& assetName)
{
std::string sanitizedFileName(assetName);
if (sanitizedFileName[0] == '*')
{
std::ranges::replace(sanitizedFileName, '*', '_');
const auto parenthesisPos = sanitizedFileName.find('(');
if (parenthesisPos != std::string::npos)
sanitizedFileName.erase(parenthesisPos);
sanitizedFileName = std::format("generated/{}", sanitizedFileName);
}
return std::format("materials/{}.json", sanitizedFileName);
}
} // namespace material

View File

@ -0,0 +1,8 @@
#pragma once
#include <string>
namespace material
{
std::string GetFileNameForAssetName(const std::string& assetName);
}