Pārlūkot izejas kodu

~ fixed video background playback being broken
~ CTexture should properly pick up the right width and height for animated backgrounds too

Signed-off-by: Alexis Maiquez <almamu@almamu.com>

Alexis Maiquez 4 gadi atpakaļ
vecāks
revīzija
34635ba6ac
2 mainītis faili ar 10 papildinājumiem un 6 dzēšanām
  1. 6 2
      main.cpp
  2. 4 4
      src/WallpaperEngine/Assets/CTexture.cpp

+ 6 - 2
main.cpp

@@ -227,14 +227,18 @@ int main (int argc, char* argv[])
         return 3;
     }
 
+    // parse the project.json file
+    auto project = WallpaperEngine::Core::CProject::fromFile ("project.json", containers);
+    // go to the right folder so the videos will play
+    if (project->getWallpaper ()->is <WallpaperEngine::Core::CVideo> () == true)
+        chdir (path.c_str ());
+
     // initialize custom context class
     WallpaperEngine::Render::CContext* context = new WallpaperEngine::Render::CContext (screens, window);
     // initialize mouse support
     context->setMouse (new CMouseInput (window));
     // set the default viewport
     context->setDefaultViewport ({0, 0, windowWidth, windowHeight});
-    // parse the project.json file
-    auto project = WallpaperEngine::Core::CProject::fromFile ("project.json", containers);
     // ensure the context knows what wallpaper to render
     context->setWallpaper (
         WallpaperEngine::Render::CWallpaper::fromWallpaper (project->getWallpaper (), containers, context)

+ 4 - 4
src/WallpaperEngine/Assets/CTexture.cpp

@@ -24,8 +24,8 @@ CTexture::CTexture (void* fileData)
     {
         // set the texture resolution
         this->m_resolution = {
-                this->m_header->textureWidth, this->m_header->textureHeight,
-                this->m_header->width, this->m_header->height
+            this->m_header->textureWidth, this->m_header->textureHeight,
+            this->m_header->width, this->m_header->height
         };
     }
 
@@ -212,12 +212,12 @@ const uint32_t CTexture::getTextureHeight () const
 
 const uint32_t CTexture::getRealWidth () const
 {
-    return this->getHeader ()->width;
+    return this->isAnimated () == true ? this->getHeader ()->gifWidth : this->getHeader ()->width;
 }
 
 const uint32_t CTexture::getRealHeight () const
 {
-    return this->getHeader ()->height;
+    return this->isAnimated () == true ? this->getHeader ()->gifHeight : this->getHeader ()->height;
 }
 
 const ITexture::TextureFormat CTexture::getFormat () const