XmlScreensFile.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include "common/Logger.h"
  16. #include "core/XmlScreenFile.h"
  17. #include "core/XmlScreensFile.h"
  18. #include "core/XmlPrototypesFile.h"
  19. XmlScreensFile::XmlScreensFile(const Ogre::String& file): XmlFile(file){}
  20. XmlScreensFile::~XmlScreensFile(){}
  21. void XmlScreensFile::LoadScreens(){
  22. TiXmlNode* node = file_.RootElement();
  23. if (node == nullptr || node->ValueStr() != "ui"){
  24. LOG_ERROR(
  25. "UI XML Manager: " + file_.ValueStr() + " is not a valid ui file! No <ui> in root."
  26. );
  27. return;
  28. }
  29. node = node->FirstChild();
  30. while (node != nullptr){
  31. if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "prototype"){
  32. XmlPrototypesFile prototypes("./data/" + GetString(node, "file_name"));
  33. prototypes.LoadPrototypes();
  34. }
  35. node = node->NextSibling();
  36. }
  37. node = file_.RootElement();
  38. node = node->FirstChild();
  39. while (node != NULL){
  40. if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "screen"){
  41. XmlScreenFile screen("./data/" + GetString(node, "file_name"));
  42. screen.LoadScreen();
  43. }
  44. node = node->NextSibling();
  45. }
  46. }