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
This commit is contained in:
Glenn Rice 2011-07-15 14:49:34 +00:00
parent a154df1e7c
commit a5a45992ad
7 changed files with 36 additions and 17 deletions

View File

@ -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')

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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");

View File

@ -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)