Add yes/no buttons to message box

This commit is contained in:
FutureRave 2022-02-10 14:41:51 +00:00
parent 333e2eb024
commit 8290cadbe9
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955

View File

@ -73,7 +73,7 @@ namespace Components
CloseClipboard(); CloseClipboard();
return; return;
} }
auto lock = GlobalLock(hMem); auto lock = GlobalLock(hMem);
if (lock != nullptr) if (lock != nullptr)
{ {
@ -102,15 +102,18 @@ namespace Components
} }
else else
{ {
errorStr = Utils::String::VA("Fatal error (0x%08X) at 0x%08X.", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress); errorStr = Utils::String::VA("Fatal error (0x%08X) at 0x%08X.\n Copy exception address to keyboard?", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
} }
//Exception::SuspendProcess(); //Exception::SuspendProcess();
Exception::CopyMessageToClipboard(Utils::String::VA("0x%08X", ExceptionInfo->ExceptionRecord->ExceptionAddress)); // Message should be copied to the keyboard if no button is pressed
MessageBoxA(nullptr, errorStr.data(), "ERROR", MB_ICONERROR); if (MessageBoxA(nullptr, errorStr.data(), nullptr, MB_YESNO | MB_ICONERROR) == IDYES)
{
Exception::CopyMessageToClipboard(Utils::String::VA("0x%08X", ExceptionInfo->ExceptionRecord->ExceptionAddress));
}
if ( Flags::HasFlag("bigminidumps")) if (Flags::HasFlag("bigminidumps"))
{ {
Exception::SetMiniDumpType(true, false); Exception::SetMiniDumpType(true, false);
} }
@ -201,20 +204,20 @@ namespace Components
#ifdef DEBUG #ifdef DEBUG
// Display DEBUG branding, so we know we're on a debug build // Display DEBUG branding, so we know we're on a debug build
Scheduler::OnFrame([]() Scheduler::OnFrame([]()
{
Game::Font_s* font = Game::R_RegisterFont("fonts/normalFont", 0);
float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
// Change the color when attaching a debugger
if (IsDebuggerPresent())
{ {
color[0] = 0.6588f; Game::Font_s* font = Game::R_RegisterFont("fonts/normalFont", 0);
color[1] = 1.0000f; float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
color[2] = 0.0000f;
}
Game::R_AddCmdDrawText("DEBUG-BUILD", 0x7FFFFFFF, font, 15.0f, 10.0f + Game::R_TextHeight(font), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED); // Change the color when attaching a debugger
}, true); if (IsDebuggerPresent())
{
color[0] = 0.6588f;
color[1] = 1.0000f;
color[2] = 0.0000f;
}
Game::R_AddCmdDrawText("DEBUG-BUILD", 0x7FFFFFFF, font, 15.0f, 10.0f + Game::R_TextHeight(font), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED);
}, true);
#endif #endif
#if !defined(DEBUG) || defined(FORCE_EXCEPTION_HANDLER) #if !defined(DEBUG) || defined(FORCE_EXCEPTION_HANDLER)
Exception::SetFilterHook.initialize(SetUnhandledExceptionFilter, Exception::SetUnhandledExceptionFilterStub, HOOK_JUMP); Exception::SetFilterHook.initialize(SetUnhandledExceptionFilter, Exception::SetUnhandledExceptionFilterStub, HOOK_JUMP);
@ -227,28 +230,28 @@ namespace Components
Utils::Hook(0x6B8898, Exception::LongJmp, HOOK_JUMP).install()->quick(); Utils::Hook(0x6B8898, Exception::LongJmp, HOOK_JUMP).install()->quick();
Command::Add("mapTest", [](Command::Params* params) Command::Add("mapTest", [](Command::Params* params)
{
Game::UI_UpdateArenas();
std::string command;
for (int i = 0; i < (params->length() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i)
{ {
char* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName; Game::UI_UpdateArenas();
if (!(i % 2)) command.append(Utils::String::VA("wait 250;disconnect;wait 750;", mapname)); // Test a disconnect std::string command;
else command.append(Utils::String::VA("wait 500;", mapname)); // Test direct map switch for (int i = 0; i < (params->length() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i)
command.append(Utils::String::VA("map %s;", mapname)); {
} char* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName;
Command::Execute(command, false); if (!(i % 2)) command.append(Utils::String::VA("wait 250;disconnect;wait 750;", mapname)); // Test a disconnect
}); else command.append(Utils::String::VA("wait 500;", mapname)); // Test direct map switch
command.append(Utils::String::VA("map %s;", mapname));
}
Command::Execute(command, false);
});
Command::Add("debug_exceptionhandler", [](Command::Params*) Command::Add("debug_exceptionhandler", [](Command::Params*)
{ {
Logger::Print("Rerunning SetUnhandledExceptionHandler...\n"); Logger::Print("Rerunning SetUnhandledExceptionHandler...\n");
auto oldHandler = Exception::Hook(); auto oldHandler = Exception::Hook();
Logger::Print("Old exception handler was 0x%010X.\n", oldHandler); Logger::Print("Old exception handler was 0x%010X.\n", oldHandler);
}); });
} }
Exception::~Exception() Exception::~Exception()