mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
Warn user whenever specified asset type is unrecognized
This commit is contained in:
parent
2108737f22
commit
6e57834dc6
@ -216,15 +216,49 @@ class Unlinker::Impl
|
||||
|
||||
ObjWriting::Configuration.AssetTypesToHandleBitfield = std::vector<bool>(assetTypeCount);
|
||||
|
||||
std::vector<bool> handledSpecifiedAssets(m_args.m_specified_asset_types.size());
|
||||
for (auto i = 0; i < assetTypeCount; i++)
|
||||
{
|
||||
const auto assetTypeName = std::string(context.m_zone->m_pools->GetAssetTypeName(i));
|
||||
|
||||
if (m_args.m_specified_asset_types.find(assetTypeName) != m_args.m_specified_asset_types.end())
|
||||
const auto foundSpecifiedEntry = m_args.m_specified_asset_type_map.find(assetTypeName);
|
||||
if (foundSpecifiedEntry != m_args.m_specified_asset_type_map.end())
|
||||
{
|
||||
ObjWriting::Configuration.AssetTypesToHandleBitfield[i] = m_args.m_asset_type_handling == UnlinkerArgs::AssetTypeHandling::INCLUDE;
|
||||
assert(foundSpecifiedEntry->second < handledSpecifiedAssets.size());
|
||||
handledSpecifiedAssets[foundSpecifiedEntry->second] = true;
|
||||
}
|
||||
else
|
||||
ObjWriting::Configuration.AssetTypesToHandleBitfield[i] = m_args.m_asset_type_handling == UnlinkerArgs::AssetTypeHandling::EXCLUDE;
|
||||
}
|
||||
|
||||
auto anySpecifiedValueInvalid = false;
|
||||
for (auto i = 0u; i < handledSpecifiedAssets.size(); i++)
|
||||
{
|
||||
if (!handledSpecifiedAssets[i])
|
||||
{
|
||||
std::cerr << "Unknown asset type \"" << m_args.m_specified_asset_types[i] << "\"\n";
|
||||
anySpecifiedValueInvalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (anySpecifiedValueInvalid)
|
||||
{
|
||||
std::cerr << "Valid asset types are:\n";
|
||||
|
||||
auto first = true;
|
||||
for (auto i = 0; i < assetTypeCount; i++)
|
||||
{
|
||||
const auto assetTypeName = std::string(context.m_zone->m_pools->GetAssetTypeName(i));
|
||||
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
std::cerr << ", ";
|
||||
std::cerr << assetTypeName;
|
||||
}
|
||||
std::cerr << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,6 +197,16 @@ bool UnlinkerArgs::SetModelDumpingMode()
|
||||
return false;
|
||||
}
|
||||
|
||||
void UnlinkerArgs::AddSpecifiedAssetType(std::string value)
|
||||
{
|
||||
const auto alreadySpecifiedAssetType = m_specified_asset_type_map.find(value);
|
||||
if (alreadySpecifiedAssetType == m_specified_asset_type_map.end())
|
||||
{
|
||||
m_specified_asset_type_map.emplace(std::make_pair(value, m_specified_asset_types.size()));
|
||||
m_specified_asset_types.emplace_back(std::move(value));
|
||||
}
|
||||
}
|
||||
|
||||
void UnlinkerArgs::ParseCommaSeparatedAssetTypeString(const std::string& input)
|
||||
{
|
||||
auto currentPos = 0u;
|
||||
@ -208,12 +218,12 @@ void UnlinkerArgs::ParseCommaSeparatedAssetTypeString(const std::string& input)
|
||||
|
||||
while (currentPos < lowerInput.size() && (endPos = lowerInput.find_first_of(',', currentPos)) != std::string::npos)
|
||||
{
|
||||
m_specified_asset_types.emplace(lowerInput, currentPos, endPos - currentPos);
|
||||
AddSpecifiedAssetType(std::string(lowerInput, currentPos, endPos - currentPos));
|
||||
currentPos = endPos + 1;
|
||||
}
|
||||
|
||||
if (currentPos < lowerInput.size())
|
||||
m_specified_asset_types.emplace(lowerInput, currentPos, lowerInput.size() - currentPos);
|
||||
AddSpecifiedAssetType(std::string(lowerInput, currentPos, lowerInput.size() - currentPos));
|
||||
}
|
||||
|
||||
bool UnlinkerArgs::ParseArgs(const int argc, const char** argv)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Utils/Arguments/ArgumentParser.h"
|
||||
#include "Zone/Zone.h"
|
||||
@ -25,6 +26,7 @@ private:
|
||||
bool SetImageDumpingMode();
|
||||
bool SetModelDumpingMode();
|
||||
|
||||
void AddSpecifiedAssetType(std::string value);
|
||||
void ParseCommaSeparatedAssetTypeString(const std::string& input);
|
||||
|
||||
public:
|
||||
@ -48,7 +50,8 @@ public:
|
||||
std::string m_output_folder;
|
||||
bool m_minimal_zone_def;
|
||||
|
||||
std::set<std::string> m_specified_asset_types;
|
||||
std::vector<std::string> m_specified_asset_types;
|
||||
std::unordered_map<std::string, size_t> m_specified_asset_type_map;
|
||||
AssetTypeHandling m_asset_type_handling;
|
||||
|
||||
bool m_use_gdt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user