- add platform independent message dialog;
This commit is contained in:
parent
09c8027d69
commit
be8d5288ee
|
@ -52,3 +52,42 @@ char *removeSpecialChars(char *s)
|
|||
*buf = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
// ===============================================================================
|
||||
// Message dialogs
|
||||
// ===============================================================================
|
||||
#define MSG_PRINT { \
|
||||
va_list args; \
|
||||
va_start (args, fmt); \
|
||||
vprintf (fmt, args); \
|
||||
va_end (args); \
|
||||
}
|
||||
void msgFakeInfo(const char *fmt, ...)
|
||||
{
|
||||
MSG_PRINT;
|
||||
}
|
||||
|
||||
bool msgFakeConfirm(const char *fmt, ...)
|
||||
{
|
||||
MSG_PRINT;
|
||||
return true;
|
||||
}
|
||||
|
||||
void msgFakeError(const char *fmt, ...)
|
||||
{
|
||||
MSG_PRINT;
|
||||
}
|
||||
|
||||
void msgFakeWarn(const char *fmt, ...)
|
||||
{
|
||||
MSG_PRINT;
|
||||
}
|
||||
|
||||
msgBoxInterface msgBoxFake = {
|
||||
msgFakeInfo,
|
||||
msgFakeConfirm,
|
||||
msgFakeError,
|
||||
msgFakeWarn,
|
||||
};
|
||||
|
||||
msgBoxInterface *msgbox = &msgBoxFake;
|
||||
|
|
|
@ -82,5 +82,19 @@ char *intToBin(T val)
|
|||
extern char *trim(char *s, int len=-1);
|
||||
extern char *removeSpecialChars(char *s);
|
||||
|
||||
// ===============================================================================
|
||||
// Message dialogs
|
||||
// ===============================================================================
|
||||
#define CALL_CONVENTION
|
||||
typedef struct
|
||||
{
|
||||
void (CALL_CONVENTION* info) (const char *fmt, ...);
|
||||
bool (CALL_CONVENTION* confirm)(const char *fmt, ...);
|
||||
void (CALL_CONVENTION* error) (const char *fmt, ...);
|
||||
void (CALL_CONVENTION* warn) (const char *fmt, ...);
|
||||
} msgBoxInterface;
|
||||
|
||||
extern msgBoxInterface *msgbox;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -460,10 +460,7 @@ void BackupDevice::reset_command()
|
|||
{
|
||||
case 0:
|
||||
case 1:
|
||||
printf("Catastrophic error while autodetecting save type.\nIt will need to be specified manually\n");
|
||||
#ifdef _WINDOWS
|
||||
MessageBox(0,"Catastrophic Error Code: Camel;\nyour save type has not been autodetected correctly;\nplease report to developers",0,0);
|
||||
#endif
|
||||
msgbox->error("Catastrophic error while autodetecting save type.\nIt will need to be specified manually\n");
|
||||
addr_size = 1; //choose 1 just to keep the busted savefile from growing too big
|
||||
break;
|
||||
case 2:
|
||||
|
|
|
@ -1107,11 +1107,7 @@ bool savestate_load(EMUFILE* is)
|
|||
|
||||
if(!x && !SAV_silent_fail_flag)
|
||||
{
|
||||
printf("Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked");
|
||||
#ifdef _WINDOWS
|
||||
//HACK! we really need a better way to handle this kind of feedback
|
||||
MessageBox(0,"Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked",0,0);
|
||||
#endif
|
||||
msgbox->error("Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -240,6 +240,51 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
//====================== Message box
|
||||
#define MSG_ARG \
|
||||
char msg_buf[1024] = {0}; \
|
||||
{ \
|
||||
va_list args; \
|
||||
va_start (args, fmt); \
|
||||
vsprintf (msg_buf, fmt, args); \
|
||||
va_end (args); \
|
||||
}
|
||||
void msgWndInfo(const char *fmt, ...)
|
||||
{
|
||||
MSG_ARG;
|
||||
printf("Info: %s\n", msg_buf);
|
||||
MessageBox(MainWindow->getHWnd(), msg_buf, EMU_DESMUME_NAME_AND_VERSION(), MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
bool msgWndConfirm(const char *fmt, ...)
|
||||
{
|
||||
MSG_ARG;
|
||||
printf("Confirm: %s\n", msg_buf);
|
||||
return (MessageBox(MainWindow->getHWnd(), msg_buf, EMU_DESMUME_NAME_AND_VERSION(), MB_YESNO | MB_ICONQUESTION) == IDYES);
|
||||
}
|
||||
|
||||
void msgWndError(const char *fmt, ...)
|
||||
{
|
||||
MSG_ARG;
|
||||
printf("Error: %s\n", msg_buf);
|
||||
MessageBox(MainWindow->getHWnd(), msg_buf, EMU_DESMUME_NAME_AND_VERSION(), MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
void msgWndWarn(const char *fmt, ...)
|
||||
{
|
||||
MSG_ARG;
|
||||
printf("Warning: %s\n", msg_buf);
|
||||
MessageBox(MainWindow->getHWnd(), msg_buf, EMU_DESMUME_NAME_AND_VERSION(), MB_YESNO | MB_ICONWARNING);
|
||||
}
|
||||
|
||||
msgBoxInterface msgBoxWnd = {
|
||||
msgWndInfo,
|
||||
msgWndConfirm,
|
||||
msgWndError,
|
||||
msgWndWarn,
|
||||
};
|
||||
//====================== Dialogs end
|
||||
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI_COMM
|
||||
bool bSocketsAvailable = false;
|
||||
|
@ -2846,6 +2891,8 @@ int _main()
|
|||
GetSystemInfo(&systemInfo);
|
||||
CommonSettings.num_cores = systemInfo.dwNumberOfProcessors;
|
||||
|
||||
msgbox = &msgBoxWnd;
|
||||
|
||||
char text[80];
|
||||
|
||||
path.ReadPathSettings();
|
||||
|
|
Loading…
Reference in New Issue