project.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. if (this->m_type != "scene")
  34. {
  35. throw "Only scene wallpapers supported for now";
  36. }
  37. }
  38. scene* project::getScene ()
  39. {
  40. return this->m_scene;
  41. }
  42. }