change: the name of smart pointers start with 'Sp'
minor fixes minor fixes minor fixes minor fixes
This commit is contained in:
		
							parent
							
								
									c165db986b
								
							
						
					
					
						commit
						22d9e843fe
					
				|  | @ -30,13 +30,13 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	class Action | 	class Action | ||||||
| 		: public Object | 		: public Object | ||||||
| 		, protected intrusive::ListItem<spAction> | 		, protected intrusive::ListItem<SpAction> | ||||||
| 	{ | 	{ | ||||||
| 		friend class ActionManager; | 		friend class ActionManager; | ||||||
| 		friend class Loop; | 		friend class Loop; | ||||||
| 		friend class Sequence; | 		friend class Sequence; | ||||||
| 		friend class Spawn; | 		friend class Spawn; | ||||||
| 		friend class intrusive::List<spAction>; | 		friend class intrusive::List<SpAction>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		Action() : running_(false), done_(false), initialized_(false) {} | 		Action() : running_(false), done_(false), initialized_(false) {} | ||||||
|  | @ -56,10 +56,10 @@ namespace easy2d | ||||||
| 		virtual void Stop() { if (!done_) { done_ = true; if (cb_) cb_(); } } | 		virtual void Stop() { if (!done_) { done_ = true; if (cb_) cb_(); } } | ||||||
| 
 | 
 | ||||||
| 		// 获取动作的拷贝
 | 		// 获取动作的拷贝
 | ||||||
| 		virtual spAction Clone() const = 0; | 		virtual SpAction Clone() const = 0; | ||||||
| 
 | 
 | ||||||
| 		// 获取动作的倒转
 | 		// 获取动作的倒转
 | ||||||
| 		virtual spAction Reverse() const = 0; | 		virtual SpAction Reverse() const = 0; | ||||||
| 
 | 
 | ||||||
| 		// 重置动作
 | 		// 重置动作
 | ||||||
| 		virtual void Reset() | 		virtual void Reset() | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ namespace easy2d | ||||||
| 	// Loop
 | 	// Loop
 | ||||||
| 	//-------------------------------------------------------
 | 	//-------------------------------------------------------
 | ||||||
| 
 | 
 | ||||||
| 	Loop::Loop(spAction const& action, int times) | 	Loop::Loop(SpAction const& action, int times) | ||||||
| 		: action_(action) | 		: action_(action) | ||||||
| 		, times_(0) | 		, times_(0) | ||||||
| 		, total_times_(times) | 		, total_times_(times) | ||||||
|  | @ -41,7 +41,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Loop::Clone() const | 	SpAction Loop::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		if (action_) | 		if (action_) | ||||||
| 		{ | 		{ | ||||||
|  | @ -53,7 +53,7 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Loop::Reverse() const | 	SpAction Loop::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		if (action_) | 		if (action_) | ||||||
| 		{ | 		{ | ||||||
|  | @ -172,7 +172,7 @@ namespace easy2d | ||||||
| 		action_index_ = 0; | 		action_index_ = 0; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Sequence::Add(spAction const& action) | 	void Sequence::Add(SpAction const& action) | ||||||
| 	{ | 	{ | ||||||
| 		if (action) | 		if (action) | ||||||
| 		{ | 		{ | ||||||
|  | @ -188,7 +188,7 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Sequence::Clone() const | 	SpAction Sequence::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		auto sequence = new (std::nothrow) Sequence(); | 		auto sequence = new (std::nothrow) Sequence(); | ||||||
| 		if (sequence) | 		if (sequence) | ||||||
|  | @ -204,7 +204,7 @@ namespace easy2d | ||||||
| 		return sequence; | 		return sequence; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Sequence::Reverse() const | 	SpAction Sequence::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		auto sequence = new (std::nothrow) Sequence(); | 		auto sequence = new (std::nothrow) Sequence(); | ||||||
| 		if (sequence && !actions_.empty()) | 		if (sequence && !actions_.empty()) | ||||||
|  | @ -281,7 +281,7 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Spawn::Add(spAction const& action) | 	void Spawn::Add(SpAction const& action) | ||||||
| 	{ | 	{ | ||||||
| 		if (action) | 		if (action) | ||||||
| 		{ | 		{ | ||||||
|  | @ -297,7 +297,7 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Spawn::Clone() const | 	SpAction Spawn::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		auto spawn = new (std::nothrow) Spawn(); | 		auto spawn = new (std::nothrow) Spawn(); | ||||||
| 		if (spawn) | 		if (spawn) | ||||||
|  | @ -313,7 +313,7 @@ namespace easy2d | ||||||
| 		return spawn; | 		return spawn; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Spawn::Reverse() const | 	SpAction Spawn::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		auto spawn = new (std::nothrow) Spawn(); | 		auto spawn = new (std::nothrow) Spawn(); | ||||||
| 		if (spawn && !actions_.empty()) | 		if (spawn && !actions_.empty()) | ||||||
|  |  | ||||||
|  | @ -29,17 +29,17 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| 		explicit Loop( | 		explicit Loop( | ||||||
| 			spAction const& action,	/* 执行循环的动作 */ | 			SpAction const& action,	/* 执行循环的动作 */ | ||||||
| 			int times = -1			/* 循环次数 */ | 			int times = -1			/* 循环次数 */ | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		virtual ~Loop(); | 		virtual ~Loop(); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 		// 重置动作
 | 		// 重置动作
 | ||||||
| 		virtual void Reset() override; | 		virtual void Reset() override; | ||||||
|  | @ -54,7 +54,7 @@ namespace easy2d | ||||||
| 		virtual void Update(Node* target, Duration const& dt) override; | 		virtual void Update(Node* target, Duration const& dt) override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		spAction	action_; | 		SpAction	action_; | ||||||
| 		int			times_; | 		int			times_; | ||||||
| 		int			total_times_; | 		int			total_times_; | ||||||
| 	}; | 	}; | ||||||
|  | @ -64,7 +64,7 @@ namespace easy2d | ||||||
| 	class Sequence | 	class Sequence | ||||||
| 		: public Action | 		: public Action | ||||||
| 	{ | 	{ | ||||||
| 		using Actions = std::vector<spAction>; | 		using Actions = std::vector<SpAction>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		Sequence(); | 		Sequence(); | ||||||
|  | @ -77,7 +77,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 在结尾添加动作
 | 		// 在结尾添加动作
 | ||||||
| 		void Add( | 		void Add( | ||||||
| 			spAction const& action | 			SpAction const& action | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 在结尾添加多个动作
 | 		// 在结尾添加多个动作
 | ||||||
|  | @ -86,10 +86,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 		// 重置动作
 | 		// 重置动作
 | ||||||
| 		virtual void Reset() override; | 		virtual void Reset() override; | ||||||
|  | @ -111,7 +111,7 @@ namespace easy2d | ||||||
| 	class Spawn | 	class Spawn | ||||||
| 		: public Action | 		: public Action | ||||||
| 	{ | 	{ | ||||||
| 		using Actions = std::vector<spAction>; | 		using Actions = std::vector<SpAction>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		Spawn(); | 		Spawn(); | ||||||
|  | @ -124,7 +124,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 在结尾添加动作
 | 		// 在结尾添加动作
 | ||||||
| 		void Add( | 		void Add( | ||||||
| 			spAction const& action | 			SpAction const& action | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 在结尾添加多个动作
 | 		// 在结尾添加多个动作
 | ||||||
|  | @ -133,10 +133,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const; | 		virtual SpAction Reverse() const; | ||||||
| 
 | 
 | ||||||
| 		// 重置动作
 | 		// 重置动作
 | ||||||
| 		virtual void Reset() override; | 		virtual void Reset() override; | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ namespace easy2d | ||||||
| 		if (actions_.IsEmpty()) | 		if (actions_.IsEmpty()) | ||||||
| 			return; | 			return; | ||||||
| 
 | 
 | ||||||
| 		spAction next; | 		SpAction next; | ||||||
| 		for (auto action = actions_.First(); action; action = next) | 		for (auto action = actions_.First(); action; action = next) | ||||||
| 		{ | 		{ | ||||||
| 			next = action->NextItem(); | 			next = action->NextItem(); | ||||||
|  | @ -41,14 +41,14 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void ActionManager::AddAction(spAction const& action) | 	void ActionManager::AddAction(SpAction const& action) | ||||||
| 	{ | 	{ | ||||||
| 		E2D_ASSERT(action && "AddAction failed, NULL pointer exception"); | 		E2D_ASSERT(action && "AddAction failed, NULL pointer exception"); | ||||||
| 
 | 
 | ||||||
| 		if (action) | 		if (action) | ||||||
| 		{ | 		{ | ||||||
| 			action->Start(); | 			action->Start(); | ||||||
| 			actions_.PushBack(Action::ItemType(action)); | 			actions_.PushBack(action); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -25,12 +25,12 @@ namespace easy2d | ||||||
| { | { | ||||||
| 	class ActionManager | 	class ActionManager | ||||||
| 	{ | 	{ | ||||||
| 		using Actions = intrusive::List<spAction>; | 		using Actions = intrusive::List<SpAction>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		// 执行动作
 | 		// 执行动作
 | ||||||
| 		void AddAction( | 		void AddAction( | ||||||
| 			spAction const& action | 			SpAction const& action | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 继续所有暂停动作
 | 		// 继续所有暂停动作
 | ||||||
|  |  | ||||||
|  | @ -235,12 +235,12 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction MoveBy::Clone() const | 	SpAction MoveBy::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) MoveBy(duration_, delta_pos_, ease_type_); | 		return new (std::nothrow) MoveBy(duration_, delta_pos_, ease_type_); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction MoveBy::Reverse() const | 	SpAction MoveBy::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) MoveBy(duration_, -delta_pos_, ease_type_); | 		return new (std::nothrow) MoveBy(duration_, -delta_pos_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -251,7 +251,7 @@ namespace easy2d | ||||||
| 		end_pos_ = pos; | 		end_pos_ = pos; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction MoveTo::Clone() const | 	SpAction MoveTo::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) MoveTo(duration_, end_pos_, ease_type_); | 		return new (std::nothrow) MoveTo(duration_, end_pos_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -275,12 +275,12 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction JumpBy::Clone() const | 	SpAction JumpBy::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) JumpBy(duration_, delta_pos_, height_, jumps_, ease_type_); | 		return new (std::nothrow) JumpBy(duration_, delta_pos_, height_, jumps_, ease_type_); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction JumpBy::Reverse() const | 	SpAction JumpBy::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) JumpBy(duration_, -delta_pos_, height_, jumps_, ease_type_); | 		return new (std::nothrow) JumpBy(duration_, -delta_pos_, height_, jumps_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -320,7 +320,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction JumpTo::Clone() const | 	SpAction JumpTo::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) JumpTo(duration_, end_pos_, height_, jumps_, ease_type_); | 		return new (std::nothrow) JumpTo(duration_, end_pos_, height_, jumps_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -369,12 +369,12 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction ScaleBy::Clone() const | 	SpAction ScaleBy::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) ScaleBy(duration_, delta_x_, delta_y_, ease_type_); | 		return new (std::nothrow) ScaleBy(duration_, delta_x_, delta_y_, ease_type_); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction ScaleBy::Reverse() const | 	SpAction ScaleBy::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) ScaleBy(duration_, -delta_x_, -delta_y_, ease_type_); | 		return new (std::nothrow) ScaleBy(duration_, -delta_x_, -delta_y_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -393,7 +393,7 @@ namespace easy2d | ||||||
| 		end_scale_y_ = scale_y; | 		end_scale_y_ = scale_y; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction ScaleTo::Clone() const | 	SpAction ScaleTo::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) ScaleTo(duration_, end_scale_x_, end_scale_y_, ease_type_); | 		return new (std::nothrow) ScaleTo(duration_, end_scale_x_, end_scale_y_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -434,12 +434,12 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction OpacityBy::Clone() const | 	SpAction OpacityBy::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) OpacityBy(duration_, delta_val_, ease_type_); | 		return new (std::nothrow) OpacityBy(duration_, delta_val_, ease_type_); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction OpacityBy::Reverse() const | 	SpAction OpacityBy::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) OpacityBy(duration_, -delta_val_, ease_type_); | 		return new (std::nothrow) OpacityBy(duration_, -delta_val_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -450,7 +450,7 @@ namespace easy2d | ||||||
| 		end_val_ = opacity; | 		end_val_ = opacity; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction OpacityTo::Clone() const | 	SpAction OpacityTo::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) OpacityTo(duration_, end_val_, ease_type_); | 		return new (std::nothrow) OpacityTo(duration_, end_val_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -500,12 +500,12 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction RotateBy::Clone() const | 	SpAction RotateBy::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) RotateBy(duration_, delta_val_, ease_type_); | 		return new (std::nothrow) RotateBy(duration_, delta_val_, ease_type_); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction RotateBy::Reverse() const | 	SpAction RotateBy::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) RotateBy(duration_, -delta_val_, ease_type_); | 		return new (std::nothrow) RotateBy(duration_, -delta_val_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -516,7 +516,7 @@ namespace easy2d | ||||||
| 		end_val_ = rotation; | 		end_val_ = rotation; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction RotateTo::Clone() const | 	SpAction RotateTo::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) RotateTo(duration_, end_val_, ease_type_); | 		return new (std::nothrow) RotateTo(duration_, end_val_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  | @ -532,7 +532,7 @@ namespace easy2d | ||||||
| 	// PathAction
 | 	// PathAction
 | ||||||
| 	//-------------------------------------------------------
 | 	//-------------------------------------------------------
 | ||||||
| 
 | 
 | ||||||
| 	PathAction::PathAction(Duration const & duration, spGeometry const& geo, bool rotating, float start, float end, EaseFunc func) | 	PathAction::PathAction(Duration const & duration, SpGeometry const& geo, bool rotating, float start, float end, EaseFunc func) | ||||||
| 		: Tween(duration, func) | 		: Tween(duration, func) | ||||||
| 		, start_(start) | 		, start_(start) | ||||||
| 		, end_(end) | 		, end_(end) | ||||||
|  | @ -541,12 +541,12 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction PathAction::Clone() const | 	SpAction PathAction::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new PathAction(duration_, geo_, rotating_, start_, end_, ease_type_); | 		return new PathAction(duration_, geo_, rotating_, start_, end_, ease_type_); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction PathAction::Reverse() const | 	SpAction PathAction::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		return new PathAction(duration_, geo_, rotating_, end_, start_, ease_type_); | 		return new PathAction(duration_, geo_, rotating_, end_, start_, ease_type_); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -128,10 +128,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		virtual void Init(Node* target) override; | 		virtual void Init(Node* target) override; | ||||||
|  | @ -157,10 +157,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override | 		virtual SpAction Reverse() const override | ||||||
| 		{ | 		{ | ||||||
| 			logs::Errorln("Reverse() not supported in MoveTo"); | 			logs::Errorln("Reverse() not supported in MoveTo"); | ||||||
| 			return nullptr; | 			return nullptr; | ||||||
|  | @ -188,10 +188,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		virtual void Init(Node* target) override; | 		virtual void Init(Node* target) override; | ||||||
|  | @ -221,10 +221,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override | 		virtual SpAction Reverse() const override | ||||||
| 		{ | 		{ | ||||||
| 			logs::Errorln("Reverse() not supported in JumpTo"); | 			logs::Errorln("Reverse() not supported in JumpTo"); | ||||||
| 			return nullptr; | 			return nullptr; | ||||||
|  | @ -257,10 +257,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		virtual void Init(Node* target) override; | 		virtual void Init(Node* target) override; | ||||||
|  | @ -294,10 +294,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override | 		virtual SpAction Reverse() const override | ||||||
| 		{ | 		{ | ||||||
| 			logs::Errorln("Reverse() not supported in ScaleTo"); | 			logs::Errorln("Reverse() not supported in ScaleTo"); | ||||||
| 			return nullptr; | 			return nullptr; | ||||||
|  | @ -324,10 +324,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		virtual void Init(Node* target) override; | 		virtual void Init(Node* target) override; | ||||||
|  | @ -352,10 +352,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override | 		virtual SpAction Reverse() const override | ||||||
| 		{ | 		{ | ||||||
| 			logs::Errorln("Reverse() not supported in OpacityTo"); | 			logs::Errorln("Reverse() not supported in OpacityTo"); | ||||||
| 			return nullptr; | 			return nullptr; | ||||||
|  | @ -407,10 +407,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		virtual void Init(Node* target) override; | 		virtual void Init(Node* target) override; | ||||||
|  | @ -435,10 +435,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override | 		virtual SpAction Reverse() const override | ||||||
| 		{ | 		{ | ||||||
| 			logs::Errorln("Reverse() not supported in RotateTo"); | 			logs::Errorln("Reverse() not supported in RotateTo"); | ||||||
| 			return nullptr; | 			return nullptr; | ||||||
|  | @ -459,7 +459,7 @@ namespace easy2d | ||||||
| 	public: | 	public: | ||||||
| 		explicit PathAction( | 		explicit PathAction( | ||||||
| 			Duration const& duration,			/* 持续时长 */ | 			Duration const& duration,			/* 持续时长 */ | ||||||
| 			spGeometry const& geo,				/* ¼¸ºÎͼÐÎ */ | 			SpGeometry const& geo,				/* ¼¸ºÎͼÐÎ */ | ||||||
| 			bool rotating = false,				/* 沿路径切线方向旋转 */ | 			bool rotating = false,				/* 沿路径切线方向旋转 */ | ||||||
| 			float start = 0.f,					/* 起点 */ | 			float start = 0.f,					/* 起点 */ | ||||||
| 			float end = 1.f,					/* 终点 */ | 			float end = 1.f,					/* 终点 */ | ||||||
|  | @ -467,10 +467,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		virtual void Init(Node* target) override; | 		virtual void Init(Node* target) override; | ||||||
|  | @ -482,6 +482,6 @@ namespace easy2d | ||||||
| 		float		start_; | 		float		start_; | ||||||
| 		float		end_; | 		float		end_; | ||||||
| 		Point		start_pos_; | 		Point		start_pos_; | ||||||
| 		spGeometry	geo_; | 		SpGeometry	geo_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	Animation::Animation(spFrames const& animation) | 	Animation::Animation(SpFrames const& animation) | ||||||
| 		: frame_index_(0) | 		: frame_index_(0) | ||||||
| 		, frames_(nullptr) | 		, frames_(nullptr) | ||||||
| 	{ | 	{ | ||||||
|  | @ -42,12 +42,12 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spFrames Animation::GetAnimation() const | 	SpFrames Animation::GetAnimation() const | ||||||
| 	{ | 	{ | ||||||
| 		return frames_; | 		return frames_; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Animation::SetAnimation(spFrames const& animation) | 	void Animation::SetAnimation(SpFrames const& animation) | ||||||
| 	{ | 	{ | ||||||
| 		if (animation && animation != frames_) | 		if (animation && animation != frames_) | ||||||
| 		{ | 		{ | ||||||
|  | @ -106,7 +106,7 @@ namespace easy2d | ||||||
| 		frame_index_ = 0; | 		frame_index_ = 0; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Animation::Clone() const | 	SpAction Animation::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		if (frames_) | 		if (frames_) | ||||||
| 		{ | 		{ | ||||||
|  | @ -115,7 +115,7 @@ namespace easy2d | ||||||
| 		return nullptr; | 		return nullptr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Animation::Reverse() const | 	SpAction Animation::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		if (frames_) | 		if (frames_) | ||||||
| 		{ | 		{ | ||||||
|  |  | ||||||
|  | @ -31,24 +31,24 @@ namespace easy2d | ||||||
| 		Animation(); | 		Animation(); | ||||||
| 
 | 
 | ||||||
| 		explicit Animation( | 		explicit Animation( | ||||||
| 			spFrames const& animation | 			SpFrames const& animation | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		virtual ~Animation(); | 		virtual ~Animation(); | ||||||
| 
 | 
 | ||||||
| 		// 获取动画
 | 		// 获取动画
 | ||||||
| 		spFrames GetAnimation() const; | 		SpFrames GetAnimation() const; | ||||||
| 
 | 
 | ||||||
| 		// 设置动画
 | 		// 设置动画
 | ||||||
| 		void SetAnimation( | 		void SetAnimation( | ||||||
| 			spFrames const& animation | 			SpFrames const& animation | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 		// 重置动作
 | 		// 重置动作
 | ||||||
| 		virtual void Reset() override; | 		virtual void Reset() override; | ||||||
|  | @ -63,6 +63,6 @@ namespace easy2d | ||||||
| 	protected: | 	protected: | ||||||
| 		size_t frame_index_; | 		size_t frame_index_; | ||||||
| 		Duration delta_; | 		Duration delta_; | ||||||
| 		spFrames frames_; | 		SpFrames frames_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -247,7 +247,7 @@ namespace easy2d | ||||||
| 		cache_expired_ = true; | 		cache_expired_ = true; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Canvas::DrawImage(spImage const & image, float opacity) | 	void Canvas::DrawImage(SpImage const & image, float opacity) | ||||||
| 	{ | 	{ | ||||||
| 		if (image && image->GetBitmap()) | 		if (image && image->GetBitmap()) | ||||||
| 		{ | 		{ | ||||||
|  | @ -267,7 +267,7 @@ namespace easy2d | ||||||
| 		if (text.empty()) | 		if (text.empty()) | ||||||
| 			return; | 			return; | ||||||
| 
 | 
 | ||||||
| 		cpTextFormat text_format; | 		CpTextFormat text_format; | ||||||
| 		ThrowIfFailed( | 		ThrowIfFailed( | ||||||
| 			Factory::Instance()->CreateTextFormat( | 			Factory::Instance()->CreateTextFormat( | ||||||
| 				text_format, | 				text_format, | ||||||
|  | @ -276,7 +276,7 @@ namespace easy2d | ||||||
| 			) | 			) | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		cpTextLayout text_layout; | 		CpTextLayout text_layout; | ||||||
| 		Size layout_size; | 		Size layout_size; | ||||||
| 		ThrowIfFailed( | 		ThrowIfFailed( | ||||||
| 			Factory::Instance()->CreateTextLayout( | 			Factory::Instance()->CreateTextLayout( | ||||||
|  | @ -293,7 +293,7 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Canvas::DrawGeometry(spGeometry const & geo) | 	void Canvas::DrawGeometry(SpGeometry const & geo) | ||||||
| 	{ | 	{ | ||||||
| 		if (geo && geo->geo_) | 		if (geo && geo->geo_) | ||||||
| 		{ | 		{ | ||||||
|  | @ -371,7 +371,7 @@ namespace easy2d | ||||||
| 		cache_expired_ = true; | 		cache_expired_ = true; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Canvas::FillGeometry(spGeometry const & geo) | 	void Canvas::FillGeometry(SpGeometry const & geo) | ||||||
| 	{ | 	{ | ||||||
| 		if (geo && geo->geo_) | 		if (geo && geo->geo_) | ||||||
| 		{ | 		{ | ||||||
|  | @ -493,14 +493,14 @@ namespace easy2d | ||||||
| 		cache_expired_ = true; | 		cache_expired_ = true; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spImage Canvas::ExportToImage() const | 	SpImage Canvas::ExportToImage() const | ||||||
| 	{ | 	{ | ||||||
| 		auto image = new Image(GetBitmap()); | 		auto image = new Image(GetBitmap()); | ||||||
| 		image->Crop(Rect(Point{}, this->GetSize())); | 		image->Crop(Rect(Point{}, this->GetSize())); | ||||||
| 		return image; | 		return image; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	cpBitmap const& easy2d::Canvas::GetBitmap() const | 	CpBitmap const& easy2d::Canvas::GetBitmap() const | ||||||
| 	{ | 	{ | ||||||
| 		if (cache_expired_) | 		if (cache_expired_) | ||||||
| 		{ | 		{ | ||||||
|  |  | ||||||
|  | @ -85,7 +85,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 画图片
 | 		// 画图片
 | ||||||
| 		void DrawImage( | 		void DrawImage( | ||||||
| 			spImage const& image, | 			SpImage const& image, | ||||||
| 			float opacity = 1.f | 			float opacity = 1.f | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
|  | @ -97,7 +97,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 画几何图形边框
 | 		// 画几何图形边框
 | ||||||
| 		void DrawGeometry( | 		void DrawGeometry( | ||||||
| 			spGeometry const& geo | 			SpGeometry const& geo | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 填充圆形
 | 		// 填充圆形
 | ||||||
|  | @ -127,7 +127,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 填充几何图形
 | 		// 填充几何图形
 | ||||||
| 		void FillGeometry( | 		void FillGeometry( | ||||||
| 			spGeometry const& geo | 			SpGeometry const& geo | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 开始绘制路径
 | 		// 开始绘制路径
 | ||||||
|  | @ -216,26 +216,26 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 导出为图片
 | 		// 导出为图片
 | ||||||
| 		spImage ExportToImage() const; | 		SpImage ExportToImage() const; | ||||||
| 
 | 
 | ||||||
| 		virtual void OnRender() override; | 		virtual void OnRender() override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		cpBitmap const& GetBitmap() const; | 		CpBitmap const& GetBitmap() const; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		mutable bool			cache_expired_; | 		mutable bool			cache_expired_; | ||||||
| 		mutable cpBitmap		bitmap_cached_; | 		mutable CpBitmap		bitmap_cached_; | ||||||
| 		float					stroke_width_; | 		float					stroke_width_; | ||||||
| 		Font					text_font_; | 		Font					text_font_; | ||||||
| 		TextStyle				text_style_; | 		TextStyle				text_style_; | ||||||
| 		cpPathGeometry			current_geometry_; | 		CpPathGeometry			current_geometry_; | ||||||
| 		cpGeometrySink			current_sink_; | 		CpGeometrySink			current_sink_; | ||||||
| 		cpStrokeStyle			outline_join_style_; | 		CpStrokeStyle			outline_join_style_; | ||||||
| 		cpSolidColorBrush		fill_brush_; | 		CpSolidColorBrush		fill_brush_; | ||||||
| 		cpSolidColorBrush		stroke_brush_; | 		CpSolidColorBrush		stroke_brush_; | ||||||
| 		cpSolidColorBrush		text_brush_; | 		CpSolidColorBrush		text_brush_; | ||||||
| 		cpTextRenderer			text_renderer_; | 		CpTextRenderer			text_renderer_; | ||||||
| 		cpBitmapRenderTarget	render_target_; | 		CpBitmapRenderTarget	render_target_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  | @ -44,7 +44,7 @@ namespace easy2d | ||||||
| 		void OnUpdate(Duration const& dt) override; | 		void OnUpdate(Duration const& dt) override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		spText debug_text_; | 		SpText debug_text_; | ||||||
| 		std::vector<TimePoint> frame_time_; | 		std::vector<TimePoint> frame_time_; | ||||||
| 		std::vector<std::wstring> texts_; | 		std::vector<std::wstring> texts_; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
|  | @ -51,12 +51,12 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Delay::Clone() const | 	SpAction Delay::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) Delay(delay_); | 		return new (std::nothrow) Delay(delay_); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spAction Delay::Reverse() const | 	SpAction Delay::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		return new (std::nothrow) Delay(delay_); | 		return new (std::nothrow) Delay(delay_); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -33,10 +33,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的拷贝对象
 | 		// 获取该动作的拷贝对象
 | ||||||
| 		virtual spAction Clone() const override; | 		virtual SpAction Clone() const override; | ||||||
| 
 | 
 | ||||||
| 		// 获取该动作的倒转
 | 		// 获取该动作的倒转
 | ||||||
| 		virtual spAction Reverse() const override; | 		virtual SpAction Reverse() const override; | ||||||
| 
 | 
 | ||||||
| 		// 重置动作
 | 		// 重置动作
 | ||||||
| 		virtual void Reset() override; | 		virtual void Reset() override; | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ namespace easy2d | ||||||
| 		if (listeners_.IsEmpty()) | 		if (listeners_.IsEmpty()) | ||||||
| 			return; | 			return; | ||||||
| 
 | 
 | ||||||
| 		spEventListener next; | 		SpEventListener next; | ||||||
| 		for (auto listener = listeners_.First(); listener; listener = next) | 		for (auto listener = listeners_.First(); listener; listener = next) | ||||||
| 		{ | 		{ | ||||||
| 			next = listener->NextItem(); | 			next = listener->NextItem(); | ||||||
|  | @ -40,22 +40,22 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void EventDispatcher::AddListener(spEventListener const & listener) | 	void EventDispatcher::AddListener(SpEventListener const & listener) | ||||||
| 	{ | 	{ | ||||||
| 		E2D_ASSERT(listener && "AddListener failed, NULL pointer exception"); | 		E2D_ASSERT(listener && "AddListener failed, NULL pointer exception"); | ||||||
| 
 | 
 | ||||||
| 		if (listener) | 		if (listener) | ||||||
| 		{ | 		{ | ||||||
| 			listeners_.PushBack(EventListener::ItemType(listener)); | 			listeners_.PushBack(listener); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void EventDispatcher::AddListener(EventType type, EventCallback callback, std::wstring const& name) | 	void EventDispatcher::AddListener(EventType type, EventCallback callback, std::wstring const& name) | ||||||
| 	{ | 	{ | ||||||
| 		spEventListener listener = new EventListener(type, callback, name); | 		SpEventListener listener = new EventListener(type, callback, name); | ||||||
| 		if (listener) | 		if (listener) | ||||||
| 		{ | 		{ | ||||||
| 			listeners_.PushBack(EventListener::ItemType(listener)); | 			listeners_.PushBack(listener); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -83,7 +83,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	void EventDispatcher::RemoveListeners(std::wstring const & listener_name) | 	void EventDispatcher::RemoveListeners(std::wstring const & listener_name) | ||||||
| 	{ | 	{ | ||||||
| 		spEventListener next; | 		SpEventListener next; | ||||||
| 		for (auto listener = listeners_.First(); listener; listener = next) | 		for (auto listener = listeners_.First(); listener; listener = next) | ||||||
| 		{ | 		{ | ||||||
| 			next = listener->NextItem(); | 			next = listener->NextItem(); | ||||||
|  | @ -119,7 +119,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	void EventDispatcher::RemoveListeners(EventType type) | 	void EventDispatcher::RemoveListeners(EventType type) | ||||||
| 	{ | 	{ | ||||||
| 		spEventListener next; | 		SpEventListener next; | ||||||
| 		for (auto listener = listeners_.First(); listener; listener = next) | 		for (auto listener = listeners_.First(); listener; listener = next) | ||||||
| 		{ | 		{ | ||||||
| 			next = listener->NextItem(); | 			next = listener->NextItem(); | ||||||
|  |  | ||||||
|  | @ -25,12 +25,12 @@ namespace easy2d | ||||||
| { | { | ||||||
| 	class EventDispatcher | 	class EventDispatcher | ||||||
| 	{ | 	{ | ||||||
| 		using Listeners = intrusive::List<spEventListener>; | 		using Listeners = intrusive::List<SpEventListener>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		// 添加监听器
 | 		// 添加监听器
 | ||||||
| 		void AddListener( | 		void AddListener( | ||||||
| 			spEventListener const& listener | 			SpEventListener const& listener | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 添加监听器
 | 		// 添加监听器
 | ||||||
|  |  | ||||||
|  | @ -32,10 +32,10 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	class EventListener | 	class EventListener | ||||||
| 		: public Object | 		: public Object | ||||||
| 		, protected intrusive::ListItem<spEventListener> | 		, protected intrusive::ListItem<SpEventListener> | ||||||
| 	{ | 	{ | ||||||
| 		friend class EventDispatcher; | 		friend class EventDispatcher; | ||||||
| 		friend class intrusive::List<spEventListener>; | 		friend class intrusive::List<SpEventListener>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		EventListener( | 		EventListener( | ||||||
|  | @ -58,7 +58,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		bool			running_; | 		bool			running_; | ||||||
| 		std::wstring			name_; | 		std::wstring	name_; | ||||||
| 		EventType		type_; | 		EventType		type_; | ||||||
| 		EventCallback	callback_; | 		EventCallback	callback_; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
|  | @ -111,12 +111,12 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateHwndRenderTarget(cpHwndRenderTarget & hwnd_render_target, D2D1_RENDER_TARGET_PROPERTIES const & properties, D2D1_HWND_RENDER_TARGET_PROPERTIES const & hwnd_rt_properties) const | 	HRESULT FactoryImpl::CreateHwndRenderTarget(CpHwndRenderTarget & hwnd_render_target, D2D1_RENDER_TARGET_PROPERTIES const & properties, D2D1_HWND_RENDER_TARGET_PROPERTIES const & hwnd_rt_properties) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!factory_) | 		if (!factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
| 
 | 
 | ||||||
| 		cpHwndRenderTarget hwnd_render_target_tmp; | 		CpHwndRenderTarget hwnd_render_target_tmp; | ||||||
| 		HRESULT hr = factory_->CreateHwndRenderTarget( | 		HRESULT hr = factory_->CreateHwndRenderTarget( | ||||||
| 			properties, | 			properties, | ||||||
| 			hwnd_rt_properties, | 			hwnd_rt_properties, | ||||||
|  | @ -129,15 +129,15 @@ namespace easy2d | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateTextRenderer( | 	HRESULT FactoryImpl::CreateTextRenderer( | ||||||
| 		cpTextRenderer& text_renderer, | 		CpTextRenderer& text_renderer, | ||||||
| 		cpRenderTarget const& render_target, | 		CpRenderTarget const& render_target, | ||||||
| 		cpSolidColorBrush const& brush | 		CpSolidColorBrush const& brush | ||||||
| 	) | 	) | ||||||
| 	{ | 	{ | ||||||
| 		if (!factory_) | 		if (!factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
| 
 | 
 | ||||||
| 		cpTextRenderer text_renderer_tmp; | 		CpTextRenderer text_renderer_tmp; | ||||||
| 		HRESULT hr = ITextRenderer::Create( | 		HRESULT hr = ITextRenderer::Create( | ||||||
| 			&text_renderer_tmp, | 			&text_renderer_tmp, | ||||||
| 			factory_.Get(), | 			factory_.Get(), | ||||||
|  | @ -150,7 +150,7 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateBitmapFromFile(cpBitmap & bitmap, cpRenderTarget const & rt, std::wstring const & file_path) | 	HRESULT FactoryImpl::CreateBitmapFromFile(CpBitmap & bitmap, CpRenderTarget const & rt, std::wstring const & file_path) | ||||||
| 	{ | 	{ | ||||||
| 		if (imaging_factory_ == nullptr) | 		if (imaging_factory_ == nullptr) | ||||||
| 		{ | 		{ | ||||||
|  | @ -211,7 +211,7 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateBitmapFromResource(cpBitmap & bitmap, cpRenderTarget const & rt, Resource const & res) | 	HRESULT FactoryImpl::CreateBitmapFromResource(CpBitmap & bitmap, CpRenderTarget const & rt, Resource const & res) | ||||||
| 	{ | 	{ | ||||||
| 		if (imaging_factory_ == nullptr) | 		if (imaging_factory_ == nullptr) | ||||||
| 		{ | 		{ | ||||||
|  | @ -293,12 +293,12 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateRectangleGeometry(cpRectangleGeometry & geo, Rect const& rect) const | 	HRESULT FactoryImpl::CreateRectangleGeometry(CpRectangleGeometry & geo, Rect const& rect) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!factory_) | 		if (!factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
| 
 | 
 | ||||||
| 		cpRectangleGeometry rectangle; | 		CpRectangleGeometry rectangle; | ||||||
| 		HRESULT hr = factory_->CreateRectangleGeometry( | 		HRESULT hr = factory_->CreateRectangleGeometry( | ||||||
| 			rect, | 			rect, | ||||||
| 			&rectangle | 			&rectangle | ||||||
|  | @ -309,12 +309,12 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateRoundedRectangleGeometry(cpRoundedRectangleGeometry & geo, Rect const & rect, float radius_x, float radius_y) const | 	HRESULT FactoryImpl::CreateRoundedRectangleGeometry(CpRoundedRectangleGeometry & geo, Rect const & rect, float radius_x, float radius_y) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!factory_) | 		if (!factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
| 
 | 
 | ||||||
| 		cpRoundedRectangleGeometry rounded_rect; | 		CpRoundedRectangleGeometry rounded_rect; | ||||||
| 		HRESULT hr = factory_->CreateRoundedRectangleGeometry( | 		HRESULT hr = factory_->CreateRoundedRectangleGeometry( | ||||||
| 			D2D1::RoundedRect( | 			D2D1::RoundedRect( | ||||||
| 				rect, | 				rect, | ||||||
|  | @ -329,12 +329,12 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateEllipseGeometry(cpEllipseGeometry & geo, Point const & center, float radius_x, float radius_y) const | 	HRESULT FactoryImpl::CreateEllipseGeometry(CpEllipseGeometry & geo, Point const & center, float radius_x, float radius_y) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!factory_) | 		if (!factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
| 
 | 
 | ||||||
| 		cpEllipseGeometry ellipse; | 		CpEllipseGeometry ellipse; | ||||||
| 		HRESULT hr = factory_->CreateEllipseGeometry( | 		HRESULT hr = factory_->CreateEllipseGeometry( | ||||||
| 			D2D1::Ellipse( | 			D2D1::Ellipse( | ||||||
| 				center, | 				center, | ||||||
|  | @ -350,15 +350,15 @@ namespace easy2d | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateTransformedGeometry( | 	HRESULT FactoryImpl::CreateTransformedGeometry( | ||||||
| 		cpTransformedGeometry& transformed, | 		CpTransformedGeometry& transformed, | ||||||
| 		Matrix const& matrix, | 		Matrix const& matrix, | ||||||
| 		cpGeometry const& geo | 		CpGeometry const& geo | ||||||
| 	) const | 	) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!factory_) | 		if (!factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
| 
 | 
 | ||||||
| 		cpTransformedGeometry transformed_tmp; | 		CpTransformedGeometry transformed_tmp; | ||||||
| 		HRESULT hr = factory_->CreateTransformedGeometry( | 		HRESULT hr = factory_->CreateTransformedGeometry( | ||||||
| 			geo.Get(), | 			geo.Get(), | ||||||
| 			matrix, | 			matrix, | ||||||
|  | @ -372,7 +372,7 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreatePathGeometry(cpPathGeometry & geometry) const | 	HRESULT FactoryImpl::CreatePathGeometry(CpPathGeometry & geometry) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!factory_) | 		if (!factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
|  | @ -380,12 +380,12 @@ namespace easy2d | ||||||
| 		return factory_->CreatePathGeometry(&geometry); | 		return factory_->CreatePathGeometry(&geometry); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateTextFormat(cpTextFormat & text_format, Font const & font, TextStyle const & text_style) const | 	HRESULT FactoryImpl::CreateTextFormat(CpTextFormat & text_format, Font const & font, TextStyle const & text_style) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!write_factory_) | 		if (!write_factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
| 
 | 
 | ||||||
| 		cpTextFormat text_format_tmp; | 		CpTextFormat text_format_tmp; | ||||||
| 		HRESULT hr = write_factory_->CreateTextFormat( | 		HRESULT hr = write_factory_->CreateTextFormat( | ||||||
| 			font.family.c_str(), | 			font.family.c_str(), | ||||||
| 			nullptr, | 			nullptr, | ||||||
|  | @ -418,7 +418,7 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT FactoryImpl::CreateTextLayout(cpTextLayout & text_layout, Size& layout_size, std::wstring const & text, cpTextFormat const& text_format, TextStyle const & text_style) const | 	HRESULT FactoryImpl::CreateTextLayout(CpTextLayout & text_layout, Size& layout_size, std::wstring const & text, CpTextFormat const& text_format, TextStyle const & text_style) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!write_factory_) | 		if (!write_factory_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
|  | @ -426,7 +426,7 @@ namespace easy2d | ||||||
| 		text_layout = nullptr; | 		text_layout = nullptr; | ||||||
| 
 | 
 | ||||||
| 		HRESULT hr; | 		HRESULT hr; | ||||||
| 		cpTextLayout text_layout_tmp; | 		CpTextLayout text_layout_tmp; | ||||||
| 		UINT32 length = static_cast<UINT32>(text.length()); | 		UINT32 length = static_cast<UINT32>(text.length()); | ||||||
| 
 | 
 | ||||||
| 		if (text_style.wrap) | 		if (text_style.wrap) | ||||||
|  | @ -496,7 +496,7 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	cpStrokeStyle const& FactoryImpl::GetStrokeStyle(StrokeStyle stroke) const | 	CpStrokeStyle const& FactoryImpl::GetStrokeStyle(StrokeStyle stroke) const | ||||||
| 	{ | 	{ | ||||||
| 		switch (stroke) | 		switch (stroke) | ||||||
| 		{ | 		{ | ||||||
|  |  | ||||||
|  | @ -38,73 +38,73 @@ namespace easy2d | ||||||
| 		HRESULT Init(bool debug); | 		HRESULT Init(bool debug); | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateHwndRenderTarget( | 		HRESULT CreateHwndRenderTarget( | ||||||
| 			cpHwndRenderTarget& hwnd_render_target, | 			CpHwndRenderTarget& hwnd_render_target, | ||||||
| 			D2D1_RENDER_TARGET_PROPERTIES const& properties, | 			D2D1_RENDER_TARGET_PROPERTIES const& properties, | ||||||
| 			D2D1_HWND_RENDER_TARGET_PROPERTIES const& hwnd_rt_properties | 			D2D1_HWND_RENDER_TARGET_PROPERTIES const& hwnd_rt_properties | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateTextRenderer( | 		HRESULT CreateTextRenderer( | ||||||
| 			cpTextRenderer& text_renderer, | 			CpTextRenderer& text_renderer, | ||||||
| 			cpRenderTarget const& render_target, | 			CpRenderTarget const& render_target, | ||||||
| 			cpSolidColorBrush const& brush | 			CpSolidColorBrush const& brush | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateBitmapFromFile( | 		HRESULT CreateBitmapFromFile( | ||||||
| 			cpBitmap& bitmap, | 			CpBitmap& bitmap, | ||||||
| 			cpRenderTarget const& rt, | 			CpRenderTarget const& rt, | ||||||
| 			std::wstring const& file_path | 			std::wstring const& file_path | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateBitmapFromResource( | 		HRESULT CreateBitmapFromResource( | ||||||
| 			cpBitmap& bitmap, | 			CpBitmap& bitmap, | ||||||
| 			cpRenderTarget const& rt, | 			CpRenderTarget const& rt, | ||||||
| 			Resource const& res | 			Resource const& res | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateRectangleGeometry( | 		HRESULT CreateRectangleGeometry( | ||||||
| 			cpRectangleGeometry& geo, | 			CpRectangleGeometry& geo, | ||||||
| 			Rect const& rect | 			Rect const& rect | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateRoundedRectangleGeometry( | 		HRESULT CreateRoundedRectangleGeometry( | ||||||
| 			cpRoundedRectangleGeometry& geo, | 			CpRoundedRectangleGeometry& geo, | ||||||
| 			Rect const& rect, | 			Rect const& rect, | ||||||
| 			float radius_x, | 			float radius_x, | ||||||
| 			float radius_y | 			float radius_y | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateEllipseGeometry( | 		HRESULT CreateEllipseGeometry( | ||||||
| 			cpEllipseGeometry& geo, | 			CpEllipseGeometry& geo, | ||||||
| 			Point const& center, | 			Point const& center, | ||||||
| 			float radius_x, | 			float radius_x, | ||||||
| 			float radius_y | 			float radius_y | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateTransformedGeometry( | 		HRESULT CreateTransformedGeometry( | ||||||
| 			cpTransformedGeometry& transformed, | 			CpTransformedGeometry& transformed, | ||||||
| 			Matrix const& matrix, | 			Matrix const& matrix, | ||||||
| 			cpGeometry const& geo | 			CpGeometry const& geo | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreatePathGeometry( | 		HRESULT CreatePathGeometry( | ||||||
| 			cpPathGeometry& geometry | 			CpPathGeometry& geometry | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateTextFormat( | 		HRESULT CreateTextFormat( | ||||||
| 			cpTextFormat& text_format, | 			CpTextFormat& text_format, | ||||||
| 			Font const& font, | 			Font const& font, | ||||||
| 			TextStyle const& text_style | 			TextStyle const& text_style | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateTextLayout( | 		HRESULT CreateTextLayout( | ||||||
| 			cpTextLayout& text_layout, | 			CpTextLayout& text_layout, | ||||||
| 			Size& layout_size, | 			Size& layout_size, | ||||||
| 			std::wstring const& text, | 			std::wstring const& text, | ||||||
| 			cpTextFormat const& text_format, | 			CpTextFormat const& text_format, | ||||||
| 			TextStyle const& text_style | 			TextStyle const& text_style | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		cpStrokeStyle const& GetStrokeStyle( | 		CpStrokeStyle const& GetStrokeStyle( | ||||||
| 			StrokeStyle stroke | 			StrokeStyle stroke | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
|  | @ -114,12 +114,12 @@ namespace easy2d | ||||||
| 		~FactoryImpl(); | 		~FactoryImpl(); | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		cpFactory			factory_; | 		CpFactory			factory_; | ||||||
| 		cpImagingFactory	imaging_factory_; | 		CpImagingFactory	imaging_factory_; | ||||||
| 		cpWriteFactory		write_factory_; | 		CpWriteFactory		write_factory_; | ||||||
| 		cpStrokeStyle		miter_stroke_style_; | 		CpStrokeStyle		miter_stroke_style_; | ||||||
| 		cpStrokeStyle		bevel_stroke_style_; | 		CpStrokeStyle		bevel_stroke_style_; | ||||||
| 		cpStrokeStyle		round_stroke_style_; | 		CpStrokeStyle		round_stroke_style_; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	E2D_DECLARE_SINGLETON_TYPE(FactoryImpl, Factory); | 	E2D_DECLARE_SINGLETON_TYPE(FactoryImpl, Factory); | ||||||
|  |  | ||||||
|  | @ -55,7 +55,7 @@ namespace easy2d | ||||||
| 		interval_ = interval; | 		interval_ = interval; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Frames::Add(spImage const& frame) | 	void Frames::Add(SpImage const& frame) | ||||||
| 	{ | 	{ | ||||||
| 		E2D_ASSERT(frame && "Frames::Add failed, NULL pointer exception"); | 		E2D_ASSERT(frame && "Frames::Add failed, NULL pointer exception"); | ||||||
| 
 | 
 | ||||||
|  | @ -83,7 +83,7 @@ namespace easy2d | ||||||
| 		return frames_; | 		return frames_; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spFrames Frames::Clone() const | 	SpFrames Frames::Clone() const | ||||||
| 	{ | 	{ | ||||||
| 		auto animation = new (std::nothrow) Frames(interval_); | 		auto animation = new (std::nothrow) Frames(interval_); | ||||||
| 		if (animation) | 		if (animation) | ||||||
|  | @ -96,7 +96,7 @@ namespace easy2d | ||||||
| 		return animation; | 		return animation; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spFrames Frames::Reverse() const | 	SpFrames Frames::Reverse() const | ||||||
| 	{ | 	{ | ||||||
| 		auto animation = new (std::nothrow) Frames(interval_); | 		auto animation = new (std::nothrow) Frames(interval_); | ||||||
| 		if (!frames_.empty()) | 		if (!frames_.empty()) | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ namespace easy2d | ||||||
| 	class Frames | 	class Frames | ||||||
| 		: public Object | 		: public Object | ||||||
| 	{ | 	{ | ||||||
| 		using Images = std::vector< spImage >; | 		using Images = std::vector< SpImage >; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		Frames(); | 		Frames(); | ||||||
|  | @ -50,7 +50,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 添加关键帧
 | 		// 添加关键帧
 | ||||||
| 		void Add( | 		void Add( | ||||||
| 			spImage const& frame		/* 关键帧 */ | 			SpImage const& frame		/* 关键帧 */ | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 添加多个关键帧
 | 		// 添加多个关键帧
 | ||||||
|  | @ -70,10 +70,10 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取帧动画的拷贝对象
 | 		// 获取帧动画的拷贝对象
 | ||||||
| 		spFrames Clone() const; | 		SpFrames Clone() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取帧动画的倒转
 | 		// 获取帧动画的倒转
 | ||||||
| 		spFrames Reverse() const; | 		SpFrames Reverse() const; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		Duration	interval_; | 		Duration	interval_; | ||||||
|  |  | ||||||
|  | @ -154,7 +154,7 @@ namespace easy2d | ||||||
| 		Window::Instance()->Destroy(); | 		Window::Instance()->Destroy(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Game::EnterScene(spScene const & scene) | 	void Game::EnterScene(SpScene const & scene) | ||||||
| 	{ | 	{ | ||||||
| 		E2D_ASSERT(scene && "Game::EnterScene failed, NULL pointer exception"); | 		E2D_ASSERT(scene && "Game::EnterScene failed, NULL pointer exception"); | ||||||
| 
 | 
 | ||||||
|  | @ -164,7 +164,7 @@ namespace easy2d | ||||||
| 		next_scene_ = scene; | 		next_scene_ = scene; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Game::EnterScene(spScene const& scene, spTransition const& transition) | 	void Game::EnterScene(SpScene const& scene, SpTransition const& transition) | ||||||
| 	{ | 	{ | ||||||
| 		EnterScene(scene); | 		EnterScene(scene); | ||||||
| 		 | 		 | ||||||
|  | @ -179,7 +179,7 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spScene const& Game::GetCurrentScene() | 	SpScene const& Game::GetCurrentScene() | ||||||
| 	{ | 	{ | ||||||
| 		return curr_scene_; | 		return curr_scene_; | ||||||
| 	} | 	} | ||||||
|  | @ -199,26 +199,15 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		Input::Instance()->Update(); | 		Input::Instance()->Update(); | ||||||
| 
 | 
 | ||||||
| 		if (curr_scene_) |  | ||||||
| 			curr_scene_->Update(dt); |  | ||||||
| 
 |  | ||||||
| 		if (next_scene_) |  | ||||||
| 			next_scene_->Update(dt); |  | ||||||
| 
 |  | ||||||
| 		if (debug_) |  | ||||||
| 			DebugNode::Instance()->Update(dt); |  | ||||||
| 
 |  | ||||||
| 		if (transition_) | 		if (transition_) | ||||||
| 		{ | 		{ | ||||||
| 			transition_->Update(dt); | 			transition_->Update(dt); | ||||||
| 
 | 
 | ||||||
| 			if (transition_->IsDone()) | 			if (transition_->IsDone()) | ||||||
| 				transition_ = nullptr; | 				transition_ = nullptr; | ||||||
| 			else |  | ||||||
| 				return; |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (next_scene_) | 		if (next_scene_ && !transition_) | ||||||
| 		{ | 		{ | ||||||
| 			if (curr_scene_) | 			if (curr_scene_) | ||||||
| 			{ | 			{ | ||||||
|  | @ -230,6 +219,15 @@ namespace easy2d | ||||||
| 			curr_scene_ = next_scene_; | 			curr_scene_ = next_scene_; | ||||||
| 			next_scene_ = nullptr; | 			next_scene_ = nullptr; | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		if (curr_scene_) | ||||||
|  | 			curr_scene_->Update(dt); | ||||||
|  | 
 | ||||||
|  | 		if (next_scene_) | ||||||
|  | 			next_scene_->Update(dt); | ||||||
|  | 
 | ||||||
|  | 		if (debug_) | ||||||
|  | 			DebugNode::Instance()->Update(dt); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Game::Render(HWND hwnd) | 	void Game::Render(HWND hwnd) | ||||||
|  |  | ||||||
|  | @ -32,11 +32,11 @@ namespace easy2d | ||||||
| 	struct Options | 	struct Options | ||||||
| 	{ | 	{ | ||||||
| 		std::wstring	title;	// ±êÌâ
 | 		std::wstring	title;	// ±êÌâ
 | ||||||
| 		int		width;	// 宽度
 | 		int				width;	// 宽度
 | ||||||
| 		int		height;	// 高度
 | 		int				height;	// 高度
 | ||||||
| 		LPCWSTR	icon;	// 图标
 | 		LPCWSTR			icon;	// 图标
 | ||||||
| 		bool	vsync;	// 垂直同步
 | 		bool			vsync;	// 垂直同步
 | ||||||
| 		bool	debug;	// 调试模式
 | 		bool			debug;	// 调试模式
 | ||||||
| 
 | 
 | ||||||
| 		Options() | 		Options() | ||||||
| 			: title(L"Easy2D Game") | 			: title(L"Easy2D Game") | ||||||
|  | @ -80,17 +80,17 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// Çл»³¡¾°
 | 		// Çл»³¡¾°
 | ||||||
| 		void EnterScene( | 		void EnterScene( | ||||||
| 			spScene const& scene			/* 场景 */ | 			SpScene const& scene			/* 场景 */ | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// Çл»³¡¾°
 | 		// Çл»³¡¾°
 | ||||||
| 		void EnterScene( | 		void EnterScene( | ||||||
| 			spScene const& scene,			/* 场景 */ | 			SpScene const& scene,			/* 场景 */ | ||||||
| 			spTransition const& transition	/* 场景动画 */ | 			SpTransition const& transition	/* 场景动画 */ | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// »ñÈ¡µ±Ç°³¡¾°
 | 		// »ñÈ¡µ±Ç°³¡¾°
 | ||||||
| 		spScene const& GetCurrentScene(); | 		SpScene const& GetCurrentScene(); | ||||||
| 
 | 
 | ||||||
| 		// ÉèÖñäËÙ
 | 		// ÉèÖñäËÙ
 | ||||||
| 		void SetTimeScale(float scale); | 		void SetTimeScale(float scale); | ||||||
|  | @ -117,8 +117,8 @@ namespace easy2d | ||||||
| 		bool			debug_; | 		bool			debug_; | ||||||
| 		bool			active_; | 		bool			active_; | ||||||
| 		float			time_scale_; | 		float			time_scale_; | ||||||
| 		spScene			curr_scene_; | 		SpScene			curr_scene_; | ||||||
| 		spScene			next_scene_; | 		SpScene			next_scene_; | ||||||
| 		spTransition	transition_; | 		SpTransition	transition_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -126,8 +126,8 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	void LineGeometry::SetLine(Point const & begin, Point const & end) | 	void LineGeometry::SetLine(Point const & begin, Point const & end) | ||||||
| 	{ | 	{ | ||||||
| 		cpPathGeometry path_geo; | 		CpPathGeometry path_geo; | ||||||
| 		cpGeometrySink path_sink; | 		CpGeometrySink path_sink; | ||||||
| 
 | 
 | ||||||
| 		HRESULT hr = Factory::Instance()->CreatePathGeometry(path_geo); | 		HRESULT hr = Factory::Instance()->CreatePathGeometry(path_geo); | ||||||
| 
 | 
 | ||||||
|  | @ -185,7 +185,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	void RectangleGeometry::SetRect(Rect const & rect) | 	void RectangleGeometry::SetRect(Rect const & rect) | ||||||
| 	{ | 	{ | ||||||
| 		cpRectangleGeometry geo; | 		CpRectangleGeometry geo; | ||||||
| 		if (SUCCEEDED(Factory::Instance()->CreateRectangleGeometry(geo, rect))) | 		if (SUCCEEDED(Factory::Instance()->CreateRectangleGeometry(geo, rect))) | ||||||
| 		{ | 		{ | ||||||
| 			geo_ = geo; | 			geo_ = geo; | ||||||
|  | @ -224,7 +224,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	void CircleGeometry::SetCircle(Point const & center, float radius) | 	void CircleGeometry::SetCircle(Point const & center, float radius) | ||||||
| 	{ | 	{ | ||||||
| 		cpEllipseGeometry geo; | 		CpEllipseGeometry geo; | ||||||
| 		if (SUCCEEDED(Factory::Instance()->CreateEllipseGeometry(geo, center, radius, radius))) | 		if (SUCCEEDED(Factory::Instance()->CreateEllipseGeometry(geo, center, radius, radius))) | ||||||
| 		{ | 		{ | ||||||
| 			geo_ = geo; | 			geo_ = geo; | ||||||
|  | @ -265,7 +265,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	void EllipseGeometry::SetEllipse(Point const & center, float radius_x, float radius_y) | 	void EllipseGeometry::SetEllipse(Point const & center, float radius_x, float radius_y) | ||||||
| 	{ | 	{ | ||||||
| 		cpEllipseGeometry geo; | 		CpEllipseGeometry geo; | ||||||
| 		if (SUCCEEDED(Factory::Instance()->CreateEllipseGeometry(geo, center, radius_x, radius_y))) | 		if (SUCCEEDED(Factory::Instance()->CreateEllipseGeometry(geo, center, radius_x, radius_y))) | ||||||
| 		{ | 		{ | ||||||
| 			geo_ = geo; | 			geo_ = geo; | ||||||
|  | @ -414,7 +414,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	void RoundedRectGeometry::SetRoundedRect(Rect const & rect, float radius_x, float radius_y) | 	void RoundedRectGeometry::SetRoundedRect(Rect const & rect, float radius_x, float radius_y) | ||||||
| 	{ | 	{ | ||||||
| 		cpRoundedRectangleGeometry geo; | 		CpRoundedRectangleGeometry geo; | ||||||
| 		if (SUCCEEDED(Factory::Instance()->CreateRoundedRectangleGeometry(geo, rect, radius_x, radius_y))) | 		if (SUCCEEDED(Factory::Instance()->CreateRoundedRectangleGeometry(geo, rect, radius_x, radius_y))) | ||||||
| 		{ | 		{ | ||||||
| 			geo_ = geo; | 			geo_ = geo; | ||||||
|  |  | ||||||
|  | @ -57,7 +57,7 @@ namespace easy2d | ||||||
| 		float ComputeArea(); | 		float ComputeArea(); | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		cpGeometry geo_; | 		CpGeometry geo_; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -254,8 +254,8 @@ namespace easy2d | ||||||
| 		void ClearPath(); | 		void ClearPath(); | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		cpPathGeometry	current_geometry_; | 		CpPathGeometry	current_geometry_; | ||||||
| 		cpGeometrySink	current_sink_; | 		CpGeometrySink	current_sink_; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	GeometryNode::GeometryNode(spGeometry const& geometry) | 	GeometryNode::GeometryNode(SpGeometry const& geometry) | ||||||
| 		: GeometryNode() | 		: GeometryNode() | ||||||
| 	{ | 	{ | ||||||
| 		SetGeometry(geometry); | 		SetGeometry(geometry); | ||||||
|  | @ -41,7 +41,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void GeometryNode::SetGeometry(spGeometry const& geometry) | 	void GeometryNode::SetGeometry(SpGeometry const& geometry) | ||||||
| 	{ | 	{ | ||||||
| 		geometry_ = geometry; | 		geometry_ = geometry; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -32,14 +32,14 @@ namespace easy2d | ||||||
| 		GeometryNode(); | 		GeometryNode(); | ||||||
| 
 | 
 | ||||||
| 		GeometryNode( | 		GeometryNode( | ||||||
| 			spGeometry const& geometry | 			SpGeometry const& geometry | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		virtual ~GeometryNode(); | 		virtual ~GeometryNode(); | ||||||
| 
 | 
 | ||||||
| 		// ÉčÖĂĐÎ×´
 | 		// ÉčÖĂĐÎ×´
 | ||||||
| 		void SetGeometry( | 		void SetGeometry( | ||||||
| 			spGeometry const& geometry | 			SpGeometry const& geometry | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// ÉčÖĂĚîłäŃŐÉŤ
 | 		// ÉčÖĂĚîłäŃŐÉŤ
 | ||||||
|  | @ -63,7 +63,7 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// ťńČĄĐÎ×´
 | 		// ťńČĄĐÎ×´
 | ||||||
| 		spGeometry const& GetGeometry() const { return geometry_; } | 		SpGeometry const& GetGeometry() const { return geometry_; } | ||||||
| 
 | 
 | ||||||
| 		// ťńČĄĚîłäŃŐÉŤ
 | 		// ťńČĄĚîłäŃŐÉŤ
 | ||||||
| 		Color GetFillColor() const { return fill_color_; } | 		Color GetFillColor() const { return fill_color_; } | ||||||
|  | @ -84,6 +84,6 @@ namespace easy2d | ||||||
| 		Color		stroke_color_; | 		Color		stroke_color_; | ||||||
| 		float		stroke_width_; | 		float		stroke_width_; | ||||||
| 		StrokeStyle	outline_join_; | 		StrokeStyle	outline_join_; | ||||||
| 		spGeometry	geometry_; | 		SpGeometry	geometry_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -58,7 +58,7 @@ namespace easy2d | ||||||
| 		this->Crop(crop_rect); | 		this->Crop(crop_rect); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	Image::Image(cpBitmap const & bitmap) | 	Image::Image(CpBitmap const & bitmap) | ||||||
| 		: Image() | 		: Image() | ||||||
| 	{ | 	{ | ||||||
| 		SetBitmap(bitmap); | 		SetBitmap(bitmap); | ||||||
|  | @ -70,7 +70,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	bool Image::Load(Resource const& res) | 	bool Image::Load(Resource const& res) | ||||||
| 	{ | 	{ | ||||||
| 		cpBitmap bitmap; | 		CpBitmap bitmap; | ||||||
| 		HRESULT hr = Graphics::Instance()->CreateBitmapFromResource(bitmap, res); | 		HRESULT hr = Graphics::Instance()->CreateBitmapFromResource(bitmap, res); | ||||||
| 		if (FAILED(hr)) | 		if (FAILED(hr)) | ||||||
| 		{ | 		{ | ||||||
|  | @ -94,7 +94,7 @@ namespace easy2d | ||||||
| 		// 默认搜索路径,所以需要通过 File::GetPath 获取完整路径
 | 		// 默认搜索路径,所以需要通过 File::GetPath 获取完整路径
 | ||||||
| 		std::wstring image_file_path = image_file.GetPath(); | 		std::wstring image_file_path = image_file.GetPath(); | ||||||
| 
 | 
 | ||||||
| 		cpBitmap bitmap; | 		CpBitmap bitmap; | ||||||
| 		HRESULT hr = Graphics::Instance()->CreateBitmapFromFile(bitmap, image_file_path); | 		HRESULT hr = Graphics::Instance()->CreateBitmapFromFile(bitmap, image_file_path); | ||||||
| 		if (FAILED(hr)) | 		if (FAILED(hr)) | ||||||
| 		{ | 		{ | ||||||
|  | @ -181,12 +181,12 @@ namespace easy2d | ||||||
| 		return crop_rect_; | 		return crop_rect_; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	cpBitmap const& Image::GetBitmap() const | 	CpBitmap const& Image::GetBitmap() const | ||||||
| 	{ | 	{ | ||||||
| 		return bitmap_; | 		return bitmap_; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Image::SetBitmap(cpBitmap const & bitmap) | 	void Image::SetBitmap(CpBitmap const & bitmap) | ||||||
| 	{ | 	{ | ||||||
| 		if (bitmap) | 		if (bitmap) | ||||||
| 		{ | 		{ | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		explicit Image( | 		explicit Image( | ||||||
| 			cpBitmap const& bitmap | 			CpBitmap const& bitmap | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		virtual ~Image(); | 		virtual ~Image(); | ||||||
|  | @ -100,15 +100,15 @@ namespace easy2d | ||||||
| 		// »ñÈ¡²Ã¼ô¾ØÐÎ
 | 		// »ñÈ¡²Ã¼ô¾ØÐÎ
 | ||||||
| 		Rect const& GetCropRect() const; | 		Rect const& GetCropRect() const; | ||||||
| 
 | 
 | ||||||
| 		cpBitmap const& GetBitmap() const; | 		CpBitmap const& GetBitmap() const; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		void SetBitmap( | 		void SetBitmap( | ||||||
| 			cpBitmap const& bitmap | 			CpBitmap const& bitmap | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		Rect		crop_rect_; | 		Rect		crop_rect_; | ||||||
| 		cpBitmap	bitmap_; | 		CpBitmap	bitmap_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -62,7 +62,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		if (!children_.IsEmpty()) | 		if (!children_.IsEmpty()) | ||||||
| 		{ | 		{ | ||||||
| 			spNode next; | 			SpNode next; | ||||||
| 			for (auto child = children_.First(); child; child = next) | 			for (auto child = children_.First(); child; child = next) | ||||||
| 			{ | 			{ | ||||||
| 				next = child->NextItem(); | 				next = child->NextItem(); | ||||||
|  | @ -118,7 +118,7 @@ namespace easy2d | ||||||
| 		if (!visible_) | 		if (!visible_) | ||||||
| 			return; | 			return; | ||||||
| 
 | 
 | ||||||
| 		spNode prev; | 		SpNode prev; | ||||||
| 		for (auto child = children_.Last(); child; child = prev) | 		for (auto child = children_.Last(); child; child = prev) | ||||||
| 		{ | 		{ | ||||||
| 			prev = child->PrevItem(); | 			prev = child->PrevItem(); | ||||||
|  | @ -255,7 +255,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		if (parent_) | 		if (parent_) | ||||||
| 		{ | 		{ | ||||||
| 			spNode me = this; | 			SpNode me = this; | ||||||
| 
 | 
 | ||||||
| 			parent_->children_.Remove(me); | 			parent_->children_.Remove(me); | ||||||
| 
 | 
 | ||||||
|  | @ -272,7 +272,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 			if (sibling) | 			if (sibling) | ||||||
| 			{ | 			{ | ||||||
| 				parent_->children_.InsertAfter(me, spNode(sibling)); | 				parent_->children_.InsertAfter(me, SpNode(sibling)); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
|  | @ -444,7 +444,7 @@ namespace easy2d | ||||||
| 		dirty_transform_ = true; | 		dirty_transform_ = true; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Node::AddChild(spNode const& child) | 	void Node::AddChild(SpNode const& child) | ||||||
| 	{ | 	{ | ||||||
| 		E2D_ASSERT(child && "Node::AddChild failed, NULL pointer exception"); | 		E2D_ASSERT(child && "Node::AddChild failed, NULL pointer exception"); | ||||||
| 
 | 
 | ||||||
|  | @ -461,7 +461,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| #endif // E2D_DEBUG
 | #endif // E2D_DEBUG
 | ||||||
| 
 | 
 | ||||||
| 			children_.PushBack(Node::ItemType(child)); | 			children_.PushBack(child); | ||||||
| 			child->parent_ = this; | 			child->parent_ = this; | ||||||
| 			child->SetScene(this->scene_); | 			child->SetScene(this->scene_); | ||||||
| 			child->dirty_transform_ = true; | 			child->dirty_transform_ = true; | ||||||
|  | @ -498,7 +498,7 @@ namespace easy2d | ||||||
| 		return children; | 		return children; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spNode Node::GetChild(std::wstring const& name) const | 	SpNode Node::GetChild(std::wstring const& name) const | ||||||
| 	{ | 	{ | ||||||
| 		size_t hash_code = std::hash<std::wstring>{}(name); | 		size_t hash_code = std::hash<std::wstring>{}(name); | ||||||
| 
 | 
 | ||||||
|  | @ -525,7 +525,7 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	bool Node::RemoveChild(spNode const& child) | 	bool Node::RemoveChild(SpNode const& child) | ||||||
| 	{ | 	{ | ||||||
| 		return RemoveChild(child.Get()); | 		return RemoveChild(child.Get()); | ||||||
| 	} | 	} | ||||||
|  | @ -541,7 +541,7 @@ namespace easy2d | ||||||
| 		{ | 		{ | ||||||
| 			child->parent_ = nullptr; | 			child->parent_ = nullptr; | ||||||
| 			if (child->scene_) child->SetScene(nullptr); | 			if (child->scene_) child->SetScene(nullptr); | ||||||
| 			children_.Remove(spNode(child)); | 			children_.Remove(SpNode(child)); | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| 		return false; | 		return false; | ||||||
|  |  | ||||||
|  | @ -37,15 +37,15 @@ namespace easy2d | ||||||
| 		, public TaskManager | 		, public TaskManager | ||||||
| 		, public ActionManager | 		, public ActionManager | ||||||
| 		, public EventDispatcher | 		, public EventDispatcher | ||||||
| 		, protected intrusive::ListItem<spNode> | 		, protected intrusive::ListItem<SpNode> | ||||||
| 	{ | 	{ | ||||||
| 		friend class Game; | 		friend class Game; | ||||||
| 		friend class Scene; | 		friend class Scene; | ||||||
| 		friend class Transition; | 		friend class Transition; | ||||||
| 		friend class intrusive::List<spNode>; | 		friend class intrusive::List<SpNode>; | ||||||
| 
 | 
 | ||||||
| 		using Nodes = std::vector<spNode>; | 		using Nodes = std::vector<SpNode>; | ||||||
| 		using Children = intrusive::List<spNode>; | 		using Children = intrusive::List<SpNode>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		Node(); | 		Node(); | ||||||
|  | @ -292,7 +292,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 添加子节点
 | 		// 添加子节点
 | ||||||
| 		void AddChild( | 		void AddChild( | ||||||
| 			spNode const& child | 			SpNode const& child | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 添加多个子节点
 | 		// 添加多个子节点
 | ||||||
|  | @ -306,7 +306,7 @@ namespace easy2d | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		// 获取名称相同的子节点
 | 		// 获取名称相同的子节点
 | ||||||
| 		spNode GetChild( | 		SpNode GetChild( | ||||||
| 			std::wstring const& name | 			std::wstring const& name | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
|  | @ -315,7 +315,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 移除子节点
 | 		// 移除子节点
 | ||||||
| 		bool RemoveChild( | 		bool RemoveChild( | ||||||
| 			spNode const& child | 			SpNode const& child | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 移除子节点
 | 		// 移除子节点
 | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	Sprite::Sprite(spImage const& image) | 	Sprite::Sprite(SpImage const& image) | ||||||
| 		: image_(nullptr) | 		: image_(nullptr) | ||||||
| 	{ | 	{ | ||||||
| 		Load(image); | 		Load(image); | ||||||
|  | @ -64,7 +64,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	bool Sprite::Load(spImage const& image) | 	bool Sprite::Load(SpImage const& image) | ||||||
| 	{ | 	{ | ||||||
| 		if (image) | 		if (image) | ||||||
| 		{ | 		{ | ||||||
|  | @ -121,7 +121,7 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	spImage const& Sprite::GetImage() const | 	SpImage const& Sprite::GetImage() const | ||||||
| 	{ | 	{ | ||||||
| 		return image_; | 		return image_; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace easy2d | ||||||
| 		Sprite(); | 		Sprite(); | ||||||
| 
 | 
 | ||||||
| 		explicit Sprite( | 		explicit Sprite( | ||||||
| 			spImage const& image | 			SpImage const& image | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		explicit Sprite( | 		explicit Sprite( | ||||||
|  | @ -67,7 +67,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		// 加载图片
 | 		// 加载图片
 | ||||||
| 		bool Load( | 		bool Load( | ||||||
| 			spImage const& image | 			SpImage const& image | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 将图片裁剪为矩形
 | 		// 将图片裁剪为矩形
 | ||||||
|  | @ -76,12 +76,12 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取 Image 对象
 | 		// 获取 Image 对象
 | ||||||
| 		spImage const& GetImage() const; | 		SpImage const& GetImage() const; | ||||||
| 
 | 
 | ||||||
| 		// 渲染精灵
 | 		// 渲染精灵
 | ||||||
| 		virtual void OnRender() override; | 		virtual void OnRender() override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		spImage image_; | 		SpImage image_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace easy2d | namespace easy2d | ||||||
| { | { | ||||||
| 	Task::Task(const Callback & func, std::wstring const& name) | 	Task::Task(Callback const& func, std::wstring const& name) | ||||||
| 		: Task(func, Duration{}, -1, name) | 		: Task(func, Duration{}, -1, name) | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -31,23 +31,23 @@ namespace easy2d | ||||||
|     // 定时任务
 |     // 定时任务
 | ||||||
| 	class Task | 	class Task | ||||||
| 		: public Object | 		: public Object | ||||||
| 		, protected intrusive::ListItem<spTask> | 		, protected intrusive::ListItem<SpTask> | ||||||
| 	{ | 	{ | ||||||
| 		friend class TaskManager; | 		friend class TaskManager; | ||||||
| 		friend class intrusive::List<spTask>; | 		friend class intrusive::List<SpTask>; | ||||||
| 
 | 
 | ||||||
| 		using Callback = std::function<void()>; | 		using Callback = std::function<void()>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		explicit Task( | 		explicit Task( | ||||||
| 			const Callback& func,		/* 执行函数 */ | 			Callback const& func,			/* 执行函数 */ | ||||||
| 			std::wstring const& name = L""	/* 任务名称 */ | 			std::wstring const& name = L""	/* 任务名称 */ | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		explicit Task( | 		explicit Task( | ||||||
| 			Callback const& func,		/* 执行函数 */ | 			Callback const& func,			/* 执行函数 */ | ||||||
| 			Duration const& delay,		/* 时间间隔(秒) */ | 			Duration const& delay,			/* 时间间隔(秒) */ | ||||||
| 			int times = -1,				/* 执行次数(设 -1 为永久执行) */ | 			int times = -1,					/* 执行次数(设 -1 为永久执行) */ | ||||||
| 			std::wstring const& name = L""	/* 任务名称 */ | 			std::wstring const& name = L""	/* 任务名称 */ | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
|  | @ -69,12 +69,12 @@ namespace easy2d | ||||||
| 		void Reset(); | 		void Reset(); | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		bool		running_; | 		bool			running_; | ||||||
| 		int			run_times_; | 		int				run_times_; | ||||||
| 		int			total_times_; | 		int				total_times_; | ||||||
| 		std::wstring		name_; | 		std::wstring	name_; | ||||||
| 		Duration	delay_; | 		Duration		delay_; | ||||||
| 		Duration	delta_; | 		Duration		delta_; | ||||||
| 		Callback	callback_; | 		Callback		callback_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ namespace easy2d | ||||||
| 		if (tasks_.IsEmpty()) | 		if (tasks_.IsEmpty()) | ||||||
| 			return; | 			return; | ||||||
| 
 | 
 | ||||||
| 		spTask next; | 		SpTask next; | ||||||
| 		for (auto task = tasks_.First(); task; task = next) | 		for (auto task = tasks_.First(); task; task = next) | ||||||
| 		{ | 		{ | ||||||
| 			next = task->NextItem(); | 			next = task->NextItem(); | ||||||
|  | @ -41,14 +41,14 @@ namespace easy2d | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void TaskManager::AddTask(spTask const& task) | 	void TaskManager::AddTask(SpTask const& task) | ||||||
| 	{ | 	{ | ||||||
| 		E2D_ASSERT(task && "AddTask failed, NULL pointer exception"); | 		E2D_ASSERT(task && "AddTask failed, NULL pointer exception"); | ||||||
| 
 | 
 | ||||||
| 		if (task) | 		if (task) | ||||||
| 		{ | 		{ | ||||||
| 			task->Reset(); | 			task->Reset(); | ||||||
| 			tasks_.PushBack(Task::ItemType(task)); | 			tasks_.PushBack(task); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -85,7 +85,7 @@ namespace easy2d | ||||||
| 		if (tasks_.IsEmpty()) | 		if (tasks_.IsEmpty()) | ||||||
| 			return; | 			return; | ||||||
| 
 | 
 | ||||||
| 		spTask next; | 		SpTask next; | ||||||
| 		for (auto task = tasks_.First(); task; task = next) | 		for (auto task = tasks_.First(); task; task = next) | ||||||
| 		{ | 		{ | ||||||
| 			next = task->NextItem(); | 			next = task->NextItem(); | ||||||
|  |  | ||||||
|  | @ -25,12 +25,12 @@ namespace easy2d | ||||||
| { | { | ||||||
| 	class TaskManager | 	class TaskManager | ||||||
| 	{ | 	{ | ||||||
| 		using Tasks = intrusive::List<spTask>; | 		using Tasks = intrusive::List<SpTask>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		// 添加任务
 | 		// 添加任务
 | ||||||
| 		void AddTask( | 		void AddTask( | ||||||
| 			spTask const& task | 			SpTask const& task | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 启动任务
 | 		// 启动任务
 | ||||||
|  |  | ||||||
|  | @ -208,7 +208,7 @@ namespace easy2d | ||||||
| 		std::wstring			text_; | 		std::wstring			text_; | ||||||
| 		Font			font_; | 		Font			font_; | ||||||
| 		TextStyle		style_; | 		TextStyle		style_; | ||||||
| 		cpTextFormat	text_format_; | 		CpTextFormat	text_format_; | ||||||
| 		cpTextLayout	text_layout_; | 		CpTextLayout	text_layout_; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|  | @ -123,4 +123,4 @@ namespace easy2d | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| E2D_DECLARE_D2D_SMART_PTR(easy2d::ITextRenderer, cpTextRenderer); | E2D_DECLARE_D2D_SMART_PTR(easy2d::ITextRenderer, CpTextRenderer); | ||||||
|  |  | ||||||
|  | @ -55,7 +55,7 @@ namespace easy2d | ||||||
| 		return done_; | 		return done_; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Transition::Init(spScene const& prev, spScene const& next) | 	void Transition::Init(SpScene const& prev, SpScene const& next) | ||||||
| 	{ | 	{ | ||||||
| 		process_ = 0; | 		process_ = 0; | ||||||
| 		delta_ = Duration{}; | 		delta_ = Duration{}; | ||||||
|  | @ -147,7 +147,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void BoxTransition::Init(spScene const& prev, spScene const& next) | 	void BoxTransition::Init(SpScene const& prev, SpScene const& next) | ||||||
| 	{ | 	{ | ||||||
| 		Transition::Init(prev, next); | 		Transition::Init(prev, next); | ||||||
| 
 | 
 | ||||||
|  | @ -189,7 +189,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void EmergeTransition::Init(spScene const& prev, spScene const& next) | 	void EmergeTransition::Init(SpScene const& prev, SpScene const& next) | ||||||
| 	{ | 	{ | ||||||
| 		Transition::Init(prev, next); | 		Transition::Init(prev, next); | ||||||
| 
 | 
 | ||||||
|  | @ -214,7 +214,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void FadeTransition::Init(spScene const& prev, spScene const& next) | 	void FadeTransition::Init(SpScene const& prev, SpScene const& next) | ||||||
| 	{ | 	{ | ||||||
| 		Transition::Init(prev, next); | 		Transition::Init(prev, next); | ||||||
| 
 | 
 | ||||||
|  | @ -248,7 +248,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void MoveTransition::Init(spScene const& prev, spScene const& next) | 	void MoveTransition::Init(SpScene const& prev, SpScene const& next) | ||||||
| 	{ | 	{ | ||||||
| 		Transition::Init(prev, next); | 		Transition::Init(prev, next); | ||||||
| 
 | 
 | ||||||
|  | @ -327,7 +327,7 @@ namespace easy2d | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void RotationTransition::Init(spScene const& prev, spScene const& next) | 	void RotationTransition::Init(SpScene const& prev, SpScene const& next) | ||||||
| 	{ | 	{ | ||||||
| 		Transition::Init(prev, next); | 		Transition::Init(prev, next); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -43,8 +43,8 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		virtual void Init( | 		virtual void Init( | ||||||
| 			spScene const& prev, | 			SpScene const& prev, | ||||||
| 			spScene const& next | 			SpScene const& next | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		virtual void Update(Duration const& dt); | 		virtual void Update(Duration const& dt); | ||||||
|  | @ -61,10 +61,10 @@ namespace easy2d | ||||||
| 		Duration		duration_; | 		Duration		duration_; | ||||||
| 		Duration		delta_; | 		Duration		delta_; | ||||||
| 		Size			window_size_; | 		Size			window_size_; | ||||||
| 		spScene			out_scene_; | 		SpScene			out_scene_; | ||||||
| 		spScene			in_scene_; | 		SpScene			in_scene_; | ||||||
| 		cpLayer			out_layer_; | 		CpLayer			out_layer_; | ||||||
| 		cpLayer			in_layer_; | 		CpLayer			in_layer_; | ||||||
| 		LayerProperties out_layer_prop_; | 		LayerProperties out_layer_prop_; | ||||||
| 		LayerProperties in_layer_prop_; | 		LayerProperties in_layer_prop_; | ||||||
| 	}; | 	}; | ||||||
|  | @ -84,8 +84,8 @@ namespace easy2d | ||||||
| 		virtual void Update(Duration const& dt) override; | 		virtual void Update(Duration const& dt) override; | ||||||
| 
 | 
 | ||||||
| 		virtual void Init( | 		virtual void Init( | ||||||
| 			spScene const& prev, | 			SpScene const& prev, | ||||||
| 			spScene const& next | 			SpScene const& next | ||||||
| 		) override; | 		) override; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  | @ -103,8 +103,8 @@ namespace easy2d | ||||||
| 		virtual void Update(Duration const& dt) override; | 		virtual void Update(Duration const& dt) override; | ||||||
| 
 | 
 | ||||||
| 		virtual void Init( | 		virtual void Init( | ||||||
| 			spScene const& prev, | 			SpScene const& prev, | ||||||
| 			spScene const& next | 			SpScene const& next | ||||||
| 		) override; | 		) override; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  | @ -122,8 +122,8 @@ namespace easy2d | ||||||
| 		virtual void Update(Duration const& dt) override; | 		virtual void Update(Duration const& dt) override; | ||||||
| 
 | 
 | ||||||
| 		virtual void Init( | 		virtual void Init( | ||||||
| 			spScene const& prev, | 			SpScene const& prev, | ||||||
| 			spScene const& next | 			SpScene const& next | ||||||
| 		) override; | 		) override; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  | @ -142,8 +142,8 @@ namespace easy2d | ||||||
| 		virtual void Update(Duration const& dt) override; | 		virtual void Update(Duration const& dt) override; | ||||||
| 
 | 
 | ||||||
| 		virtual void Init( | 		virtual void Init( | ||||||
| 			spScene const& prev, | 			SpScene const& prev, | ||||||
| 			spScene const& next | 			SpScene const& next | ||||||
| 		) override; | 		) override; | ||||||
| 
 | 
 | ||||||
| 		virtual void Reset() override; | 		virtual void Reset() override; | ||||||
|  | @ -169,8 +169,8 @@ namespace easy2d | ||||||
| 		virtual void Update(Duration const& dt) override; | 		virtual void Update(Duration const& dt) override; | ||||||
| 
 | 
 | ||||||
| 		virtual void Init( | 		virtual void Init( | ||||||
| 			spScene const& prev, | 			SpScene const& prev, | ||||||
| 			spScene const& next | 			SpScene const& next | ||||||
| 		) override; | 		) override; | ||||||
| 
 | 
 | ||||||
| 		virtual void Reset() override; | 		virtual void Reset() override; | ||||||
|  |  | ||||||
|  | @ -31,28 +31,30 @@ | ||||||
| 
 | 
 | ||||||
| namespace easy2d | namespace easy2d | ||||||
| { | { | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1Factory, cpFactory); | 	// "Cp" is a shorthand for "COM Pointer"
 | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(IWICImagingFactory, cpImagingFactory); |  | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(IDWriteFactory, cpWriteFactory); |  | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1SolidColorBrush, cpSolidColorBrush); |  | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1RenderTarget, cpRenderTarget); |  | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1HwndRenderTarget, cpHwndRenderTarget); |  | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1BitmapRenderTarget, cpBitmapRenderTarget); |  | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1StrokeStyle, cpStrokeStyle); |  | ||||||
| 
 | 
 | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1Geometry, cpGeometry); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1Factory, CpFactory); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1RectangleGeometry, cpRectangleGeometry); | 	E2D_DECLARE_D2D_SMART_PTR(IWICImagingFactory, CpImagingFactory); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1RoundedRectangleGeometry, cpRoundedRectangleGeometry); | 	E2D_DECLARE_D2D_SMART_PTR(IDWriteFactory, CpWriteFactory); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1EllipseGeometry, cpEllipseGeometry); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1SolidColorBrush, CpSolidColorBrush); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1GeometryGroup, cpGeometryGroup); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1RenderTarget, CpRenderTarget); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1PathGeometry, cpPathGeometry); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1HwndRenderTarget, CpHwndRenderTarget); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1TransformedGeometry, cpTransformedGeometry); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1BitmapRenderTarget, CpBitmapRenderTarget); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1GeometrySink, cpGeometrySink); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1StrokeStyle, CpStrokeStyle); | ||||||
| 
 | 
 | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1Layer, cpLayer); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1Geometry, CpGeometry); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(ID2D1Bitmap, cpBitmap); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1RectangleGeometry, CpRectangleGeometry); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(IDWriteTextFormat, cpTextFormat); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1RoundedRectangleGeometry, CpRoundedRectangleGeometry); | ||||||
| 	E2D_DECLARE_D2D_SMART_PTR(IDWriteTextLayout, cpTextLayout); | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1EllipseGeometry, CpEllipseGeometry); | ||||||
|  | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1GeometryGroup, CpGeometryGroup); | ||||||
|  | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1PathGeometry, CpPathGeometry); | ||||||
|  | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1TransformedGeometry, CpTransformedGeometry); | ||||||
|  | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1GeometrySink, CpGeometrySink); | ||||||
|  | 
 | ||||||
|  | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1Layer, CpLayer); | ||||||
|  | 	E2D_DECLARE_D2D_SMART_PTR(ID2D1Bitmap, CpBitmap); | ||||||
|  | 	E2D_DECLARE_D2D_SMART_PTR(IDWriteTextFormat, CpTextFormat); | ||||||
|  | 	E2D_DECLARE_D2D_SMART_PTR(IDWriteTextLayout, CpTextLayout); | ||||||
| 
 | 
 | ||||||
| 	inline void IntrusivePtrAddRef(IUnknown* ptr) | 	inline void IntrusivePtrAddRef(IUnknown* ptr) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -28,18 +28,20 @@ | ||||||
| #ifndef E2D_DECLARE_SMART_PTR | #ifndef E2D_DECLARE_SMART_PTR | ||||||
| #define E2D_DECLARE_SMART_PTR(class_name)\ | #define E2D_DECLARE_SMART_PTR(class_name)\ | ||||||
| 	class class_name;\ | 	class class_name;\ | ||||||
| 	using sp##class_name = ::easy2d::intrusive::SmartPointer< class_name > | 	using Sp##class_name = ::easy2d::intrusive::SmartPointer< class_name > | ||||||
| 
 | 
 | ||||||
| #define E2D_DECLARE_NS_SMART_PTR(ns_name, class_name)\ | #define E2D_DECLARE_NS_SMART_PTR(ns_name, class_name)\ | ||||||
| 	namespace ns_name\ | 	namespace ns_name\ | ||||||
| 	{\ | 	{\ | ||||||
| 		class class_name; \ | 		class class_name; \ | ||||||
| 		using sp##class_name = ::easy2d::intrusive::SmartPointer< class_name >;\ | 		using Sp##class_name = ::easy2d::intrusive::SmartPointer< class_name >;\ | ||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| namespace easy2d | namespace easy2d | ||||||
| { | { | ||||||
|  | 	// "Sp" is a shorthand for "Smart Pointer"
 | ||||||
|  | 
 | ||||||
| 	E2D_DECLARE_SMART_PTR(Image); | 	E2D_DECLARE_SMART_PTR(Image); | ||||||
| 	E2D_DECLARE_SMART_PTR(Music); | 	E2D_DECLARE_SMART_PTR(Music); | ||||||
| 	E2D_DECLARE_SMART_PTR(Task); | 	E2D_DECLARE_SMART_PTR(Task); | ||||||
|  | @ -97,19 +99,4 @@ namespace easy2d | ||||||
| 	using Size = math::Vector2; | 	using Size = math::Vector2; | ||||||
| 	using Rect = math::Rect; | 	using Rect = math::Rect; | ||||||
| 	using Matrix = math::Matrix; | 	using Matrix = math::Matrix; | ||||||
| 
 |  | ||||||
| 	template <typename Dest, typename Src> |  | ||||||
| 	inline Dest SafeCast(Src ptr) |  | ||||||
| 	{ |  | ||||||
| 		if (!ptr) |  | ||||||
| 			return nullptr; |  | ||||||
| 
 |  | ||||||
| #ifdef E2D_DEBUG |  | ||||||
| 		Dest cast = dynamic_cast<Dest>(ptr); |  | ||||||
| 		E2D_ASSERT(cast); |  | ||||||
| 		return cast; |  | ||||||
| #else |  | ||||||
| 		return static_cast<Dest>(ptr); |  | ||||||
| #endif |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -82,7 +82,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 			bool IsEmpty() const { return !first_; } | 			bool IsEmpty() const { return !first_; } | ||||||
| 
 | 
 | ||||||
| 			void PushBack(T& child) | 			void PushBack(T const& child) | ||||||
| 			{ | 			{ | ||||||
| 				if (child->prev_) | 				if (child->prev_) | ||||||
| 					child->prev_->next_ = child->next_; | 					child->prev_->next_ = child->next_; | ||||||
|  | @ -106,7 +106,7 @@ namespace easy2d | ||||||
| 				DEBUG_CHECK_LIST(this); | 				DEBUG_CHECK_LIST(this); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			void PushFront(T& child) | 			void PushFront(T const& child) | ||||||
| 			{ | 			{ | ||||||
| 				if (child->prev_) | 				if (child->prev_) | ||||||
| 					child->prev_->next_ = child->next_; | 					child->prev_->next_ = child->next_; | ||||||
|  | @ -130,7 +130,7 @@ namespace easy2d | ||||||
| 				DEBUG_CHECK_LIST(this); | 				DEBUG_CHECK_LIST(this); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			void InsertBefore(T& child, T& before) | 			void InsertBefore(T const& child, T const& before) | ||||||
| 			{ | 			{ | ||||||
| 				if (child->prev_) | 				if (child->prev_) | ||||||
| 					child->prev_->next_ = child->next_; | 					child->prev_->next_ = child->next_; | ||||||
|  | @ -149,7 +149,7 @@ namespace easy2d | ||||||
| 				DEBUG_CHECK_LIST(this); | 				DEBUG_CHECK_LIST(this); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			void InsertAfter(T& child, T& after) | 			void InsertAfter(T const& child, T const& after) | ||||||
| 			{ | 			{ | ||||||
| 				if (child->prev_) | 				if (child->prev_) | ||||||
| 					child->prev_->next_ = child->next_; | 					child->prev_->next_ = child->next_; | ||||||
|  | @ -168,7 +168,7 @@ namespace easy2d | ||||||
| 				DEBUG_CHECK_LIST(this); | 				DEBUG_CHECK_LIST(this); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			void Remove(T& child) | 			void Remove(T const& child) | ||||||
| 			{ | 			{ | ||||||
| #ifdef E2D_DEBUG | #ifdef E2D_DEBUG | ||||||
| 				T tmp = first_; | 				T tmp = first_; | ||||||
|  |  | ||||||
|  | @ -192,7 +192,7 @@ namespace easy2d | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	template<class T> | 	template<class T> | ||||||
| 	inline intrusive::SmartPointer<T> make_intrusive(T* ptr) E2D_NOEXCEPT | 	inline intrusive::SmartPointer<T> MakeSmart(T* ptr) E2D_NOEXCEPT | ||||||
| 	{ | 	{ | ||||||
| 		return intrusive::SmartPointer<T>(ptr); | 		return intrusive::SmartPointer<T>(ptr); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -32,6 +32,9 @@ namespace easy2d | ||||||
| 			{ | 			{ | ||||||
| 				PathFileExistsW = (PFN_PathFileExistsW) | 				PathFileExistsW = (PFN_PathFileExistsW) | ||||||
| 					GetProcAddress(shlwapi, "PathFileExistsW"); | 					GetProcAddress(shlwapi, "PathFileExistsW"); | ||||||
|  | 
 | ||||||
|  | 				SHCreateMemStream = (PFN_SHCreateMemStream) | ||||||
|  | 					GetProcAddress(shlwapi, "SHCreateMemStream"); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
|  |  | ||||||
|  | @ -37,11 +37,13 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 			// Shlwapi functions
 | 			// Shlwapi functions
 | ||||||
| 			typedef BOOL(WINAPI *PFN_PathFileExistsW)(LPCWSTR); | 			typedef BOOL(WINAPI *PFN_PathFileExistsW)(LPCWSTR); | ||||||
|  | 			typedef IStream*(WINAPI *PFN_SHCreateMemStream)(const BYTE*, UINT); | ||||||
| 
 | 
 | ||||||
| 		public: | 		public: | ||||||
| 			Shlwapi(); | 			Shlwapi(); | ||||||
| 
 | 
 | ||||||
| 			PFN_PathFileExistsW PathFileExistsW; | 			PFN_PathFileExistsW PathFileExistsW; | ||||||
|  | 			PFN_SHCreateMemStream SHCreateMemStream; | ||||||
| 		}; | 		}; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -108,17 +108,17 @@ namespace easy2d | ||||||
| 		bitmap_cache_.clear(); | 		bitmap_cache_.clear(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	cpHwndRenderTarget const & GraphicsDevice::GetRenderTarget() const | 	CpHwndRenderTarget const & GraphicsDevice::GetRenderTarget() const | ||||||
| 	{ | 	{ | ||||||
| 		return render_target_; | 		return render_target_; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	cpSolidColorBrush const & GraphicsDevice::GetSolidBrush() const | 	CpSolidColorBrush const & GraphicsDevice::GetSolidBrush() const | ||||||
| 	{ | 	{ | ||||||
| 		return solid_brush_; | 		return solid_brush_; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::CreateLayer(cpLayer& layer) | 	HRESULT GraphicsDevice::CreateLayer(CpLayer& layer) | ||||||
| 	{ | 	{ | ||||||
| 		if (!render_target_) | 		if (!render_target_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
|  | @ -127,7 +127,7 @@ namespace easy2d | ||||||
| 		return render_target_->CreateLayer(&layer); | 		return render_target_->CreateLayer(&layer); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::CreateSolidColorBrush(cpSolidColorBrush & brush) const | 	HRESULT GraphicsDevice::CreateSolidColorBrush(CpSolidColorBrush & brush) const | ||||||
| 	{ | 	{ | ||||||
| 		if (!render_target_) | 		if (!render_target_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
|  | @ -140,7 +140,7 @@ namespace easy2d | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::DrawGeometry( | 	HRESULT GraphicsDevice::DrawGeometry( | ||||||
| 		cpGeometry const& geometry, | 		CpGeometry const& geometry, | ||||||
| 		Color const& stroke_color, | 		Color const& stroke_color, | ||||||
| 		float stroke_width, | 		float stroke_width, | ||||||
| 		StrokeStyle stroke | 		StrokeStyle stroke | ||||||
|  | @ -167,7 +167,7 @@ namespace easy2d | ||||||
| 		return S_OK; | 		return S_OK; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::FillGeometry(cpGeometry const & geometry, const Color & fill_color) | 	HRESULT GraphicsDevice::FillGeometry(CpGeometry const & geometry, const Color & fill_color) | ||||||
| 	{ | 	{ | ||||||
| 		if (!solid_brush_ || | 		if (!solid_brush_ || | ||||||
| 			!render_target_) | 			!render_target_) | ||||||
|  | @ -187,7 +187,7 @@ namespace easy2d | ||||||
| 		return S_OK; | 		return S_OK; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::DrawImage(spImage const & image) | 	HRESULT GraphicsDevice::DrawImage(SpImage const & image) | ||||||
| 	{ | 	{ | ||||||
| 		if (!render_target_) | 		if (!render_target_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
|  | @ -212,7 +212,7 @@ namespace easy2d | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::DrawBitmap( | 	HRESULT GraphicsDevice::DrawBitmap( | ||||||
| 		cpBitmap const& bitmap | 		CpBitmap const& bitmap | ||||||
| 	) | 	) | ||||||
| 	{ | 	{ | ||||||
| 		if (!render_target_) | 		if (!render_target_) | ||||||
|  | @ -236,7 +236,7 @@ namespace easy2d | ||||||
| 		return S_OK; | 		return S_OK; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::DrawTextLayout(cpTextLayout const& text_layout) | 	HRESULT GraphicsDevice::DrawTextLayout(CpTextLayout const& text_layout) | ||||||
| 	{ | 	{ | ||||||
| 		if (!text_renderer_) | 		if (!text_renderer_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
|  | @ -277,7 +277,7 @@ namespace easy2d | ||||||
| 		return S_OK; | 		return S_OK; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::PushLayer(cpLayer const& layer, LayerProperties const& properties) | 	HRESULT GraphicsDevice::PushLayer(CpLayer const& layer, LayerProperties const& properties) | ||||||
| 	{ | 	{ | ||||||
| 		if (!render_target_ || | 		if (!render_target_ || | ||||||
| 			!solid_brush_) | 			!solid_brush_) | ||||||
|  | @ -324,7 +324,7 @@ namespace easy2d | ||||||
| 		return S_OK; | 		return S_OK; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::CreateBitmapFromFile(cpBitmap& bitmap, std::wstring const& file_path) | 	HRESULT GraphicsDevice::CreateBitmapFromFile(CpBitmap& bitmap, std::wstring const& file_path) | ||||||
| 	{ | 	{ | ||||||
| 		if (render_target_ == nullptr) | 		if (render_target_ == nullptr) | ||||||
| 		{ | 		{ | ||||||
|  | @ -338,7 +338,7 @@ namespace easy2d | ||||||
| 			return S_OK; | 			return S_OK; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		cpBitmap bitmap_tmp; | 		CpBitmap bitmap_tmp; | ||||||
| 		HRESULT hr = Factory::Instance()->CreateBitmapFromFile( | 		HRESULT hr = Factory::Instance()->CreateBitmapFromFile( | ||||||
| 			bitmap, | 			bitmap, | ||||||
| 			render_target_, | 			render_target_, | ||||||
|  | @ -353,7 +353,7 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::CreateBitmapFromResource(cpBitmap& bitmap, Resource const& res) | 	HRESULT GraphicsDevice::CreateBitmapFromResource(CpBitmap& bitmap, Resource const& res) | ||||||
| 	{ | 	{ | ||||||
| 		if (render_target_ == nullptr) | 		if (render_target_ == nullptr) | ||||||
| 		{ | 		{ | ||||||
|  | @ -381,7 +381,7 @@ namespace easy2d | ||||||
| 		return hr; | 		return hr; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	HRESULT GraphicsDevice::CreateBitmapRenderTarget(cpBitmapRenderTarget & brt) | 	HRESULT GraphicsDevice::CreateBitmapRenderTarget(CpBitmapRenderTarget & brt) | ||||||
| 	{ | 	{ | ||||||
| 		if (!render_target_) | 		if (!render_target_) | ||||||
| 			return E_UNEXPECTED; | 			return E_UNEXPECTED; | ||||||
|  |  | ||||||
|  | @ -43,7 +43,7 @@ namespace easy2d | ||||||
| 			int primitives; | 			int primitives; | ||||||
| 		}; | 		}; | ||||||
| 
 | 
 | ||||||
| 		using BitmapMap = std::unordered_map<size_t, cpBitmap>; | 		using BitmapMap = std::unordered_map<size_t, CpBitmap>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		HRESULT Init(HWND hwnd, bool vsync, bool debug); | 		HRESULT Init(HWND hwnd, bool vsync, bool debug); | ||||||
|  | @ -78,25 +78,25 @@ namespace easy2d | ||||||
| 		void DiscardResources(); | 		void DiscardResources(); | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateLayer( | 		HRESULT CreateLayer( | ||||||
| 			cpLayer& layer | 			CpLayer& layer | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateSolidColorBrush( | 		HRESULT CreateSolidColorBrush( | ||||||
| 			cpSolidColorBrush& brush | 			CpSolidColorBrush& brush | ||||||
| 		) const; | 		) const; | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateBitmapFromFile( | 		HRESULT CreateBitmapFromFile( | ||||||
| 			cpBitmap& bitmap, | 			CpBitmap& bitmap, | ||||||
| 			std::wstring const& file_path | 			std::wstring const& file_path | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateBitmapFromResource( | 		HRESULT CreateBitmapFromResource( | ||||||
| 			cpBitmap& bitmap, | 			CpBitmap& bitmap, | ||||||
| 			Resource const& res | 			Resource const& res | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT CreateBitmapRenderTarget( | 		HRESULT CreateBitmapRenderTarget( | ||||||
| 			cpBitmapRenderTarget& brt | 			CpBitmapRenderTarget& brt | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT SetTransform( | 		HRESULT SetTransform( | ||||||
|  | @ -116,27 +116,27 @@ namespace easy2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT DrawGeometry( | 		HRESULT DrawGeometry( | ||||||
| 			cpGeometry const& geometry, | 			CpGeometry const& geometry, | ||||||
| 			const Color& stroke_color, | 			const Color& stroke_color, | ||||||
| 			float stroke_width, | 			float stroke_width, | ||||||
| 			StrokeStyle stroke = StrokeStyle::Miter | 			StrokeStyle stroke = StrokeStyle::Miter | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT FillGeometry( | 		HRESULT FillGeometry( | ||||||
| 			cpGeometry const& geometry, | 			CpGeometry const& geometry, | ||||||
| 			const Color& fill_color | 			const Color& fill_color | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT DrawImage( | 		HRESULT DrawImage( | ||||||
| 			spImage const& image | 			SpImage const& image | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT DrawBitmap( | 		HRESULT DrawBitmap( | ||||||
| 			cpBitmap const& bitmap | 			CpBitmap const& bitmap | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT DrawTextLayout( | 		HRESULT DrawTextLayout( | ||||||
| 			cpTextLayout const& text_layout | 			CpTextLayout const& text_layout | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		HRESULT PushClip( | 		HRESULT PushClip( | ||||||
|  | @ -147,7 +147,7 @@ namespace easy2d | ||||||
| 		HRESULT PopClip(); | 		HRESULT PopClip(); | ||||||
| 
 | 
 | ||||||
| 		HRESULT PushLayer( | 		HRESULT PushLayer( | ||||||
| 			cpLayer const& layer, | 			CpLayer const& layer, | ||||||
| 			LayerProperties const& properties | 			LayerProperties const& properties | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
|  | @ -164,9 +164,9 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		void ClearImageCache(); | 		void ClearImageCache(); | ||||||
| 
 | 
 | ||||||
| 		cpHwndRenderTarget const& GetRenderTarget() const; | 		CpHwndRenderTarget const& GetRenderTarget() const; | ||||||
| 
 | 
 | ||||||
| 		cpSolidColorBrush const& GetSolidBrush() const; | 		CpSolidColorBrush const& GetSolidBrush() const; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		GraphicsDevice(); | 		GraphicsDevice(); | ||||||
|  | @ -182,11 +182,11 @@ namespace easy2d | ||||||
| 		D2D1_COLOR_F		clear_color_; | 		D2D1_COLOR_F		clear_color_; | ||||||
| 		TextAntialias		text_antialias_; | 		TextAntialias		text_antialias_; | ||||||
| 		Status				status_; | 		Status				status_; | ||||||
| 		cpTextRenderer		text_renderer_; | 		CpTextRenderer		text_renderer_; | ||||||
| 		cpSolidColorBrush	solid_brush_; | 		CpSolidColorBrush	solid_brush_; | ||||||
| 		cpHwndRenderTarget	render_target_; | 		CpHwndRenderTarget	render_target_; | ||||||
| 		cpTextFormat		fps_text_format_; | 		CpTextFormat		fps_text_format_; | ||||||
| 		cpTextLayout		fps_text_layout_; | 		CpTextLayout		fps_text_layout_; | ||||||
| 		BitmapMap			bitmap_cache_; | 		BitmapMap			bitmap_cache_; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ namespace easy2d | ||||||
| 		{ | 		{ | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		TimePoint::TimePoint(long long dur) | 		TimePoint::TimePoint(long dur) | ||||||
| 			: dur(dur) | 			: dur(dur) | ||||||
| 		{ | 		{ | ||||||
| 		} | 		} | ||||||
|  | @ -124,7 +124,7 @@ namespace easy2d | ||||||
| 		{ | 		{ | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Duration::Duration(long long milliseconds) | 		Duration::Duration(long milliseconds) | ||||||
| 			: milliseconds_(milliseconds) | 			: milliseconds_(milliseconds) | ||||||
| 		{ | 		{ | ||||||
| 		} | 		} | ||||||
|  | @ -257,42 +257,32 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		const Duration easy2d::time::Duration::operator*(unsigned long long val) const | 		const Duration easy2d::time::Duration::operator*(unsigned long long val) const | ||||||
| 		{ | 		{ | ||||||
| 			return Duration(static_cast<long long>(milliseconds_ * val)); | 			return Duration(static_cast<long>(milliseconds_ * val)); | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		const Duration easy2d::time::Duration::operator/(unsigned long long val) const |  | ||||||
| 		{ |  | ||||||
| 			return Duration(static_cast<long long>(milliseconds_ / val)); |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const Duration Duration::operator*(float val) const | 		const Duration Duration::operator*(float val) const | ||||||
| 		{ | 		{ | ||||||
| 			return Duration(static_cast<long long>(milliseconds_ * val)); | 			return Duration(static_cast<long>(milliseconds_ * val)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const Duration Duration::operator/(float val) const | 		const Duration Duration::operator/(float val) const | ||||||
| 		{ | 		{ | ||||||
| 			return Duration(static_cast<long long>(milliseconds_ / val)); | 			return Duration(static_cast<long>(milliseconds_ / val)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const Duration Duration::operator*(double val) const | 		const Duration Duration::operator*(double val) const | ||||||
| 		{ | 		{ | ||||||
| 			return Duration(static_cast<long long>(milliseconds_ * val)); | 			return Duration(static_cast<long>(milliseconds_ * val)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const Duration Duration::operator*(long double val) const | 		const Duration Duration::operator*(long double val) const | ||||||
| 		{ | 		{ | ||||||
| 			return Duration(static_cast<long long>(milliseconds_ * val)); | 			return Duration(static_cast<long>(milliseconds_ * val)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const Duration Duration::operator/(double val) const | 		const Duration Duration::operator/(double val) const | ||||||
| 		{ | 		{ | ||||||
| 			return Duration(static_cast<long long>(milliseconds_ / val)); | 			return Duration(static_cast<long>(milliseconds_ / val)); | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		const Duration Duration::operator/(long double val) const |  | ||||||
| 		{ |  | ||||||
| 			return Duration(static_cast<long long>(milliseconds_ / val)); |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Duration & Duration::operator+=(const Duration &other) | 		Duration & Duration::operator+=(const Duration &other) | ||||||
|  | @ -315,55 +305,31 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 		Duration & Duration::operator/=(int val) | 		Duration & Duration::operator/=(int val) | ||||||
| 		{ | 		{ | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ / val); | 			milliseconds_ = static_cast<long>(milliseconds_ / val); | ||||||
| 			return (*this); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		Duration & easy2d::time::Duration::operator*=(unsigned long long val) |  | ||||||
| 		{ |  | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ * val); |  | ||||||
| 			return (*this); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		Duration & easy2d::time::Duration::operator/=(unsigned long long val) |  | ||||||
| 		{ |  | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ * val); |  | ||||||
| 			return (*this); | 			return (*this); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Duration & Duration::operator*=(float val) | 		Duration & Duration::operator*=(float val) | ||||||
| 		{ | 		{ | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ * val); | 			milliseconds_ = static_cast<long>(milliseconds_ * val); | ||||||
| 			return (*this); | 			return (*this); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Duration & Duration::operator/=(float val) | 		Duration & Duration::operator/=(float val) | ||||||
| 		{ | 		{ | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ / val); | 			milliseconds_ = static_cast<long>(milliseconds_ / val); | ||||||
| 			return (*this); | 			return (*this); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Duration & Duration::operator*=(double val) | 		Duration & Duration::operator*=(double val) | ||||||
| 		{ | 		{ | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ * val); | 			milliseconds_ = static_cast<long>(milliseconds_ * val); | ||||||
| 			return (*this); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		Duration & Duration::operator*=(long double val) |  | ||||||
| 		{ |  | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ * val); |  | ||||||
| 			return (*this); | 			return (*this); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Duration & Duration::operator/=(double val) | 		Duration & Duration::operator/=(double val) | ||||||
| 		{ | 		{ | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ / val); | 			milliseconds_ = static_cast<long>(milliseconds_ / val); | ||||||
| 			return (*this); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		Duration & Duration::operator/=(long double val) |  | ||||||
| 		{ |  | ||||||
| 			milliseconds_ = static_cast<long long>(milliseconds_ / val); |  | ||||||
| 			return (*this); | 			return (*this); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -372,21 +338,11 @@ namespace easy2d | ||||||
| 			return dur * val; | 			return dur * val; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const Duration easy2d::time::operator*(unsigned long long val, const Duration & dur) |  | ||||||
| 		{ |  | ||||||
| 			return dur / val; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		const Duration easy2d::time::operator/(int val, const Duration & dur) | 		const Duration easy2d::time::operator/(int val, const Duration & dur) | ||||||
| 		{ | 		{ | ||||||
| 			return dur / val; | 			return dur / val; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const Duration easy2d::time::operator/(unsigned long long val, const Duration & dur) |  | ||||||
| 		{ |  | ||||||
| 			return dur * val; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		const Duration easy2d::time::operator*(float val, const Duration & dur) | 		const Duration easy2d::time::operator*(float val, const Duration & dur) | ||||||
| 		{ | 		{ | ||||||
| 			return dur * val; | 			return dur * val; | ||||||
|  | @ -412,11 +368,6 @@ namespace easy2d | ||||||
| 			return dur * val; | 			return dur * val; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const Duration easy2d::time::operator/(long double val, const Duration & dur) |  | ||||||
| 		{ |  | ||||||
| 			return dur / val; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		std::wostream & easy2d::time::operator<<(std::wostream & out, const Duration & dur) | 		std::wostream & easy2d::time::operator<<(std::wostream & out, const Duration & dur) | ||||||
| 		{ | 		{ | ||||||
| 			return out << dur.ToString(); | 			return out << dur.ToString(); | ||||||
|  | @ -449,7 +400,7 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 			const long long whole = (count.QuadPart / freq.QuadPart) * 1000LL; | 			const long long whole = (count.QuadPart / freq.QuadPart) * 1000LL; | ||||||
| 			const long long part = (count.QuadPart % freq.QuadPart) * 1000LL / freq.QuadPart; | 			const long long part = (count.QuadPart % freq.QuadPart) * 1000LL / freq.QuadPart; | ||||||
| 			return TimePoint{ whole + part }; | 			return TimePoint{ static_cast<long>(whole + part) }; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Duration easy2d::time::ParseDuration(const std::wstring & str) | 		Duration easy2d::time::ParseDuration(const std::wstring & str) | ||||||
|  |  | ||||||
|  | @ -20,7 +20,6 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| #include "macros.h" | #include "macros.h" | ||||||
| #include <cstdint> |  | ||||||
| 
 | 
 | ||||||
| namespace easy2d | namespace easy2d | ||||||
| { | { | ||||||
|  | @ -45,11 +44,11 @@ namespace easy2d | ||||||
| 			Duration(); | 			Duration(); | ||||||
| 
 | 
 | ||||||
| 			explicit Duration( | 			explicit Duration( | ||||||
| 				long long milliseconds | 				long milliseconds | ||||||
| 			); | 			); | ||||||
| 
 | 
 | ||||||
| 			// 转化为毫秒
 | 			// 转化为毫秒
 | ||||||
| 			inline long long Milliseconds() const { return milliseconds_; } | 			inline long Milliseconds() const { return milliseconds_; } | ||||||
| 
 | 
 | ||||||
| 			// 转化为秒
 | 			// 转化为秒
 | ||||||
| 			float Seconds() const; | 			float Seconds() const; | ||||||
|  | @ -84,40 +83,31 @@ namespace easy2d | ||||||
| 			const Duration operator * (double) const; | 			const Duration operator * (double) const; | ||||||
| 			const Duration operator * (long double) const; | 			const Duration operator * (long double) const; | ||||||
| 			const Duration operator / (int) const; | 			const Duration operator / (int) const; | ||||||
| 			const Duration operator / (unsigned long long) const; |  | ||||||
| 			const Duration operator / (float) const; | 			const Duration operator / (float) const; | ||||||
| 			const Duration operator / (double) const; | 			const Duration operator / (double) const; | ||||||
| 			const Duration operator / (long double) const; |  | ||||||
| 
 | 
 | ||||||
| 			Duration& operator += (const Duration &); | 			Duration& operator += (const Duration &); | ||||||
| 			Duration& operator -= (const Duration &); | 			Duration& operator -= (const Duration &); | ||||||
| 			Duration& operator *= (int); | 			Duration& operator *= (int); | ||||||
| 			Duration& operator *= (unsigned long long); |  | ||||||
| 			Duration& operator *= (float); | 			Duration& operator *= (float); | ||||||
| 			Duration& operator *= (double); | 			Duration& operator *= (double); | ||||||
| 			Duration& operator *= (long double); |  | ||||||
| 			Duration& operator /= (int); | 			Duration& operator /= (int); | ||||||
| 			Duration& operator /= (unsigned long long); |  | ||||||
| 			Duration& operator /= (float); | 			Duration& operator /= (float); | ||||||
| 			Duration& operator /= (double); | 			Duration& operator /= (double); | ||||||
| 			Duration& operator /= (long double); |  | ||||||
| 
 | 
 | ||||||
| 			friend const Duration operator* (int, const Duration &); | 			friend const Duration operator* (int, const Duration &); | ||||||
| 			friend const Duration operator* (unsigned long long, const Duration &); |  | ||||||
| 			friend const Duration operator* (float, const Duration &); | 			friend const Duration operator* (float, const Duration &); | ||||||
| 			friend const Duration operator* (double, const Duration &); | 			friend const Duration operator* (double, const Duration &); | ||||||
| 			friend const Duration operator* (long double, const Duration &); | 			friend const Duration operator* (long double, const Duration &); | ||||||
| 			friend const Duration operator/ (int, const Duration &); | 			friend const Duration operator/ (int, const Duration &); | ||||||
| 			friend const Duration operator/ (unsigned long long, const Duration &); |  | ||||||
| 			friend const Duration operator/ (float, const Duration &); | 			friend const Duration operator/ (float, const Duration &); | ||||||
| 			friend const Duration operator/ (double, const Duration &); | 			friend const Duration operator/ (double, const Duration &); | ||||||
| 			friend const Duration operator/ (long double, const Duration &); |  | ||||||
| 
 | 
 | ||||||
| 			friend std::wostream& operator<< (std::wostream &, const Duration &); | 			friend std::wostream& operator<< (std::wostream &, const Duration &); | ||||||
| 			friend std::wistream& operator>> (std::wistream &, Duration &); | 			friend std::wistream& operator>> (std::wistream &, Duration &); | ||||||
| 
 | 
 | ||||||
| 		private: | 		private: | ||||||
| 			long long milliseconds_; | 			long milliseconds_; | ||||||
| 		}; | 		}; | ||||||
| 
 | 
 | ||||||
| 		extern const Duration Millisecond;	// 毫秒
 | 		extern const Duration Millisecond;	// 毫秒
 | ||||||
|  | @ -129,12 +119,12 @@ namespace easy2d | ||||||
| 		// 时间
 | 		// 时间
 | ||||||
| 		//
 | 		//
 | ||||||
| 		// Usage:
 | 		// Usage:
 | ||||||
| 		//     »ñÈ¡µ±Ç°Ê±¼ä: Time now = time::Now();
 | 		//     获取当前时间: TimePoint now = time::Now();
 | ||||||
| 		//     时间操作:
 | 		//     时间操作:
 | ||||||
| 		//         两时间相减, 得到一个 Duration 对象, 例如:
 | 		//         两时间相减, 得到一个 Duration 对象, 例如:
 | ||||||
| 		//         Time t1 = time::Now();
 | 		//         TimePoint t1 = time::Now();
 | ||||||
| 		//         ...  // 做些什么
 | 		//         ...  // 做些什么
 | ||||||
| 		//         Time t2 = time::Now();
 | 		//         TimePoint t2 = time::Now();
 | ||||||
| 		//         auto duration = t2 - t1;
 | 		//         auto duration = t2 - t1;
 | ||||||
| 		//         获取两时间相差的毫秒数:
 | 		//         获取两时间相差的毫秒数:
 | ||||||
| 		//         int ms = duration.Milliseconds();
 | 		//         int ms = duration.Milliseconds();
 | ||||||
|  | @ -147,7 +137,7 @@ namespace easy2d | ||||||
| 			TimePoint(); | 			TimePoint(); | ||||||
| 
 | 
 | ||||||
| 			explicit TimePoint( | 			explicit TimePoint( | ||||||
| 				long long | 				long | ||||||
| 			); | 			); | ||||||
| 
 | 
 | ||||||
| 			TimePoint( | 			TimePoint( | ||||||
|  | @ -173,7 +163,7 @@ namespace easy2d | ||||||
| 			TimePoint& operator = (TimePoint &&) E2D_NOEXCEPT; | 			TimePoint& operator = (TimePoint &&) E2D_NOEXCEPT; | ||||||
| 
 | 
 | ||||||
| 		private: | 		private: | ||||||
| 			long long dur; | 			long dur; | ||||||
| 		}; | 		}; | ||||||
| 
 | 
 | ||||||
| 		// 获取当前时间
 | 		// 获取当前时间
 | ||||||
|  |  | ||||||
|  | @ -55,7 +55,7 @@ namespace easy2d | ||||||
| 		WNDCLASSEX wcex		= { 0 }; | 		WNDCLASSEX wcex		= { 0 }; | ||||||
| 		wcex.cbSize			= sizeof(WNDCLASSEX); | 		wcex.cbSize			= sizeof(WNDCLASSEX); | ||||||
| 		wcex.lpszClassName	= REGISTER_CLASS; | 		wcex.lpszClassName	= REGISTER_CLASS; | ||||||
| 		wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | 		wcex.style			= CS_HREDRAW | CS_VREDRAW /* | CS_DBLCLKS */; | ||||||
| 		wcex.lpfnWndProc	= proc; | 		wcex.lpfnWndProc	= proc; | ||||||
| 		wcex.hIcon			= nullptr; | 		wcex.hIcon			= nullptr; | ||||||
| 		wcex.cbClsExtra		= 0; | 		wcex.cbClsExtra		= 0; | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ namespace easy2d | ||||||
| 		{ | 		{ | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Menu::Menu(const std::vector<spButton>& buttons) | 		Menu::Menu(const std::vector<SpButton>& buttons) | ||||||
| 			: enabled_(true) | 			: enabled_(true) | ||||||
| 		{ | 		{ | ||||||
| 			for (const auto& button : buttons) | 			for (const auto& button : buttons) | ||||||
|  | @ -61,7 +61,7 @@ namespace easy2d | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		void Menu::AddButton(spButton const& button) | 		void Menu::AddButton(SpButton const& button) | ||||||
| 		{ | 		{ | ||||||
| 			if (button) | 			if (button) | ||||||
| 			{ | 			{ | ||||||
|  | @ -71,7 +71,7 @@ namespace easy2d | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		bool Menu::RemoveButton(spButton const& button) | 		bool Menu::RemoveButton(SpButton const& button) | ||||||
| 		{ | 		{ | ||||||
| 			if (buttons_.empty()) | 			if (buttons_.empty()) | ||||||
| 			{ | 			{ | ||||||
|  | @ -94,7 +94,7 @@ namespace easy2d | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const std::vector<spButton>& Menu::GetAllButtons() const | 		const std::vector<SpButton>& Menu::GetAllButtons() const | ||||||
| 		{ | 		{ | ||||||
| 			return buttons_; | 			return buttons_; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ namespace easy2d | ||||||
| 			Menu(); | 			Menu(); | ||||||
| 
 | 
 | ||||||
| 			explicit Menu( | 			explicit Menu( | ||||||
| 				const std::vector<spButton>& buttons	/* 按钮数组 */ | 				const std::vector<SpButton>& buttons	/* 按钮数组 */ | ||||||
| 			); | 			); | ||||||
| 
 | 
 | ||||||
| 			// 获取菜单是否禁用
 | 			// 获取菜单是否禁用
 | ||||||
|  | @ -49,20 +49,20 @@ namespace easy2d | ||||||
| 
 | 
 | ||||||
| 			// 添加按钮
 | 			// 添加按钮
 | ||||||
| 			void AddButton( | 			void AddButton( | ||||||
| 				spButton const& button | 				SpButton const& button | ||||||
| 			); | 			); | ||||||
| 
 | 
 | ||||||
| 			// 移除按钮
 | 			// 移除按钮
 | ||||||
| 			bool RemoveButton( | 			bool RemoveButton( | ||||||
| 				spButton const& button | 				SpButton const& button | ||||||
| 			); | 			); | ||||||
| 
 | 
 | ||||||
| 			// 获取所有按钮
 | 			// 获取所有按钮
 | ||||||
| 			const std::vector<spButton>& GetAllButtons() const; | 			const std::vector<SpButton>& GetAllButtons() const; | ||||||
| 
 | 
 | ||||||
| 		private: | 		private: | ||||||
| 			bool enabled_; | 			bool enabled_; | ||||||
| 			std::vector<spButton> buttons_; | 			std::vector<SpButton> buttons_; | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -38,7 +38,7 @@ namespace easy2d | ||||||
| 		if (file_path.empty()) | 		if (file_path.empty()) | ||||||
| 			return false; | 			return false; | ||||||
| 
 | 
 | ||||||
| 		spMusic music = new (std::nothrow) Music(); | 		SpMusic music = new (std::nothrow) Music(); | ||||||
| 
 | 
 | ||||||
| 		if (music) | 		if (music) | ||||||
| 		{ | 		{ | ||||||
|  | @ -117,7 +117,7 @@ namespace easy2d | ||||||
| 		if (musics_cache_.end() != musics_cache_.find(hash_code)) | 		if (musics_cache_.end() != musics_cache_.find(hash_code)) | ||||||
| 			return true; | 			return true; | ||||||
| 
 | 
 | ||||||
| 		spMusic music = new (std::nothrow) Music(); | 		SpMusic music = new (std::nothrow) Music(); | ||||||
| 
 | 
 | ||||||
| 		if (music) | 		if (music) | ||||||
| 		{ | 		{ | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ namespace easy2d | ||||||
| 	class Player | 	class Player | ||||||
| 		: protected Noncopyable | 		: protected Noncopyable | ||||||
| 	{ | 	{ | ||||||
| 		using MusicMap = std::unordered_map<size_t, spMusic>; | 		using MusicMap = std::unordered_map<size_t, SpMusic>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		Player(); | 		Player(); | ||||||
|  |  | ||||||
|  | @ -79,7 +79,7 @@ namespace easy2d | ||||||
| 		ResourceData buffer; | 		ResourceData buffer; | ||||||
| 		if (!res.Load(&buffer)) { return false; } | 		if (!res.Load(&buffer)) { return false; } | ||||||
| 
 | 
 | ||||||
| 		stream = SHCreateMemStream( | 		stream = modules::Shlwapi{}.SHCreateMemStream( | ||||||
| 			static_cast<const BYTE*>(buffer.buffer), | 			static_cast<const BYTE*>(buffer.buffer), | ||||||
| 			static_cast<UINT>(buffer.buffer_size) | 			static_cast<UINT>(buffer.buffer_size) | ||||||
| 		); | 		); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue