add splash screen and setup remote debugger

This commit is contained in:
2019-05-15 02:35:11 +02:00
parent 5b26afa1a3
commit f890d580b0
8 changed files with 150 additions and 35 deletions

View File

@@ -578,6 +578,77 @@ void win32_save_window_state()
p.rcNormalPosition.top, p.rcNormalPosition.right, p.rcNormalPosition.bottom }));
}
LRESULT CALLBACK splash_proc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_INITDIALOG:
{
static char base_path[MAX_PATH];
GetCurrentDirectoryA(MAX_PATH, base_path);
std::string path = std::string(base_path) + "\\data\\splash.bmp";
auto hbitmap = (HBITMAP)LoadImageA(NULL, path.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SendMessage(GetDlgItem(hWndDlg, IDC_STATIC_IMAGE), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbitmap);
SetDlgItemText(hWndDlg, IDC_STATIC_VERSION, g_version_number_w);
auto monitor = MonitorFromWindow(0, MONITOR_DEFAULTTOPRIMARY);
auto x = unsigned{};
auto y = unsigned{};
GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &x, &y);
float z = (float)x / 96.f;
RECT r;
GetClientRect(hWndDlg, &r);
MoveWindow(GetDlgItem(hWndDlg, IDC_STATIC_IMAGE), 0, 0, 512 * z, 200 * z, TRUE);
SetWindowPos(hWndDlg, HWND_TOP, 0, 0, 512 * z, 200 * z, SWP_NOMOVE);
HWND hWndVersion = GetDlgItem(hWndDlg, IDC_STATIC_VERSION);
RECT rv;
GetClientRect(hWndVersion, &rv);
MoveWindow(hWndVersion, 0, 200 * z - (rv.bottom - rv.top), r.right - r.left, rv.bottom - rv.top, TRUE);
return TRUE;
}
case WM_USER + 1:
PostQuitMessage(0);
return TRUE;
}
return DefWindowProc(hWndDlg, Msg, wParam, lParam);;
}
HWND splash_dialog;
void splash_thread_loop()
{
splash_dialog = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SPLASH), NULL, reinterpret_cast<DLGPROC>(splash_proc));
MSG msg;
while (GetMessage(&msg, 0, 0, 0) > 0)
{
if (IsDialogMessage(splash_dialog, &msg))
{
DispatchMessage(&msg);
TranslateMessage(&msg);
}
}
DestroyWindow(splash_dialog);
}
BOOL UnadjustWindowRectEx(LPRECT prc, DWORD dwStyle, BOOL fMenu, DWORD dwExStyle)
{
RECT rc;
SetRectEmpty(&rc);
BOOL fRc = AdjustWindowRectEx(&rc, dwStyle, fMenu, dwExStyle);
if (fRc) {
prc->left -= rc.left;
prc->top -= rc.top;
prc->right -= rc.right;
prc->bottom -= rc.bottom;
}
return fRc;
}
int main(int argc, char** argv)
{
WNDCLASS wc;
@@ -587,17 +658,6 @@ int main(int argc, char** argv)
App::I.initLog();
init_vk_map();
/*
if (!App::I.check_license())
{
MessageBoxA(NULL, "Unable to verify this demo license, please make sure you are connected to Internet.",
"PanoPainter - License Error", MB_ICONERROR | MB_OK);
return -1;
}
*/
FILE* fp_check = fopen("data\\layout.xml", "rb");
if (!fp_check)
{
@@ -615,6 +675,9 @@ int main(int argc, char** argv)
LOG("data files ok");
}
std::thread dialog_thread(splash_thread_loop);
init_vk_map();
SetupExceptionHandler();
BT_SetTerminate();
@@ -647,6 +710,12 @@ int main(int argc, char** argv)
GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &x, &y);
App::I.zoom *= (float)x / 96.f;
int show_cmd = SW_NORMAL;
Settings::value<Serializer::Integer>("window-show-cmd", show_cmd);
DWORD wnd_style = WS_OVERLAPPEDWINDOW;
//if (show_cmd == SW_MAXIMIZE)
// wnd_style != WS_MAXIMIZE;
RECT clientRect = { 0, 0, (int)App::I.width * App::I.zoom, (int)App::I.height * App::I.zoom };
POINT clientPos = { CW_USEDEFAULT, CW_USEDEFAULT };
if (Settings::has("window-rect"))
@@ -659,9 +728,9 @@ int main(int argc, char** argv)
}
else
{
AdjustWindowRect(&clientRect, WS_OVERLAPPEDWINDOW, false);
AdjustWindowRect(&clientRect, wnd_style, false);
}
hWnd = CreateWindow(wc.lpszClassName, L"PanoPainter", WS_OVERLAPPEDWINDOW, clientPos.x, clientPos.y,
hWnd = CreateWindow(wc.lpszClassName, L"PanoPainter", wnd_style, clientPos.x, clientPos.y,
(float)(clientRect.right - clientRect.left),
(float)(clientRect.bottom - clientRect.top), 0, 0, hInst, 0);
@@ -723,7 +792,7 @@ int main(int argc, char** argv)
wglDeleteContext(hRC);
DestroyWindow(hWnd);
hWnd = CreateWindow(wc.lpszClassName, window_title, WS_OVERLAPPEDWINDOW, clientPos.x, clientPos.y,
hWnd = CreateWindow(wc.lpszClassName, window_title, wnd_style, clientPos.x, clientPos.y,
(float)(clientRect.right - clientRect.left),
(float)(clientRect.bottom - clientRect.top), 0, 0, hInst, 0);
@@ -767,12 +836,6 @@ int main(int argc, char** argv)
LOG("init app");
App::I.init();
int show_cmd = SW_NORMAL;
Settings::value<Serializer::Integer>("window-show-cmd", show_cmd);
LOG("show main window");
ShowWindow(hWnd, show_cmd);
if (!sandboxed)
{
LOG("init WinTab");
@@ -798,6 +861,7 @@ int main(int argc, char** argv)
const float target_tick_rate = 60;
unsigned long t0 = GetTickCount();
unsigned long t1;
bool first_frame = true;
int frames = 0;
float one_sec = 0;
float render_timer = 0;
@@ -850,6 +914,18 @@ int main(int argc, char** argv)
}
}
if (first_frame)
{
first_frame = false;
WINDOWPLACEMENT wp;
GetWindowPlacement(hWnd, &wp);
wp.showCmd = show_cmd;
SetWindowPlacement(hWnd, &wp);
// GetClientRect(hWnd, &clientRect);
// App::I.width = clientRect.right - clientRect.left;
// App::I.height = clientRect.bottom - clientRect.top;
}
App::I.tick(dt);
std::unique_lock<std::mutex> lock(render_mutex);
@@ -901,6 +977,14 @@ int main(int argc, char** argv)
if (start_in_vr)
App::I.vr_start();
LOG("show main window");
SetForegroundWindow(hWnd);
//ShowWindow(hWnd, show_cmd);
SendMessage(splash_dialog, WM_USER + 1, 0, 0);
if (dialog_thread.joinable())
dialog_thread.join();
MSG msg;
LOG("start main loop");
while (running == 1)
@@ -941,7 +1025,7 @@ int main(int argc, char** argv)
}
// Clean up
WacomTablet::I.terminate();
DestroyWindow(hWnd);
UnregisterClass(className, hInst);
LogRemote::I.stop();
}
@@ -958,21 +1042,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
switch (msg)
{
case WM_DESTROY:
if (running != -1)
{
running = 0;
render_cv.notify_all();
if (renderer.joinable())
renderer.join();
if (hmd_renderer.joinable())
hmd_renderer.join();
App::I.terminate();
}
break;
case WM_USER_CLOSE:
running = 0;
render_cv.notify_all();
if (renderer.joinable())
renderer.join();
if (hmd_renderer.joinable())
hmd_renderer.join();
App::I.terminate();
PostQuitMessage(0);
break;
return 0;
case WM_PAINT:
App::I.redraw = true;
break;
@@ -981,15 +1060,27 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
break;
case WM_CLOSE:
if (App::I.request_close())
{
running = 0;
render_cv.notify_all();
if (renderer.joinable())
renderer.join();
if (hmd_renderer.joinable())
hmd_renderer.join();
App::I.terminate();
PostQuitMessage(0);
return 0;
}
else
{
return true;
}
break;
case WM_SIZE:
{
auto w = (float)LOWORD(lp);
auto h = (float)HIWORD(lp);
if (h != 0)
if (h != 0 && running == 1)
{
async_locker lock;
App::I.resize(w, h);