Show correct icon to popup message dialog

This commit is contained in:
RadWolfie 2018-05-19 00:08:59 -05:00
parent 51fb5483e1
commit 093c9e20d2
5 changed files with 43 additions and 14 deletions

View File

@ -489,17 +489,38 @@ HANDLE CxbxRestorePageTablesMemory(char* szFilePath_page_tables)
#pragma optimize("", off)
void CxbxPopupMessage(const char *message, ...)
void CxbxPopupMessage(CxbxPopupMsgIcon icon, const char *message, ...)
{
char Buffer[1024];
va_list argp;
UINT uType = MB_OK | MB_TOPMOST | MB_SETFOREGROUND;
switch (icon) {
case CxbxMsgDlgIcon_Warn: {
uType |= MB_ICONWARNING;
break;
}
case CxbxMsgDlgIcon_Error: {
uType |= MB_ICONERROR;
break;
}
case CxbxMsgDlgIcon_Info: {
uType |= MB_ICONINFORMATION;
break;
}
case CxbxMsgDlgIcon_Unknown:
default: {
uType |= MB_ICONQUESTION;
break;
}
}
va_start(argp, message);
vsprintf(Buffer, message, argp);
va_end(argp);
EmuWarning("Popup : %s\n", Buffer);
MessageBox(NULL, Buffer, TEXT("Cxbx-Reloaded"), MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST | MB_SETFOREGROUND);
MessageBox(NULL, Buffer, TEXT("Cxbx-Reloaded"), uType);
}
void PrintCurrentConfigurationLog()
@ -882,14 +903,14 @@ void CxbxKrnlMain(int argc, char* argv[])
// verify base of code of our executable is 0x00001000
if (ExeNtHeader->OptionalHeader.BaseOfCode != CXBX_BASE_OF_CODE)
{
CxbxPopupMessage("Cxbx-Reloaded executuable requires it's base of code to be 0x00001000");
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "Cxbx-Reloaded executuable requires it's base of code to be 0x00001000");
return; // TODO : Halt(0);
}
// verify virtual_memory_placeholder is located at 0x00011000
if ((UINT_PTR)(&(virtual_memory_placeholder[0])) != (XBE_IMAGE_BASE + CXBX_BASE_OF_CODE))
{
CxbxPopupMessage("virtual_memory_placeholder is not loaded to base address 0x00011000 (which is a requirement for Xbox emulation)");
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "virtual_memory_placeholder is not loaded to base address 0x00011000 (which is a requirement for Xbox emulation)");
return; // TODO : Halt(0);
}
@ -930,7 +951,7 @@ void CxbxKrnlMain(int argc, char* argv[])
EEPROM = CxbxRestoreEEPROM(szFilePath_EEPROM_bin);
if (EEPROM == nullptr)
{
CxbxPopupMessage("Couldn't init EEPROM!");
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "Couldn't init EEPROM!");
return; // TODO : Halt(0);
}
@ -1450,7 +1471,7 @@ __declspec(noreturn) void CxbxKrnlCleanup(const char *szErrorMessage, ...)
vsprintf(szBuffer2, szErrorMessage, argp);
va_end(argp);
CxbxPopupMessage("Received Fatal Message:\n\n* %s\n", szBuffer2); // Will also DbgPrintf
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "Received Fatal Message:\n\n* %s\n", szBuffer2); // Will also DbgPrintf
}
printf("[0x%.4X] MAIN: Terminating Process\n", GetCurrentThreadId());
@ -1666,11 +1687,11 @@ void CxbxPrintUEMInfo(ULONG ErrorCode)
if (it != UEMErrorTable.end())
{
std::string ErrorMessage = "Fatal error. " + it->second + ". This error screen will persist indefinitely. Stop the emulation to close it";
CxbxPopupMessage(ErrorMessage.c_str());
CxbxPopupMessage(CxbxMsgDlgIcon_Error, ErrorMessage.c_str());
}
else
{
CxbxPopupMessage("Unknown fatal error. This error screen will persist indefinitely. Stop the emulation to close it");
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "Unknown fatal error. This error screen will persist indefinitely. Stop the emulation to close it");
}
}
@ -1716,4 +1737,4 @@ void UpdateFPSCounter()
g_Frames = 0;
g_DeltaTime -= CLOCKS_PER_SEC;
}
}
}

View File

@ -227,11 +227,19 @@ enum {
#define XBOX_MEM_NOZERO 0x800000 // Replaces MEM_ROTATE on WinXP+
#define XBOX_MEM_IMAGE 0x1000000 // ?
void CxbxPopupMessage(const char *message, ...);
typedef enum _CxbxMsgDlgIcon {
CxbxMsgDlgIcon_Info=0,
CxbxMsgDlgIcon_Warn,
CxbxMsgDlgIcon_Error,
CxbxMsgDlgIcon_Unknown
} CxbxPopupMsgIcon;
void CxbxPopupMessage(CxbxPopupMsgIcon icon, const char *message, ...);
#define LOG_TEST_CASE(message) do { static bool bPopupShown = false; \
if (!bPopupShown) { bPopupShown = true; \
CxbxPopupMessage("Please report that %s shows this test-case: %s\nIn %s (%s line %d)", \
CxbxPopupMessage(CxbxMsgDlgIcon_Info, "Please report that %s shows this test-case: %s\nIn %s (%s line %d)", \
CxbxKrnl_Xbe->m_szAsciiTitle, message, __func__, __FILE__, __LINE__); } } while(0)
// was g_pCertificate->wszTitleName

View File

@ -517,7 +517,7 @@ VOID XTL::CxbxInitWindow(bool bFullInit)
if (hRenderWindowThread == NULL) {
char szBuffer[1024] = { 0 };
sprintf(szBuffer, "Creating EmuRenderWindowThread Failed: %08X", GetLastError());
CxbxPopupMessage(szBuffer);
CxbxPopupMessage(CxbxMsgDlgIcon_Error, szBuffer);
EmuShared::Cleanup();
ExitProcess(0);
}

View File

@ -303,7 +303,7 @@ XBSYSAPI EXPORTNUM(264) xboxkrnl::VOID NTAPI xboxkrnl::RtlAssert
LOG_FUNC_ARG(Message)
LOG_FUNC_END;
CxbxPopupMessage("RtlAssert() raised by emulated program - consult Debug log");
CxbxPopupMessage(CxbxMsgDlgIcon_Warn, "RtlAssert() raised by emulated program - consult Debug log");
}
// ******************************************************************

View File

@ -216,7 +216,7 @@ bool TitleIsJSRF()
wcstombs(tAsciiTitle, g_pCertificate->wszTitleName, sizeof(tAsciiTitle));
if (_strnicmp(tAsciiTitle, "Jet Set Radio", 13) == 0) {
CxbxPopupMessage("Detected JSRF by name, not title ID, please report that [%08X] should be added to the list", g_pCertificate->dwTitleId);
CxbxPopupMessage(CxbxMsgDlgIcon_Info, "Detected JSRF by name, not title ID, please report that [%08X] should be added to the list", g_pCertificate->dwTitleId);
result = true;
}
}