XmlArchive.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "EditorDefs.h"
  9. #include "XmlArchive.h"
  10. // Editor
  11. #include "PakFile.h"
  12. //////////////////////////////////////////////////////////////////////////
  13. // CXmlArchive
  14. //////////////////////////////////////////////////////////////////////////
  15. bool CXmlArchive::SaveToPak([[maybe_unused]] const QString& levelPath, CPakFile& pakFile)
  16. {
  17. _smart_ptr<IXmlStringData> pXmlStrData = root->getXMLData(5000000);
  18. // Save xml file.
  19. QString xmlFilename = "level.editor_xml";
  20. pakFile.UpdateFile(xmlFilename.toUtf8().data(), (void*)pXmlStrData->GetString(), static_cast<int>(pXmlStrData->GetStringLength()));
  21. if (pakFile.GetArchive())
  22. {
  23. CLogFile::FormatLine("Saving pak file %.*s", AZ_STRING_ARG(pakFile.GetArchive()->GetFullPath().Native()));
  24. }
  25. pNamedData->Save(pakFile);
  26. return true;
  27. }
  28. //////////////////////////////////////////////////////////////////////////
  29. bool CXmlArchive::LoadFromPak(const QString& levelPath, CPakFile& pakFile)
  30. {
  31. QString xmlFilename = QDir(levelPath).absoluteFilePath("level.editor_xml");
  32. root = XmlHelpers::LoadXmlFromFile(xmlFilename.toUtf8().data());
  33. if (!root)
  34. {
  35. return false;
  36. }
  37. return pNamedData->Load(levelPath, pakFile);
  38. }