Refactoring : project files
This commit is contained in:
parent
65ba8e96d2
commit
42ac308278
234
core/e2devent.h
234
core/e2devent.h
|
|
@ -5,135 +5,135 @@ namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// 按键消息
|
// 按键消息
|
||||||
class KeyEvent
|
class KeyEvent
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 按键消息类型
|
|
||||||
enum class Type : int
|
|
||||||
{
|
{
|
||||||
Down = 0x0100, // 按下
|
public:
|
||||||
Up // 抬起
|
// 按键消息类型
|
||||||
|
enum class Type : int
|
||||||
|
{
|
||||||
|
Down = 0x0100, // 按下
|
||||||
|
Up // 抬起
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit KeyEvent(
|
||||||
|
HWND hWnd,
|
||||||
|
UINT message,
|
||||||
|
WPARAM w_param,
|
||||||
|
LPARAM l_param
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取按键键值
|
||||||
|
KeyCode GetCode() const;
|
||||||
|
|
||||||
|
// 获取按键次数
|
||||||
|
int GetCount() const;
|
||||||
|
|
||||||
|
// 获取事件类型
|
||||||
|
KeyEvent::Type GetType() const;
|
||||||
|
|
||||||
|
// VK 键值转换
|
||||||
|
static KeyCode ToKeyCode(
|
||||||
|
WPARAM w_param
|
||||||
|
);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int count_;
|
||||||
|
KeyCode code_;
|
||||||
|
KeyEvent::Type type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
explicit KeyEvent(
|
|
||||||
HWND hWnd,
|
|
||||||
UINT message,
|
|
||||||
WPARAM w_param,
|
|
||||||
LPARAM l_param
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取按键键值
|
// 鼠标消息
|
||||||
KeyCode GetCode() const;
|
class MouseEvent
|
||||||
|
|
||||||
// 获取按键次数
|
|
||||||
int GetCount() const;
|
|
||||||
|
|
||||||
// 获取事件类型
|
|
||||||
KeyEvent::Type GetType() const;
|
|
||||||
|
|
||||||
// VK 键值转换
|
|
||||||
static KeyCode ToKeyCode(
|
|
||||||
WPARAM w_param
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int count_;
|
|
||||||
KeyCode code_;
|
|
||||||
KeyEvent::Type type_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 鼠标消息
|
|
||||||
class MouseEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 鼠标消息类型
|
|
||||||
enum class Type : int
|
|
||||||
{
|
{
|
||||||
Move = 0x0200, // 鼠标移动
|
public:
|
||||||
LeftDown, // 鼠标左键按下
|
// 鼠标消息类型
|
||||||
LeftUp, // 鼠标左键抬起
|
enum class Type : int
|
||||||
LeftDoubleClick, // 鼠标左键双击
|
{
|
||||||
RightDown, // 鼠标右键按下
|
Move = 0x0200, // 鼠标移动
|
||||||
RightUp, // 鼠标右键抬起
|
LeftDown, // 鼠标左键按下
|
||||||
RightDoubleClick, // 鼠标右键双击
|
LeftUp, // 鼠标左键抬起
|
||||||
MiddleDown, // 鼠标中键按下
|
LeftDoubleClick, // 鼠标左键双击
|
||||||
MiddleUp, // 鼠标中键抬起
|
RightDown, // 鼠标右键按下
|
||||||
MiddleDoubleClick, // 鼠标中键双击
|
RightUp, // 鼠标右键抬起
|
||||||
Wheel // 滑动滚轮
|
RightDoubleClick, // 鼠标右键双击
|
||||||
|
MiddleDown, // 鼠标中键按下
|
||||||
|
MiddleUp, // 鼠标中键抬起
|
||||||
|
MiddleDoubleClick, // 鼠标中键双击
|
||||||
|
Wheel // 滑动滚轮
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MouseEvent(
|
||||||
|
HWND hWnd,
|
||||||
|
UINT message,
|
||||||
|
WPARAM w_param,
|
||||||
|
LPARAM l_param,
|
||||||
|
float dpi
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取鼠标横坐标
|
||||||
|
float GetX() const;
|
||||||
|
|
||||||
|
// 获取鼠标纵坐标
|
||||||
|
float GetY() const;
|
||||||
|
|
||||||
|
// 获取鼠标坐标
|
||||||
|
Point GetPos() const;
|
||||||
|
|
||||||
|
// 获取事件类型
|
||||||
|
MouseEvent::Type GetType() const;
|
||||||
|
|
||||||
|
float GetWheelDelta() const;
|
||||||
|
|
||||||
|
// 鼠标左键是否按下
|
||||||
|
bool IsLButtonDown() const;
|
||||||
|
|
||||||
|
// 鼠标右键是否按下
|
||||||
|
bool IsRButtonDown() const;
|
||||||
|
|
||||||
|
// 鼠标中键是否按下
|
||||||
|
bool IsMButtonDown() const;
|
||||||
|
|
||||||
|
// Shift 键是否按下
|
||||||
|
bool IsShiftDown() const;
|
||||||
|
|
||||||
|
// Ctrl 键是否按下
|
||||||
|
bool IsCtrlDown() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UINT message_;
|
||||||
|
WPARAM w_param_;
|
||||||
|
LPARAM l_param_;
|
||||||
|
Point pos_;
|
||||||
|
MouseEvent::Type type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
explicit MouseEvent(
|
|
||||||
HWND hWnd,
|
|
||||||
UINT message,
|
|
||||||
WPARAM w_param,
|
|
||||||
LPARAM l_param,
|
|
||||||
float dpi
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取鼠标横坐标
|
// 碰撞事件
|
||||||
float GetX() const;
|
class Collision
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Collision();
|
||||||
|
|
||||||
// 获取鼠标纵坐标
|
explicit Collision(
|
||||||
float GetY() const;
|
Node* node,
|
||||||
|
Collider::Relation relation
|
||||||
|
);
|
||||||
|
|
||||||
// 获取鼠标坐标
|
~Collision();
|
||||||
Point GetPos() const;
|
|
||||||
|
|
||||||
// 获取事件类型
|
// 获取发生碰撞节点
|
||||||
MouseEvent::Type GetType() const;
|
Node* GetNode() const;
|
||||||
|
|
||||||
float GetWheelDelta() const;
|
// 获取交集关系
|
||||||
|
Collider::Relation GetRelation() const;
|
||||||
|
|
||||||
// 鼠标左键是否按下
|
protected:
|
||||||
bool IsLButtonDown() const;
|
Node * node_;
|
||||||
|
Collider::Relation relation_;
|
||||||
// 鼠标右键是否按下
|
};
|
||||||
bool IsRButtonDown() const;
|
|
||||||
|
|
||||||
// 鼠标中键是否按下
|
|
||||||
bool IsMButtonDown() const;
|
|
||||||
|
|
||||||
// Shift 键是否按下
|
|
||||||
bool IsShiftDown() const;
|
|
||||||
|
|
||||||
// Ctrl 键是否按下
|
|
||||||
bool IsCtrlDown() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
UINT message_;
|
|
||||||
WPARAM w_param_;
|
|
||||||
LPARAM l_param_;
|
|
||||||
Point pos_;
|
|
||||||
MouseEvent::Type type_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 碰撞事件
|
|
||||||
class Collision
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Collision();
|
|
||||||
|
|
||||||
explicit Collision(
|
|
||||||
Node* node,
|
|
||||||
Collider::Relation relation
|
|
||||||
);
|
|
||||||
|
|
||||||
~Collision();
|
|
||||||
|
|
||||||
// 获取发生碰撞节点
|
|
||||||
Node* GetNode() const;
|
|
||||||
|
|
||||||
// 获取交集关系
|
|
||||||
Collider::Relation GetRelation() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Node * node_;
|
|
||||||
Collider::Relation relation_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
360
core/e2dimpl.h
360
core/e2dimpl.h
|
|
@ -5,191 +5,191 @@ namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class Music;
|
class Music;
|
||||||
|
|
||||||
// 音源回调
|
// 音源回调
|
||||||
class VoiceCallback
|
class VoiceCallback
|
||||||
: public IXAudio2VoiceCallback
|
: public IXAudio2VoiceCallback
|
||||||
{
|
|
||||||
public:
|
|
||||||
VoiceCallback();
|
|
||||||
|
|
||||||
~VoiceCallback();
|
|
||||||
|
|
||||||
STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) {}
|
|
||||||
|
|
||||||
STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS) {}
|
|
||||||
|
|
||||||
STDMETHOD_(void, OnStreamEnd) (THIS);
|
|
||||||
|
|
||||||
STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext) {}
|
|
||||||
|
|
||||||
STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext);
|
|
||||||
|
|
||||||
STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext);
|
|
||||||
|
|
||||||
STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) {}
|
|
||||||
|
|
||||||
STDMETHOD_(void, SetCallbackOnStreamEnd) (THIS_ const Function& func);
|
|
||||||
|
|
||||||
STDMETHOD_(void, SetCallbackOnLoopEnd) (THIS_ const Function& func);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Function loop_end_callback_;
|
|
||||||
Function stream_end_callback_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 文字渲染器
|
|
||||||
class E2DTextRenderer
|
|
||||||
: public IDWriteTextRenderer
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
E2DTextRenderer();
|
|
||||||
|
|
||||||
~E2DTextRenderer();
|
|
||||||
|
|
||||||
public:
|
|
||||||
static HRESULT Create(
|
|
||||||
E2DTextRenderer** ppTextRenderer,
|
|
||||||
ID2D1Factory* pD2DFactory,
|
|
||||||
ID2D1HwndRenderTarget* pRT,
|
|
||||||
ID2D1SolidColorBrush* pBrush
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD_(void, SetTextStyle)(
|
|
||||||
CONST D2D1_COLOR_F &fillColor,
|
|
||||||
BOOL outline,
|
|
||||||
CONST D2D1_COLOR_F &outline_color,
|
|
||||||
FLOAT outline_width,
|
|
||||||
D2D1_LINE_JOIN outlineJoin
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawGlyphRun)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT baselineOriginX,
|
|
||||||
FLOAT baselineOriginY,
|
|
||||||
DWRITE_MEASURING_MODE measuringMode,
|
|
||||||
__in DWRITE_GLYPH_RUN const* glyphRun,
|
|
||||||
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawUnderline)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT baselineOriginX,
|
|
||||||
FLOAT baselineOriginY,
|
|
||||||
__in DWRITE_UNDERLINE const* underline,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawStrikethrough)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT baselineOriginX,
|
|
||||||
FLOAT baselineOriginY,
|
|
||||||
__in DWRITE_STRIKETHROUGH const* strikethrough,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawInlineObject)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT originX,
|
|
||||||
FLOAT originY,
|
|
||||||
IDWriteInlineObject* inlineObject,
|
|
||||||
BOOL IsSideways,
|
|
||||||
BOOL IsRightToLeft,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(IsPixelSnappingDisabled)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
__out BOOL* isDisabled
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(GetCurrentTransform)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
__out DWRITE_MATRIX* transform
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(GetPixelsPerDip)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
__out FLOAT* pixelsPerDip
|
|
||||||
);
|
|
||||||
|
|
||||||
public:
|
|
||||||
unsigned long STDMETHODCALLTYPE AddRef();
|
|
||||||
unsigned long STDMETHODCALLTYPE Release();
|
|
||||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
|
||||||
IID const& riid,
|
|
||||||
void** ppvObject
|
|
||||||
);
|
|
||||||
|
|
||||||
private:
|
|
||||||
unsigned long cRefCount_;
|
|
||||||
D2D1_COLOR_F sFillColor_;
|
|
||||||
D2D1_COLOR_F sOutlineColor_;
|
|
||||||
FLOAT fOutlineWidth;
|
|
||||||
BOOL bShowOutline_;
|
|
||||||
ID2D1Factory* pD2DFactory_;
|
|
||||||
ID2D1HwndRenderTarget* pRT_;
|
|
||||||
ID2D1SolidColorBrush* pBrush_;
|
|
||||||
ID2D1StrokeStyle * pCurrStrokeStyle_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 异常
|
|
||||||
class Exception
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Exception() E2D_NOEXCEPT;
|
|
||||||
|
|
||||||
explicit Exception(const char * message) E2D_NOEXCEPT;
|
|
||||||
|
|
||||||
Exception(Exception const& other) E2D_NOEXCEPT;
|
|
||||||
|
|
||||||
virtual ~Exception() E2D_NOEXCEPT;
|
|
||||||
|
|
||||||
Exception& operator=(Exception const& other) E2D_NOEXCEPT;
|
|
||||||
|
|
||||||
// 获取异常信息
|
|
||||||
virtual const char * GetMsg() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char * message_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 系统异常
|
|
||||||
class SystemException
|
|
||||||
: public Exception
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SystemException() E2D_NOEXCEPT;
|
|
||||||
|
|
||||||
explicit SystemException(const char * message) E2D_NOEXCEPT;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template<class Interface>
|
|
||||||
inline void SafeRelease(Interface*& p)
|
|
||||||
{
|
|
||||||
if (p != nullptr)
|
|
||||||
{
|
{
|
||||||
p->Release();
|
public:
|
||||||
p = nullptr;
|
VoiceCallback();
|
||||||
}
|
|
||||||
}
|
~VoiceCallback();
|
||||||
|
|
||||||
|
STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) {}
|
||||||
|
|
||||||
|
STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS) {}
|
||||||
|
|
||||||
|
STDMETHOD_(void, OnStreamEnd) (THIS);
|
||||||
|
|
||||||
|
STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext) {}
|
||||||
|
|
||||||
|
STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext);
|
||||||
|
|
||||||
|
STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext);
|
||||||
|
|
||||||
|
STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) {}
|
||||||
|
|
||||||
|
STDMETHOD_(void, SetCallbackOnStreamEnd) (THIS_ const Function& func);
|
||||||
|
|
||||||
|
STDMETHOD_(void, SetCallbackOnLoopEnd) (THIS_ const Function& func);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Function loop_end_callback_;
|
||||||
|
Function stream_end_callback_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void ThrowIfFailed(HRESULT hr)
|
// 文字渲染器
|
||||||
{
|
class E2DTextRenderer
|
||||||
if (FAILED(hr))
|
: public IDWriteTextRenderer
|
||||||
{
|
{
|
||||||
// 在此处设置断点以捕获 D2D API 异常.
|
private:
|
||||||
static char s_str[64] = {};
|
E2DTextRenderer();
|
||||||
sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast<unsigned int>(hr));
|
|
||||||
throw SystemException(s_str);
|
~E2DTextRenderer();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static HRESULT Create(
|
||||||
|
E2DTextRenderer** ppTextRenderer,
|
||||||
|
ID2D1Factory* pD2DFactory,
|
||||||
|
ID2D1HwndRenderTarget* pRT,
|
||||||
|
ID2D1SolidColorBrush* pBrush
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD_(void, SetTextStyle)(
|
||||||
|
CONST D2D1_COLOR_F &fillColor,
|
||||||
|
BOOL outline,
|
||||||
|
CONST D2D1_COLOR_F &outline_color,
|
||||||
|
FLOAT outline_width,
|
||||||
|
D2D1_LINE_JOIN outlineJoin
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(DrawGlyphRun)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
FLOAT baselineOriginX,
|
||||||
|
FLOAT baselineOriginY,
|
||||||
|
DWRITE_MEASURING_MODE measuringMode,
|
||||||
|
__in DWRITE_GLYPH_RUN const* glyphRun,
|
||||||
|
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
|
||||||
|
IUnknown* clientDrawingEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(DrawUnderline)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
FLOAT baselineOriginX,
|
||||||
|
FLOAT baselineOriginY,
|
||||||
|
__in DWRITE_UNDERLINE const* underline,
|
||||||
|
IUnknown* clientDrawingEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(DrawStrikethrough)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
FLOAT baselineOriginX,
|
||||||
|
FLOAT baselineOriginY,
|
||||||
|
__in DWRITE_STRIKETHROUGH const* strikethrough,
|
||||||
|
IUnknown* clientDrawingEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(DrawInlineObject)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
FLOAT originX,
|
||||||
|
FLOAT originY,
|
||||||
|
IDWriteInlineObject* inlineObject,
|
||||||
|
BOOL IsSideways,
|
||||||
|
BOOL IsRightToLeft,
|
||||||
|
IUnknown* clientDrawingEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(IsPixelSnappingDisabled)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
__out BOOL* isDisabled
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(GetCurrentTransform)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
__out DWRITE_MATRIX* transform
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(GetPixelsPerDip)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
__out FLOAT* pixelsPerDip
|
||||||
|
);
|
||||||
|
|
||||||
|
public:
|
||||||
|
unsigned long STDMETHODCALLTYPE AddRef();
|
||||||
|
unsigned long STDMETHODCALLTYPE Release();
|
||||||
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||||
|
IID const& riid,
|
||||||
|
void** ppvObject
|
||||||
|
);
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned long cRefCount_;
|
||||||
|
D2D1_COLOR_F sFillColor_;
|
||||||
|
D2D1_COLOR_F sOutlineColor_;
|
||||||
|
FLOAT fOutlineWidth;
|
||||||
|
BOOL bShowOutline_;
|
||||||
|
ID2D1Factory* pD2DFactory_;
|
||||||
|
ID2D1HwndRenderTarget* pRT_;
|
||||||
|
ID2D1SolidColorBrush* pBrush_;
|
||||||
|
ID2D1StrokeStyle * pCurrStrokeStyle_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 异常
|
||||||
|
class Exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Exception() E2D_NOEXCEPT;
|
||||||
|
|
||||||
|
explicit Exception(const char * message) E2D_NOEXCEPT;
|
||||||
|
|
||||||
|
Exception(Exception const& other) E2D_NOEXCEPT;
|
||||||
|
|
||||||
|
virtual ~Exception() E2D_NOEXCEPT;
|
||||||
|
|
||||||
|
Exception& operator=(Exception const& other) E2D_NOEXCEPT;
|
||||||
|
|
||||||
|
// 获取异常信息
|
||||||
|
virtual const char * GetMsg() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char * message_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 系统异常
|
||||||
|
class SystemException
|
||||||
|
: public Exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SystemException() E2D_NOEXCEPT;
|
||||||
|
|
||||||
|
explicit SystemException(const char * message) E2D_NOEXCEPT;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class Interface>
|
||||||
|
inline void SafeRelease(Interface*& p)
|
||||||
|
{
|
||||||
|
if (p != nullptr)
|
||||||
|
{
|
||||||
|
p->Release();
|
||||||
|
p = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void ThrowIfFailed(HRESULT hr)
|
||||||
|
{
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
// 在此处设置断点以捕获 D2D API 异常.
|
||||||
|
static char s_str[64] = {};
|
||||||
|
sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast<unsigned int>(hr));
|
||||||
|
throw SystemException(s_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,74 +6,74 @@ namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class Node;
|
class Node;
|
||||||
|
|
||||||
|
|
||||||
// 碰撞体管理器
|
// 碰撞体管理器
|
||||||
class CollisionManager
|
class CollisionManager
|
||||||
{
|
{
|
||||||
friend class Node;
|
friend class Node;
|
||||||
friend class Collider;
|
friend class Collider;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 获取碰撞体管理器实例
|
// 获取碰撞体管理器实例
|
||||||
static CollisionManager * GetInstance();
|
static CollisionManager * GetInstance();
|
||||||
|
|
||||||
// 打开或关闭碰撞监听
|
// 打开或关闭碰撞监听
|
||||||
// 默认:关闭
|
// 默认:关闭
|
||||||
void SetCollisionEnabled(
|
void SetCollisionEnabled(
|
||||||
bool enabled
|
bool enabled
|
||||||
);
|
);
|
||||||
|
|
||||||
// 添加可互相碰撞物体的名称
|
// 添加可互相碰撞物体的名称
|
||||||
void AddName(
|
void AddName(
|
||||||
const String& name1,
|
const String& name1,
|
||||||
const String& name2
|
const String& name2
|
||||||
);
|
);
|
||||||
|
|
||||||
// 添加可互相碰撞物体的名称
|
// 添加可互相碰撞物体的名称
|
||||||
void AddName(
|
void AddName(
|
||||||
const std::vector<std::pair<String, String>>& names
|
const std::vector<std::pair<String, String>>& names
|
||||||
);
|
);
|
||||||
|
|
||||||
// 判断两个物体是否是可碰撞的
|
// 判断两个物体是否是可碰撞的
|
||||||
bool IsCollidable(
|
bool IsCollidable(
|
||||||
Node * node1,
|
Node * node1,
|
||||||
Node * node2
|
Node * node2
|
||||||
);
|
);
|
||||||
|
|
||||||
// 判断两个物体是否是可碰撞的
|
// 判断两个物体是否是可碰撞的
|
||||||
bool IsCollidable(
|
bool IsCollidable(
|
||||||
const String& name1,
|
const String& name1,
|
||||||
const String& name2
|
const String& name2
|
||||||
);
|
);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CollisionManager();
|
CollisionManager();
|
||||||
|
|
||||||
~CollisionManager();
|
~CollisionManager();
|
||||||
|
|
||||||
E2D_DISABLE_COPY(CollisionManager);
|
E2D_DISABLE_COPY(CollisionManager);
|
||||||
|
|
||||||
// 添加碰撞体
|
// 添加碰撞体
|
||||||
void AddCollider(
|
void AddCollider(
|
||||||
Collider* collider
|
Collider* collider
|
||||||
);
|
);
|
||||||
|
|
||||||
// 移除碰撞体
|
// 移除碰撞体
|
||||||
void RemoveCollider(
|
void RemoveCollider(
|
||||||
Collider* collider
|
Collider* collider
|
||||||
);
|
);
|
||||||
|
|
||||||
// 更新碰撞体
|
// 更新碰撞体
|
||||||
void UpdateCollider(
|
void UpdateCollider(
|
||||||
Collider* collider
|
Collider* collider
|
||||||
);
|
);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool collision_enabled_;
|
bool collision_enabled_;
|
||||||
std::vector<Collider*> colliders_;
|
std::vector<Collider*> colliders_;
|
||||||
std::set<std::pair<size_t, size_t>> collision_list_;
|
std::set<std::pair<size_t, size_t>> collision_list_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
682
core/e2dmodule.h
682
core/e2dmodule.h
|
|
@ -8,406 +8,406 @@ namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// 窗体
|
// 窗体
|
||||||
class Window
|
class Window
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 鼠标指针样式
|
|
||||||
enum class Cursor : int
|
|
||||||
{
|
{
|
||||||
Normal, /* 默认指针样式 */
|
public:
|
||||||
Hand, /* 手状指针 */
|
// 鼠标指针样式
|
||||||
No, /* 禁止指针 */
|
enum class Cursor : int
|
||||||
Wait, /* 沙漏指针 */
|
{
|
||||||
ArrowWait /* 默认指针和小沙漏 */
|
Normal, /* 默认指针样式 */
|
||||||
|
Hand, /* 手状指针 */
|
||||||
|
No, /* 禁止指针 */
|
||||||
|
Wait, /* 沙漏指针 */
|
||||||
|
ArrowWait /* 默认指针和小沙漏 */
|
||||||
|
};
|
||||||
|
|
||||||
|
// 弹窗样式
|
||||||
|
enum class PopupStyle : int
|
||||||
|
{
|
||||||
|
Info, /* 提示 */
|
||||||
|
Warning, /* 警告 */
|
||||||
|
Error /* 错误 */
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
// 获取窗体实例
|
||||||
|
static Window * GetInstance();
|
||||||
|
|
||||||
|
// 销毁窗体实例
|
||||||
|
static void DestroyInstance();
|
||||||
|
|
||||||
|
// 创建窗体互斥体
|
||||||
|
bool CheckMutex(
|
||||||
|
const String& mutex = L"" /* 进程互斥体名称 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取窗体标题
|
||||||
|
const String& GetTitle() const;
|
||||||
|
|
||||||
|
// 获取窗体宽度
|
||||||
|
int GetWidth() const;
|
||||||
|
|
||||||
|
// 获取窗体高度
|
||||||
|
int GetHeight() const;
|
||||||
|
|
||||||
|
// 获取窗体大小
|
||||||
|
Size GetSize() const;
|
||||||
|
|
||||||
|
// 获取窗口 DPI
|
||||||
|
float GetDpi() const;
|
||||||
|
|
||||||
|
// 获取窗口句柄
|
||||||
|
HWND GetHWnd();
|
||||||
|
|
||||||
|
// 修改窗体大小
|
||||||
|
void SetSize(
|
||||||
|
int width, /* 窗体宽度 */
|
||||||
|
int height /* 窗体高度 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 设置窗体标题
|
||||||
|
void SetTitle(
|
||||||
|
const String& title /* 窗体标题 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 设置窗体图标
|
||||||
|
void SetIcon(
|
||||||
|
int icon_id
|
||||||
|
);
|
||||||
|
|
||||||
|
// 设置鼠标指针样式
|
||||||
|
void SetCursor(
|
||||||
|
Cursor cursor
|
||||||
|
);
|
||||||
|
|
||||||
|
// 打开或隐藏控制台
|
||||||
|
void SetConsoleEnabled(
|
||||||
|
bool enabled
|
||||||
|
);
|
||||||
|
|
||||||
|
// 是否允许响应输入法
|
||||||
|
void SetTypewritingEnabled(
|
||||||
|
bool enabled
|
||||||
|
);
|
||||||
|
|
||||||
|
// 弹出窗口
|
||||||
|
// 返回值:当窗口包含取消按钮时,返回值表示用户是否点击确认按钮
|
||||||
|
bool Popup(
|
||||||
|
const String& text, /* 窗口内容 */
|
||||||
|
const String& title, /* 窗口标题 */
|
||||||
|
PopupStyle style = PopupStyle::Info,/* 弹窗样式 */
|
||||||
|
bool has_cancel = false /* 包含取消按钮 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 处理窗体消息
|
||||||
|
void Poll();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Window();
|
||||||
|
|
||||||
|
~Window();
|
||||||
|
|
||||||
|
E2D_DISABLE_COPY(Window);
|
||||||
|
|
||||||
|
// 根据客户区大小定位窗口
|
||||||
|
Rect Locate(
|
||||||
|
int width,
|
||||||
|
int height
|
||||||
|
);
|
||||||
|
|
||||||
|
// Win32 窗口消息回调程序
|
||||||
|
static LRESULT CALLBACK WndProc(
|
||||||
|
HWND hWnd,
|
||||||
|
UINT msg,
|
||||||
|
WPARAM w_param,
|
||||||
|
LPARAM l_param
|
||||||
|
);
|
||||||
|
|
||||||
|
private:
|
||||||
|
HWND hWnd_;
|
||||||
|
MSG msg_;
|
||||||
|
int width_;
|
||||||
|
int height_;
|
||||||
|
String title_;
|
||||||
|
int icon_id_;
|
||||||
|
float dpi_;
|
||||||
|
|
||||||
|
static Window * instance_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 弹窗样式
|
|
||||||
enum class PopupStyle : int
|
// 渲染器
|
||||||
|
class Renderer
|
||||||
{
|
{
|
||||||
Info, /* 提示 */
|
public:
|
||||||
Warning, /* 警告 */
|
// 获取渲染器实例
|
||||||
Error /* 错误 */
|
static Renderer * GetInstance();
|
||||||
|
|
||||||
|
// 销毁实例
|
||||||
|
static void DestroyInstance();
|
||||||
|
|
||||||
|
// 获取背景色
|
||||||
|
Color GetBackgroundColor();
|
||||||
|
|
||||||
|
// 修改背景色
|
||||||
|
void SetBackgroundColor(
|
||||||
|
const Color& color
|
||||||
|
);
|
||||||
|
|
||||||
|
// 显示或隐藏 FPS
|
||||||
|
// 默认:隐藏
|
||||||
|
void ShowFps(
|
||||||
|
bool show
|
||||||
|
);
|
||||||
|
|
||||||
|
// 开始渲染
|
||||||
|
void BeginDraw();
|
||||||
|
|
||||||
|
// 结束渲染
|
||||||
|
void EndDraw();
|
||||||
|
|
||||||
|
// 获取文字渲染器
|
||||||
|
E2DTextRenderer * GetTextRenderer();
|
||||||
|
|
||||||
|
// 获取 ID2D1HwndRenderTarget 对象
|
||||||
|
ID2D1HwndRenderTarget * GetRenderTarget();
|
||||||
|
|
||||||
|
// 获取 ID2D1SolidColorBrush 对象
|
||||||
|
ID2D1SolidColorBrush * GetSolidBrush();
|
||||||
|
|
||||||
|
// 获取 ID2D1Factory 对象
|
||||||
|
static ID2D1Factory * GetFactory();
|
||||||
|
|
||||||
|
// 获取 IWICImagingFactory 对象
|
||||||
|
static IWICImagingFactory * GetImagingFactory();
|
||||||
|
|
||||||
|
// 获取 IDWriteFactory 对象
|
||||||
|
static IDWriteFactory * GetWriteFactory();
|
||||||
|
|
||||||
|
// 获取 Miter 样式的 ID2D1StrokeStyle
|
||||||
|
static ID2D1StrokeStyle * GetMiterStrokeStyle();
|
||||||
|
|
||||||
|
// 获取 Bevel 样式的 ID2D1StrokeStyle
|
||||||
|
static ID2D1StrokeStyle * GetBevelStrokeStyle();
|
||||||
|
|
||||||
|
// 获取 Round 样式的 ID2D1StrokeStyle
|
||||||
|
static ID2D1StrokeStyle * GetRoundStrokeStyle();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Renderer();
|
||||||
|
|
||||||
|
~Renderer();
|
||||||
|
|
||||||
|
E2D_DISABLE_COPY(Renderer);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool show_fps_;
|
||||||
|
int render_times_;
|
||||||
|
Time last_render_time_;
|
||||||
|
D2D1_COLOR_F clear_color_;
|
||||||
|
E2DTextRenderer* text_renderer_;
|
||||||
|
IDWriteTextFormat* fps_text_format_;
|
||||||
|
IDWriteTextLayout* fps_text_layout_;
|
||||||
|
ID2D1SolidColorBrush* solid_brush_;
|
||||||
|
ID2D1HwndRenderTarget* render_target_;
|
||||||
|
|
||||||
|
static ID2D1Factory* factory_;
|
||||||
|
static IWICImagingFactory* imaging_factory_;
|
||||||
|
static IDWriteFactory* write_factory_;
|
||||||
|
static ID2D1StrokeStyle* miter_stroke_style_;
|
||||||
|
static ID2D1StrokeStyle* bevel_stroke_style_;
|
||||||
|
static ID2D1StrokeStyle* round_stroke_style_;
|
||||||
|
static Renderer * instance_;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
// 获取窗体实例
|
|
||||||
static Window * GetInstance();
|
|
||||||
|
|
||||||
// 销毁窗体实例
|
|
||||||
static void DestroyInstance();
|
|
||||||
|
|
||||||
// 创建窗体互斥体
|
|
||||||
bool CheckMutex(
|
|
||||||
const String& mutex = L"" /* 进程互斥体名称 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取窗体标题
|
|
||||||
const String& GetTitle() const;
|
|
||||||
|
|
||||||
// 获取窗体宽度
|
|
||||||
int GetWidth() const;
|
|
||||||
|
|
||||||
// 获取窗体高度
|
|
||||||
int GetHeight() const;
|
|
||||||
|
|
||||||
// 获取窗体大小
|
|
||||||
Size GetSize() const;
|
|
||||||
|
|
||||||
// 获取窗口 DPI
|
|
||||||
float GetDpi() const;
|
|
||||||
|
|
||||||
// 获取窗口句柄
|
|
||||||
HWND GetHWnd();
|
|
||||||
|
|
||||||
// 修改窗体大小
|
|
||||||
void SetSize(
|
|
||||||
int width, /* 窗体宽度 */
|
|
||||||
int height /* 窗体高度 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 设置窗体标题
|
|
||||||
void SetTitle(
|
|
||||||
const String& title /* 窗体标题 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 设置窗体图标
|
|
||||||
void SetIcon(
|
|
||||||
int icon_id
|
|
||||||
);
|
|
||||||
|
|
||||||
// 设置鼠标指针样式
|
|
||||||
void SetCursor(
|
|
||||||
Cursor cursor
|
|
||||||
);
|
|
||||||
|
|
||||||
// 打开或隐藏控制台
|
|
||||||
void SetConsoleEnabled(
|
|
||||||
bool enabled
|
|
||||||
);
|
|
||||||
|
|
||||||
// 是否允许响应输入法
|
|
||||||
void SetTypewritingEnabled(
|
|
||||||
bool enabled
|
|
||||||
);
|
|
||||||
|
|
||||||
// 弹出窗口
|
// 输入设备
|
||||||
// 返回值:当窗口包含取消按钮时,返回值表示用户是否点击确认按钮
|
class Input
|
||||||
bool Popup(
|
{
|
||||||
const String& text, /* 窗口内容 */
|
public:
|
||||||
const String& title, /* 窗口标题 */
|
// 获取输入设备实例
|
||||||
PopupStyle style = PopupStyle::Info,/* 弹窗样式 */
|
static Input * GetInstance();
|
||||||
bool has_cancel = false /* 包含取消按钮 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 处理窗体消息
|
// 销毁输入设备实例
|
||||||
void Poll();
|
static void DestroyInstance();
|
||||||
|
|
||||||
private:
|
// 检测键盘某按键是否正被按下
|
||||||
Window();
|
bool IsDown(
|
||||||
|
KeyCode key
|
||||||
|
);
|
||||||
|
|
||||||
~Window();
|
// 检测鼠标按键是否正被按下
|
||||||
|
bool IsDown(
|
||||||
|
MouseCode code
|
||||||
|
);
|
||||||
|
|
||||||
E2D_DISABLE_COPY(Window);
|
// 获得鼠标X轴坐标值
|
||||||
|
float GetMouseX();
|
||||||
// 根据客户区大小定位窗口
|
|
||||||
Rect Locate(
|
|
||||||
int width,
|
|
||||||
int height
|
|
||||||
);
|
|
||||||
|
|
||||||
// Win32 窗口消息回调程序
|
|
||||||
static LRESULT CALLBACK WndProc(
|
|
||||||
HWND hWnd,
|
|
||||||
UINT msg,
|
|
||||||
WPARAM w_param,
|
|
||||||
LPARAM l_param
|
|
||||||
);
|
|
||||||
|
|
||||||
private:
|
|
||||||
HWND hWnd_;
|
|
||||||
MSG msg_;
|
|
||||||
int width_;
|
|
||||||
int height_;
|
|
||||||
String title_;
|
|
||||||
int icon_id_;
|
|
||||||
float dpi_;
|
|
||||||
|
|
||||||
static Window * instance_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 渲染器
|
|
||||||
class Renderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 获取渲染器实例
|
|
||||||
static Renderer * GetInstance();
|
|
||||||
|
|
||||||
// 销毁实例
|
|
||||||
static void DestroyInstance();
|
|
||||||
|
|
||||||
// 获取背景色
|
|
||||||
Color GetBackgroundColor();
|
|
||||||
|
|
||||||
// 修改背景色
|
|
||||||
void SetBackgroundColor(
|
|
||||||
const Color& color
|
|
||||||
);
|
|
||||||
|
|
||||||
// 显示或隐藏 FPS
|
|
||||||
// 默认:隐藏
|
|
||||||
void ShowFps(
|
|
||||||
bool show
|
|
||||||
);
|
|
||||||
|
|
||||||
// 开始渲染
|
|
||||||
void BeginDraw();
|
|
||||||
|
|
||||||
// 结束渲染
|
|
||||||
void EndDraw();
|
|
||||||
|
|
||||||
// 获取文字渲染器
|
|
||||||
E2DTextRenderer * GetTextRenderer();
|
|
||||||
|
|
||||||
// 获取 ID2D1HwndRenderTarget 对象
|
// 获得鼠标Y轴坐标值
|
||||||
ID2D1HwndRenderTarget * GetRenderTarget();
|
float GetMouseY();
|
||||||
|
|
||||||
// 获取 ID2D1SolidColorBrush 对象
|
// 获得鼠标坐标值
|
||||||
ID2D1SolidColorBrush * GetSolidBrush();
|
Point GetMousePos();
|
||||||
|
|
||||||
// 获取 ID2D1Factory 对象
|
// 获得鼠标X轴坐标增量
|
||||||
static ID2D1Factory * GetFactory();
|
float GetMouseDeltaX();
|
||||||
|
|
||||||
// 获取 IWICImagingFactory 对象
|
// 获得鼠标Y轴坐标增量
|
||||||
static IWICImagingFactory * GetImagingFactory();
|
float GetMouseDeltaY();
|
||||||
|
|
||||||
// 获取 IDWriteFactory 对象
|
// 获得鼠标Z轴(鼠标滚轮)坐标增量
|
||||||
static IDWriteFactory * GetWriteFactory();
|
float GetMouseDeltaZ();
|
||||||
|
|
||||||
// 获取 Miter 样式的 ID2D1StrokeStyle
|
// 刷新输入设备状态
|
||||||
static ID2D1StrokeStyle * GetMiterStrokeStyle();
|
void Update();
|
||||||
|
|
||||||
// 获取 Bevel 样式的 ID2D1StrokeStyle
|
protected:
|
||||||
static ID2D1StrokeStyle * GetBevelStrokeStyle();
|
Input();
|
||||||
|
|
||||||
// 获取 Round 样式的 ID2D1StrokeStyle
|
~Input();
|
||||||
static ID2D1StrokeStyle * GetRoundStrokeStyle();
|
|
||||||
|
|
||||||
protected:
|
E2D_DISABLE_COPY(Input);
|
||||||
Renderer();
|
|
||||||
|
|
||||||
~Renderer();
|
protected:
|
||||||
|
IDirectInput8W * direct_input_;
|
||||||
|
IDirectInputDevice8W* keyboard_device_;
|
||||||
|
IDirectInputDevice8W* mouse_device_;
|
||||||
|
DIMOUSESTATE mouse_state_;
|
||||||
|
char key_buffer_[256];
|
||||||
|
|
||||||
E2D_DISABLE_COPY(Renderer);
|
static Input * instance_;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
|
||||||
bool show_fps_;
|
|
||||||
int render_times_;
|
|
||||||
Time last_render_time_;
|
|
||||||
D2D1_COLOR_F clear_color_;
|
|
||||||
E2DTextRenderer* text_renderer_;
|
|
||||||
IDWriteTextFormat* fps_text_format_;
|
|
||||||
IDWriteTextLayout* fps_text_layout_;
|
|
||||||
ID2D1SolidColorBrush* solid_brush_;
|
|
||||||
ID2D1HwndRenderTarget* render_target_;
|
|
||||||
|
|
||||||
static ID2D1Factory* factory_;
|
// 音频设备
|
||||||
static IWICImagingFactory* imaging_factory_;
|
class Audio
|
||||||
static IDWriteFactory* write_factory_;
|
{
|
||||||
static ID2D1StrokeStyle* miter_stroke_style_;
|
public:
|
||||||
static ID2D1StrokeStyle* bevel_stroke_style_;
|
// 获取音频设备实例
|
||||||
static ID2D1StrokeStyle* round_stroke_style_;
|
static Audio * GetInstance();
|
||||||
static Renderer * instance_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// 销毁实例
|
||||||
|
static void DestroyInstance();
|
||||||
|
|
||||||
// 输入设备
|
// 获取 XAudio2 实例对象
|
||||||
class Input
|
IXAudio2 * GetXAudio2();
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 获取输入设备实例
|
|
||||||
static Input * GetInstance();
|
|
||||||
|
|
||||||
// 销毁输入设备实例
|
// 获取 MasteringVoice 实例对象
|
||||||
static void DestroyInstance();
|
IXAudio2MasteringVoice* GetMasteringVoice();
|
||||||
|
|
||||||
// 检测键盘某按键是否正被按下
|
protected:
|
||||||
bool IsDown(
|
Audio();
|
||||||
KeyCode key
|
|
||||||
);
|
|
||||||
|
|
||||||
// 检测鼠标按键是否正被按下
|
virtual ~Audio();
|
||||||
bool IsDown(
|
|
||||||
MouseCode code
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获得鼠标X轴坐标值
|
E2D_DISABLE_COPY(Audio);
|
||||||
float GetMouseX();
|
|
||||||
|
|
||||||
// 获得鼠标Y轴坐标值
|
protected:
|
||||||
float GetMouseY();
|
IXAudio2 * x_audio2_;
|
||||||
|
IXAudio2MasteringVoice* mastering_voice_;
|
||||||
|
|
||||||
// 获得鼠标坐标值
|
static Audio * instance_;
|
||||||
Point GetMousePos();
|
};
|
||||||
|
|
||||||
// 获得鼠标X轴坐标增量
|
|
||||||
float GetMouseDeltaX();
|
|
||||||
|
|
||||||
// 获得鼠标Y轴坐标增量
|
// 游戏
|
||||||
float GetMouseDeltaY();
|
class Game
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// 获取 Game 实例
|
||||||
|
static Game * GetInstance();
|
||||||
|
|
||||||
// 获得鼠标Z轴(鼠标滚轮)坐标增量
|
// 销毁实例
|
||||||
float GetMouseDeltaZ();
|
static void DestroyInstance();
|
||||||
|
|
||||||
// 刷新输入设备状态
|
// 启动游戏
|
||||||
void Update();
|
void Start();
|
||||||
|
|
||||||
protected:
|
// 暂停游戏
|
||||||
Input();
|
void Pause();
|
||||||
|
|
||||||
~Input();
|
// 继续游戏
|
||||||
|
void Resume();
|
||||||
|
|
||||||
E2D_DISABLE_COPY(Input);
|
// 结束游戏
|
||||||
|
void Quit();
|
||||||
|
|
||||||
protected:
|
// 游戏是否暂停
|
||||||
IDirectInput8W * direct_input_;
|
bool IsPaused();
|
||||||
IDirectInputDevice8W* keyboard_device_;
|
|
||||||
IDirectInputDevice8W* mouse_device_;
|
|
||||||
DIMOUSESTATE mouse_state_;
|
|
||||||
char key_buffer_[256];
|
|
||||||
|
|
||||||
static Input * instance_;
|
// 场景入栈
|
||||||
};
|
void EnterScene(
|
||||||
|
Scene * scene /* 下一个场景的指针 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 场景入栈
|
||||||
|
void EnterScene(
|
||||||
|
Transition * transition /* 场景动画 */
|
||||||
|
);
|
||||||
|
|
||||||
// 音频设备
|
// 获取当前场景
|
||||||
class Audio
|
Scene * GetCurrentScene();
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 获取音频设备实例
|
|
||||||
static Audio * GetInstance();
|
|
||||||
|
|
||||||
// 销毁实例
|
// 是否正在进行场景动画
|
||||||
static void DestroyInstance();
|
bool IsTransitioning() const;
|
||||||
|
|
||||||
// 获取 XAudio2 实例对象
|
// 更新场景内容
|
||||||
IXAudio2 * GetXAudio2();
|
void UpdateScene();
|
||||||
|
|
||||||
// 获取 MasteringVoice 实例对象
|
// 渲染场景画面
|
||||||
IXAudio2MasteringVoice* GetMasteringVoice();
|
void DrawScene();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Audio();
|
Game();
|
||||||
|
|
||||||
virtual ~Audio();
|
~Game();
|
||||||
|
|
||||||
E2D_DISABLE_COPY(Audio);
|
E2D_DISABLE_COPY(Game);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
IXAudio2 * x_audio2_;
|
bool quit_;
|
||||||
IXAudio2MasteringVoice* mastering_voice_;
|
bool paused_;
|
||||||
|
Scene* curr_scene_;
|
||||||
|
Scene* next_scene_;
|
||||||
|
Transition* transition_;
|
||||||
|
|
||||||
static Audio * instance_;
|
static Game * instance_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 游戏
|
// 垃圾回收池
|
||||||
class Game
|
class GC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 获取 Game 实例
|
// 获取 GC 实例
|
||||||
static Game * GetInstance();
|
static GC * GetInstance();
|
||||||
|
|
||||||
// 销毁实例
|
// 自动释放
|
||||||
static void DestroyInstance();
|
void AutoRelease(
|
||||||
|
Ref* ref
|
||||||
|
);
|
||||||
|
|
||||||
// 启动游戏
|
// 安全地释放对象
|
||||||
void Start();
|
void SafeRelease(
|
||||||
|
Ref* ref
|
||||||
|
);
|
||||||
|
|
||||||
// 暂停游戏
|
// 刷新内存池
|
||||||
void Pause();
|
void Flush();
|
||||||
|
|
||||||
// 继续游戏
|
private:
|
||||||
void Resume();
|
GC();
|
||||||
|
|
||||||
// 结束游戏
|
~GC();
|
||||||
void Quit();
|
|
||||||
|
|
||||||
// 游戏是否暂停
|
E2D_DISABLE_COPY(GC);
|
||||||
bool IsPaused();
|
|
||||||
|
|
||||||
// 场景入栈
|
private:
|
||||||
void EnterScene(
|
bool notifyed_;
|
||||||
Scene * scene /* 下一个场景的指针 */
|
bool cleanup_;
|
||||||
);
|
std::set<Ref*> pool_;
|
||||||
|
};
|
||||||
// 场景入栈
|
|
||||||
void EnterScene(
|
|
||||||
Transition * transition /* 场景动画 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取当前场景
|
|
||||||
Scene * GetCurrentScene();
|
|
||||||
|
|
||||||
// 是否正在进行场景动画
|
|
||||||
bool IsTransitioning() const;
|
|
||||||
|
|
||||||
// 更新场景内容
|
|
||||||
void UpdateScene();
|
|
||||||
|
|
||||||
// 渲染场景画面
|
|
||||||
void DrawScene();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Game();
|
|
||||||
|
|
||||||
~Game();
|
|
||||||
|
|
||||||
E2D_DISABLE_COPY(Game);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool quit_;
|
|
||||||
bool paused_;
|
|
||||||
Scene* curr_scene_;
|
|
||||||
Scene* next_scene_;
|
|
||||||
Transition* transition_;
|
|
||||||
|
|
||||||
static Game * instance_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 垃圾回收池
|
|
||||||
class GC
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 获取 GC 实例
|
|
||||||
static GC * GetInstance();
|
|
||||||
|
|
||||||
// 自动释放
|
|
||||||
void AutoRelease(
|
|
||||||
Ref* ref
|
|
||||||
);
|
|
||||||
|
|
||||||
// 安全地释放对象
|
|
||||||
void SafeRelease(
|
|
||||||
Ref* ref
|
|
||||||
);
|
|
||||||
|
|
||||||
// 刷新内存池
|
|
||||||
void Flush();
|
|
||||||
|
|
||||||
private:
|
|
||||||
GC();
|
|
||||||
|
|
||||||
~GC();
|
|
||||||
|
|
||||||
E2D_DISABLE_COPY(GC);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool notifyed_;
|
|
||||||
bool cleanup_;
|
|
||||||
std::set<Ref*> pool_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
884
core/e2dtool.h
884
core/e2dtool.h
|
|
@ -6,505 +6,505 @@ namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// 随机数产生器
|
// 随机数产生器
|
||||||
class Random
|
class Random
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 取得范围内的一个整型随机数
|
|
||||||
template<typename T>
|
|
||||||
static inline T Range(T min, T max)
|
|
||||||
{
|
{
|
||||||
return e2d::Random::RandomInt(min, max);
|
public:
|
||||||
}
|
// 取得范围内的一个整型随机数
|
||||||
|
template<typename T>
|
||||||
|
static inline T Range(T min, T max)
|
||||||
|
{
|
||||||
|
return e2d::Random::RandomInt(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
// 取得范围内的一个浮点数随机数
|
// 取得范围内的一个浮点数随机数
|
||||||
static inline float Range(float min, float max)
|
static inline float Range(float min, float max)
|
||||||
|
{
|
||||||
|
return e2d::Random::RandomReal(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取得范围内的一个浮点数随机数
|
||||||
|
static inline double Range(double min, double max)
|
||||||
|
{
|
||||||
|
return e2d::Random::RandomReal(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<typename T>
|
||||||
|
static T RandomInt(T min, T max)
|
||||||
|
{
|
||||||
|
std::uniform_int_distribution<T> dist(min, max);
|
||||||
|
return dist(Random::GetEngine());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static T RandomReal(T min, T max)
|
||||||
|
{
|
||||||
|
std::uniform_real_distribution<T> dist(min, max);
|
||||||
|
return dist(Random::GetEngine());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取随机数产生器
|
||||||
|
static std::default_random_engine &GetEngine();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 音乐
|
||||||
|
class Music :
|
||||||
|
public Ref
|
||||||
{
|
{
|
||||||
return e2d::Random::RandomReal(min, max);
|
friend class VoiceCallback;
|
||||||
}
|
|
||||||
|
|
||||||
// 取得范围内的一个浮点数随机数
|
public:
|
||||||
static inline double Range(double min, double max)
|
Music();
|
||||||
|
|
||||||
|
explicit Music(
|
||||||
|
const e2d::String& file_path /* 音乐文件路径 */
|
||||||
|
);
|
||||||
|
|
||||||
|
explicit Music(
|
||||||
|
const Resource& res /* 音乐资源 */
|
||||||
|
);
|
||||||
|
|
||||||
|
virtual ~Music();
|
||||||
|
|
||||||
|
// 打开音乐文件
|
||||||
|
bool Open(
|
||||||
|
const e2d::String& file_path /* 音乐文件路径 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 打开音乐资源
|
||||||
|
bool Open(
|
||||||
|
const Resource& res
|
||||||
|
);
|
||||||
|
|
||||||
|
// 播放
|
||||||
|
bool Play(
|
||||||
|
int loopCount = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
// 暂停
|
||||||
|
void Pause();
|
||||||
|
|
||||||
|
// 继续
|
||||||
|
void Resume();
|
||||||
|
|
||||||
|
// 停止
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
// 关闭并回收资源
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
// 是否正在播放
|
||||||
|
bool IsPlaying() const;
|
||||||
|
|
||||||
|
// 设置音量
|
||||||
|
bool SetVolume(
|
||||||
|
float volume
|
||||||
|
);
|
||||||
|
|
||||||
|
// 设置播放结束时的执行函数
|
||||||
|
void SetCallbackOnEnd(
|
||||||
|
const Function& func
|
||||||
|
);
|
||||||
|
|
||||||
|
// 设置循环播放中每一次播放结束时的执行函数
|
||||||
|
void SetCallbackOnLoopEnd(
|
||||||
|
const Function& func
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取 IXAudio2SourceVoice 对象
|
||||||
|
IXAudio2SourceVoice * GetSourceVoice() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool _readMMIO();
|
||||||
|
|
||||||
|
bool _resetFile();
|
||||||
|
|
||||||
|
bool _read(
|
||||||
|
BYTE* buffer,
|
||||||
|
DWORD size_to_read
|
||||||
|
);
|
||||||
|
|
||||||
|
bool _findMediaFileCch(
|
||||||
|
wchar_t* dest_path,
|
||||||
|
int cch_dest,
|
||||||
|
const wchar_t * file_name
|
||||||
|
);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool opened_;
|
||||||
|
DWORD size_;
|
||||||
|
CHAR* buffer_;
|
||||||
|
BYTE* wave_data_;
|
||||||
|
HMMIO hmmio_;
|
||||||
|
MMCKINFO ck_;
|
||||||
|
MMCKINFO ck_riff_;
|
||||||
|
WAVEFORMATEX* wfx_;
|
||||||
|
VoiceCallback callback_;
|
||||||
|
IXAudio2SourceVoice* voice_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 音乐播放器
|
||||||
|
class Player
|
||||||
{
|
{
|
||||||
return e2d::Random::RandomReal(min, max);
|
public:
|
||||||
}
|
// 获取播放器实例
|
||||||
|
static Player * GetInstance();
|
||||||
|
|
||||||
private:
|
// 销毁实例
|
||||||
template<typename T>
|
static void DestroyInstance();
|
||||||
static T RandomInt(T min, T max)
|
|
||||||
|
// 预加载音乐资源
|
||||||
|
bool Preload(
|
||||||
|
const String& file_path /* 音乐文件路径 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 播放音乐
|
||||||
|
bool Play(
|
||||||
|
const String& file_path, /* 音乐文件路径 */
|
||||||
|
int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 暂停音乐
|
||||||
|
void Pause(
|
||||||
|
const String& file_path /* 音乐文件路径 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 继续播放音乐
|
||||||
|
void Resume(
|
||||||
|
const String& file_path /* 音乐文件路径 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 停止音乐
|
||||||
|
void Stop(
|
||||||
|
const String& file_path /* 音乐文件路径 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取音乐播放状态
|
||||||
|
bool IsPlaying(
|
||||||
|
const String& file_path /* 音乐文件路径 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 预加载音乐资源
|
||||||
|
bool Preload(
|
||||||
|
const Resource& res /* 音乐资源 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 播放音乐
|
||||||
|
bool Play(
|
||||||
|
const Resource& res, /* 音乐资源 */
|
||||||
|
int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 暂停音乐
|
||||||
|
void Pause(
|
||||||
|
const Resource& res /* 音乐资源 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 继续播放音乐
|
||||||
|
void Resume(
|
||||||
|
const Resource& res /* 音乐资源 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 停止音乐
|
||||||
|
void Stop(
|
||||||
|
const Resource& res /* 音乐资源 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取音乐播放状态
|
||||||
|
bool IsPlaying(
|
||||||
|
const Resource& res /* 音乐资源 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取音量
|
||||||
|
float GetVolume();
|
||||||
|
|
||||||
|
// 设置音量
|
||||||
|
void SetVolume(
|
||||||
|
float volume /* 音量范围为 -224 ~ 224,0 是静音,1 是正常音量 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 暂停所有音乐
|
||||||
|
void PauseAll();
|
||||||
|
|
||||||
|
// 继续播放所有音乐
|
||||||
|
void ResumeAll();
|
||||||
|
|
||||||
|
// 停止所有音乐
|
||||||
|
void StopAll();
|
||||||
|
|
||||||
|
// 清空音乐缓存
|
||||||
|
void ClearCache();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Player();
|
||||||
|
|
||||||
|
~Player();
|
||||||
|
|
||||||
|
E2D_DISABLE_COPY(Player);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float volume_;
|
||||||
|
std::map<size_t, Music*> musics_;
|
||||||
|
|
||||||
|
static Player * instance_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Timer;
|
||||||
|
|
||||||
|
// 定时任务
|
||||||
|
class Task :
|
||||||
|
public Ref
|
||||||
{
|
{
|
||||||
std::uniform_int_distribution<T> dist(min, max);
|
friend class Timer;
|
||||||
return dist(Random::GetEngine());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
public:
|
||||||
static T RandomReal(T min, T max)
|
explicit Task(
|
||||||
|
const Function& func, /* 执行函数 */
|
||||||
|
const String& name = L"" /* 任务名称 */
|
||||||
|
);
|
||||||
|
|
||||||
|
explicit Task(
|
||||||
|
const Function& func, /* 执行函数 */
|
||||||
|
float delay, /* 时间间隔(秒) */
|
||||||
|
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
||||||
|
const String& name = L"" /* 任务名称 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 启动任务
|
||||||
|
void Start();
|
||||||
|
|
||||||
|
// 停止任务
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
// 任务是否正在执行
|
||||||
|
bool IsRunning() const;
|
||||||
|
|
||||||
|
// 获取任务名称
|
||||||
|
const String& GetName() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// 执行任务
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
// 任务是否就绪
|
||||||
|
bool IsReady() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool running_;
|
||||||
|
bool stopped_;
|
||||||
|
int run_times_;
|
||||||
|
int total_times_;
|
||||||
|
String name_;
|
||||||
|
Duration delay_;
|
||||||
|
Time last_time_;
|
||||||
|
Function callback_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 定时器
|
||||||
|
class Timer
|
||||||
{
|
{
|
||||||
std::uniform_real_distribution<T> dist(min, max);
|
public:
|
||||||
return dist(Random::GetEngine());
|
// 获取定时器实例
|
||||||
}
|
static Timer * GetInstance();
|
||||||
|
|
||||||
// 获取随机数产生器
|
|
||||||
static std::default_random_engine &GetEngine();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 音乐
|
|
||||||
class Music :
|
|
||||||
public Ref
|
|
||||||
{
|
|
||||||
friend class VoiceCallback;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Music();
|
|
||||||
|
|
||||||
explicit Music(
|
|
||||||
const e2d::String& file_path /* 音乐文件路径 */
|
|
||||||
);
|
|
||||||
|
|
||||||
explicit Music(
|
|
||||||
const Resource& res /* 音乐资源 */
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual ~Music();
|
|
||||||
|
|
||||||
// 打开音乐文件
|
|
||||||
bool Open(
|
|
||||||
const e2d::String& file_path /* 音乐文件路径 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 打开音乐资源
|
|
||||||
bool Open(
|
|
||||||
const Resource& res
|
|
||||||
);
|
|
||||||
|
|
||||||
// 播放
|
|
||||||
bool Play(
|
|
||||||
int loopCount = 0
|
|
||||||
);
|
|
||||||
|
|
||||||
// 暂停
|
|
||||||
void Pause();
|
|
||||||
|
|
||||||
// 继续
|
|
||||||
void Resume();
|
|
||||||
|
|
||||||
// 停止
|
|
||||||
void Stop();
|
|
||||||
|
|
||||||
// 关闭并回收资源
|
|
||||||
void Close();
|
|
||||||
|
|
||||||
// 是否正在播放
|
|
||||||
bool IsPlaying() const;
|
|
||||||
|
|
||||||
// 设置音量
|
|
||||||
bool SetVolume(
|
|
||||||
float volume
|
|
||||||
);
|
|
||||||
|
|
||||||
// 设置播放结束时的执行函数
|
|
||||||
void SetCallbackOnEnd(
|
|
||||||
const Function& func
|
|
||||||
);
|
|
||||||
|
|
||||||
// 设置循环播放中每一次播放结束时的执行函数
|
|
||||||
void SetCallbackOnLoopEnd(
|
|
||||||
const Function& func
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取 IXAudio2SourceVoice 对象
|
|
||||||
IXAudio2SourceVoice * GetSourceVoice() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool _readMMIO();
|
|
||||||
|
|
||||||
bool _resetFile();
|
|
||||||
|
|
||||||
bool _read(
|
|
||||||
BYTE* buffer,
|
|
||||||
DWORD size_to_read
|
|
||||||
);
|
|
||||||
|
|
||||||
bool _findMediaFileCch(
|
|
||||||
wchar_t* dest_path,
|
|
||||||
int cch_dest,
|
|
||||||
const wchar_t * file_name
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool opened_;
|
|
||||||
DWORD size_;
|
|
||||||
CHAR* buffer_;
|
|
||||||
BYTE* wave_data_;
|
|
||||||
HMMIO hmmio_;
|
|
||||||
MMCKINFO ck_;
|
|
||||||
MMCKINFO ck_riff_;
|
|
||||||
WAVEFORMATEX* wfx_;
|
|
||||||
VoiceCallback callback_;
|
|
||||||
IXAudio2SourceVoice* voice_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 音乐播放器
|
|
||||||
class Player
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 获取播放器实例
|
|
||||||
static Player * GetInstance();
|
|
||||||
|
|
||||||
// 销毁实例
|
|
||||||
static void DestroyInstance();
|
|
||||||
|
|
||||||
// 预加载音乐资源
|
|
||||||
bool Preload(
|
|
||||||
const String& file_path /* 音乐文件路径 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 播放音乐
|
|
||||||
bool Play(
|
|
||||||
const String& file_path, /* 音乐文件路径 */
|
|
||||||
int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 暂停音乐
|
|
||||||
void Pause(
|
|
||||||
const String& file_path /* 音乐文件路径 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 继续播放音乐
|
|
||||||
void Resume(
|
|
||||||
const String& file_path /* 音乐文件路径 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 停止音乐
|
|
||||||
void Stop(
|
|
||||||
const String& file_path /* 音乐文件路径 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取音乐播放状态
|
|
||||||
bool IsPlaying(
|
|
||||||
const String& file_path /* 音乐文件路径 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 预加载音乐资源
|
|
||||||
bool Preload(
|
|
||||||
const Resource& res /* 音乐资源 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 播放音乐
|
|
||||||
bool Play(
|
|
||||||
const Resource& res, /* 音乐资源 */
|
|
||||||
int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 暂停音乐
|
|
||||||
void Pause(
|
|
||||||
const Resource& res /* 音乐资源 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 继续播放音乐
|
|
||||||
void Resume(
|
|
||||||
const Resource& res /* 音乐资源 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 停止音乐
|
|
||||||
void Stop(
|
|
||||||
const Resource& res /* 音乐资源 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取音乐播放状态
|
|
||||||
bool IsPlaying(
|
|
||||||
const Resource& res /* 音乐资源 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取音量
|
|
||||||
float GetVolume();
|
|
||||||
|
|
||||||
// 设置音量
|
|
||||||
void SetVolume(
|
|
||||||
float volume /* 音量范围为 -224 ~ 224,0 是静音,1 是正常音量 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 暂停所有音乐
|
|
||||||
void PauseAll();
|
|
||||||
|
|
||||||
// 继续播放所有音乐
|
|
||||||
void ResumeAll();
|
|
||||||
|
|
||||||
// 停止所有音乐
|
|
||||||
void StopAll();
|
|
||||||
|
|
||||||
// 清空音乐缓存
|
|
||||||
void ClearCache();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Player();
|
|
||||||
|
|
||||||
~Player();
|
|
||||||
|
|
||||||
E2D_DISABLE_COPY(Player);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
float volume_;
|
|
||||||
std::map<size_t, Music*> musics_;
|
|
||||||
|
|
||||||
static Player * instance_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// 添加任务
|
||||||
|
void AddTask(
|
||||||
|
Task * task
|
||||||
|
);
|
||||||
|
|
||||||
class Timer;
|
// 启动任务
|
||||||
|
void StartTasks(
|
||||||
|
const String& task_name
|
||||||
|
);
|
||||||
|
|
||||||
// 定时任务
|
// 停止任务
|
||||||
class Task :
|
void StopTasks(
|
||||||
public Ref
|
const String& task_name
|
||||||
{
|
);
|
||||||
friend class Timer;
|
|
||||||
|
|
||||||
public:
|
// 移除任务
|
||||||
explicit Task(
|
void RemoveTasks(
|
||||||
const Function& func, /* 执行函数 */
|
const String& task_name
|
||||||
const String& name = L"" /* 任务名称 */
|
);
|
||||||
);
|
|
||||||
|
|
||||||
explicit Task(
|
// 启动所有任务
|
||||||
const Function& func, /* 执行函数 */
|
void StartAllTasks();
|
||||||
float delay, /* 时间间隔(秒) */
|
|
||||||
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
|
||||||
const String& name = L"" /* 任务名称 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 启动任务
|
// 停止所有任务
|
||||||
void Start();
|
void StopAllTasks();
|
||||||
|
|
||||||
// 停止任务
|
// 移除所有任务
|
||||||
void Stop();
|
void RemoveAllTasks();
|
||||||
|
|
||||||
// 任务是否正在执行
|
// 更新定时器
|
||||||
bool IsRunning() const;
|
void Update();
|
||||||
|
|
||||||
// 获取任务名称
|
// 刷新所有任务计时
|
||||||
const String& GetName() const;
|
void UpdateTime();
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
// 执行任务
|
Timer();
|
||||||
void Update();
|
|
||||||
|
|
||||||
// 任务是否就绪
|
~Timer();
|
||||||
bool IsReady() const;
|
|
||||||
|
|
||||||
protected:
|
E2D_DISABLE_COPY(Timer);
|
||||||
bool running_;
|
|
||||||
bool stopped_;
|
|
||||||
int run_times_;
|
|
||||||
int total_times_;
|
|
||||||
String name_;
|
|
||||||
Duration delay_;
|
|
||||||
Time last_time_;
|
|
||||||
Function callback_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<Task*> tasks_;
|
||||||
|
};
|
||||||
|
|
||||||
// 定时器
|
|
||||||
class Timer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 获取定时器实例
|
|
||||||
static Timer * GetInstance();
|
|
||||||
|
|
||||||
// 添加任务
|
// 数据管理工具
|
||||||
void AddTask(
|
class Data
|
||||||
Task * task
|
{
|
||||||
);
|
public:
|
||||||
|
Data(
|
||||||
|
const String& key, /* 键值 */
|
||||||
|
const String& field = L"Defalut" /* 字段名称 */
|
||||||
|
);
|
||||||
|
|
||||||
// 启动任务
|
// 该数据是否存在
|
||||||
void StartTasks(
|
bool Exists() const;
|
||||||
const String& task_name
|
|
||||||
);
|
|
||||||
|
|
||||||
// 停止任务
|
// 保存 int 类型的值
|
||||||
void StopTasks(
|
bool SaveInt(
|
||||||
const String& task_name
|
int value
|
||||||
);
|
);
|
||||||
|
|
||||||
// 移除任务
|
// 保存 float 类型的值
|
||||||
void RemoveTasks(
|
bool SaveFloat(
|
||||||
const String& task_name
|
float value
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动所有任务
|
// 保存 double 类型的值
|
||||||
void StartAllTasks();
|
bool SaveDouble(
|
||||||
|
double value
|
||||||
|
);
|
||||||
|
|
||||||
// 停止所有任务
|
// 保存 bool 类型的值
|
||||||
void StopAllTasks();
|
bool SaveBool(
|
||||||
|
bool value
|
||||||
|
);
|
||||||
|
|
||||||
// 移除所有任务
|
// 保存 String 类型的值
|
||||||
void RemoveAllTasks();
|
bool SaveString(
|
||||||
|
const String& value
|
||||||
|
);
|
||||||
|
|
||||||
// 更新定时器
|
// 获取 int 类型的值
|
||||||
void Update();
|
int GetInt() const;
|
||||||
|
|
||||||
// 刷新所有任务计时
|
// 获取 float 类型的值
|
||||||
void UpdateTime();
|
float GetFloat() const;
|
||||||
|
|
||||||
private:
|
// 获取 double 类型的值
|
||||||
Timer();
|
double GetDouble() const;
|
||||||
|
|
||||||
~Timer();
|
// 获取 bool 类型的值
|
||||||
|
bool GetBool() const;
|
||||||
|
|
||||||
E2D_DISABLE_COPY(Timer);
|
// 获取 字符串 类型的值
|
||||||
|
String GetString();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
std::vector<Task*> tasks_;
|
String key_;
|
||||||
};
|
String field_;
|
||||||
|
const String& data_path_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// 数据管理工具
|
// 文件
|
||||||
class Data
|
class File
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Data(
|
File();
|
||||||
const String& key, /* 键值 */
|
|
||||||
const String& field = L"Defalut" /* 字段名称 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 该数据是否存在
|
File(
|
||||||
bool Exists() const;
|
const String& file_name
|
||||||
|
);
|
||||||
|
|
||||||
// 保存 int 类型的值
|
virtual ~File();
|
||||||
bool SaveInt(
|
|
||||||
int value
|
|
||||||
);
|
|
||||||
|
|
||||||
// 保存 float 类型的值
|
// 打开文件
|
||||||
bool SaveFloat(
|
bool Open(
|
||||||
float value
|
const String& file_name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 保存 double 类型的值
|
|
||||||
bool SaveDouble(
|
|
||||||
double value
|
|
||||||
);
|
|
||||||
|
|
||||||
// 保存 bool 类型的值
|
|
||||||
bool SaveBool(
|
|
||||||
bool value
|
|
||||||
);
|
|
||||||
|
|
||||||
// 保存 String 类型的值
|
|
||||||
bool SaveString(
|
|
||||||
const String& value
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取 int 类型的值
|
|
||||||
int GetInt() const;
|
|
||||||
|
|
||||||
// 获取 float 类型的值
|
// 文件或文件夹是否存在
|
||||||
float GetFloat() const;
|
bool Exists() const;
|
||||||
|
|
||||||
// 获取 double 类型的值
|
// 是否是文件夹
|
||||||
double GetDouble() const;
|
bool IsFolder() const;
|
||||||
|
|
||||||
// 获取 bool 类型的值
|
// 删除文件
|
||||||
bool GetBool() const;
|
bool Delete();
|
||||||
|
|
||||||
// 获取 字符串 类型的值
|
// 获取文件路径
|
||||||
String GetString();
|
const String& GetPath() const;
|
||||||
|
|
||||||
protected:
|
// 获取文件扩展名
|
||||||
String key_;
|
String GetExtension() const;
|
||||||
String field_;
|
|
||||||
const String& data_path_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// 释放资源到临时文件目录
|
||||||
|
static File Extract(
|
||||||
|
int resource_name, /* 资源名称 */
|
||||||
|
const String& resource_type, /* 资源类型 */
|
||||||
|
const String& dest_file_name /* 目标文件名 */
|
||||||
|
);
|
||||||
|
|
||||||
// 文件
|
// 添加文件搜索路径
|
||||||
class File
|
static void AddSearchPath(
|
||||||
{
|
const String& path
|
||||||
public:
|
);
|
||||||
File();
|
|
||||||
|
// 创建文件夹
|
||||||
|
static bool CreateFolder(
|
||||||
|
const String& dir_path /* 文件夹路径 */
|
||||||
|
);
|
||||||
|
|
||||||
File(
|
// 弹出打开文件对话框
|
||||||
const String& file_name
|
static File ShowOpenDialog(
|
||||||
);
|
const String& title = L"打开", /* 对话框标题 */
|
||||||
|
const String& filter = L"" /* 筛选扩展名,例如 "*.jpg;*.jpeg" */
|
||||||
|
);
|
||||||
|
|
||||||
virtual ~File();
|
// 弹出保存文件对话框
|
||||||
|
static File ShowSaveDialog(
|
||||||
|
const String& title = L"保存", /* 对话框标题 */
|
||||||
|
const String& def_file = L"", /* 默认保存的文件名 */
|
||||||
|
const String& def_ext = L"" /* 默认追加的扩展名,例如 "txt" */
|
||||||
|
);
|
||||||
|
|
||||||
// 打开文件
|
protected:
|
||||||
bool Open(
|
DWORD attributes_;
|
||||||
const String& file_name
|
String file_path_;
|
||||||
);
|
|
||||||
|
|
||||||
// 文件或文件夹是否存在
|
static std::list<String> search_paths_;
|
||||||
bool Exists() const;
|
};
|
||||||
|
|
||||||
// 是否是文件夹
|
|
||||||
bool IsFolder() const;
|
|
||||||
|
|
||||||
// 删除文件
|
// 路径
|
||||||
bool Delete();
|
class Path
|
||||||
|
{
|
||||||
|
friend class Game;
|
||||||
|
|
||||||
// 获取文件路径
|
public:
|
||||||
const String& GetPath() const;
|
// 获取数据的默认保存路径
|
||||||
|
static const String& GetDataPath();
|
||||||
|
|
||||||
// 获取文件扩展名
|
// 获取临时文件目录
|
||||||
String GetExtension() const;
|
static const String& GetTemporaryPath();
|
||||||
|
|
||||||
// 释放资源到临时文件目录
|
// 获取 LocalAppData 目录
|
||||||
static File Extract(
|
static const String& GetLocalAppDataPath();
|
||||||
int resource_name, /* 资源名称 */
|
|
||||||
const String& resource_type, /* 资源类型 */
|
|
||||||
const String& dest_file_name /* 目标文件名 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 添加文件搜索路径
|
// 获取当前程序的运行路径
|
||||||
static void AddSearchPath(
|
static const String& GetExeFilePath();
|
||||||
const String& path
|
};
|
||||||
);
|
|
||||||
|
|
||||||
// 创建文件夹
|
|
||||||
static bool CreateFolder(
|
|
||||||
const String& dir_path /* 文件夹路径 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 弹出打开文件对话框
|
|
||||||
static File ShowOpenDialog(
|
|
||||||
const String& title = L"打开", /* 对话框标题 */
|
|
||||||
const String& filter = L"" /* 筛选扩展名,例如 "*.jpg;*.jpeg" */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 弹出保存文件对话框
|
|
||||||
static File ShowSaveDialog(
|
|
||||||
const String& title = L"保存", /* 对话框标题 */
|
|
||||||
const String& def_file = L"", /* 默认保存的文件名 */
|
|
||||||
const String& def_ext = L"" /* 默认追加的扩展名,例如 "txt" */
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
DWORD attributes_;
|
|
||||||
String file_path_;
|
|
||||||
|
|
||||||
static std::list<String> search_paths_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 路径
|
|
||||||
class Path
|
|
||||||
{
|
|
||||||
friend class Game;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// 获取数据的默认保存路径
|
|
||||||
static const String& GetDataPath();
|
|
||||||
|
|
||||||
// 获取临时文件目录
|
|
||||||
static const String& GetTemporaryPath();
|
|
||||||
|
|
||||||
// 获取 LocalAppData 目录
|
|
||||||
static const String& GetLocalAppDataPath();
|
|
||||||
|
|
||||||
// 获取当前程序的运行路径
|
|
||||||
static const String& GetExeFilePath();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -5,145 +5,145 @@ namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
class Scene;
|
class Scene;
|
||||||
|
|
||||||
// 场景过渡
|
// 场景过渡
|
||||||
class Transition :
|
class Transition :
|
||||||
public Ref
|
public Ref
|
||||||
{
|
{
|
||||||
friend class Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Transition(
|
explicit Transition(
|
||||||
Scene* scene,
|
Scene* scene,
|
||||||
float duration
|
float duration
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~Transition();
|
virtual ~Transition();
|
||||||
|
|
||||||
// 场景过渡动画是否结束
|
// 场景过渡动画是否结束
|
||||||
bool IsDone();
|
bool IsDone();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化场景过渡动画
|
// 初始化场景过渡动画
|
||||||
virtual bool Init(
|
virtual bool Init(
|
||||||
Game * game,
|
Game * game,
|
||||||
Scene * prev
|
Scene * prev
|
||||||
);
|
);
|
||||||
|
|
||||||
// 更新场景过渡动画
|
// 更新场景过渡动画
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
|
|
||||||
// 渲染场景过渡动画
|
// 渲染场景过渡动画
|
||||||
virtual void Draw();
|
virtual void Draw();
|
||||||
|
|
||||||
// 停止场景过渡动画
|
// 停止场景过渡动画
|
||||||
virtual void Stop();
|
virtual void Stop();
|
||||||
|
|
||||||
// 重置场景过渡动画
|
// 重置场景过渡动画
|
||||||
virtual void Reset() { };
|
virtual void Reset() { };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool done_;
|
bool done_;
|
||||||
float duration_;
|
float duration_;
|
||||||
float delta_;
|
float delta_;
|
||||||
Time started_;
|
Time started_;
|
||||||
Scene* out_scene_;
|
Scene* out_scene_;
|
||||||
Scene* in_scene_;
|
Scene* in_scene_;
|
||||||
ID2D1Layer * out_layer_;
|
ID2D1Layer * out_layer_;
|
||||||
ID2D1Layer * in_layer_;
|
ID2D1Layer * in_layer_;
|
||||||
D2D1_LAYER_PARAMETERS out_layer_param_;
|
D2D1_LAYER_PARAMETERS out_layer_param_;
|
||||||
D2D1_LAYER_PARAMETERS in_layer_param_;
|
D2D1_LAYER_PARAMETERS in_layer_param_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 淡入淡出过渡
|
// 淡入淡出过渡
|
||||||
class FadeTransition :
|
class FadeTransition :
|
||||||
public Transition
|
public Transition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit FadeTransition(
|
explicit FadeTransition(
|
||||||
Scene* scene, /* 切换的场景 */
|
Scene* scene, /* 切换的场景 */
|
||||||
float duration /* 动画持续时长 */
|
float duration /* 动画持续时长 */
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 更新动画
|
// 更新动画
|
||||||
virtual void Update() override;
|
virtual void Update() override;
|
||||||
|
|
||||||
virtual bool Init(
|
virtual bool Init(
|
||||||
Game * game,
|
Game * game,
|
||||||
Scene * prev
|
Scene * prev
|
||||||
) override;
|
) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 渐变过渡
|
// 渐变过渡
|
||||||
class EmergeTransition :
|
class EmergeTransition :
|
||||||
public Transition
|
public Transition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit EmergeTransition(
|
explicit EmergeTransition(
|
||||||
Scene* scene, /* 切换的场景 */
|
Scene* scene, /* 切换的场景 */
|
||||||
float duration /* 浮现动画持续时长 */
|
float duration /* 浮现动画持续时长 */
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Update() override;
|
virtual void Update() override;
|
||||||
|
|
||||||
virtual bool Init(
|
virtual bool Init(
|
||||||
Game * game,
|
Game * game,
|
||||||
Scene * prev
|
Scene * prev
|
||||||
) override;
|
) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 盒状过渡
|
// 盒状过渡
|
||||||
class BoxTransition :
|
class BoxTransition :
|
||||||
public Transition
|
public Transition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit BoxTransition(
|
explicit BoxTransition(
|
||||||
Scene* scene, /* 切换的场景 */
|
Scene* scene, /* 切换的场景 */
|
||||||
float duration /* 动画持续时长 */
|
float duration /* 动画持续时长 */
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Update() override;
|
virtual void Update() override;
|
||||||
|
|
||||||
virtual bool Init(
|
virtual bool Init(
|
||||||
Game * game,
|
Game * game,
|
||||||
Scene * prev
|
Scene * prev
|
||||||
) override;
|
) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 移入过渡
|
// 移入过渡
|
||||||
class MoveTransition :
|
class MoveTransition :
|
||||||
public Transition
|
public Transition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MoveTransition(
|
explicit MoveTransition(
|
||||||
Scene* scene, /* 切换的场景 */
|
Scene* scene, /* 切换的场景 */
|
||||||
float moveDuration, /* 场景移动动画持续时长 */
|
float moveDuration, /* 场景移动动画持续时长 */
|
||||||
Direction direction = Direction::Left /* 场景移动方向 */
|
Direction direction = Direction::Left /* 场景移动方向 */
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Update() override;
|
virtual void Update() override;
|
||||||
|
|
||||||
virtual bool Init(
|
virtual bool Init(
|
||||||
Game * game,
|
Game * game,
|
||||||
Scene * prev
|
Scene * prev
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
virtual void Reset() override;
|
virtual void Reset() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Direction direction_;
|
Direction direction_;
|
||||||
Point pos_delta_;
|
Point pos_delta_;
|
||||||
Point start_pos_;
|
Point start_pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -19,16 +19,17 @@
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\core\e2dnode.h" />
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
<ClInclude Include="..\..\core\e2daction.h" />
|
<ClInclude Include="..\..\core\e2daction.h" />
|
||||||
<ClInclude Include="..\..\core\e2dcommon.h" />
|
<ClInclude Include="..\..\core\e2dutil.h" />
|
||||||
<ClInclude Include="..\..\core\e2dcomponent.h" />
|
<ClInclude Include="..\..\core\e2dcomponent.h" />
|
||||||
<ClInclude Include="..\..\core\e2devent.h" />
|
<ClInclude Include="..\..\core\e2devent.h" />
|
||||||
<ClInclude Include="..\..\core\e2dimpl.h" />
|
<ClInclude Include="..\..\core\e2dimpl.h" />
|
||||||
<ClInclude Include="..\..\core\e2dmodule.h" />
|
<ClInclude Include="..\..\core\e2dmodule.h" />
|
||||||
<ClInclude Include="..\..\core\e2dmacros.h" />
|
<ClInclude Include="..\..\core\e2dmacros.h" />
|
||||||
<ClInclude Include="..\..\core\e2dmanager.h" />
|
<ClInclude Include="..\..\core\e2dmanager.h" />
|
||||||
<ClInclude Include="..\..\core\e2dutil.h" />
|
<ClInclude Include="..\..\core\e2dtool.h" />
|
||||||
<ClInclude Include="..\..\core\e2dtransition.h" />
|
<ClInclude Include="..\..\core\e2dtransition.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -80,14 +81,14 @@
|
||||||
<ClCompile Include="..\..\core\Event\KeyEvent.cpp" />
|
<ClCompile Include="..\..\core\Event\KeyEvent.cpp" />
|
||||||
<ClCompile Include="..\..\core\Event\MouseEvent.cpp" />
|
<ClCompile Include="..\..\core\Event\MouseEvent.cpp" />
|
||||||
<ClCompile Include="..\..\core\Manager\CollisionManager.cpp" />
|
<ClCompile Include="..\..\core\Manager\CollisionManager.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Button.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\Node\Canvas.cpp" />
|
<ClCompile Include="..\..\core\Node\Canvas.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Scene.cpp" />
|
<ClCompile Include="..\..\core\Node\Scene.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Menu.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\Node\Node.cpp" />
|
<ClCompile Include="..\..\core\Node\Node.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Sprite.cpp" />
|
<ClCompile Include="..\..\core\Node\Sprite.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Text.cpp" />
|
<ClCompile Include="..\..\core\Node\Text.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\ToggleButton.cpp" />
|
<ClCompile Include="..\..\core\Component\Button.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\Component\ToggleButton.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\Component\Menu.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Music.cpp" />
|
<ClCompile Include="..\..\core\Tool\Music.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,16 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
<ClInclude Include="..\..\core\e2daction.h" />
|
<ClInclude Include="..\..\core\e2daction.h" />
|
||||||
<ClInclude Include="..\..\core\e2dcommon.h" />
|
|
||||||
<ClInclude Include="..\..\core\e2dmacros.h" />
|
<ClInclude Include="..\..\core\e2dmacros.h" />
|
||||||
<ClInclude Include="..\..\core\e2dmanager.h" />
|
<ClInclude Include="..\..\core\e2dmanager.h" />
|
||||||
<ClInclude Include="..\..\core\e2dtransition.h" />
|
<ClInclude Include="..\..\core\e2dtransition.h" />
|
||||||
<ClInclude Include="..\..\core\e2devent.h" />
|
<ClInclude Include="..\..\core\e2devent.h" />
|
||||||
<ClInclude Include="..\..\core\e2dutil.h" />
|
|
||||||
<ClInclude Include="..\..\core\e2dmodule.h" />
|
<ClInclude Include="..\..\core\e2dmodule.h" />
|
||||||
<ClInclude Include="..\..\core\e2dcomponent.h" />
|
<ClInclude Include="..\..\core\e2dcomponent.h" />
|
||||||
<ClInclude Include="..\..\core\e2dimpl.h" />
|
<ClInclude Include="..\..\core\e2dimpl.h" />
|
||||||
|
<ClInclude Include="..\..\core\e2dnode.h" />
|
||||||
|
<ClInclude Include="..\..\core\e2dtool.h" />
|
||||||
|
<ClInclude Include="..\..\core\e2dutil.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\core\Action\Action.cpp">
|
<ClCompile Include="..\..\core\Action\Action.cpp">
|
||||||
|
|
@ -154,12 +155,6 @@
|
||||||
<ClCompile Include="..\..\core\Custom\VoiceCallback.cpp">
|
<ClCompile Include="..\..\core\Custom\VoiceCallback.cpp">
|
||||||
<Filter>Custom</Filter>
|
<Filter>Custom</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Node\Button.cpp">
|
|
||||||
<Filter>Node</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Node\Menu.cpp">
|
|
||||||
<Filter>Node</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Node\Node.cpp">
|
<ClCompile Include="..\..\core\Node\Node.cpp">
|
||||||
<Filter>Node</Filter>
|
<Filter>Node</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -169,9 +164,6 @@
|
||||||
<ClCompile Include="..\..\core\Node\Text.cpp">
|
<ClCompile Include="..\..\core\Node\Text.cpp">
|
||||||
<Filter>Node</Filter>
|
<Filter>Node</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Node\ToggleButton.cpp">
|
|
||||||
<Filter>Node</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Tool\Data.cpp">
|
<ClCompile Include="..\..\core\Tool\Data.cpp">
|
||||||
<Filter>Tool</Filter>
|
<Filter>Tool</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -244,5 +236,14 @@
|
||||||
<ClCompile Include="..\..\core\Action\Callback.cpp">
|
<ClCompile Include="..\..\core\Action\Callback.cpp">
|
||||||
<Filter>Action</Filter>
|
<Filter>Action</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Component\Button.cpp">
|
||||||
|
<Filter>Component</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Component\Menu.cpp">
|
||||||
|
<Filter>Component</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Component\ToggleButton.cpp">
|
||||||
|
<Filter>Component</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -163,16 +163,17 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\core\e2dnode.h" />
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
<ClInclude Include="..\..\core\e2daction.h" />
|
<ClInclude Include="..\..\core\e2daction.h" />
|
||||||
<ClInclude Include="..\..\core\e2dcommon.h" />
|
<ClInclude Include="..\..\core\e2dutil.h" />
|
||||||
<ClInclude Include="..\..\core\e2dcomponent.h" />
|
<ClInclude Include="..\..\core\e2dcomponent.h" />
|
||||||
<ClInclude Include="..\..\core\e2devent.h" />
|
<ClInclude Include="..\..\core\e2devent.h" />
|
||||||
<ClInclude Include="..\..\core\e2dimpl.h" />
|
<ClInclude Include="..\..\core\e2dimpl.h" />
|
||||||
<ClInclude Include="..\..\core\e2dmodule.h" />
|
<ClInclude Include="..\..\core\e2dmodule.h" />
|
||||||
<ClInclude Include="..\..\core\e2dmacros.h" />
|
<ClInclude Include="..\..\core\e2dmacros.h" />
|
||||||
<ClInclude Include="..\..\core\e2dmanager.h" />
|
<ClInclude Include="..\..\core\e2dmanager.h" />
|
||||||
<ClInclude Include="..\..\core\e2dutil.h" />
|
<ClInclude Include="..\..\core\e2dtool.h" />
|
||||||
<ClInclude Include="..\..\core\e2dtransition.h" />
|
<ClInclude Include="..\..\core\e2dtransition.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -224,14 +225,14 @@
|
||||||
<ClCompile Include="..\..\core\Event\KeyEvent.cpp" />
|
<ClCompile Include="..\..\core\Event\KeyEvent.cpp" />
|
||||||
<ClCompile Include="..\..\core\Event\MouseEvent.cpp" />
|
<ClCompile Include="..\..\core\Event\MouseEvent.cpp" />
|
||||||
<ClCompile Include="..\..\core\Manager\CollisionManager.cpp" />
|
<ClCompile Include="..\..\core\Manager\CollisionManager.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Button.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\Node\Canvas.cpp" />
|
<ClCompile Include="..\..\core\Node\Canvas.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Scene.cpp" />
|
<ClCompile Include="..\..\core\Node\Scene.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Menu.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\Node\Node.cpp" />
|
<ClCompile Include="..\..\core\Node\Node.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Sprite.cpp" />
|
<ClCompile Include="..\..\core\Node\Sprite.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\Text.cpp" />
|
<ClCompile Include="..\..\core\Node\Text.cpp" />
|
||||||
<ClCompile Include="..\..\core\Node\ToggleButton.cpp" />
|
<ClCompile Include="..\..\core\Component\Button.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\Component\ToggleButton.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\Component\Menu.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Music.cpp" />
|
<ClCompile Include="..\..\core\Tool\Music.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,16 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
<ClInclude Include="..\..\core\e2daction.h" />
|
<ClInclude Include="..\..\core\e2daction.h" />
|
||||||
<ClInclude Include="..\..\core\e2dcommon.h" />
|
|
||||||
<ClInclude Include="..\..\core\e2dmacros.h" />
|
<ClInclude Include="..\..\core\e2dmacros.h" />
|
||||||
<ClInclude Include="..\..\core\e2dmanager.h" />
|
<ClInclude Include="..\..\core\e2dmanager.h" />
|
||||||
<ClInclude Include="..\..\core\e2dtransition.h" />
|
<ClInclude Include="..\..\core\e2dtransition.h" />
|
||||||
<ClInclude Include="..\..\core\e2devent.h" />
|
<ClInclude Include="..\..\core\e2devent.h" />
|
||||||
<ClInclude Include="..\..\core\e2dutil.h" />
|
|
||||||
<ClInclude Include="..\..\core\e2dmodule.h" />
|
<ClInclude Include="..\..\core\e2dmodule.h" />
|
||||||
<ClInclude Include="..\..\core\e2dcomponent.h" />
|
<ClInclude Include="..\..\core\e2dcomponent.h" />
|
||||||
<ClInclude Include="..\..\core\e2dimpl.h" />
|
<ClInclude Include="..\..\core\e2dimpl.h" />
|
||||||
|
<ClInclude Include="..\..\core\e2dnode.h" />
|
||||||
|
<ClInclude Include="..\..\core\e2dtool.h" />
|
||||||
|
<ClInclude Include="..\..\core\e2dutil.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\core\Action\Action.cpp">
|
<ClCompile Include="..\..\core\Action\Action.cpp">
|
||||||
|
|
@ -154,12 +155,6 @@
|
||||||
<ClCompile Include="..\..\core\Custom\VoiceCallback.cpp">
|
<ClCompile Include="..\..\core\Custom\VoiceCallback.cpp">
|
||||||
<Filter>Custom</Filter>
|
<Filter>Custom</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Node\Button.cpp">
|
|
||||||
<Filter>Node</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Node\Menu.cpp">
|
|
||||||
<Filter>Node</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Node\Node.cpp">
|
<ClCompile Include="..\..\core\Node\Node.cpp">
|
||||||
<Filter>Node</Filter>
|
<Filter>Node</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -169,9 +164,6 @@
|
||||||
<ClCompile Include="..\..\core\Node\Text.cpp">
|
<ClCompile Include="..\..\core\Node\Text.cpp">
|
||||||
<Filter>Node</Filter>
|
<Filter>Node</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Node\ToggleButton.cpp">
|
|
||||||
<Filter>Node</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Tool\Data.cpp">
|
<ClCompile Include="..\..\core\Tool\Data.cpp">
|
||||||
<Filter>Tool</Filter>
|
<Filter>Tool</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -244,5 +236,14 @@
|
||||||
<ClCompile Include="..\..\core\Action\Callback.cpp">
|
<ClCompile Include="..\..\core\Action\Callback.cpp">
|
||||||
<Filter>Action</Filter>
|
<Filter>Action</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Component\Button.cpp">
|
||||||
|
<Filter>Component</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Component\Menu.cpp">
|
||||||
|
<Filter>Component</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Component\ToggleButton.cpp">
|
||||||
|
<Filter>Component</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Loading…
Reference in New Issue