From 83462faad0fc21a74adf6a7ab027e5b0c6b51f84 Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Thu, 6 Sep 2018 23:26:32 +0800 Subject: [PATCH] Refactoring : filters --- core/Event/Collision.cpp | 2 +- core/Manager/CollisionManager.cpp | 2 +- core/Node/Scene.cpp | 42 -- core/{Action => actions}/Action.cpp | 0 core/{Action => actions}/Animate.cpp | 2 +- core/{Action => actions}/Animation.cpp | 0 core/{Action => actions}/Callback.cpp | 0 core/{Action => actions}/Delay.cpp | 0 core/{Action => actions}/FadeIn.cpp | 0 core/{Action => actions}/FadeOut.cpp | 0 core/{Action => actions}/FiniteTimeAction.cpp | 0 core/{Action => actions}/JumpBy.cpp | 2 +- core/{Action => actions}/JumpTo.cpp | 2 +- core/{Action => actions}/Loop.cpp | 0 core/{Action => actions}/MoveBy.cpp | 2 +- core/{Action => actions}/MoveTo.cpp | 2 +- core/{Action => actions}/OpacityBy.cpp | 2 +- core/{Action => actions}/OpacityTo.cpp | 2 +- core/{Action => actions}/RotateBy.cpp | 2 +- core/{Action => actions}/RotateTo.cpp | 2 +- core/{Action => actions}/ScaleBy.cpp | 2 +- core/{Action => actions}/ScaleTo.cpp | 2 +- core/{Action => actions}/Sequence.cpp | 0 core/{Action => actions}/Spawn.cpp | 0 core/{Component => components}/Button.cpp | 0 core/{Component => components}/Menu.cpp | 0 .../ToggleButton.cpp | 0 core/e2dcomponent.h | 2 +- core/e2devent.h | 31 +- core/e2dmanager.h | 6 +- core/e2dmodule.h | 2 +- core/{e2dnode.h => e2dobject.h} | 352 +++++++++++-- core/e2dtool.h | 13 +- core/e2dutil.h | 204 -------- core/easy2d.h | 2 +- core/{Custom => impl}/Exception.cpp | 0 core/{Custom => impl}/SystemException.cpp | 0 core/{Custom => impl}/TextRenderer.cpp | 0 core/{Custom => impl}/VoiceCallback.cpp | 0 core/{Base => modules}/Audio.cpp | 0 core/{Base => modules}/GC.cpp | 0 core/{Base => modules}/Game.cpp | 6 +- core/{Base => modules}/Input.cpp | 0 core/{Base => modules}/Renderer.cpp | 2 +- core/{Base => modules}/Window.cpp | 2 +- core/{Node => objects}/Canvas.cpp | 2 +- core/{Common => objects}/Collider.cpp | 2 +- core/{Common => objects}/Image.cpp | 2 +- core/{Node => objects}/Node.cpp | 2 +- core/{Common/Ref.cpp => objects/Object.cpp} | 2 +- core/objects/Scene.cpp | 100 ++++ core/{Node => objects}/Sprite.cpp | 2 +- core/{Node => objects}/Text.cpp | 2 +- core/{Tool => tools}/Data.cpp | 0 core/{Tool => tools}/File.cpp | 0 core/{Tool => tools}/Music.cpp | 22 +- core/{Tool => tools}/Path.cpp | 0 core/{Tool => tools}/Player.cpp | 0 core/{Tool => tools}/Random.cpp | 0 core/{Tool => tools}/Task.cpp | 0 core/{Tool => tools}/Timer.cpp | 0 .../BoxTransition.cpp | 2 +- .../EmergeTransition.cpp | 2 +- .../FadeTransition.cpp | 2 +- .../MoveTransition.cpp | 26 +- .../Transition.cpp | 14 +- core/{Common => utils}/Color.cpp | 0 core/{Common => utils}/Duration.cpp | 0 core/{Common => utils}/Font.cpp | 0 core/{Common => utils}/Function.cpp | 0 core/{Common => utils}/Point.cpp | 0 core/{Common => utils}/Rect.cpp | 0 core/{Common => utils}/Resource.cpp | 0 core/{Common => utils}/Size.cpp | 0 core/{Common => utils}/String.cpp | 0 core/{Common => utils}/Time.cpp | 0 project/vs2012/Easy2D.vcxproj | 144 +++--- project/vs2012/Easy2D.vcxproj.filters | 315 ++++++------ project/vs2013/Easy2D.vcxproj | 144 +++--- project/vs2013/Easy2D.vcxproj.filters | 315 ++++++------ project/vs2017/Easy2D.vcxproj | 140 +++--- project/vs2017/Easy2D.vcxproj.filters | 468 +++++++++--------- 82 files changed, 1260 insertions(+), 1138 deletions(-) delete mode 100644 core/Node/Scene.cpp rename core/{Action => actions}/Action.cpp (100%) rename core/{Action => actions}/Animate.cpp (98%) rename core/{Action => actions}/Animation.cpp (100%) rename core/{Action => actions}/Callback.cpp (100%) rename core/{Action => actions}/Delay.cpp (100%) rename core/{Action => actions}/FadeIn.cpp (100%) rename core/{Action => actions}/FadeOut.cpp (100%) rename core/{Action => actions}/FiniteTimeAction.cpp (100%) rename core/{Action => actions}/JumpBy.cpp (97%) rename core/{Action => actions}/JumpTo.cpp (93%) rename core/{Action => actions}/Loop.cpp (100%) rename core/{Action => actions}/MoveBy.cpp (96%) rename core/{Action => actions}/MoveTo.cpp (92%) rename core/{Action => actions}/OpacityBy.cpp (96%) rename core/{Action => actions}/OpacityTo.cpp (92%) rename core/{Action => actions}/RotateBy.cpp (96%) rename core/{Action => actions}/RotateTo.cpp (92%) rename core/{Action => actions}/ScaleBy.cpp (97%) rename core/{Action => actions}/ScaleTo.cpp (95%) rename core/{Action => actions}/Sequence.cpp (100%) rename core/{Action => actions}/Spawn.cpp (100%) rename core/{Component => components}/Button.cpp (100%) rename core/{Component => components}/Menu.cpp (100%) rename core/{Component => components}/ToggleButton.cpp (100%) rename core/{e2dnode.h => e2dobject.h} (78%) rename core/{Custom => impl}/Exception.cpp (100%) rename core/{Custom => impl}/SystemException.cpp (100%) rename core/{Custom => impl}/TextRenderer.cpp (100%) rename core/{Custom => impl}/VoiceCallback.cpp (100%) rename core/{Base => modules}/Audio.cpp (100%) rename core/{Base => modules}/GC.cpp (100%) rename core/{Base => modules}/Game.cpp (97%) rename core/{Base => modules}/Input.cpp (100%) rename core/{Base => modules}/Renderer.cpp (99%) rename core/{Base => modules}/Window.cpp (99%) rename core/{Node => objects}/Canvas.cpp (99%) rename core/{Common => objects}/Collider.cpp (99%) rename core/{Common => objects}/Image.cpp (99%) rename core/{Node => objects}/Node.cpp (99%) rename core/{Common/Ref.cpp => objects/Object.cpp} (88%) create mode 100644 core/objects/Scene.cpp rename core/{Node => objects}/Sprite.cpp (98%) rename core/{Node => objects}/Text.cpp (99%) rename core/{Tool => tools}/Data.cpp (100%) rename core/{Tool => tools}/File.cpp (100%) rename core/{Tool => tools}/Music.cpp (96%) rename core/{Tool => tools}/Path.cpp (100%) rename core/{Tool => tools}/Player.cpp (100%) rename core/{Tool => tools}/Random.cpp (100%) rename core/{Tool => tools}/Task.cpp (100%) rename core/{Tool => tools}/Timer.cpp (100%) rename core/{Transition => transitions}/BoxTransition.cpp (97%) rename core/{Transition => transitions}/EmergeTransition.cpp (95%) rename core/{Transition => transitions}/FadeTransition.cpp (96%) rename core/{Transition => transitions}/MoveTransition.cpp (66%) rename core/{Transition => transitions}/Transition.cpp (91%) rename core/{Common => utils}/Color.cpp (100%) rename core/{Common => utils}/Duration.cpp (100%) rename core/{Common => utils}/Font.cpp (100%) rename core/{Common => utils}/Function.cpp (100%) rename core/{Common => utils}/Point.cpp (100%) rename core/{Common => utils}/Rect.cpp (100%) rename core/{Common => utils}/Resource.cpp (100%) rename core/{Common => utils}/Size.cpp (100%) rename core/{Common => utils}/String.cpp (100%) rename core/{Common => utils}/Time.cpp (100%) diff --git a/core/Event/Collision.cpp b/core/Event/Collision.cpp index db4a9fb7..f008cb71 100644 --- a/core/Event/Collision.cpp +++ b/core/Event/Collision.cpp @@ -1,4 +1,4 @@ -#include "..\e2devent.h" +#include "..\e2dobject.h" e2d::Collision::Collision() : node_(nullptr) diff --git a/core/Manager/CollisionManager.cpp b/core/Manager/CollisionManager.cpp index ef28ce62..3ad3ea20 100644 --- a/core/Manager/CollisionManager.cpp +++ b/core/Manager/CollisionManager.cpp @@ -1,5 +1,5 @@ #include "..\e2dmanager.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include "..\e2dtool.h" #include "..\e2dmodule.h" diff --git a/core/Node/Scene.cpp b/core/Node/Scene.cpp deleted file mode 100644 index 3d25f261..00000000 --- a/core/Node/Scene.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "..\e2dmodule.h" -#include "..\e2dnode.h" -#include "..\e2dmanager.h" - -e2d::Scene::Scene() - : border_visible_(false) - , collider_visible_(false) -{ - parent_scene_ = this; -} - -e2d::Scene::~Scene() -{ -} - -void e2d::Scene::ShowBorder(bool visible) -{ - border_visible_ = visible; -} - -void e2d::Scene::ShowCollider(bool visible) -{ - collider_visible_ = visible; -} - -void e2d::Scene::Visit() -{ - Node::Visit(); - - if (border_visible_) - { - Renderer::GetInstance()->GetRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity()); - Renderer::GetInstance()->GetSolidBrush()->SetOpacity(1.f); - this->DrawBorder(); - } - - if (collider_visible_) - { - Renderer::GetInstance()->GetRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity()); - this->DrawCollider(); - } -} diff --git a/core/Action/Action.cpp b/core/actions/Action.cpp similarity index 100% rename from core/Action/Action.cpp rename to core/actions/Action.cpp diff --git a/core/Action/Animate.cpp b/core/actions/Animate.cpp similarity index 98% rename from core/Action/Animate.cpp rename to core/actions/Animate.cpp index 35d613ca..c8882a5e 100644 --- a/core/Action/Animate.cpp +++ b/core/actions/Animate.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::Animate::Animate() : frame_index_(0) diff --git a/core/Action/Animation.cpp b/core/actions/Animation.cpp similarity index 100% rename from core/Action/Animation.cpp rename to core/actions/Animation.cpp diff --git a/core/Action/Callback.cpp b/core/actions/Callback.cpp similarity index 100% rename from core/Action/Callback.cpp rename to core/actions/Callback.cpp diff --git a/core/Action/Delay.cpp b/core/actions/Delay.cpp similarity index 100% rename from core/Action/Delay.cpp rename to core/actions/Delay.cpp diff --git a/core/Action/FadeIn.cpp b/core/actions/FadeIn.cpp similarity index 100% rename from core/Action/FadeIn.cpp rename to core/actions/FadeIn.cpp diff --git a/core/Action/FadeOut.cpp b/core/actions/FadeOut.cpp similarity index 100% rename from core/Action/FadeOut.cpp rename to core/actions/FadeOut.cpp diff --git a/core/Action/FiniteTimeAction.cpp b/core/actions/FiniteTimeAction.cpp similarity index 100% rename from core/Action/FiniteTimeAction.cpp rename to core/actions/FiniteTimeAction.cpp diff --git a/core/Action/JumpBy.cpp b/core/actions/JumpBy.cpp similarity index 97% rename from core/Action/JumpBy.cpp rename to core/actions/JumpBy.cpp index dd373f51..1c1be6a3 100644 --- a/core/Action/JumpBy.cpp +++ b/core/actions/JumpBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::JumpBy::JumpBy(float duration, const Point & vec, float height, int jumps) : FiniteTimeAction(duration) diff --git a/core/Action/JumpTo.cpp b/core/actions/JumpTo.cpp similarity index 93% rename from core/Action/JumpTo.cpp rename to core/actions/JumpTo.cpp index ebe1968e..9ab39d5e 100644 --- a/core/Action/JumpTo.cpp +++ b/core/actions/JumpTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::JumpTo::JumpTo(float duration, const Point & pos, float height, int jumps) : JumpBy(duration, Point(), height, jumps) diff --git a/core/Action/Loop.cpp b/core/actions/Loop.cpp similarity index 100% rename from core/Action/Loop.cpp rename to core/actions/Loop.cpp diff --git a/core/Action/MoveBy.cpp b/core/actions/MoveBy.cpp similarity index 96% rename from core/Action/MoveBy.cpp rename to core/actions/MoveBy.cpp index 7c819e94..83290e36 100644 --- a/core/Action/MoveBy.cpp +++ b/core/actions/MoveBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::MoveBy::MoveBy(float duration, Point vector) diff --git a/core/Action/MoveTo.cpp b/core/actions/MoveTo.cpp similarity index 92% rename from core/Action/MoveTo.cpp rename to core/actions/MoveTo.cpp index 001ac250..df682f44 100644 --- a/core/Action/MoveTo.cpp +++ b/core/actions/MoveTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::MoveTo::MoveTo(float duration, Point pos) : MoveBy(duration, Point()) diff --git a/core/Action/OpacityBy.cpp b/core/actions/OpacityBy.cpp similarity index 96% rename from core/Action/OpacityBy.cpp rename to core/actions/OpacityBy.cpp index 5bdc36a2..84e12e5e 100644 --- a/core/Action/OpacityBy.cpp +++ b/core/actions/OpacityBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::OpacityBy::OpacityBy(float duration, float opacity) diff --git a/core/Action/OpacityTo.cpp b/core/actions/OpacityTo.cpp similarity index 92% rename from core/Action/OpacityTo.cpp rename to core/actions/OpacityTo.cpp index e55b1299..3717f3f9 100644 --- a/core/Action/OpacityTo.cpp +++ b/core/actions/OpacityTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::OpacityTo::OpacityTo(float duration, float opacity) diff --git a/core/Action/RotateBy.cpp b/core/actions/RotateBy.cpp similarity index 96% rename from core/Action/RotateBy.cpp rename to core/actions/RotateBy.cpp index 71ae1f33..c4024c28 100644 --- a/core/Action/RotateBy.cpp +++ b/core/actions/RotateBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::RotateBy::RotateBy(float duration, float rotation) diff --git a/core/Action/RotateTo.cpp b/core/actions/RotateTo.cpp similarity index 92% rename from core/Action/RotateTo.cpp rename to core/actions/RotateTo.cpp index 18b64e50..08fa4a6e 100644 --- a/core/Action/RotateTo.cpp +++ b/core/actions/RotateTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::RotateTo::RotateTo(float duration, float rotation) diff --git a/core/Action/ScaleBy.cpp b/core/actions/ScaleBy.cpp similarity index 97% rename from core/Action/ScaleBy.cpp rename to core/actions/ScaleBy.cpp index b03a8f53..3ec7504b 100644 --- a/core/Action/ScaleBy.cpp +++ b/core/actions/ScaleBy.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::ScaleBy::ScaleBy(float duration, float scale) diff --git a/core/Action/ScaleTo.cpp b/core/actions/ScaleTo.cpp similarity index 95% rename from core/Action/ScaleTo.cpp rename to core/actions/ScaleTo.cpp index 0855e660..95fc3276 100644 --- a/core/Action/ScaleTo.cpp +++ b/core/actions/ScaleTo.cpp @@ -1,5 +1,5 @@ #include "..\e2daction.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::ScaleTo::ScaleTo(float duration, float scale) : ScaleBy(duration, 0, 0) diff --git a/core/Action/Sequence.cpp b/core/actions/Sequence.cpp similarity index 100% rename from core/Action/Sequence.cpp rename to core/actions/Sequence.cpp diff --git a/core/Action/Spawn.cpp b/core/actions/Spawn.cpp similarity index 100% rename from core/Action/Spawn.cpp rename to core/actions/Spawn.cpp diff --git a/core/Component/Button.cpp b/core/components/Button.cpp similarity index 100% rename from core/Component/Button.cpp rename to core/components/Button.cpp diff --git a/core/Component/Menu.cpp b/core/components/Menu.cpp similarity index 100% rename from core/Component/Menu.cpp rename to core/components/Menu.cpp diff --git a/core/Component/ToggleButton.cpp b/core/components/ToggleButton.cpp similarity index 100% rename from core/Component/ToggleButton.cpp rename to core/components/ToggleButton.cpp diff --git a/core/e2dcomponent.h b/core/e2dcomponent.h index 4c190317..6da97657 100644 --- a/core/e2dcomponent.h +++ b/core/e2dcomponent.h @@ -1,5 +1,5 @@ #pragma once -#include "e2dnode.h" +#include "e2dobject.h" namespace e2d { diff --git a/core/e2devent.h b/core/e2devent.h index 8f5f4b77..da26f2aa 100644 --- a/core/e2devent.h +++ b/core/e2devent.h @@ -112,28 +112,21 @@ namespace e2d }; - // Åöײʼþ - class Collision + // ʼþ½ÓÊÕÄ¿±ê + class EventTarget { public: - Collision(); + // ·Ö·¢Êó±êÏûÏ¢ + virtual bool Dispatch( + const MouseEvent& e, + bool handled + ) = 0; - explicit Collision( - Node* node, - Collider::Relation relation - ); - - ~Collision(); - - // »ñÈ¡·¢ÉúÅöײ½Úµã - Node* GetNode() const; - - // »ñÈ¡½»¼¯¹ØÏµ - Collider::Relation GetRelation() const; - - protected: - Node * node_; - Collider::Relation relation_; + // ·Ö·¢°´¼üÏûÏ¢ + virtual bool Dispatch( + const KeyEvent& e, + bool handled + ) = 0; }; } \ No newline at end of file diff --git a/core/e2dmanager.h b/core/e2dmanager.h index 03959855..7ffead55 100644 --- a/core/e2dmanager.h +++ b/core/e2dmanager.h @@ -1,14 +1,10 @@ #pragma once -#include "e2dmacros.h" -#include "e2dutil.h" +#include "e2dobject.h" namespace e2d { - class Node; - - // ÅöײÌå¹ÜÀíÆ÷ class CollisionManager { diff --git a/core/e2dmodule.h b/core/e2dmodule.h index 5400a9fd..b8fc205f 100644 --- a/core/e2dmodule.h +++ b/core/e2dmodule.h @@ -1,6 +1,6 @@ #pragma once #include "e2dimpl.h" -#include "e2dnode.h" +#include "e2dobject.h" #include "e2dtransition.h" diff --git a/core/e2dnode.h b/core/e2dobject.h similarity index 78% rename from core/e2dnode.h rename to core/e2dobject.h index 4180f668..17c95cdf 100644 --- a/core/e2dnode.h +++ b/core/e2dobject.h @@ -2,12 +2,307 @@ #include "e2dutil.h" #include "e2devent.h" + namespace e2d { - class Action; - class Scene; + // ͼƬ + 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_; + }; + + + class Node; + + // ³¡¾° + class Scene : + public Ref, + public EventTarget + { + public: + Scene(); + + explicit Scene( + Node * root + ); + + virtual ~Scene(); + + // ½øÈ볡¾° + virtual void OnEnter() {} + + // Í˳ö³¡¾° + virtual void OnExit() {} + + // ¹Ø±Õ´°¿Ú + // ˵Ã÷£º·µ»Ø false ½«×èÖ¹´°¿Ú¹Ø±Õ + virtual bool OnCloseWindow() { return true; } + + // ÉèÖøù½Úµã + void SetRoot( + Node * root + ); + + // »ñÈ¡¸ù½Úµã + Node* GetRoot() const; + + // ÏÔʾ»òÒþ²Ø½Úµã±ßÔµ + // ĬÈÏ£ºÒþ²Ø + void ShowBorder( + bool visible + ); + + // ÏÔʾ»òÒþ²ØÅöײÌå + // ĬÈÏ£ºÒþ²Ø + void ShowCollider( + bool visible + ); + + // äÖȾ³¡¾° + void Draw(); + + // ·Ö·¢Êó±êÏûÏ¢ + virtual bool Dispatch( + const MouseEvent& e, + bool handled + ) override; + + // ·Ö·¢°´¼üÏûÏ¢ + virtual bool Dispatch( + const KeyEvent& e, + bool handled + ) override; + + protected: + E2D_DISABLE_COPY(Scene); + + protected: + Node * root_; + bool border_visible_; + bool collider_visible_; + }; + + + // ÅöײÌå + 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 Collision + { + public: + Collision(); + + explicit Collision( + Node* node, + Collider::Relation relation + ); + + ~Collision(); + + // »ñÈ¡·¢ÉúÅöײ½Úµã + Node* GetNode() const; + + // »ñÈ¡½»¼¯¹ØÏµ + Collider::Relation GetRelation() const; + + protected: + Node * node_; + Collider::Relation relation_; + }; // »æÍ¼½Ó¿Ú @@ -55,10 +350,14 @@ namespace e2d }; + class Action; + // ½Úµã class Node : - public Ref + public Ref, + public EventTarget { + friend class Scene; friend class Collider; public: @@ -421,13 +720,13 @@ namespace e2d virtual bool Dispatch( const MouseEvent& e, bool handled - ); + ) override; // ·Ö·¢°´¼üÏûÏ¢ virtual bool Dispatch( const KeyEvent& e, bool handled - ); + ) override; // ±éÀú½Úµã virtual void Visit(); @@ -488,49 +787,6 @@ namespace e2d }; - // ³¡¾° - 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, diff --git a/core/e2dtool.h b/core/e2dtool.h index fd4c7059..67fc5074 100644 --- a/core/e2dtool.h +++ b/core/e2dtool.h @@ -50,11 +50,8 @@ namespace e2d // ÒôÀÖ - class Music : - public Ref + class Music { - friend class VoiceCallback; - public: Music(); @@ -117,16 +114,16 @@ namespace e2d IXAudio2SourceVoice * GetSourceVoice() const; protected: - bool _readMMIO(); + bool ReadMMIO(); - bool _resetFile(); + bool ResetFile(); - bool _read( + bool Read( BYTE* buffer, DWORD size_to_read ); - bool _findMediaFileCch( + bool FindMediaFileCch( wchar_t* dest_path, int cch_dest, const wchar_t * file_name diff --git a/core/e2dutil.h b/core/e2dutil.h index e6541125..3997c045 100644 --- a/core/e2dutil.h +++ b/core/e2dutil.h @@ -586,109 +586,6 @@ namespace e2d }; - 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 { @@ -729,107 +626,6 @@ namespace e2d }; - // ͼƬ - 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_; - }; - - } diff --git a/core/easy2d.h b/core/easy2d.h index 79ed3356..ba36c34b 100644 --- a/core/easy2d.h +++ b/core/easy2d.h @@ -20,7 +20,7 @@ #include "e2dmacros.h" #include "e2dutil.h" #include "e2dmanager.h" -#include "e2dnode.h" +#include "e2dobject.h" #include "e2dcomponent.h" #include "e2dtool.h" #include "e2daction.h" diff --git a/core/Custom/Exception.cpp b/core/impl/Exception.cpp similarity index 100% rename from core/Custom/Exception.cpp rename to core/impl/Exception.cpp diff --git a/core/Custom/SystemException.cpp b/core/impl/SystemException.cpp similarity index 100% rename from core/Custom/SystemException.cpp rename to core/impl/SystemException.cpp diff --git a/core/Custom/TextRenderer.cpp b/core/impl/TextRenderer.cpp similarity index 100% rename from core/Custom/TextRenderer.cpp rename to core/impl/TextRenderer.cpp diff --git a/core/Custom/VoiceCallback.cpp b/core/impl/VoiceCallback.cpp similarity index 100% rename from core/Custom/VoiceCallback.cpp rename to core/impl/VoiceCallback.cpp diff --git a/core/Base/Audio.cpp b/core/modules/Audio.cpp similarity index 100% rename from core/Base/Audio.cpp rename to core/modules/Audio.cpp diff --git a/core/Base/GC.cpp b/core/modules/GC.cpp similarity index 100% rename from core/Base/GC.cpp rename to core/modules/GC.cpp diff --git a/core/Base/Game.cpp b/core/modules/Game.cpp similarity index 97% rename from core/Base/Game.cpp rename to core/modules/Game.cpp index 0edc169c..fa56b27e 100644 --- a/core/Base/Game.cpp +++ b/core/modules/Game.cpp @@ -1,5 +1,5 @@ #include "..\e2dmodule.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include "..\e2dtransition.h" #include "..\e2dmanager.h" #include "..\e2dtool.h" @@ -102,7 +102,7 @@ void e2d::Game::Resume() { Timer::GetInstance()->UpdateTime(); if (curr_scene_) - curr_scene_->UpdateActionsTime(); + curr_scene_->GetRoot()->UpdateActionsTime(); } paused_ = false; } @@ -204,7 +204,7 @@ void e2d::Game::DrawScene() } else if (curr_scene_) { - curr_scene_->Visit(); + curr_scene_->Draw(); } } Renderer::GetInstance()->EndDraw(); diff --git a/core/Base/Input.cpp b/core/modules/Input.cpp similarity index 100% rename from core/Base/Input.cpp rename to core/modules/Input.cpp diff --git a/core/Base/Renderer.cpp b/core/modules/Renderer.cpp similarity index 99% rename from core/Base/Renderer.cpp rename to core/modules/Renderer.cpp index 3aa412d7..2d1f1816 100644 --- a/core/Base/Renderer.cpp +++ b/core/modules/Renderer.cpp @@ -1,6 +1,6 @@ #include "..\e2dmodule.h" #include "..\e2dmanager.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::Renderer* e2d::Renderer::instance_ = nullptr; diff --git a/core/Base/Window.cpp b/core/modules/Window.cpp similarity index 99% rename from core/Base/Window.cpp rename to core/modules/Window.cpp index eb3fd256..71d32ef0 100644 --- a/core/Base/Window.cpp +++ b/core/modules/Window.cpp @@ -1,6 +1,6 @@ #include "..\e2dmodule.h" #include "..\e2dmanager.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include #pragma comment (lib ,"imm32.lib") diff --git a/core/Node/Canvas.cpp b/core/objects/Canvas.cpp similarity index 99% rename from core/Node/Canvas.cpp rename to core/objects/Canvas.cpp index 11f3aa00..adbfa13d 100644 --- a/core/Node/Canvas.cpp +++ b/core/objects/Canvas.cpp @@ -1,4 +1,4 @@ -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include "..\e2dmodule.h" e2d::Canvas::Canvas(float width, float height) diff --git a/core/Common/Collider.cpp b/core/objects/Collider.cpp similarity index 99% rename from core/Common/Collider.cpp rename to core/objects/Collider.cpp index 038f0b6a..047f50e6 100644 --- a/core/Common/Collider.cpp +++ b/core/objects/Collider.cpp @@ -2,7 +2,7 @@ #include "..\e2dimpl.h" #include "..\e2dmodule.h" #include "..\e2dmanager.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::Collider::Collider(Node * parent) : visible_(true) diff --git a/core/Common/Image.cpp b/core/objects/Image.cpp similarity index 99% rename from core/Common/Image.cpp rename to core/objects/Image.cpp index f6b1873b..c8d73831 100644 --- a/core/Common/Image.cpp +++ b/core/objects/Image.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dobject.h" #include "..\e2dmodule.h" #include "..\e2dtool.h" diff --git a/core/Node/Node.cpp b/core/objects/Node.cpp similarity index 99% rename from core/Node/Node.cpp rename to core/objects/Node.cpp index 8fd05b19..11265954 100644 --- a/core/Node/Node.cpp +++ b/core/objects/Node.cpp @@ -1,4 +1,4 @@ -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include "..\e2devent.h" #include "..\e2dmanager.h" #include "..\e2daction.h" diff --git a/core/Common/Ref.cpp b/core/objects/Object.cpp similarity index 88% rename from core/Common/Ref.cpp rename to core/objects/Object.cpp index 71dbad35..bcbefc3b 100644 --- a/core/Common/Ref.cpp +++ b/core/objects/Object.cpp @@ -1,4 +1,4 @@ -#include "..\e2dutil.h" +#include "..\e2dobject.h" e2d::Ref::Ref() : ref_count_(0) diff --git a/core/objects/Scene.cpp b/core/objects/Scene.cpp new file mode 100644 index 00000000..adc0b9ba --- /dev/null +++ b/core/objects/Scene.cpp @@ -0,0 +1,100 @@ +#include "..\e2dmodule.h" +#include "..\e2dobject.h" + +e2d::Scene::Scene() + : root_(nullptr) + , border_visible_(false) + , collider_visible_(false) +{ +} + +e2d::Scene::Scene(Node * root) + : root_(nullptr) + , border_visible_(false) + , collider_visible_(false) +{ + this->SetRoot(root); +} + +e2d::Scene::~Scene() +{ + if (root_) + { + root_->Release(); + root_->SetParentScene(nullptr); + } +} + +void e2d::Scene::SetRoot(Node * root) +{ + if (root_ == root) + return; + + if (root_) + { + root_->Release(); + root_->SetParentScene(nullptr); + } + + if (root) + { + root->Retain(); + root->SetParentScene(this); + } + + root_ = root; +} + +e2d::Node * e2d::Scene::GetRoot() const +{ + return root_; +} + +void e2d::Scene::ShowBorder(bool visible) +{ + border_visible_ = visible; +} + +void e2d::Scene::ShowCollider(bool visible) +{ + collider_visible_ = visible; +} + +void e2d::Scene::Draw() +{ + if (root_) + { + root_->Visit(); + + if (border_visible_) + { + Renderer::GetInstance()->GetRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity()); + Renderer::GetInstance()->GetSolidBrush()->SetOpacity(1.f); + root_->DrawBorder(); + } + + if (collider_visible_) + { + Renderer::GetInstance()->GetRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity()); + root_->DrawCollider(); + } + } +} + +bool e2d::Scene::Dispatch(const MouseEvent & e, bool handled) +{ + if (root_) + { + return root_->Dispatch(e, handled); + } + return false; +} + +bool e2d::Scene::Dispatch(const KeyEvent & e, bool handled) +{ + if (root_) + { + return root_->Dispatch(e, handled); + } + return false; +} diff --git a/core/Node/Sprite.cpp b/core/objects/Sprite.cpp similarity index 98% rename from core/Node/Sprite.cpp rename to core/objects/Sprite.cpp index 9ca252fe..95dd5268 100644 --- a/core/Node/Sprite.cpp +++ b/core/objects/Sprite.cpp @@ -1,4 +1,4 @@ -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include "..\e2dmodule.h" e2d::Sprite::Sprite() diff --git a/core/Node/Text.cpp b/core/objects/Text.cpp similarity index 99% rename from core/Node/Text.cpp rename to core/objects/Text.cpp index eca30375..bf7e3505 100644 --- a/core/Node/Text.cpp +++ b/core/objects/Text.cpp @@ -1,4 +1,4 @@ -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include "..\e2dmodule.h" //------------------------------------------------------- diff --git a/core/Tool/Data.cpp b/core/tools/Data.cpp similarity index 100% rename from core/Tool/Data.cpp rename to core/tools/Data.cpp diff --git a/core/Tool/File.cpp b/core/tools/File.cpp similarity index 100% rename from core/Tool/File.cpp rename to core/tools/File.cpp diff --git a/core/Tool/Music.cpp b/core/tools/Music.cpp similarity index 96% rename from core/Tool/Music.cpp rename to core/tools/Music.cpp index d6f24b38..fec1273a 100644 --- a/core/Tool/Music.cpp +++ b/core/tools/Music.cpp @@ -88,7 +88,7 @@ bool e2d::Music::Open(const e2d::String & file_path) // ¶¨Î» wave Îļþ wchar_t pFilePath[MAX_PATH]; - if (!_findMediaFileCch(pFilePath, MAX_PATH, (const wchar_t *)actualFilePath)) + if (!FindMediaFileCch(pFilePath, MAX_PATH, (const wchar_t *)actualFilePath)) { WARN("Failed to Find media file: %s", pFilePath); return false; @@ -101,14 +101,14 @@ bool e2d::Music::Open(const e2d::String & file_path) return TraceError(L"mmioOpen"); } - if (!_readMMIO()) + if (!ReadMMIO()) { // ¶ÁÈ¡·Ç wave Îļþʱ ReadMMIO µ÷ÓÃʧ°Ü mmioClose(hmmio_, 0); return TraceError(L"ReadMMIO"); } - if (!_resetFile()) + if (!ResetFile()) return TraceError(L"ResetFile"); // ÖØÖÃÎļþºó£¬wave ÎļþµÄ´óСÊÇ ck_.cksize @@ -117,7 +117,7 @@ bool e2d::Music::Open(const e2d::String & file_path) // ½«Ñù±¾Êý¾Ý¶ÁÈ¡µ½ÄÚ´æÖÐ wave_data_ = new BYTE[size_]; - if (!_read(wave_data_, size_)) + if (!Read(wave_data_, size_)) { TraceError(L"Failed to read WAV data"); SAFE_DELETE_ARRAY(wave_data_); @@ -179,14 +179,14 @@ bool e2d::Music::Open(const Resource& res) return TraceError(L"mmioOpen"); } - if (!_readMMIO()) + if (!ReadMMIO()) { // ¶ÁÈ¡·Ç wave Îļþʱ ReadMMIO µ÷ÓÃʧ°Ü mmioClose(hmmio_, 0); return TraceError(L"ReadMMIO"); } - if (!_resetFile()) + if (!ResetFile()) return TraceError(L"ResetFile"); // ÖØÖÃÎļþºó£¬wave ÎļþµÄ´óСÊÇ ck_.cksize @@ -195,7 +195,7 @@ bool e2d::Music::Open(const Resource& res) // ½«Ñù±¾Êý¾Ý¶ÁÈ¡µ½ÄÚ´æÖÐ wave_data_ = new BYTE[size_]; - if (!_read(wave_data_, size_)) + if (!Read(wave_data_, size_)) { TraceError(L"Failed to read WAV data"); SAFE_DELETE_ARRAY(wave_data_); @@ -349,7 +349,7 @@ void e2d::Music::SetCallbackOnLoopEnd(const Function & func) callback_.SetCallbackOnLoopEnd(func); } -bool e2d::Music::_readMMIO() +bool e2d::Music::ReadMMIO() { MMCKINFO ckIn; PCMWAVEFORMAT pcmWaveFormat; @@ -421,7 +421,7 @@ bool e2d::Music::_readMMIO() return true; } -bool e2d::Music::_resetFile() +bool e2d::Music::ResetFile() { // Seek to the data if (-1 == mmioSeek(hmmio_, ck_riff_.dwDataOffset + sizeof(FOURCC), @@ -436,7 +436,7 @@ bool e2d::Music::_resetFile() return true; } -bool e2d::Music::_read(BYTE* buffer, DWORD size_to_read) +bool e2d::Music::Read(BYTE* buffer, DWORD size_to_read) { MMIOINFO mmioinfoIn; // current status of hmmio_ @@ -472,7 +472,7 @@ bool e2d::Music::_read(BYTE* buffer, DWORD size_to_read) return true; } -bool e2d::Music::_findMediaFileCch(wchar_t* dest_path, int cch_dest, const wchar_t * file_name) +bool e2d::Music::FindMediaFileCch(wchar_t* dest_path, int cch_dest, const wchar_t * file_name) { bool bFound = false; diff --git a/core/Tool/Path.cpp b/core/tools/Path.cpp similarity index 100% rename from core/Tool/Path.cpp rename to core/tools/Path.cpp diff --git a/core/Tool/Player.cpp b/core/tools/Player.cpp similarity index 100% rename from core/Tool/Player.cpp rename to core/tools/Player.cpp diff --git a/core/Tool/Random.cpp b/core/tools/Random.cpp similarity index 100% rename from core/Tool/Random.cpp rename to core/tools/Random.cpp diff --git a/core/Tool/Task.cpp b/core/tools/Task.cpp similarity index 100% rename from core/Tool/Task.cpp rename to core/tools/Task.cpp diff --git a/core/Tool/Timer.cpp b/core/tools/Timer.cpp similarity index 100% rename from core/Tool/Timer.cpp rename to core/tools/Timer.cpp diff --git a/core/Transition/BoxTransition.cpp b/core/transitions/BoxTransition.cpp similarity index 97% rename from core/Transition/BoxTransition.cpp rename to core/transitions/BoxTransition.cpp index cf907cc3..45ea8c43 100644 --- a/core/Transition/BoxTransition.cpp +++ b/core/transitions/BoxTransition.cpp @@ -1,5 +1,5 @@ #include "..\e2dtransition.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include "..\e2dmodule.h" e2d::BoxTransition::BoxTransition(Scene* scene, float duration) diff --git a/core/Transition/EmergeTransition.cpp b/core/transitions/EmergeTransition.cpp similarity index 95% rename from core/Transition/EmergeTransition.cpp rename to core/transitions/EmergeTransition.cpp index 428c03f4..ea8c79e9 100644 --- a/core/Transition/EmergeTransition.cpp +++ b/core/transitions/EmergeTransition.cpp @@ -1,5 +1,5 @@ #include "..\e2dtransition.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::EmergeTransition::EmergeTransition(Scene* scene, float duration) : Transition(scene, duration) diff --git a/core/Transition/FadeTransition.cpp b/core/transitions/FadeTransition.cpp similarity index 96% rename from core/Transition/FadeTransition.cpp rename to core/transitions/FadeTransition.cpp index 50b7d0ff..f506bb6b 100644 --- a/core/Transition/FadeTransition.cpp +++ b/core/transitions/FadeTransition.cpp @@ -1,5 +1,5 @@ #include "..\e2dtransition.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::FadeTransition::FadeTransition(Scene* scene, float duration) : Transition(scene, duration) diff --git a/core/Transition/MoveTransition.cpp b/core/transitions/MoveTransition.cpp similarity index 66% rename from core/Transition/MoveTransition.cpp rename to core/transitions/MoveTransition.cpp index 2c3b9884..71e4e263 100644 --- a/core/Transition/MoveTransition.cpp +++ b/core/transitions/MoveTransition.cpp @@ -1,5 +1,5 @@ #include "..\e2dtransition.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" #include "..\e2dmodule.h" e2d::MoveTransition::MoveTransition(Scene* scene, float duration, Direction direction) @@ -34,8 +34,8 @@ bool e2d::MoveTransition::Init(Game * game, Scene * prev) start_pos_ = Point(-size.width, 0); } - if (out_scene_) out_scene_->SetPos(0, 0); - in_scene_->SetPos(start_pos_); + if (out_scene_ && out_scene_->GetRoot()) out_scene_->GetRoot()->SetPos(0, 0); + if (in_scene_->GetRoot()) in_scene_->GetRoot()->SetPos(start_pos_); return true; } return false; @@ -45,13 +45,14 @@ void e2d::MoveTransition::Update() { Transition::Update(); - if (out_scene_) + if (out_scene_ && out_scene_->GetRoot()) { - out_scene_->SetPos(pos_delta_ * delta_); + out_scene_->GetRoot()->SetPos(pos_delta_ * delta_); } - if (in_scene_) + + if (in_scene_->GetRoot()) { - in_scene_->SetPos(start_pos_ + pos_delta_ * delta_); + in_scene_->GetRoot()->SetPos(start_pos_ + pos_delta_ * delta_); } if (delta_ >= 1) @@ -62,6 +63,13 @@ void e2d::MoveTransition::Update() void e2d::MoveTransition::Reset() { - if (out_scene_) out_scene_->SetPos(0, 0); - in_scene_->SetPos(0, 0); + if (out_scene_ && out_scene_->GetRoot()) + { + out_scene_->GetRoot()->SetPos(0, 0); + } + + if (in_scene_->GetRoot()) + { + in_scene_->GetRoot()->SetPos(0, 0); + } } diff --git a/core/Transition/Transition.cpp b/core/transitions/Transition.cpp similarity index 91% rename from core/Transition/Transition.cpp rename to core/transitions/Transition.cpp index 810eb543..d13f4ed7 100644 --- a/core/Transition/Transition.cpp +++ b/core/transitions/Transition.cpp @@ -1,6 +1,6 @@ #include "..\e2dmodule.h" #include "..\e2dtransition.h" -#include "..\e2dnode.h" +#include "..\e2dobject.h" e2d::Transition::Transition(Scene* scene, float duration) : done_(false) @@ -87,9 +87,9 @@ void e2d::Transition::Draw() auto render_target = Renderer::GetInstance()->GetRenderTarget(); auto size = Window::GetInstance()->GetSize(); - if (out_scene_) + if (out_scene_ && out_scene_->GetRoot()) { - auto rootPos = out_scene_->GetPos(); + auto rootPos = out_scene_->GetRoot()->GetPos(); auto clipRect = D2D1::RectF( std::max(rootPos.x, 0.f), std::max(rootPos.y, 0.f), @@ -100,15 +100,15 @@ void e2d::Transition::Draw() render_target->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); render_target->PushLayer(out_layer_param_, out_layer_); - out_scene_->Visit(); + out_scene_->Draw(); render_target->PopLayer(); render_target->PopAxisAlignedClip(); } - if (in_scene_) + if (in_scene_ && in_scene_->GetRoot()) { - Point rootPos = in_scene_->GetPos(); + Point rootPos = in_scene_->GetRoot()->GetPos(); auto clipRect = D2D1::RectF( std::max(rootPos.x, 0.f), std::max(rootPos.y, 0.f), @@ -119,7 +119,7 @@ void e2d::Transition::Draw() render_target->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); render_target->PushLayer(in_layer_param_, in_layer_); - in_scene_->Visit(); + in_scene_->Draw(); render_target->PopLayer(); render_target->PopAxisAlignedClip(); diff --git a/core/Common/Color.cpp b/core/utils/Color.cpp similarity index 100% rename from core/Common/Color.cpp rename to core/utils/Color.cpp diff --git a/core/Common/Duration.cpp b/core/utils/Duration.cpp similarity index 100% rename from core/Common/Duration.cpp rename to core/utils/Duration.cpp diff --git a/core/Common/Font.cpp b/core/utils/Font.cpp similarity index 100% rename from core/Common/Font.cpp rename to core/utils/Font.cpp diff --git a/core/Common/Function.cpp b/core/utils/Function.cpp similarity index 100% rename from core/Common/Function.cpp rename to core/utils/Function.cpp diff --git a/core/Common/Point.cpp b/core/utils/Point.cpp similarity index 100% rename from core/Common/Point.cpp rename to core/utils/Point.cpp diff --git a/core/Common/Rect.cpp b/core/utils/Rect.cpp similarity index 100% rename from core/Common/Rect.cpp rename to core/utils/Rect.cpp diff --git a/core/Common/Resource.cpp b/core/utils/Resource.cpp similarity index 100% rename from core/Common/Resource.cpp rename to core/utils/Resource.cpp diff --git a/core/Common/Size.cpp b/core/utils/Size.cpp similarity index 100% rename from core/Common/Size.cpp rename to core/utils/Size.cpp diff --git a/core/Common/String.cpp b/core/utils/String.cpp similarity index 100% rename from core/Common/String.cpp rename to core/utils/String.cpp diff --git a/core/Common/Time.cpp b/core/utils/Time.cpp similarity index 100% rename from core/Common/Time.cpp rename to core/utils/Time.cpp diff --git a/project/vs2012/Easy2D.vcxproj b/project/vs2012/Easy2D.vcxproj index bca15888..b40c4c0a 100644 --- a/project/vs2012/Easy2D.vcxproj +++ b/project/vs2012/Easy2D.vcxproj @@ -19,7 +19,78 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -32,77 +103,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {722EA245-ADD5-4296-8C85-8FF42C0335D3} Win32Proj diff --git a/project/vs2012/Easy2D.vcxproj.filters b/project/vs2012/Easy2D.vcxproj.filters index f4018b3c..79dd0cd0 100644 --- a/project/vs2012/Easy2D.vcxproj.filters +++ b/project/vs2012/Easy2D.vcxproj.filters @@ -1,32 +1,35 @@  - - {01311827-b639-4313-a5b6-61cd22fe8920} + + {be5d9314-b00a-4f11-bd2a-1f720dc32407} - - {e5c42dd3-2d56-4a95-8f88-45d059d58c21} + + {261633d3-3814-40c7-bd6d-201ede6c6ade} - - {08126b0c-d139-48f9-8559-3d9d9e3a5940} + + {50293f38-87fe-4dde-b938-cf1b7a2921f8} - - {a8185fe2-5477-4293-97d6-d84f27d354bb} + + {7ffdcb87-b6a2-4815-be96-5598f74155ee} - - {70412fec-4c60-425b-81c9-4547e5a1b78a} + + {3475b59d-d50c-43b1-8334-bcb9e1703ed2} - - {dacd05f1-3496-488b-af4d-b3ea7bce9515} + + {6c9657de-02d5-4d3b-9e1d-bc921eb5aea3} - - {337d5a0f-60fd-473a-83da-b2a3515affd9} + + {9031e36b-fa85-4b4e-8e80-657c7e68f283} - - {8ef0d8e2-1138-40c0-a1a8-0eb681721f4e} + + {563b19f2-4c5e-4362-983a-94d2ae724550} - - {69654184-01f6-4729-9559-802cd79bcb4b} + + {42d46a92-c043-4667-8c20-358319e5c313} + + + {51864c81-02ee-4043-bf09-9ce3cbe5b6da} @@ -39,211 +42,217 @@ - + - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Base + + actions - - Base + + actions - - Base + + actions - - Base + + modules - - Base + + modules - - Common + + modules - - Common + + modules - - Common + + modules - - Common + + modules - - Common + + utils - - Common + + utils - - Common + + utils - - Common + + utils - - Common + + utils - - Common + + utils - - Custom + + utils - - Custom + + utils - - Custom + + utils - - Custom + + utils - - Node + + components - - Node + + components - - Node + + components - - Tool + + impl - - Tool + + impl - - Tool + + impl - - Tool + + impl - - Tool + + event - - Tool + + event - - Tool + + event - - Transition + + manager - - Transition + + tools - - Transition + + tools - - Transition + + tools - - Transition + + tools - - Tool + + tools - - Common + + tools - - Manager + + tools - - Event + + tools - - Event + + transitions - - Event + + transitions - - Node + + transitions - - Node + + transitions - - Base + + transitions - - Action + + objects - - Action + + objects - - Action + + objects - - Component + + objects - - Component + + objects - - Component + + objects + + + objects + + + objects \ No newline at end of file diff --git a/project/vs2013/Easy2D.vcxproj b/project/vs2013/Easy2D.vcxproj index 1401b49c..2ff2a4ce 100644 --- a/project/vs2013/Easy2D.vcxproj +++ b/project/vs2013/Easy2D.vcxproj @@ -163,7 +163,78 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -176,77 +247,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vs2013/Easy2D.vcxproj.filters b/project/vs2013/Easy2D.vcxproj.filters index c14a1aa3..79dd0cd0 100644 --- a/project/vs2013/Easy2D.vcxproj.filters +++ b/project/vs2013/Easy2D.vcxproj.filters @@ -1,32 +1,35 @@  - - {01311827-b639-4313-a5b6-61cd22fe8920} + + {be5d9314-b00a-4f11-bd2a-1f720dc32407} - - {e5c42dd3-2d56-4a95-8f88-45d059d58c21} + + {261633d3-3814-40c7-bd6d-201ede6c6ade} - - {08126b0c-d139-48f9-8559-3d9d9e3a5940} + + {50293f38-87fe-4dde-b938-cf1b7a2921f8} - - {a8185fe2-5477-4293-97d6-d84f27d354bb} + + {7ffdcb87-b6a2-4815-be96-5598f74155ee} - - {70412fec-4c60-425b-81c9-4547e5a1b78a} + + {3475b59d-d50c-43b1-8334-bcb9e1703ed2} - - {dacd05f1-3496-488b-af4d-b3ea7bce9515} + + {6c9657de-02d5-4d3b-9e1d-bc921eb5aea3} - - {337d5a0f-60fd-473a-83da-b2a3515affd9} + + {9031e36b-fa85-4b4e-8e80-657c7e68f283} - - {7660a3fa-36f9-4b1b-8942-e38e02c0c95b} + + {563b19f2-4c5e-4362-983a-94d2ae724550} - - {c597916e-c162-41a4-849a-c568513f6d14} + + {42d46a92-c043-4667-8c20-358319e5c313} + + + {51864c81-02ee-4043-bf09-9ce3cbe5b6da} @@ -39,211 +42,217 @@ - + - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Action + + actions - - Base + + actions - - Base + + actions - - Base + + actions - - Base + + modules - - Base + + modules - - Common + + modules - - Common + + modules - - Common + + modules - - Common + + modules - - Common + + utils - - Common + + utils - - Common + + utils - - Common + + utils - - Common + + utils - - Common + + utils - - Custom + + utils - - Custom + + utils - - Custom + + utils - - Custom + + utils - - Node + + components - - Node + + components - - Node + + components - - Tool + + impl - - Tool + + impl - - Tool + + impl - - Tool + + impl - - Tool + + event - - Tool + + event - - Tool + + event - - Transition + + manager - - Transition + + tools - - Transition + + tools - - Transition + + tools - - Transition + + tools - - Tool + + tools - - Common + + tools - - Manager + + tools - - Event + + tools - - Event + + transitions - - Event + + transitions - - Node + + transitions - - Node + + transitions - - Base + + transitions - - Action + + objects - - Action + + objects - - Action + + objects - - Component + + objects - - Component + + objects - - Component + + objects + + + objects + + + objects \ No newline at end of file diff --git a/project/vs2017/Easy2D.vcxproj b/project/vs2017/Easy2D.vcxproj index a55d431d..8f8aeb37 100644 --- a/project/vs2017/Easy2D.vcxproj +++ b/project/vs2017/Easy2D.vcxproj @@ -196,78 +196,78 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/project/vs2017/Easy2D.vcxproj.filters b/project/vs2017/Easy2D.vcxproj.filters index 4b7c3c07..79dd0cd0 100644 --- a/project/vs2017/Easy2D.vcxproj.filters +++ b/project/vs2017/Easy2D.vcxproj.filters @@ -1,245 +1,36 @@  - - {42d46a92-c043-4667-8c20-358319e5c313} - - - {51864c81-02ee-4043-bf09-9ce3cbe5b6da} - - - {261633d3-3814-40c7-bd6d-201ede6c6ade} - - - {50293f38-87fe-4dde-b938-cf1b7a2921f8} - - - {563b19f2-4c5e-4362-983a-94d2ae724550} - - - {9031e36b-fa85-4b4e-8e80-657c7e68f283} - - + {be5d9314-b00a-4f11-bd2a-1f720dc32407} - - {3475b59d-d50c-43b1-8334-bcb9e1703ed2} + + {261633d3-3814-40c7-bd6d-201ede6c6ade} - - {6c9657de-02d5-4d3b-9e1d-bc921eb5aea3} + + {50293f38-87fe-4dde-b938-cf1b7a2921f8} - + {7ffdcb87-b6a2-4815-be96-5598f74155ee} - - - - Base - - - Common - - - Common - - - Node - - - Node - - - Node - - - Tool - - - Tool - - - Base - - - Base - - - Base - - - Common - - - Common - - - Tool - - - Tool - - - Common - - - Common - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Transition - - - Action - - - Action - - - Action - - - Tool - - - Tool - - - Action - - - Base - - - Custom - - - Custom - - - Common - - - Transition - - - Transition - - - Transition - - - Transition - - - Action - - - Common - - - Custom - - - Custom - - - Common - - - Tool - - - Common - - - Tool - - - Common - - - Manager - - - Event - - - Event - - - Event - - - Common - - - Common - - - Node - - - Node - - - Base - - - Action - - - Action - - - Action - - - Component - - - Component - - - Component - + + {3475b59d-d50c-43b1-8334-bcb9e1703ed2} + + + {6c9657de-02d5-4d3b-9e1d-bc921eb5aea3} + + + {9031e36b-fa85-4b4e-8e80-657c7e68f283} + + + {563b19f2-4c5e-4362-983a-94d2ae724550} + + + {42d46a92-c043-4667-8c20-358319e5c313} + + + {51864c81-02ee-4043-bf09-9ce3cbe5b6da} + @@ -251,8 +42,217 @@ - + + + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + modules + + + modules + + + modules + + + modules + + + modules + + + modules + + + utils + + + utils + + + utils + + + utils + + + utils + + + utils + + + utils + + + utils + + + utils + + + utils + + + components + + + components + + + components + + + impl + + + impl + + + impl + + + impl + + + event + + + event + + + event + + + manager + + + tools + + + tools + + + tools + + + tools + + + tools + + + tools + + + tools + + + tools + + + transitions + + + transitions + + + transitions + + + transitions + + + transitions + + + objects + + + objects + + + objects + + + objects + + + objects + + + objects + + + objects + + + objects + \ No newline at end of file