From e1ec4f76b7ddc78ed3c1fc05e76690768aa12265 Mon Sep 17 00:00:00 2001 From: Nomango Date: Wed, 20 May 2020 23:38:24 +0800 Subject: [PATCH 1/4] minor fixes --- src/kiwano/platform/Application.cpp | 4 +- src/kiwano/platform/Window.cpp | 6 ++- src/kiwano/platform/Window.h | 10 ++++ src/kiwano/platform/win32/WindowImpl.cpp | 63 ++++++++++++++++++------ 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/src/kiwano/platform/Application.cpp b/src/kiwano/platform/Application.cpp index 5222fe11..b3f0c3c2 100644 --- a/src/kiwano/platform/Application.cpp +++ b/src/kiwano/platform/Application.cpp @@ -52,6 +52,8 @@ void Application::Run(RunnerPtr runner, bool debug) { KGE_ASSERT(runner); runner_ = runner; + timer_ = Timer::Create(); + running_ = true; // Setup all modules for (auto c : modules_) @@ -68,8 +70,6 @@ void Application::Run(RunnerPtr runner, bool debug) // Everything is ready runner->OnReady(); - running_ = true; - timer_ = Timer::Create(); while (running_) { timer_->Tick(); diff --git a/src/kiwano/platform/Window.cpp b/src/kiwano/platform/Window.cpp index 1fdd40d7..7bff692b 100644 --- a/src/kiwano/platform/Window.cpp +++ b/src/kiwano/platform/Window.cpp @@ -29,8 +29,10 @@ Window::Window() , is_fullscreen_(false) , width_(0) , height_(0) - , min_width_(100) - , min_height_(50) + , min_width_(0) + , min_height_(0) + , max_width_(0) + , max_height_(0) { } diff --git a/src/kiwano/platform/Window.h b/src/kiwano/platform/Window.h index a982bfaa..63dbb122 100644 --- a/src/kiwano/platform/Window.h +++ b/src/kiwano/platform/Window.h @@ -136,6 +136,14 @@ public: */ virtual void SetMinimumSize(uint32_t width, uint32_t height) = 0; + /** + * \~chinese + * @brief 设置窗口最大大小 + * @param width 最大窗口宽度 + * @param height 最大窗口高度 + */ + virtual void SetMaximumSize(uint32_t width, uint32_t height) = 0; + /** * \~chinese * @brief 设置鼠标指针类型 @@ -193,6 +201,8 @@ protected: uint32_t height_; uint32_t min_width_; uint32_t min_height_; + uint32_t max_width_; + uint32_t max_height_; WindowHandle handle_; String title_; std::queue event_queue_; diff --git a/src/kiwano/platform/win32/WindowImpl.cpp b/src/kiwano/platform/win32/WindowImpl.cpp index ffe85838..5fc92edf 100644 --- a/src/kiwano/platform/win32/WindowImpl.cpp +++ b/src/kiwano/platform/win32/WindowImpl.cpp @@ -58,6 +58,8 @@ public: void SetMinimumSize(uint32_t width, uint32_t height) override; + void SetMaximumSize(uint32_t width, uint32_t height) override; + void SetCursor(CursorType cursor) override; void PumpEvents() override; @@ -257,8 +259,11 @@ void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height, height = win_height; } - handle_ = ::CreateWindowExA(fullscreen ? WS_EX_TOPMOST : 0, "KiwanoAppWnd", title.c_str(), GetStyle(), - left, top, width, height, nullptr, nullptr, hinst, nullptr); + width_ = width; + height_ = height; + resizable_ = resizable; + handle_ = ::CreateWindowExA(fullscreen ? WS_EX_TOPMOST : 0, "KiwanoAppWnd", title.c_str(), GetStyle(), left, top, + width, height, nullptr, nullptr, hinst, nullptr); if (handle_ == nullptr) { @@ -266,10 +271,6 @@ void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height, KGE_THROW_SYSTEM_ERROR(HRESULT_FROM_WIN32(GetLastError()), "Create window failed"); } - width_ = width; - height_ = height; - resizable_ = resizable; - // disable imm ::ImmAssociateContext(handle_, nullptr); @@ -333,6 +334,12 @@ void WindowWin32Impl::SetMinimumSize(uint32_t width, uint32_t height) min_height_ = height; } +void WindowWin32Impl::SetMaximumSize(uint32_t width, uint32_t height) +{ + max_width_ = width; + max_height_ = height; +} + void WindowWin32Impl::SetCursor(CursorType cursor) { mouse_cursor_ = cursor; @@ -498,13 +505,15 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA } else if (SIZE_MAXIMIZED == wparam) { + KGE_SYS_LOG("Window maximized"); + if (is_minimized_) { is_minimized_ = false; if (Application::GetInstance().IsRunning()) { TimerPtr timer = Application::GetInstance().GetTimer(); - timer->Pause(); + timer->Resume(); } } } @@ -519,7 +528,7 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA if (Application::GetInstance().IsRunning()) { TimerPtr timer = Application::GetInstance().GetTimer(); - timer->Pause(); + timer->Resume(); } } else if (is_resizing_) @@ -528,8 +537,6 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA } else { - KGE_SYS_LOG("Window resized"); - this->width_ = ((uint32_t)(short)LOWORD(lparam)); this->height_ = ((uint32_t)(short)HIWORD(lparam)); @@ -537,6 +544,8 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA evt->width = this->GetWidth(); evt->height = this->GetHeight(); this->PushEvent(evt); + + KGE_SYS_LOG("Window resized to (%d, %d)", this->width_, this->height_); } } } @@ -552,7 +561,6 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA } return 0; } - break; case WM_EXITSIZEMOVE: { @@ -562,17 +570,40 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA TimerPtr timer = Application::GetInstance().GetTimer(); timer->Resume(); } + + // Send window resized event when client size changed + RECT client_rect = { 0 }; + ::GetClientRect(hwnd, &client_rect); + + uint32_t client_width = uint32_t(client_rect.right - client_rect.left); + uint32_t client_height = uint32_t(client_rect.bottom - client_rect.top); + if (client_width != this->GetWidth() || client_height != this->GetHeight()) + { + KGE_SYS_LOG("Window resized to (%d, %d)", client_width, client_height); + + this->width_ = client_width; + this->height_ = client_height; + + WindowResizedEventPtr evt = new WindowResizedEvent; + evt->width = this->GetWidth(); + evt->height = this->GetHeight(); + this->PushEvent(evt); + } return 0; } - break; case WM_GETMINMAXINFO: { - // prevent the window from becoming too small - ((MINMAXINFO*)lparam)->ptMinTrackSize.x = LONG(min_width_); - ((MINMAXINFO*)lparam)->ptMinTrackSize.y = LONG(min_height_); + if (min_width_ || min_height_) + { + ((MINMAXINFO*)lparam)->ptMinTrackSize = POINT{ LONG(min_width_), LONG(min_height_) }; + } + if (max_width_ || max_height_) + { + ((MINMAXINFO*)lparam)->ptMaxTrackSize = POINT{ LONG(max_width_), LONG(max_height_) }; + } + return 0; } - return 0; case WM_MOVE: { From e68bb9d94d0d85e70c61cad78d1fa33a7906e622 Mon Sep 17 00:00:00 2001 From: Nomango Date: Wed, 20 May 2020 23:48:56 +0800 Subject: [PATCH 2/4] refactor utils --- projects/kiwano/kiwano.vcxproj | 24 +++++----- projects/kiwano/kiwano.vcxproj.filters | 52 +++++++++++----------- src/kiwano-network/HttpRequest.h | 2 +- src/kiwano/2d/Actor.h | 4 +- src/kiwano/core/ObjectBase.cpp | 2 +- src/kiwano/kiwano.h | 10 ++--- src/kiwano/platform/Application.h | 2 +- src/kiwano/{core => utils}/EventTicker.cpp | 2 +- src/kiwano/{core => utils}/EventTicker.h | 2 +- src/kiwano/{core => utils}/Json.h | 0 src/kiwano/utils/ResourceCache.h | 6 +-- src/kiwano/{core => utils}/Task.cpp | 2 +- src/kiwano/{core => utils}/Task.h | 2 +- src/kiwano/{core => utils}/TaskManager.cpp | 2 +- src/kiwano/{core => utils}/TaskManager.h | 2 +- src/kiwano/{core => utils}/Ticker.cpp | 2 +- src/kiwano/{core => utils}/Ticker.h | 2 +- src/kiwano/{core => utils}/Timer.cpp | 2 +- src/kiwano/{core => utils}/Timer.h | 0 src/kiwano/{core => utils}/Xml.h | 0 20 files changed, 60 insertions(+), 60 deletions(-) rename src/kiwano/{core => utils}/EventTicker.cpp (97%) rename src/kiwano/{core => utils}/EventTicker.h (98%) rename src/kiwano/{core => utils}/Json.h (100%) rename src/kiwano/{core => utils}/Task.cpp (98%) rename src/kiwano/{core => utils}/Task.h (99%) rename src/kiwano/{core => utils}/TaskManager.cpp (98%) rename src/kiwano/{core => utils}/TaskManager.h (98%) rename src/kiwano/{core => utils}/Ticker.cpp (98%) rename src/kiwano/{core => utils}/Ticker.h (99%) rename src/kiwano/{core => utils}/Timer.cpp (98%) rename src/kiwano/{core => utils}/Timer.h (100%) rename src/kiwano/{core => utils}/Xml.h (100%) diff --git a/projects/kiwano/kiwano.vcxproj b/projects/kiwano/kiwano.vcxproj index 6c148289..46c98312 100644 --- a/projects/kiwano/kiwano.vcxproj +++ b/projects/kiwano/kiwano.vcxproj @@ -17,7 +17,6 @@ - @@ -26,16 +25,12 @@ - - - - @@ -56,8 +51,6 @@ - - @@ -101,9 +94,16 @@ + + + + + + + @@ -126,7 +126,6 @@ - @@ -142,11 +141,7 @@ - - - - @@ -176,8 +171,13 @@ + + + + + diff --git a/projects/kiwano/kiwano.vcxproj.filters b/projects/kiwano/kiwano.vcxproj.filters index 3bbe6b4a..8e32b171 100644 --- a/projects/kiwano/kiwano.vcxproj.filters +++ b/projects/kiwano/kiwano.vcxproj.filters @@ -285,12 +285,6 @@ core - - core - - - core - core @@ -321,20 +315,26 @@ render - - core + + utils - - core + + utils - - core + + utils - - core + + utils - - core + + utils + + + utils + + + utils @@ -542,20 +542,20 @@ render - - core + + utils - - core + + utils - - core + + utils - - core + + utils - - core + + utils diff --git a/src/kiwano-network/HttpRequest.h b/src/kiwano-network/HttpRequest.h index fe8bdd6c..626c3b56 100644 --- a/src/kiwano-network/HttpRequest.h +++ b/src/kiwano-network/HttpRequest.h @@ -21,7 +21,7 @@ #pragma once #include #include -#include +#include namespace kiwano { diff --git a/src/kiwano/2d/Actor.h b/src/kiwano/2d/Actor.h index 0c552b20..a1af5e8b 100644 --- a/src/kiwano/2d/Actor.h +++ b/src/kiwano/2d/Actor.h @@ -19,11 +19,11 @@ // THE SOFTWARE. #pragma once +#include #include #include -#include #include -#include +#include #include #include diff --git a/src/kiwano/core/ObjectBase.cpp b/src/kiwano/core/ObjectBase.cpp index 9423407c..7fa059f2 100644 --- a/src/kiwano/core/ObjectBase.cpp +++ b/src/kiwano/core/ObjectBase.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include namespace kiwano diff --git a/src/kiwano/kiwano.h b/src/kiwano/kiwano.h index 92aa77fd..e7cb0773 100644 --- a/src/kiwano/kiwano.h +++ b/src/kiwano/kiwano.h @@ -52,11 +52,6 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include @@ -120,3 +115,8 @@ #include #include #include +#include +#include +#include +#include +#include diff --git a/src/kiwano/platform/Application.h b/src/kiwano/platform/Application.h index 6fe77c3c..5c2d4e87 100644 --- a/src/kiwano/platform/Application.h +++ b/src/kiwano/platform/Application.h @@ -23,11 +23,11 @@ #include #include #include -#include #include #include #include #include +#include namespace kiwano { diff --git a/src/kiwano/core/EventTicker.cpp b/src/kiwano/utils/EventTicker.cpp similarity index 97% rename from src/kiwano/core/EventTicker.cpp rename to src/kiwano/utils/EventTicker.cpp index b0872b41..f354f081 100644 --- a/src/kiwano/core/EventTicker.cpp +++ b/src/kiwano/utils/EventTicker.cpp @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include +#include namespace kiwano { diff --git a/src/kiwano/core/EventTicker.h b/src/kiwano/utils/EventTicker.h similarity index 98% rename from src/kiwano/core/EventTicker.h rename to src/kiwano/utils/EventTicker.h index 1f070edb..37ec50d1 100644 --- a/src/kiwano/core/EventTicker.h +++ b/src/kiwano/utils/EventTicker.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include +#include #include #include diff --git a/src/kiwano/core/Json.h b/src/kiwano/utils/Json.h similarity index 100% rename from src/kiwano/core/Json.h rename to src/kiwano/utils/Json.h diff --git a/src/kiwano/utils/ResourceCache.h b/src/kiwano/utils/ResourceCache.h index 6c40b938..e6aaa9e8 100644 --- a/src/kiwano/utils/ResourceCache.h +++ b/src/kiwano/utils/ResourceCache.h @@ -19,11 +19,11 @@ // THE SOFTWARE. #pragma once +#include +#include +#include #include #include -#include -#include -#include #include #include diff --git a/src/kiwano/core/Task.cpp b/src/kiwano/utils/Task.cpp similarity index 98% rename from src/kiwano/core/Task.cpp rename to src/kiwano/utils/Task.cpp index 430c6094..a1988735 100644 --- a/src/kiwano/core/Task.cpp +++ b/src/kiwano/utils/Task.cpp @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include +#include namespace kiwano { diff --git a/src/kiwano/core/Task.h b/src/kiwano/utils/Task.h similarity index 99% rename from src/kiwano/core/Task.h rename to src/kiwano/utils/Task.h index 9297d707..2fcce5f2 100644 --- a/src/kiwano/core/Task.h +++ b/src/kiwano/utils/Task.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include +#include #include namespace kiwano diff --git a/src/kiwano/core/TaskManager.cpp b/src/kiwano/utils/TaskManager.cpp similarity index 98% rename from src/kiwano/core/TaskManager.cpp rename to src/kiwano/utils/TaskManager.cpp index 740ef94a..36afa031 100644 --- a/src/kiwano/core/TaskManager.cpp +++ b/src/kiwano/utils/TaskManager.cpp @@ -19,7 +19,7 @@ // THE SOFTWARE. #include -#include +#include namespace kiwano { diff --git a/src/kiwano/core/TaskManager.h b/src/kiwano/utils/TaskManager.h similarity index 98% rename from src/kiwano/core/TaskManager.h rename to src/kiwano/utils/TaskManager.h index d71d975b..1d2c8669 100644 --- a/src/kiwano/core/TaskManager.h +++ b/src/kiwano/utils/TaskManager.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include +#include namespace kiwano { diff --git a/src/kiwano/core/Ticker.cpp b/src/kiwano/utils/Ticker.cpp similarity index 98% rename from src/kiwano/core/Ticker.cpp rename to src/kiwano/utils/Ticker.cpp index b3884cd8..c072f580 100644 --- a/src/kiwano/core/Ticker.cpp +++ b/src/kiwano/utils/Ticker.cpp @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include +#include namespace kiwano { diff --git a/src/kiwano/core/Ticker.h b/src/kiwano/utils/Ticker.h similarity index 99% rename from src/kiwano/core/Ticker.h rename to src/kiwano/utils/Ticker.h index a4663769..0fb86ab0 100644 --- a/src/kiwano/core/Ticker.h +++ b/src/kiwano/utils/Ticker.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include +#include namespace kiwano { diff --git a/src/kiwano/core/Timer.cpp b/src/kiwano/utils/Timer.cpp similarity index 98% rename from src/kiwano/core/Timer.cpp rename to src/kiwano/utils/Timer.cpp index aec2bb48..1c9ce5e2 100644 --- a/src/kiwano/core/Timer.cpp +++ b/src/kiwano/utils/Timer.cpp @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include +#include #include namespace kiwano diff --git a/src/kiwano/core/Timer.h b/src/kiwano/utils/Timer.h similarity index 100% rename from src/kiwano/core/Timer.h rename to src/kiwano/utils/Timer.h diff --git a/src/kiwano/core/Xml.h b/src/kiwano/utils/Xml.h similarity index 100% rename from src/kiwano/core/Xml.h rename to src/kiwano/utils/Xml.h From 6a8b2f528aefc45118fe9110972a659528529b06 Mon Sep 17 00:00:00 2001 From: Nomango Date: Thu, 21 May 2020 00:06:47 +0800 Subject: [PATCH 3/4] TaskManager => TaskScheduler, ActionManager => ActionScheduler --- projects/kiwano/kiwano.vcxproj | 8 +++---- projects/kiwano/kiwano.vcxproj.filters | 24 +++++++++---------- src/kiwano/2d/Actor.cpp | 4 ++-- src/kiwano/2d/Actor.h | 8 +++---- src/kiwano/2d/action/Action.h | 4 ++-- ...{ActionManager.cpp => ActionScheduler.cpp} | 17 ++++++------- .../{ActionManager.h => ActionScheduler.h} | 7 +++--- src/kiwano/kiwano.h | 4 ++-- src/kiwano/utils/Task.h | 4 ++-- .../{TaskManager.cpp => TaskScheduler.cpp} | 20 ++++++++-------- .../utils/{TaskManager.h => TaskScheduler.h} | 10 ++++---- 11 files changed, 55 insertions(+), 55 deletions(-) rename src/kiwano/2d/action/{ActionManager.cpp => ActionScheduler.cpp} (85%) rename src/kiwano/2d/action/{ActionManager.h => ActionScheduler.h} (94%) rename src/kiwano/utils/{TaskManager.cpp => TaskScheduler.cpp} (84%) rename src/kiwano/utils/{TaskManager.h => TaskScheduler.h} (94%) diff --git a/projects/kiwano/kiwano.vcxproj b/projects/kiwano/kiwano.vcxproj index 46c98312..d872159e 100644 --- a/projects/kiwano/kiwano.vcxproj +++ b/projects/kiwano/kiwano.vcxproj @@ -5,7 +5,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -175,7 +175,7 @@ - + diff --git a/projects/kiwano/kiwano.vcxproj.filters b/projects/kiwano/kiwano.vcxproj.filters index 8e32b171..43387c70 100644 --- a/projects/kiwano/kiwano.vcxproj.filters +++ b/projects/kiwano/kiwano.vcxproj.filters @@ -90,9 +90,6 @@ 2d\action - - 2d\action - 2d\action @@ -324,9 +321,6 @@ utils - - utils - utils @@ -336,6 +330,12 @@ utils + + utils + + + 2d\action + @@ -377,9 +377,6 @@ 2d\action - - 2d\action - 2d\action @@ -548,15 +545,18 @@ utils - - utils - utils utils + + utils + + + 2d\action + diff --git a/src/kiwano/2d/Actor.cpp b/src/kiwano/2d/Actor.cpp index 6e9a0340..85cc83c3 100644 --- a/src/kiwano/2d/Actor.cpp +++ b/src/kiwano/2d/Actor.cpp @@ -77,9 +77,9 @@ Actor::~Actor() void Actor::Update(Duration dt) { - UpdateActions(this, dt); + ActionScheduler::Update(this, dt); + TaskScheduler::Update(dt); UpdateComponents(dt); - UpdateTasks(dt); if (!update_pausing_) { diff --git a/src/kiwano/2d/Actor.h b/src/kiwano/2d/Actor.h index a1af5e8b..8ebc92d2 100644 --- a/src/kiwano/2d/Actor.h +++ b/src/kiwano/2d/Actor.h @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include namespace kiwano @@ -62,8 +62,8 @@ typedef IntrusiveList ActorList; */ class KGE_API Actor : public ObjectBase - , public TaskManager - , public ActionManager + , public TaskScheduler + , public ActionScheduler , public EventDispatcher , protected IntrusiveListValue { diff --git a/src/kiwano/2d/action/Action.h b/src/kiwano/2d/action/Action.h index f8d79e4a..8bc67bbb 100644 --- a/src/kiwano/2d/action/Action.h +++ b/src/kiwano/2d/action/Action.h @@ -30,7 +30,7 @@ namespace kiwano { class Actor; -class ActionManager; +class ActionScheduler; KGE_DECLARE_SMART_PTR(Action); @@ -55,7 +55,7 @@ class KGE_API Action , public Cloneable , protected IntrusiveListValue { - friend class ActionManager; + friend class ActionScheduler; friend class ActionGroup; friend IntrusiveList; diff --git a/src/kiwano/2d/action/ActionManager.cpp b/src/kiwano/2d/action/ActionScheduler.cpp similarity index 85% rename from src/kiwano/2d/action/ActionManager.cpp rename to src/kiwano/2d/action/ActionScheduler.cpp index 8c79bfe2..4d8b8765 100644 --- a/src/kiwano/2d/action/ActionManager.cpp +++ b/src/kiwano/2d/action/ActionScheduler.cpp @@ -19,12 +19,13 @@ // THE SOFTWARE. #include -#include +#include #include namespace kiwano { -void ActionManager::UpdateActions(Actor* target, Duration dt) + +void ActionScheduler::Update(Actor* target, Duration dt) { if (actions_.IsEmpty() || !target) return; @@ -42,7 +43,7 @@ void ActionManager::UpdateActions(Actor* target, Duration dt) } } -Action* ActionManager::AddAction(ActionPtr action) +Action* ActionScheduler::AddAction(ActionPtr action) { KGE_ASSERT(action && "AddAction failed, NULL pointer exception"); @@ -53,7 +54,7 @@ Action* ActionManager::AddAction(ActionPtr action) return action.Get(); } -void ActionManager::ResumeAllActions() +void ActionScheduler::ResumeAllActions() { if (actions_.IsEmpty()) return; @@ -64,7 +65,7 @@ void ActionManager::ResumeAllActions() } } -void ActionManager::PauseAllActions() +void ActionScheduler::PauseAllActions() { if (actions_.IsEmpty()) return; @@ -75,7 +76,7 @@ void ActionManager::PauseAllActions() } } -void ActionManager::StopAllActions() +void ActionScheduler::StopAllActions() { if (actions_.IsEmpty()) return; @@ -86,7 +87,7 @@ void ActionManager::StopAllActions() } } -ActionPtr ActionManager::GetAction(const String& name) +ActionPtr ActionScheduler::GetAction(const String& name) { if (actions_.IsEmpty()) return nullptr; @@ -97,7 +98,7 @@ ActionPtr ActionManager::GetAction(const String& name) return nullptr; } -const ActionList& ActionManager::GetAllActions() const +const ActionList& ActionScheduler::GetAllActions() const { return actions_; } diff --git a/src/kiwano/2d/action/ActionManager.h b/src/kiwano/2d/action/ActionScheduler.h similarity index 94% rename from src/kiwano/2d/action/ActionManager.h rename to src/kiwano/2d/action/ActionScheduler.h index 841a4611..34d37421 100644 --- a/src/kiwano/2d/action/ActionManager.h +++ b/src/kiwano/2d/action/ActionScheduler.h @@ -30,9 +30,9 @@ namespace kiwano /** * \~chinese - * @brief 动画管理器 + * @brief 动画调度器 */ -class KGE_API ActionManager +class KGE_API ActionScheduler { public: /// \~chinese @@ -60,10 +60,9 @@ public: /// @brief 获取所有动画 const ActionList& GetAllActions() const; -protected: /// \~chinese /// @brief 更新动画 - void UpdateActions(Actor* target, Duration dt); + void Update(Actor* target, Duration dt); private: ActionList actions_; diff --git a/src/kiwano/kiwano.h b/src/kiwano/kiwano.h index e7cb0773..86e32e0f 100644 --- a/src/kiwano/kiwano.h +++ b/src/kiwano/kiwano.h @@ -93,7 +93,7 @@ #include #include #include -#include +#include #include #include #include @@ -119,4 +119,4 @@ #include #include #include -#include +#include diff --git a/src/kiwano/utils/Task.h b/src/kiwano/utils/Task.h index 2fcce5f2..30e4b652 100644 --- a/src/kiwano/utils/Task.h +++ b/src/kiwano/utils/Task.h @@ -24,7 +24,7 @@ namespace kiwano { -class TaskManager; +class TaskScheduler; KGE_DECLARE_SMART_PTR(Task); @@ -39,7 +39,7 @@ class KGE_API Task : public ObjectBase , protected IntrusiveListValue { - friend class TaskManager; + friend class TaskScheduler; friend IntrusiveList; public: diff --git a/src/kiwano/utils/TaskManager.cpp b/src/kiwano/utils/TaskScheduler.cpp similarity index 84% rename from src/kiwano/utils/TaskManager.cpp rename to src/kiwano/utils/TaskScheduler.cpp index 36afa031..c06d88da 100644 --- a/src/kiwano/utils/TaskManager.cpp +++ b/src/kiwano/utils/TaskScheduler.cpp @@ -19,11 +19,11 @@ // THE SOFTWARE. #include -#include +#include namespace kiwano { -void TaskManager::UpdateTasks(Duration dt) +void TaskScheduler::Update(Duration dt) { if (tasks_.IsEmpty()) return; @@ -40,7 +40,7 @@ void TaskManager::UpdateTasks(Duration dt) } } -Task* TaskManager::AddTask(TaskPtr task) +Task* TaskScheduler::AddTask(TaskPtr task) { KGE_ASSERT(task && "AddTask failed, NULL pointer exception"); @@ -53,7 +53,7 @@ Task* TaskManager::AddTask(TaskPtr task) return task.Get(); } -void TaskManager::StopTasks(const String& name) +void TaskScheduler::StopTasks(const String& name) { if (tasks_.IsEmpty()) return; @@ -67,7 +67,7 @@ void TaskManager::StopTasks(const String& name) } } -void TaskManager::StartTasks(const String& name) +void TaskScheduler::StartTasks(const String& name) { if (tasks_.IsEmpty()) return; @@ -81,7 +81,7 @@ void TaskManager::StartTasks(const String& name) } } -void TaskManager::RemoveTasks(const String& name) +void TaskScheduler::RemoveTasks(const String& name) { if (tasks_.IsEmpty()) return; @@ -95,7 +95,7 @@ void TaskManager::RemoveTasks(const String& name) } } -void TaskManager::StopAllTasks() +void TaskScheduler::StopAllTasks() { if (tasks_.IsEmpty()) return; @@ -106,7 +106,7 @@ void TaskManager::StopAllTasks() } } -void TaskManager::StartAllTasks() +void TaskScheduler::StartAllTasks() { if (tasks_.IsEmpty()) return; @@ -117,12 +117,12 @@ void TaskManager::StartAllTasks() } } -void TaskManager::RemoveAllTasks() +void TaskScheduler::RemoveAllTasks() { tasks_.Clear(); } -const TaskList& TaskManager::GetAllTasks() const +const TaskList& TaskScheduler::GetAllTasks() const { return tasks_; } diff --git a/src/kiwano/utils/TaskManager.h b/src/kiwano/utils/TaskScheduler.h similarity index 94% rename from src/kiwano/utils/TaskManager.h rename to src/kiwano/utils/TaskScheduler.h index 1d2c8669..32ae2c33 100644 --- a/src/kiwano/utils/TaskManager.h +++ b/src/kiwano/utils/TaskScheduler.h @@ -25,9 +25,9 @@ namespace kiwano { /** * \~chinese - * @brief 任务管理器 + * @brief 任务调度器 */ -class KGE_API TaskManager +class KGE_API TaskScheduler { public: /// \~chinese @@ -62,12 +62,12 @@ public: /// @brief 获取所有任务 const TaskList& GetAllTasks() const; -protected: /// \~chinese - /// @brief 更新任务 - void UpdateTasks(Duration dt); + /// @brief 更新调度器 + void Update(Duration dt); private: TaskList tasks_; }; + } // namespace kiwano From fababdbe9b02b9f91e4af72e68ddc39fca0492e8 Mon Sep 17 00:00:00 2001 From: Nomango Date: Thu, 21 May 2020 00:32:43 +0800 Subject: [PATCH 4/4] minor fixes --- src/kiwano/utils/EventTicker.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kiwano/utils/EventTicker.h b/src/kiwano/utils/EventTicker.h index 37ec50d1..3fffff84 100644 --- a/src/kiwano/utils/EventTicker.h +++ b/src/kiwano/utils/EventTicker.h @@ -63,6 +63,8 @@ public: /// @param times 报时次数(设 -1 为永久) static EventTickerPtr Create(Duration interval, int times = -1); + using Ticker::Tick; + bool Tick(Duration dt) override; };