project.cpp 1.3 KB

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