mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Refactors to allow support for other wallpaper types
This commit is contained in:
parent
9b05f45bd0
commit
67876c78cc
@ -24,7 +24,7 @@ CProject* CProject::fromFile (const irr::io::path& filename)
|
||||
CProject* project = new CProject (
|
||||
*title,
|
||||
*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 ())
|
||||
|
@ -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));
|
||||
|
||||
@ -105,6 +119,10 @@ CScene* CScene::fromFile (const irr::io::path& filename)
|
||||
return scene;
|
||||
}
|
||||
|
||||
CScene* CScene::loadVideo (const irr::io::path& filename)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::vector<CObject*>& CScene::getObjects () const
|
||||
{
|
||||
|
@ -20,7 +20,9 @@ namespace WallpaperEngine::Core
|
||||
class CScene
|
||||
{
|
||||
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 ();
|
||||
const std::vector<CObject*>& getObjects () const;
|
||||
|
Loading…
Reference in New Issue
Block a user