From 77d469ddb509439a7b3de517354c6e9a8cce121b Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Wed, 10 Jun 2020 00:18:06 -0500 Subject: [PATCH] suppress popups while in exclusive fullscreen mode --- src/common/Logging.cpp | 14 +++++++++++++- src/common/Logging.h | 9 +++++++-- src/core/kernel/init/CxbxKrnl.cpp | 3 +++ src/core/kernel/support/Emu.cpp | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/common/Logging.cpp b/src/common/Logging.cpp index 8e4814bf0..89fc40bf1 100644 --- a/src/common/Logging.cpp +++ b/src/common/Logging.cpp @@ -103,6 +103,7 @@ const char* g_EnumModules2String[to_underlying(CXBXR_MODULE::MAX)] = { }; std::atomic_int g_CurrentLogLevel = to_underlying(LOG_LEVEL::INFO); std::atomic_bool g_CurrentLogPopupTestcase = true; +static bool g_bFullScreen = false; const char log_debug[] = "DEBUG: "; const char log_info[] = "INFO : "; @@ -230,10 +231,21 @@ void log_generate_active_filter_output(const CXBXR_MODULE cxbxr_module) } } std::cout << std::flush; +} + +// Use kernel managed environment +void log_init_popup_msg() +{ + Settings::s_video vSettings; + g_EmuShared->GetVideoSettings(&vSettings); + g_bFullScreen = vSettings.bFullScreen; } -int CxbxMessageBox(const char* msg, UINT uType, HWND hWnd) +int CxbxMessageBox(const char* msg, UINT uType, HWND hWnd, int default_return) { + if (g_bFullScreen) { + return default_return; + } return MessageBox(hWnd, msg, /*lpCaption=*/TEXT("Cxbx-Reloaded"), uType); } diff --git a/src/common/Logging.h b/src/common/Logging.h index 2a4df8d8d..b2d47f442 100644 --- a/src/common/Logging.h +++ b/src/common/Logging.h @@ -130,7 +130,12 @@ extern inline void log_sync_config(); void log_set_config(int LogLevel, unsigned int* LoggedModules, bool LogPopupTestcase); -void log_generate_active_filter_output(const CXBXR_MODULE cxbxr_module); +void log_generate_active_filter_output(const CXBXR_MODULE cxbxr_module); + +// Use emulation environment to manage popup messages +// If log_init_popup_msg is not called at earliest point of emulation. +// Then users will have a chance of popup message appear during start of emulation in full screen. +void log_init_popup_msg(); typedef enum class _CxbxMsgDlgIcon { Info = 0, @@ -139,7 +144,7 @@ typedef enum class _CxbxMsgDlgIcon { Unknown } CxbxMsgDlgIcon; -int CxbxMessageBox(const char* msg, UINT uType = MB_OK, HWND hWnd = NULL); +int CxbxMessageBox(const char* msg, UINT uType = MB_OK, HWND hWnd = NULL, int default_return = IDCANCEL); void CxbxShowError(const char* msg, HWND hWnd = NULL); diff --git a/src/core/kernel/init/CxbxKrnl.cpp b/src/core/kernel/init/CxbxKrnl.cpp index 08ea9ec2e..b6a3469b5 100644 --- a/src/core/kernel/init/CxbxKrnl.cpp +++ b/src/core/kernel/init/CxbxKrnl.cpp @@ -686,6 +686,9 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res //g_EmuShared->SetIsReady(true); } + /* Initialize popup message management from kernel side. */ + log_init_popup_msg(); + /* Initialize Cxbx File Paths */ CxbxInitFilePaths(); diff --git a/src/core/kernel/support/Emu.cpp b/src/core/kernel/support/Emu.cpp index 1a6b9a0df..e7e0bb16c 100644 --- a/src/core/kernel/support/Emu.cpp +++ b/src/core/kernel/support/Emu.cpp @@ -201,7 +201,7 @@ void EmuExceptionNonBreakpointUnhandledShow(LPEXCEPTION_POINTERS e) " Press \"Cancel\" to debug.", e->ExceptionRecord->ExceptionCode, EIPToString(e->ContextRecord->Eip).c_str()); - if (CxbxMessageBox(buffer, MB_ICONSTOP | MB_OKCANCEL, g_hEmuWindow) == IDOK) + if (CxbxMessageBox(buffer, MB_ICONSTOP | MB_OKCANCEL, g_hEmuWindow, IDOK) == IDOK) { EmuExceptionExitProcess(); }