Refactors to allow support for other wallpaper types

This commit is contained in:
IceCryptonym 2020-03-31 14:03:03 +10:00
parent 9b05f45bd0
commit 67876c78cc
3 changed files with 23 additions and 3 deletions

View File

@ -24,7 +24,7 @@ CProject* CProject::fromFile (const irr::io::path& filename)
CProject* project = new CProject ( CProject* project = new CProject (
*title, *title,
*type, *type,
CScene::fromFile ((*file).get <std::string> ().c_str ()) CScene::fromFile ((*file).get <std::string> ().c_str (), (*type).get <std::string> ().c_str())
); );
if (general != content.end ()) if (general != content.end ())

View File

@ -45,7 +45,21 @@ CScene::CScene (
{ {
} }
CScene* CScene::fromFile (const irr::io::path& filename) CScene* CScene::fromFile (const irr::io::path& filename, const char *type)
{
if (strcmp(type, "scene") == 0)
{
return loadScene (filename);
}
else if (strcmp(type, "video") == 0)
{
return loadVideo (filename);
}
throw std::runtime_error("Unsupported wallpaper type");
}
CScene* CScene::loadScene (const irr::io::path& filename)
{ {
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)); json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename));
@ -105,6 +119,10 @@ CScene* CScene::fromFile (const irr::io::path& filename)
return scene; return scene;
} }
CScene* CScene::loadVideo (const irr::io::path& filename)
{
return nullptr;
}
const std::vector<CObject*>& CScene::getObjects () const const std::vector<CObject*>& CScene::getObjects () const
{ {

View File

@ -20,7 +20,9 @@ namespace WallpaperEngine::Core
class CScene class CScene
{ {
public: public:
static CScene* fromFile (const irr::io::path& filename); static CScene* fromFile (const irr::io::path& filename, const char *type);
static CScene* loadScene (const irr::io::path& filename);
static CScene* loadVideo (const irr::io::path& filename);
CProject* getProject (); CProject* getProject ();
const std::vector<CObject*>& getObjects () const; const std::vector<CObject*>& getObjects () const;