- add platform independent message dialog;
This commit is contained in:
parent
09c8027d69
commit
be8d5288ee
|
@ -52,3 +52,42 @@ char *removeSpecialChars(char *s)
|
||||||
*buf = 0;
|
*buf = 0;
|
||||||
return s;
|
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 *trim(char *s, int len=-1);
|
||||||
extern char *removeSpecialChars(char *s);
|
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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -460,10 +460,7 @@ void BackupDevice::reset_command()
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
printf("Catastrophic error while autodetecting save type.\nIt will need to be specified manually\n");
|
msgbox->error("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
|
|
||||||
addr_size = 1; //choose 1 just to keep the busted savefile from growing too big
|
addr_size = 1; //choose 1 just to keep the busted savefile from growing too big
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
|
@ -1107,11 +1107,7 @@ bool savestate_load(EMUFILE* is)
|
||||||
|
|
||||||
if(!x && !SAV_silent_fail_flag)
|
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");
|
msgbox->error("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
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,6 +240,51 @@
|
||||||
|
|
||||||
using namespace std;
|
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
|
#ifdef EXPERIMENTAL_WIFI_COMM
|
||||||
bool bSocketsAvailable = false;
|
bool bSocketsAvailable = false;
|
||||||
|
@ -2846,6 +2891,8 @@ int _main()
|
||||||
GetSystemInfo(&systemInfo);
|
GetSystemInfo(&systemInfo);
|
||||||
CommonSettings.num_cores = systemInfo.dwNumberOfProcessors;
|
CommonSettings.num_cores = systemInfo.dwNumberOfProcessors;
|
||||||
|
|
||||||
|
msgbox = &msgBoxWnd;
|
||||||
|
|
||||||
char text[80];
|
char text[80];
|
||||||
|
|
||||||
path.ReadPathSettings();
|
path.ReadPathSettings();
|
||||||
|
|
Loading…
Reference in New Issue