From e4381d57d60217b75cba356e1a39e831d8ba2916 Mon Sep 17 00:00:00 2001 From: Jett <55758076+Jettford@users.noreply.github.com> Date: Thu, 24 Feb 2022 10:08:55 +0000 Subject: [PATCH] Update InventoryComponent Loading from XML Expands the ability to load extra info from the inventories XML data --- dGame/dComponents/InventoryComponent.cpp | 30 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index f1bd8db..515893c 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -619,11 +619,33 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document) if (extraInfo) { - std::string modInfo = extraInfo->Attribute("ma"); + std::unordered_map extraInfoMap = { + {"b", "modelBehaviors"}, + {"ub", "userModelBehaviors"}, + {"ud", "userModelDesc"}, + {"ui", "userModelID"}, + {"um", "userModelMod"}, + {"un", "userModelName"}, + {"uo", "userModelOpt"}, + {"up", "userModelPhysicsType"} + }; + + for (const auto& item : extraInfoMap) { + auto* attribute = extraInfo->FindAttribute(item.first.c_str()); + + if (attribute) { + LDFBaseData* extraInfoItem = new LDFData(GeneralUtils::ASCIIToUTF16(item.second), GeneralUtils::ASCIIToUTF16(attribute->Value())); + config.push_back(extraInfoItem); + } + } + + if (extraInfo->FindAttribute("ma")) { + std::string modInfo = extraInfo->Attribute("ma"); - LDFBaseData* moduleAssembly = new LDFData(u"assemblyPartLOTs", GeneralUtils::ASCIIToUTF16(modInfo.substr(2, modInfo.size() - 1))); - - config.push_back(moduleAssembly); + LDFBaseData* moduleAssembly = new LDFData(u"assemblyPartLOTs", GeneralUtils::ASCIIToUTF16(modInfo.substr(2, modInfo.size() - 1))); + + config.push_back(moduleAssembly); + } } const auto* item = new Item(id, lot, inventory, slot, count, bound, config, parent, subKey);