Added ResourceListenerWrapper
This class wraps the call to Resource::AddResourceListener/RemoveResourceListener using RAII and help a lot with some of the dependencies. Thanks to this, the render queues now handle their resources listening properly. Former-commit-id: 7f215ffa4ccadcc4f44f777656970e92ce01087a
This commit is contained in:
@@ -9,16 +9,18 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Sequence.hpp>
|
||||
#include <limits>
|
||||
|
||||
struct NAZARA_API NzAnimationParams
|
||||
{
|
||||
// La frame de fin à charger
|
||||
unsigned int endFrame = static_cast<unsigned int>(-1);
|
||||
unsigned int endFrame = std::numeric_limits<unsigned int>::max();
|
||||
// La frame de début à charger
|
||||
unsigned int startFrame = 0;
|
||||
|
||||
@@ -28,7 +30,9 @@ struct NAZARA_API NzAnimationParams
|
||||
class NzAnimation;
|
||||
class NzSkeleton;
|
||||
|
||||
using NzAnimationConstListener = NzResourceListenerWrapper<const NzAnimation>;
|
||||
using NzAnimationConstRef = NzResourceRef<const NzAnimation>;
|
||||
using NzAnimationListener = NzResourceListenerWrapper<NzAnimation>;
|
||||
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
|
||||
using NzAnimationRef = NzResourceRef<NzAnimation>;
|
||||
|
||||
|
||||
@@ -10,12 +10,15 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
class NzBuffer;
|
||||
|
||||
using NzBufferConstListener = NzResourceListenerWrapper<const NzBuffer>;
|
||||
using NzBufferConstRef = NzResourceRef<const NzBuffer>;
|
||||
using NzBufferListener = NzResourceListenerWrapper<NzBuffer>;
|
||||
using NzBufferRef = NzResourceRef<NzBuffer>;
|
||||
|
||||
class NzAbstractBuffer;
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Utility/AbstractAtlas.hpp>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
@@ -25,7 +26,9 @@ class NzFontData;
|
||||
|
||||
struct NzFontGlyph;
|
||||
|
||||
using NzFontConstListener = NzResourceListenerWrapper<const NzFont>;
|
||||
using NzFontConstRef = NzResourceRef<const NzFont>;
|
||||
using NzFontListener = NzResourceListenerWrapper<NzFont>;
|
||||
using NzFontLoader = NzResourceLoader<NzFont, NzFontParams>;
|
||||
using NzFontRef = NzResourceRef<NzFont>;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
@@ -32,7 +33,9 @@ struct NAZARA_API NzImageParams
|
||||
|
||||
class NzImage;
|
||||
|
||||
using NzImageConstListener = NzResourceListenerWrapper<const NzImage>;
|
||||
using NzImageConstRef = NzResourceRef<const NzImage>;
|
||||
using NzImageListener = NzResourceListenerWrapper<NzImage>;
|
||||
using NzImageLoader = NzResourceLoader<NzImage, NzImageParams>;
|
||||
using NzImageRef = NzResourceRef<NzImage>;
|
||||
|
||||
|
||||
@@ -9,12 +9,15 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
|
||||
class NzIndexBuffer;
|
||||
|
||||
using NzIndexBufferConstListener = NzResourceListenerWrapper<const NzIndexBuffer>;
|
||||
using NzIndexBufferConstRef = NzResourceRef<const NzIndexBuffer>;
|
||||
using NzIndexBufferListener = NzResourceListenerWrapper<NzIndexBuffer>;
|
||||
using NzIndexBufferRef = NzResourceRef<NzIndexBuffer>;
|
||||
|
||||
class NAZARA_API NzIndexBuffer : public NzResource
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/Primitive.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
@@ -52,13 +52,15 @@ class NzPrimitiveList;
|
||||
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
|
||||
typedef NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning NzSkeletalMeshVertex;
|
||||
|
||||
using NzMeshConstListener = NzResourceListenerWrapper<const NzMesh>;
|
||||
using NzMeshConstRef = NzResourceRef<const NzMesh>;
|
||||
using NzMeshListener = NzResourceListenerWrapper<NzMesh>;
|
||||
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
|
||||
using NzMeshRef = NzResourceRef<NzMesh>;
|
||||
|
||||
struct NzMeshImpl;
|
||||
|
||||
class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
class NAZARA_API NzMesh : public NzResource
|
||||
{
|
||||
friend NzMeshLoader;
|
||||
|
||||
@@ -121,8 +123,6 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
void Transform(const NzMatrix4f& matrix);
|
||||
|
||||
private:
|
||||
void OnResourceReleased(const NzResource* resource, int index) override;
|
||||
|
||||
NzMeshImpl* m_impl = nullptr;
|
||||
|
||||
static NzMeshLoader::LoaderList s_loaders;
|
||||
|
||||
@@ -19,7 +19,7 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer, NzResourceLis
|
||||
{
|
||||
public:
|
||||
NzSimpleTextDrawer();
|
||||
virtual ~NzSimpleTextDrawer();
|
||||
virtual ~NzSimpleTextDrawer() = default;
|
||||
|
||||
const NzRectui& GetBounds() const;
|
||||
unsigned int GetCharacterSize() const;
|
||||
@@ -49,6 +49,7 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer, NzResourceLis
|
||||
mutable std::vector<Glyph> m_glyphs;
|
||||
NzColor m_color;
|
||||
NzFontRef m_font;
|
||||
NzFontListener m_fontListener; // Doit se situer après le FontRef (pour être libéré avant)
|
||||
mutable NzRectui m_bounds;
|
||||
NzString m_text;
|
||||
nzUInt32 m_style;
|
||||
|
||||
@@ -8,12 +8,16 @@
|
||||
#define NAZARA_SKELETALMESH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzSkeletalMesh;
|
||||
|
||||
using NzSkeletalMeshConstListener = NzResourceListenerWrapper<const NzSkeletalMesh>;
|
||||
using NzSkeletalMeshConstRef = NzResourceRef<const NzSkeletalMesh>;
|
||||
using NzSkeletalMeshListener = NzResourceListenerWrapper<NzSkeletalMesh>;
|
||||
using NzSkeletalMeshRef = NzResourceRef<NzSkeletalMesh>;
|
||||
|
||||
class NAZARA_API NzSkeletalMesh final : public NzSubMesh
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Utility/Joint.hpp>
|
||||
@@ -16,7 +17,9 @@
|
||||
|
||||
class NzSkeleton;
|
||||
|
||||
using NzSkeletonConstListener = NzResourceListenerWrapper<const NzSkeleton>;
|
||||
using NzSkeletonConstRef = NzResourceRef<const NzSkeleton>;
|
||||
using NzSkeletonListener = NzResourceListenerWrapper<NzSkeleton>;
|
||||
using NzSkeletonRef = NzResourceRef<NzSkeleton>;
|
||||
|
||||
struct NzSkeletonImpl;
|
||||
|
||||
@@ -9,11 +9,14 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzStaticMesh;
|
||||
|
||||
using NzStaticMeshConstListener = NzResourceListenerWrapper<const NzStaticMesh>;
|
||||
using NzStaticMeshConstRef = NzResourceRef<const NzStaticMesh>;
|
||||
using NzStaticMeshListener = NzResourceListenerWrapper<NzStaticMesh>;
|
||||
using NzStaticMeshRef = NzResourceRef<NzStaticMesh>;
|
||||
|
||||
class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
@@ -19,7 +20,9 @@
|
||||
class NzMesh;
|
||||
class NzSubMesh;
|
||||
|
||||
using NzSubMeshConstListener = NzResourceListenerWrapper<const NzSubMesh>;
|
||||
using NzSubMeshConstRef = NzResourceRef<const NzSubMesh>;
|
||||
using NzSubMeshListener = NzResourceListenerWrapper<NzSubMesh>;
|
||||
using NzSubMeshRef = NzResourceRef<NzSubMesh>;
|
||||
|
||||
class NAZARA_API NzSubMesh : public NzResource
|
||||
|
||||
@@ -9,13 +9,16 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
|
||||
class NzVertexBuffer;
|
||||
|
||||
using NzVertexBufferConstListener = NzResourceListenerWrapper<const NzVertexBuffer>;
|
||||
using NzVertexBufferConstRef = NzResourceRef<NzVertexBuffer>;
|
||||
using NzVertexBufferListener = NzResourceListenerWrapper<NzVertexBuffer>;
|
||||
using NzVertexBufferRef = NzResourceRef<NzVertexBuffer>;
|
||||
|
||||
class NAZARA_API NzVertexBuffer : public NzResource
|
||||
|
||||
@@ -9,12 +9,15 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
class NzVertexDeclaration;
|
||||
|
||||
using NzVertexDeclarationConstListener = NzResourceListenerWrapper<const NzVertexDeclaration>;
|
||||
using NzVertexDeclarationConstRef = NzResourceRef<const NzVertexDeclaration>;
|
||||
using NzVertexDeclarationListener = NzResourceListenerWrapper<NzVertexDeclaration>;
|
||||
using NzVertexDeclarationRef = NzResourceRef<NzVertexDeclaration>;
|
||||
|
||||
class NAZARA_API NzVertexDeclaration : public NzResource
|
||||
|
||||
Reference in New Issue
Block a user