project.cpp 1.3 KB

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