Move ErrorDialog into ArchHooks. Simplify ArchHooks_darwin.
This commit is contained in:
@@ -21,7 +21,21 @@ enum {
|
|||||||
kMacOSX_10_3 = 0x1030
|
kMacOSX_10_3 = 0x1030
|
||||||
};
|
};
|
||||||
|
|
||||||
OSStatus HandleException(ExceptionInformation *theException);
|
SInt16 ShowAlert(int type, CFStringRef message, CFStringRef OK, CFStringRef cancel = NULL)
|
||||||
|
{
|
||||||
|
struct AlertStdCFStringAlertParamRec params = {kStdCFStringAlertVersionOne, true, false, OK, cancel, NULL,
|
||||||
|
kAlertStdAlertOKButton, kAlertStdAlertCancelButton, kWindowAlertPositionParentWindowScreen, NULL};
|
||||||
|
DialogRef dialog;
|
||||||
|
SInt16 result;
|
||||||
|
OSErr err;
|
||||||
|
|
||||||
|
CreateStandardAlert(type, message, NULL, ¶ms, &dialog);
|
||||||
|
err = AutoSizeDialog(dialog);
|
||||||
|
ASSERT(err == noErr);
|
||||||
|
RunStandardAlert(dialog, NULL, &result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
ArchHooks_darwin::ArchHooks_darwin()
|
ArchHooks_darwin::ArchHooks_darwin()
|
||||||
{
|
{
|
||||||
@@ -232,59 +246,40 @@ void ArchHooks_darwin::MessageBoxOK(CString sMessage, CString ID)
|
|||||||
if (allowHush && MessageIsIgnored(ID))
|
if (allowHush && MessageIsIgnored(ID))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CFStringRef noShow = CFStringCreateWithCString(NULL, "Don't show again", kCFStringEncodingASCII);
|
CFStringRef message = CFStringCreateWithCString(NULL, sMessage, kCFStringEncodingASCII);
|
||||||
CFStringRef error = CFStringCreateWithCString(NULL, sMessage.c_str(), kCFStringEncodingASCII);
|
SInt16 result = ShowAlert(kAlertNoteAlert, message, CFSTR("OK"), CFSTR("Don't show again"));
|
||||||
CFStringRef OK = CFStringCreateWithCString(NULL, "OK", kCFStringEncodingASCII);
|
|
||||||
struct AlertStdCFStringAlertParamRec params = {kStdCFStringAlertVersionOne, true, false, OK, NULL,
|
|
||||||
(allowHush ? noShow : NULL),
|
|
||||||
kAlertStdAlertOKButton, NULL, kWindowAlertPositionParentWindowScreen, NULL};
|
|
||||||
DialogRef dialog;
|
|
||||||
CreateStandardAlert(kAlertNoteAlert, error, NULL, ¶ms, &dialog);
|
|
||||||
OSErr err;
|
|
||||||
SInt16 result;
|
|
||||||
|
|
||||||
err = AutoSizeDialog(dialog);
|
CFRelease(message);
|
||||||
ASSERT(err == noErr);
|
if (result == kAlertStdAlertCancelButton && allowHush)
|
||||||
|
|
||||||
RunStandardAlert(dialog, NULL, &result);
|
|
||||||
if (result != kAlertStdAlertOKButton && allowHush)
|
|
||||||
IgnoreMessage(ID);
|
IgnoreMessage(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArchHooks_darwin::MessageBoxError(CString sError)
|
||||||
|
{
|
||||||
|
CFStringRef error = CFStringCreateWithCString(NULL, sError, kCFStringEncodingASCII);
|
||||||
|
ShowAlert(kAlertStopAlert, error, CFSTR("OK"));
|
||||||
|
|
||||||
CFRelease(error);
|
CFRelease(error);
|
||||||
CFRelease(OK);
|
|
||||||
CFRelease(noShow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchHooks::MessageBoxResult ArchHooks_darwin::MessageBoxAbortRetryIgnore(CString sMessage, CString ID)
|
ArchHooks::MessageBoxResult ArchHooks_darwin::MessageBoxAbortRetryIgnore(CString sMessage, CString ID)
|
||||||
{
|
{
|
||||||
SInt16 button;
|
CFStringRef error = CFStringCreateWithCString(NULL, sMessage, kCFStringEncodingASCII);
|
||||||
/* I see no reason for an abort button */
|
SInt16 result = ShowAlert(kAlertNoteAlert, error, CFSTR("Retry"), CFSTR("Ignore"));
|
||||||
CFStringRef r = CFStringCreateWithCString(NULL, "Retry", kCFStringEncodingASCII);
|
ArchHooks::MessageBoxResult ret;
|
||||||
CFStringRef i = CFStringCreateWithCString(NULL, "Ignore", kCFStringEncodingASCII);
|
|
||||||
CFStringRef error = CFStringCreateWithCString(NULL, sMessage.c_str(), kCFStringEncodingASCII);
|
|
||||||
struct AlertStdCFStringAlertParamRec params = {kStdCFStringAlertVersionOne, true, false, r, i, NULL,
|
|
||||||
kAlertStdAlertOKButton, kAlertStdAlertCancelButton, kWindowAlertPositionParentWindowScreen, NULL};
|
|
||||||
DialogRef dialog;
|
|
||||||
MessageBoxResult result;
|
|
||||||
|
|
||||||
CreateStandardAlert(kAlertNoteAlert, error, NULL, ¶ms, &dialog);
|
|
||||||
OSErr err = AutoSizeDialog(dialog);
|
|
||||||
ASSERT(err == noErr);
|
|
||||||
RunStandardAlert(dialog, NULL, &button);
|
|
||||||
|
|
||||||
switch (button)
|
|
||||||
{
|
|
||||||
case kAlertStdAlertOKButton:
|
|
||||||
result = retry;
|
|
||||||
break;
|
|
||||||
case kAlertStdAlertCancelButton:
|
|
||||||
result = ignore;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
CFRelease(error);
|
CFRelease(error);
|
||||||
CFRelease(i);
|
switch (result)
|
||||||
CFRelease(r);
|
{
|
||||||
return result;
|
case kAlertStdAlertOKButton:
|
||||||
|
ret = retry;
|
||||||
|
break;
|
||||||
|
case kAlertStdAlertCancelButton:
|
||||||
|
ret = ignore;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
~ArchHooks_darwin() { }
|
~ArchHooks_darwin() { }
|
||||||
void DumpDebugInfo();
|
void DumpDebugInfo();
|
||||||
void MessageBoxOK(CString sMessage, CString ID = "");
|
void MessageBoxOK(CString sMessage, CString ID = "");
|
||||||
|
void MessageBoxError(CString sError);
|
||||||
MessageBoxResult MessageBoxAbortRetryIgnore(CString sMessage, CString ID = "");
|
MessageBoxResult MessageBoxAbortRetryIgnore(CString sMessage, CString ID = "");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "Sound/RageSoundDriver_QT1.h"
|
#include "Sound/RageSoundDriver_QT1.h"
|
||||||
#include "Sound/RageSoundDriver_QT.h"
|
#include "Sound/RageSoundDriver_QT.h"
|
||||||
#include "LoadingWindow/LoadingWindow_Cocoa.h"
|
#include "LoadingWindow/LoadingWindow_Cocoa.h"
|
||||||
#include "ErrorDialog/ErrorDialog_darwin.h"
|
|
||||||
#include "ArchHooks/ArchHooks_darwin.h"
|
#include "ArchHooks/ArchHooks_darwin.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user