feat(Console): Disable close button and handle close signal

This commit is contained in:
Yimura 2021-05-21 02:28:42 +02:00
parent 7006e55558
commit 6c622152eb
2 changed files with 13 additions and 1 deletions

View File

@ -59,7 +59,7 @@ namespace big
if ((m_console_handle = GetStdHandle(STD_OUTPUT_HANDLE)) != nullptr)
{
SetConsoleTitleA("BigBaseV2");
SetConsoleTitleA("Yim's Mod Menu");
SetConsoleOutputCP(CP_UTF8);
m_console_out.open("CONOUT$", std::ios_base::out | std::ios_base::app);

View File

@ -8,6 +8,15 @@
#include "renderer.hpp"
#include "script_mgr.hpp"
BOOL WINAPI ctrl_handler(DWORD event)
{
LOG(INFO) << "Received close signal, unloading menu.";
g_running = false;
return true;
}
BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
{
using namespace big;
@ -23,6 +32,9 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
std::this_thread::sleep_for(1s);
auto logger_instance = std::make_unique<logger>();
SetConsoleCtrlHandler(ctrl_handler, TRUE);
DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND);
try
{
LOG(RAW_GREEN_TO_CONSOLE) << u8R"kek(