diff --git a/core/Base/Game.cpp b/core/Base/Game.cpp index 8fd4443b..4029d575 100644 --- a/core/Base/Game.cpp +++ b/core/Base/Game.cpp @@ -102,8 +102,6 @@ void e2d::Game::resume() if (_paused && !_ended) { Time::__reset(); - Timer::getInstance()->updateTime(); - ActionManager::getInstance()->updateTime(); } _paused = false; } diff --git a/core/Base/Time.cpp b/core/Base/Time.cpp index 7a1759e0..29ebc2fb 100644 --- a/core/Base/Time.cpp +++ b/core/Base/Time.cpp @@ -1,4 +1,6 @@ #include "..\e2dbase.h" +#include "..\e2dtool.h" +#include "..\e2dmanager.h" #include using namespace std::chrono; @@ -40,7 +42,6 @@ bool e2d::Time::__isReady() void e2d::Time::__updateNow() { - // 刷新时间 _now = steady_clock::now(); } @@ -55,6 +56,8 @@ void e2d::Time::__updateLast() void e2d::Time::__reset() { _last = _fixedLast = _now = steady_clock::now(); + Timer::getInstance()->updateTime(); + ActionManager::getInstance()->updateTime(); } void e2d::Time::__sleep() diff --git a/core/Base/Window.cpp b/core/Base/Window.cpp index ce4f7a9d..8087725f 100644 --- a/core/Base/Window.cpp +++ b/core/Base/Window.cpp @@ -319,10 +319,6 @@ void e2d::Window::setConsoleEnabled(bool enabled) HMENU hmenu = ::GetSystemMenu(hwnd, FALSE); ::RemoveMenu(hmenu, SC_CLOSE, MF_BYCOMMAND); } - else - { - this->error(L"Alloc Console Failed!"); - } } } else @@ -355,25 +351,33 @@ void e2d::Window::setTypewritingEnabled(bool enabled) } } -void e2d::Window::info(const String & text, const String & title) +bool e2d::Window::popup(const String & text, const String & title, PopupStyle style, bool hasCancel) { - Game::getInstance()->pause(); - ::MessageBox(_hWnd, (LPCWSTR)text, (LPCWSTR)title, MB_ICONINFORMATION | MB_OK); - Game::getInstance()->resume(); -} + UINT type = 0; + switch (style) + { + case e2d::Window::PopupStyle::Information: + type = MB_ICONINFORMATION; + break; + case e2d::Window::PopupStyle::Warning: + type = MB_ICONWARNING; + break; + case e2d::Window::PopupStyle::Error: + type = MB_ICONERROR; + break; + default: + break; + } -void e2d::Window::warning(const String& title, const String& text) -{ - Game::getInstance()->pause(); - ::MessageBox(_hWnd, (LPCWSTR)text, (LPCWSTR)title, MB_ICONWARNING | MB_OK); - Game::getInstance()->resume(); -} + if (hasCancel) + { + type |= MB_OKCANCEL; + } -void e2d::Window::error(const String & text, const String & title) -{ Game::getInstance()->pause(); - ::MessageBox(_hWnd, (LPCWSTR)text, (LPCWSTR)title, MB_ICONERROR | MB_OK); + int ret = ::MessageBox(_hWnd, (LPCWSTR)text, (LPCWSTR)title, type); Game::getInstance()->resume(); + return ret == IDOK; } diff --git a/core/e2dbase.h b/core/e2dbase.h index 9e91fca2..3f1f51b0 100644 --- a/core/e2dbase.h +++ b/core/e2dbase.h @@ -78,6 +78,14 @@ public: ArrowWait /* 默认指针和小沙漏 */ }; + // 弹窗样式 + enum class PopupStyle : int + { + Information, /* 信息 */ + Warning, /* 警告 */ + Error /* 错误 */ + }; + public: // 获取窗体实例 static Window * getInstance(); @@ -136,22 +144,12 @@ public: bool enabled ); - // 弹出提示窗口 - void info( - const String& text, /* 内容 */ - const String& title = L"Infomation" /* 窗口标题 */ - ); - - // 弹出警告窗口 - void warning( - const String& text, /* 内容 */ - const String& title = L"Warning" /* 窗口标题 */ - ); - - // 弹出错误窗口 - void error( - const String& text, /* 内容 */ - const String& title = L"Error" /* 窗口标题 */ + // 弹窗 + bool popup( + const String& text, /* 窗口内容 */ + const String& title, /* 窗口标题 */ + PopupStyle style = PopupStyle::Information, /* 弹窗样式 */ + bool hasCancel = false /* 包含取消按钮 */ ); // 处理窗体消息