convert all instances of copy+pasted type-system code to use the new macros
This commit is contained in:
parent
2ae39ff14f
commit
c9d9152e45
|
@ -2,6 +2,7 @@
|
|||
#define __EFFECTS_DIMEFFECT_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
#include "effect.h"
|
||||
#include "../framework/graphics/color.h"
|
||||
|
||||
|
@ -10,12 +11,7 @@ class RenderContext;
|
|||
class DimEffect : public Effect
|
||||
{
|
||||
public:
|
||||
static EFFECT_TYPE GetType()
|
||||
{
|
||||
static EFFECT_TYPE typeName = "DimEffect";
|
||||
return typeName;
|
||||
}
|
||||
EFFECT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(EFFECT_TYPE, "DimEffect");
|
||||
|
||||
DimEffect();
|
||||
virtual ~DimEffect();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __EFFECTS_EFFECT_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
|
||||
class RenderContext;
|
||||
|
||||
|
@ -10,6 +11,8 @@ typedef const char* EFFECT_TYPE;
|
|||
class Effect
|
||||
{
|
||||
public:
|
||||
TYPE_BASE(EFFECT_TYPE);
|
||||
|
||||
Effect();
|
||||
virtual ~Effect();
|
||||
|
||||
|
@ -28,13 +31,6 @@ public:
|
|||
BOOL IsActive() const { return m_isActive; }
|
||||
void MarkInactive();
|
||||
|
||||
virtual EFFECT_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(EFFECT_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
|
||||
private:
|
||||
BOOL m_isActive;
|
||||
};
|
||||
|
@ -53,34 +49,5 @@ inline void Effect::MarkInactive()
|
|||
m_isActive = FALSE;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline BOOL Effect::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL Effect::Is(EFFECT_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* Effect::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* Effect::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __EFFECTS_FADEEFFECT_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
#include "effect.h"
|
||||
#include "../framework/graphics/color.h"
|
||||
|
||||
|
@ -10,12 +11,7 @@ class RenderContext;
|
|||
class FadeEffect : public Effect
|
||||
{
|
||||
public:
|
||||
static EFFECT_TYPE GetType()
|
||||
{
|
||||
static EFFECT_TYPE typeName = "FadeEffect";
|
||||
return typeName;
|
||||
}
|
||||
EFFECT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(EFFECT_TYPE, "FadeEffect");
|
||||
|
||||
FadeEffect();
|
||||
virtual ~FadeEffect();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __EFFECTS_FLASHEFFECT_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
#include "effect.h"
|
||||
#include "../framework/graphics/color.h"
|
||||
|
||||
|
@ -10,12 +11,7 @@ class RenderContext;
|
|||
class FlashEffect : public Effect
|
||||
{
|
||||
public:
|
||||
static EFFECT_TYPE GetType()
|
||||
{
|
||||
static EFFECT_TYPE typeName = "FlashEffect";
|
||||
return typeName;
|
||||
}
|
||||
EFFECT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(EFFECT_TYPE, "FlashEffect");
|
||||
|
||||
FlashEffect();
|
||||
virtual ~FlashEffect();
|
||||
|
|
|
@ -2,21 +2,17 @@
|
|||
#define __ENTITIES_COMPONENT_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
|
||||
typedef const char* COMPONENT_TYPE;
|
||||
|
||||
class Component
|
||||
{
|
||||
public:
|
||||
TYPE_BASE(COMPONENT_TYPE);
|
||||
|
||||
virtual ~Component();
|
||||
virtual void Reset();
|
||||
|
||||
virtual COMPONENT_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(COMPONENT_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
};
|
||||
|
||||
inline Component::~Component()
|
||||
|
@ -27,34 +23,5 @@ inline void Component::Reset()
|
|||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline BOOL Component::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL Component::Is(COMPONENT_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* Component::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* Component::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,16 +3,12 @@
|
|||
|
||||
#include "../component.h"
|
||||
#include "../entitypreset.h"
|
||||
#include "../../framework/util/typesystem.h"
|
||||
|
||||
class EntityPresetComponent : public Component
|
||||
{
|
||||
public:
|
||||
static COMPONENT_TYPE GetType()
|
||||
{
|
||||
static COMPONENT_TYPE typeName = "EntityPresetComponent";
|
||||
return typeName;
|
||||
}
|
||||
COMPONENT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(COMPONENT_TYPE, "EntityPresetComponent");
|
||||
|
||||
EntityPresetComponent();
|
||||
void Reset();
|
||||
|
|
|
@ -2,16 +2,12 @@
|
|||
#define __ENTITIES_COMPONENTS_INACTIVECOMPONENT_H_INCLUDED__
|
||||
|
||||
#include "../component.h"
|
||||
#include "../../framework/util/typesystem.h"
|
||||
|
||||
class InactiveComponent : public Component
|
||||
{
|
||||
public:
|
||||
static COMPONENT_TYPE GetType()
|
||||
{
|
||||
static COMPONENT_TYPE typeName = "InactiveComponent";
|
||||
return typeName;
|
||||
}
|
||||
COMPONENT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(COMPONENT_TYPE, "InactiveComponent");
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __ENTITIES_COMPONENTSYSTEM_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
#include "../events/eventlistenerex.h"
|
||||
|
||||
class EntityManager;
|
||||
|
@ -14,6 +15,8 @@ typedef const char* COMPONENTSYSTEM_TYPE;
|
|||
class ComponentSystem : public EventListenerEx
|
||||
{
|
||||
public:
|
||||
TYPE_BASE(COMPONENTSYSTEM_TYPE);
|
||||
|
||||
virtual ~ComponentSystem();
|
||||
|
||||
virtual void OnLostContext() {}
|
||||
|
@ -24,13 +27,6 @@ public:
|
|||
|
||||
virtual BOOL Handle(const Event *event);
|
||||
|
||||
virtual COMPONENTSYSTEM_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(COMPONENTSYSTEM_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
|
||||
protected:
|
||||
ComponentSystem(EntityManager *entityManager, EventManager *eventManager);
|
||||
|
||||
|
@ -55,34 +51,5 @@ inline BOOL ComponentSystem::Handle(const Event *event)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline BOOL ComponentSystem::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL ComponentSystem::Is(COMPONENTSYSTEM_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* ComponentSystem::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* ComponentSystem::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __ENTITIES_ENTITYPRESET_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
#include "entitypresetargs.h"
|
||||
|
||||
typedef const char* ENTITYPRESET_TYPE;
|
||||
|
@ -12,16 +13,11 @@ class EntityManager;
|
|||
class EntityPreset
|
||||
{
|
||||
public:
|
||||
TYPE_BASE(ENTITYPRESET_TYPE);
|
||||
|
||||
EntityPreset(EntityManager *entityManager);
|
||||
virtual ~EntityPreset();
|
||||
|
||||
virtual ENTITYPRESET_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(ENTITYPRESET_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
|
||||
virtual Entity* Create(EntityPresetArgs *args = NULL) = 0;
|
||||
|
||||
protected:
|
||||
|
@ -40,33 +36,4 @@ inline EntityPreset::~EntityPreset()
|
|||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline BOOL EntityPreset::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL EntityPreset::Is(ENTITYPRESET_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* EntityPreset::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* EntityPreset::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,46 +2,13 @@
|
|||
#define __ENTITIES_ENTITYPRESETARGS_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
|
||||
typedef const char* ENTITYPRESETARGS_TYPE;
|
||||
|
||||
struct EntityPresetArgs
|
||||
{
|
||||
virtual ENTITYPRESETARGS_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(ENTITYPRESETARGS_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
TYPE_BASE(ENTITYPRESETARGS_TYPE);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline BOOL EntityPresetArgs::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL EntityPresetArgs::Is(ENTITYPRESETARGS_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* EntityPresetArgs::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* EntityPresetArgs::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,21 +2,17 @@
|
|||
#define __ENTITIES_GLOBALCOMPONENT_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
|
||||
typedef const char* GLOBAL_COMPONENT_TYPE;
|
||||
|
||||
class GlobalComponent
|
||||
{
|
||||
public:
|
||||
TYPE_BASE(GLOBAL_COMPONENT_TYPE);
|
||||
|
||||
virtual ~GlobalComponent();
|
||||
virtual void Reset();
|
||||
|
||||
virtual GLOBAL_COMPONENT_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(GLOBAL_COMPONENT_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
};
|
||||
|
||||
inline GlobalComponent::~GlobalComponent()
|
||||
|
@ -27,34 +23,5 @@ inline void GlobalComponent::Reset()
|
|||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline BOOL GlobalComponent::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL GlobalComponent::Is(GLOBAL_COMPONENT_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* GlobalComponent::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* GlobalComponent::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __EVENTS_EVENT_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
|
||||
typedef const char* EVENT_TYPE;
|
||||
|
||||
|
@ -9,46 +10,13 @@ const EVENT_TYPE EVENT_TYPE_WILDCARD = "EventWildcard";
|
|||
|
||||
struct Event
|
||||
{
|
||||
TYPE_BASE(EVENT_TYPE);
|
||||
|
||||
virtual ~Event();
|
||||
virtual EVENT_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(EVENT_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
};
|
||||
|
||||
inline Event::~Event()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline BOOL Event::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL Event::Is(EVENT_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* Event::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* Event::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <stl/string.h>
|
||||
#include "../../support/animationsequence.h"
|
||||
#include "../../content/content.h"
|
||||
#include "../../util/typesystem.h"
|
||||
|
||||
class Keyframe;
|
||||
class KeyframeMeshFile;
|
||||
|
@ -19,12 +20,7 @@ class VertexBuffer;
|
|||
class KeyframeMesh : public Content
|
||||
{
|
||||
public:
|
||||
static CONTENT_TYPE GetType()
|
||||
{
|
||||
static CONTENT_TYPE typeName = "KeyframeMesh";
|
||||
return typeName;
|
||||
}
|
||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(CONTENT_TYPE, "KeyframeMesh");
|
||||
|
||||
/**
|
||||
* Creates a keyframe mesh object.
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../../common.h"
|
||||
#include "../../support/animationsequence.h"
|
||||
#include "../../content/content.h"
|
||||
#include "../../util/typesystem.h"
|
||||
#include <stl/string.h>
|
||||
|
||||
class SkeletalMeshFile;
|
||||
|
@ -18,12 +19,7 @@ class SkeletalMesh : public Content
|
|||
friend class SkeletalMeshFile;
|
||||
|
||||
public:
|
||||
static CONTENT_TYPE GetType()
|
||||
{
|
||||
static CONTENT_TYPE typeName = "SkeletalMesh";
|
||||
return typeName;
|
||||
}
|
||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(CONTENT_TYPE, "SkeletalMesh");
|
||||
|
||||
virtual ~SkeletalMesh();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../../common.h"
|
||||
#include "../../content/content.h"
|
||||
#include "../../util/typesystem.h"
|
||||
|
||||
class ContentManager;
|
||||
class StaticMeshFile;
|
||||
|
@ -14,12 +15,7 @@ class StaticMeshSubset;
|
|||
class StaticMesh : public Content
|
||||
{
|
||||
public:
|
||||
static CONTENT_TYPE GetType()
|
||||
{
|
||||
static CONTENT_TYPE typeName = "StaticMesh";
|
||||
return typeName;
|
||||
}
|
||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(CONTENT_TYPE, "StaticMesh");
|
||||
|
||||
/**
|
||||
* Creates a static mesh object.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __FRAMEWORK_CONTENT_CONTENT_H_INCLUDED__
|
||||
|
||||
#include "../common.h"
|
||||
#include "../util/typesystem.h"
|
||||
|
||||
class ContentLoaderBase;
|
||||
|
||||
|
@ -16,6 +17,8 @@ class Content
|
|||
friend class ContentLoaderBase;
|
||||
|
||||
public:
|
||||
TYPE_BASE(CONTENT_TYPE);
|
||||
|
||||
Content();
|
||||
virtual ~Content();
|
||||
|
||||
|
@ -38,37 +41,6 @@ public:
|
|||
* @return the number of references currently being held for this content
|
||||
*/
|
||||
uint32_t GetNumReferences() const { return m_referenceCount; }
|
||||
|
||||
/**
|
||||
* @return the type of content being held in this object
|
||||
*/
|
||||
virtual CONTENT_TYPE GetTypeOf() const = 0;
|
||||
|
||||
/**
|
||||
* @param <T> the type of content to check
|
||||
* @return TRUE if this content object is of type T
|
||||
*/
|
||||
template<class T> BOOL Is() const;
|
||||
|
||||
/**
|
||||
* @param type the content type to check
|
||||
* @return TRUE if this content object is the same as the type specified
|
||||
*/
|
||||
BOOL Is(CONTENT_TYPE type) const;
|
||||
|
||||
/**
|
||||
* @param <T> the type of content to attempt to cast to
|
||||
* @return this content object casted to type T if this content object
|
||||
* is of type T, or NULL if the types don't match
|
||||
*/
|
||||
template<class T> T* As();
|
||||
|
||||
/**
|
||||
* @param <T> the type of content to attempt to cast to
|
||||
* @return this content object casted to type T if this content object
|
||||
* is of type T, or NULL if the types don't match
|
||||
*/
|
||||
template<class T> const T* As() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -86,34 +58,5 @@ private:
|
|||
uint32_t m_referenceCount;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline BOOL Content::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL Content::Is(CONTENT_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* Content::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* Content::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../common.h"
|
||||
#include "../content/content.h"
|
||||
#include "../util/typesystem.h"
|
||||
|
||||
#include "color.h"
|
||||
#include "imageformats.h"
|
||||
|
@ -15,12 +16,7 @@ class File;
|
|||
class Image : public Content
|
||||
{
|
||||
public:
|
||||
static CONTENT_TYPE GetType()
|
||||
{
|
||||
static CONTENT_TYPE typeName = "Image";
|
||||
return typeName;
|
||||
}
|
||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(CONTENT_TYPE, "Image");
|
||||
|
||||
Image();
|
||||
virtual ~Image() { Release(); }
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../common.h"
|
||||
#include "../content/content.h"
|
||||
#include "../util/typesystem.h"
|
||||
|
||||
class Texture;
|
||||
class TextureAtlas;
|
||||
|
@ -18,12 +19,7 @@ const uint8_t HIGH_GLYPH = 127;
|
|||
class SpriteFont : public Content
|
||||
{
|
||||
public:
|
||||
static CONTENT_TYPE GetType()
|
||||
{
|
||||
static CONTENT_TYPE typeName = "SpriteFont";
|
||||
return typeName;
|
||||
}
|
||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(CONTENT_TYPE, "SpriteFont");
|
||||
|
||||
/**
|
||||
* Creates an uninitialized sprite font object.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../common.h"
|
||||
#include "../content/content.h"
|
||||
#include "../util/typesystem.h"
|
||||
#include "textureformats.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
@ -14,12 +15,7 @@ class Image;
|
|||
class Texture : public Content
|
||||
{
|
||||
public:
|
||||
static CONTENT_TYPE GetType()
|
||||
{
|
||||
static CONTENT_TYPE typeName = "Texture";
|
||||
return typeName;
|
||||
}
|
||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(CONTENT_TYPE, "Texture");
|
||||
|
||||
Texture();
|
||||
virtual ~Texture();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __GAME_DEBUGINFOPROCESS_H_INCLUDED__
|
||||
|
||||
#include "../processes/gameprocess.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
|
||||
class GameState;
|
||||
class ProcessManager;
|
||||
|
@ -10,12 +11,7 @@ class RenderContext;
|
|||
class DebugInfoProcess : public GameProcess
|
||||
{
|
||||
public:
|
||||
static GAMEPROCESS_TYPE GetType()
|
||||
{
|
||||
static GAMEPROCESS_TYPE typeName = "DebugInfoProcess";
|
||||
return typeName;
|
||||
}
|
||||
GAMEPROCESS_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(GAMEPROCESS_TYPE, "DebugInfoProcess");
|
||||
|
||||
DebugInfoProcess(GameState *gameState, ProcessManager *processManager);
|
||||
virtual ~DebugInfoProcess();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __GAME_TESTINGSTATE_H_INCLUDED__
|
||||
|
||||
#include "../states/gamestate.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
|
||||
class FreeCamera;
|
||||
class GameApp;
|
||||
|
@ -12,12 +13,7 @@ class StateManager;
|
|||
class TestingState : public GameState
|
||||
{
|
||||
public:
|
||||
static GAMESTATE_TYPE GetType()
|
||||
{
|
||||
static GAMESTATE_TYPE typeName = "TestingState";
|
||||
return typeName;
|
||||
}
|
||||
GAMESTATE_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(GAMESTATE_TYPE, "TestingState");
|
||||
|
||||
TestingState(GameApp *gameApp, StateManager *stateManager);
|
||||
virtual ~TestingState();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __PROCESSES_GAMEPROCESS_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
|
||||
#include "../states/gamestate.h"
|
||||
#include "../events/eventlistenerex.h"
|
||||
|
@ -16,6 +17,8 @@ struct Event;
|
|||
class GameProcess : public EventListenerEx
|
||||
{
|
||||
public:
|
||||
TYPE_BASE(GAMEPROCESS_TYPE);
|
||||
|
||||
GameProcess(GameState *gameState, ProcessManager *processManager);
|
||||
virtual ~GameProcess();
|
||||
|
||||
|
@ -36,13 +39,6 @@ public:
|
|||
|
||||
virtual BOOL Handle(const Event *event);
|
||||
|
||||
virtual GAMEPROCESS_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(GAMEPROCESS_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
|
||||
GameApp* GetGameApp() const { return m_gameState->GetGameApp(); }
|
||||
|
||||
BOOL IsFinished() const { return m_finished; }
|
||||
|
@ -60,34 +56,5 @@ private:
|
|||
BOOL m_finished;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline BOOL GameProcess::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL GameProcess::Is(GAMEPROCESS_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* GameProcess::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* GameProcess::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/debug.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
#include "gameprocess.h"
|
||||
|
||||
class GwenGameProcessUIController;
|
||||
|
@ -14,12 +15,7 @@ struct Event;
|
|||
class GwenGameProcess : public GameProcess
|
||||
{
|
||||
public:
|
||||
static GAMEPROCESS_TYPE GetType()
|
||||
{
|
||||
static GAMEPROCESS_TYPE typeName = "GwenGameProcess";
|
||||
return typeName;
|
||||
}
|
||||
GAMEPROCESS_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(GAMEPROCESS_TYPE, "GwenGameProcess");
|
||||
|
||||
GwenGameProcess(GameState *gameState, ProcessManager *processManager);
|
||||
virtual ~GwenGameProcess();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __STATES_GAMESTATE_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
#include "../events/eventlistenerex.h"
|
||||
|
||||
typedef const char* GAMESTATE_TYPE;
|
||||
|
@ -16,6 +17,8 @@ struct Event;
|
|||
class GameState : public EventListenerEx
|
||||
{
|
||||
public:
|
||||
TYPE_BASE(GAMESTATE_TYPE);
|
||||
|
||||
GameState(GameApp *gameApp, StateManager *stateManager);
|
||||
virtual ~GameState();
|
||||
|
||||
|
@ -36,13 +39,6 @@ public:
|
|||
|
||||
virtual BOOL Handle(const Event *event);
|
||||
|
||||
virtual GAMESTATE_TYPE GetTypeOf() const = 0;
|
||||
|
||||
template<class T> BOOL Is() const;
|
||||
BOOL Is(GAMESTATE_TYPE type) const;
|
||||
template<class T> T* As();
|
||||
template<class T> const T* As() const;
|
||||
|
||||
GameApp* GetGameApp() const { return m_gameApp; }
|
||||
ProcessManager* GetProcessManager() const { return m_processManager; }
|
||||
EffectManager* GetEffectManager() const { return m_effectManager; }
|
||||
|
@ -69,34 +65,5 @@ private:
|
|||
BOOL m_hasReturnValue;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline BOOL GameState::Is() const
|
||||
{
|
||||
return (GetTypeOf() == T::GetType());
|
||||
}
|
||||
|
||||
inline BOOL GameState::Is(GAMESTATE_TYPE type) const
|
||||
{
|
||||
return (GetTypeOf() == type);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* GameState::As()
|
||||
{
|
||||
if (Is<T>())
|
||||
return (T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* GameState::As() const
|
||||
{
|
||||
if (Is<T>())
|
||||
return (const T*)this;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __STATES_GWENGAMESTATE_H_INCLUDED__
|
||||
|
||||
#include "../framework/common.h"
|
||||
#include "../framework/util/typesystem.h"
|
||||
#include "../framework/debug.h"
|
||||
#include "gamestate.h"
|
||||
|
||||
|
@ -14,12 +15,7 @@ struct Event;
|
|||
class GwenGameState : public GameState
|
||||
{
|
||||
public:
|
||||
static GAMESTATE_TYPE GetType()
|
||||
{
|
||||
static GAMESTATE_TYPE typeName = "GwenGameState";
|
||||
return typeName;
|
||||
}
|
||||
GAMESTATE_TYPE GetTypeOf() const { return GetType(); }
|
||||
TYPE_DEFINE(GAMESTATE_TYPE, "GwenGameState");
|
||||
|
||||
GwenGameState(GameApp *gameApp, StateManager *stateManager);
|
||||
virtual ~GwenGameState();
|
||||
|
|
Reference in a new issue