diff --git a/core/Action/Animate.cpp b/core/Action/Animate.cpp index a44b1c87..35d613ca 100644 --- a/core/Action/Animate.cpp +++ b/core/Action/Animate.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::Animate::Animate() : frame_index_(0) diff --git a/core/Action/JumpBy.cpp b/core/Action/JumpBy.cpp index daa844e5..dd373f51 100644 --- a/core/Action/JumpBy.cpp +++ b/core/Action/JumpBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::JumpBy::JumpBy(float duration, const Point & vec, float height, int jumps) : FiniteTimeAction(duration) diff --git a/core/Action/JumpTo.cpp b/core/Action/JumpTo.cpp index 8be792d9..ebe1968e 100644 --- a/core/Action/JumpTo.cpp +++ b/core/Action/JumpTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::JumpTo::JumpTo(float duration, const Point & pos, float height, int jumps) : JumpBy(duration, Point(), height, jumps) diff --git a/core/Action/MoveBy.cpp b/core/Action/MoveBy.cpp index 15104c72..7c819e94 100644 --- a/core/Action/MoveBy.cpp +++ b/core/Action/MoveBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::MoveBy::MoveBy(float duration, Point vector) diff --git a/core/Action/MoveTo.cpp b/core/Action/MoveTo.cpp index a058b245..001ac250 100644 --- a/core/Action/MoveTo.cpp +++ b/core/Action/MoveTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::MoveTo::MoveTo(float duration, Point pos) : MoveBy(duration, Point()) diff --git a/core/Action/OpacityBy.cpp b/core/Action/OpacityBy.cpp index 9ec1d346..5bdc36a2 100644 --- a/core/Action/OpacityBy.cpp +++ b/core/Action/OpacityBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::OpacityBy::OpacityBy(float duration, float opacity) diff --git a/core/Action/OpacityTo.cpp b/core/Action/OpacityTo.cpp index 42cd2e11..e55b1299 100644 --- a/core/Action/OpacityTo.cpp +++ b/core/Action/OpacityTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::OpacityTo::OpacityTo(float duration, float opacity) diff --git a/core/Action/RotateBy.cpp b/core/Action/RotateBy.cpp index 76f6b028..71ae1f33 100644 --- a/core/Action/RotateBy.cpp +++ b/core/Action/RotateBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::RotateBy::RotateBy(float duration, float rotation) diff --git a/core/Action/RotateTo.cpp b/core/Action/RotateTo.cpp index cc68db3a..18b64e50 100644 --- a/core/Action/RotateTo.cpp +++ b/core/Action/RotateTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::RotateTo::RotateTo(float duration, float rotation) diff --git a/core/Action/ScaleBy.cpp b/core/Action/ScaleBy.cpp index 8e2b1c79..b03a8f53 100644 --- a/core/Action/ScaleBy.cpp +++ b/core/Action/ScaleBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::ScaleBy::ScaleBy(float duration, float scale) diff --git a/core/Action/ScaleTo.cpp b/core/Action/ScaleTo.cpp index 60df03d8..0855e660 100644 --- a/core/Action/ScaleTo.cpp +++ b/core/Action/ScaleTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::ScaleTo::ScaleTo(float duration, float scale) : ScaleBy(duration, 0, 0) diff --git a/core/Base/GC.cpp b/core/Base/GC.cpp index 5dc7898c..16fee797 100644 --- a/core/Base/GC.cpp +++ b/core/Base/GC.cpp @@ -1,5 +1,5 @@ #include "..\e2dmodule.h" -#include "..\e2dutil.h" +#include "..\e2dtool.h" #include "..\e2dmanager.h" using namespace e2d; diff --git a/core/Base/Game.cpp b/core/Base/Game.cpp index 6dc93c98..0edc169c 100644 --- a/core/Base/Game.cpp +++ b/core/Base/Game.cpp @@ -1,8 +1,8 @@ #include "..\e2dmodule.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include "..\e2dtransition.h" #include "..\e2dmanager.h" -#include "..\e2dutil.h" +#include "..\e2dtool.h" #include diff --git a/core/Base/Input.cpp b/core/Base/Input.cpp index 605898f9..3c3e91c2 100644 --- a/core/Base/Input.cpp +++ b/core/Base/Input.cpp @@ -1,5 +1,5 @@ #include "..\e2dmodule.h" -#include "..\e2dutil.h" +#include "..\e2dtool.h" #include "..\e2dmanager.h" #pragma comment(lib, "dinput8.lib") diff --git a/core/Base/Renderer.cpp b/core/Base/Renderer.cpp index de891b3c..3aa412d7 100644 --- a/core/Base/Renderer.cpp +++ b/core/Base/Renderer.cpp @@ -1,6 +1,6 @@ #include "..\e2dmodule.h" #include "..\e2dmanager.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::Renderer* e2d::Renderer::instance_ = nullptr; diff --git a/core/Base/Window.cpp b/core/Base/Window.cpp index 743f9e9d..17b052b0 100644 --- a/core/Base/Window.cpp +++ b/core/Base/Window.cpp @@ -1,6 +1,6 @@ #include "..\e2dmodule.h" #include "..\e2dmanager.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include #pragma comment (lib ,"imm32.lib") diff --git a/core/Common/Collider.cpp b/core/Common/Collider.cpp index 3a30fd18..038f0b6a 100644 --- a/core/Common/Collider.cpp +++ b/core/Common/Collider.cpp @@ -1,8 +1,8 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" #include "..\e2dimpl.h" #include "..\e2dmodule.h" #include "..\e2dmanager.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::Collider::Collider(Node * parent) : visible_(true) diff --git a/core/Common/Color.cpp b/core/Common/Color.cpp index 1d48901d..544a751a 100644 --- a/core/Common/Color.cpp +++ b/core/Common/Color.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" static const UINT sc_redShift = 16; static const UINT sc_greenShift = 8; diff --git a/core/Common/Duration.cpp b/core/Common/Duration.cpp index d5c08768..5ae45914 100644 --- a/core/Common/Duration.cpp +++ b/core/Common/Duration.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" using namespace std::chrono; diff --git a/core/Common/Font.cpp b/core/Common/Font.cpp index 474dd1d2..a2ec02da 100644 --- a/core/Common/Font.cpp +++ b/core/Common/Font.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" e2d::Font::Font() : family("") diff --git a/core/Common/Function.cpp b/core/Common/Function.cpp index 520e405d..93067dee 100644 --- a/core/Common/Function.cpp +++ b/core/Common/Function.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" e2d::Function::Function() : func_(nullptr) diff --git a/core/Common/Image.cpp b/core/Common/Image.cpp index f1f2621f..f6b1873b 100644 --- a/core/Common/Image.cpp +++ b/core/Common/Image.cpp @@ -1,6 +1,6 @@ -#include "..\e2dcommon.h" -#include "..\e2dmodule.h" #include "..\e2dutil.h" +#include "..\e2dmodule.h" +#include "..\e2dtool.h" std::map e2d::Image::bitmap_cache_; diff --git a/core/Common/Point.cpp b/core/Common/Point.cpp index 48463d97..a007d2ef 100644 --- a/core/Common/Point.cpp +++ b/core/Common/Point.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" #include diff --git a/core/Common/Rect.cpp b/core/Common/Rect.cpp index 4ca4a78e..8c666100 100644 --- a/core/Common/Rect.cpp +++ b/core/Common/Rect.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" e2d::Rect::Rect(void) : origin() diff --git a/core/Common/Ref.cpp b/core/Common/Ref.cpp index 7db787b0..71dbad35 100644 --- a/core/Common/Ref.cpp +++ b/core/Common/Ref.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" e2d::Ref::Ref() : ref_count_(0) diff --git a/core/Common/Resource.cpp b/core/Common/Resource.cpp index 0e62e3c2..e3807d62 100644 --- a/core/Common/Resource.cpp +++ b/core/Common/Resource.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" e2d::Resource::Resource(size_t resource_name, const String & resource_type) diff --git a/core/Common/Size.cpp b/core/Common/Size.cpp index 8d043c7d..a88f0586 100644 --- a/core/Common/Size.cpp +++ b/core/Common/Size.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" e2d::Size::Size() { diff --git a/core/Common/String.cpp b/core/Common/String.cpp index f8e6f709..b6cc6e73 100644 --- a/core/Common/String.cpp +++ b/core/Common/String.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" #include #include #include diff --git a/core/Common/Time.cpp b/core/Common/Time.cpp index 79e6f416..7f9c1309 100644 --- a/core/Common/Time.cpp +++ b/core/Common/Time.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcommon.h" +#include "..\e2dutil.h" using namespace std::chrono; diff --git a/core/Node/Button.cpp b/core/Component/Button.cpp similarity index 100% rename from core/Node/Button.cpp rename to core/Component/Button.cpp diff --git a/core/Node/Menu.cpp b/core/Component/Menu.cpp similarity index 100% rename from core/Node/Menu.cpp rename to core/Component/Menu.cpp diff --git a/core/Node/ToggleButton.cpp b/core/Component/ToggleButton.cpp similarity index 100% rename from core/Node/ToggleButton.cpp rename to core/Component/ToggleButton.cpp diff --git a/core/Custom/VoiceCallback.cpp b/core/Custom/VoiceCallback.cpp index 04cae99b..7a7781cf 100644 --- a/core/Custom/VoiceCallback.cpp +++ b/core/Custom/VoiceCallback.cpp @@ -1,5 +1,5 @@ #include "..\e2dimpl.h" -#include "..\e2dcommon.h" +#include "..\e2dutil.h" e2d::VoiceCallback::VoiceCallback() { diff --git a/core/Manager/CollisionManager.cpp b/core/Manager/CollisionManager.cpp index c878e15f..ef28ce62 100644 --- a/core/Manager/CollisionManager.cpp +++ b/core/Manager/CollisionManager.cpp @@ -1,6 +1,6 @@ #include "..\e2dmanager.h" -#include "..\e2dcomponent.h" -#include "..\e2dutil.h" +#include "..\e2dnode.h" +#include "..\e2dtool.h" #include "..\e2dmodule.h" diff --git a/core/Node/Canvas.cpp b/core/Node/Canvas.cpp index 9885b1c6..11f3aa00 100644 --- a/core/Node/Canvas.cpp +++ b/core/Node/Canvas.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include "..\e2dmodule.h" e2d::Canvas::Canvas(float width, float height) diff --git a/core/Node/Node.cpp b/core/Node/Node.cpp index 7872be2b..8fd05b19 100644 --- a/core/Node/Node.cpp +++ b/core/Node/Node.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include "..\e2devent.h" #include "..\e2dmanager.h" #include "..\e2daction.h" diff --git a/core/Node/Scene.cpp b/core/Node/Scene.cpp index 5cb55300..3d25f261 100644 --- a/core/Node/Scene.cpp +++ b/core/Node/Scene.cpp @@ -1,5 +1,5 @@ #include "..\e2dmodule.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include "..\e2dmanager.h" e2d::Scene::Scene() diff --git a/core/Node/Sprite.cpp b/core/Node/Sprite.cpp index 439dc0fc..9ca252fe 100644 --- a/core/Node/Sprite.cpp +++ b/core/Node/Sprite.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include "..\e2dmodule.h" e2d::Sprite::Sprite() diff --git a/core/Node/Text.cpp b/core/Node/Text.cpp index 7ad0b9a3..eca30375 100644 --- a/core/Node/Text.cpp +++ b/core/Node/Text.cpp @@ -1,4 +1,4 @@ -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include "..\e2dmodule.h" //------------------------------------------------------- diff --git a/core/Tool/Data.cpp b/core/Tool/Data.cpp index 406fdc85..08a33e95 100644 --- a/core/Tool/Data.cpp +++ b/core/Tool/Data.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" e2d::Data::Data(const String & key, const String & field) diff --git a/core/Tool/File.cpp b/core/Tool/File.cpp index abbd4d18..7398b5cd 100644 --- a/core/Tool/File.cpp +++ b/core/Tool/File.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" #include "..\e2dmodule.h" #include diff --git a/core/Tool/Music.cpp b/core/Tool/Music.cpp index 4a767a0a..d6f24b38 100644 --- a/core/Tool/Music.cpp +++ b/core/Tool/Music.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" #include "..\e2dmodule.h" diff --git a/core/Tool/Path.cpp b/core/Tool/Path.cpp index 3fe276c2..64e831f4 100644 --- a/core/Tool/Path.cpp +++ b/core/Tool/Path.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" #include "..\e2dmodule.h" #include diff --git a/core/Tool/Player.cpp b/core/Tool/Player.cpp index a6e8a151..d1aa096a 100644 --- a/core/Tool/Player.cpp +++ b/core/Tool/Player.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" e2d::Player * e2d::Player::instance_ = nullptr; diff --git a/core/Tool/Random.cpp b/core/Tool/Random.cpp index 032f16f8..09d55ec2 100644 --- a/core/Tool/Random.cpp +++ b/core/Tool/Random.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" std::default_random_engine &e2d::Random::GetEngine() { diff --git a/core/Tool/Task.cpp b/core/Tool/Task.cpp index 04d32df8..5e11f18d 100644 --- a/core/Tool/Task.cpp +++ b/core/Tool/Task.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" e2d::Task::Task(const Function & func, const String & name) diff --git a/core/Tool/Timer.cpp b/core/Tool/Timer.cpp index ac48d40f..35d96c4a 100644 --- a/core/Tool/Timer.cpp +++ b/core/Tool/Timer.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dtool.h" e2d::Timer * e2d::Timer::GetInstance() diff --git a/core/Transition/BoxTransition.cpp b/core/Transition/BoxTransition.cpp index d4343737..cf907cc3 100644 --- a/core/Transition/BoxTransition.cpp +++ b/core/Transition/BoxTransition.cpp @@ -1,5 +1,5 @@ #include "..\e2dtransition.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include "..\e2dmodule.h" e2d::BoxTransition::BoxTransition(Scene* scene, float duration) diff --git a/core/Transition/EmergeTransition.cpp b/core/Transition/EmergeTransition.cpp index 1983c258..428c03f4 100644 --- a/core/Transition/EmergeTransition.cpp +++ b/core/Transition/EmergeTransition.cpp @@ -1,5 +1,5 @@ #include "..\e2dtransition.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::EmergeTransition::EmergeTransition(Scene* scene, float duration) : Transition(scene, duration) diff --git a/core/Transition/FadeTransition.cpp b/core/Transition/FadeTransition.cpp index b7627944..50b7d0ff 100644 --- a/core/Transition/FadeTransition.cpp +++ b/core/Transition/FadeTransition.cpp @@ -1,5 +1,5 @@ #include "..\e2dtransition.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::FadeTransition::FadeTransition(Scene* scene, float duration) : Transition(scene, duration) diff --git a/core/Transition/MoveTransition.cpp b/core/Transition/MoveTransition.cpp index 8c711c1c..2c3b9884 100644 --- a/core/Transition/MoveTransition.cpp +++ b/core/Transition/MoveTransition.cpp @@ -1,5 +1,5 @@ #include "..\e2dtransition.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" #include "..\e2dmodule.h" e2d::MoveTransition::MoveTransition(Scene* scene, float duration, Direction direction) diff --git a/core/Transition/Transition.cpp b/core/Transition/Transition.cpp index ce058109..810eb543 100644 --- a/core/Transition/Transition.cpp +++ b/core/Transition/Transition.cpp @@ -1,6 +1,6 @@ #include "..\e2dmodule.h" #include "..\e2dtransition.h" -#include "..\e2dcomponent.h" +#include "..\e2dnode.h" e2d::Transition::Transition(Scene* scene, float duration) : done_(false) diff --git a/core/e2daction.h b/core/e2daction.h index f16e4b14..458806c8 100644 --- a/core/e2daction.h +++ b/core/e2daction.h @@ -1,802 +1,802 @@ #pragma once -#include "e2dcommon.h" +#include "e2dutil.h" #include "e2dmodule.h" namespace e2d { -class Node; -class Loop; -class Sequence; -class Spawn; -class ActionManager; + class Node; + class Loop; + class Sequence; + class Spawn; + class ActionManager; -// 基础动作 -class Action : - public Ref -{ - friend class ActionManager; - friend class Loop; - friend class Sequence; - friend class Spawn; - -public: - Action(); - - virtual ~Action(); - - // 获取动作运行状态 - virtual bool IsRunning(); - - // 继续动作 - virtual void Resume(); - - // 暂停动作 - virtual void Pause(); - - // 停止动作 - virtual void Stop(); - - // 获取动作名称 - virtual const String& GetName() const; - - // 设置动作名称 - virtual void SetName( - const String& name - ); - - // 获取动作的拷贝 - virtual Action * Clone() const = 0; - - // 获取动作的倒转 - virtual Action * Reverse() const = 0; - - // 重置动作 - virtual void Reset(); - - // 获取该动作的执行目标 - virtual Node * GetTarget(); - - // 开始动作 - virtual void StartWithTarget( - Node* target - ); - - // 初始化动作 - virtual void Init(); - - // 更新动作 - virtual void Update(); - - // 重置动作时间 - virtual void ResetTime(); - - // 获取动作结束状态 - virtual bool IsDone() const; - -protected: - E2D_DISABLE_COPY(Action); - -protected: - String name_; - bool running_; - bool done_; - bool initialized_; - Node * target_; - Time started_; -}; - - -// 持续动作 -class FiniteTimeAction : - public Action -{ -public: - // 创建特定时长的持续动作 - explicit FiniteTimeAction( - float duration - ); - - // 重置动作 - virtual void Reset() override; - -protected: - E2D_DISABLE_COPY(FiniteTimeAction); - - // 初始化动作 - virtual void Init() override; - - // 更新动作 - virtual void Update() override; - - // 重置动作时间 - virtual void ResetTime() override; - -protected: - float duration_; - float delta_; -}; - - -// 相对位移动作 -class MoveBy : - public FiniteTimeAction -{ -public: - explicit MoveBy( - float duration, /* 持续时长 */ - Point vector /* 移动距离 */ - ); - - // 获取该动作的拷贝对象 - virtual MoveBy * Clone() const override; - - // 获取该动作的倒转 - virtual MoveBy * Reverse() const override; - -protected: - E2D_DISABLE_COPY(MoveBy); - - // 初始化动作 - virtual void Init() override; - - // 更新动作 - virtual void Update() override; - -protected: - Point start_pos_; - Point prev_pos_; - Point delta_pos_; -}; - - -// 位移动作 -class MoveTo : - public MoveBy -{ -public: - explicit MoveTo( - float duration, /* 持续时长 */ - Point pos /* 目的坐标 */ - ); - - // 获取该动作的拷贝对象 - virtual MoveTo * Clone() const override; - - // 获取该动作的倒转 - virtual MoveTo * Reverse() const override + // 基础动作 + class Action : + public Ref { - WARN("Reverse() not supported in MoveTo"); - return nullptr; - } + friend class ActionManager; + friend class Loop; + friend class Sequence; + friend class Spawn; -protected: - E2D_DISABLE_COPY(MoveTo); + public: + Action(); - // 初始化动作 - virtual void Init() override; + virtual ~Action(); -protected: - Point end_pos_; -}; + // 获取动作运行状态 + virtual bool IsRunning(); + + // 继续动作 + virtual void Resume(); + + // 暂停动作 + virtual void Pause(); + + // 停止动作 + virtual void Stop(); + + // 获取动作名称 + virtual const String& GetName() const; + + // 设置动作名称 + virtual void SetName( + const String& name + ); + + // 获取动作的拷贝 + virtual Action * Clone() const = 0; + + // 获取动作的倒转 + virtual Action * Reverse() const = 0; + + // 重置动作 + virtual void Reset(); + + // 获取该动作的执行目标 + virtual Node * GetTarget(); + + // 开始动作 + virtual void StartWithTarget( + Node* target + ); + + // 初始化动作 + virtual void Init(); + + // 更新动作 + virtual void Update(); + + // 重置动作时间 + virtual void ResetTime(); + + // 获取动作结束状态 + virtual bool IsDone() const; + + protected: + E2D_DISABLE_COPY(Action); + + protected: + String name_; + bool running_; + bool done_; + bool initialized_; + Node * target_; + Time started_; + }; -// 相对跳跃动作 -class JumpBy : - public FiniteTimeAction -{ -public: - explicit JumpBy( - float duration, /* 持续时长 */ - const Point& vec, /* 跳跃距离 */ - float height, /* 跳跃高度 */ - int jumps = 1 /* 跳跃次数 */ - ); - - // 获取该动作的拷贝对象 - virtual JumpBy * Clone() const override; - - // 获取该动作的倒转 - virtual JumpBy * Reverse() const override; - -protected: - E2D_DISABLE_COPY(JumpBy); - - // 初始化动作 - virtual void Init() override; - - // 更新动作 - virtual void Update() override; - -protected: - Point start_pos_; - Point delta_pos_; - float height_; - int jumps_; - Point prev_pos_; -}; - - -// 跳跃动作 -class JumpTo : - public JumpBy -{ -public: - explicit JumpTo( - float duration, /* 持续时长 */ - const Point& pos, /* 目的坐标 */ - float height, /* 跳跃高度 */ - int jumps = 1 /* 跳跃次数 */ - ); - - // 获取该动作的拷贝对象 - virtual JumpTo * Clone() const override; - - // 获取该动作的倒转 - virtual JumpTo * Reverse() const override + // 持续动作 + class FiniteTimeAction : + public Action { - WARN("Reverse() not supported in JumpTo"); - return nullptr; - } + public: + // 创建特定时长的持续动作 + explicit FiniteTimeAction( + float duration + ); -protected: - E2D_DISABLE_COPY(JumpTo); + // 重置动作 + virtual void Reset() override; - // 初始化动作 - virtual void Init() override; + protected: + E2D_DISABLE_COPY(FiniteTimeAction); -protected: - Point end_pos_; -}; + // 初始化动作 + virtual void Init() override; + + // 更新动作 + virtual void Update() override; + + // 重置动作时间 + virtual void ResetTime() override; + + protected: + float duration_; + float delta_; + }; -// 相对缩放动作 -class ScaleBy : - public FiniteTimeAction -{ -public: - explicit ScaleBy( - float duration, /* 持续时长 */ - float scale /* 相对变化值 */ - ); - - explicit ScaleBy( - float duration, /* 持续时长 */ - float scale_x, /* 横向缩放相对变化值 */ - float scale_y /* 纵向缩放相对变化值 */ - ); - - // 获取该动作的拷贝对象 - virtual ScaleBy * Clone() const override; - - // 获取该动作的倒转 - virtual ScaleBy * Reverse() const override; - -protected: - E2D_DISABLE_COPY(ScaleBy); - - // 初始化动作 - virtual void Init() override; - - // 更新动作 - virtual void Update() override; - -protected: - float start_scale_x_; - float start_scale_y_; - float delta_x_; - float delta_y_; -}; - - -// 缩放动作 -class ScaleTo : - public ScaleBy -{ -public: - explicit ScaleTo( - float duration, /* 持续时长 */ - float scale /* 目标值 */ - ); - - explicit ScaleTo( - float duration, /* 持续时长 */ - float scale_x, /* 横向缩放目标值 */ - float scale_y /* 纵向缩放目标值 */ - ); - - // 获取该动作的拷贝对象 - virtual ScaleTo * Clone() const override; - - // 获取该动作的倒转 - virtual ScaleTo * Reverse() const override + // 相对位移动作 + class MoveBy : + public FiniteTimeAction { - WARN("Reverse() not supported in ScaleTo"); - return nullptr; - } + public: + explicit MoveBy( + float duration, /* 持续时长 */ + Point vector /* 移动距离 */ + ); -protected: - E2D_DISABLE_COPY(ScaleTo); + // 获取该动作的拷贝对象 + virtual MoveBy * Clone() const override; - // 初始化动作 - virtual void Init() override; + // 获取该动作的倒转 + virtual MoveBy * Reverse() const override; -protected: - float end_scale_x_; - float end_scale_y_; -}; + protected: + E2D_DISABLE_COPY(MoveBy); + + // 初始化动作 + virtual void Init() override; + + // 更新动作 + virtual void Update() override; + + protected: + Point start_pos_; + Point prev_pos_; + Point delta_pos_; + }; -// 透明度相对渐变动作 -class OpacityBy : - public FiniteTimeAction -{ -public: - explicit OpacityBy( - float duration, /* 持续时长 */ - float opacity /* 相对变化值 */ - ); - - // 获取该动作的拷贝对象 - virtual OpacityBy * Clone() const override; - - // 获取该动作的倒转 - virtual OpacityBy * Reverse() const override; - -protected: - E2D_DISABLE_COPY(OpacityBy); - - // 初始化动作 - virtual void Init() override; - - // 更新动作 - virtual void Update() override; - -protected: - float start_val_; - float delta_val_; -}; - - -// 透明度渐变动作 -class OpacityTo : - public OpacityBy -{ -public: - explicit OpacityTo( - float duration, /* 持续时长 */ - float opacity /* 目标值 */ - ); - - // 获取该动作的拷贝对象 - virtual OpacityTo * Clone() const override; - - // 获取该动作的倒转 - virtual OpacityTo * Reverse() const override + // 位移动作 + class MoveTo : + public MoveBy { - WARN("Reverse() not supported in OpacityTo"); - return nullptr; - } + public: + explicit MoveTo( + float duration, /* 持续时长 */ + Point pos /* 目的坐标 */ + ); -protected: - E2D_DISABLE_COPY(OpacityTo); + // 获取该动作的拷贝对象 + virtual MoveTo * Clone() const override; - // 初始化动作 - virtual void Init() override; + // 获取该动作的倒转 + virtual MoveTo * Reverse() const override + { + WARN("Reverse() not supported in MoveTo"); + return nullptr; + } -protected: - float end_val_; -}; + protected: + E2D_DISABLE_COPY(MoveTo); + + // 初始化动作 + virtual void Init() override; + + protected: + Point end_pos_; + }; -// 淡入动作 -class FadeIn : - public OpacityTo -{ -public: - // 创建淡入动作 - explicit FadeIn( - float duration /* 持续时长 */ - ); - -protected: - E2D_DISABLE_COPY(FadeIn); -}; - - -// 淡出动作 -class FadeOut : - public OpacityTo -{ -public: - // 创建淡出动作 - explicit FadeOut( - float duration /* 持续时长 */ - ); - -protected: - E2D_DISABLE_COPY(FadeOut); -}; - - -// 相对旋转动作 -class RotateBy : - public FiniteTimeAction -{ -public: - explicit RotateBy( - float duration, /* 持续时长 */ - float rotation /* 相对变化值 */ - ); - - // 获取该动作的拷贝对象 - virtual RotateBy * Clone() const override; - - // 获取该动作的倒转 - virtual RotateBy * Reverse() const override; - -protected: - E2D_DISABLE_COPY(RotateBy); - - // 初始化动作 - virtual void Init() override; - - // 更新动作 - virtual void Update() override; - -protected: - float start_val_; - float delta_val_; -}; - - -// 旋转动作 -class RotateTo : - public RotateBy -{ -public: - explicit RotateTo( - float duration, /* 持续时长 */ - float rotation /* 目标值 */ - ); - - // 获取该动作的拷贝对象 - virtual RotateTo * Clone() const override; - - // 获取该动作的倒转 - virtual RotateTo * Reverse() const override + // 相对跳跃动作 + class JumpBy : + public FiniteTimeAction { - WARN("Reverse() not supported in RotateTo"); - return nullptr; - } + public: + explicit JumpBy( + float duration, /* 持续时长 */ + const Point& vec, /* 跳跃距离 */ + float height, /* 跳跃高度 */ + int jumps = 1 /* 跳跃次数 */ + ); + + // 获取该动作的拷贝对象 + virtual JumpBy * Clone() const override; + + // 获取该动作的倒转 + virtual JumpBy * Reverse() const override; + + protected: + E2D_DISABLE_COPY(JumpBy); + + // 初始化动作 + virtual void Init() override; + + // 更新动作 + virtual void Update() override; + + protected: + Point start_pos_; + Point delta_pos_; + float height_; + int jumps_; + Point prev_pos_; + }; + + + // 跳跃动作 + class JumpTo : + public JumpBy + { + public: + explicit JumpTo( + float duration, /* 持续时长 */ + const Point& pos, /* 目的坐标 */ + float height, /* 跳跃高度 */ + int jumps = 1 /* 跳跃次数 */ + ); + + // 获取该动作的拷贝对象 + virtual JumpTo * Clone() const override; + + // 获取该动作的倒转 + virtual JumpTo * Reverse() const override + { + WARN("Reverse() not supported in JumpTo"); + return nullptr; + } + + protected: + E2D_DISABLE_COPY(JumpTo); + + // 初始化动作 + virtual void Init() override; + + protected: + Point end_pos_; + }; + + + // 相对缩放动作 + class ScaleBy : + public FiniteTimeAction + { + public: + explicit ScaleBy( + float duration, /* 持续时长 */ + float scale /* 相对变化值 */ + ); + + explicit ScaleBy( + float duration, /* 持续时长 */ + float scale_x, /* 横向缩放相对变化值 */ + float scale_y /* 纵向缩放相对变化值 */ + ); + + // 获取该动作的拷贝对象 + virtual ScaleBy * Clone() const override; + + // 获取该动作的倒转 + virtual ScaleBy * Reverse() const override; + + protected: + E2D_DISABLE_COPY(ScaleBy); + + // 初始化动作 + virtual void Init() override; + + // 更新动作 + virtual void Update() override; + + protected: + float start_scale_x_; + float start_scale_y_; + float delta_x_; + float delta_y_; + }; + + + // 缩放动作 + class ScaleTo : + public ScaleBy + { + public: + explicit ScaleTo( + float duration, /* 持续时长 */ + float scale /* 目标值 */ + ); + + explicit ScaleTo( + float duration, /* 持续时长 */ + float scale_x, /* 横向缩放目标值 */ + float scale_y /* 纵向缩放目标值 */ + ); + + // 获取该动作的拷贝对象 + virtual ScaleTo * Clone() const override; + + // 获取该动作的倒转 + virtual ScaleTo * Reverse() const override + { + WARN("Reverse() not supported in ScaleTo"); + return nullptr; + } + + protected: + E2D_DISABLE_COPY(ScaleTo); + + // 初始化动作 + virtual void Init() override; + + protected: + float end_scale_x_; + float end_scale_y_; + }; + + + // 透明度相对渐变动作 + class OpacityBy : + public FiniteTimeAction + { + public: + explicit OpacityBy( + float duration, /* 持续时长 */ + float opacity /* 相对变化值 */ + ); + + // 获取该动作的拷贝对象 + virtual OpacityBy * Clone() const override; + + // 获取该动作的倒转 + virtual OpacityBy * Reverse() const override; + + protected: + E2D_DISABLE_COPY(OpacityBy); + + // 初始化动作 + virtual void Init() override; + + // 更新动作 + virtual void Update() override; + + protected: + float start_val_; + float delta_val_; + }; + + + // 透明度渐变动作 + class OpacityTo : + public OpacityBy + { + public: + explicit OpacityTo( + float duration, /* 持续时长 */ + float opacity /* 目标值 */ + ); + + // 获取该动作的拷贝对象 + virtual OpacityTo * Clone() const override; + + // 获取该动作的倒转 + virtual OpacityTo * Reverse() const override + { + WARN("Reverse() not supported in OpacityTo"); + return nullptr; + } + + protected: + E2D_DISABLE_COPY(OpacityTo); + + // 初始化动作 + virtual void Init() override; + + protected: + float end_val_; + }; + + + // 淡入动作 + class FadeIn : + public OpacityTo + { + public: + // 创建淡入动作 + explicit FadeIn( + float duration /* 持续时长 */ + ); + + protected: + E2D_DISABLE_COPY(FadeIn); + }; + + + // 淡出动作 + class FadeOut : + public OpacityTo + { + public: + // 创建淡出动作 + explicit FadeOut( + float duration /* 持续时长 */ + ); + + protected: + E2D_DISABLE_COPY(FadeOut); + }; -protected: - E2D_DISABLE_COPY(RotateTo); - // 初始化动作 - virtual void Init() override; + // 相对旋转动作 + class RotateBy : + public FiniteTimeAction + { + public: + explicit RotateBy( + float duration, /* 持续时长 */ + float rotation /* 相对变化值 */ + ); + + // 获取该动作的拷贝对象 + virtual RotateBy * Clone() const override; + + // 获取该动作的倒转 + virtual RotateBy * Reverse() const override; + + protected: + E2D_DISABLE_COPY(RotateBy); -protected: - float end_val_; -}; + // 初始化动作 + virtual void Init() override; + // 更新动作 + virtual void Update() override; -// 延时动作 -class Delay : - public Action -{ -public: - explicit Delay( - float duration /* 延迟时长(秒) */ - ); + protected: + float start_val_; + float delta_val_; + }; - // 获取该动作的拷贝对象 - virtual Delay * Clone() const override; - // 获取该动作的倒转 - virtual Delay * Reverse() const override; + // 旋转动作 + class RotateTo : + public RotateBy + { + public: + explicit RotateTo( + float duration, /* 持续时长 */ + float rotation /* 目标值 */ + ); + + // 获取该动作的拷贝对象 + virtual RotateTo * Clone() const override; + + // 获取该动作的倒转 + virtual RotateTo * Reverse() const override + { + WARN("Reverse() not supported in RotateTo"); + return nullptr; + } - // 重置动作 - virtual void Reset() override; + protected: + E2D_DISABLE_COPY(RotateTo); -protected: - E2D_DISABLE_COPY(Delay); + // 初始化动作 + virtual void Init() override; - // 初始化动作 - virtual void Init() override; + protected: + float end_val_; + }; - // 更新动作 - virtual void Update() override; - // 重置动作时间 - virtual void ResetTime() override; + // 延时动作 + class Delay : + public Action + { + public: + explicit Delay( + float duration /* 延迟时长(秒) */ + ); -protected: - float delay_; - float delta_; -}; + // 获取该动作的拷贝对象 + virtual Delay * Clone() const override; + // 获取该动作的倒转 + virtual Delay * Reverse() const override; -// 循环动作 -class Loop : - public Action -{ -public: - explicit Loop( - Action * action, /* 执行循环的动作 */ - int times = -1 /* 循环次数 */ - ); + // 重置动作 + virtual void Reset() override; - virtual ~Loop(); + protected: + E2D_DISABLE_COPY(Delay); - // 获取该动作的拷贝对象 - virtual Loop * Clone() const override; + // 初始化动作 + virtual void Init() override; - // 获取该动作的倒转 - virtual Loop * Reverse() const override; + // 更新动作 + virtual void Update() override; - // 重置动作 - virtual void Reset() override; + // 重置动作时间 + virtual void ResetTime() override; -protected: - E2D_DISABLE_COPY(Loop); + protected: + float delay_; + float delta_; + }; - // 初始化动作 - virtual void Init() override; - // 更新动作 - virtual void Update() override; + // 循环动作 + class Loop : + public Action + { + public: + explicit Loop( + Action * action, /* 执行循环的动作 */ + int times = -1 /* 循环次数 */ + ); - // 重置动作时间 - virtual void ResetTime() override; + virtual ~Loop(); -protected: - Action * action_; - int times_; - int total_times_; -}; + // 获取该动作的拷贝对象 + virtual Loop * Clone() const override; + // 获取该动作的倒转 + virtual Loop * Reverse() const override; -// 回调动作 -class Callback : - public Action -{ -public: - explicit Callback( - const Function& func /* 函数对象 */ - ); + // 重置动作 + virtual void Reset() override; - // 获取该动作的拷贝对象 - virtual Callback * Clone() const override; + protected: + E2D_DISABLE_COPY(Loop); - // 获取该动作的倒转 - virtual Callback * Reverse() const override; + // 初始化动作 + virtual void Init() override; -protected: - E2D_DISABLE_COPY(Callback); + // 更新动作 + virtual void Update() override; - // 初始化动作 - virtual void Init() override; + // 重置动作时间 + virtual void ResetTime() override; - // 更新动作 - virtual void Update() override; + protected: + Action * action_; + int times_; + int total_times_; + }; -protected: - Function callback_; -}; + // 回调动作 + class Callback : + public Action + { + public: + explicit Callback( + const Function& func /* 函数对象 */ + ); -// 顺序动作 -class Sequence : - public Action -{ -public: - typedef std::vector Actions; + // 获取该动作的拷贝对象 + virtual Callback * Clone() const override; - Sequence(); + // 获取该动作的倒转 + virtual Callback * Reverse() const override; - explicit Sequence( - const Actions& actions /* 动作列表 */ - ); + protected: + E2D_DISABLE_COPY(Callback); - virtual ~Sequence(); + // 初始化动作 + virtual void Init() override; - // 在结尾添加动作 - void Add( - Action * action - ); + // 更新动作 + virtual void Update() override; - // 在结尾添加多个动作 - void Add( - const Actions& actions /* 动作列表 */ - ); + protected: + Function callback_; + }; - // 获取该动作的拷贝对象 - virtual Sequence * Clone() const override; - // 获取该动作的倒转 - virtual Sequence * Reverse() const; + // 顺序动作 + class Sequence : + public Action + { + public: + typedef std::vector Actions; - // 重置动作 - virtual void Reset() override; + Sequence(); -protected: - E2D_DISABLE_COPY(Sequence); + explicit Sequence( + const Actions& actions /* 动作列表 */ + ); - // 初始化动作 - virtual void Init() override; + virtual ~Sequence(); - // 更新动作 - virtual void Update() override; + // 在结尾添加动作 + void Add( + Action * action + ); - // 重置动作时间 - virtual void ResetTime() override; + // 在结尾添加多个动作 + void Add( + const Actions& actions /* 动作列表 */ + ); -protected: - UINT action_index_; - Actions actions_; -}; + // 获取该动作的拷贝对象 + virtual Sequence * Clone() const override; + // 获取该动作的倒转 + virtual Sequence * Reverse() const; -// 同步动作 -class Spawn : - public Action -{ -public: - typedef std::vector Actions; + // 重置动作 + virtual void Reset() override; - Spawn(); + protected: + E2D_DISABLE_COPY(Sequence); - explicit Spawn( - const Actions& actions /* 动作列表 */ - ); + // 初始化动作 + virtual void Init() override; - virtual ~Spawn(); + // 更新动作 + virtual void Update() override; - // 在结尾添加动作 - void Add( - Action * action - ); + // 重置动作时间 + virtual void ResetTime() override; - // 在结尾添加多个动作 - void Add( - const Actions& actions /* 动作列表 */ - ); + protected: + UINT action_index_; + Actions actions_; + }; - // 获取该动作的拷贝对象 - virtual Spawn * Clone() const override; - // 获取该动作的倒转 - virtual Spawn * Reverse() const; + // 同步动作 + class Spawn : + public Action + { + public: + typedef std::vector Actions; - // 重置动作 - virtual void Reset() override; + Spawn(); -protected: - E2D_DISABLE_COPY(Spawn); + explicit Spawn( + const Actions& actions /* 动作列表 */ + ); - // 初始化动作 - virtual void Init() override; + virtual ~Spawn(); - // 更新动作 - virtual void Update() override; + // 在结尾添加动作 + void Add( + Action * action + ); - // 重置动作时间 - virtual void ResetTime() override; + // 在结尾添加多个动作 + void Add( + const Actions& actions /* 动作列表 */ + ); -protected: - Actions actions_; -}; + // 获取该动作的拷贝对象 + virtual Spawn * Clone() const override; + // 获取该动作的倒转 + virtual Spawn * Reverse() const; -// 帧动画 -class Animation : - public Ref -{ -public: - typedef std::vector Images; + // 重置动作 + virtual void Reset() override; - Animation(); + protected: + E2D_DISABLE_COPY(Spawn); - explicit Animation( - const Images& frames /* 关键帧数组 */ - ); + // 初始化动作 + virtual void Init() override; - explicit Animation( - float interval /* 帧间隔(秒) */ - ); + // 更新动作 + virtual void Update() override; - explicit Animation( - float interval, /* 帧间隔(秒) */ - const Images& frames /* 关键帧数组 */ - ); + // 重置动作时间 + virtual void ResetTime() override; - virtual ~Animation(); + protected: + Actions actions_; + }; - // 添加关键帧 - void Add( - Image * frame /* 关键帧 */ - ); - // 添加多个关键帧 - void Add( - const Images& frames /* 关键帧数组 */ - ); + // 帧动画 + class Animation : + public Ref + { + public: + typedef std::vector Images; - // 获取帧间隔 - float GetInterval() const; + Animation(); - // 获取关键帧 - const Images& GetFrames() const; + explicit Animation( + const Images& frames /* 关键帧数组 */ + ); - // 设置每一帧的时间间隔 - void SetInterval( - float interval /* 帧间隔(秒) */ - ); + explicit Animation( + float interval /* 帧间隔(秒) */ + ); - // 获取帧动画的拷贝对象 - Animation * Clone() const; + explicit Animation( + float interval, /* 帧间隔(秒) */ + const Images& frames /* 关键帧数组 */ + ); - // 获取帧动画的倒转 - Animation * Reverse() const; + virtual ~Animation(); -protected: - E2D_DISABLE_COPY(Animation); + // 添加关键帧 + void Add( + Image * frame /* 关键帧 */ + ); -protected: - float interval_; - Images frames_; -}; + // 添加多个关键帧 + void Add( + const Images& frames /* 关键帧数组 */ + ); + // 获取帧间隔 + float GetInterval() const; -// 精灵动作 -class Animate : - public Action -{ -public: - Animate(); + // 获取关键帧 + const Images& GetFrames() const; - explicit Animate( - Animation * animation - ); + // 设置每一帧的时间间隔 + void SetInterval( + float interval /* 帧间隔(秒) */ + ); - virtual ~Animate(); + // 获取帧动画的拷贝对象 + Animation * Clone() const; - // 获取动画 - virtual Animation * GetAnimation() const; + // 获取帧动画的倒转 + Animation * Reverse() const; - // 设置动画 - virtual void SetAnimation( - Animation * animation - ); + protected: + E2D_DISABLE_COPY(Animation); - // 获取该动作的拷贝对象 - virtual Animate * Clone() const override; + protected: + float interval_; + Images frames_; + }; - // 获取该动作的倒转 - virtual Animate * Reverse() const override; - // 重置动作 - virtual void Reset() override; + // 精灵动作 + class Animate : + public Action + { + public: + Animate(); -protected: - E2D_DISABLE_COPY(Animate); + explicit Animate( + Animation * animation + ); - // 初始化动作 - virtual void Init() override; + virtual ~Animate(); - // 更新动作 - virtual void Update() override; + // 获取动画 + virtual Animation * GetAnimation() const; - // 重置动作时间 - virtual void ResetTime() override; + // 设置动画 + virtual void SetAnimation( + Animation * animation + ); -protected: - UINT frame_index_; - Animation * animation_; -}; + // 获取该动作的拷贝对象 + virtual Animate * Clone() const override; + + // 获取该动作的倒转 + virtual Animate * Reverse() const override; + + // 重置动作 + virtual void Reset() override; + + protected: + E2D_DISABLE_COPY(Animate); + + // 初始化动作 + virtual void Init() override; + + // 更新动作 + virtual void Update() override; + + // 重置动作时间 + virtual void ResetTime() override; + + protected: + UINT frame_index_; + Animation * animation_; + }; } \ No newline at end of file diff --git a/core/e2dcommon.h b/core/e2dcommon.h deleted file mode 100644 index 77944388..00000000 --- a/core/e2dcommon.h +++ /dev/null @@ -1,851 +0,0 @@ -#pragma once -#include "e2dmacros.h" - -namespace e2d -{ - - -// 方向 -enum class Direction : int -{ - Up, /* 上 */ - Down, /* 下 */ - Left, /* 左 */ - Right /* 右 */ -}; - - -// 线条相交样式 -enum class Stroke : int -{ - Miter = 0, /* 斜切 */ - Bevel = 1, /* 斜角 */ - Round = 2 /* 圆角 */ -}; - - -class Size; - -// 坐标 -class Point -{ -public: - float x; // X 坐标 - float y; // Y 坐标 - -public: - Point(); - - Point( - float x, - float y - ); - - Point( - const Point& other - ); - - Point operator + (const Point & other) const; - Point operator - (const Point & other) const; - Point operator * (float value) const; - Point operator / (float value) const; - Point operator - () const; - bool operator== (const Point& other) const; - - E2D_OP_EXPLICIT operator e2d::Size() const; - - // 判断两点间距离 - static float Distance( - const Point& p1, - const Point& p2 - ); -}; - - -// 大小 -class Size -{ -public: - float width; // 宽度 - float height; // 高度 - -public: - Size(); - - Size( - float width, - float height - ); - - Size( - const Size& other - ); - - Size operator + (const Size & other) const; - Size operator - (const Size & other) const; - Size operator * (float value) const; - Size operator / (float value) const; - Size operator - () const; - bool operator== (const Size& other) const; - - E2D_OP_EXPLICIT operator e2d::Point() const; -}; - - -// 矩形 -class Rect -{ -public: - Point origin; // 原点坐标 - Size size; // 宽度和高度 - -public: - Rect(); - - Rect( - float x, - float y, - float width, - float height - ); - - Rect( - const Point& pos, - const Size& size - ); - - Rect( - const Rect& other - ); - - Rect& operator= (const Rect& other); - - bool operator== (const Rect& rect) const; - - // 判断点是否在矩形内 - bool ContainsPoint( - const Point& point - ) const; - - // 判断两矩形是否相交 - bool Intersects( - const Rect& rect - ) const; -}; - - -// 字符串 -class String -{ -public: - String(); - - String( - const String & - ); - - String( - const char * - ); - - String( - const wchar_t * - ); - - String( - String && - ); - - ~String(); - - // 获取字符串长度 - int GetLength() const; - - // 获取该字符串的 Hash 值 - size_t GetHash() const; - - // 判断字符串是否为空 - bool IsEmpty() const; - - // 获取指定位置字符 - const wchar_t& At( - size_t index - ) const; - - // 比较字符串 - int Compare( - const String & str - ) const; - - // 截取字符串 - String Subtract( - int offset, /* 偏移量 */ - int count = -1 /* 截取字符数量 */ - ) const; - - // 插入字符串 - void Insert( - const String & str, - int pos - ); - - // 替换字符串中的指定内容 - void Replace( - const String & from, /* 需替换内容 */ - const String & to /* 替换成内容 */ - ); - - // 删除字符串中的指定内容 - void Erase( - int offset, /* 偏移量 */ - int count /* 删除字符数量 */ - ); - - // 搜索字符串 - int Find( - const String & str, /* 查找内容 */ - int offset = 0 /* 偏移量 */ - ) const; - - // 清空字符串 - void Clear(); - - // 获取大写字符串 - String ToUpper() const; - - // 获取小写字符串 - String ToLower() const; - - // 将字符串转化为 int 型 - int ToInt() const; - - // 将字符串转化为 float 型 - float ToFloat() const; - - // 将字符串转化为 double 型 - double ToDouble() const; - - // 将字符串转化为 bool 型 - bool ToBool() const; - - // 数字类型转字符串 - static String Parse(int value); - static String Parse(unsigned int value); - static String Parse(float value); - static String Parse(double value); - - // 格式化字符串 - static String Format(const char * format, ...); - static String Format(const wchar_t * format, ...); - - // 赋值运算符 - String& operator= (const String &); - String& operator= (const char *); - String& operator= (const wchar_t *); - - // 运算符 - String& operator+= (const String &); - String& operator+= (const char *); - String& operator+= (const wchar_t *); - String operator+ (const String &) const; - String operator+ (const char *) const; - String operator+ (const wchar_t *) const; - - // 友元运算符 - friend String operator+ (const char *, const String &); - friend String operator+ (const wchar_t*, const String &); - - // 类型转换操作符 - E2D_OP_EXPLICIT operator const wchar_t* () const; - E2D_OP_EXPLICIT operator wchar_t* () const; - E2D_OP_EXPLICIT operator std::wstring () const; - E2D_OP_EXPLICIT operator std::string () const; - - // 比较运算符 - bool operator== (const String &) const; - bool operator== (const char *) const; - bool operator== (const wchar_t *) const; - bool operator!= (const String &) const; - bool operator!= (const char *) const; - bool operator!= (const wchar_t *) const; - bool operator> (const String &) const; - bool operator>= (const String &) const; - bool operator< (const String &) const; - bool operator<= (const String &) const; - - // << 运算符(后接字符串) - String& operator<< (const String &); - String& operator<< (const char *); - String& operator<< (char *); - String& operator<< (const wchar_t *); - String& operator<< (wchar_t *); - String& operator<< (int value); - String& operator<< (unsigned int value); - String& operator<< (float value); - String& operator<< (double value); - - // 其他运算符 - wchar_t& operator[] (size_t); - - friend std::ostream& operator<< (std::ostream &, const String &); - friend std::wostream& operator<< (std::wostream &, const String &); - - friend std::istream& operator>> (std::istream &, String &); - friend std::wistream& operator>> (std::wistream &, String &); - -private: - std::wstring string_; -}; - - -// 颜色 -class Color -{ -public: - Color(); - - Color( - float r, - float g, - float b - ); - - Color( - float r, - float g, - float b, - float alpha - ); - - Color( - UINT rgb - ); - - Color( - UINT rgb, - float alpha - ); - - Color( - const D2D1_COLOR_F& color - ); - - E2D_OP_EXPLICIT operator D2D1_COLOR_F() const; - -public: - enum Value : UINT - { - Black = 0x000000, - Blue = 0x0000FF, - BlueViolet = 0x8A2BE2, - Brown = 0xA52A2A, - Chocolate = 0xD2691E, - DarkBlue = 0x00008B, - DarkGray = 0xA9A9A9, - DarkGreen = 0x006400, - DarkOrange = 0xFF8C00, - DarkRed = 0x8B0000, - DarkViolet = 0x9400D3, - ForestGreen = 0x228B22, - Gold = 0xFFD700, - Gray = 0x808080, - Green = 0x008000, - GreenYellow = 0xADFF2F, - LightBlue = 0xADD8E6, - LightCyan = 0xE0FFFF, - LightGreen = 0x90EE90, - LightGray = 0xD3D3D3, - LightPink = 0xFFB6C1, - LightSeaGreen = 0x20B2AA, - LightSkyBlue = 0x87CEFA, - LightYellow = 0xFFFFE0, - Orange = 0xFFA500, - OrangeRed = 0xFF4500, - Pink = 0xFFC0CB, - Purple = 0x800080, - Red = 0xFF0000, - Silver = 0xC0C0C0, - SkyBlue = 0x87CEEB, - Snow = 0xFFFAFA, - Violet = 0xEE82EE, - Wheat = 0xF5DEB3, - White = 0xFFFFFF, - WhiteSmoke = 0xF5F5F5, - Wood = 0xDEB887, - Yellow = 0xFFFF00, - Yellow_Green = 0x9ACD32 - }; - -public: - float r; - float g; - float b; - float a; -}; - - -// 键盘键值 -enum class KeyCode : int -{ - Unknown = 0, - Up = 0xC8, - Left = 0xCB, - Right = 0xCD, - Down = 0xD0, - Enter = 0x1C, - Space = 0x39, - Esc = 0x01, - Q = 0x10, - W = 0x11, - E = 0x12, - R = 0x13, - T = 0x14, - Y = 0x15, - U = 0x16, - I = 0x17, - O = 0x18, - P = 0x19, - A = 0x1E, - S = 0x1F, - D = 0x20, - F = 0x21, - G = 0x22, - H = 0x23, - J = 0x24, - K = 0x25, - L = 0x26, - Z = 0x2C, - X = 0x2D, - C = 0x2E, - V = 0x2F, - B = 0x30, - N = 0x31, - M = 0x32, - Num1 = 0x02, - Num2 = 0x03, - Num3 = 0x04, - Num4 = 0x05, - Num5 = 0x06, - Num6 = 0x07, - Num7 = 0x08, - Num8 = 0x09, - Num9 = 0x0A, - Num0 = 0x0B, - Numpad7 = 0x47, - Numpad8 = 0x48, - Numpad9 = 0x49, - Numpad4 = 0x4B, - Numpad5 = 0x4C, - Numpad6 = 0x4D, - Numpad1 = 0x4F, - Numpad2 = 0x50, - Numpad3 = 0x51, - Numpad0 = 0x52, -}; - - -// 鼠标键值 -enum class MouseCode : int -{ - Left, /* 鼠标左键 */ - Right, /* 鼠标右键 */ - Middle /* 鼠标中键 */ -}; - - -// 函数对象 -class Function -{ -public: - Function(); - - Function( - std::nullptr_t - ); - - Function( - std::function func - ); - - template - Function(Func func) : func_(func) {} - - template - Function( - Func&& func, /* 对象的成员函数 */ - Object&& obj /* 对象指针 */ - ) - { - func_ = std::bind(func, obj); - } - - void operator() (void) const; - - E2D_OP_EXPLICIT operator bool() const; - -protected: - std::function func_; -}; - - -// 时间段 -class Duration -{ -public: - Duration(); - - explicit Duration( - float seconds - ); - - // 获取毫秒数 - int Milliseconds() const; - - // 获取秒数 - float Seconds() const; - - bool operator== (const Duration &) const; - bool operator!= (const Duration &) const; - bool operator> (const Duration &) const; - bool operator>= (const Duration &) const; - bool operator< (const Duration &) const; - bool operator<= (const Duration &) const; - - Duration operator + (Duration const &) const; - Duration operator - (Duration const &) const; - - Duration& operator += (Duration const &); - Duration& operator -= (Duration const &); - -protected: - std::chrono::milliseconds duration_ms_; -}; - - -// 时间点 -class Time -{ -public: - Time(); - - // 获取时间戳 - time_t GetTimeStamp() const; - - // 是否是 - bool IsZero() const; - - Time operator + (Duration const &) const; - Time operator - (Duration const &) const; - - Time& operator += (Duration const &); - Time& operator -= (Duration const &); - - Duration operator - (Time const &) const; - - // 获取当前时间 - static Time Now(); - -protected: - std::chrono::steady_clock::time_point time_; -}; - - -// 字体 -class Font -{ -public: - String family; // 字体族 - float size; // 字号 - UINT weight; // 粗细值 - bool italic; // 是否斜体 - -public: - // 字体粗细值 - enum Weight : UINT - { - Thin = 100, - ExtraLight = 200, - Light = 300, - Normal = 400, - Medium = 500, - Bold = 700, - ExtraBold = 800, - Black = 900, - ExtraBlack = 950 - }; - -public: - Font(); - - explicit Font( - const String& family, - float size = 22, - UINT weight = Font::Weight::Normal, - bool italic = false - ); -}; - - -class Node; - -// 碰撞体 -class Collider -{ -public: - // 碰撞体形状 - enum class Shape - { - None, /* 无 */ - Rect, /* 矩形 */ - Circle, /* 圆形 */ - Ellipse /* 椭圆形 */ - }; - - // 碰撞体交集关系 - enum class Relation : int - { - Unknown = 0, /* 关系不确定 */ - Disjoin = 1, /* 没有交集 */ - IsContained = 2, /* 完全被包含 */ - Contains = 3, /* 完全包含 */ - Overlap = 4 /* 部分重叠 */ - }; - -public: - explicit Collider( - Node * parent - ); - - virtual ~Collider(); - - // 设置碰撞体形状 - void SetShape( - Shape shape - ); - - // 是否触发碰撞事件 - void SetCollisionNotify( - bool notify - ); - - // 启用或关闭该碰撞体 - void SetEnabled( - bool enabled - ); - - // 设置碰撞体的可见性 - void SetVisible( - bool visible - ); - - // 设置绘制颜色 - void SetBorderColor( - const Color& color - ); - - // 判断两碰撞体的交集关系 - Relation GetRelationWith( - Collider * collider - ) const; - - // 是否启用碰撞体 - bool IsEnabled() const; - - // 是否可见 - bool IsVisible() const; - - // 是否触发碰撞事件 - bool IsCollisionNotify() const; - - // 获取绘制颜色 - const Color& GetBorderColor() const; - - // 获取形状 - Shape GetShape() const; - - // 获取绑定节点 - Node* GetNode() const; - - // 获取 ID2D1Geometry* 对象 - ID2D1Geometry* GetGeometry() const; - - // 重新生成 - void Recreate(); - - // 渲染碰撞体 - void Draw(); - -protected: - E2D_DISABLE_COPY(Collider); - -protected: - bool enabled_; - bool visible_; - bool notify_; - Color border_color_; - Node * parent_node_; - Shape shape_; - ID2D1Geometry* geometry_; -}; - - -// 资源 -class Resource -{ -public: - Resource( - size_t resource_name, /* 资源名称 */ - const String& resource_type /* 资源类型 */ - ); - -public: - size_t name; - String type; -}; - - -// 引用计数对象 -class Ref -{ -public: - Ref(); - - virtual ~Ref(); - - // 增加引用计数 - void Retain(); - - // 减少引用计数 - void Release(); - - // 获取引用计数 - int GetRefCount() const; - -protected: - E2D_DISABLE_COPY(Ref); - -private: - int ref_count_; -}; - - -// 图片 -class Image : - public Ref -{ -public: - Image(); - - explicit Image( - const Resource& res - ); - - explicit Image( - const Resource& res, - const Rect& crop_rect /* 裁剪矩形 */ - ); - - explicit Image( - const String& file_name - ); - - explicit Image( - const String& file_name, - const Rect& crop_rect /* 裁剪矩形 */ - ); - - virtual ~Image(); - - // 加载图片资源 - bool Open( - const Resource& res - ); - - // 加载图片资源 - bool Open( - const String& file_name - ); - - // 将图片裁剪为矩形 - void Crop( - const Rect& crop_rect /* 裁剪矩形 */ - ); - - // 获取宽度 - virtual float GetWidth() const; - - // 获取高度 - virtual float GetHeight() const; - - // 获取大小 - virtual Size GetSize() const; - - // 获取源图片宽度 - virtual float GetSourceWidth() const; - - // 获取源图片高度 - virtual float GetSourceHeight() const; - - // 获取源图片大小 - virtual Size GetSourceSize() const; - - // 获取裁剪位置 X 坐标 - virtual float GetCropX() const; - - // 获取裁剪位置 Y 坐标 - virtual float GetCropY() const; - - // 获取裁剪位置 - virtual Point GetCropPos() const; - - // 获取 ID2D1Bitmap 对象 - ID2D1Bitmap * GetBitmap(); - - // 预加载图片资源 - static bool Preload( - const String& file_name - ); - - // 预加载图片资源 - static bool Preload( - const Resource& res - ); - - // 清空缓存 - static void ClearCache(); - -protected: - E2D_DISABLE_COPY(Image); - - // 设置 Bitmap - void SetBitmap( - ID2D1Bitmap * bitmap - ); - -protected: - Rect crop_rect_; - ID2D1Bitmap * bitmap_; - - static std::map bitmap_cache_; -}; - - -} - - -namespace e2d -{ - struct autorelease_t { }; - - extern autorelease_t const autorelease; -} - -void* operator new( - size_t size, - e2d::autorelease_t const& - ) E2D_NOEXCEPT; - -void operator delete( - void* block, - e2d::autorelease_t const& - ) E2D_NOEXCEPT; diff --git a/core/e2dcomponent.h b/core/e2dcomponent.h index 19978ec4..4c190317 100644 --- a/core/e2dcomponent.h +++ b/core/e2dcomponent.h @@ -1,1203 +1,281 @@ #pragma once -#include "e2dcommon.h" -#include "e2devent.h" +#include "e2dnode.h" -namespace e2d +namespace e2d { -class Action; -class Scene; - - -// 绘图接口 -class Drawable -{ -public: - // 渲染图形 - virtual void Draw() const = 0; -}; - - -// 更新接口 -class Updatable -{ -public: - // 渲染图形 - virtual void Update() = 0; -}; - - -// 按键消息处理接口 -class KeyEventHandler -{ -public: - // 处理按键消息 - virtual void Handle(KeyEvent e) = 0; -}; - - -// 鼠标消息处理接口 -class MouseEventHandler -{ -public: - // 处理鼠标消息 - virtual void Handle(MouseEvent e) = 0; -}; - - -// 碰撞消息处理接口 -class CollisionHandler -{ -public: - // 处理碰撞消息 - virtual void Handle(Collision collision) = 0; -}; - - -// 节点 -class Node : - public Ref -{ - friend class Collider; - -public: - // 节点属性 - struct Property - { - Point pos; // 坐标 - Size size; // 大小 - Point anchor; // 锚点坐标 - Point scale; // 缩放 - Point skew; // 倾斜角度 - float rotation; // 旋转角度 - - Property operator+ (Property const & prop) const; - Property operator- (Property const & prop) const; - - static const Property Origin; - }; - -public: - typedef std::vector Nodes; - typedef std::vector Actions; - - Node(); - - virtual ~Node(); - - // 获取节点显示状态 - bool IsVisible() const; - - // 获取节点名称 - const String& GetName() const; - - // 获取节点名称的 Hash 值 - size_t GetHashName() const; - - // 获取节点绘图顺序 - int GetOrder() const; - - // 获取节点横坐标 - float GetPosX() const; - - // 获取节点纵坐标 - float GetPosY() const; - - // 获取节点坐标 - Point GetPos() const; - - // 获取节点宽度 - float GetWidth() const; - - // 获取节点高度 - float GetHeight() const; - - // 获取节点宽度(不考虑缩放) - float GetRealWidth() const; - - // 获取节点高度(不考虑缩放) - float GetRealHeight() const; - - // 获取节点大小(不考虑缩放) - Size GetRealSize() const; - - // 获取节点的锚点 - float GetAnchorX() const; - - // 获取节点的锚点 - float GetAnchorY() const; - - // 获取节点大小 - Size GetSize() const; - - // 获取节点横向缩放比例 - float GetScaleX() const; - - // 获取节点纵向缩放比例 - float GetScaleY() const; - - // 获取节点横向倾斜角度 - float GetSkewX() const; - - // 获取节点纵向倾斜角度 - float GetSkewY() const; - - // 获取节点旋转角度 - float GetRotation() const; - - // 获取节点透明度 - float GetOpacity() const; - - // 获取节点属性 - Property GetProperty() const; - - // 获取差别属性 - Property GetExtrapolate() const; - - // 获取节点碰撞体 - Collider * GetCollider(); - - // 获取父节点 - Node * GetParent() const; - - // 获取节点所在场景 - Scene * GetParentScene() const; - - // 设置节点是否显示 - void SetVisible( - bool value - ); - - // 设置节点名称 - void SetName( - const String& name - ); - - // 设置节点横坐标 - virtual void SetPosX( - float x - ); - - // 设置节点纵坐标 - virtual void SetPosY( - float y - ); - - // 设置节点坐标 - virtual void SetPos( - const Point & point - ); - - // 设置节点坐标 - virtual void SetPos( - float x, - float y - ); - - // 节点坐标固定 - virtual void SetPosFixed( - bool fixed - ); - - // 移动节点 - virtual void Move( - float x, - float y - ); - - // 移动节点 - virtual void Move( - const Point & v - ); - - // 设置节点绘图顺序 - // 默认为 0 - virtual void SetOrder( - int order - ); - - // 设置横向缩放比例 - // 默认为 1.0 - virtual void SetScaleX( - float scale_x - ); - - // 设置纵向缩放比例 - // 默认为 1.0 - virtual void SetScaleY( - float scale_y - ); - - // 设置缩放比例 - // 默认为 (1.0, 1.0) - virtual void SetScale( - float scale_x, - float scale_y - ); - - // 设置缩放比例 - // 默认为 1.0 - virtual void SetScale( - float scale - ); - - // 设置横向倾斜角度 - // 默认为 0 - virtual void SetSkewX( - float skew_x - ); - - // 设置纵向倾斜角度 - // 默认为 0 - virtual void SetSkewY( - float skew_y - ); - - // 设置倾斜角度 - // 默认为 (0, 0) - virtual void SetSkew( - float skew_x, - float skew_y - ); - - // 设置旋转角度 - // 默认为 0 - virtual void SetRotation( - float rotation - ); - - // 设置透明度 - // 默认为 1.0, 范围 [0, 1] - virtual void SetOpacity( - float opacity - ); - - // 设置锚点的横向位置 - // 默认为 0, 范围 [0, 1] - virtual void SetAnchorX( - float anchor_x - ); - - // 设置锚点的纵向位置 - // 默认为 0, 范围 [0, 1] - virtual void SetAnchorY( - float anchor_y - ); - - // 设置锚点位置 - // 默认为 (0, 0), 范围 [0, 1] - virtual void SetAnchor( - float anchor_x, - float anchor_y - ); - - // 修改节点宽度 - virtual void SetWidth( - float width - ); - - // 修改节点高度 - virtual void SetHeight( - float height - ); - - // 修改节点大小 - virtual void SetSize( - float width, - float height - ); - - // 修改节点大小 - virtual void SetSize( - Size size - ); - - // 设置节点属性 - virtual void SetProperty( - Property prop - ); - - // 启用或关闭渲染区域裁剪 - virtual void SetClipEnabled( - bool enabled - ); - - // 设置节点边缘颜色 - virtual void SetBorderColor( - const Color& color - ); - - // 判断点是否在节点内 - bool ContainsPoint( - const Point& point - ); - - // 判断两物体是否相交 - bool Intersects( - Node * node - ); - - // 添加子节点 - void AddChild( - Node * child, - int order = 0 /* 渲染顺序 */ - ); - - // 添加多个子节点 - void AddChild( - const Nodes& nodes, /* 节点数组 */ - int order = 0 /* 渲染顺序 */ - ); - - // 获取所有名称相同的子节点 - Nodes GetChildren( - const String& name - ) const; - - // 获取名称相同的子节点 - Node* GetChild( - const String& name - ) const; - - // 获取所有子节点 - const Nodes& GetAllChildren() const; - - // 获取子节点数量 - int GetChildrenCount() const; - - // 移除子节点 - bool RemoveChild( - Node * child - ); - - // 移除所有名称相同的子节点 - void RemoveChildren( - const String& child_name - ); - - // 移除所有节点 - void RemoveAllChildren(); - - // 从父节点移除 - void RemoveFromParent(); - - // 执行动作 - void RunAction( - Action * action - ); - - // 继续动作 - void ResumeAction( - const String& name - ); - - // 暂停动作 - void PauseAction( - const String& name - ); - - // 停止动作 - void StopAction( - const String& name - ); - - // 继续所有暂停动作 - void ResumeAllActions(); - - // 暂停所有动作 - void PauseAllActions(); - - // 停止所有动作 - void StopAllActions(); - - // 获取所有动作 - const Actions& GetAllActions() const; - - // 刷新动作进度 - void UpdateActionsTime(); - - // 分发鼠标消息 - virtual bool Dispatch( - const MouseEvent& e, - bool handled - ); - - // 分发按键消息 - virtual bool Dispatch( - const KeyEvent& e, - bool handled - ); - - // 遍历节点 - virtual void Visit(); - -protected: - E2D_DISABLE_COPY(Node); - - // 渲染节点边缘 - void DrawBorder(); - - // 渲染碰撞体轮廓 - void DrawCollider(); - - // 设置节点所在场景 - void SetParentScene( - Scene * scene - ); - - // 子节点排序 - void SortChildren(); - - // 更新转换矩阵 - void UpdateTransform(); - - // 更新节点透明度 - void UpdateOpacity(); - - // 更新动作 - void UpdateActions(); - -protected: - String name_; - size_t hash_name_; - Point pos_; - Size size_; - Point scale_; - Point anchor_; - Point skew_; - float rotation_; - float display_opacity_; - float real_opacity_; - int order_; - bool visible_; - bool clip_enabled_; - bool need_sort_; - bool need_transform_; - bool fixed_position_; - Collider collider_; - Scene * parent_scene_; - Node * parent_; - Property extrapolate_; - Color border_color_; - Actions actions_; - Nodes children_; - ID2D1Geometry* border_; - D2D1::Matrix3x2F initial_matrix_; - D2D1::Matrix3x2F final_matrix_; -}; - - -// 场景 -class Scene : - public Node -{ -public: - Scene(); - - virtual ~Scene(); - - // 进入场景 - virtual void OnEnter() {} - - // 退出场景 - virtual void OnExit() {} - - // 关闭窗口 - // 说明:返回 false 将阻止窗口关闭 - virtual bool OnCloseWindow() { return true; } - - // 显示或隐藏节点边缘 - // 默认:隐藏 - void ShowBorder( - bool visible - ); - - // 显示或隐藏碰撞体 - // 默认:隐藏 - void ShowCollider( - bool visible - ); - - // 遍历节点 - virtual void Visit() override; - -protected: - E2D_DISABLE_COPY(Scene); - -protected: - bool border_visible_; - bool collider_visible_; -}; - - -// 精灵 -class Sprite : - public Node, - public Drawable -{ -public: - Sprite(); - - explicit Sprite( - Image * image - ); - - explicit Sprite( - const Resource& res - ); - - explicit Sprite( - const Resource& res, - const Rect& crop_rect /* 裁剪矩形 */ - ); - - explicit Sprite( - const String& file_name - ); - - explicit Sprite( - const String& file_name, - const Rect& crop_rect /* 裁剪矩形 */ - ); - - virtual ~Sprite(); - - // 加载图片文件 - bool Open( - const Resource& res - ); - - // 加载图片文件 - bool Open( - const String& file_name - ); - - // 加载图片 - bool Open( - Image * image - ); - - // 将图片裁剪为矩形 - void Crop( - const Rect& crop_rect /* 裁剪矩形 */ - ); - - // 获取 Image 对象 - Image * GetImage() const; - - // 渲染精灵 - virtual void Draw() const override; - -protected: - E2D_DISABLE_COPY(Sprite); - -protected: - Image * image_; -}; - - -// 文本 -class Text : - public Node, - public Drawable -{ -public: - // 文本对齐方式 - enum class Align - { - Left, /* 左对齐 */ - Right, /* 右对齐 */ - Center /* 居中对齐 */ - }; - - // 文本样式 - class Style + class Button : + public Node { public: - Color color; // 颜色 - Align alignment; // 对齐方式 - bool wrap; // 打开自动换行 - float wrap_width; // 自动换行宽度 - float line_spacing; // 行间距 - bool underline; // 下划线 - bool strikethrough; // 删除线 - bool outline; // 显示描边 - Color outline_color; // 描边颜色 - float outline_width; // 描边线宽 - Stroke outline_stroke; // 描边线相交样式 + Button(); - public: - Style(); - - Style( - Color color, - Align alignment = Align::Left, - bool wrap = false, - float wrap_width = 0.f, - float line_spacing = 0.f, - bool underline = false, - bool strikethrough = false, - bool outline = true, - Color outline_color = Color(Color::Black, 0.5), - float outline_width = 1.f, - Stroke outline_stroke = Stroke::Round + explicit Button( + Node * normal, /* 普通状态 */ + const Function& func = nullptr /* 按钮点击后的回调函数 */ ); + + explicit Button( + Node * normal, /* 普通状态 */ + Node * selected, /* 鼠标按下状态 */ + const Function& func = nullptr /* 按钮点击后的回调函数 */ + ); + + explicit Button( + Node * normal, /* 普通状态 */ + Node * mouseover, /* 鼠标移入状态 */ + Node * selected, /* 鼠标按下状态 */ + const Function& func = nullptr /* 按钮点击后的回调函数 */ + ); + + explicit Button( + Node * normal, /* 普通状态 */ + Node * mouseover, /* 鼠标移入状态 */ + Node * selected, /* 鼠标移入状态 */ + Node * disabled, /* 按钮禁用状态 */ + const Function& func = nullptr /* 按钮点击后的回调函数 */ + ); + + // 获取按钮状态是启用还是禁用 + bool IsEnable() const; + + // 设置按钮启用或禁用 + void SetEnabled( + bool enabled + ); + + // 设置一般情况下显示的按钮 + virtual void SetNormal( + Node * normal + ); + + // 设置鼠标移入按钮时显示的按钮 + virtual void SetMouseOver( + Node * mouseover + ); + + // 设置鼠标按下按钮时显示的按钮 + virtual void SetSelected( + Node * selected + ); + + // 设置按钮被禁用时显示的按钮 + virtual void SetDisabled( + Node * disabled + ); + + // 设置按钮点击后的回调函数 + void SetCallbackOnClick( + const Function& func + ); + + // 设置锚点位置 + // 默认为 (0, 0), 范围 [0, 1] + virtual void SetAnchor( + float anchor_x, + float anchor_y + ) override; + + // 分发鼠标消息 + virtual bool Dispatch( + const MouseEvent& e, + bool handled + ) override; + + // 遍历节点 + virtual void Visit() override; + + protected: + E2D_DISABLE_COPY(Button); + + // 按钮状态枚举 + enum class Status { Normal, Mouseover, Selected }; + + // 设置按钮状态 + virtual void SetStatus( + Status status + ); + + // 刷新按钮显示 + virtual void UpdateVisible(); + + // 点击回调 + virtual void OnClick(); + + protected: + Node * normal_; + Node * mouseover_; + Node * selected_; + Node * disabled_; + bool enabled_; + bool is_selected_; + Status status_; + Function callback_; }; -public: - Text(); - explicit Text( - const String& text, /* 文字内容 */ - const Font& font = Font(), /* 字体 */ - const Style& style = Style() /* 文本样式 */ - ); - - virtual ~Text(); - - // 获取文本 - const String& GetText() const; - - // 获取字体 - const Font& GetFont() const; - - // 获取文本样式 - const Style& GetStyle() const; - - // 获取字体族 - const String& GetFontFamily() const; - - // 获取当前字号 - float GetFontSize() const; - - // 获取当前字体粗细值 - UINT GetFontWeight() const; - - // 获取文字颜色 - const Color& GetColor() const; - - // 获取描边颜色 - const Color& GetOutlineColor() const; - - // 获取描边线宽 - float GetOutlineWidth() const; - - // 获取描边线相交样式 - Stroke GetOutlineStroke() const; - - // 获取文本显示行数 - int GetLineCount() const; - - // 是否是斜体 - bool IsItalic() const; - - // 是否显示删除线 - bool strikethrough() const; - - // 是否显示下划线 - bool underline() const; - - // 是否显示描边 - bool outline() const; - - // 设置文本 - void SetText( - const String& text - ); - - // 设置文本样式 - void SetStyle( - const Style& style - ); - - // 设置字体 - void SetFont( - const Font& font - ); - - // 设置字体族 - void SetFontFamily( - const String& family - ); - - // 设置字号(默认值为 22) - void SetFontSize( - float size - ); - - // 设置字体粗细值(默认值为 Text::Font::Weight::Normal) - void SetFontWeight( - UINT weight - ); - - // 设置文字颜色(默认值为 Color::WHITE) - void SetColor( - Color color - ); - - // 设置文字斜体(默认值为 false) - void SetItalic( - bool value - ); - - // 打开或关闭文本自动换行(默认为关闭) - void SetWrapEnabled( - bool wrap - ); - - // 设置文本自动换行的宽度(默认为 0) - void SetWrapWidth( - float wrap_width - ); - - // 设置行间距(默认为 0) - void SetLineSpacing( - float line_spacing - ); - - // 设置对齐方式(默认为 Align::Left) - void SetAlignment( - Align align - ); - - // 设置下划线(默认值为 false) - void SetUnderline( - bool underline - ); - - // 设置删除线(默认值为 false) - void SetStrikethrough( - bool strikethrough - ); - - // 设置是否显示描边 - void SetOutline( - bool outline - ); - - // 设置描边颜色 - void SetOutlineColor( - Color outline_color - ); - - // 设置描边线宽 - void SetOutlineWidth( - float outline_width - ); - - // 设置描边线相交样式 - void SetOutlineStroke( - Stroke outline_stroke - ); - - // 渲染文字 - virtual void Draw() const override; - -protected: - E2D_DISABLE_COPY(Text); - - // 重新排版文字 - void Reset(); - - // 创建文字格式化 - void CreateFormat(); - - // 创建文字布局 - void CreateLayout(); - -protected: - String text_; - Font font_; - Style style_; - IDWriteTextFormat * text_format_; - IDWriteTextLayout * text_layout_; -}; - - -class Button : - public Node -{ -public: - Button(); - - explicit Button( - Node * normal, /* 普通状态 */ - const Function& func = nullptr /* 按钮点击后的回调函数 */ - ); - - explicit Button( - Node * normal, /* 普通状态 */ - Node * selected, /* 鼠标按下状态 */ - const Function& func = nullptr /* 按钮点击后的回调函数 */ - ); - - explicit Button( - Node * normal, /* 普通状态 */ - Node * mouseover, /* 鼠标移入状态 */ - Node * selected, /* 鼠标按下状态 */ - const Function& func = nullptr /* 按钮点击后的回调函数 */ - ); - - explicit Button( - Node * normal, /* 普通状态 */ - Node * mouseover, /* 鼠标移入状态 */ - Node * selected, /* 鼠标移入状态 */ - Node * disabled, /* 按钮禁用状态 */ - const Function& func = nullptr /* 按钮点击后的回调函数 */ - ); - - // 获取按钮状态是启用还是禁用 - bool IsEnable() const; - - // 设置按钮启用或禁用 - void SetEnabled( - bool enabled - ); - - // 设置一般情况下显示的按钮 - virtual void SetNormal( - Node * normal - ); - - // 设置鼠标移入按钮时显示的按钮 - virtual void SetMouseOver( - Node * mouseover - ); - - // 设置鼠标按下按钮时显示的按钮 - virtual void SetSelected( - Node * selected - ); - - // 设置按钮被禁用时显示的按钮 - virtual void SetDisabled( - Node * disabled - ); - - // 设置按钮点击后的回调函数 - void SetCallbackOnClick( - const Function& func - ); - - // 设置锚点位置 - // 默认为 (0, 0), 范围 [0, 1] - virtual void SetAnchor( - float anchor_x, - float anchor_y - ) override; - - // 分发鼠标消息 - virtual bool Dispatch( - const MouseEvent& e, - bool handled - ) override; - - // 遍历节点 - virtual void Visit() override; - -protected: - E2D_DISABLE_COPY(Button); - - // 按钮状态枚举 - enum class Status { Normal, Mouseover, Selected }; - - // 设置按钮状态 - virtual void SetStatus( - Status status - ); - - // 刷新按钮显示 - virtual void UpdateVisible(); - - // 点击回调 - virtual void OnClick(); - -protected: - Node * normal_; - Node * mouseover_; - Node * selected_; - Node * disabled_; - bool enabled_; - bool is_selected_; - Status status_; - Function callback_; -}; - - -class ToggleButton : - public Button -{ -public: - ToggleButton(); - - explicit ToggleButton( - Node * normal_on, /* 按钮打开时,普通状态 */ - Node * normal_off, /* 按钮关闭时,普通状态 */ - const Function& func = nullptr /* 按钮点击后的回调函数 */ - ); - - explicit ToggleButton( - Node * normal_on, /* 按钮打开时,普通状态 */ - Node * normal_off, /* 按钮关闭时,普通状态 */ - Node * selected_on, /* 按钮打开时,鼠标按下状态 */ - Node * selected_off, /* 按钮关闭时,鼠标按下状态 */ - const Function& func = nullptr /* 按钮点击后的回调函数 */ - ); - - explicit ToggleButton( - Node * normal_on, /* 按钮打开时,普通状态 */ - Node * normal_off, /* 按钮关闭时,普通状态 */ - Node * mouseover_on, /* 按钮打开时,鼠标移入状态 */ - Node * mouseover_off, /* 按钮关闭时,鼠标移入状态 */ - Node * selected_on, /* 按钮打开时,鼠标按下状态 */ - Node * selected_off, /* 按钮关闭时,鼠标按下状态 */ - const Function& func = nullptr /* 按钮点击后的回调函数 */ - ); - - explicit ToggleButton( - Node * normal_on, /* 按钮打开时,普通状态 */ - Node * normal_off, /* 按钮关闭时,普通状态 */ - Node * mouseover_on, /* 按钮打开时,鼠标移入状态 */ - Node * mouseover_off, /* 按钮关闭时,鼠标移入状态 */ - Node * selected_on, /* 按钮打开时,鼠标按下状态 */ - Node * selected_off, /* 按钮关闭时,鼠标按下状态 */ - Node * disabled_on, /* 按钮打开时,禁用状态 */ - Node * disabled_off, /* 按钮关闭时,禁用状态 */ - const Function& func = nullptr /* 按钮点击后的回调函数 */ - ); - - // 获取开关状态 - bool IsChecked() const; - - // 设置开关按钮的状态 - void SetChecked( - bool checked - ); - - // 设置按钮打开状态下显示的按钮 - virtual void SetNormal( - Node * normal - ) override; - - // 设置按钮打开状态下,鼠标移入按钮时显示的按钮 - virtual void SetMouseOver( - Node * mouseover - ) override; - - // 设置按钮打开状态下,鼠标按下按钮时显示的按钮 - virtual void SetSelected( - Node * selected - ) override; - - // 设置按钮打开状态下,被禁用时显示的按钮 - virtual void SetDisabled( - Node * disabled - ) override; - - // 设置按钮关闭状态下显示的按钮 - void SetNormalOff( - Node * normal - ); - - // 设置按钮关闭状态下,鼠标移入按钮时显示的按钮 - void SetMouseOverOff( - Node * mouseover - ); - - // 设置按钮关闭状态下,鼠标按下按钮时显示的按钮 - void SetSelectedOff( - Node * selected - ); - - // 设置按钮关闭状态下,按钮被禁用时显示的按钮 - void SetDisabledOff( - Node * disabled - ); - - // 设置锚点位置 - // 默认为 (0, 0), 范围 [0, 1] - virtual void SetAnchor( - float anchor_x, - float anchor_y - ) override; - -protected: - E2D_DISABLE_COPY(ToggleButton); - - // 刷新按钮开关 - virtual void UpdateStatus(); - - // 执行按钮函数对象 - virtual void OnClick() override; - -protected: - Node* normal_on_; - Node* mouseover_on_; - Node* selected_on_; - Node* disabled_on_; - Node* normal_off_; - Node* mouseover_off_; - Node* selected_off_; - Node* disabled_off_; - bool checked_; -}; - - -class Menu : - public Node -{ -public: - Menu(); - - explicit Menu( - const std::vector& buttons /* 按钮数组 */ - ); - - // 获取菜单是否禁用 - bool IsEnable() const; - - // 获取菜单中的按钮数量 - size_t GetButtonCount() const; - - // 设置菜单启用或禁用 - void SetEnabled( - bool enabled - ); - - // 添加按钮 - void AddButton( - Button * button - ); - - // 移除按钮 - bool RemoveButton( - Button * button - ); - - // 获取所有按钮 - const std::vector& GetAllButtons() const; - -protected: - E2D_DISABLE_COPY(Menu); - -protected: - bool enabled_; - std::vector buttons_; -}; - - -// 画布 -class Canvas : - public Node, - public Drawable -{ -public: - Canvas( - float width, - float height - ); - - virtual ~Canvas(); - - // 设置线条颜色 - void SetLineColor( - const Color& color - ); - - // 设置填充颜色 - void SetFillColor( - const Color& color - ); - - // 设置线条宽度 - void SetStrokeWidth( - float width - ); - - // 设置线条相交样式 - void SetStrokeStyle( - Stroke strokeStyle - ); - - // 获取线条颜色 - Color GetLineColor() const; - - // 获取填充颜色 - Color GetFillColor() const; - - // 获取线条宽度 - float GetStrokeWidth() const; - - // 获取线条相交样式 - Stroke GetStrokeStyle() const; - - // 画直线 - void DrawLine( - const Point& begin, - const Point& end - ); - - // 画圆形边框 - void DrawCircle( - const Point& center, - float radius - ); - - // 画椭圆形边框 - void DrawEllipse( - const Point& center, - float radius_x, - float radius_y - ); - - // 画矩形边框 - void DrawRect( - const Rect& rect - ); - - // 画圆角矩形边框 - void DrawRoundedRect( - const Rect& rect, - float radius_x, - float radius_y - ); - - // 填充圆形 - void FillCircle( - const Point& center, - float radius - ); - - // 填充椭圆形 - void FillEllipse( - const Point& center, - float radius_x, - float radius_y - ); - - // 填充矩形 - void FillRect( - const Rect& rect - ); - - // 填充圆角矩形 - void FillRoundedRect( - const Rect& rect, - float radius_x, - float radius_y - ); - -protected: - E2D_DISABLE_COPY(Canvas); - -protected: - float stroke_width_; - Stroke stroke_; - ID2D1RenderTarget * render_target_; - ID2D1SolidColorBrush * fill_brush_; - ID2D1SolidColorBrush * line_brush_; - ID2D1StrokeStyle * stroke_style_; -}; - -} \ No newline at end of file + class ToggleButton : + public Button + { + public: + ToggleButton(); + + explicit ToggleButton( + Node * normal_on, /* 按钮打开时,普通状态 */ + Node * normal_off, /* 按钮关闭时,普通状态 */ + const Function& func = nullptr /* 按钮点击后的回调函数 */ + ); + + explicit ToggleButton( + Node * normal_on, /* 按钮打开时,普通状态 */ + Node * normal_off, /* 按钮关闭时,普通状态 */ + Node * selected_on, /* 按钮打开时,鼠标按下状态 */ + Node * selected_off, /* 按钮关闭时,鼠标按下状态 */ + const Function& func = nullptr /* 按钮点击后的回调函数 */ + ); + + explicit ToggleButton( + Node * normal_on, /* 按钮打开时,普通状态 */ + Node * normal_off, /* 按钮关闭时,普通状态 */ + Node * mouseover_on, /* 按钮打开时,鼠标移入状态 */ + Node * mouseover_off, /* 按钮关闭时,鼠标移入状态 */ + Node * selected_on, /* 按钮打开时,鼠标按下状态 */ + Node * selected_off, /* 按钮关闭时,鼠标按下状态 */ + const Function& func = nullptr /* 按钮点击后的回调函数 */ + ); + + explicit ToggleButton( + Node * normal_on, /* 按钮打开时,普通状态 */ + Node * normal_off, /* 按钮关闭时,普通状态 */ + Node * mouseover_on, /* 按钮打开时,鼠标移入状态 */ + Node * mouseover_off, /* 按钮关闭时,鼠标移入状态 */ + Node * selected_on, /* 按钮打开时,鼠标按下状态 */ + Node * selected_off, /* 按钮关闭时,鼠标按下状态 */ + Node * disabled_on, /* 按钮打开时,禁用状态 */ + Node * disabled_off, /* 按钮关闭时,禁用状态 */ + const Function& func = nullptr /* 按钮点击后的回调函数 */ + ); + + // 获取开关状态 + bool IsChecked() const; + + // 设置开关按钮的状态 + void SetChecked( + bool checked + ); + + // 设置按钮打开状态下显示的按钮 + virtual void SetNormal( + Node * normal + ) override; + + // 设置按钮打开状态下,鼠标移入按钮时显示的按钮 + virtual void SetMouseOver( + Node * mouseover + ) override; + + // 设置按钮打开状态下,鼠标按下按钮时显示的按钮 + virtual void SetSelected( + Node * selected + ) override; + + // 设置按钮打开状态下,被禁用时显示的按钮 + virtual void SetDisabled( + Node * disabled + ) override; + + // 设置按钮关闭状态下显示的按钮 + void SetNormalOff( + Node * normal + ); + + // 设置按钮关闭状态下,鼠标移入按钮时显示的按钮 + void SetMouseOverOff( + Node * mouseover + ); + + // 设置按钮关闭状态下,鼠标按下按钮时显示的按钮 + void SetSelectedOff( + Node * selected + ); + + // 设置按钮关闭状态下,按钮被禁用时显示的按钮 + void SetDisabledOff( + Node * disabled + ); + + // 设置锚点位置 + // 默认为 (0, 0), 范围 [0, 1] + virtual void SetAnchor( + float anchor_x, + float anchor_y + ) override; + + protected: + E2D_DISABLE_COPY(ToggleButton); + + // 刷新按钮开关 + virtual void UpdateStatus(); + + // 执行按钮函数对象 + virtual void OnClick() override; + + protected: + Node * normal_on_; + Node* mouseover_on_; + Node* selected_on_; + Node* disabled_on_; + Node* normal_off_; + Node* mouseover_off_; + Node* selected_off_; + Node* disabled_off_; + bool checked_; + }; + + + // 菜单 + class Menu : + public Node + { + public: + Menu(); + + explicit Menu( + const std::vector& buttons /* 按钮数组 */ + ); + + // 获取菜单是否禁用 + bool IsEnable() const; + + // 获取菜单中的按钮数量 + size_t GetButtonCount() const; + + // 设置菜单启用或禁用 + void SetEnabled( + bool enabled + ); + + // 添加按钮 + void AddButton( + Button * button + ); + + // 移除按钮 + bool RemoveButton( + Button * button + ); + + // 获取所有按钮 + const std::vector& GetAllButtons() const; + + protected: + E2D_DISABLE_COPY(Menu); + + protected: + bool enabled_; + std::vector buttons_; + }; + + +} diff --git a/core/e2devent.h b/core/e2devent.h index 30231ef3..802aa840 100644 --- a/core/e2devent.h +++ b/core/e2devent.h @@ -1,5 +1,5 @@ #pragma once -#include "e2dcommon.h" +#include "e2dutil.h" namespace e2d { diff --git a/core/e2dimpl.h b/core/e2dimpl.h index 697d2d07..bfed6404 100644 --- a/core/e2dimpl.h +++ b/core/e2dimpl.h @@ -1,5 +1,5 @@ #pragma once -#include "e2dcommon.h" +#include "e2dutil.h" namespace e2d { diff --git a/core/e2dmanager.h b/core/e2dmanager.h index 3b2036d4..b07b9977 100644 --- a/core/e2dmanager.h +++ b/core/e2dmanager.h @@ -1,6 +1,6 @@ #pragma once #include "e2dmacros.h" -#include "e2dcommon.h" +#include "e2dutil.h" namespace e2d { diff --git a/core/e2dmodule.h b/core/e2dmodule.h index 8578fbc6..581fb90f 100644 --- a/core/e2dmodule.h +++ b/core/e2dmodule.h @@ -1,6 +1,6 @@ #pragma once #include "e2dimpl.h" -#include "e2dcomponent.h" +#include "e2dnode.h" #include "e2dtransition.h" diff --git a/core/e2dnode.h b/core/e2dnode.h new file mode 100644 index 00000000..4180f668 --- /dev/null +++ b/core/e2dnode.h @@ -0,0 +1,931 @@ +#pragma once +#include "e2dutil.h" +#include "e2devent.h" + +namespace e2d +{ + + + class Action; + class Scene; + + + // 绘图接口 + class Drawable + { + public: + // 渲染图形 + virtual void Draw() const = 0; + }; + + + // 更新接口 + class Updatable + { + public: + // 渲染图形 + virtual void Update() = 0; + }; + + + // 按键消息处理接口 + class KeyEventHandler + { + public: + // 处理按键消息 + virtual void Handle(KeyEvent e) = 0; + }; + + + // 鼠标消息处理接口 + class MouseEventHandler + { + public: + // 处理鼠标消息 + virtual void Handle(MouseEvent e) = 0; + }; + + + // 碰撞消息处理接口 + class CollisionHandler + { + public: + // 处理碰撞消息 + virtual void Handle(Collision collision) = 0; + }; + + + // 节点 + class Node : + public Ref + { + friend class Collider; + + public: + // 节点属性 + struct Property + { + Point pos; // 坐标 + Size size; // 大小 + Point anchor; // 锚点坐标 + Point scale; // 缩放 + Point skew; // 倾斜角度 + float rotation; // 旋转角度 + + Property operator+ (Property const & prop) const; + Property operator- (Property const & prop) const; + + static const Property Origin; + }; + + public: + typedef std::vector Nodes; + typedef std::vector Actions; + + Node(); + + virtual ~Node(); + + // 获取节点显示状态 + bool IsVisible() const; + + // 获取节点名称 + const String& GetName() const; + + // 获取节点名称的 Hash 值 + size_t GetHashName() const; + + // 获取节点绘图顺序 + int GetOrder() const; + + // 获取节点横坐标 + float GetPosX() const; + + // 获取节点纵坐标 + float GetPosY() const; + + // 获取节点坐标 + Point GetPos() const; + + // 获取节点宽度 + float GetWidth() const; + + // 获取节点高度 + float GetHeight() const; + + // 获取节点宽度(不考虑缩放) + float GetRealWidth() const; + + // 获取节点高度(不考虑缩放) + float GetRealHeight() const; + + // 获取节点大小(不考虑缩放) + Size GetRealSize() const; + + // 获取节点的锚点 + float GetAnchorX() const; + + // 获取节点的锚点 + float GetAnchorY() const; + + // 获取节点大小 + Size GetSize() const; + + // 获取节点横向缩放比例 + float GetScaleX() const; + + // 获取节点纵向缩放比例 + float GetScaleY() const; + + // 获取节点横向倾斜角度 + float GetSkewX() const; + + // 获取节点纵向倾斜角度 + float GetSkewY() const; + + // 获取节点旋转角度 + float GetRotation() const; + + // 获取节点透明度 + float GetOpacity() const; + + // 获取节点属性 + Property GetProperty() const; + + // 获取差别属性 + Property GetExtrapolate() const; + + // 获取节点碰撞体 + Collider * GetCollider(); + + // 获取父节点 + Node * GetParent() const; + + // 获取节点所在场景 + Scene * GetParentScene() const; + + // 设置节点是否显示 + void SetVisible( + bool value + ); + + // 设置节点名称 + void SetName( + const String& name + ); + + // 设置节点横坐标 + virtual void SetPosX( + float x + ); + + // 设置节点纵坐标 + virtual void SetPosY( + float y + ); + + // 设置节点坐标 + virtual void SetPos( + const Point & point + ); + + // 设置节点坐标 + virtual void SetPos( + float x, + float y + ); + + // 节点坐标固定 + virtual void SetPosFixed( + bool fixed + ); + + // 移动节点 + virtual void Move( + float x, + float y + ); + + // 移动节点 + virtual void Move( + const Point & v + ); + + // 设置节点绘图顺序 + // 默认为 0 + virtual void SetOrder( + int order + ); + + // 设置横向缩放比例 + // 默认为 1.0 + virtual void SetScaleX( + float scale_x + ); + + // 设置纵向缩放比例 + // 默认为 1.0 + virtual void SetScaleY( + float scale_y + ); + + // 设置缩放比例 + // 默认为 (1.0, 1.0) + virtual void SetScale( + float scale_x, + float scale_y + ); + + // 设置缩放比例 + // 默认为 1.0 + virtual void SetScale( + float scale + ); + + // 设置横向倾斜角度 + // 默认为 0 + virtual void SetSkewX( + float skew_x + ); + + // 设置纵向倾斜角度 + // 默认为 0 + virtual void SetSkewY( + float skew_y + ); + + // 设置倾斜角度 + // 默认为 (0, 0) + virtual void SetSkew( + float skew_x, + float skew_y + ); + + // 设置旋转角度 + // 默认为 0 + virtual void SetRotation( + float rotation + ); + + // 设置透明度 + // 默认为 1.0, 范围 [0, 1] + virtual void SetOpacity( + float opacity + ); + + // 设置锚点的横向位置 + // 默认为 0, 范围 [0, 1] + virtual void SetAnchorX( + float anchor_x + ); + + // 设置锚点的纵向位置 + // 默认为 0, 范围 [0, 1] + virtual void SetAnchorY( + float anchor_y + ); + + // 设置锚点位置 + // 默认为 (0, 0), 范围 [0, 1] + virtual void SetAnchor( + float anchor_x, + float anchor_y + ); + + // 修改节点宽度 + virtual void SetWidth( + float width + ); + + // 修改节点高度 + virtual void SetHeight( + float height + ); + + // 修改节点大小 + virtual void SetSize( + float width, + float height + ); + + // 修改节点大小 + virtual void SetSize( + Size size + ); + + // 设置节点属性 + virtual void SetProperty( + Property prop + ); + + // 启用或关闭渲染区域裁剪 + virtual void SetClipEnabled( + bool enabled + ); + + // 设置节点边缘颜色 + virtual void SetBorderColor( + const Color& color + ); + + // 判断点是否在节点内 + bool ContainsPoint( + const Point& point + ); + + // 判断两物体是否相交 + bool Intersects( + Node * node + ); + + // 添加子节点 + void AddChild( + Node * child, + int order = 0 /* 渲染顺序 */ + ); + + // 添加多个子节点 + void AddChild( + const Nodes& nodes, /* 节点数组 */ + int order = 0 /* 渲染顺序 */ + ); + + // 获取所有名称相同的子节点 + Nodes GetChildren( + const String& name + ) const; + + // 获取名称相同的子节点 + Node* GetChild( + const String& name + ) const; + + // 获取所有子节点 + const Nodes& GetAllChildren() const; + + // 获取子节点数量 + int GetChildrenCount() const; + + // 移除子节点 + bool RemoveChild( + Node * child + ); + + // 移除所有名称相同的子节点 + void RemoveChildren( + const String& child_name + ); + + // 移除所有节点 + void RemoveAllChildren(); + + // 从父节点移除 + void RemoveFromParent(); + + // 执行动作 + void RunAction( + Action * action + ); + + // 继续动作 + void ResumeAction( + const String& name + ); + + // 暂停动作 + void PauseAction( + const String& name + ); + + // 停止动作 + void StopAction( + const String& name + ); + + // 继续所有暂停动作 + void ResumeAllActions(); + + // 暂停所有动作 + void PauseAllActions(); + + // 停止所有动作 + void StopAllActions(); + + // 获取所有动作 + const Actions& GetAllActions() const; + + // 刷新动作进度 + void UpdateActionsTime(); + + // 分发鼠标消息 + virtual bool Dispatch( + const MouseEvent& e, + bool handled + ); + + // 分发按键消息 + virtual bool Dispatch( + const KeyEvent& e, + bool handled + ); + + // 遍历节点 + virtual void Visit(); + + protected: + E2D_DISABLE_COPY(Node); + + // 渲染节点边缘 + void DrawBorder(); + + // 渲染碰撞体轮廓 + void DrawCollider(); + + // 设置节点所在场景 + void SetParentScene( + Scene * scene + ); + + // 子节点排序 + void SortChildren(); + + // 更新转换矩阵 + void UpdateTransform(); + + // 更新节点透明度 + void UpdateOpacity(); + + // 更新动作 + void UpdateActions(); + + protected: + String name_; + size_t hash_name_; + Point pos_; + Size size_; + Point scale_; + Point anchor_; + Point skew_; + float rotation_; + float display_opacity_; + float real_opacity_; + int order_; + bool visible_; + bool clip_enabled_; + bool need_sort_; + bool need_transform_; + bool fixed_position_; + Collider collider_; + Scene * parent_scene_; + Node * parent_; + Property extrapolate_; + Color border_color_; + Actions actions_; + Nodes children_; + ID2D1Geometry* border_; + D2D1::Matrix3x2F initial_matrix_; + D2D1::Matrix3x2F final_matrix_; + }; + + + // 场景 + class Scene : + public Node + { + public: + Scene(); + + virtual ~Scene(); + + // 进入场景 + virtual void OnEnter() {} + + // 退出场景 + virtual void OnExit() {} + + // 关闭窗口 + // 说明:返回 false 将阻止窗口关闭 + virtual bool OnCloseWindow() { return true; } + + // 显示或隐藏节点边缘 + // 默认:隐藏 + void ShowBorder( + bool visible + ); + + // 显示或隐藏碰撞体 + // 默认:隐藏 + void ShowCollider( + bool visible + ); + + // 遍历节点 + virtual void Visit() override; + + protected: + E2D_DISABLE_COPY(Scene); + + protected: + bool border_visible_; + bool collider_visible_; + }; + + + // 精灵 + class Sprite : + public Node, + public Drawable + { + public: + Sprite(); + + explicit Sprite( + Image * image + ); + + explicit Sprite( + const Resource& res + ); + + explicit Sprite( + const Resource& res, + const Rect& crop_rect /* 裁剪矩形 */ + ); + + explicit Sprite( + const String& file_name + ); + + explicit Sprite( + const String& file_name, + const Rect& crop_rect /* 裁剪矩形 */ + ); + + virtual ~Sprite(); + + // 加载图片文件 + bool Open( + const Resource& res + ); + + // 加载图片文件 + bool Open( + const String& file_name + ); + + // 加载图片 + bool Open( + Image * image + ); + + // 将图片裁剪为矩形 + void Crop( + const Rect& crop_rect /* 裁剪矩形 */ + ); + + // 获取 Image 对象 + Image * GetImage() const; + + // 渲染精灵 + virtual void Draw() const override; + + protected: + E2D_DISABLE_COPY(Sprite); + + protected: + Image * image_; + }; + + + // 文本 + class Text : + public Node, + public Drawable + { + public: + // 文本对齐方式 + enum class Align + { + Left, /* 左对齐 */ + Right, /* 右对齐 */ + Center /* 居中对齐 */ + }; + + // 文本样式 + class Style + { + public: + Color color; // 颜色 + Align alignment; // 对齐方式 + bool wrap; // 打开自动换行 + float wrap_width; // 自动换行宽度 + float line_spacing; // 行间距 + bool underline; // 下划线 + bool strikethrough; // 删除线 + bool outline; // 显示描边 + Color outline_color; // 描边颜色 + float outline_width; // 描边线宽 + Stroke outline_stroke; // 描边线相交样式 + + public: + Style(); + + Style( + Color color, + Align alignment = Align::Left, + bool wrap = false, + float wrap_width = 0.f, + float line_spacing = 0.f, + bool underline = false, + bool strikethrough = false, + bool outline = true, + Color outline_color = Color(Color::Black, 0.5), + float outline_width = 1.f, + Stroke outline_stroke = Stroke::Round + ); + }; + + public: + Text(); + + explicit Text( + const String& text, /* 文字内容 */ + const Font& font = Font(), /* 字体 */ + const Style& style = Style() /* 文本样式 */ + ); + + virtual ~Text(); + + // 获取文本 + const String& GetText() const; + + // 获取字体 + const Font& GetFont() const; + + // 获取文本样式 + const Style& GetStyle() const; + + // 获取字体族 + const String& GetFontFamily() const; + + // 获取当前字号 + float GetFontSize() const; + + // 获取当前字体粗细值 + UINT GetFontWeight() const; + + // 获取文字颜色 + const Color& GetColor() const; + + // 获取描边颜色 + const Color& GetOutlineColor() const; + + // 获取描边线宽 + float GetOutlineWidth() const; + + // 获取描边线相交样式 + Stroke GetOutlineStroke() const; + + // 获取文本显示行数 + int GetLineCount() const; + + // 是否是斜体 + bool IsItalic() const; + + // 是否显示删除线 + bool strikethrough() const; + + // 是否显示下划线 + bool underline() const; + + // 是否显示描边 + bool outline() const; + + // 设置文本 + void SetText( + const String& text + ); + + // 设置文本样式 + void SetStyle( + const Style& style + ); + + // 设置字体 + void SetFont( + const Font& font + ); + + // 设置字体族 + void SetFontFamily( + const String& family + ); + + // 设置字号(默认值为 22) + void SetFontSize( + float size + ); + + // 设置字体粗细值(默认值为 Text::Font::Weight::Normal) + void SetFontWeight( + UINT weight + ); + + // 设置文字颜色(默认值为 Color::WHITE) + void SetColor( + Color color + ); + + // 设置文字斜体(默认值为 false) + void SetItalic( + bool value + ); + + // 打开或关闭文本自动换行(默认为关闭) + void SetWrapEnabled( + bool wrap + ); + + // 设置文本自动换行的宽度(默认为 0) + void SetWrapWidth( + float wrap_width + ); + + // 设置行间距(默认为 0) + void SetLineSpacing( + float line_spacing + ); + + // 设置对齐方式(默认为 Align::Left) + void SetAlignment( + Align align + ); + + // 设置下划线(默认值为 false) + void SetUnderline( + bool underline + ); + + // 设置删除线(默认值为 false) + void SetStrikethrough( + bool strikethrough + ); + + // 设置是否显示描边 + void SetOutline( + bool outline + ); + + // 设置描边颜色 + void SetOutlineColor( + Color outline_color + ); + + // 设置描边线宽 + void SetOutlineWidth( + float outline_width + ); + + // 设置描边线相交样式 + void SetOutlineStroke( + Stroke outline_stroke + ); + + // 渲染文字 + virtual void Draw() const override; + + protected: + E2D_DISABLE_COPY(Text); + + // 重新排版文字 + void Reset(); + + // 创建文字格式化 + void CreateFormat(); + + // 创建文字布局 + void CreateLayout(); + + protected: + String text_; + Font font_; + Style style_; + IDWriteTextFormat * text_format_; + IDWriteTextLayout * text_layout_; + }; + + + // 画布 + class Canvas : + public Node, + public Drawable + { + public: + Canvas( + float width, + float height + ); + + virtual ~Canvas(); + + // 设置线条颜色 + void SetLineColor( + const Color& color + ); + + // 设置填充颜色 + void SetFillColor( + const Color& color + ); + + // 设置线条宽度 + void SetStrokeWidth( + float width + ); + + // 设置线条相交样式 + void SetStrokeStyle( + Stroke strokeStyle + ); + + // 获取线条颜色 + Color GetLineColor() const; + + // 获取填充颜色 + Color GetFillColor() const; + + // 获取线条宽度 + float GetStrokeWidth() const; + + // 获取线条相交样式 + Stroke GetStrokeStyle() const; + + // 画直线 + void DrawLine( + const Point& begin, + const Point& end + ); + + // 画圆形边框 + void DrawCircle( + const Point& center, + float radius + ); + + // 画椭圆形边框 + void DrawEllipse( + const Point& center, + float radius_x, + float radius_y + ); + + // 画矩形边框 + void DrawRect( + const Rect& rect + ); + + // 画圆角矩形边框 + void DrawRoundedRect( + const Rect& rect, + float radius_x, + float radius_y + ); + + // 填充圆形 + void FillCircle( + const Point& center, + float radius + ); + + // 填充椭圆形 + void FillEllipse( + const Point& center, + float radius_x, + float radius_y + ); + + // 填充矩形 + void FillRect( + const Rect& rect + ); + + // 填充圆角矩形 + void FillRoundedRect( + const Rect& rect, + float radius_x, + float radius_y + ); + + protected: + E2D_DISABLE_COPY(Canvas); + + protected: + float stroke_width_; + Stroke stroke_; + ID2D1RenderTarget * render_target_; + ID2D1SolidColorBrush * fill_brush_; + ID2D1SolidColorBrush * line_brush_; + ID2D1StrokeStyle * stroke_style_; + }; + +} diff --git a/core/e2dtool.h b/core/e2dtool.h new file mode 100644 index 00000000..74e785d8 --- /dev/null +++ b/core/e2dtool.h @@ -0,0 +1,510 @@ +#pragma once +#include "e2dutil.h" +#include "e2dimpl.h" + +namespace e2d +{ + + +// 随机数产生器 +class Random +{ +public: + // 取得范围内的一个整型随机数 + template + static inline T Range(T min, T max) + { + return e2d::Random::RandomInt(min, max); + } + + // 取得范围内的一个浮点数随机数 + static inline float Range(float min, float max) + { + return e2d::Random::RandomReal(min, max); + } + + // 取得范围内的一个浮点数随机数 + static inline double Range(double min, double max) + { + return e2d::Random::RandomReal(min, max); + } + +private: + template + static T RandomInt(T min, T max) + { + std::uniform_int_distribution dist(min, max); + return dist(Random::GetEngine()); + } + + template + static T RandomReal(T min, T max) + { + std::uniform_real_distribution dist(min, max); + return dist(Random::GetEngine()); + } + + // 获取随机数产生器 + static std::default_random_engine &GetEngine(); +}; + + +// 音乐 +class Music : + public Ref +{ + friend class VoiceCallback; + +public: + Music(); + + explicit Music( + const e2d::String& file_path /* 音乐文件路径 */ + ); + + explicit Music( + const Resource& res /* 音乐资源 */ + ); + + virtual ~Music(); + + // 打开音乐文件 + bool Open( + const e2d::String& file_path /* 音乐文件路径 */ + ); + + // 打开音乐资源 + bool Open( + const Resource& res + ); + + // 播放 + bool Play( + int loopCount = 0 + ); + + // 暂停 + void Pause(); + + // 继续 + void Resume(); + + // 停止 + void Stop(); + + // 关闭并回收资源 + void Close(); + + // 是否正在播放 + bool IsPlaying() const; + + // 设置音量 + bool SetVolume( + float volume + ); + + // 设置播放结束时的执行函数 + void SetCallbackOnEnd( + const Function& func + ); + + // 设置循环播放中每一次播放结束时的执行函数 + void SetCallbackOnLoopEnd( + const Function& func + ); + + // 获取 IXAudio2SourceVoice 对象 + IXAudio2SourceVoice * GetSourceVoice() const; + +protected: + bool _readMMIO(); + + bool _resetFile(); + + bool _read( + BYTE* buffer, + DWORD size_to_read + ); + + bool _findMediaFileCch( + wchar_t* dest_path, + int cch_dest, + const wchar_t * file_name + ); + +protected: + bool opened_; + DWORD size_; + CHAR* buffer_; + BYTE* wave_data_; + HMMIO hmmio_; + MMCKINFO ck_; + MMCKINFO ck_riff_; + WAVEFORMATEX* wfx_; + VoiceCallback callback_; + IXAudio2SourceVoice* voice_; +}; + + +// 音乐播放器 +class Player +{ +public: + // 获取播放器实例 + static Player * GetInstance(); + + // 销毁实例 + static void DestroyInstance(); + + // 预加载音乐资源 + bool Preload( + const String& file_path /* 音乐文件路径 */ + ); + + // 播放音乐 + bool Play( + const String& file_path, /* 音乐文件路径 */ + int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */ + ); + + // 暂停音乐 + void Pause( + const String& file_path /* 音乐文件路径 */ + ); + + // 继续播放音乐 + void Resume( + const String& file_path /* 音乐文件路径 */ + ); + + // 停止音乐 + void Stop( + const String& file_path /* 音乐文件路径 */ + ); + + // 获取音乐播放状态 + bool IsPlaying( + const String& file_path /* 音乐文件路径 */ + ); + + // 预加载音乐资源 + bool Preload( + const Resource& res /* 音乐资源 */ + ); + + // 播放音乐 + bool Play( + const Resource& res, /* 音乐资源 */ + int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */ + ); + + // 暂停音乐 + void Pause( + const Resource& res /* 音乐资源 */ + ); + + // 继续播放音乐 + void Resume( + const Resource& res /* 音乐资源 */ + ); + + // 停止音乐 + void Stop( + const Resource& res /* 音乐资源 */ + ); + + // 获取音乐播放状态 + bool IsPlaying( + const Resource& res /* 音乐资源 */ + ); + + // 获取音量 + float GetVolume(); + + // 设置音量 + void SetVolume( + float volume /* 音量范围为 -224 ~ 224,0 是静音,1 是正常音量 */ + ); + + // 暂停所有音乐 + void PauseAll(); + + // 继续播放所有音乐 + void ResumeAll(); + + // 停止所有音乐 + void StopAll(); + + // 清空音乐缓存 + void ClearCache(); + +protected: + Player(); + + ~Player(); + + E2D_DISABLE_COPY(Player); + +protected: + float volume_; + std::map musics_; + + static Player * instance_; +}; + + +class Timer; + +// 定时任务 +class Task : + public Ref +{ + friend class Timer; + +public: + explicit Task( + const Function& func, /* 执行函数 */ + const String& name = L"" /* 任务名称 */ + ); + + explicit Task( + const Function& func, /* 执行函数 */ + float delay, /* 时间间隔(秒) */ + int times = -1, /* 执行次数(设 -1 为永久执行) */ + const String& name = L"" /* 任务名称 */ + ); + + // 启动任务 + void Start(); + + // 停止任务 + void Stop(); + + // 任务是否正在执行 + bool IsRunning() const; + + // 获取任务名称 + const String& GetName() const; + +protected: + // 执行任务 + void Update(); + + // 任务是否就绪 + bool IsReady() const; + +protected: + bool running_; + bool stopped_; + int run_times_; + int total_times_; + String name_; + Duration delay_; + Time last_time_; + Function callback_; +}; + + +// 定时器 +class Timer +{ +public: + // 获取定时器实例 + static Timer * GetInstance(); + + // 添加任务 + void AddTask( + Task * task + ); + + // 启动任务 + void StartTasks( + const String& task_name + ); + + // 停止任务 + void StopTasks( + const String& task_name + ); + + // 移除任务 + void RemoveTasks( + const String& task_name + ); + + // 启动所有任务 + void StartAllTasks(); + + // 停止所有任务 + void StopAllTasks(); + + // 移除所有任务 + void RemoveAllTasks(); + + // 更新定时器 + void Update(); + + // 刷新所有任务计时 + void UpdateTime(); + +private: + Timer(); + + ~Timer(); + + E2D_DISABLE_COPY(Timer); + +private: + std::vector tasks_; +}; + + +// 数据管理工具 +class Data +{ +public: + Data( + const String& key, /* 键值 */ + const String& field = L"Defalut" /* 字段名称 */ + ); + + // 该数据是否存在 + bool Exists() const; + + // 保存 int 类型的值 + bool SaveInt( + int value + ); + + // 保存 float 类型的值 + bool SaveFloat( + float value + ); + + // 保存 double 类型的值 + bool SaveDouble( + double value + ); + + // 保存 bool 类型的值 + bool SaveBool( + bool value + ); + + // 保存 String 类型的值 + bool SaveString( + const String& value + ); + + // 获取 int 类型的值 + int GetInt() const; + + // 获取 float 类型的值 + float GetFloat() const; + + // 获取 double 类型的值 + double GetDouble() const; + + // 获取 bool 类型的值 + bool GetBool() const; + + // 获取 字符串 类型的值 + String GetString(); + +protected: + String key_; + String field_; + const String& data_path_; +}; + + +// 文件 +class File +{ +public: + File(); + + File( + const String& file_name + ); + + virtual ~File(); + + // 打开文件 + bool Open( + const String& file_name + ); + + // 文件或文件夹是否存在 + bool Exists() const; + + // 是否是文件夹 + bool IsFolder() const; + + // 删除文件 + bool Delete(); + + // 获取文件路径 + const String& GetPath() const; + + // 获取文件扩展名 + String GetExtension() const; + + // 释放资源到临时文件目录 + static File Extract( + int resource_name, /* 资源名称 */ + const String& resource_type, /* 资源类型 */ + const String& dest_file_name /* 目标文件名 */ + ); + + // 添加文件搜索路径 + static void AddSearchPath( + const String& path + ); + + // 创建文件夹 + static bool CreateFolder( + const String& dir_path /* 文件夹路径 */ + ); + + // 弹出打开文件对话框 + static File ShowOpenDialog( + const String& title = L"打开", /* 对话框标题 */ + const String& filter = L"" /* 筛选扩展名,例如 "*.jpg;*.jpeg" */ + ); + + // 弹出保存文件对话框 + static File ShowSaveDialog( + const String& title = L"保存", /* 对话框标题 */ + const String& def_file = L"", /* 默认保存的文件名 */ + const String& def_ext = L"" /* 默认追加的扩展名,例如 "txt" */ + ); + +protected: + DWORD attributes_; + String file_path_; + + static std::list search_paths_; +}; + + +// 路径 +class Path +{ + friend class Game; + +public: + // 获取数据的默认保存路径 + static const String& GetDataPath(); + + // 获取临时文件目录 + static const String& GetTemporaryPath(); + + // 获取 LocalAppData 目录 + static const String& GetLocalAppDataPath(); + + // 获取当前程序的运行路径 + static const String& GetExeFilePath(); +}; + +} \ No newline at end of file diff --git a/core/e2dtransition.h b/core/e2dtransition.h index 8169d3a7..3394719d 100644 --- a/core/e2dtransition.h +++ b/core/e2dtransition.h @@ -1,5 +1,5 @@ #pragma once -#include "e2dcommon.h" +#include "e2dutil.h" namespace e2d { diff --git a/core/e2dutil.h b/core/e2dutil.h index 1a6805b8..e6541125 100644 --- a/core/e2dutil.h +++ b/core/e2dutil.h @@ -1,510 +1,851 @@ #pragma once -#include "e2dcommon.h" -#include "e2dimpl.h" +#include "e2dmacros.h" namespace e2d { -// 随机数产生器 -class Random -{ -public: - // 取得范围内的一个整型随机数 - template - static inline T Range(T min, T max) - { - return e2d::Random::RandomInt(min, max); - } - - // 取得范围内的一个浮点数随机数 - static inline float Range(float min, float max) - { - return e2d::Random::RandomReal(min, max); - } - - // 取得范围内的一个浮点数随机数 - static inline double Range(double min, double max) - { - return e2d::Random::RandomReal(min, max); - } - -private: - template - static T RandomInt(T min, T max) + // 方向 + enum class Direction : int { - std::uniform_int_distribution dist(min, max); - return dist(Random::GetEngine()); - } + Up, /* 上 */ + Down, /* 下 */ + Left, /* 左 */ + Right /* 右 */ + }; - template - static T RandomReal(T min, T max) + + // 线条相交样式 + enum class Stroke : int { - std::uniform_real_distribution dist(min, max); - return dist(Random::GetEngine()); - } - - // 获取随机数产生器 - static std::default_random_engine &GetEngine(); -}; + Miter = 0, /* 斜切 */ + Bevel = 1, /* 斜角 */ + Round = 2 /* 圆角 */ + }; -// 音乐 -class Music : - public Ref + class Size; + + // 坐标 + class Point + { + public: + float x; // X 坐标 + float y; // Y 坐标 + + public: + Point(); + + Point( + float x, + float y + ); + + Point( + const Point& other + ); + + Point operator + (const Point & other) const; + Point operator - (const Point & other) const; + Point operator * (float value) const; + Point operator / (float value) const; + Point operator - () const; + bool operator== (const Point& other) const; + + E2D_OP_EXPLICIT operator e2d::Size() const; + + // 判断两点间距离 + static float Distance( + const Point& p1, + const Point& p2 + ); + }; + + + // 大小 + class Size + { + public: + float width; // 宽度 + float height; // 高度 + + public: + Size(); + + Size( + float width, + float height + ); + + Size( + const Size& other + ); + + Size operator + (const Size & other) const; + Size operator - (const Size & other) const; + Size operator * (float value) const; + Size operator / (float value) const; + Size operator - () const; + bool operator== (const Size& other) const; + + E2D_OP_EXPLICIT operator e2d::Point() const; + }; + + + // 矩形 + class Rect + { + public: + Point origin; // 原点坐标 + Size size; // 宽度和高度 + + public: + Rect(); + + Rect( + float x, + float y, + float width, + float height + ); + + Rect( + const Point& pos, + const Size& size + ); + + Rect( + const Rect& other + ); + + Rect& operator= (const Rect& other); + + bool operator== (const Rect& rect) const; + + // 判断点是否在矩形内 + bool ContainsPoint( + const Point& point + ) const; + + // 判断两矩形是否相交 + bool Intersects( + const Rect& rect + ) const; + }; + + + // 字符串 + class String + { + public: + String(); + + String( + const String & + ); + + String( + const char * + ); + + String( + const wchar_t * + ); + + String( + String && + ); + + ~String(); + + // 获取字符串长度 + int GetLength() const; + + // 获取该字符串的 Hash 值 + size_t GetHash() const; + + // 判断字符串是否为空 + bool IsEmpty() const; + + // 获取指定位置字符 + const wchar_t& At( + size_t index + ) const; + + // 比较字符串 + int Compare( + const String & str + ) const; + + // 截取字符串 + String Subtract( + int offset, /* 偏移量 */ + int count = -1 /* 截取字符数量 */ + ) const; + + // 插入字符串 + void Insert( + const String & str, + int pos + ); + + // 替换字符串中的指定内容 + void Replace( + const String & from, /* 需替换内容 */ + const String & to /* 替换成内容 */ + ); + + // 删除字符串中的指定内容 + void Erase( + int offset, /* 偏移量 */ + int count /* 删除字符数量 */ + ); + + // 搜索字符串 + int Find( + const String & str, /* 查找内容 */ + int offset = 0 /* 偏移量 */ + ) const; + + // 清空字符串 + void Clear(); + + // 获取大写字符串 + String ToUpper() const; + + // 获取小写字符串 + String ToLower() const; + + // 将字符串转化为 int 型 + int ToInt() const; + + // 将字符串转化为 float 型 + float ToFloat() const; + + // 将字符串转化为 double 型 + double ToDouble() const; + + // 将字符串转化为 bool 型 + bool ToBool() const; + + // 数字类型转字符串 + static String Parse(int value); + static String Parse(unsigned int value); + static String Parse(float value); + static String Parse(double value); + + // 格式化字符串 + static String Format(const char * format, ...); + static String Format(const wchar_t * format, ...); + + // 赋值运算符 + String& operator= (const String &); + String& operator= (const char *); + String& operator= (const wchar_t *); + + // 运算符 + String& operator+= (const String &); + String& operator+= (const char *); + String& operator+= (const wchar_t *); + String operator+ (const String &) const; + String operator+ (const char *) const; + String operator+ (const wchar_t *) const; + + // 友元运算符 + friend String operator+ (const char *, const String &); + friend String operator+ (const wchar_t*, const String &); + + // 类型转换操作符 + E2D_OP_EXPLICIT operator const wchar_t* () const; + E2D_OP_EXPLICIT operator wchar_t* () const; + E2D_OP_EXPLICIT operator std::wstring() const; + E2D_OP_EXPLICIT operator std::string() const; + + // 比较运算符 + bool operator== (const String &) const; + bool operator== (const char *) const; + bool operator== (const wchar_t *) const; + bool operator!= (const String &) const; + bool operator!= (const char *) const; + bool operator!= (const wchar_t *) const; + bool operator> (const String &) const; + bool operator>= (const String &) const; + bool operator< (const String &) const; + bool operator<= (const String &) const; + + // << 运算符(后接字符串) + String& operator<< (const String &); + String& operator<< (const char *); + String& operator<< (char *); + String& operator<< (const wchar_t *); + String& operator<< (wchar_t *); + String& operator<< (int value); + String& operator<< (unsigned int value); + String& operator<< (float value); + String& operator<< (double value); + + // 其他运算符 + wchar_t& operator[] (size_t); + + friend std::ostream& operator<< (std::ostream &, const String &); + friend std::wostream& operator<< (std::wostream &, const String &); + + friend std::istream& operator>> (std::istream &, String &); + friend std::wistream& operator>> (std::wistream &, String &); + + private: + std::wstring string_; + }; + + + // 颜色 + class Color + { + public: + Color(); + + Color( + float r, + float g, + float b + ); + + Color( + float r, + float g, + float b, + float alpha + ); + + Color( + UINT rgb + ); + + Color( + UINT rgb, + float alpha + ); + + Color( + const D2D1_COLOR_F& color + ); + + E2D_OP_EXPLICIT operator D2D1_COLOR_F() const; + + public: + enum Value : UINT + { + Black = 0x000000, + Blue = 0x0000FF, + BlueViolet = 0x8A2BE2, + Brown = 0xA52A2A, + Chocolate = 0xD2691E, + DarkBlue = 0x00008B, + DarkGray = 0xA9A9A9, + DarkGreen = 0x006400, + DarkOrange = 0xFF8C00, + DarkRed = 0x8B0000, + DarkViolet = 0x9400D3, + ForestGreen = 0x228B22, + Gold = 0xFFD700, + Gray = 0x808080, + Green = 0x008000, + GreenYellow = 0xADFF2F, + LightBlue = 0xADD8E6, + LightCyan = 0xE0FFFF, + LightGreen = 0x90EE90, + LightGray = 0xD3D3D3, + LightPink = 0xFFB6C1, + LightSeaGreen = 0x20B2AA, + LightSkyBlue = 0x87CEFA, + LightYellow = 0xFFFFE0, + Orange = 0xFFA500, + OrangeRed = 0xFF4500, + Pink = 0xFFC0CB, + Purple = 0x800080, + Red = 0xFF0000, + Silver = 0xC0C0C0, + SkyBlue = 0x87CEEB, + Snow = 0xFFFAFA, + Violet = 0xEE82EE, + Wheat = 0xF5DEB3, + White = 0xFFFFFF, + WhiteSmoke = 0xF5F5F5, + Wood = 0xDEB887, + Yellow = 0xFFFF00, + Yellow_Green = 0x9ACD32 + }; + + public: + float r; + float g; + float b; + float a; + }; + + + // 键盘键值 + enum class KeyCode : int + { + Unknown = 0, + Up = 0xC8, + Left = 0xCB, + Right = 0xCD, + Down = 0xD0, + Enter = 0x1C, + Space = 0x39, + Esc = 0x01, + Q = 0x10, + W = 0x11, + E = 0x12, + R = 0x13, + T = 0x14, + Y = 0x15, + U = 0x16, + I = 0x17, + O = 0x18, + P = 0x19, + A = 0x1E, + S = 0x1F, + D = 0x20, + F = 0x21, + G = 0x22, + H = 0x23, + J = 0x24, + K = 0x25, + L = 0x26, + Z = 0x2C, + X = 0x2D, + C = 0x2E, + V = 0x2F, + B = 0x30, + N = 0x31, + M = 0x32, + Num1 = 0x02, + Num2 = 0x03, + Num3 = 0x04, + Num4 = 0x05, + Num5 = 0x06, + Num6 = 0x07, + Num7 = 0x08, + Num8 = 0x09, + Num9 = 0x0A, + Num0 = 0x0B, + Numpad7 = 0x47, + Numpad8 = 0x48, + Numpad9 = 0x49, + Numpad4 = 0x4B, + Numpad5 = 0x4C, + Numpad6 = 0x4D, + Numpad1 = 0x4F, + Numpad2 = 0x50, + Numpad3 = 0x51, + Numpad0 = 0x52, + }; + + + // 鼠标键值 + enum class MouseCode : int + { + Left, /* 鼠标左键 */ + Right, /* 鼠标右键 */ + Middle /* 鼠标中键 */ + }; + + + // 函数对象 + class Function + { + public: + Function(); + + Function( + std::nullptr_t + ); + + Function( + std::function func + ); + + template + Function(Func func) : func_(func) {} + + template + Function( + Func&& func, /* 对象的成员函数 */ + Object&& obj /* 对象指针 */ + ) + { + func_ = std::bind(func, obj); + } + + void operator() (void) const; + + E2D_OP_EXPLICIT operator bool() const; + + protected: + std::function func_; + }; + + + // 时间段 + class Duration + { + public: + Duration(); + + explicit Duration( + float seconds + ); + + // 获取毫秒数 + int Milliseconds() const; + + // 获取秒数 + float Seconds() const; + + bool operator== (const Duration &) const; + bool operator!= (const Duration &) const; + bool operator> (const Duration &) const; + bool operator>= (const Duration &) const; + bool operator< (const Duration &) const; + bool operator<= (const Duration &) const; + + Duration operator + (Duration const &) const; + Duration operator - (Duration const &) const; + + Duration& operator += (Duration const &); + Duration& operator -= (Duration const &); + + protected: + std::chrono::milliseconds duration_ms_; + }; + + + // 时间点 + class Time + { + public: + Time(); + + // 获取时间戳 + time_t GetTimeStamp() const; + + // 是否是 + bool IsZero() const; + + Time operator + (Duration const &) const; + Time operator - (Duration const &) const; + + Time& operator += (Duration const &); + Time& operator -= (Duration const &); + + Duration operator - (Time const &) const; + + // 获取当前时间 + static Time Now(); + + protected: + std::chrono::steady_clock::time_point time_; + }; + + + // 字体 + class Font + { + public: + String family; // 字体族 + float size; // 字号 + UINT weight; // 粗细值 + bool italic; // 是否斜体 + + public: + // 字体粗细值 + enum Weight : UINT + { + Thin = 100, + ExtraLight = 200, + Light = 300, + Normal = 400, + Medium = 500, + Bold = 700, + ExtraBold = 800, + Black = 900, + ExtraBlack = 950 + }; + + public: + Font(); + + explicit Font( + const String& family, + float size = 22, + UINT weight = Font::Weight::Normal, + bool italic = false + ); + }; + + + class Node; + + // 碰撞体 + class Collider + { + public: + // 碰撞体形状 + enum class Shape + { + None, /* 无 */ + Rect, /* 矩形 */ + Circle, /* 圆形 */ + Ellipse /* 椭圆形 */ + }; + + // 碰撞体交集关系 + enum class Relation : int + { + Unknown = 0, /* 关系不确定 */ + Disjoin = 1, /* 没有交集 */ + IsContained = 2, /* 完全被包含 */ + Contains = 3, /* 完全包含 */ + Overlap = 4 /* 部分重叠 */ + }; + + public: + explicit Collider( + Node * parent + ); + + virtual ~Collider(); + + // 设置碰撞体形状 + void SetShape( + Shape shape + ); + + // 是否触发碰撞事件 + void SetCollisionNotify( + bool notify + ); + + // 启用或关闭该碰撞体 + void SetEnabled( + bool enabled + ); + + // 设置碰撞体的可见性 + void SetVisible( + bool visible + ); + + // 设置绘制颜色 + void SetBorderColor( + const Color& color + ); + + // 判断两碰撞体的交集关系 + Relation GetRelationWith( + Collider * collider + ) const; + + // 是否启用碰撞体 + bool IsEnabled() const; + + // 是否可见 + bool IsVisible() const; + + // 是否触发碰撞事件 + bool IsCollisionNotify() const; + + // 获取绘制颜色 + const Color& GetBorderColor() const; + + // 获取形状 + Shape GetShape() const; + + // 获取绑定节点 + Node* GetNode() const; + + // 获取 ID2D1Geometry* 对象 + ID2D1Geometry* GetGeometry() const; + + // 重新生成 + void Recreate(); + + // 渲染碰撞体 + void Draw(); + + protected: + E2D_DISABLE_COPY(Collider); + + protected: + bool enabled_; + bool visible_; + bool notify_; + Color border_color_; + Node * parent_node_; + Shape shape_; + ID2D1Geometry* geometry_; + }; + + + // 资源 + class Resource + { + public: + Resource( + size_t resource_name, /* 资源名称 */ + const String& resource_type /* 资源类型 */ + ); + + public: + size_t name; + String type; + }; + + + // 引用计数对象 + class Ref + { + public: + Ref(); + + virtual ~Ref(); + + // 增加引用计数 + void Retain(); + + // 减少引用计数 + void Release(); + + // 获取引用计数 + int GetRefCount() const; + + protected: + E2D_DISABLE_COPY(Ref); + + private: + int ref_count_; + }; + + + // 图片 + class Image : + public Ref + { + public: + Image(); + + explicit Image( + const Resource& res + ); + + explicit Image( + const Resource& res, + const Rect& crop_rect /* 裁剪矩形 */ + ); + + explicit Image( + const String& file_name + ); + + explicit Image( + const String& file_name, + const Rect& crop_rect /* 裁剪矩形 */ + ); + + virtual ~Image(); + + // 加载图片资源 + bool Open( + const Resource& res + ); + + // 加载图片资源 + bool Open( + const String& file_name + ); + + // 将图片裁剪为矩形 + void Crop( + const Rect& crop_rect /* 裁剪矩形 */ + ); + + // 获取宽度 + virtual float GetWidth() const; + + // 获取高度 + virtual float GetHeight() const; + + // 获取大小 + virtual Size GetSize() const; + + // 获取源图片宽度 + virtual float GetSourceWidth() const; + + // 获取源图片高度 + virtual float GetSourceHeight() const; + + // 获取源图片大小 + virtual Size GetSourceSize() const; + + // 获取裁剪位置 X 坐标 + virtual float GetCropX() const; + + // 获取裁剪位置 Y 坐标 + virtual float GetCropY() const; + + // 获取裁剪位置 + virtual Point GetCropPos() const; + + // 获取 ID2D1Bitmap 对象 + ID2D1Bitmap * GetBitmap(); + + // 预加载图片资源 + static bool Preload( + const String& file_name + ); + + // 预加载图片资源 + static bool Preload( + const Resource& res + ); + + // 清空缓存 + static void ClearCache(); + + protected: + E2D_DISABLE_COPY(Image); + + // 设置 Bitmap + void SetBitmap( + ID2D1Bitmap * bitmap + ); + + protected: + Rect crop_rect_; + ID2D1Bitmap * bitmap_; + + static std::map bitmap_cache_; + }; + + +} + + +namespace e2d { - friend class VoiceCallback; + struct autorelease_t { }; -public: - Music(); + extern autorelease_t const autorelease; +} - explicit Music( - const e2d::String& file_path /* 音乐文件路径 */ - ); +void* operator new( + size_t size, + e2d::autorelease_t const& + ) E2D_NOEXCEPT; - explicit Music( - const Resource& res /* 音乐资源 */ - ); - - virtual ~Music(); - - // 打开音乐文件 - bool Open( - const e2d::String& file_path /* 音乐文件路径 */ - ); - - // 打开音乐资源 - bool Open( - const Resource& res - ); - - // 播放 - bool Play( - int loopCount = 0 - ); - - // 暂停 - void Pause(); - - // 继续 - void Resume(); - - // 停止 - void Stop(); - - // 关闭并回收资源 - void Close(); - - // 是否正在播放 - bool IsPlaying() const; - - // 设置音量 - bool SetVolume( - float volume - ); - - // 设置播放结束时的执行函数 - void SetCallbackOnEnd( - const Function& func - ); - - // 设置循环播放中每一次播放结束时的执行函数 - void SetCallbackOnLoopEnd( - const Function& func - ); - - // 获取 IXAudio2SourceVoice 对象 - IXAudio2SourceVoice * GetSourceVoice() const; - -protected: - bool _readMMIO(); - - bool _resetFile(); - - bool _read( - BYTE* buffer, - DWORD size_to_read - ); - - bool _findMediaFileCch( - wchar_t* dest_path, - int cch_dest, - const wchar_t * file_name - ); - -protected: - bool opened_; - DWORD size_; - CHAR* buffer_; - BYTE* wave_data_; - HMMIO hmmio_; - MMCKINFO ck_; - MMCKINFO ck_riff_; - WAVEFORMATEX* wfx_; - VoiceCallback callback_; - IXAudio2SourceVoice* voice_; -}; - - -// 音乐播放器 -class Player -{ -public: - // 获取播放器实例 - static Player * GetInstance(); - - // 销毁实例 - static void DestroyInstance(); - - // 预加载音乐资源 - bool Preload( - const String& file_path /* 音乐文件路径 */ - ); - - // 播放音乐 - bool Play( - const String& file_path, /* 音乐文件路径 */ - int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */ - ); - - // 暂停音乐 - void Pause( - const String& file_path /* 音乐文件路径 */ - ); - - // 继续播放音乐 - void Resume( - const String& file_path /* 音乐文件路径 */ - ); - - // 停止音乐 - void Stop( - const String& file_path /* 音乐文件路径 */ - ); - - // 获取音乐播放状态 - bool IsPlaying( - const String& file_path /* 音乐文件路径 */ - ); - - // 预加载音乐资源 - bool Preload( - const Resource& res /* 音乐资源 */ - ); - - // 播放音乐 - bool Play( - const Resource& res, /* 音乐资源 */ - int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */ - ); - - // 暂停音乐 - void Pause( - const Resource& res /* 音乐资源 */ - ); - - // 继续播放音乐 - void Resume( - const Resource& res /* 音乐资源 */ - ); - - // 停止音乐 - void Stop( - const Resource& res /* 音乐资源 */ - ); - - // 获取音乐播放状态 - bool IsPlaying( - const Resource& res /* 音乐资源 */ - ); - - // 获取音量 - float GetVolume(); - - // 设置音量 - void SetVolume( - float volume /* 音量范围为 -224 ~ 224,0 是静音,1 是正常音量 */ - ); - - // 暂停所有音乐 - void PauseAll(); - - // 继续播放所有音乐 - void ResumeAll(); - - // 停止所有音乐 - void StopAll(); - - // 清空音乐缓存 - void ClearCache(); - -protected: - Player(); - - ~Player(); - - E2D_DISABLE_COPY(Player); - -protected: - float volume_; - std::map musics_; - - static Player * instance_; -}; - - -class Timer; - -// 定时任务 -class Task : - public Ref -{ - friend class Timer; - -public: - explicit Task( - const Function& func, /* 执行函数 */ - const String& name = L"" /* 任务名称 */ - ); - - explicit Task( - const Function& func, /* 执行函数 */ - float delay, /* 时间间隔(秒) */ - int times = -1, /* 执行次数(设 -1 为永久执行) */ - const String& name = L"" /* 任务名称 */ - ); - - // 启动任务 - void Start(); - - // 停止任务 - void Stop(); - - // 任务是否正在执行 - bool IsRunning() const; - - // 获取任务名称 - const String& GetName() const; - -protected: - // 执行任务 - void Update(); - - // 任务是否就绪 - bool IsReady() const; - -protected: - bool running_; - bool stopped_; - int run_times_; - int total_times_; - String name_; - Duration delay_; - Time last_time_; - Function callback_; -}; - - -// 定时器 -class Timer -{ -public: - // 获取定时器实例 - static Timer * GetInstance(); - - // 添加任务 - void AddTask( - Task * task - ); - - // 启动任务 - void StartTasks( - const String& task_name - ); - - // 停止任务 - void StopTasks( - const String& task_name - ); - - // 移除任务 - void RemoveTasks( - const String& task_name - ); - - // 启动所有任务 - void StartAllTasks(); - - // 停止所有任务 - void StopAllTasks(); - - // 移除所有任务 - void RemoveAllTasks(); - - // 更新定时器 - void Update(); - - // 刷新所有任务计时 - void UpdateTime(); - -private: - Timer(); - - ~Timer(); - - E2D_DISABLE_COPY(Timer); - -private: - std::vector tasks_; -}; - - -// 数据管理工具 -class Data -{ -public: - Data( - const String& key, /* 键值 */ - const String& field = L"Defalut" /* 字段名称 */ - ); - - // 该数据是否存在 - bool Exists() const; - - // 保存 int 类型的值 - bool SaveInt( - int value - ); - - // 保存 float 类型的值 - bool SaveFloat( - float value - ); - - // 保存 double 类型的值 - bool SaveDouble( - double value - ); - - // 保存 bool 类型的值 - bool SaveBool( - bool value - ); - - // 保存 String 类型的值 - bool SaveString( - const String& value - ); - - // 获取 int 类型的值 - int GetInt() const; - - // 获取 float 类型的值 - float GetFloat() const; - - // 获取 double 类型的值 - double GetDouble() const; - - // 获取 bool 类型的值 - bool GetBool() const; - - // 获取 字符串 类型的值 - String GetString(); - -protected: - String key_; - String field_; - const String& data_path_; -}; - - -// 文件 -class File -{ -public: - File(); - - File( - const String& file_name - ); - - virtual ~File(); - - // 打开文件 - bool Open( - const String& file_name - ); - - // 文件或文件夹是否存在 - bool Exists() const; - - // 是否是文件夹 - bool IsFolder() const; - - // 删除文件 - bool Delete(); - - // 获取文件路径 - const String& GetPath() const; - - // 获取文件扩展名 - String GetExtension() const; - - // 释放资源到临时文件目录 - static File Extract( - int resource_name, /* 资源名称 */ - const String& resource_type, /* 资源类型 */ - const String& dest_file_name /* 目标文件名 */ - ); - - // 添加文件搜索路径 - static void AddSearchPath( - const String& path - ); - - // 创建文件夹 - static bool CreateFolder( - const String& dir_path /* 文件夹路径 */ - ); - - // 弹出打开文件对话框 - static File ShowOpenDialog( - const String& title = L"打开", /* 对话框标题 */ - const String& filter = L"" /* 筛选扩展名,例如 "*.jpg;*.jpeg" */ - ); - - // 弹出保存文件对话框 - static File ShowSaveDialog( - const String& title = L"保存", /* 对话框标题 */ - const String& def_file = L"", /* 默认保存的文件名 */ - const String& def_ext = L"" /* 默认追加的扩展名,例如 "txt" */ - ); - -protected: - DWORD attributes_; - String file_path_; - - static std::list search_paths_; -}; - - -// 路径 -class Path -{ - friend class Game; - -public: - // 获取数据的默认保存路径 - static const String& GetDataPath(); - - // 获取临时文件目录 - static const String& GetTemporaryPath(); - - // 获取 LocalAppData 目录 - static const String& GetLocalAppDataPath(); - - // 获取当前程序的运行路径 - static const String& GetExeFilePath(); -}; - -} \ No newline at end of file +void operator delete( + void* block, + e2d::autorelease_t const& + ) E2D_NOEXCEPT; diff --git a/core/easy2d.h b/core/easy2d.h index e8e07422..79ed3356 100644 --- a/core/easy2d.h +++ b/core/easy2d.h @@ -18,10 +18,11 @@ #include "e2dmacros.h" -#include "e2dcommon.h" -#include "e2dmanager.h" -#include "e2dcomponent.h" #include "e2dutil.h" +#include "e2dmanager.h" +#include "e2dnode.h" +#include "e2dcomponent.h" +#include "e2dtool.h" #include "e2daction.h" #include "e2dtransition.h" #include "e2dmodule.h" diff --git a/project/vs2012/Easy2D.vcxproj b/project/vs2012/Easy2D.vcxproj index e14b93f7..cf7d99bb 100644 --- a/project/vs2012/Easy2D.vcxproj +++ b/project/vs2012/Easy2D.vcxproj @@ -19,17 +19,17 @@ + - - + + + - - + - diff --git a/project/vs2012/Easy2D.vcxproj.filters b/project/vs2012/Easy2D.vcxproj.filters index f4d080ee..be54a26c 100644 --- a/project/vs2012/Easy2D.vcxproj.filters +++ b/project/vs2012/Easy2D.vcxproj.filters @@ -30,17 +30,17 @@ + - - - - - - + + + + + diff --git a/project/vs2013/Easy2D.vcxproj b/project/vs2013/Easy2D.vcxproj index 37dbee4c..035b5b40 100644 --- a/project/vs2013/Easy2D.vcxproj +++ b/project/vs2013/Easy2D.vcxproj @@ -163,17 +163,17 @@ + - - + + + - - + - diff --git a/project/vs2013/Easy2D.vcxproj.filters b/project/vs2013/Easy2D.vcxproj.filters index a4368022..9140abed 100644 --- a/project/vs2013/Easy2D.vcxproj.filters +++ b/project/vs2013/Easy2D.vcxproj.filters @@ -30,17 +30,17 @@ + - - - - - - + + + + + diff --git a/project/vs2017/Easy2D.vcxproj b/project/vs2017/Easy2D.vcxproj index 32434b8d..a55d431d 100644 --- a/project/vs2017/Easy2D.vcxproj +++ b/project/vs2017/Easy2D.vcxproj @@ -236,6 +236,9 @@ + + + @@ -244,11 +247,8 @@ - - - @@ -267,16 +267,17 @@ - - - + + + + + + - - - + diff --git a/project/vs2017/Easy2D.vcxproj.filters b/project/vs2017/Easy2D.vcxproj.filters index 56ca3c6b..4b7c3c07 100644 --- a/project/vs2017/Easy2D.vcxproj.filters +++ b/project/vs2017/Easy2D.vcxproj.filters @@ -28,6 +28,9 @@ {6c9657de-02d5-4d3b-9e1d-bc921eb5aea3} + + {7ffdcb87-b6a2-4815-be96-5598f74155ee} + @@ -39,12 +42,6 @@ Common - - Node - - - Node - Node @@ -174,9 +171,6 @@ Action - - Node - Common @@ -237,18 +231,28 @@ Action + + Component + + + Component + + + Component + - - + + + \ No newline at end of file