2018-12-23 13:17:08 +01:00
|
|
|
#include <std_include.hpp>
|
|
|
|
#include "launcher.hpp"
|
2019-01-05 17:32:34 +01:00
|
|
|
#include "utils/nt.hpp"
|
2018-12-23 13:17:08 +01:00
|
|
|
|
2019-01-05 11:44:45 +01:00
|
|
|
launcher::launcher()
|
2018-12-23 13:17:08 +01:00
|
|
|
{
|
2019-01-05 23:34:46 +01:00
|
|
|
this->main_window_.register_callback("selectMode", [this](html_frame::callback_params* params)
|
2019-01-05 17:32:34 +01:00
|
|
|
{
|
|
|
|
if(params->arguments.empty()) return;
|
|
|
|
|
|
|
|
const auto param = params->arguments[0];
|
|
|
|
if(!param.is_number()) return;
|
|
|
|
|
|
|
|
const auto number = param.get_number();
|
|
|
|
if(number == singleplayer || number == multiplayer)
|
|
|
|
{
|
|
|
|
this->select_mode(static_cast<mode>(number));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-01-05 23:34:46 +01:00
|
|
|
this->main_window_.register_callback("showSettings", [this](html_frame::callback_params*)
|
|
|
|
{
|
|
|
|
this->settings_window_.show();
|
|
|
|
});
|
|
|
|
|
|
|
|
this->settings_window_.set_hide_on_close(true);
|
|
|
|
this->settings_window_.create("Open-IW5 Settings", 615, 300);
|
|
|
|
this->settings_window_.load_html(load_content(MENU_SETTINGS));
|
|
|
|
|
|
|
|
this->main_window_.set_close_all_on_close(true);
|
|
|
|
this->main_window_.create("Open-IW5", 615, 300);
|
|
|
|
this->main_window_.load_html(load_content(MENU_MAIN));
|
|
|
|
this->main_window_.show();
|
2018-12-23 13:17:08 +01:00
|
|
|
}
|
|
|
|
|
2018-12-23 18:25:22 +01:00
|
|
|
launcher::mode launcher::run() const
|
2018-12-23 13:17:08 +01:00
|
|
|
{
|
2019-01-05 23:34:46 +01:00
|
|
|
window::run();
|
2018-12-23 18:25:22 +01:00
|
|
|
|
|
|
|
return this->mode_;
|
|
|
|
}
|
|
|
|
|
2019-01-05 11:44:45 +01:00
|
|
|
|
2018-12-23 18:25:22 +01:00
|
|
|
|
|
|
|
void launcher::select_mode(const mode mode)
|
|
|
|
{
|
|
|
|
this->mode_ = mode;
|
2019-01-05 23:34:46 +01:00
|
|
|
this->settings_window_.close();
|
|
|
|
this->main_window_.close();
|
2018-12-23 18:25:22 +01:00
|
|
|
}
|
2019-01-05 17:32:34 +01:00
|
|
|
|
2019-01-05 23:34:46 +01:00
|
|
|
std::string launcher::load_content(int res)
|
2019-01-05 17:32:34 +01:00
|
|
|
{
|
2019-01-05 23:34:46 +01:00
|
|
|
const auto resource = FindResource(::utils::nt::module(), MAKEINTRESOURCE(res), RT_RCDATA);
|
2019-01-05 17:32:34 +01:00
|
|
|
if (!res) return {};
|
|
|
|
|
2019-01-05 23:34:46 +01:00
|
|
|
const auto handle = LoadResource(nullptr, resource);
|
2019-01-05 17:32:34 +01:00
|
|
|
if (!handle) return {};
|
|
|
|
|
2019-01-05 23:34:46 +01:00
|
|
|
return std::string(LPSTR(LockResource(handle)), SizeofResource(nullptr, resource));
|
2019-01-05 17:32:34 +01:00
|
|
|
}
|