Use custom assert to hide private file information

This commit is contained in:
Nomango 2019-08-18 18:33:44 +08:00
parent 253548dafe
commit cb19ce830d
6 changed files with 32 additions and 33 deletions

View File

@ -66,7 +66,7 @@ namespace kiwano
}
}
HRESULT Window::Create(String const& title, int width, int height, LPCWSTR icon, bool fullscreen, WNDPROC proc)
void Window::Init(String const& title, int width, int height, LPCWSTR icon, bool fullscreen, WNDPROC proc)
{
HINSTANCE hinst = GetModuleHandleW(nullptr);
WNDCLASSEX wcex = { 0 };
@ -157,16 +157,17 @@ namespace kiwano
if (handle_ == nullptr)
{
::UnregisterClass(KGE_WND_CLASS_NAME, hinst);
return HRESULT_FROM_WIN32(GetLastError());
ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError()));
}
else
{
RECT rc;
GetClientRect(handle_, &rc);
width_ = rc.right - rc.left;
height_ = rc.bottom - rc.top;
RECT rc;
GetClientRect(handle_, &rc);
width_ = rc.right - rc.left;
height_ = rc.bottom - rc.top;
SetMouseCursor(MouseCursor::Arrow);
return S_OK;
SetMouseCursor(MouseCursor::Arrow);
}
}
void Window::Prepare()

View File

@ -60,7 +60,7 @@ namespace kiwano
void SetMouseCursor(MouseCursor cursor);
public:
HRESULT Create(
void Init(
String const& title,
int width,
int height,

View File

@ -66,7 +66,7 @@ namespace kiwano
}
}
HRESULT Window::Create(String const& title, int width, int height, LPCWSTR icon, bool fullscreen, WNDPROC proc)
void Window::Init(String const& title, int width, int height, LPCWSTR icon, bool fullscreen, WNDPROC proc)
{
HINSTANCE hinst = GetModuleHandleW(nullptr);
WNDCLASSEX wcex = { 0 };
@ -157,16 +157,17 @@ namespace kiwano
if (handle_ == nullptr)
{
::UnregisterClass(KGE_WND_CLASS_NAME, hinst);
return HRESULT_FROM_WIN32(GetLastError());
ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError()));
}
else
{
RECT rc;
GetClientRect(handle_, &rc);
width_ = rc.right - rc.left;
height_ = rc.bottom - rc.top;
RECT rc;
GetClientRect(handle_, &rc);
width_ = rc.right - rc.left;
height_ = rc.bottom - rc.top;
SetMouseCursor(MouseCursor::Arrow);
return S_OK;
SetMouseCursor(MouseCursor::Arrow);
}
}
void Window::Prepare()

View File

@ -60,7 +60,7 @@ namespace kiwano
void SetMouseCursor(MouseCursor cursor);
public:
HRESULT Create(
void Init(
String const& title,
int width,
int height,

View File

@ -87,7 +87,7 @@
#ifndef KGE_ASSERT
# ifdef KGE_DEBUG
# define KGE_ASSERT(EXPR) assert(EXPR)
# define KGE_ASSERT(EXPR) do { (void)((!!(EXPR)) || (_wassert(_CRT_WIDE(#EXPR), _CRT_WIDE(__FUNCTION__), (unsigned)(__LINE__)), 0)); } while(0)
# else
# define KGE_ASSERT __noop
# endif

View File

@ -80,15 +80,13 @@ namespace kiwano
void Application::Init(const Options& options)
{
ThrowIfFailed(
Window::GetInstance()->Create(
options.title,
options.width,
options.height,
options.icon,
options.fullscreen,
Application::WndProc
)
Window::GetInstance()->Init(
options.title,
options.width,
options.height,
options.icon,
options.fullscreen,
Application::WndProc
);
Renderer::GetInstance()->SetClearColor(options.clear_color);
@ -122,10 +120,9 @@ namespace kiwano
void Application::Run()
{
HWND hwnd = Window::GetInstance()->GetHandle();
KGE_ASSERT(inited_ && "Calling Application::Run before Application::Init");
if (!inited_)
throw std::exception("Calling Application::Run before Application::Init");
HWND hwnd = Window::GetInstance()->GetHandle();
if (hwnd)
{