Add Alternate Headers XML logger (#4207)

This commit is contained in:
Pepe20129 2024-06-16 05:47:35 +02:00 committed by GitHub
parent f99993af85
commit 839fcffe17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@ std::shared_ptr<Ship::IResource> SetAlternateHeadersFactory::ReadResource(std::s
auto headerName = reader->ReadString(); auto headerName = reader->ReadString();
if (!headerName.empty()) { if (!headerName.empty()) {
setAlternateHeaders->headers.push_back(std::static_pointer_cast<Scene>(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); setAlternateHeaders->headers.push_back(std::static_pointer_cast<Scene>(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str())));
setAlternateHeaders->headerFileNames.push_back(headerName);
} else { } else {
setAlternateHeaders->headers.push_back(nullptr); setAlternateHeaders->headers.push_back(nullptr);
} }
@ -41,7 +42,7 @@ std::shared_ptr<Ship::IResource> SetAlternateHeadersFactoryXML::ReadResource(std
std::string childName = child->Name(); std::string childName = child->Name();
if (childName == "AlternateHeader") { if (childName == "AlternateHeader") {
for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) {
auto headerName = std::string(child->Attribute("HeaderName")); auto headerName = std::string(child->Attribute("Path"));
if (!headerName.empty()) { if (!headerName.empty()) {
setAlternateHeaders->headers.push_back(std::static_pointer_cast<Scene>(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); setAlternateHeaders->headers.push_back(std::static_pointer_cast<Scene>(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str())));
} else { } else {

View File

@ -73,6 +73,12 @@ void LogAlternateHeadersAsXML(std::shared_ptr<Ship::IResource> resource) {
tinyxml2::XMLElement* root = doc.NewElement("SetAlternateHeaders"); tinyxml2::XMLElement* root = doc.NewElement("SetAlternateHeaders");
doc.InsertFirstChild(root); doc.InsertFirstChild(root);
for (size_t i = 0; i < setAlternateHeaders->headerFileNames.size(); i++) {
tinyxml2::XMLElement* entry = doc.NewElement("Header");
entry->SetAttribute("Path", setAlternateHeaders->headerFileNames[i].c_str());
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer; tinyxml2::XMLPrinter printer;
doc.Accept(&printer); doc.Accept(&printer);

View File

@ -21,6 +21,7 @@ class SetAlternateHeaders : public SceneCommand<void> {
size_t GetPointerSize(); size_t GetPointerSize();
uint32_t numHeaders; uint32_t numHeaders;
std::vector<std::string> headerFileNames;
std::vector<std::shared_ptr<Scene>> headers; std::vector<std::shared_ptr<Scene>> headers;
}; };
}; // namespace LUS }; // namespace LUS