Moved C++ tools out
This commit is contained in:
40
archive/dawntools/util/parser/SceneAssetParser.cpp
Normal file
40
archive/dawntools/util/parser/SceneAssetParser.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "SceneAssetParser.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
std::vector<std::string> SceneAssetParser::getRequiredAttributes() {
|
||||
return { "type", "name" };
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> SceneAssetParser::getOptionalAttributes() {
|
||||
return {
|
||||
{ "ref", "" }
|
||||
};
|
||||
}
|
||||
|
||||
int32_t SceneAssetParser::onParse(
|
||||
Xml *node,
|
||||
std::map<std::string, std::string> values,
|
||||
struct SceneAsset *out,
|
||||
std::string *error
|
||||
) {
|
||||
out->fileName = values["name"];
|
||||
|
||||
if(values["type"] == "texture") {
|
||||
out->type = SCENE_ASSET_TYPE_TEXTURE;
|
||||
} else if(values["type"] == "truetype") {
|
||||
out->type = SCENE_ASSET_TYPE_TRUETYPE_FONT;
|
||||
} else {
|
||||
*error = "Unknown asset type '" + values["type"] + "'";
|
||||
return 1;
|
||||
}
|
||||
|
||||
out->ref = values["ref"];
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user