コード例 #1
0
ファイル: macalert.cpp プロジェクト: amuramatsu/np2-mod
void ResumeErrorDialogProc(void) {
    DialogRef	ret;
    AlertStdCFStringAlertParamRec	param;
    DialogItemIndex	hit;
    
    GetStandardAlertDefaultParams(&param, kStdCFStringAlertVersionOne);   
    param.movable = true;
    CreateStandardAlert(kAlertStopAlert, CFCopyLocalizedString(CFSTR("Couldn't restart"), "Resume Error Message"), 
                                         CFCopyLocalizedString(CFSTR("An error occured when reading the np2.sav file. Neko Project IIx couldn't restart."), "Resume Error Description"),
                                         &param, &ret);
    SysBeep(0);
    RunStandardAlert(ret, NULL, &hit);
}
コード例 #2
0
// ---------------------------------------------------------------------------
// Constructeur
// ------------
bStdAlert::bStdAlert(int kind, 
					 int def_btn, 
					 bool has_cancel, 
					 const char* error_string, 
					 const char* explanation_string,
					 bool silent,
					 UInt32 delay){
	_res=false;
	
	if(silent){
fprintf(stderr,"ALERT : %s\n",error_string);
fprintf(stderr,"%s\n",explanation_string);
		_res=true;
		return;
	}
	
AlertStdCFStringAlertParamRec	prm;
	
    (void)GetStandardAlertDefaultParams(&prm,kStdCFStringAlertVersionOne);

	prm.defaultButton=def_btn;
	if(def_btn==kAlertStdAlertOKButton){
		prm.cancelButton=kAlertStdAlertCancelButton;
	}
	else if(def_btn==kAlertStdAlertCancelButton){
		prm.cancelButton=kAlertStdAlertOKButton;
	}
	
char	msg[__MESSAGE_STRING_LENGTH_MAX__];
	message_string(kMsgOk,msg,1);
	prm.defaultText=CFStringCreateWithCString(kCFAllocatorDefault,msg,kCFStringEncodingMacRoman);
	if(has_cancel){
		message_string(kMsgCancel,msg,1);
		prm.cancelText=CFStringCreateWithCString(kCFAllocatorDefault,msg,kCFStringEncodingMacRoman);
	}
	
CFStringRef	err=CFStringCreateWithCString(kCFAllocatorDefault,error_string,kCFStringEncodingMacRoman);
CFStringRef	exp=CFStringCreateWithCString(kCFAllocatorDefault,explanation_string,kCFStringEncodingMacRoman);

DialogRef	alrt;
	
    (void)CreateStandardAlert(kind,err,exp,&prm,&alrt);
		
	SetDialogTimeout(alrt,def_btn,delay);
	
    (void)RunStandardAlert(alrt,NULL,&_hit);
	
	_res=(_hit==def_btn);
	CFRelease(err);
	CFRelease(exp);		
}
コード例 #3
0
ファイル: macalert.cpp プロジェクト: amuramatsu/np2-mod
static SInt16 showCautionAlert(CFStringRef title, CFStringRef string, CFStringRef button) {
    DialogRef	ret;
    AlertStdCFStringAlertParamRec	param;
    DialogItemIndex	hit;
    
    GetStandardAlertDefaultParams(&param, kStdCFStringAlertVersionOne);
    param.movable = true;
    param.cancelButton = kAlertStdAlertCancelButton;
    param.cancelText = param.defaultText;
    if (button) param.defaultText = button;
   
    CreateStandardAlert(kAlertCautionAlert, title, string, &param, &ret);
    SysBeep(0);
    RunStandardAlert(ret, NULL, &hit);
    return(hit);
}
コード例 #4
0
ファイル: appbundle.c プロジェクト: megastep/loki_setup
static int ui_prompt_yn(const char *question, const char *desc)
{
    OSStatus err;
    DialogItemIndex item;
    AlertStdCFStringAlertParamRec params;
    err = GetStandardAlertDefaultParams(&params, kStdCFStringAlertVersionOne);
    if (err != noErr)
        return(0);

    params.movable = TRUE;
    params.helpButton = FALSE;
    params.defaultText = CFSTR("Yes");
    params.cancelText = CFSTR("No");
    params.defaultButton = kAlertStdAlertOKButton;
    params.cancelButton = kAlertStdAlertCancelButton;
    if (!do_msgbox(question, kAlertCautionAlert, &params, &item, desc))
        return(0); /* oh well. */

    return(item == kAlertStdAlertOKButton);
} /* ui_prompt_yes_or_no */
コード例 #5
0
ファイル: macdriver_console.c プロジェクト: digarok/gsplus
int x_show_alert(int is_fatal, const char *str)     {
  DialogRef alert;
  DialogItemIndex out_item_hit;
  CFStringRef cfstrref;
  CFStringRef okstrref;
  AlertStdCFStringAlertParamRec alert_param;
  OSStatus osstat;

  if (!str || !*str) return 0;

  /* The dialog eats all events--including key-up events */
  /* Call adb_all_keys_up() to prevent annoying key-repeat problems */
  /*  for instance, a key-down causes a dialog to appear--and the */
  /*  eats the key-up event...then as soon as the dialog goes, adb.c */
  /*  auto-repeat will repeat the key, and the dialog re-appears...*/
  adb_all_keys_up();


  cfstrref = CFStringCreateWithCString(NULL, str,
                                       kCFStringEncodingMacRoman);


  osstat = GetStandardAlertDefaultParams(&alert_param,
                                         kStdCFStringAlertVersionOne);

  okstrref = CFSTR("Click OK to continue");
  if(is_fatal) {
    okstrref = CFSTR("Click OK to exit GSplus");
  }
  CreateStandardAlert(kAlertStopAlert, cfstrref, okstrref,
                      &alert_param, &alert);
  out_item_hit = -1;
  RunStandardAlert(alert, NULL, &out_item_hit);

  CFRelease(cfstrref);
  return (out_item_hit >= 3);
}
コード例 #6
0
ファイル: debug.c プロジェクト: blezek/warzone2100
void _debug( code_part part, const char *function, const char *str, ... )
{
    va_list ap;
    static char outputBuffer[MAX_LEN_LOG_LINE];
    static unsigned int repeated = 0; /* times current message repeated */
    static unsigned int next = 2;     /* next total to print update */
    static unsigned int prev = 0;     /* total on last update */

    va_start(ap, str);
    vssprintf(outputBuffer, str, ap);
    va_end(ap);

    ssprintf(inputBuffer[useInputBuffer1 ? 1 : 0], "[%s] %s", function, outputBuffer);

    if (sstrcmp(inputBuffer[0], inputBuffer[1]) == 0)
    {
        // Received again the same line
        repeated++;
        if (repeated == next) {
            if (repeated > 2) {
                ssprintf(outputBuffer, "last message repeated %u times (total %u repeats)", repeated - prev, repeated);
            } else {
                ssprintf(outputBuffer, "last message repeated %u times", repeated - prev);
            }
            printToDebugCallbacks(outputBuffer);
            prev = repeated;
            next *= 2;
        }
    } else {
        // Received another line, cleanup the old
        if (repeated > 0 && repeated != prev && repeated != 1) {
            /* just repeat the previous message when only one repeat occurred */
            if (repeated > 2) {
                ssprintf(outputBuffer, "last message repeated %u times (total %u repeats)", repeated - prev, repeated);
            } else {
                ssprintf(outputBuffer, "last message repeated %u times", repeated - prev);
            }
            printToDebugCallbacks(outputBuffer);
        }
        repeated = 0;
        next = 2;
        prev = 0;
    }

    if (!repeated)
    {
        time_t rawtime;
        struct tm * timeinfo;
        char ourtime[15];		//HH:MM:SS

        time ( &rawtime );
        timeinfo = localtime ( &rawtime );
        strftime (ourtime,15,"%I:%M:%S",timeinfo);

        // Assemble the outputBuffer:
        ssprintf(outputBuffer, "%-8s|%s: %s", code_part_names[part], ourtime, useInputBuffer1 ? inputBuffer[1] : inputBuffer[0]);

        printToDebugCallbacks(outputBuffer);

        // Throw up a dialog box for windows users since most don't have a clue to check the stderr.txt file for information
        // Use for (duh) Fatal errors, that force us to terminate the game.
        if (part == LOG_FATAL)
        {
#if defined(WZ_OS_WIN)
            char wbuf[512];
            ssprintf(wbuf, "%s\n\nPlease check your stderr.txt file in the same directory as the program file for more details. \
				\nDo not forget to upload both the stderr.txt file and the warzone2100.rpt file in your bug reports!", useInputBuffer1 ? inputBuffer[1] : inputBuffer[0]);
            MessageBoxA( NULL,
                         wbuf,
                         "Warzone has terminated unexpectedly", MB_OK|MB_ICONERROR);
#elif defined(WZ_OS_MAC32) // FIXME: Needs to be made compatible with 64bit
            AlertStdCFStringAlertParamRec	param;
            DialogRef						dialog;
            OSStatus						err;
            DialogItemIndex					itemHit;
            char aBuffer[512];

            GetStandardAlertDefaultParams( &param, kStdCFStringAlertVersionOne );
            param.movable = true;

            ssprintf(aBuffer, "%s\n\nPlease check your logs for more details.\n", useInputBuffer1 ? inputBuffer[1] : inputBuffer[0] );

            err = CreateStandardAlert( kAlertStopAlert, CFStringCreateWithCString( nil, aBuffer, kCFStringEncodingMacRoman),
                                       CFSTR( "Run Console.app and search for wz2100 and copy that to a file.\
					  \n\nFor the Crash report on 10.4/10.5 check\
					  \n~/Library/Logs/CrashReporter,\
					  \non 10.6 check ~/Library/Logs/DiagnosticReports\
					  \nDo not forget to upload and attach those to a bug report at http://developer.wz2100.net/newticket\
					  \nThanks!" ), &param, &dialog );
            SetWindowTitleWithCFString( GetDialogWindow( dialog ), CFSTR( "Warzone has terminated unexpectedly" ) );

            RunStandardAlert( dialog, NULL, &itemHit );
#endif
        }
コード例 #7
0
ファイル: macdriver_kegs.c プロジェクト: chinnytp/kegs
int
x_show_alert(int is_fatal, const char *str)
{
	DialogRef	alert;
	DialogItemIndex	out_item_hit;
	CFStringRef	cfstrref, cfstrref2;
	CFStringRef	okstrref;
	AlertStdCFStringAlertParamRec alert_param;
	OSStatus osstat;
	char	*bufptr, *buf2ptr;
	int	sum, len;
	int	i;
	
	/* The dialog eats all events--including key-up events */
	/* Call adb_all_keys_up() to prevent annoying key-repeat problems */
	/*  for instance, a key-down causes a dialog to appear--and the */
	/*  eats the key-up event...then as soon as the dialog goes, adb.c */
	/*  auto-repeat will repeat the key, and the dialog re-appears...*/
	adb_all_keys_up();
	
	sum = 20;
	for(i = 0; i < g_fatal_log; i++) {
		sum += strlen(g_fatal_log_strs[i]);
	}
	bufptr = (char*)malloc(sum);
	buf2ptr = bufptr;
	for(i = 0; i < g_fatal_log; i++) {
		len = strlen(g_fatal_log_strs[i]);
		len = MIN(len, sum);
		len = MAX(len, 0);
		memcpy(bufptr, g_fatal_log_strs[i], MIN(len, sum));
		bufptr += len;
		bufptr[0] = 0;
		sum = sum - len;
	}
	
	cfstrref = CFStringCreateWithCString(NULL, buf2ptr,
										 kCFStringEncodingMacRoman);
	
	printf("buf2ptr: :%s:\n", buf2ptr);
	
	osstat = GetStandardAlertDefaultParams(&alert_param,
										   kStdCFStringAlertVersionOne);
	
	if(str) {
		// Provide an extra option--create a file
		cfstrref2 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
											 CFSTR("Create ~/Library/KEGS/%s"), str);
		alert_param.otherText = cfstrref2;
	}
	okstrref = CFSTR("Click OK to continue");
	if(is_fatal) {
		okstrref = CFSTR("Clock OK to exit KEGS");
	}
	CreateStandardAlert(kAlertStopAlert, cfstrref, okstrref,
						&alert_param, &alert);
	out_item_hit = -1;
	RunStandardAlert(alert, NULL, &out_item_hit);
	printf("out_item_hit: %d\n", out_item_hit);
	free(buf2ptr);
	
	clear_fatal_logs();		/* free the fatal_log string memory */
	return (out_item_hit >= 3);
	
}