Clean html components
This commit is contained in:
parent
ba38d467de
commit
fa76233e1f
@ -3,7 +3,6 @@
|
||||
|
||||
html_argument::html_argument(VARIANT* val) : value_(val)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool html_argument::is_empty() const
|
||||
@ -13,25 +12,25 @@ bool html_argument::is_empty() const
|
||||
|
||||
bool html_argument::is_string() const
|
||||
{
|
||||
if(this->is_empty()) return false;
|
||||
if (this->is_empty()) return false;
|
||||
return this->value_->vt == VT_BSTR;
|
||||
}
|
||||
|
||||
bool html_argument::is_number() const
|
||||
{
|
||||
if(this->is_empty()) return false;
|
||||
if (this->is_empty()) return false;
|
||||
return this->value_->vt == VT_I4;
|
||||
}
|
||||
|
||||
std::string html_argument::get_string() const
|
||||
{
|
||||
if(!this->is_string()) return {};
|
||||
if (!this->is_string()) return {};
|
||||
std::wstring wide_string(this->value_->bstrVal);
|
||||
return std::string(wide_string.begin(), wide_string.end());
|
||||
}
|
||||
|
||||
int html_argument::get_number() const
|
||||
{
|
||||
if(!this->is_number()) return 0;
|
||||
if (!this->is_number()) return 0;
|
||||
return this->value_->intVal;
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
class html_argument final
|
||||
{
|
||||
public:
|
||||
html_argument(VARIANT* val);
|
||||
class html_argument final
|
||||
{
|
||||
public:
|
||||
html_argument(VARIANT* val);
|
||||
|
||||
bool is_empty() const;
|
||||
bool is_empty() const;
|
||||
|
||||
bool is_string() const;
|
||||
bool is_number() const;
|
||||
bool is_string() const;
|
||||
bool is_number() const;
|
||||
|
||||
std::string get_string() const;
|
||||
int get_number() const;
|
||||
std::string get_string() const;
|
||||
int get_number() const;
|
||||
|
||||
private:
|
||||
VARIANT* value_;
|
||||
};
|
||||
private:
|
||||
VARIANT* value_;
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ HRESULT html_dispatch::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
|
||||
|
||||
HRESULT html_dispatch::GetIDsOfNames(const IID& riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
|
||||
{
|
||||
for(unsigned int i = 0; i < cNames; ++i)
|
||||
for (unsigned int i = 0; i < cNames; ++i)
|
||||
{
|
||||
std::wstring wide_name(rgszNames[i]);
|
||||
std::string name(wide_name.begin(), wide_name.end());
|
||||
@ -53,7 +53,7 @@ HRESULT html_dispatch::GetIDsOfNames(const IID& riid, LPOLESTR* rgszNames, UINT
|
||||
}
|
||||
|
||||
HRESULT html_dispatch::Invoke(DISPID dispIdMember, const IID& riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
|
||||
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
|
||||
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
|
||||
{
|
||||
html_frame::callback_params params(pDispParams, pVarResult);
|
||||
this->frame_->invoke_callback(dispIdMember, ¶ms);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "window.hpp"
|
||||
#include "html/html_frame.hpp"
|
||||
#include "../window.hpp"
|
||||
#include "html_frame.hpp"
|
||||
|
||||
class html_window final : public window, public html_frame
|
||||
{
|
@ -12,13 +12,13 @@ void launcher::create_main_menu()
|
||||
{
|
||||
this->main_window_.register_callback("selectMode", [this](html_frame::callback_params* params)
|
||||
{
|
||||
if(params->arguments.empty()) return;
|
||||
if (params->arguments.empty()) return;
|
||||
|
||||
const auto param = params->arguments[0];
|
||||
if(!param.is_number()) return;
|
||||
if (!param.is_number()) return;
|
||||
|
||||
const auto number = param.get_number();
|
||||
if(number == singleplayer || number == multiplayer)
|
||||
if (number == singleplayer || number == multiplayer)
|
||||
{
|
||||
this->select_mode(static_cast<mode>(number));
|
||||
}
|
||||
@ -29,15 +29,16 @@ void launcher::create_main_menu()
|
||||
this->settings_window_.show();
|
||||
});
|
||||
|
||||
this->main_window_.set_callback([](window* window, const UINT message, const WPARAM w_param, const LPARAM l_param) -> LRESULT
|
||||
{
|
||||
if(message == WM_CLOSE)
|
||||
this->main_window_.set_callback(
|
||||
[](window* window, const UINT message, const WPARAM w_param, const LPARAM l_param) -> LRESULT
|
||||
{
|
||||
window::close_all();
|
||||
}
|
||||
if (message == WM_CLOSE)
|
||||
{
|
||||
window::close_all();
|
||||
}
|
||||
|
||||
return DefWindowProcA(*window, message, w_param, l_param);
|
||||
});
|
||||
return DefWindowProcA(*window, message, w_param, l_param);
|
||||
});
|
||||
|
||||
this->main_window_.create("Open-IW5", 615, 300);
|
||||
this->main_window_.load_html(load_content(MENU_MAIN));
|
||||
@ -46,18 +47,20 @@ void launcher::create_main_menu()
|
||||
|
||||
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)
|
||||
this->settings_window_.set_callback(
|
||||
[](window* window, const UINT message, const WPARAM w_param, const LPARAM l_param) -> LRESULT
|
||||
{
|
||||
window->hide();
|
||||
return TRUE;
|
||||
}
|
||||
if (message == WM_CLOSE)
|
||||
{
|
||||
window->hide();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return DefWindowProcA(*window, message, w_param, l_param);
|
||||
});
|
||||
return DefWindowProcA(*window, message, w_param, l_param);
|
||||
});
|
||||
|
||||
this->settings_window_.create("Open-IW5 Settings", 400, 200);
|
||||
this->settings_window_.create("Open-IW5 Settings", 400, 200,
|
||||
WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
|
||||
this->settings_window_.load_html(load_content(MENU_SETTINGS));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "html_window.hpp"
|
||||
#include "html/html_window.hpp"
|
||||
|
||||
class launcher final
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ window::window()
|
||||
RegisterClassEx(&this->wc_);
|
||||
}
|
||||
|
||||
void window::create(const std::string& title, const int width, const int height)
|
||||
void window::create(const std::string& title, const int width, const int height, const long flags)
|
||||
{
|
||||
{
|
||||
std::lock_guard _(mutex_);
|
||||
@ -32,9 +32,8 @@ void window::create(const std::string& title, const int width, const int height)
|
||||
const auto x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2;
|
||||
const auto y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2;
|
||||
|
||||
this->handle_ = CreateWindowExA(NULL, this->wc_.lpszClassName, title.data(),
|
||||
WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), x, y, width,
|
||||
height, nullptr, nullptr, this->wc_.hInstance, this);
|
||||
this->handle_ = CreateWindowExA(NULL, this->wc_.lpszClassName, title.data(), flags, x, y, width, height, nullptr,
|
||||
nullptr, this->wc_.hInstance, this);
|
||||
}
|
||||
|
||||
window::~window()
|
||||
|
@ -8,7 +8,8 @@ public:
|
||||
window();
|
||||
virtual ~window();
|
||||
|
||||
void create(const std::string& title, int width, int height);
|
||||
void create(const std::string& title, int width, int height,
|
||||
long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX)));
|
||||
|
||||
void close();
|
||||
|
||||
|
@ -39,8 +39,9 @@
|
||||
|
||||
.button>span {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
font-size: 20px;
|
||||
margin-top: -15px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
.button>img {
|
||||
@ -73,17 +74,17 @@
|
||||
|
||||
#settings {
|
||||
position: fixed;
|
||||
right: 3px;
|
||||
top: 3px;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
cursor:pointer;
|
||||
opacity: 0.1;
|
||||
transition: all 0.08s ease-out;
|
||||
transition: all 0.1s ease-out;
|
||||
}
|
||||
|
||||
#settings:hover {
|
||||
opacity: 0.4;
|
||||
opacity: 0.3;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
Loading…
Reference in New Issue
Block a user