From 2e08fd38eaab3d33da86c57fced82f374ed737f5 Mon Sep 17 00:00:00 2001 From: wraitii Date: Tue, 4 May 2021 15:17:50 +0000 Subject: [PATCH] GUI cleanup: XML & child handling. - We only need an XMBFile, not a CXeromyces to parse GUI objects/scripts/... This makes the interface more consistent with other usage, notably ParamNode. - Rename IGUIObject::AddChild to RegisterChild and flesh out the interface a little. Differential Revision: https://code.wildfiregames.com/D3908 This was SVN commit r25378. --- source/gui/CGUI.cpp | 208 +++++++++++++------------- source/gui/CGUI.h | 30 ++-- source/gui/ObjectBases/IGUIObject.cpp | 16 +- source/gui/ObjectBases/IGUIObject.h | 20 ++- source/gui/ObjectTypes/CList.cpp | 4 +- source/gui/ObjectTypes/CList.h | 2 +- source/gui/ObjectTypes/COList.cpp | 8 +- source/gui/ObjectTypes/COList.h | 4 +- 8 files changed, 153 insertions(+), 139 deletions(-) diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index db9771ee3f..67686a44be 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -386,7 +386,7 @@ bool CGUI::AddObject(IGUIObject& parent, IGUIObject& child) } m_pAllObjects[child.m_Name] = &child; - parent.AddChild(child); + parent.RegisterChild(&child); return true; } @@ -527,21 +527,21 @@ void CGUI::LoadXmlFile(const VfsPath& Filename, std::unordered_set& Pat { Paths.insert(Filename); - CXeromyces XeroFile; - if (XeroFile.Load(g_VFS, Filename, "gui") != PSRETURN_OK) + CXeromyces xeroFile; + if (xeroFile.Load(g_VFS, Filename, "gui") != PSRETURN_OK) return; - XMBElement node = XeroFile.GetRoot(); - std::string_view root_name(XeroFile.GetElementStringView(node.GetNodeName())); + XMBElement node = xeroFile.GetRoot(); + std::string_view root_name(xeroFile.GetElementStringView(node.GetNodeName())); if (root_name == "objects") - Xeromyces_ReadRootObjects(node, &XeroFile, Paths); + Xeromyces_ReadRootObjects(xeroFile, node, Paths); else if (root_name == "sprites") - Xeromyces_ReadRootSprites(node, &XeroFile); + Xeromyces_ReadRootSprites(xeroFile, node); else if (root_name == "styles") - Xeromyces_ReadRootStyles(node, &XeroFile); + Xeromyces_ReadRootStyles(xeroFile, node); else if (root_name == "setup") - Xeromyces_ReadRootSetup(node, &XeroFile); + Xeromyces_ReadRootSetup(xeroFile, node); else LOGERROR("CGUI::LoadXmlFile encountered an unknown XML root node type: %s", root_name.data()); } @@ -560,63 +560,62 @@ void CGUI::LoadedXmlFiles() // XML Reading Xeromyces Specific Sub-Routines //=================================================================== -void CGUI::Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, std::unordered_set& Paths) +void CGUI::Xeromyces_ReadRootObjects(const XMBData& xmb, XMBElement element, std::unordered_set& Paths) { - int el_script = pFile->GetElementID("script"); + int el_script = xmb.GetElementID("script"); std::vector > subst; // Iterate main children // they should all be or