new MsgHandler replacing common
Most things moved to macros git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1542 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
a46392f243
commit
b0f17043bd
|
@ -475,7 +475,7 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Common.cpp"
|
||||
RelativePath=".\Src\MsgHandler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static PanicAlertHandler panic_handler = 0;
|
||||
}
|
||||
|
||||
void RegisterPanicAlertHandler(PanicAlertHandler handler)
|
||||
{
|
||||
panic_handler = handler;
|
||||
}
|
||||
|
||||
void SuccessAlert(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
if (panic_handler)
|
||||
{
|
||||
char buffer[2048];
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
LOG(MASTER_LOG, "SUCCESS: %s", buffer);
|
||||
panic_handler(buffer, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char buffer[2048];
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
LOG(MASTER_LOG, "SUCCESS: %s", buffer);
|
||||
MessageBox(0, buffer, "SUCCESS!", MB_ICONWARNING);
|
||||
#elif __GNUC__
|
||||
//#error Do a messagebox!
|
||||
vprintf(format, args);
|
||||
printf("\n");
|
||||
// asm ("int $3") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void PanicAlert(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
if (panic_handler)
|
||||
{
|
||||
char buffer[2048];
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
LOG(MASTER_LOG, "PANIC: %s", buffer);
|
||||
panic_handler(buffer, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char buffer[2048];
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
LOG(MASTER_LOG, "PANIC: %s", buffer);
|
||||
MessageBox(0, buffer, "PANIC!", MB_ICONWARNING);
|
||||
#elif __GNUC__
|
||||
//#error Do a messagebox!
|
||||
vprintf(format, args);
|
||||
printf("\n");
|
||||
// asm ("int $3") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
bool PanicYesNo(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
bool retval;
|
||||
#ifdef _WIN32
|
||||
char buffer[2048];
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
LOG(MASTER_LOG, "PANIC: %s", buffer);
|
||||
retval = IDYES == MessageBox(0, buffer, "PANIC! Continue?", MB_ICONQUESTION | MB_YESNO);
|
||||
#elif __GNUC__
|
||||
//vprintf(format, args);
|
||||
return(true); //#error Do a messagebox!
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
||||
bool AskYesNo(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
bool retval;
|
||||
#ifdef _WIN32
|
||||
char buffer[2048];
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
LOG(MASTER_LOG, "ASK: %s", buffer);
|
||||
retval = IDYES == MessageBox(0, buffer, "Dolphin", MB_ICONQUESTION | MB_YESNO);
|
||||
#elif __GNUC__
|
||||
//vprintf(format, args);
|
||||
return(true); //#error Do a messagebox!
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
// Standard implementation of logging - simply print to standard output.
|
||||
// Programs are welcome to override this.
|
||||
/*
|
||||
void __Log(int logNumber, const char *text, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, text);
|
||||
vprintf(text, args);
|
||||
va_end(args);
|
||||
}*/
|
|
@ -190,15 +190,25 @@ inline u64 swap64(u64 data) {return(((u64)swap32(data) << 32) | swap32(data >> 3
|
|||
|
||||
// Utility functions
|
||||
|
||||
void PanicAlert(const char* text, ...);
|
||||
void SuccessAlert(const char* text, ...);
|
||||
bool PanicYesNo(const char* text, ...);
|
||||
bool AskYesNo(const char* text, ...);
|
||||
|
||||
// Msg Alert
|
||||
typedef bool (*MsgAlertHandler)(const char* caption, const char* text,
|
||||
bool yes_no);
|
||||
void RegisterMsgAlertHandler(MsgAlertHandler handler);
|
||||
extern bool MsgAlert(const char* caption, bool yes_no, const char* format, ...);
|
||||
#ifdef _WIN32
|
||||
#define SuccessAlert(format, ...) MsgAlert("SUCCESS", false, format, __VA_ARGS__)
|
||||
#define PanicAlert(format, ...) MsgAlert("PANIC", false, format, __VA_ARGS__)
|
||||
#define PanicYesNo(format, ...) MsgAlert("PANIC", true, format, __VA_ARGS__)
|
||||
#define AskYesNo(format, ...) MsgAlert("ASK", true, format, __VA_ARGS__)
|
||||
#else
|
||||
#define SuccessAlert(format, ...) MsgAlert("SUCCESS", false, format, ##__VA_ARGS__)
|
||||
#define PanicAlert(format, ...) MsgAlert("PANIC", false, format, ##__VA_ARGS__)
|
||||
#define PanicYesNo(format, ...) MsgAlert("PANIC", true, format, ##__VA_ARGS__)
|
||||
#define AskYesNo(format, ...) MsgAlert("ASK", true, format, ##__VA_ARGS__)
|
||||
#endif
|
||||
extern void __Log(int logNumber, const char* text, ...);
|
||||
extern void __Logv(int log, int v, const char *format, ...);
|
||||
|
||||
|
||||
// dummy class
|
||||
class LogTypes
|
||||
{
|
||||
|
@ -241,8 +251,6 @@ class LogTypes
|
|||
};
|
||||
};
|
||||
|
||||
typedef bool (*PanicAlertHandler)(const char* text, bool yes_no);
|
||||
void RegisterPanicAlertHandler(PanicAlertHandler handler);
|
||||
|
||||
void Host_UpdateLogDisplay();
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no);
|
||||
|
||||
static MsgAlertHandler msg_handler = DefaultMsgHandler;
|
||||
|
||||
void RegisterMsgAlertHandler(MsgAlertHandler handler) {
|
||||
msg_handler = handler;
|
||||
}
|
||||
|
||||
bool MsgAlert(const char* caption, bool yes_no,
|
||||
const char* format, ...) {
|
||||
|
||||
char buffer[2048];
|
||||
va_list args;
|
||||
bool ret = false;
|
||||
|
||||
va_start(args, format);
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
|
||||
LOG(MASTER_LOG, "%s: %s", caption, buffer);
|
||||
|
||||
if (msg_handler) {
|
||||
ret = msg_handler(caption, buffer, yes_no);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DefaultMsgHandler(const char* caption, const char* text,
|
||||
bool yes_no) {
|
||||
|
||||
#ifdef _WIN32
|
||||
if (yes_no)
|
||||
return IDYES == MessageBox(0, text, caption,
|
||||
MB_ICONQUESTION | MB_YESNO);
|
||||
else {
|
||||
MessageBox(0, text, caption, MB_ICONWARNING);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
printf("%s\n", text);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ Import('env')
|
|||
|
||||
files = [
|
||||
"ABI.cpp",
|
||||
"Common.cpp",
|
||||
"MsgHandler.cpp",
|
||||
"ChunkFile.cpp",
|
||||
"CPUDetect.cpp",
|
||||
"DynamicLibrary.cpp",
|
||||
|
|
|
@ -69,7 +69,7 @@ static const SPatch OSPatches[] =
|
|||
{ ".evil_vec_cosine", HLE_Misc::SMB_EvilVecCosine },
|
||||
{ ".evil_normalize", HLE_Misc::SMB_EvilNormalize },
|
||||
{ ".evil_vec_setlength", HLE_Misc::SMB_evil_vec_setlength },
|
||||
{ "PanicAlert", HLE_Misc::PanicAlert },
|
||||
{ "PanicAlert", HLE_Misc::HLEPanicAlert },
|
||||
{ ".sqrt_internal_needs_cr1", HLE_Misc::SMB_sqrt_internal },
|
||||
{ ".rsqrt_internal_needs_cr1", HLE_Misc::SMB_rsqrt_internal },
|
||||
{ ".atan2", HLE_Misc::SMB_atan2},
|
||||
|
|
|
@ -66,7 +66,7 @@ void GXPeekARGB()
|
|||
NPC = LR;
|
||||
}
|
||||
|
||||
void PanicAlert()
|
||||
void HLEPanicAlert()
|
||||
{
|
||||
::PanicAlert("HLE: PanicAlert %08x", LR);
|
||||
NPC = LR;
|
||||
|
|
|
@ -21,18 +21,18 @@
|
|||
namespace HLE_Misc
|
||||
{
|
||||
void Pass();
|
||||
void PanicAlert();
|
||||
void HLEPanicAlert();
|
||||
void UnimplementedFunction();
|
||||
void UnimplementedFunctionTrue();
|
||||
void UnimplementedFunctionFalse();
|
||||
void GXPeekZ();
|
||||
void GXPeekARGB();
|
||||
void SMB_EvilVecCosine();
|
||||
void SMB_EvilNormalize();
|
||||
void SMB_sqrt_internal();
|
||||
void SMB_rsqrt_internal();
|
||||
void SMB_atan2();
|
||||
void SMB_evil_vec_setlength();
|
||||
void GXPeekZ();
|
||||
void GXPeekARGB();
|
||||
void SMB_EvilVecCosine();
|
||||
void SMB_EvilNormalize();
|
||||
void SMB_sqrt_internal();
|
||||
void SMB_rsqrt_internal();
|
||||
void SMB_atan2();
|
||||
void SMB_evil_vec_setlength();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
IMPLEMENT_APP(DolphinApp)
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
bool wxPanicAlert(const char* text, bool /*yes_no*/);
|
||||
bool wxMsgAlert(const char*, const char*, bool);
|
||||
#endif
|
||||
|
||||
CFrame* main_frame = NULL;
|
||||
|
@ -92,7 +92,7 @@ bool DolphinApp::OnInit()
|
|||
#endif
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
RegisterPanicAlertHandler(&wxPanicAlert);
|
||||
RegisterMsgAlertHandler(&wxMsgAlert);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -264,10 +264,11 @@ void DolphinApp::OnEndSession()
|
|||
}
|
||||
|
||||
|
||||
bool wxPanicAlert(const char* text, bool /*yes_no*/)
|
||||
{
|
||||
wxMessageBox(wxString::FromAscii(text), _T("PANIC ALERT"));
|
||||
return(true);
|
||||
bool wxMsgAlert(const char* caption, const char* text,
|
||||
bool yes_no) {
|
||||
return wxYES == wxMessageBox(wxString::FromAscii(text),
|
||||
wxString::FromAscii(caption),
|
||||
(yes_no)?wxYES_NO:wxOK);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -364,7 +364,6 @@ void gdsp_stop()
|
|||
#include "Mixer.h"
|
||||
|
||||
uint16 r30 = 0, r31 = 0;
|
||||
void PanicAlert(const char* text, ...);
|
||||
extern WaveFileWriter g_wave_writer;
|
||||
|
||||
extern uint16 dsp_swap16(uint16 x);
|
||||
|
|
Loading…
Reference in New Issue