Project.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <irrlicht/irrlicht.h>
  2. #include <iostream>
  3. #include <fstream>
  4. #include "Project.h"
  5. Project::Project (irr::io::path baseDirectory)
  6. {
  7. irr::io::path projectFile = baseDirectory + "/project.json";
  8. std::ifstream _in (projectFile.c_str ());
  9. this->m_content = "";
  10. this->m_content.append (std::istreambuf_iterator<char> (_in), std::istreambuf_iterator<char> ());
  11. this->m_projectFile = json::parse (this->m_content);
  12. json::const_iterator file_it = this->m_projectFile.find ("file");
  13. json::const_iterator name_it = this->m_projectFile.find ("title");
  14. json::const_iterator type_it = this->m_projectFile.find ("type");
  15. if (file_it != this->m_projectFile.end ())
  16. {
  17. // load scene file
  18. this->m_file = file_it.value ();
  19. this->m_file = baseDirectory.c_str ();
  20. this->m_file += "/";
  21. this->m_file += this->m_projectFile ["file"];
  22. this->m_scene = new Scene (this->m_file.c_str ());
  23. }
  24. if (type_it != this->m_projectFile.end ())
  25. {
  26. this->m_type = type_it.value ();
  27. }
  28. if (name_it != this->m_projectFile.end ())
  29. {
  30. this->m_title = name_it.value ();
  31. }
  32. }