修改弹窗函数
This commit is contained in:
parent
767a5da6c1
commit
02bb68f21f
|
|
@ -102,8 +102,6 @@ void e2d::Game::resume()
|
|||
if (_paused && !_ended)
|
||||
{
|
||||
Time::__reset();
|
||||
Timer::getInstance()->updateTime();
|
||||
ActionManager::getInstance()->updateTime();
|
||||
}
|
||||
_paused = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "..\e2dbase.h"
|
||||
#include "..\e2dtool.h"
|
||||
#include "..\e2dmanager.h"
|
||||
#include <thread>
|
||||
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 /* 包含取消按钮 */
|
||||
);
|
||||
|
||||
// 处理窗体消息
|
||||
|
|
|
|||
Loading…
Reference in New Issue