New launcher menu

This commit is contained in:
momo5502 2019-11-30 13:23:35 +01:00
parent 04fefe4003
commit 4778c5bda6
7 changed files with 389 additions and 175 deletions

View File

@ -108,7 +108,7 @@ HRESULT STDMETHODCALLTYPE doc_host_ui_handler::TranslateUrl(DWORD /*dwTranslate*
HRESULT doc_host_ui_handler::GetHostInfo(DOCHOSTUIINFO __RPC_FAR * pInfo)
{
pInfo->cbSize = sizeof(DOCHOSTUIINFO);
pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_DPI_AWARE | DOCHOSTUIFLAG_SCROLL_NO;
pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_DPI_AWARE /*| DOCHOSTUIFLAG_SCROLL_NO*/;
pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
return S_OK;

View File

@ -4,12 +4,22 @@
launcher::launcher()
{
this->create_settings_menu();
this->create_main_menu();
}
void launcher::create_main_menu()
{
this->main_window_.register_callback("openUrl", [](html_frame::callback_params* params)
{
if (params->arguments.empty()) return;
const auto param = params->arguments[0];
if (!param.is_string()) return;
const auto url = param.get_string();
ShellExecuteA(nullptr, "open", url.data(), nullptr, nullptr, SW_SHOWNORMAL);
});
this->main_window_.register_callback("selectMode", [this](html_frame::callback_params* params)
{
if (params->arguments.empty()) return;
@ -24,11 +34,6 @@ void launcher::create_main_menu()
}
});
this->main_window_.register_callback("showSettings", [this](html_frame::callback_params*)
{
this->settings_window_.show();
});
this->main_window_.set_callback(
[](window* window, const UINT message, const WPARAM w_param, const LPARAM l_param) -> LRESULT
{
@ -40,29 +45,11 @@ void launcher::create_main_menu()
return DefWindowProcA(*window, message, w_param, l_param);
});
this->main_window_.create("Open-IW5", 615, 300);
this->main_window_.create("Open-IW5", 750, 430);
this->main_window_.load_html(load_content(MENU_MAIN));
this->main_window_.show();
}
void launcher::create_settings_menu()
{
this->settings_window_.set_callback(
[](window* window, const UINT message, const WPARAM w_param, const LPARAM l_param) -> LRESULT
{
if (message == WM_CLOSE)
{
window->hide();
return TRUE;
}
return DefWindowProcA(*window, message, w_param, l_param);
});
this->settings_window_.create("Open-IW5 Settings", 400, 200, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU);
this->settings_window_.load_html(load_content(MENU_SETTINGS));
}
launcher::mode launcher::run() const
{
window::run();
@ -72,7 +59,6 @@ launcher::mode launcher::run() const
void launcher::select_mode(const mode mode)
{
this->mode_ = mode;
this->settings_window_.close();
this->main_window_.close();
}

View File

@ -20,12 +20,10 @@ private:
mode mode_ = none;
html_window main_window_;
html_window settings_window_;
void select_mode(mode mode);
void create_main_menu();
void create_settings_menu();
static std::string load_content(int res);
};

View File

@ -13,4 +13,3 @@
#define DW_IOTD_IMG 309
#define MENU_MAIN 310
#define MENU_SETTINGS 311

View File

@ -97,7 +97,6 @@ DW_IOTD_TXT RCDATA "resources/dw/iotd-english.txt"
DW_IOTD_IMG RCDATA "resources/dw/iotd-english.jpg"
MENU_MAIN RCDATA "resources/main.html"
MENU_SETTINGS RCDATA "resources/settings.html"
#endif // English (United States) resources

File diff suppressed because one or more lines are too long

View File

@ -1,44 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Open-IW5 Settings</title>
<style>
* {
user-select: none;
-ms-user-select: none;
cursor: default;
}
html,
body {
margin: 0;
background-color: #2D2D2D;
color: white;
font-family: "Segoe UI Light", "Segoe UI", "Lucida Sans", Arial, sans-serif;
font-style: normal;
font-weight: lighter;
width: 100%;
height: 100%;
overflow: hidden;
}
.content {
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<h3>No settings, yet!</h3>
</div>
</body>
</html>