void BURGER_API Burger::OkAlertMessage(const char *pMessage,const char *pTitle) { Word8 *TitleStr; /* Pointer to the window title */ DialogPtr MyDialog; /* My dialog pointer */ Handle ItemList; /* Handle to the item list */ Rect DialogRect; /* Rect of the dialog window */ Word TitleLen; /* Length of the title */ Word MessLen; /* Length of the caption */ short ItemHit; /* Junk */ Rect WorkRect; GrafPtr MyPort; /* My grafport */ //Word Foo; //Foo = InputSetState(FALSE); GetPort(&MyPort); /* Save the current port */ /* Center my dialog to the screen */ #if ACCESSOR_CALLS_ARE_FUNCTIONS GetPortBounds(MyPort,&WorkRect); #else WorkRect = MyPort->portRect; #endif DialogRect.top = static_cast<short>((((WorkRect.bottom-WorkRect.top)-190)/2)+WorkRect.top); DialogRect.left = static_cast<short>((((WorkRect.right-WorkRect.left)-350)/2)+WorkRect.left); DialogRect.bottom = static_cast<short>(DialogRect.top+190); DialogRect.right = static_cast<short>(DialogRect.left+350); TitleLen = 0; /* Assume no length */ if (pTitle) { TitleLen = Burger::StringLength(pTitle); /* Get the length of the title string */ } TitleStr = (Word8 *)Burger::Alloc(TitleLen+1); /* Get memory of pascal string */ if (TitleStr) { /* Did I get the memory? */ MemoryCopy(TitleStr+1,pTitle,TitleLen); TitleStr[0] = static_cast<Word8>(TitleLen); /* Set the pascal length */ MessLen = Burger::StringLength(pMessage); /* Size of the message */ ItemList = NewHandle(static_cast<Size>(sizeof(Template)+MessLen)); if (ItemList) { /* Ok? */ Template[sizeof(Template)-1]=static_cast<Word8>(MessLen); /* Save the message length */ MemoryCopy(ItemList[0],Template,sizeof(Template)); /* Copy the template */ MemoryCopy((ItemList[0])+sizeof(Template),pMessage,MessLen); /* Copy the message */ MyDialog = NewDialog(0,&DialogRect,(Word8 *)TitleStr,TRUE,5,(WindowPtr)-1,FALSE,0,ItemList); if (MyDialog) { SetDialogDefaultItem(MyDialog,1); /* Default for OK button */ ModalDialog(0,&ItemHit); /* Handle the event */ DisposeDialog(MyDialog); /* Kill the dialog */ } else { DisposeHandle(ItemList); /* I must kill this myself! */ } } Burger::Free(TitleStr); /* Kill the title */ } SetPort(MyPort); /* Restore my grafport */ //InputSetState(Foo); }
/* Routine to set the default signal used by "Quick Kill", or Point and Kill. */ void popup_default_kill_dialog( Widget button, XtPointer client_data, XtPointer call_data) { Widget dialog_box, signal_list; int i; XmStringTable xmstr; #include "help/kill_signal.h" /* Create the user name dialog */ dialog_box = NewDialog(button, "set_kill_signal", "Set Kill Signal", True, help_callback , kill_signal_help, True, destroy_widget_callback , NULL, True, set_kill_signal_callback, &dialog_signal_pos); dialog_signal_pos = last_global_signal_pos; xmstr = ( XmString * ) XtMalloc (sizeof ( XmString ) * sigmap_elts ) ; /* Create list skipping over the 0th item -- no action. */ for ( i = 1; i < sigmap_elts; i++ ) { xmstr[i-1] = XmStringCreateLtoR ( signal_map[i].signal_name, XmFONTLIST_DEFAULT_TAG ); } signal_list = XmCreateScrolledList( dialog_box, "signal_list", NULL, 0 ); XtManageChild(signal_list); XtVaSetValues(signal_list, XmNitems, xmstr, XmNitemCount, sigmap_elts-1, XmNvisibleItemCount, 6, XmNselectionPolicy, XmSINGLE_SELECT, NULL ); for ( i = 0; i < sigmap_elts-1; i++ ) { XmStringFree ( xmstr[i] ); } XtFree((char *) xmstr); XtAddCallback( signal_list, XmNdefaultActionCallback, set_kill_signal_callback, &dialog_signal_pos); XtAddCallback( signal_list, XmNsingleSelectionCallback, SignalListCallback, &dialog_signal_pos); XmListSelectPos(signal_list, last_global_signal_pos+1, False); XtManageChild(dialog_box); }
/* Called when the 'New Game' menu item is selected */ void NewGame(void) { char arg1[16],arg2[16], arg01[16], arg02[16]; int i; #ifdef GRAPHICS if(!NewDialog(player1,player2,&SecPerMove)) return; if(!strcmp(player1,"human")) player[0] = HUMAN; else player[0] = COMPUTER; if(!strcmp(player2,"human")) player[1] = HUMAN; else player[1] = COMPUTER; #else player[0]=COMPUTER; player[1]=COMPUTER; #endif arg01[0]=0; arg02[0]=0; player1Java=0; player2Java=0; if(!strncmp(player1,"java",4)) { player1Java=1; fprintf(stderr,"Player1 is java player\n"); strcpy(arg01,&(player1[5])); player1[4]=0; strcpy(player1,"/usr/bin/java"); fprintf(stderr,"%s %s\n", player1, arg01); } if(!strncmp(player2,"java",4)) { player2Java=1; fprintf(stderr,"Player2 is java player\n"); strcpy(arg02,&(player2[5])); //player2[4]=0; strcpy(player2,"/usr/bin/java"); fprintf(stderr,"%s %s\n", player2, arg02); } /* If 'New Game' is chosen while a game is in progress, stop the game */ if (playing) StopGame(); // Set up the pipes necessary for communication with computer players. for (i = 0; i < 2; i++) { int to_proc[2]; int from_proc[2]; if (player[i] == HUMAN) { // Pipes aren't needed for human players. continue; } pipe(to_proc); pipe(from_proc); writefd[i] = to_proc[1]; readfd[i] = from_proc[0]; if (fcntl(readfd[i],F_SETFL,(int)O_NDELAY) < 0) { printf("fcntl failed\n"); return; } /* Fork a child process. We will then overlay the computer program */ if((pid[i] = fork()) == (pid_t)0) { int temp; dup2(to_proc[0], STDIN_FILENO); close(to_proc[0]); dup2(from_proc[1], STDOUT_FILENO); close(from_proc[1]); sprintf(arg1,"%.2f",SecPerMove); if(MaxDepth >= 0) { sprintf(arg2,"%d", MaxDepth); if((i==0 && player1Java ) || (i==1 && player2Java)) temp = execl(i?player2:player1,i?player2:player1, i?arg02:arg01,arg1,arg2, NULL); else temp = execl(i?player2:player1,i?player2:player1, arg1,arg2,(char *)0); if(temp) { fprintf(stderr, "exec for %s failed\n",i?player2:player1); exit(0); } } else { if((i==0 && player1Java ) || (i==1 && player2Java)) temp = execl(i?player2:player1,i?player2:player1, i?arg02:arg01,arg1, NULL); else temp = execl(i?player2:player1,i?player2:player1, arg1,(char *)0); if(temp) { fprintf(stderr, "exec for %s failed\n",i?player2:player1); exit(0); } } } } ResetBoard(); playing = 1; turn = 0; hlen = 0; memset(hmove,0,12*sizeof(int)); FindLegalMoves(turn+1); /* Tell the computer programs which player they are */ if(player[0] == COMPUTER) { write(writefd[0],"Player1",7); fsync(writefd[0]); } if(player[1] == COMPUTER) { write(writefd[1],"Player2",7); fsync(writefd[1]); } }