diff --git a/ResLoader.cpp b/ResLoader.cpp new file mode 100644 index 00000000..1e34b2f0 --- /dev/null +++ b/ResLoader.cpp @@ -0,0 +1,45 @@ +// Copyright (c) 2016-2018 Easy2D - Nomango +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#include "ResLoader.h" + +namespace easy2d +{ + /*void ResLoader::Add(String const & id, SpImage const & image) + { + res_.insert(std::make_pair(id, image.Get())); + } + + void ResLoader::Add(String const & id, SpFrames const & frames) + { + res_.insert(std::make_pair(id, frames.Get())); + } + + SpImage easy2d::ResLoader::GetImage(String const & id) + { + return Get(id); + }*/ + + /*SpFrames easy2d::ResLoader::GetFrames(String const & id) + { + return Get(id); + }*/ + +} \ No newline at end of file diff --git a/ResLoader.h b/ResLoader.h new file mode 100644 index 00000000..ee4455a2 --- /dev/null +++ b/ResLoader.h @@ -0,0 +1,48 @@ +// Copyright (c) 2016-2018 Easy2D - Nomango +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#pragma once +#include "include-forwards.h" + +namespace easy2d +{ + class ResLoader + { + public: + //void Add(String const& id, SpImage const& image); + + //void Add(String const& id, SpFrames const& frames); + + //SpImage GetImage(String const& id); + + //SpFrames GetFrames(String const& id); + + template + T Get(String const& id) const + { + if (res_.find(id) == res_.end()) + return T{}; + return static_cast(res_.at(id)); + } + + protected: + UnorderedMap res_; + }; +} diff --git a/project/vs2013/Easy2D.vcxproj b/project/vs2013/Easy2D.vcxproj index 70b42e75..b6658356 100644 --- a/project/vs2013/Easy2D.vcxproj +++ b/project/vs2013/Easy2D.vcxproj @@ -19,118 +19,118 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {91DBDFCC-4083-427C-AAAD-55715118DB26} diff --git a/project/vs2013/Easy2D.vcxproj.filters b/project/vs2013/Easy2D.vcxproj.filters index 95ad21af..bdc83e0e 100644 --- a/project/vs2013/Easy2D.vcxproj.filters +++ b/project/vs2013/Easy2D.vcxproj.filters @@ -1,208 +1,208 @@  - - - base + + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + math - + math - + math - + utils - + utils - + utils - + utils - + utils - + ui - + ui - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base\intrusive + + core\intrusive - - base\intrusive + + core\intrusive - - base + + core - - base + + core - + utils - - base + + core - - base + + core - + math - - base + + core - - base + + core - - base + + core - + math - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + {896bdedf-6e82-449b-9b6e-0bc69f3699b1} @@ -214,139 +214,139 @@ {07b6d541-4a1b-472a-aae0-daf9d082fe84} - + {0f508149-735a-43da-ab16-36cc1e9ab63a} - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + utils - + utils - + utils - + utils - + utils - + ui - + ui - - base + + core - - base + + core - - base + + core - - base + + core - + utils - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core \ No newline at end of file diff --git a/project/vs2015/Easy2D.vcxproj b/project/vs2015/Easy2D.vcxproj index 79178010..fa65406a 100644 --- a/project/vs2015/Easy2D.vcxproj +++ b/project/vs2015/Easy2D.vcxproj @@ -19,118 +19,118 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF} diff --git a/project/vs2015/Easy2D.vcxproj.filters b/project/vs2015/Easy2D.vcxproj.filters index 95ad21af..bdc83e0e 100644 --- a/project/vs2015/Easy2D.vcxproj.filters +++ b/project/vs2015/Easy2D.vcxproj.filters @@ -1,208 +1,208 @@  - - - base + + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + math - + math - + math - + utils - + utils - + utils - + utils - + utils - + ui - + ui - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base\intrusive + + core\intrusive - - base\intrusive + + core\intrusive - - base + + core - - base + + core - + utils - - base + + core - - base + + core - + math - - base + + core - - base + + core - - base + + core - + math - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + {896bdedf-6e82-449b-9b6e-0bc69f3699b1} @@ -214,139 +214,139 @@ {07b6d541-4a1b-472a-aae0-daf9d082fe84} - + {0f508149-735a-43da-ab16-36cc1e9ab63a} - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + utils - + utils - + utils - + utils - + utils - + ui - + ui - - base + + core - - base + + core - - base + + core - - base + + core - + utils - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core \ No newline at end of file diff --git a/project/vs2017/Easy2D.vcxproj b/project/vs2017/Easy2D.vcxproj index cba9d6e6..cfd59a42 100644 --- a/project/vs2017/Easy2D.vcxproj +++ b/project/vs2017/Easy2D.vcxproj @@ -19,118 +19,118 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 15.0 diff --git a/project/vs2017/Easy2D.vcxproj.filters b/project/vs2017/Easy2D.vcxproj.filters index 95ad21af..bdc83e0e 100644 --- a/project/vs2017/Easy2D.vcxproj.filters +++ b/project/vs2017/Easy2D.vcxproj.filters @@ -1,208 +1,208 @@  - - - base + + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + math - + math - + math - + utils - + utils - + utils - + utils - + utils - + ui - + ui - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base\intrusive + + core\intrusive - - base\intrusive + + core\intrusive - - base + + core - - base + + core - + utils - - base + + core - - base + + core - + math - - base + + core - - base + + core - - base + + core - + math - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + {896bdedf-6e82-449b-9b6e-0bc69f3699b1} @@ -214,139 +214,139 @@ {07b6d541-4a1b-472a-aae0-daf9d082fe84} - + {0f508149-735a-43da-ab16-36cc1e9ab63a} - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - + math - + utils - + utils - + utils - + utils - + utils - + ui - + ui - - base + + core - - base + + core - - base + + core - - base + + core - + utils - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core - - base + + core \ No newline at end of file diff --git a/core/base/Action.hpp b/src/core/Action.hpp similarity index 100% rename from core/base/Action.hpp rename to src/core/Action.hpp diff --git a/core/base/ActionCombined.cpp b/src/core/ActionCombined.cpp similarity index 100% rename from core/base/ActionCombined.cpp rename to src/core/ActionCombined.cpp diff --git a/core/base/ActionCombined.h b/src/core/ActionCombined.h similarity index 100% rename from core/base/ActionCombined.h rename to src/core/ActionCombined.h diff --git a/core/base/ActionManager.cpp b/src/core/ActionManager.cpp similarity index 100% rename from core/base/ActionManager.cpp rename to src/core/ActionManager.cpp diff --git a/core/base/ActionManager.h b/src/core/ActionManager.h similarity index 100% rename from core/base/ActionManager.h rename to src/core/ActionManager.h diff --git a/core/base/ActionTween.cpp b/src/core/ActionTween.cpp similarity index 100% rename from core/base/ActionTween.cpp rename to src/core/ActionTween.cpp diff --git a/core/base/ActionTween.h b/src/core/ActionTween.h similarity index 100% rename from core/base/ActionTween.h rename to src/core/ActionTween.h diff --git a/core/base/Animation.cpp b/src/core/Animation.cpp similarity index 100% rename from core/base/Animation.cpp rename to src/core/Animation.cpp diff --git a/core/base/Animation.h b/src/core/Animation.h similarity index 100% rename from core/base/Animation.h rename to src/core/Animation.h diff --git a/core/base/Canvas.cpp b/src/core/Canvas.cpp similarity index 100% rename from core/base/Canvas.cpp rename to src/core/Canvas.cpp diff --git a/core/base/Canvas.h b/src/core/Canvas.h similarity index 100% rename from core/base/Canvas.h rename to src/core/Canvas.h diff --git a/core/base/Color.cpp b/src/core/Color.cpp similarity index 100% rename from core/base/Color.cpp rename to src/core/Color.cpp diff --git a/core/base/Color.h b/src/core/Color.h similarity index 90% rename from core/base/Color.h rename to src/core/Color.h index ecb90b9a..7a2ba78f 100644 --- a/core/base/Color.h +++ b/src/core/Color.h @@ -26,11 +26,10 @@ namespace easy2d { // ÑÕÉ« // - // Usage: - // ʹÓÃö¾Ù±íʾÑÕÉ«: Color blue = Color::Blue; - // ʹÓà RGB ±íʾһ¸öÑÕÉ«: Color red(1.0f, 0.0f, 0.0f); - // ʹÓà RGBA ±íʾһ¸ö´øÍ¸Ã÷¶ÈµÄÑÕÉ«: Color not_black(1.0f, 1.0f, 1.0f, 0.5f); - // ʹÓÃÒ»¸ö unsigned int ÀàÐ͵ÄÖµ±íʾ RGB: Color black(0x000000); + // ʹÓÃö¾Ù±íʾÑÕÉ«: Color blue = Color::Blue; + // ʹÓà RGB ±íʾһ¸öÑÕÉ«: Color red(1.0f, 0.0f, 0.0f); + // ʹÓà RGBA ±íʾһ¸ö´øÍ¸Ã÷¶ÈµÄÑÕÉ«: Color not_black(1.0f, 1.0f, 1.0f, 0.5f); + // ʹÓÃÒ»¸ö unsigned int ÀàÐ͵ÄÖµ±íʾ RGB: Color black(0x000000); // class Color { diff --git a/core/base/DebugNode.cpp b/src/core/DebugNode.cpp similarity index 100% rename from core/base/DebugNode.cpp rename to src/core/DebugNode.cpp diff --git a/core/base/DebugNode.h b/src/core/DebugNode.h similarity index 100% rename from core/base/DebugNode.h rename to src/core/DebugNode.h diff --git a/core/base/Delay.cpp b/src/core/Delay.cpp similarity index 100% rename from core/base/Delay.cpp rename to src/core/Delay.cpp diff --git a/core/base/Delay.h b/src/core/Delay.h similarity index 100% rename from core/base/Delay.h rename to src/core/Delay.h diff --git a/core/base/Event.hpp b/src/core/Event.hpp similarity index 100% rename from core/base/Event.hpp rename to src/core/Event.hpp diff --git a/core/base/EventDispatcher.cpp b/src/core/EventDispatcher.cpp similarity index 100% rename from core/base/EventDispatcher.cpp rename to src/core/EventDispatcher.cpp diff --git a/core/base/EventDispatcher.h b/src/core/EventDispatcher.h similarity index 100% rename from core/base/EventDispatcher.h rename to src/core/EventDispatcher.h diff --git a/core/base/EventListener.cpp b/src/core/EventListener.cpp similarity index 100% rename from core/base/EventListener.cpp rename to src/core/EventListener.cpp diff --git a/core/base/EventListener.h b/src/core/EventListener.h similarity index 100% rename from core/base/EventListener.h rename to src/core/EventListener.h diff --git a/core/base/Factory.cpp b/src/core/Factory.cpp similarity index 100% rename from core/base/Factory.cpp rename to src/core/Factory.cpp diff --git a/core/base/Factory.h b/src/core/Factory.h similarity index 100% rename from core/base/Factory.h rename to src/core/Factory.h diff --git a/core/base/Font.hpp b/src/core/Font.hpp similarity index 100% rename from core/base/Font.hpp rename to src/core/Font.hpp diff --git a/core/base/Frames.cpp b/src/core/Frames.cpp similarity index 100% rename from core/base/Frames.cpp rename to src/core/Frames.cpp diff --git a/core/base/Frames.h b/src/core/Frames.h similarity index 100% rename from core/base/Frames.h rename to src/core/Frames.h diff --git a/core/base/Game.cpp b/src/core/Game.cpp similarity index 100% rename from core/base/Game.cpp rename to src/core/Game.cpp diff --git a/core/base/Game.h b/src/core/Game.h similarity index 100% rename from core/base/Game.h rename to src/core/Game.h diff --git a/core/base/Geometry.cpp b/src/core/Geometry.cpp similarity index 100% rename from core/base/Geometry.cpp rename to src/core/Geometry.cpp diff --git a/core/base/Geometry.h b/src/core/Geometry.h similarity index 100% rename from core/base/Geometry.h rename to src/core/Geometry.h diff --git a/core/base/GeometryNode.cpp b/src/core/GeometryNode.cpp similarity index 100% rename from core/base/GeometryNode.cpp rename to src/core/GeometryNode.cpp diff --git a/core/base/GeometryNode.h b/src/core/GeometryNode.h similarity index 100% rename from core/base/GeometryNode.h rename to src/core/GeometryNode.h diff --git a/core/base/Image.cpp b/src/core/Image.cpp similarity index 100% rename from core/base/Image.cpp rename to src/core/Image.cpp diff --git a/core/base/Image.h b/src/core/Image.h similarity index 100% rename from core/base/Image.h rename to src/core/Image.h diff --git a/core/base/Input.cpp b/src/core/Input.cpp similarity index 100% rename from core/base/Input.cpp rename to src/core/Input.cpp diff --git a/core/base/Input.h b/src/core/Input.h similarity index 100% rename from core/base/Input.h rename to src/core/Input.h diff --git a/core/base/KeyEvent.hpp b/src/core/KeyEvent.hpp similarity index 100% rename from core/base/KeyEvent.hpp rename to src/core/KeyEvent.hpp diff --git a/core/base/MouseEvent.hpp b/src/core/MouseEvent.hpp similarity index 100% rename from core/base/MouseEvent.hpp rename to src/core/MouseEvent.hpp diff --git a/core/base/Music.cpp b/src/core/Music.cpp similarity index 100% rename from core/base/Music.cpp rename to src/core/Music.cpp diff --git a/core/base/Music.h b/src/core/Music.h similarity index 100% rename from core/base/Music.h rename to src/core/Music.h diff --git a/core/base/Node.cpp b/src/core/Node.cpp similarity index 100% rename from core/base/Node.cpp rename to src/core/Node.cpp diff --git a/core/base/Node.h b/src/core/Node.h similarity index 100% rename from core/base/Node.h rename to src/core/Node.h diff --git a/core/base/Object.cpp b/src/core/Object.cpp similarity index 100% rename from core/base/Object.cpp rename to src/core/Object.cpp diff --git a/core/base/Object.h b/src/core/Object.h similarity index 100% rename from core/base/Object.h rename to src/core/Object.h diff --git a/core/base/RefCounter.hpp b/src/core/RefCounter.hpp similarity index 100% rename from core/base/RefCounter.hpp rename to src/core/RefCounter.hpp diff --git a/core/base/Resource.cpp b/src/core/Resource.cpp similarity index 98% rename from core/base/Resource.cpp rename to src/core/Resource.cpp index a00a9b9a..0e1cd56b 100644 --- a/core/base/Resource.cpp +++ b/src/core/Resource.cpp @@ -23,7 +23,7 @@ namespace easy2d { - Resource::Resource(String file_name) + Resource::Resource(String const& file_name) : type_(Type::File) , file_name_(file_name) { diff --git a/core/base/Resource.h b/src/core/Resource.h similarity index 78% rename from core/base/Resource.h rename to src/core/Resource.h index 61780f7c..8c8470e3 100644 --- a/core/base/Resource.h +++ b/src/core/Resource.h @@ -20,18 +20,17 @@ #pragma once #include "helper.hpp" +#include "Frames.h" namespace easy2d { // ×ÊÔ´ // - // Usage: - // Resource ÓÃÓÚÖ¸¶¨Ò»·Ý×ÊÔ´ - // ×ÊÔ´¿ÉÒÔÊÇÎļþÀàÐÍ£¬Ò²¿ÉÒÔÊDZ£´æÔÚ exe ÖеĶþ½øÖÆÎļþ - // ÀýÈç, Ò»·ÝÒôƵ×ÊÔ´µÄÀàÐÍΪ L"WAVE", Ãû³Æ±êʶ·ûΪ IDR_WAVE_1, - // ÄÇô¿ÉÒÔÕâÑùÖ¸¶¨¸Ã×ÊÔ´: Resource res(MAKEINTRESOURCE(IDR_WAVE_1), L"WAVE"); + // ×ÊÔ´¿ÉÒÔÊÇÎļþÀàÐÍ£¬Ò²¿ÉÒÔÊDZ£´æÔÚ exe ÖеĶþ½øÖÆÎļþ + // ÀýÈç, Ò»·ÝÒôƵ×ÊÔ´µÄÀàÐÍΪ L"WAVE", Ãû³Æ±êʶ·ûΪ IDR_WAVE_1, + // ÄÇô¿ÉÒÔÕâÑùÖ¸¶¨¸Ã×ÊÔ´: Resource res(MAKEINTRESOURCE(IDR_WAVE_1), L"WAVE"); // - // Á˽â×ÊÔ´µÄ¸ü¶àÐÅÏ¢: https://docs.microsoft.com/en-us/windows/desktop/menurc/resources + // Á˽â×ÊÔ´µÄ¸ü¶àÐÅÏ¢: https://docs.microsoft.com/en-us/windows/desktop/menurc/resources // class Resource { @@ -39,16 +38,16 @@ namespace easy2d enum class Type { File, Binary }; Resource( - String file_name /* Îļþ·¾¶ */ + String const& file_name /* Îļþ·¾¶ */ ); Resource( - LPCWSTR file_name /* Îļþ·¾¶ */ + LPCWSTR file_name /* Îļþ·¾¶ */ ); Resource( - LPCWSTR name, /* ×ÊÔ´Ãû³Æ */ - LPCWSTR type /* ×ÊÔ´ÀàÐÍ */ + LPCWSTR name, /* ×ÊÔ´Ãû³Æ */ + LPCWSTR type /* ×ÊÔ´ÀàÐÍ */ ); virtual ~Resource(); diff --git a/core/base/Scene.cpp b/src/core/Scene.cpp similarity index 100% rename from core/base/Scene.cpp rename to src/core/Scene.cpp diff --git a/core/base/Scene.h b/src/core/Scene.h similarity index 100% rename from core/base/Scene.h rename to src/core/Scene.h diff --git a/core/base/Singleton.hpp b/src/core/Singleton.hpp similarity index 100% rename from core/base/Singleton.hpp rename to src/core/Singleton.hpp diff --git a/core/base/Sprite.cpp b/src/core/Sprite.cpp similarity index 100% rename from core/base/Sprite.cpp rename to src/core/Sprite.cpp diff --git a/core/base/Sprite.h b/src/core/Sprite.h similarity index 100% rename from core/base/Sprite.h rename to src/core/Sprite.h diff --git a/core/base/Task.cpp b/src/core/Task.cpp similarity index 100% rename from core/base/Task.cpp rename to src/core/Task.cpp diff --git a/core/base/Task.h b/src/core/Task.h similarity index 100% rename from core/base/Task.h rename to src/core/Task.h diff --git a/core/base/TaskManager.cpp b/src/core/TaskManager.cpp similarity index 100% rename from core/base/TaskManager.cpp rename to src/core/TaskManager.cpp diff --git a/core/base/TaskManager.h b/src/core/TaskManager.h similarity index 100% rename from core/base/TaskManager.h rename to src/core/TaskManager.h diff --git a/core/base/Text.cpp b/src/core/Text.cpp similarity index 100% rename from core/base/Text.cpp rename to src/core/Text.cpp diff --git a/core/base/Text.h b/src/core/Text.h similarity index 100% rename from core/base/Text.h rename to src/core/Text.h diff --git a/core/base/TextRenderer.cpp b/src/core/TextRenderer.cpp similarity index 100% rename from core/base/TextRenderer.cpp rename to src/core/TextRenderer.cpp diff --git a/core/base/TextRenderer.h b/src/core/TextRenderer.h similarity index 100% rename from core/base/TextRenderer.h rename to src/core/TextRenderer.h diff --git a/core/base/TextStyle.hpp b/src/core/TextStyle.hpp similarity index 100% rename from core/base/TextStyle.hpp rename to src/core/TextStyle.hpp diff --git a/core/base/Transform.hpp b/src/core/Transform.hpp similarity index 100% rename from core/base/Transform.hpp rename to src/core/Transform.hpp diff --git a/core/base/Transition.cpp b/src/core/Transition.cpp similarity index 100% rename from core/base/Transition.cpp rename to src/core/Transition.cpp diff --git a/core/base/Transition.h b/src/core/Transition.h similarity index 100% rename from core/base/Transition.h rename to src/core/Transition.h diff --git a/core/base/audio.cpp b/src/core/audio.cpp similarity index 100% rename from core/base/audio.cpp rename to src/core/audio.cpp diff --git a/core/base/audio.h b/src/core/audio.h similarity index 100% rename from core/base/audio.h rename to src/core/audio.h diff --git a/core/base/d2dhelper.hpp b/src/core/d2dhelper.hpp similarity index 100% rename from core/base/d2dhelper.hpp rename to src/core/d2dhelper.hpp diff --git a/core/base/helper.hpp b/src/core/helper.hpp similarity index 89% rename from core/base/helper.hpp rename to src/core/helper.hpp index ece93ed9..20be6f8c 100644 --- a/core/base/helper.hpp +++ b/src/core/helper.hpp @@ -49,23 +49,23 @@ namespace easy2d using String = std::wstring; using StringStream = std::wstringstream; - template - using Array = std::vector; + template + using Array = std::vector; - template - using List = std::list; + template + using List = std::list; - template - using Set = std::set; + template + using Set = std::set; - template - using UnorderedSet = std::unordered_set; + template + using UnorderedSet = std::unordered_set; - template - using Map = std::map; + template + using Map = std::map; - template - using UnorderedMap = std::unordered_map; + template + using UnorderedMap = std::unordered_map; } namespace easy2d diff --git a/core/base/include-forwards.h b/src/core/include-forwards.h similarity index 100% rename from core/base/include-forwards.h rename to src/core/include-forwards.h diff --git a/core/base/intrusive/List.hpp b/src/core/intrusive/List.hpp similarity index 100% rename from core/base/intrusive/List.hpp rename to src/core/intrusive/List.hpp diff --git a/core/base/intrusive/SmartPointer.hpp b/src/core/intrusive/SmartPointer.hpp similarity index 100% rename from core/base/intrusive/SmartPointer.hpp rename to src/core/intrusive/SmartPointer.hpp diff --git a/core/base/keys.hpp b/src/core/keys.hpp similarity index 100% rename from core/base/keys.hpp rename to src/core/keys.hpp diff --git a/core/base/logs.cpp b/src/core/logs.cpp similarity index 100% rename from core/base/logs.cpp rename to src/core/logs.cpp diff --git a/core/base/logs.h b/src/core/logs.h similarity index 100% rename from core/base/logs.h rename to src/core/logs.h diff --git a/core/base/macros.h b/src/core/macros.h similarity index 100% rename from core/base/macros.h rename to src/core/macros.h diff --git a/core/base/modules.cpp b/src/core/modules.cpp similarity index 100% rename from core/base/modules.cpp rename to src/core/modules.cpp diff --git a/core/base/modules.h b/src/core/modules.h similarity index 100% rename from core/base/modules.h rename to src/core/modules.h diff --git a/core/base/noncopyable.hpp b/src/core/noncopyable.hpp similarity index 100% rename from core/base/noncopyable.hpp rename to src/core/noncopyable.hpp diff --git a/core/base/render.cpp b/src/core/render.cpp similarity index 100% rename from core/base/render.cpp rename to src/core/render.cpp diff --git a/core/base/render.h b/src/core/render.h similarity index 100% rename from core/base/render.h rename to src/core/render.h diff --git a/core/base/time.cpp b/src/core/time.cpp similarity index 100% rename from core/base/time.cpp rename to src/core/time.cpp diff --git a/core/base/time.h b/src/core/time.h similarity index 86% rename from core/base/time.h rename to src/core/time.h index 2375340d..dcc3d56c 100644 --- a/core/base/time.h +++ b/src/core/time.h @@ -27,16 +27,14 @@ namespace easy2d { // ʱ¼ä¶Î // - // Usage: - // ʱ¼ä¶Î±íʾ·¨: - // 5 Ãë: time::Second * 5 - // 1.5 Сʱ: time::Hour * 1.5 - // 3 Сʱ 45 ·Ö 15 Ãë: time::Hour * 3 + time::Minute * 45 + time::Second * 15 - // ʱ¼ä¶Î¸ñʽ»¯: auto d = time::ParseDuration(L"1h35m"); // 1Сʱ35·ÖÖÓ - // ÔÚ VS2015 ¼°¸ü¸ß°æ±¾¿ÉÒÔʹÓà time literals: - // 5 Ãë: 5_s - // 1.5 Сʱ: 1.5_h - // 3 Сʱ 45 ·Ö 15 Ãë: 3_h + 45_m + 15_s + // ʱ¼ä¶Î±íʾ·¨: + // 5 Ãë: time::Second * 5 + // 1.5 Сʱ: time::Hour * 1.5 + // 3 Сʱ 45 ·Ö 15 Ãë: time::Hour * 3 + time::Minute * 45 + time::Second * 15 + // ÔÚ VS2015 ¼°¸ü¸ß°æ±¾¿ÉÒÔʹÓà time literals: + // 5 Ãë: 5_s + // 1.5 Сʱ: 1.5_h + // 3 Сʱ 45 ·Ö 15 Ãë: 3_h + 45_m + 15_s // class Duration { @@ -119,18 +117,10 @@ namespace easy2d // ʱ¼ä // - // Usage: - // »ñÈ¡µ±Ç°Ê±¼ä: TimePoint now = time::Now(); - // ʱ¼ä²Ù×÷: - // Á½Ê±¼äÏà¼õ, µÃµ½Ò»¸ö Duration ¶ÔÏó, ÀýÈç: - // TimePoint t1 = time::Now(); - // ... // ×öЩʲô - // TimePoint t2 = time::Now(); - // auto duration = t2 - t1; - // »ñÈ¡Á½Ê±¼äÏà²îµÄºÁÃëÊý: - // int ms = duration.Milliseconds(); - // ×¢: ÓÉÓÚ¸Ãʱ¼äµã»ùÓÚϵͳÆô¶¯Ê±¼ä¿ªÊ¼¼ÆËã, ËùÒÔÎÞ·¨¸ñʽ»¯¸Ãʱ¼ä, - // Ò²ÎÞ·¨»ñµÃ¸Ãʱ¼äµÄ Unix ʱ¼ä´Á + // »ñÈ¡µ±Ç°Ê±¼ä: TimePoint now = time::Now(); + // Á½Ê±¼äÏà¼õ, µÃµ½Ò»¸ö Duration ¶ÔÏó, ÀýÈç: + // TimePoint t1, t2; + // int ms = (t2 - t1).Milliseconds(); // »ñÈ¡Á½Ê±¼äÏà²îµÄºÁÃëÊý // class TimePoint { @@ -168,9 +158,13 @@ namespace easy2d }; // »ñÈ¡µ±Ç°Ê±¼ä + // + // ÓÉÓÚ¸Ãʱ¼äµã»ùÓÚϵͳÆô¶¯Ê±¼ä¿ªÊ¼¼ÆËã, ËùÒÔÎÞ·¨¸ñʽ»¯¸Ãʱ¼ä, + // Ò²ÎÞ·¨»ñµÃ¸Ãʱ¼äµÄ Unix ʱ¼ä´Á TimePoint Now() E2D_NOEXCEPT; // ʱ¼ä¶Î¸ñʽ»¯ + // // ʱ¼ä¶Î×Ö·û´®ÔÊÐíÊÇÓзûºÅµÄ¸¡µãÊý, ²¢ÇÒ´øÓÐʱ¼äµ¥Î»ºó׺ // ÀýÈç: "300ms", "-1.5h", "2h45m" // ÔÊÐíµÄʱ¼äµ¥Î»ÓÐ "ms", "s", "m", "h" diff --git a/core/base/window.cpp b/src/core/window.cpp similarity index 100% rename from core/base/window.cpp rename to src/core/window.cpp diff --git a/core/base/window.h b/src/core/window.h similarity index 100% rename from core/base/window.h rename to src/core/window.h diff --git a/core/easy2d.h b/src/easy2d.h similarity index 58% rename from core/easy2d.h rename to src/easy2d.h index 6606abb6..be78367b 100644 --- a/core/easy2d.h +++ b/src/easy2d.h @@ -27,60 +27,60 @@ // -// base +// core // -#include "base/macros.h" -#include "base/modules.h" -#include "base/render.h" -#include "base/window.h" -#include "base/input.h" -#include "base/audio.h" -#include "base/time.h" -#include "base/logs.h" +#include "core/macros.h" +#include "core/modules.h" +#include "core/render.h" +#include "core/window.h" +#include "core/input.h" +#include "core/audio.h" +#include "core/time.h" +#include "core/logs.h" -#include "base/Font.hpp" -#include "base/Color.h" -#include "base/Resource.h" -#include "base/Transform.hpp" -#include "base/TextStyle.hpp" +#include "core/Font.hpp" +#include "core/Color.h" +#include "core/Resource.h" +#include "core/Transform.hpp" +#include "core/TextStyle.hpp" -#include "base/noncopyable.hpp" -#include "base/RefCounter.hpp" -#include "base/intrusive/SmartPointer.hpp" -#include "base/intrusive/List.hpp" +#include "core/noncopyable.hpp" +#include "core/RefCounter.hpp" +#include "core/intrusive/SmartPointer.hpp" +#include "core/intrusive/List.hpp" -#include "base/Object.h" -#include "base/Image.h" -#include "base/Frames.h" -#include "base/Music.h" -#include "base/Geometry.h" -#include "base/Task.h" -#include "base/TaskManager.h" -#include "base/Action.hpp" -#include "base/ActionCombined.h" -#include "base/ActionTween.h" -#include "base/Animation.h" -#include "base/Delay.h" -#include "base/ActionManager.h" -#include "base/Transition.h" +#include "core/Object.h" +#include "core/Image.h" +#include "core/Frames.h" +#include "core/Music.h" +#include "core/Geometry.h" +#include "core/Task.h" +#include "core/TaskManager.h" +#include "core/Action.hpp" +#include "core/ActionCombined.h" +#include "core/ActionTween.h" +#include "core/Animation.h" +#include "core/Delay.h" +#include "core/ActionManager.h" +#include "core/Transition.h" -#include "base/Event.hpp" -#include "base/MouseEvent.hpp" -#include "base/KeyEvent.hpp" -#include "base/EventListener.h" -#include "base/EventDispatcher.h" +#include "core/Event.hpp" +#include "core/MouseEvent.hpp" +#include "core/KeyEvent.hpp" +#include "core/EventListener.h" +#include "core/EventDispatcher.h" -#include "base/Node.h" -#include "base/Scene.h" -#include "base/Sprite.h" -#include "base/Text.h" -#include "base/Canvas.h" -#include "base/GeometryNode.h" -#include "base/DebugNode.h" +#include "core/Node.h" +#include "core/Scene.h" +#include "core/Sprite.h" +#include "core/Text.h" +#include "core/Canvas.h" +#include "core/GeometryNode.h" +#include "core/DebugNode.h" -#include "base/Factory.h" -#include "base/Game.h" +#include "core/Factory.h" +#include "core/Game.h" // diff --git a/core/math/Matrix.hpp b/src/math/Matrix.hpp similarity index 100% rename from core/math/Matrix.hpp rename to src/math/Matrix.hpp diff --git a/core/math/Rect.hpp b/src/math/Rect.hpp similarity index 90% rename from core/math/Rect.hpp rename to src/math/Rect.hpp index 53f11999..e0b5048d 100644 --- a/core/math/Rect.hpp +++ b/src/math/Rect.hpp @@ -26,13 +26,8 @@ namespace easy2d { namespace math { - // ¾ØÐÎ // - // Usage: - // ±íʾһ¸ö¶þά¾ØÐÎ: Rect rect = Rect(10, 20, 30, 40); // ×óÉϽÇ×ø±êΪ (10, 20), ¿íΪ 30, ¸ßΪ 40 - // ¾ØÐοÉÒÔͨ¹ý Vector2 + Vector2 ¶¨Òå, Vector2 ±íʾ¾ØÐÎ×óÉϽÇ×ø±ê, Vector2 ±íʾ¾ØÐοí¸ß - // ÅжÏÒ»¸öµãÊÇ·ñÔÚ¾ØÐÎÄÚ: bool contains = rect.ContainsPoint(p); - // ÅжÏÁ½¾ØÐÎÊÇ·ñÏཻ: bool intersects = rect1.Intersects(rect2); + // ¾ØÐÎ // class Rect { diff --git a/core/math/constants.hpp b/src/math/constants.hpp similarity index 100% rename from core/math/constants.hpp rename to src/math/constants.hpp diff --git a/core/math/ease.hpp b/src/math/ease.hpp similarity index 100% rename from core/math/ease.hpp rename to src/math/ease.hpp diff --git a/core/math/rand.cpp b/src/math/rand.cpp similarity index 100% rename from core/math/rand.cpp rename to src/math/rand.cpp diff --git a/core/math/rand.h b/src/math/rand.h similarity index 89% rename from core/math/rand.h rename to src/math/rand.h index 13763a1e..201a3e49 100644 --- a/core/math/rand.h +++ b/src/math/rand.h @@ -26,14 +26,12 @@ namespace easy2d namespace math { // - // Ëæ»úÊý²úÉúÆ÷ + // Ëæ»úÊý // - // Usage: - // »ñȡָ¶¨·¶Î§ÄÚµÄÒ»¸öËæ»úÊý, Èç: - // int n = math::Rand(1, 5); // »ñÈ¡ 1~5 ÄÚµÄËæ»úÕûÊý, °üº¬ 1 ºÍ 5 - // ·½·¨Í¬ÑùÊÊÓÃÓÚ¸¡µãÊýµÄÉú³É, Èç: - // double d = math::Rand(1.2, 1.5); - // ×¢Òâ, »ñµÃµÄËæ»úÊýÀàÐÍÈ¡¾öÓÚ²ÎÊýµÄÀàÐÍ¡£ + // »ñȡָ¶¨·¶Î§ÄÚµÄÒ»¸öËæ»úÊý, Èç: + // int n = math::Rand(1, 5); // »ñÈ¡ 1~5 ÄÚµÄËæ»úÕûÊý, °üº¬ 1 ºÍ 5 + // ²úÉúµÄËæ»úÊýÀàÐÍÈ¡¾öÓÚ²ÎÊýµÄÀàÐÍ, Èç»ñÈ¡Ëæ»ú¸¡µãÊý: + // double d = math::Rand(1.2, 1.5); // std::default_random_engine& GetRandomEngine(); diff --git a/core/math/scalar.hpp b/src/math/scalar.hpp similarity index 100% rename from core/math/scalar.hpp rename to src/math/scalar.hpp diff --git a/core/math/vector.hpp b/src/math/vector.hpp similarity index 100% rename from core/math/vector.hpp rename to src/math/vector.hpp diff --git a/core/ui/Button.cpp b/src/ui/Button.cpp similarity index 99% rename from core/ui/Button.cpp rename to src/ui/Button.cpp index b6501069..69531f67 100644 --- a/core/ui/Button.cpp +++ b/src/ui/Button.cpp @@ -19,7 +19,7 @@ // THE SOFTWARE. #include "Button.h" -#include "../base/MouseEvent.hpp" +#include "../core/MouseEvent.hpp" namespace easy2d { diff --git a/core/ui/Button.h b/src/ui/Button.h similarity index 98% rename from core/ui/Button.h rename to src/ui/Button.h index d32d20b2..e0098bd7 100644 --- a/core/ui/Button.h +++ b/src/ui/Button.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include "../base/Sprite.h" +#include "../core/Sprite.h" #include namespace easy2d diff --git a/core/ui/Menu.cpp b/src/ui/Menu.cpp similarity index 100% rename from core/ui/Menu.cpp rename to src/ui/Menu.cpp diff --git a/core/ui/Menu.h b/src/ui/Menu.h similarity index 100% rename from core/ui/Menu.h rename to src/ui/Menu.h diff --git a/core/utils/Data.cpp b/src/utils/Data.cpp similarity index 100% rename from core/utils/Data.cpp rename to src/utils/Data.cpp diff --git a/core/utils/Data.h b/src/utils/Data.h similarity index 98% rename from core/utils/Data.h rename to src/utils/Data.h index 1f7e48dc..5e2e2677 100644 --- a/core/utils/Data.h +++ b/src/utils/Data.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include "../base/helper.hpp" +#include "../core/helper.hpp" namespace easy2d { diff --git a/core/utils/File.cpp b/src/utils/File.cpp similarity index 99% rename from core/utils/File.cpp rename to src/utils/File.cpp index 7b98d547..6e28d6a0 100644 --- a/core/utils/File.cpp +++ b/src/utils/File.cpp @@ -19,7 +19,7 @@ // THE SOFTWARE. #include "File.h" -#include "../base/modules.h" +#include "../core/modules.h" #include namespace easy2d diff --git a/core/utils/File.h b/src/utils/File.h similarity index 96% rename from core/utils/File.h rename to src/utils/File.h index 394e1220..93f20034 100644 --- a/core/utils/File.h +++ b/src/utils/File.h @@ -19,8 +19,8 @@ // THE SOFTWARE. #pragma once -#include "../base/helper.hpp" -#include "../base/Resource.h" +#include "../core/helper.hpp" +#include "../core/Resource.h" namespace easy2d { diff --git a/core/utils/Path.cpp b/src/utils/Path.cpp similarity index 99% rename from core/utils/Path.cpp rename to src/utils/Path.cpp index 8b7b29ce..07097a86 100644 --- a/core/utils/Path.cpp +++ b/src/utils/Path.cpp @@ -20,7 +20,7 @@ #include "Path.h" #include "File.h" -#include "../base/window.h" +#include "../core/window.h" #include namespace easy2d diff --git a/core/utils/Path.h b/src/utils/Path.h similarity index 98% rename from core/utils/Path.h rename to src/utils/Path.h index 7eef6747..a39a5a31 100644 --- a/core/utils/Path.h +++ b/src/utils/Path.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include "../base/helper.hpp" +#include "../core/helper.hpp" namespace easy2d { diff --git a/core/utils/Player.cpp b/src/utils/Player.cpp similarity index 99% rename from core/utils/Player.cpp rename to src/utils/Player.cpp index 36f2ba18..853be7c7 100644 --- a/core/utils/Player.cpp +++ b/src/utils/Player.cpp @@ -19,7 +19,7 @@ // THE SOFTWARE. #include "Player.h" -#include "../base/Music.h" +#include "../core/Music.h" namespace easy2d { diff --git a/core/utils/Player.h b/src/utils/Player.h similarity index 96% rename from core/utils/Player.h rename to src/utils/Player.h index 396aa345..dee336e0 100644 --- a/core/utils/Player.h +++ b/src/utils/Player.h @@ -19,8 +19,8 @@ // THE SOFTWARE. #pragma once -#include "../base/include-forwards.h" -#include "../base/Resource.h" +#include "../core/include-forwards.h" +#include "../core/Resource.h" #include namespace easy2d diff --git a/core/utils/Transcoder.cpp b/src/utils/Transcoder.cpp similarity index 98% rename from core/utils/Transcoder.cpp rename to src/utils/Transcoder.cpp index bd097269..d4d59c4e 100644 --- a/core/utils/Transcoder.cpp +++ b/src/utils/Transcoder.cpp @@ -19,9 +19,9 @@ // THE SOFTWARE. #include "Transcoder.h" -#include "../base/d2dhelper.hpp" -#include "../base/modules.h" -#include "../base/logs.h" +#include "../core/d2dhelper.hpp" +#include "../core/modules.h" +#include "../core/logs.h" #include namespace easy2d diff --git a/core/utils/Transcoder.h b/src/utils/Transcoder.h similarity index 96% rename from core/utils/Transcoder.h rename to src/utils/Transcoder.h index 40365c62..5b490b32 100644 --- a/core/utils/Transcoder.h +++ b/src/utils/Transcoder.h @@ -19,8 +19,8 @@ // THE SOFTWARE. #pragma once -#include "../base/macros.h" -#include "../base/Resource.h" +#include "../core/macros.h" +#include "../core/Resource.h" #include #include #include diff --git a/core/utils/string.cpp b/src/utils/string.cpp similarity index 97% rename from core/utils/string.cpp rename to src/utils/string.cpp index 1c62b025..180f8130 100644 --- a/core/utils/string.cpp +++ b/src/utils/string.cpp @@ -19,8 +19,8 @@ // THE SOFTWARE. #include "string.h" -#include "../base/macros.h" -#include "../base/logs.h" +#include "../core/macros.h" +#include "../core/logs.h" namespace easy2d { diff --git a/core/utils/string.h b/src/utils/string.h similarity index 100% rename from core/utils/string.h rename to src/utils/string.h