From e4b14cc302bf8a49ef5dc096ead74077518de099 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Wed, 24 Sep 2003 09:46:52 +0000 Subject: [PATCH] Move ErrorDialog into ArchHooks. Simplify ArchHooks_darwin. --- .../src/arch/ArchHooks/ArchHooks_darwin.cpp | 91 +++++++++---------- .../src/arch/ArchHooks/ArchHooks_darwin.h | 1 + stepmania/src/arch/arch_darwin.h | 1 - 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_darwin.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_darwin.cpp index 8efa6080ac..5af81d42ab 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_darwin.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_darwin.cpp @@ -21,7 +21,21 @@ enum { 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() { @@ -232,59 +246,40 @@ void ArchHooks_darwin::MessageBoxOK(CString sMessage, CString ID) if (allowHush && MessageIsIgnored(ID)) return; - CFStringRef noShow = CFStringCreateWithCString(NULL, "Don't show again", kCFStringEncodingASCII); - CFStringRef error = CFStringCreateWithCString(NULL, sMessage.c_str(), kCFStringEncodingASCII); - 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; + CFStringRef message = CFStringCreateWithCString(NULL, sMessage, kCFStringEncodingASCII); + SInt16 result = ShowAlert(kAlertNoteAlert, message, CFSTR("OK"), CFSTR("Don't show again")); - err = AutoSizeDialog(dialog); - ASSERT(err == noErr); - - RunStandardAlert(dialog, NULL, &result); - if (result != kAlertStdAlertOKButton && allowHush) + CFRelease(message); + if (result == kAlertStdAlertCancelButton && allowHush) IgnoreMessage(ID); - +} + +void ArchHooks_darwin::MessageBoxError(CString sError) +{ + CFStringRef error = CFStringCreateWithCString(NULL, sError, kCFStringEncodingASCII); + ShowAlert(kAlertStopAlert, error, CFSTR("OK")); + CFRelease(error); - CFRelease(OK); - CFRelease(noShow); } ArchHooks::MessageBoxResult ArchHooks_darwin::MessageBoxAbortRetryIgnore(CString sMessage, CString ID) { - SInt16 button; - /* I see no reason for an abort button */ - CFStringRef r = CFStringCreateWithCString(NULL, "Retry", kCFStringEncodingASCII); - 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); - } + CFStringRef error = CFStringCreateWithCString(NULL, sMessage, kCFStringEncodingASCII); + SInt16 result = ShowAlert(kAlertNoteAlert, error, CFSTR("Retry"), CFSTR("Ignore")); + ArchHooks::MessageBoxResult ret; + CFRelease(error); - CFRelease(i); - CFRelease(r); - return result; + switch (result) + { + case kAlertStdAlertOKButton: + ret = retry; + break; + case kAlertStdAlertCancelButton: + ret = ignore; + break; + default: + ASSERT(0); + } + + return ret; } diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_darwin.h b/stepmania/src/arch/ArchHooks/ArchHooks_darwin.h index 8fdff62a39..9514b49bfa 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_darwin.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks_darwin.h @@ -20,6 +20,7 @@ public: ~ArchHooks_darwin() { } void DumpDebugInfo(); void MessageBoxOK(CString sMessage, CString ID = ""); + void MessageBoxError(CString sError); MessageBoxResult MessageBoxAbortRetryIgnore(CString sMessage, CString ID = ""); }; diff --git a/stepmania/src/arch/arch_darwin.h b/stepmania/src/arch/arch_darwin.h index 42f4cb930b..4918ceff9e 100644 --- a/stepmania/src/arch/arch_darwin.h +++ b/stepmania/src/arch/arch_darwin.h @@ -14,7 +14,6 @@ #include "Sound/RageSoundDriver_QT1.h" #include "Sound/RageSoundDriver_QT.h" #include "LoadingWindow/LoadingWindow_Cocoa.h" -#include "ErrorDialog/ErrorDialog_darwin.h" #include "ArchHooks/ArchHooks_darwin.h" #endif