project.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <irrlicht/irrlicht.h>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <stdexcept>
  5. #include "WallpaperEngine/fs/utils.h"
  6. #include "project.h"
  7. #include "WallpaperEngine/Irrlicht/Irrlicht.h"
  8. namespace WallpaperEngine
  9. {
  10. project::project (irr::io::path& jsonfile_path)
  11. {
  12. this->m_content = WallpaperEngine::FileSystem::loadFullFile (jsonfile_path);
  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).get <std::string> ().c_str ();
  21. this->m_scene = new scene (this->m_file);
  22. }
  23. if (type_it != this->m_projectFile.end ())
  24. {
  25. this->m_type = type_it.value ();
  26. }
  27. if (name_it != this->m_projectFile.end ())
  28. {
  29. this->m_title = name_it.value ();
  30. }
  31. if (this->m_type != "scene")
  32. {
  33. throw std::runtime_error ("Only scene wallpapers are supported");
  34. }
  35. }
  36. scene* project::getScene ()
  37. {
  38. return this->m_scene;
  39. }
  40. }