mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
~ Changed parser to give sane defaults to some values (like origin, scale and size for each object)
~ Improved path detection on command line arguments - Removed references to old, deprecated options Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
d041e6455e
commit
adad3bd18c
18
main.cpp
18
main.cpp
@ -38,8 +38,6 @@ void print_help (const char* route)
|
||||
<< "Usage:" << route << " [options] background_path" << std::endl
|
||||
<< "options:" << std::endl
|
||||
<< " --silent\t\tMutes all the sound the wallpaper might produce" << std::endl
|
||||
<< " --dir <folder>\tLoads an uncompressed background from the given <folder> [deprecated]" << std::endl
|
||||
<< " --pkg <folder>\tLoads a scene.pkg file from the given <folder> [deprecated]" << std::endl
|
||||
<< " --screen-root <screen name>\tDisplay as screen's background" << std::endl
|
||||
<< " --fps <maximum-fps>\tLimits the FPS to the given number, useful to keep battery consumption low" << std::endl;
|
||||
}
|
||||
@ -120,10 +118,20 @@ int main (int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (path.empty () == true && option_index == 0 || strlen (argv [option_index]) == 0)
|
||||
// increment the option index (useful for when no options were found)
|
||||
option_index ++;
|
||||
|
||||
if (path.empty () == true)
|
||||
{
|
||||
print_help (argv [0]);
|
||||
return 0;
|
||||
if (option_index < argc && strlen (argv [option_index]) > 0)
|
||||
{
|
||||
path = argv [option_index];
|
||||
}
|
||||
else
|
||||
{
|
||||
print_help (argv [0]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// first of all, initialize the window
|
||||
|
@ -34,9 +34,9 @@ CObject* CObject::fromJSON (json data, CContainer* container)
|
||||
|
||||
auto id_it = jsonFindRequired (data, "id", "Objects must have id");
|
||||
auto visible_it = data.find ("visible");
|
||||
auto origin_it = jsonFindRequired (data, "origin", "Objects must have origin point");
|
||||
auto scale_it = jsonFindRequired (data, "scale", "Objects must have scale");
|
||||
auto angles_it = jsonFindRequired (data, "angles", "Objects must have angles");
|
||||
auto origin_val = jsonFindDefault <std::string> (data, "origin", "0.0 0.0 0.0");
|
||||
auto scale_val = jsonFindDefault <std::string> (data, "scale", "0.0 0.0 0.0");
|
||||
auto angles_val = jsonFindDefault <std::string> (data, "angles", "0.0 0.0 0.0");
|
||||
auto name_it = jsonFindRequired (data, "name", "Objects must have name");
|
||||
auto effects_it = data.find ("effects");
|
||||
auto dependencies_it = data.find ("dependencies");
|
||||
@ -74,9 +74,9 @@ CObject* CObject::fromJSON (json data, CContainer* container)
|
||||
visible,
|
||||
*id_it,
|
||||
*name_it,
|
||||
WallpaperEngine::Core::aToVector3 (*origin_it),
|
||||
WallpaperEngine::Core::aToVector3 (*scale_it),
|
||||
WallpaperEngine::Core::aToVector3 (*angles_it)
|
||||
WallpaperEngine::Core::aToVector3 (origin_val),
|
||||
WallpaperEngine::Core::aToVector3 (scale_val),
|
||||
WallpaperEngine::Core::aToVector3 (angles_val)
|
||||
);
|
||||
}
|
||||
else if (sound_it != data.end () && (*sound_it).is_null () == false)
|
||||
@ -86,9 +86,9 @@ CObject* CObject::fromJSON (json data, CContainer* container)
|
||||
visible,
|
||||
*id_it,
|
||||
*name_it,
|
||||
WallpaperEngine::Core::aToVector3 (*origin_it),
|
||||
WallpaperEngine::Core::aToVector3 (*scale_it),
|
||||
WallpaperEngine::Core::aToVector3 (*angles_it)
|
||||
WallpaperEngine::Core::aToVector3 (origin_val),
|
||||
WallpaperEngine::Core::aToVector3 (scale_val),
|
||||
WallpaperEngine::Core::aToVector3 (angles_val)
|
||||
);
|
||||
}
|
||||
else if (particle_it != data.end () && (*particle_it).is_null () == false)
|
||||
@ -101,8 +101,8 @@ CObject* CObject::fromJSON (json data, CContainer* container)
|
||||
container,
|
||||
*id_it,
|
||||
*name_it,
|
||||
WallpaperEngine::Core::aToVector3 (*origin_it),
|
||||
WallpaperEngine::Core::aToVector3 (*scale_it)
|
||||
WallpaperEngine::Core::aToVector3 (origin_val),
|
||||
WallpaperEngine::Core::aToVector3 (scale_val)
|
||||
);
|
||||
}
|
||||
catch (std::runtime_error ex)
|
||||
|
@ -35,7 +35,7 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
|
||||
const glm::vec3& angles)
|
||||
{
|
||||
auto image_it = data.find ("image");
|
||||
auto size_it = jsonFindRequired (data, "size", "Images must have size");
|
||||
auto size_val = jsonFindDefault <std::string> (data, "size", "0.0 0.0"); // this one might need some adjustment
|
||||
auto alignment = jsonFindDefault <std::string> (data, "alignment", "center");
|
||||
|
||||
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile ((*image_it).get <std::string> (), container));
|
||||
@ -50,7 +50,7 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
|
||||
origin,
|
||||
scale,
|
||||
angles,
|
||||
WallpaperEngine::Core::aToVector2 (*size_it),
|
||||
WallpaperEngine::Core::aToVector2 (size_val),
|
||||
alignment
|
||||
);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ CFBO::CFBO (std::string name, ITexture::TextureFormat format, float scale, uint3
|
||||
// ensure first framebuffer is okay
|
||||
if (glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
throw std::runtime_error ("Framebuffers are not properly set");
|
||||
|
||||
|
||||
// clear the framebuffer
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
@ -58,10 +58,10 @@ void CEffect::generateFBOs ()
|
||||
(*cur)->getName (),
|
||||
ITexture::TextureFormat::ARGB8888, // TODO: CHANGE
|
||||
(*cur)->getScale (),
|
||||
this->m_image->getImage ()->getSize ().x / (*cur)->getScale (),
|
||||
this->m_image->getImage ()->getSize ().y / (*cur)->getScale (),
|
||||
this->m_image->getImage ()->getSize ().x / (*cur)->getScale (),
|
||||
this->m_image->getImage ()->getSize ().y / (*cur)->getScale ()
|
||||
this->m_image->getSize ().x / (*cur)->getScale (),
|
||||
this->m_image->getSize ().y / (*cur)->getScale (),
|
||||
this->m_image->getSize ().x / (*cur)->getScale (),
|
||||
this->m_image->getSize ().y / (*cur)->getScale ()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
auto scene_height = static_cast <float> (projection->getHeight ());
|
||||
|
||||
glm::vec3 origin = this->getImage ()->getOrigin ();
|
||||
glm::vec2 size = this->getImage ()->getSize ();
|
||||
glm::vec2 size = this->getSize ();
|
||||
glm::vec3 scale = this->getImage ()->getScale ();
|
||||
|
||||
float xleft = 0.0f;
|
||||
@ -318,6 +318,14 @@ const std::vector<CEffect*>& CImage::getEffects () const
|
||||
return this->m_effects;
|
||||
}
|
||||
|
||||
const glm::vec2 CImage::getSize() const
|
||||
{
|
||||
if (this->m_texture == nullptr)
|
||||
return this->getImage ()->getSize ();
|
||||
|
||||
return {this->m_texture->getRealWidth (), this->m_texture->getRealHeight ()};
|
||||
}
|
||||
|
||||
const GLuint* CImage::getSceneSpacePosition () const
|
||||
{
|
||||
return &this->m_sceneSpacePosition;
|
||||
|
@ -36,6 +36,7 @@ namespace WallpaperEngine::Render::Objects
|
||||
|
||||
const Core::Objects::CImage* getImage () const;
|
||||
const std::vector<CEffect*>& getEffects () const;
|
||||
const glm::vec2 getSize() const;
|
||||
|
||||
const GLfloat* getVertex () const;
|
||||
const GLuint* getSceneSpacePosition () const;
|
||||
|
Loading…
Reference in New Issue
Block a user