mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00

~ Added a small utils class to read full files to ram for the purpose of parsing json files Most of these files are really small, so there shouldn't really be any memory concerns + Added support for loading backgrounds directly from PKG files Signed-off-by: Alexis Maiquez Murcia <almamu@almamu.com>
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
#include <irrlicht/irrlicht.h>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <stdexcept>
|
|
|
|
#include "wallpaperengine/fs/utils.h"
|
|
|
|
#include "project.h"
|
|
#include "irrlicht.h"
|
|
|
|
namespace wp
|
|
{
|
|
project::project (irr::io::path& jsonfile_path)
|
|
{
|
|
this->m_content = wp::fs::utils::loadFullFile (jsonfile_path);
|
|
this->m_projectFile = json::parse (this->m_content);
|
|
|
|
json::const_iterator file_it = this->m_projectFile.find ("file");
|
|
json::const_iterator name_it = this->m_projectFile.find ("title");
|
|
json::const_iterator type_it = this->m_projectFile.find ("type");
|
|
|
|
if (file_it != this->m_projectFile.end ())
|
|
{
|
|
// load scene file
|
|
this->m_file = (*file_it).get <std::string> ().c_str ();
|
|
this->m_scene = new scene (this->m_file);
|
|
}
|
|
|
|
if (type_it != this->m_projectFile.end ())
|
|
{
|
|
this->m_type = type_it.value ();
|
|
}
|
|
|
|
if (name_it != this->m_projectFile.end ())
|
|
{
|
|
this->m_title = name_it.value ();
|
|
}
|
|
|
|
if (this->m_type != "scene")
|
|
{
|
|
throw std::runtime_error ("Only scene wallpapers are supported");
|
|
}
|
|
}
|
|
|
|
scene* project::getScene ()
|
|
{
|
|
return this->m_scene;
|
|
}
|
|
} |