mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 21:32:23 +08:00
~ moved camera initialization before the actual items initialization
+ added PKGV0007 to the list of supported packages (experimental) + added support for parsing properties of type bolean + added parsing of a missing particle initializer (turbulentvelocityrandom) + added back sound playinh which was left out when rewritting Signed-off-by: Alexis Maiquez Murcia <almamu@almamu.com>
This commit is contained in:
parent
fc8778ab64
commit
7d7c51a3bc
@ -37,6 +37,8 @@ add_executable(
|
|||||||
|
|
||||||
src/WallpaperEngine/Render/Objects/CImage.h
|
src/WallpaperEngine/Render/Objects/CImage.h
|
||||||
src/WallpaperEngine/Render/Objects/CImage.cpp
|
src/WallpaperEngine/Render/Objects/CImage.cpp
|
||||||
|
src/WallpaperEngine/Render/Objects/CSound.cpp
|
||||||
|
src/WallpaperEngine/Render/Objects/CSound.h
|
||||||
|
|
||||||
src/WallpaperEngine/FileSystem/FileSystem.cpp
|
src/WallpaperEngine/FileSystem/FileSystem.cpp
|
||||||
src/WallpaperEngine/FileSystem/FileSystem.h
|
src/WallpaperEngine/FileSystem/FileSystem.h
|
||||||
@ -61,6 +63,8 @@ add_executable(
|
|||||||
src/WallpaperEngine/Core/Projects/CProperty.cpp
|
src/WallpaperEngine/Core/Projects/CProperty.cpp
|
||||||
src/WallpaperEngine/Core/Projects/CPropertyColor.h
|
src/WallpaperEngine/Core/Projects/CPropertyColor.h
|
||||||
src/WallpaperEngine/Core/Projects/CPropertyColor.cpp
|
src/WallpaperEngine/Core/Projects/CPropertyColor.cpp
|
||||||
|
src/WallpaperEngine/Core/Projects/CPropertyBoolean.h
|
||||||
|
src/WallpaperEngine/Core/Projects/CPropertyBoolean.cpp
|
||||||
|
|
||||||
src/WallpaperEngine/Core/Scenes/CCamera.cpp
|
src/WallpaperEngine/Core/Scenes/CCamera.cpp
|
||||||
src/WallpaperEngine/Core/Scenes/CCamera.h
|
src/WallpaperEngine/Core/Scenes/CCamera.h
|
||||||
@ -97,12 +101,13 @@ add_executable(
|
|||||||
src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h
|
src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h
|
||||||
src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.cpp
|
src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.cpp
|
||||||
src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h
|
src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h
|
||||||
|
src/WallpaperEngine/Core/Objects/Particles/Initializers/CTurbulentVelocityRandom.cpp
|
||||||
|
src/WallpaperEngine/Core/Objects/Particles/Initializers/CTurbulentVelocityRandom.h
|
||||||
|
|
||||||
src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp
|
src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp
|
||||||
src/WallpaperEngine/Core/Objects/Images/CMaterial.h
|
src/WallpaperEngine/Core/Objects/Images/CMaterial.h
|
||||||
|
|
||||||
src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.cpp
|
src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.cpp
|
||||||
src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.h
|
src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.h)
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(wallengine ${X11_LIBRARIES} ${XRANDR_LIBRARIES} ${X11_Xxf86vm_LIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES} ${IRRLICHT_LIBRARY} ${LZ4_LIBRARY} ${SDL_LIBRARY} ${SDL_MIXER_LIBRARIES})
|
target_link_libraries(wallengine ${X11_LIBRARIES} ${XRANDR_LIBRARIES} ${X11_Xxf86vm_LIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES} ${IRRLICHT_LIBRARY} ${LZ4_LIBRARY} ${SDL_LIBRARY} ${SDL_MIXER_LIBRARIES})
|
@ -68,7 +68,16 @@ CObject* CObject::fromJSON (json data)
|
|||||||
// visibility is optional
|
// visibility is optional
|
||||||
if (visible_it != data.end ())
|
if (visible_it != data.end ())
|
||||||
{
|
{
|
||||||
visible = *visible_it;
|
if (visible_it->is_boolean () == false)
|
||||||
|
{
|
||||||
|
// TODO: SUPPORT CONFIGURATION VALUES ON ATTRIBUTES LIKE VISIBLE
|
||||||
|
// TODO: FOR NOW JUST DEFAULT TO FALSE
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
visible = *visible_it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
json::const_iterator image_it = data.find ("image");
|
json::const_iterator image_it = data.find ("image");
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.h"
|
#include "WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.h"
|
||||||
#include "WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h"
|
#include "WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h"
|
||||||
#include "WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h"
|
#include "WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h"
|
||||||
|
#include "WallpaperEngine/Core/Objects/Particles/Initializers/CTurbulentVelocityRandom.h"
|
||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Particles;
|
using namespace WallpaperEngine::Core::Objects::Particles;
|
||||||
|
|
||||||
@ -49,6 +50,10 @@ CInitializer* CInitializer::fromJSON (json data)
|
|||||||
{
|
{
|
||||||
return Initializers::CAngularVelocityRandom::fromJSON (data, id);
|
return Initializers::CAngularVelocityRandom::fromJSON (data, id);
|
||||||
}
|
}
|
||||||
|
else if (*name_it == "turbulentvelocityrandom")
|
||||||
|
{
|
||||||
|
return Initializers::CTurbulentVelocityRandom::fromJSON (data, id);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw std::runtime_error ("Particle's got an unknown initializer");
|
throw std::runtime_error ("Particle's got an unknown initializer");
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "CRotationRandom.h"
|
#include "CRotationRandom.h"
|
||||||
|
|
||||||
|
#include "WallpaperEngine/Core/Core.h"
|
||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||||
|
|
||||||
CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id)
|
CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id)
|
||||||
@ -7,35 +9,35 @@ CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id)
|
|||||||
json::const_iterator min_it = data.find ("min");
|
json::const_iterator min_it = data.find ("min");
|
||||||
json::const_iterator max_it = data.find ("max");
|
json::const_iterator max_it = data.find ("max");
|
||||||
|
|
||||||
irr::f64 min = 0.0f;
|
irr::core::vector3df min = irr::core::vector3df ();
|
||||||
irr::f64 max = 360.0f;
|
irr::core::vector3df max = irr::core::vector3df ();
|
||||||
|
|
||||||
if (min_it != data.end ())
|
if (min_it != data.end ())
|
||||||
{
|
{
|
||||||
min = *min_it;
|
min = WallpaperEngine::Core::ato3vf (*min_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_it != data.end ())
|
if (max_it != data.end ())
|
||||||
{
|
{
|
||||||
max = *max_it;
|
max = WallpaperEngine::Core::ato3vf (*max_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CRotationRandom (id, min, max);
|
return new CRotationRandom (id, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
CRotationRandom::CRotationRandom (irr::u32 id, irr::f64 min, irr::f64 max) :
|
CRotationRandom::CRotationRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max) :
|
||||||
CInitializer (id, "rotationrandom"),
|
CInitializer (id, "rotationrandom"),
|
||||||
m_min (min),
|
m_min (min),
|
||||||
m_max (max)
|
m_max (max)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
irr::f64 CRotationRandom::getMinimum ()
|
irr::core::vector3df CRotationRandom::getMinimum ()
|
||||||
{
|
{
|
||||||
return this->m_min;
|
return this->m_min;
|
||||||
}
|
}
|
||||||
|
|
||||||
irr::f64 CRotationRandom::getMaximum ()
|
irr::core::vector3df CRotationRandom::getMaximum ()
|
||||||
{
|
{
|
||||||
return this->m_max;
|
return this->m_max;
|
||||||
}
|
}
|
@ -10,16 +10,16 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
class CRotationRandom : CInitializer
|
class CRotationRandom : CInitializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
irr::f64 getMinimum ();
|
irr::core::vector3df getMinimum ();
|
||||||
irr::f64 getMaximum ();
|
irr::core::vector3df getMaximum ();
|
||||||
protected:
|
protected:
|
||||||
friend class CInitializer;
|
friend class CInitializer;
|
||||||
|
|
||||||
static CRotationRandom* fromJSON (json data, irr::u32 id);
|
static CRotationRandom* fromJSON (json data, irr::u32 id);
|
||||||
|
|
||||||
CRotationRandom (irr::u32 id, irr::f64 min, irr::f64 max);
|
CRotationRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max);
|
||||||
private:
|
private:
|
||||||
irr::f64 m_max;
|
irr::core::vector3df m_max;
|
||||||
irr::f64 m_min;
|
irr::core::vector3df m_min;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
#include "CTurbulentVelocityRandom.h"
|
||||||
|
|
||||||
|
#include "WallpaperEngine/Core/Core.h"
|
||||||
|
|
||||||
|
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||||
|
|
||||||
|
CTurbulentVelocityRandom* CTurbulentVelocityRandom::fromJSON (json data, irr::u32 id)
|
||||||
|
{
|
||||||
|
json::const_iterator phasemax_it = data.find ("phasemax");
|
||||||
|
json::const_iterator scale_it = data.find ("scale");
|
||||||
|
json::const_iterator speedmax_it = data.find ("speedmax");
|
||||||
|
json::const_iterator speedmin_it = data.find ("speedmin");
|
||||||
|
json::const_iterator timescale_it = data.find ("timescale");
|
||||||
|
|
||||||
|
if (phasemax_it == data.end ())
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("TurbulentVelocityRandom initializer must have a phasemax value");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scale_it == data.end ())
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("TurbulentVelocityRandom initializer must have a scale value");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (speedmax_it == data.end ())
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("TurbulentVelocityRandom initializer must have a maximum speed value");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (speedmin_it == data.end ())
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("TurbulentVelocityRandom initializer must have a minimum speed value");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timescale_it == data.end ())
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("TurbulentVelocityRandom initializer must have a timescale value");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CTurbulentVelocityRandom (
|
||||||
|
id,
|
||||||
|
*phasemax_it,
|
||||||
|
*scale_it,
|
||||||
|
*timescale_it,
|
||||||
|
*speedmin_it,
|
||||||
|
*speedmax_it
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CTurbulentVelocityRandom::CTurbulentVelocityRandom (irr::u32 id,
|
||||||
|
irr::f64 phasemax, irr::f64 scale, irr::f64 timescale, irr::u32 speedmin, irr::u32 speedmax) :
|
||||||
|
CInitializer (id, "turbulentvelocityrandom"),
|
||||||
|
m_phasemax (phasemax),
|
||||||
|
m_scale (scale),
|
||||||
|
m_timescale (timescale),
|
||||||
|
m_speedmin (speedmin),
|
||||||
|
m_speedmax (speedmax)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
irr::f64 CTurbulentVelocityRandom::getPhaseMax ()
|
||||||
|
{
|
||||||
|
return this->m_phasemax;
|
||||||
|
}
|
||||||
|
|
||||||
|
irr::f64 CTurbulentVelocityRandom::getScale ()
|
||||||
|
{
|
||||||
|
return this->m_scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
irr::f64 CTurbulentVelocityRandom::getTimeScale ()
|
||||||
|
{
|
||||||
|
return this->m_timescale;
|
||||||
|
}
|
||||||
|
|
||||||
|
irr::u32 CTurbulentVelocityRandom::getMinimumSpeed ()
|
||||||
|
{
|
||||||
|
return this->m_speedmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
irr::u32 CTurbulentVelocityRandom::getMaximumSpeed ()
|
||||||
|
{
|
||||||
|
return this->m_speedmax;
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "WallpaperEngine/Core/Objects/Particles/CInitializer.h"
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <irrlicht/irrlicht.h>
|
||||||
|
|
||||||
|
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||||
|
{
|
||||||
|
class CTurbulentVelocityRandom : CInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
irr::f64 getPhaseMax ();
|
||||||
|
irr::f64 getScale ();
|
||||||
|
irr::f64 getTimeScale ();
|
||||||
|
irr::u32 getMinimumSpeed ();
|
||||||
|
irr::u32 getMaximumSpeed ();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
friend class CInitializer;
|
||||||
|
|
||||||
|
static CTurbulentVelocityRandom* fromJSON (json data, irr::u32 id);
|
||||||
|
|
||||||
|
CTurbulentVelocityRandom (irr::u32 id,
|
||||||
|
irr::f64 phasemax, irr::f64 scale, irr::f64 timescale, irr::u32 speedmin, irr::u32 speedmax);
|
||||||
|
private:
|
||||||
|
irr::f64 m_phasemax;
|
||||||
|
irr::f64 m_scale;
|
||||||
|
irr::f64 m_timescale;
|
||||||
|
irr::u32 m_speedmin;
|
||||||
|
irr::u32 m_speedmax;
|
||||||
|
};
|
||||||
|
};
|
@ -1,5 +1,6 @@
|
|||||||
#include "CProperty.h"
|
#include "CProperty.h"
|
||||||
#include "CPropertyColor.h"
|
#include "CPropertyColor.h"
|
||||||
|
#include "CPropertyBoolean.h"
|
||||||
|
|
||||||
namespace WallpaperEngine::Core::Projects
|
namespace WallpaperEngine::Core::Projects
|
||||||
{
|
{
|
||||||
@ -24,6 +25,11 @@ namespace WallpaperEngine::Core::Projects
|
|||||||
return CPropertyColor::fromJSON (data, name);
|
return CPropertyColor::fromJSON (data, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*type == CPropertyBoolean::Type)
|
||||||
|
{
|
||||||
|
return CPropertyBoolean::fromJSON (data, name);
|
||||||
|
}
|
||||||
|
|
||||||
throw std::runtime_error ("Unexpected type for property");
|
throw std::runtime_error ("Unexpected type for property");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
src/WallpaperEngine/Core/Projects/CPropertyBoolean.cpp
Normal file
29
src/WallpaperEngine/Core/Projects/CPropertyBoolean.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "CPropertyBoolean.h"
|
||||||
|
#include "WallpaperEngine/Core/Core.h"
|
||||||
|
|
||||||
|
using namespace WallpaperEngine::Core::Projects;
|
||||||
|
|
||||||
|
CPropertyBoolean* CPropertyBoolean::fromJSON (json data, const std::string& name)
|
||||||
|
{
|
||||||
|
json::const_iterator value = data.find ("value");
|
||||||
|
json::const_iterator text = data.find ("type");
|
||||||
|
|
||||||
|
return new CPropertyBoolean (
|
||||||
|
*value,
|
||||||
|
name,
|
||||||
|
*text
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CPropertyBoolean::getValue ()
|
||||||
|
{
|
||||||
|
return &this->m_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPropertyBoolean::CPropertyBoolean (bool value, const std::string& name, const std::string& text) :
|
||||||
|
CProperty (name, Type, text),
|
||||||
|
m_value (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string CPropertyBoolean::Type = "bool";
|
25
src/WallpaperEngine/Core/Projects/CPropertyBoolean.h
Normal file
25
src/WallpaperEngine/Core/Projects/CPropertyBoolean.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <irrlicht/irrlicht.h>
|
||||||
|
|
||||||
|
#include "CProperty.h"
|
||||||
|
|
||||||
|
namespace WallpaperEngine::Core::Projects
|
||||||
|
{
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
class CPropertyBoolean : public CProperty
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static CPropertyBoolean* fromJSON (json data, const std::string& name);
|
||||||
|
|
||||||
|
bool getValue ();
|
||||||
|
|
||||||
|
static const std::string Type;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CPropertyBoolean (bool value, const std::string& name, const std::string& text);
|
||||||
|
|
||||||
|
bool m_value;
|
||||||
|
};
|
||||||
|
};
|
@ -104,7 +104,7 @@ namespace WallpaperEngine::Irrlicht
|
|||||||
{
|
{
|
||||||
char* headerVersion = this->readSizedString ();
|
char* headerVersion = this->readSizedString ();
|
||||||
|
|
||||||
if (strcmp ("PKGV0002", headerVersion) != 0 && strcmp ("PKGV0001", headerVersion) != 0)
|
if (strcmp ("PKGV0007", headerVersion) != 0 && strcmp ("PKGV0002", headerVersion) != 0 && strcmp ("PKGV0001", headerVersion) != 0)
|
||||||
{
|
{
|
||||||
delete [] headerVersion;
|
delete [] headerVersion;
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#include "WallpaperEngine/Core/Objects/CImage.h"
|
#include "WallpaperEngine/Core/Objects/CImage.h"
|
||||||
|
#include "WallpaperEngine/Core/Objects/CSound.h"
|
||||||
|
#include "WallpaperEngine/Core/Objects/CParticle.h"
|
||||||
|
|
||||||
#include "WallpaperEngine/Render/Objects/CImage.h"
|
#include "WallpaperEngine/Render/Objects/CImage.h"
|
||||||
|
#include "WallpaperEngine/Render/Objects/CSound.h"
|
||||||
#include "CScene.h"
|
#include "CScene.h"
|
||||||
|
|
||||||
using namespace WallpaperEngine;
|
using namespace WallpaperEngine;
|
||||||
@ -14,6 +18,12 @@ CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) :
|
|||||||
m_scene (project->getScene ()),
|
m_scene (project->getScene ()),
|
||||||
m_context (context)
|
m_context (context)
|
||||||
{
|
{
|
||||||
|
this->m_camera = new CCamera (this, this->m_project->getScene ()->getCamera ());
|
||||||
|
this->m_camera->setOrthogonalProjection (
|
||||||
|
this->m_scene->getOrthogonalProjection ()->getWidth (),
|
||||||
|
this->m_scene->getOrthogonalProjection ()->getHeight ()
|
||||||
|
);
|
||||||
|
|
||||||
std::vector<Core::CObject*>::const_iterator cur = this->m_scene->getObjects ()->begin ();
|
std::vector<Core::CObject*>::const_iterator cur = this->m_scene->getObjects ()->begin ();
|
||||||
std::vector<Core::CObject*>::const_iterator end = this->m_scene->getObjects ()->end ();
|
std::vector<Core::CObject*>::const_iterator end = this->m_scene->getObjects ()->end ();
|
||||||
|
|
||||||
@ -28,17 +38,23 @@ CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) :
|
|||||||
{
|
{
|
||||||
new Objects::CImage (this, (*cur)->As <Core::Objects::CImage> ());
|
new Objects::CImage (this, (*cur)->As <Core::Objects::CImage> ());
|
||||||
}
|
}
|
||||||
|
else if ((*cur)->Is <Core::Objects::CSound> () == true)
|
||||||
|
{
|
||||||
|
new Objects::CSound (this, (*cur)->As <Core::Objects::CSound> ());
|
||||||
|
}
|
||||||
|
else if ((*cur)->Is <Core::Objects::CParticle> () == true)
|
||||||
|
{
|
||||||
|
this->getContext ()->getDevice ()->getLogger ()->log ("Particles disabled, not supported yet", irr::ELL_ERROR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("unsupported object type found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_nextId = ++highestId;
|
this->m_nextId = ++highestId;
|
||||||
this->setAutomaticCulling (irr::scene::EAC_OFF);
|
this->setAutomaticCulling (irr::scene::EAC_OFF);
|
||||||
this->m_boundingBox = irr::core::aabbox3d<irr::f32>(0, 0, 0, 0, 0, 0);
|
this->m_boundingBox = irr::core::aabbox3d<irr::f32>(0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
this->m_camera = new CCamera (this, this->m_project->getScene ()->getCamera ());
|
|
||||||
this->m_camera->setOrthogonalProjection (
|
|
||||||
this->m_scene->getOrthogonalProjection ()->getWidth (),
|
|
||||||
this->m_scene->getOrthogonalProjection ()->getHeight ()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CScene::~CScene ()
|
CScene::~CScene ()
|
||||||
|
69
src/WallpaperEngine/Render/Objects/CSound.cpp
Normal file
69
src/WallpaperEngine/Render/Objects/CSound.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include "CSound.h"
|
||||||
|
|
||||||
|
using namespace WallpaperEngine;
|
||||||
|
using namespace WallpaperEngine::Render::Objects;
|
||||||
|
|
||||||
|
CSound::CSound (CScene* scene, Core::Objects::CSound* sound) :
|
||||||
|
Render::CObject (scene, Type, sound),
|
||||||
|
m_sound (sound)
|
||||||
|
{
|
||||||
|
this->m_boundingBox = irr::core::aabbox3d<irr::f32>(0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
this->play ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSound::play ()
|
||||||
|
{
|
||||||
|
std::vector<std::string>* sounds = this->m_sound->getSounds ();
|
||||||
|
std::vector<std::string>::const_iterator cur = sounds->begin ();
|
||||||
|
std::vector<std::string>::const_iterator end = sounds->end ();
|
||||||
|
|
||||||
|
for (; cur != end; cur ++)
|
||||||
|
{
|
||||||
|
SDL_RWops* rwops = nullptr;
|
||||||
|
Mix_Music* music = nullptr;
|
||||||
|
|
||||||
|
// open the sound file and read it fully
|
||||||
|
irr::io::IReadFile* readfile = this->getScene ()->getContext ()->getDevice ()->getFileSystem ()->createAndOpenFile ((*cur).c_str ());
|
||||||
|
long filesize = readfile->getSize ();
|
||||||
|
char* buffer = new char [filesize];
|
||||||
|
|
||||||
|
// TODO: IMPLEMENT A MAXIMUM FILESIZE TO PREVENT CRAZY ALLOCATIONS
|
||||||
|
|
||||||
|
readfile->read (buffer, filesize);
|
||||||
|
|
||||||
|
rwops = SDL_RWFromConstMem (buffer, filesize);
|
||||||
|
music = Mix_LoadMUS_RW (rwops);
|
||||||
|
|
||||||
|
// free the file reader
|
||||||
|
readfile->drop ();
|
||||||
|
|
||||||
|
if (music == nullptr)
|
||||||
|
{
|
||||||
|
this->getScene ()->getContext ()->getDevice ()->getLogger ()->log ("Cannot load audio", Mix_GetError (), irr::ELL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_bufferReader.push_back (rwops);
|
||||||
|
this->m_mixSdl.push_back (music);
|
||||||
|
this->m_soundBuffer.push_back (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// after all the sounds are loaded, play them all
|
||||||
|
std::vector<Mix_Music*>::const_iterator mixcur = this->m_mixSdl.begin ();
|
||||||
|
std::vector<Mix_Music*>::const_iterator mixend = this->m_mixSdl.end ();
|
||||||
|
|
||||||
|
for (; mixcur != mixend; mixcur ++)
|
||||||
|
{
|
||||||
|
if (Mix_PlayMusic ((*mixcur), -1) == -1)
|
||||||
|
{
|
||||||
|
this->getScene ()->getContext ()->getDevice ()->getLogger ()->log ("Cannot play audio", Mix_GetError (), irr::ELL_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const irr::core::aabbox3d<irr::f32>& CSound::getBoundingBox () const
|
||||||
|
{
|
||||||
|
return this->m_boundingBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string CSound::Type = "sound";
|
35
src/WallpaperEngine/Render/Objects/CSound.h
Normal file
35
src/WallpaperEngine/Render/Objects/CSound.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL_mixer.h>
|
||||||
|
|
||||||
|
#include "WallpaperEngine/Core/Objects/CSound.h"
|
||||||
|
|
||||||
|
#include "WallpaperEngine/Render/CObject.h"
|
||||||
|
#include "WallpaperEngine/Render/CScene.h"
|
||||||
|
|
||||||
|
using namespace WallpaperEngine;
|
||||||
|
|
||||||
|
namespace WallpaperEngine::Render::Objects
|
||||||
|
{
|
||||||
|
class CSound : public CObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSound (CScene* scene, Core::Objects::CSound* sound);
|
||||||
|
|
||||||
|
void render () override {};
|
||||||
|
const irr::core::aabbox3d<irr::f32>& getBoundingBox () const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static const std::string Type;
|
||||||
|
|
||||||
|
void play ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Core::Objects::CSound* m_sound;
|
||||||
|
irr::core::aabbox3d<irr::f32> m_boundingBox;
|
||||||
|
|
||||||
|
std::vector <Mix_Music*> m_mixSdl;
|
||||||
|
std::vector <SDL_RWops*> m_bufferReader;
|
||||||
|
std::vector <void*> m_soundBuffer;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user