增加Exception类
This commit is contained in:
parent
dfd49588cd
commit
7499e1af7f
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
e2d::Animate::Animate()
|
e2d::Animate::Animate()
|
||||||
: _frameIndex(0)
|
: _frameIndex(0)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
e2d::JumpBy::JumpBy(double duration, const Vector & vec, double height, int jumps)
|
e2d::JumpBy::JumpBy(double duration, const Vector & vec, double height, int jumps)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
e2d::JumpTo::JumpTo(double duration, const Point & pos, double height, int jumps)
|
e2d::JumpTo::JumpTo(double duration, const Point & pos, double height, int jumps)
|
||||||
: JumpBy(duration, Point(), height, jumps)
|
: JumpBy(duration, Point(), height, jumps)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::MoveBy::MoveBy(double duration, Vector vector)
|
e2d::MoveBy::MoveBy(double duration, Vector vector)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
e2d::MoveTo::MoveTo(double duration, Point pos)
|
e2d::MoveTo::MoveTo(double duration, Point pos)
|
||||||
: MoveBy(duration, Vector())
|
: MoveBy(duration, Vector())
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::OpacityBy::OpacityBy(double duration, double opacity)
|
e2d::OpacityBy::OpacityBy(double duration, double opacity)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::OpacityTo::OpacityTo(double duration, double opacity)
|
e2d::OpacityTo::OpacityTo(double duration, double opacity)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::RotateBy::RotateBy(double duration, double rotation)
|
e2d::RotateBy::RotateBy(double duration, double rotation)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::RotateTo::RotateTo(double duration, double rotation)
|
e2d::RotateTo::RotateTo(double duration, double rotation)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::ScaleBy::ScaleBy(double duration, double scale)
|
e2d::ScaleBy::ScaleBy(double duration, double scale)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
e2d::ScaleTo::ScaleTo(double duration, double scale)
|
e2d::ScaleTo::ScaleTo(double duration, double scale)
|
||||||
: ScaleBy(duration, 0, 0)
|
: ScaleBy(duration, 0, 0)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
|
|
||||||
// 控制游戏终止
|
// 控制游戏终止
|
||||||
static bool s_bEndGame = false;
|
static bool s_bEndGame = true;
|
||||||
// 控制游戏暂停
|
// 控制游戏暂停
|
||||||
static bool s_bPaused = false;
|
static bool s_bPaused = false;
|
||||||
// 是否进行过初始化
|
// 是否进行过初始化
|
||||||
|
|
@ -127,6 +127,8 @@ int e2d::Game::start(bool autoRelease/* true */)
|
||||||
// 初始化计时
|
// 初始化计时
|
||||||
Time::__init();
|
Time::__init();
|
||||||
|
|
||||||
|
s_bEndGame = false;
|
||||||
|
|
||||||
while (!s_bEndGame)
|
while (!s_bEndGame)
|
||||||
{
|
{
|
||||||
// 处理窗口消息
|
// 处理窗口消息
|
||||||
|
|
@ -154,6 +156,8 @@ int e2d::Game::start(bool autoRelease/* true */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_bEndGame = true;
|
||||||
|
|
||||||
if (autoRelease)
|
if (autoRelease)
|
||||||
{
|
{
|
||||||
Game::destroy();
|
Game::destroy();
|
||||||
|
|
@ -178,11 +182,12 @@ void e2d::Game::resume()
|
||||||
|
|
||||||
void e2d::Game::reset()
|
void e2d::Game::reset()
|
||||||
{
|
{
|
||||||
// 刷新当前时间
|
if (s_bInitialized && !s_bEndGame)
|
||||||
Time::__reset();
|
{
|
||||||
// 重置动作和定时器
|
Time::__reset();
|
||||||
ActionManager::__resetAll();
|
ActionManager::__resetAll();
|
||||||
Timer::__resetAll();
|
Timer::__resetAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Game::isPaused()
|
bool e2d::Game::isPaused()
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,11 @@
|
||||||
|
|
||||||
typedef std::pair<UINT, UINT> HashPair;
|
typedef std::pair<UINT, UINT> HashPair;
|
||||||
|
|
||||||
// 监听器容器
|
static std::vector<e2d::Listener*> s_vListeners; // 监听器容器
|
||||||
static std::vector<e2d::Listener*> s_vListeners;
|
static bool s_bCollisionEnable = false; // 碰撞触发状态
|
||||||
// 碰撞触发状态
|
static e2d::Node * s_pActiveNode = nullptr; // 主动碰撞体
|
||||||
static bool s_bCollisionEnable = false;
|
static e2d::Node * s_pPassiveNode = nullptr; // 被动碰撞体
|
||||||
static e2d::Node * s_pActiveNode = nullptr;
|
static std::set<HashPair> s_sCollisionList; // 碰撞映射
|
||||||
static e2d::Node * s_pPassiveNode = nullptr;
|
|
||||||
static std::set<HashPair> s_sCollisionList;
|
|
||||||
|
|
||||||
|
|
||||||
void e2d::Collision::addName(const String & name1, const String & name2)
|
void e2d::Collision::addName(const String & name1, const String & name2)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ e2d::Scene::Scene()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: 抛出一个异常
|
throw Exception(L"场景根节点构造失败!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include "..\e2dcustom.h"
|
||||||
|
|
||||||
|
|
||||||
|
e2d::Exception::Exception()
|
||||||
|
: _message()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Exception::Exception(String message)
|
||||||
|
: _message(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Exception::Exception(Exception const& other)
|
||||||
|
: _message(other._message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Exception& e2d::Exception::operator=(Exception const& other)
|
||||||
|
{
|
||||||
|
if (this == &other)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_message = other._message;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Exception::~Exception()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::String e2d::Exception::msg() const
|
||||||
|
{
|
||||||
|
return _message;
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "..\e2dmanager.h"
|
#include "..\e2dmanager.h"
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
#include "..\e2dnode.h"
|
||||||
|
|
||||||
static std::vector<e2d::Action*> s_vActions;
|
static std::vector<e2d::Action*> s_vActions;
|
||||||
static std::vector<e2d::Action*> s_vRunningActions;
|
static std::vector<e2d::Action*> s_vRunningActions;
|
||||||
|
|
|
||||||
|
|
@ -596,13 +596,17 @@ void e2d::Node::addChild(Node * child, int order /* = 0 */)
|
||||||
|
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
// TODO: 抛出一个异常
|
if (child->_parent != nullptr)
|
||||||
ASSERT(child->_parent == nullptr, "Node already added. It can't be added again!");
|
{
|
||||||
|
throw Exception(L"节点已有父节点, 不能再添加到其他节点!");
|
||||||
|
}
|
||||||
|
|
||||||
for (Node * parent = this; parent != nullptr; parent = parent->getParent())
|
for (Node * parent = this; parent != nullptr; parent = parent->getParent())
|
||||||
{
|
{
|
||||||
// TODO: 抛出一个异常
|
if (child == parent)
|
||||||
ASSERT(child != parent, "A Node cannot be the child of his own children!");
|
{
|
||||||
|
throw Exception(L"一个节点不能同时是另一个节点的父节点和子节点!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_children.push_back(child);
|
_children.push_back(child);
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,26 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "e2dnode.h"
|
#include "e2dcommon.h"
|
||||||
|
#include "e2dbase.h"
|
||||||
|
|
||||||
namespace e2d
|
namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class ActionManager;
|
class Node;
|
||||||
class Loop;
|
class Loop;
|
||||||
class Sequence;
|
class Sequence;
|
||||||
class Spawn;
|
class Spawn;
|
||||||
|
class ActionManager;
|
||||||
|
|
||||||
|
|
||||||
// 基础动作
|
// 基础动作
|
||||||
class Action :
|
class Action :
|
||||||
public Object
|
public Object
|
||||||
{
|
{
|
||||||
friend ActionManager;
|
friend class ActionManager;
|
||||||
friend Loop;
|
friend class Loop;
|
||||||
friend Sequence;
|
friend class Sequence;
|
||||||
friend Spawn;
|
friend class Spawn;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Action();
|
Action();
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public:
|
||||||
// 窗口控制
|
// 窗口控制
|
||||||
class Window
|
class Window
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 鼠标指针样式
|
// 鼠标指针样式
|
||||||
|
|
@ -147,7 +147,7 @@ private:
|
||||||
// 时间控制
|
// 时间控制
|
||||||
class Time
|
class Time
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 获取上一帧与当前帧的时间间隔(秒)
|
// 获取上一帧与当前帧的时间间隔(秒)
|
||||||
|
|
@ -188,7 +188,7 @@ class Listener;
|
||||||
// 输入控制
|
// 输入控制
|
||||||
class Input
|
class Input
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 鼠标键值
|
// 鼠标键值
|
||||||
|
|
@ -375,8 +375,8 @@ private:
|
||||||
// 渲染器
|
// 渲染器
|
||||||
class Renderer
|
class Renderer
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
friend Window;
|
friend class Window;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 获取背景色
|
// 获取背景色
|
||||||
|
|
@ -437,8 +437,8 @@ private:
|
||||||
// 垃圾回收装置
|
// 垃圾回收装置
|
||||||
class GC
|
class GC
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
friend Object;
|
friend class Object;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 创建可自动回收内存的对象
|
// 创建可自动回收内存的对象
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ class ColliderManager;
|
||||||
// 碰撞事件
|
// 碰撞事件
|
||||||
class Collision
|
class Collision
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
friend ColliderManager;
|
friend class ColliderManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 添加可互相碰撞物体的名称
|
// 添加可互相碰撞物体的名称
|
||||||
|
|
@ -123,8 +123,8 @@ private:
|
||||||
class Collider :
|
class Collider :
|
||||||
public Object
|
public Object
|
||||||
{
|
{
|
||||||
friend ColliderManager;
|
friend class ColliderManager;
|
||||||
friend Node;
|
friend class Node;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 碰撞体类别
|
// 碰撞体类别
|
||||||
|
|
|
||||||
|
|
@ -227,8 +227,8 @@ public:
|
||||||
String operator+ (const wchar_t *);
|
String operator+ (const wchar_t *);
|
||||||
|
|
||||||
// ÓÑÔªÔËËã·û
|
// ÓÑÔªÔËËã·û
|
||||||
friend String operator+ (const char *, const String &);
|
friend class String operator+ (const char *, const String &);
|
||||||
friend String operator+ (const wchar_t*, const String &);
|
friend class String operator+ (const wchar_t*, const String &);
|
||||||
|
|
||||||
// ÀàÐÍת»»²Ù×÷·û
|
// ÀàÐÍת»»²Ù×÷·û
|
||||||
operator const wchar_t* () const;
|
operator const wchar_t* () const;
|
||||||
|
|
@ -260,11 +260,11 @@ public:
|
||||||
// ÆäËûÔËËã·û
|
// ÆäËûÔËËã·û
|
||||||
wchar_t& operator[] (int);
|
wchar_t& operator[] (int);
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream &, const String &);
|
friend class std::ostream& operator<< (std::ostream &, const String &);
|
||||||
friend std::wostream& operator<< (std::wostream &, const String &);
|
friend class std::wostream& operator<< (std::wostream &, const String &);
|
||||||
|
|
||||||
friend std::istream& operator>> (std::istream &, String &);
|
friend class std::istream& operator>> (std::istream &, String &);
|
||||||
friend std::wistream& operator>> (std::wistream &, String &);
|
friend class std::wistream& operator>> (std::wistream &, String &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::wstring _str;
|
std::wstring _str;
|
||||||
|
|
@ -571,8 +571,8 @@ class Transition;
|
||||||
class Scene :
|
class Scene :
|
||||||
public Object
|
public Object
|
||||||
{
|
{
|
||||||
friend SceneManager;
|
friend class SceneManager;
|
||||||
friend Transition;
|
friend class Transition;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Scene();
|
Scene();
|
||||||
|
|
|
||||||
298
core/e2dcustom.h
298
core/e2dcustom.h
|
|
@ -4,156 +4,182 @@
|
||||||
|
|
||||||
namespace e2d
|
namespace e2d
|
||||||
{
|
{
|
||||||
template<class Interface>
|
|
||||||
inline void SafeRelease(Interface*& p)
|
|
||||||
|
template<class Interface>
|
||||||
|
inline void SafeRelease(Interface*& p)
|
||||||
|
{
|
||||||
|
if (p != nullptr)
|
||||||
{
|
{
|
||||||
if (p != nullptr)
|
p->Release();
|
||||||
{
|
p = nullptr;
|
||||||
p->Release();
|
|
||||||
p = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
class Music;
|
|
||||||
|
|
||||||
// ÒôÔ´»Øµ÷
|
|
||||||
class VoiceCallback
|
|
||||||
: public IXAudio2VoiceCallback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VoiceCallback(Music * music);
|
|
||||||
~VoiceCallback();
|
|
||||||
|
|
||||||
void __stdcall OnStreamEnd();
|
|
||||||
|
|
||||||
void __stdcall OnBufferEnd(
|
|
||||||
void * pBufferContext
|
|
||||||
);
|
|
||||||
|
|
||||||
void __stdcall OnBufferStart(
|
|
||||||
void * pBufferContext
|
|
||||||
);
|
|
||||||
|
|
||||||
void __stdcall OnLoopEnd(
|
|
||||||
void * pBufferContext
|
|
||||||
);
|
|
||||||
|
|
||||||
void __stdcall OnVoiceProcessingPassEnd();
|
|
||||||
|
|
||||||
void __stdcall OnVoiceProcessingPassStart(
|
|
||||||
UINT32 SamplesRequired
|
|
||||||
);
|
|
||||||
|
|
||||||
void __stdcall OnVoiceError(
|
|
||||||
void * pBufferContext,
|
|
||||||
HRESULT Error
|
|
||||||
);
|
|
||||||
|
|
||||||
void SetFuncOnStreamEnd(
|
|
||||||
const Function& func
|
|
||||||
);
|
|
||||||
|
|
||||||
void SetFuncOnLoopEnd(
|
|
||||||
const Function& func
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Music * _music;
|
|
||||||
Function _loopEndFunc;
|
|
||||||
Function _streamEndFunc;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ÎÄ×ÖäÖȾÆ÷
|
class Music;
|
||||||
class TextRenderer
|
|
||||||
: public IDWriteTextRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TextRenderer(
|
|
||||||
ID2D1Factory* pD2DFactory,
|
|
||||||
ID2D1HwndRenderTarget* pRT,
|
|
||||||
ID2D1SolidColorBrush* pBrush
|
|
||||||
);
|
|
||||||
|
|
||||||
~TextRenderer();
|
// 音源回调
|
||||||
|
class VoiceCallback
|
||||||
|
: public IXAudio2VoiceCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VoiceCallback(Music * music);
|
||||||
|
~VoiceCallback();
|
||||||
|
|
||||||
STDMETHOD_(void, SetTextStyle)(
|
void __stdcall OnStreamEnd();
|
||||||
CONST D2D1_COLOR_F &fillColor,
|
|
||||||
BOOL hasOutline,
|
|
||||||
CONST D2D1_COLOR_F &outlineColor,
|
|
||||||
FLOAT outlineWidth,
|
|
||||||
D2D1_LINE_JOIN outlineJoin
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawGlyphRun)(
|
void __stdcall OnBufferEnd(
|
||||||
__maybenull void* clientDrawingContext,
|
void * pBufferContext
|
||||||
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)(
|
void __stdcall OnBufferStart(
|
||||||
__maybenull void* clientDrawingContext,
|
void * pBufferContext
|
||||||
FLOAT baselineOriginX,
|
);
|
||||||
FLOAT baselineOriginY,
|
|
||||||
__in DWRITE_UNDERLINE const* underline,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawStrikethrough)(
|
void __stdcall OnLoopEnd(
|
||||||
__maybenull void* clientDrawingContext,
|
void * pBufferContext
|
||||||
FLOAT baselineOriginX,
|
);
|
||||||
FLOAT baselineOriginY,
|
|
||||||
__in DWRITE_STRIKETHROUGH const* strikethrough,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawInlineObject)(
|
void __stdcall OnVoiceProcessingPassEnd();
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT originX,
|
|
||||||
FLOAT originY,
|
|
||||||
IDWriteInlineObject* inlineObject,
|
|
||||||
BOOL isSideways,
|
|
||||||
BOOL isRightToLeft,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(IsPixelSnappingDisabled)(
|
void __stdcall OnVoiceProcessingPassStart(
|
||||||
__maybenull void* clientDrawingContext,
|
UINT32 SamplesRequired
|
||||||
__out BOOL* isDisabled
|
);
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(GetCurrentTransform)(
|
void __stdcall OnVoiceError(
|
||||||
__maybenull void* clientDrawingContext,
|
void * pBufferContext,
|
||||||
__out DWRITE_MATRIX* transform
|
HRESULT Error
|
||||||
);
|
);
|
||||||
|
|
||||||
STDMETHOD(GetPixelsPerDip)(
|
void SetFuncOnStreamEnd(
|
||||||
__maybenull void* clientDrawingContext,
|
const Function& func
|
||||||
__out FLOAT* pixelsPerDip
|
);
|
||||||
);
|
|
||||||
|
|
||||||
public:
|
void SetFuncOnLoopEnd(
|
||||||
unsigned long STDMETHODCALLTYPE AddRef();
|
const Function& func
|
||||||
unsigned long STDMETHODCALLTYPE Release();
|
);
|
||||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
|
||||||
IID const& riid,
|
|
||||||
void** ppvObject
|
|
||||||
);
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
unsigned long cRefCount_;
|
Music * _music;
|
||||||
D2D1_COLOR_F sFillColor_;
|
Function _loopEndFunc;
|
||||||
D2D1_COLOR_F sOutlineColor_;
|
Function _streamEndFunc;
|
||||||
FLOAT fOutlineWidth;
|
};
|
||||||
BOOL bShowOutline_;
|
|
||||||
D2D1_LINE_JOIN nOutlineJoin_;
|
|
||||||
ID2D1Factory* pD2DFactory_;
|
// 文字渲染器
|
||||||
ID2D1HwndRenderTarget* pRT_;
|
class TextRenderer
|
||||||
ID2D1SolidColorBrush* pBrush_;
|
: public IDWriteTextRenderer
|
||||||
};
|
{
|
||||||
|
public:
|
||||||
|
TextRenderer(
|
||||||
|
ID2D1Factory* pD2DFactory,
|
||||||
|
ID2D1HwndRenderTarget* pRT,
|
||||||
|
ID2D1SolidColorBrush* pBrush
|
||||||
|
);
|
||||||
|
|
||||||
|
~TextRenderer();
|
||||||
|
|
||||||
|
STDMETHOD_(void, SetTextStyle)(
|
||||||
|
CONST D2D1_COLOR_F &fillColor,
|
||||||
|
BOOL hasOutline,
|
||||||
|
CONST D2D1_COLOR_F &outlineColor,
|
||||||
|
FLOAT outlineWidth,
|
||||||
|
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_;
|
||||||
|
D2D1_LINE_JOIN nOutlineJoin_;
|
||||||
|
ID2D1Factory* pD2DFactory_;
|
||||||
|
ID2D1HwndRenderTarget* pRT_;
|
||||||
|
ID2D1SolidColorBrush* pBrush_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 异常
|
||||||
|
class Exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Exception() throw();
|
||||||
|
|
||||||
|
explicit Exception(String message) throw();
|
||||||
|
|
||||||
|
Exception(Exception const& other) throw();
|
||||||
|
|
||||||
|
virtual ~Exception() throw();
|
||||||
|
|
||||||
|
Exception& operator=(Exception const& other) throw();
|
||||||
|
|
||||||
|
// 获取异常信息
|
||||||
|
virtual String msg() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
String _message;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -19,8 +19,8 @@ class Transition;
|
||||||
// 场景管理器
|
// 场景管理器
|
||||||
class SceneManager
|
class SceneManager
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
friend Renderer;
|
friend class Renderer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 切换场景
|
// 切换场景
|
||||||
|
|
@ -65,9 +65,9 @@ private:
|
||||||
// 动作管理器
|
// 动作管理器
|
||||||
class ActionManager
|
class ActionManager
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
friend Node;
|
friend class Node;
|
||||||
friend Action;
|
friend class Action;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 执行动作
|
// 执行动作
|
||||||
|
|
@ -154,8 +154,8 @@ private:
|
||||||
// 碰撞体管理器
|
// 碰撞体管理器
|
||||||
class ColliderManager
|
class ColliderManager
|
||||||
{
|
{
|
||||||
friend Node;
|
friend class Node;
|
||||||
friend Collider;
|
friend class Collider;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 更新碰撞体
|
// 更新碰撞体
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ class ColliderManager;
|
||||||
class Node :
|
class Node :
|
||||||
public Object
|
public Object
|
||||||
{
|
{
|
||||||
friend Scene;
|
friend class Scene;
|
||||||
friend Collider;
|
friend class Collider;
|
||||||
friend Transition;
|
friend class Transition;
|
||||||
friend ColliderManager;
|
friend class ColliderManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 节点属性
|
// 节点属性
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ private:
|
||||||
class Music :
|
class Music :
|
||||||
public Object
|
public Object
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Music();
|
Music();
|
||||||
|
|
@ -162,7 +162,7 @@ protected:
|
||||||
// 音乐播放器
|
// 音乐播放器
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 预加载音乐资源
|
// 预加载音乐资源
|
||||||
|
|
@ -258,7 +258,7 @@ private:
|
||||||
// 定时器
|
// 定时器
|
||||||
class Timer
|
class Timer
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 启动定时器(每帧执行一次)
|
// 启动定时器(每帧执行一次)
|
||||||
|
|
@ -324,8 +324,8 @@ class Collision;
|
||||||
class Listener
|
class Listener
|
||||||
: public Object
|
: public Object
|
||||||
{
|
{
|
||||||
friend Input;
|
friend class Input;
|
||||||
friend Collision;
|
friend class Collision;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Listener();
|
Listener();
|
||||||
|
|
@ -447,7 +447,7 @@ public:
|
||||||
// 路径工具
|
// 路径工具
|
||||||
class Path
|
class Path
|
||||||
{
|
{
|
||||||
friend Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 获取数据的默认保存路径
|
// 获取数据的默认保存路径
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class SceneManager;
|
||||||
class Transition :
|
class Transition :
|
||||||
public Object
|
public Object
|
||||||
{
|
{
|
||||||
friend SceneManager;
|
friend class SceneManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Transition(double duration);
|
Transition(double duration);
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,7 @@
|
||||||
<ClCompile Include="..\..\core\Common\Size.cpp" />
|
<ClCompile Include="..\..\core\Common\Size.cpp" />
|
||||||
<ClCompile Include="..\..\core\Common\String.cpp" />
|
<ClCompile Include="..\..\core\Common\String.cpp" />
|
||||||
<ClCompile Include="..\..\core\Common\Image.cpp" />
|
<ClCompile Include="..\..\core\Common\Image.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\Custom\Exception.cpp" />
|
||||||
<ClCompile Include="..\..\core\Custom\TextRenderer.cpp" />
|
<ClCompile Include="..\..\core\Custom\TextRenderer.cpp" />
|
||||||
<ClCompile Include="..\..\core\Custom\VoiceCallback.cpp" />
|
<ClCompile Include="..\..\core\Custom\VoiceCallback.cpp" />
|
||||||
<ClCompile Include="..\..\core\Manager\ActionManager.cpp" />
|
<ClCompile Include="..\..\core\Manager\ActionManager.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,9 @@
|
||||||
<ClCompile Include="..\..\core\Common\Rect.cpp">
|
<ClCompile Include="..\..\core\Common\Rect.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Custom\Exception.cpp">
|
||||||
|
<Filter>Custom</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue