Optimize settings menu
This commit is contained in:
parent
a18364bfff
commit
ba38d467de
@ -19,7 +19,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
html_frame();
|
html_frame();
|
||||||
~html_frame();
|
virtual ~html_frame();
|
||||||
|
|
||||||
void initialize(const HWND window);
|
void initialize(const HWND window);
|
||||||
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#include <std_include.hpp>
|
#include <std_include.hpp>
|
||||||
#include "html_window.hpp"
|
#include "html_window.hpp"
|
||||||
|
|
||||||
html_window::html_window()
|
|
||||||
{
|
|
||||||
this->set_callback(std::bind(&html_window::handler, this, std::placeholders::_1, std::placeholders::_2,
|
|
||||||
std::placeholders::_3));
|
|
||||||
}
|
|
||||||
|
|
||||||
window* html_window::get_window()
|
window* html_window::get_window()
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
@ -17,7 +11,7 @@ html_frame* html_window::get_html_frame()
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT html_window::handler(const UINT message, const WPARAM w_param, const LPARAM l_param)
|
LRESULT html_window::processor(const UINT message, const WPARAM w_param, const LPARAM l_param)
|
||||||
{
|
{
|
||||||
if (message == WM_SIZE)
|
if (message == WM_SIZE)
|
||||||
{
|
{
|
||||||
@ -31,5 +25,5 @@ LRESULT html_window::handler(const UINT message, const WPARAM w_param, const LPA
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(*this, message, w_param, l_param);
|
return window::processor(message, w_param, l_param);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,11 @@
|
|||||||
class html_window final : public window, public html_frame
|
class html_window final : public window, public html_frame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
html_window();
|
|
||||||
~html_window() = default;
|
~html_window() = default;
|
||||||
|
|
||||||
window* get_window();
|
window* get_window();
|
||||||
html_frame* get_html_frame();
|
html_frame* get_html_frame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LRESULT handler(const UINT message, const WPARAM w_param, const LPARAM l_param);
|
LRESULT processor(UINT message, WPARAM w_param, LPARAM l_param) override;
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,12 @@
|
|||||||
#include "utils/nt.hpp"
|
#include "utils/nt.hpp"
|
||||||
|
|
||||||
launcher::launcher()
|
launcher::launcher()
|
||||||
|
{
|
||||||
|
this->create_settings_menu();
|
||||||
|
this->create_main_menu();
|
||||||
|
}
|
||||||
|
|
||||||
|
void launcher::create_main_menu()
|
||||||
{
|
{
|
||||||
this->main_window_.register_callback("selectMode", [this](html_frame::callback_params* params)
|
this->main_window_.register_callback("selectMode", [this](html_frame::callback_params* params)
|
||||||
{
|
{
|
||||||
@ -23,25 +29,44 @@ launcher::launcher()
|
|||||||
this->settings_window_.show();
|
this->settings_window_.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->settings_window_.set_hide_on_close(true);
|
this->main_window_.set_callback([](window* window, const UINT message, const WPARAM w_param, const LPARAM l_param) -> LRESULT
|
||||||
this->settings_window_.create("Open-IW5 Settings", 615, 300);
|
{
|
||||||
this->settings_window_.load_html(load_content(MENU_SETTINGS));
|
if(message == WM_CLOSE)
|
||||||
|
{
|
||||||
|
window::close_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProcA(*window, message, w_param, l_param);
|
||||||
|
});
|
||||||
|
|
||||||
this->main_window_.set_close_all_on_close(true);
|
|
||||||
this->main_window_.create("Open-IW5", 615, 300);
|
this->main_window_.create("Open-IW5", 615, 300);
|
||||||
this->main_window_.load_html(load_content(MENU_MAIN));
|
this->main_window_.load_html(load_content(MENU_MAIN));
|
||||||
this->main_window_.show();
|
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);
|
||||||
|
this->settings_window_.load_html(load_content(MENU_SETTINGS));
|
||||||
|
}
|
||||||
|
|
||||||
launcher::mode launcher::run() const
|
launcher::mode launcher::run() const
|
||||||
{
|
{
|
||||||
window::run();
|
window::run();
|
||||||
|
|
||||||
return this->mode_;
|
return this->mode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void launcher::select_mode(const mode mode)
|
void launcher::select_mode(const mode mode)
|
||||||
{
|
{
|
||||||
this->mode_ = mode;
|
this->mode_ = mode;
|
||||||
@ -49,9 +74,9 @@ void launcher::select_mode(const mode mode)
|
|||||||
this->main_window_.close();
|
this->main_window_.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string launcher::load_content(int res)
|
std::string launcher::load_content(const int res)
|
||||||
{
|
{
|
||||||
const auto resource = FindResource(::utils::nt::module(), MAKEINTRESOURCE(res), RT_RCDATA);
|
const auto resource = FindResource(utils::nt::module(), MAKEINTRESOURCE(res), RT_RCDATA);
|
||||||
if (!res) return {};
|
if (!res) return {};
|
||||||
|
|
||||||
const auto handle = LoadResource(nullptr, resource);
|
const auto handle = LoadResource(nullptr, resource);
|
||||||
|
@ -24,5 +24,8 @@ private:
|
|||||||
|
|
||||||
void select_mode(mode mode);
|
void select_mode(mode mode);
|
||||||
|
|
||||||
|
void create_main_menu();
|
||||||
|
void create_settings_menu();
|
||||||
|
|
||||||
static std::string load_content(int res);
|
static std::string load_content(int res);
|
||||||
};
|
};
|
||||||
|
@ -125,36 +125,13 @@ void window::hide() const
|
|||||||
UpdateWindow(this->handle_);
|
UpdateWindow(this->handle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void window::set_hide_on_close(const bool value)
|
void window::set_callback(const std::function<LRESULT(window*, UINT, WPARAM, LPARAM)>& callback)
|
||||||
{
|
|
||||||
this->hide_on_close_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void window::set_close_all_on_close(const bool value)
|
|
||||||
{
|
|
||||||
this->close_all_on_close_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void window::set_callback(const std::function<LRESULT(UINT, WPARAM, LPARAM)>& callback)
|
|
||||||
{
|
{
|
||||||
this->callback_ = callback;
|
this->callback_ = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK window::processor(const UINT message, const WPARAM w_param, const LPARAM l_param) const
|
LRESULT window::processor(const UINT message, const WPARAM w_param, const LPARAM l_param)
|
||||||
{
|
{
|
||||||
if (message == WM_CLOSE)
|
|
||||||
{
|
|
||||||
if (this->hide_on_close_)
|
|
||||||
{
|
|
||||||
this->hide();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else if (this->close_all_on_close_)
|
|
||||||
{
|
|
||||||
close_all();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message == WM_DESTROY)
|
if (message == WM_DESTROY)
|
||||||
{
|
{
|
||||||
remove_window(this);
|
remove_window(this);
|
||||||
@ -175,7 +152,7 @@ LRESULT CALLBACK window::processor(const UINT message, const WPARAM w_param, con
|
|||||||
|
|
||||||
if (this->callback_)
|
if (this->callback_)
|
||||||
{
|
{
|
||||||
return this->callback_(message, w_param, l_param);
|
return this->callback_(this, message, w_param, l_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(*this, message, w_param, l_param);
|
return DefWindowProc(*this, message, w_param, l_param);
|
||||||
|
@ -6,7 +6,7 @@ class window
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
window();
|
window();
|
||||||
~window();
|
virtual ~window();
|
||||||
|
|
||||||
void create(const std::string& title, int width, int height);
|
void create(const std::string& title, int width, int height);
|
||||||
|
|
||||||
@ -15,26 +15,22 @@ public:
|
|||||||
void show() const;
|
void show() const;
|
||||||
void hide() const;
|
void hide() const;
|
||||||
|
|
||||||
void set_hide_on_close(bool value);
|
void set_callback(const std::function<LRESULT(window*, UINT, WPARAM, LPARAM)>& callback);
|
||||||
void set_close_all_on_close(bool value);
|
|
||||||
|
|
||||||
void set_callback(const std::function<LRESULT(UINT, WPARAM, LPARAM)>& callback);
|
|
||||||
|
|
||||||
operator HWND() const;
|
operator HWND() const;
|
||||||
|
|
||||||
static void run();
|
static void run();
|
||||||
static void close_all();
|
static void close_all();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
bool hide_on_close_ = false;
|
virtual LRESULT processor(UINT message, WPARAM w_param, LPARAM l_param);
|
||||||
bool close_all_on_close_ = false;
|
|
||||||
|
|
||||||
|
private:
|
||||||
WNDCLASSEX wc_{};
|
WNDCLASSEX wc_{};
|
||||||
HWND handle_ = nullptr;
|
HWND handle_ = nullptr;
|
||||||
std::string classname_;
|
std::string classname_;
|
||||||
std::function<LRESULT(UINT, WPARAM, LPARAM)> callback_;
|
std::function<LRESULT(window*, UINT, WPARAM, LPARAM)> callback_;
|
||||||
|
|
||||||
LRESULT CALLBACK processor(UINT message, WPARAM w_param, LPARAM l_param) const;
|
|
||||||
static LRESULT CALLBACK static_processor(HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param);
|
static LRESULT CALLBACK static_processor(HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param);
|
||||||
|
|
||||||
static std::mutex mutex_;
|
static std::mutex mutex_;
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
transition: all 0.08s ease-out;
|
transition: all 0.08s ease-out;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: 0px 2px 40px 10px rgba(0, 0, 0, 0.3);
|
box-shadow: 0px 2px 30px 10px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.button>img:hover {
|
.button>img:hover {
|
||||||
|
@ -28,12 +28,16 @@
|
|||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<h1>No settings, yet!</h1>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user