From a5a45992ad1b842e6b605850574a2be6655cdd1c Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 15 Jul 2011 14:49:34 +0000 Subject: [PATCH] Add a new type of message box (CRITICAL style) which can not be disabled. Then use that message box to display shader compilation errors in the OpenGL backend to maintain consistency with the behaviour of the DirectX backends. Also fix the wxMessageAlert called from non-gui threads in the WXGTK build to use the passed caption. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7678 8ced0084-cf51-0410-be5f-012b33b47a6e --- Languages/gettextize | 4 ++-- Source/Core/Common/Src/MsgHandler.cpp | 7 +++++- Source/Core/Common/Src/MsgHandler.h | 3 +++ Source/Core/DolphinWX/Src/Frame.cpp | 10 +++++--- Source/Core/DolphinWX/Src/Main.cpp | 2 +- .../Plugin_VideoOGL/Src/PixelShaderCache.cpp | 23 ++++++++++++------- .../Plugin_VideoOGL/Src/TextureConverter.cpp | 4 ++-- 7 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Languages/gettextize b/Languages/gettextize index ac0212de0e..949c46f8df 100755 --- a/Languages/gettextize +++ b/Languages/gettextize @@ -6,8 +6,8 @@ CPP_FILE_LIST=$(find $SRCDIR \( -name '*.cpp' -o -name '*.h' -o -name '*.c' \) \ -a ! -path '*Debug*') xgettext -d dolphin-emu -s --keyword=_ --keyword=wxTRANSLATE --keyword=SuccessAlertT \ --keyword=PanicAlertT --keyword=PanicYesNoT --keyword=AskYesNoT --keyword=_trans \ - --add-comments=i18n -p ./Languages/po -o dolphin-emu.pot $CPP_FILE_LIST \ - --package-name="Dolphin Emu" + --keyword=CriticalAlertT --add-comments=i18n -p ./Languages/po -o dolphin-emu.pot \ + $CPP_FILE_LIST --package-name="Dolphin Emu" POTFILE=./Languages/po/dolphin-emu.pot PO_FILES=$(find ./Languages/po -name '*.po') diff --git a/Source/Core/Common/Src/MsgHandler.cpp b/Source/Core/Common/Src/MsgHandler.cpp index 9f980fedd2..3f68e1d29a 100644 --- a/Source/Core/Common/Src/MsgHandler.cpp +++ b/Source/Core/Common/Src/MsgHandler.cpp @@ -58,12 +58,14 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...) static std::string info_caption; static std::string warn_caption; static std::string ques_caption; + static std::string crit_caption; if (!info_caption.length()) { info_caption = str_translator(_trans("Information")); ques_caption = str_translator(_trans("Question")); warn_caption = str_translator(_trans("Warning")); + crit_caption = str_translator(_trans("Critical")); } switch(Style) @@ -77,6 +79,9 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...) case WARNING: caption = warn_caption; break; + case CRITICAL: + caption = crit_caption; + break; } va_list args; @@ -87,7 +92,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...) ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored - if (msg_handler && (AlertEnabled || Style == QUESTION)) + if (msg_handler && (AlertEnabled || Style == QUESTION || Style == CRITICAL)) return msg_handler(caption.c_str(), buffer, yes_no, Style); return true; diff --git a/Source/Core/Common/Src/MsgHandler.h b/Source/Core/Common/Src/MsgHandler.h index 0598a8b791..10635b4988 100644 --- a/Source/Core/Common/Src/MsgHandler.h +++ b/Source/Core/Common/Src/MsgHandler.h @@ -26,6 +26,7 @@ enum MSG_TYPE INFORMATION, QUESTION, WARNING, + CRITICAL }; typedef bool (*MsgAlertHandler)(const char* caption, const char* text, @@ -58,11 +59,13 @@ void SetEnableAlert(bool enable); #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__) #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__) #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) + #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) // Use these macros (that do the same thing) if the message should be translated. #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__) #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__) #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__) #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) + #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) #endif #else // GEKKO diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 87eef2fa7c..28e9bbfebd 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -642,9 +642,13 @@ void CFrame::OnHostMessage(wxCommandEvent& event) #ifdef __WXGTK__ case IDM_PANIC: - bPanicResult = (wxYES == wxMessageBox(event.GetString(), - _("Warning"), event.GetInt() ? wxYES_NO : wxOK, wxGetActiveWindow())); - panic_event.Set(); + { + wxString caption = event.GetString().BeforeFirst(':'); + wxString text = event.GetString().AfterFirst(':'); + bPanicResult = (wxYES == wxMessageBox(text, + caption, event.GetInt() ? wxYES_NO : wxOK, wxGetActiveWindow())); + panic_event.Set(); + } break; #endif diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index ed97ca9154..fc6ef09695 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -416,7 +416,7 @@ bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style* else { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_PANIC); - event.SetString(wxString::FromUTF8(text)); + event.SetString(wxString::FromUTF8(caption) + wxT(":") + wxString::FromUTF8(text)); event.SetInt(yes_no); main_frame->GetEventHandler()->AddPendingEvent(event); main_frame->panic_event.Wait(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index 32b18b9985..abde68f1db 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -255,25 +255,32 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgfProf, "main", opts); // handle errors - if (!cgIsProgram(tempprog)) { - cgDestroyProgram(tempprog); - ERROR_LOG(VIDEO, "Failed to compile ps %s:", cgGetLastListing(g_cgcontext)); - ERROR_LOG(VIDEO, "%s", pstrprogram); - return false; + if (!cgIsProgram(tempprog)) + { + cgDestroyProgram(tempprog); + if (g_ActiveConfig.bShowShaderErrors) + { + std::string message = cgGetLastListing(g_cgcontext); + message += "\n\n"; + message += pstrprogram; + CriticalAlertT("Failed to compile ps %s", message.c_str()); + } + return false; } // handle warnings if (cgGetError() != CG_NO_ERROR) { - WARN_LOG(VIDEO, "Warnings on compile ps %s:", cgGetLastListing(g_cgcontext)); - WARN_LOG(VIDEO, "%s", pstrprogram); + WARN_LOG(VIDEO, "Warnings on compile ps %s:", cgGetLastListing(g_cgcontext)); + WARN_LOG(VIDEO, "%s", pstrprogram); } // This looks evil - we modify the program through the const char * we got from cgGetProgramString! // It SHOULD not have any nasty side effects though - but you never know... char *pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM); char *plocal = strstr(pcompiledprog, "program.local"); - while (plocal != NULL) { + while (plocal != NULL) + { const char *penv = " program.env"; memcpy(plocal, penv, 13); plocal = strstr(plocal+13, "program.local"); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp index b1c68bb06b..c715775194 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp @@ -78,7 +78,7 @@ void CreateRgbToYuyvProgram() "}\n"; if (!PixelShaderCache::CompilePixelShader(s_rgbToYuyvProgram, FProgram)) - PanicAlertT("Failed to create RGB to YUYV fragment program\nReport this issue."); + ERROR_LOG(VIDEO, "Failed to create RGB to YUYV fragment program."); } void CreateYuyvToRgbProgram() @@ -104,7 +104,7 @@ void CreateYuyvToRgbProgram() "}\n"; if (!PixelShaderCache::CompilePixelShader(s_yuyvToRgbProgram, FProgram)) - PanicAlertT("Failed to create YUYV to RGB fragment program\nReport this issue."); + ERROR_LOG(VIDEO, "Failed to create YUYV to RGB fragment program."); } FRAGMENTSHADER &GetOrCreateEncodingShader(u32 format)