static void AudioCDTabInit() { ControlType *cck3P; FieldType *fld2P, *fld3P; ListType *list1P, *list2P; MemHandle lengthH, firstTrackH; Char *lengthP, *firstTrackP; cck3P = (ControlType *)GetObjectPtr(TabAudioCDMP3Checkbox); fld2P = (FieldType *)GetObjectPtr(TabAudioCDLengthSecsField); fld3P = (FieldType *)GetObjectPtr(TabAudioCDFirstTrackField); list1P = (ListType *)GetObjectPtr(TabAudioCDDriverList); list2P = (ListType *)GetObjectPtr(TabAudioCDFormatList); LstSetSelection(list1P, gameInfoP->musicInfo.sound.drvCD); CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); LstSetSelection(list2P, gameInfoP->musicInfo.sound.frtCD); CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P))); CtlSetValue(cck3P, gameInfoP->musicInfo.sound.CD); lengthH = MemHandleNew(FldGetMaxChars(fld2P)+1); lengthP = (Char *)MemHandleLock(lengthH); StrIToA(lengthP, gameInfoP->musicInfo.sound.defaultTrackLength); MemHandleUnlock(lengthH); FldSetTextHandle(fld2P, lengthH); firstTrackH = MemHandleNew(FldGetMaxChars(fld3P)+1); firstTrackP = (Char *)MemHandleLock(firstTrackH); StrIToA(firstTrackP, gameInfoP->musicInfo.sound.firstTrack); MemHandleUnlock(firstTrackH); FldSetTextHandle(fld3P, firstTrackH); }
//////////////////////////////////////////////////////////////////////// // FUNCTION: TimeToAscii // // DESCRIPTION: This routine convert the date passed to formatted string. // // PARAMETERS: (UInt8) hours - Hours. // (UInt8) minutes - Minutes. // (TimeFormatType) timeFomrat - Any TimeFormatType format. // (Char *) pString - Pointer to string which gets the result. // // RETURNED: Returns nothing. // // REVISION HISTORY: // Name Date Description // ---- ---- ----------- // Jerry 5/10/01 Initial Revision // Jerry 11/17/01 Modify 0:0 to 12:00 //////////////////////////////////////////////////////////////////////// void TimeToAscii (UInt8 hours, UInt8 minutes, TimeFormatType timeFormat, Char *pString) { Char buffer[3]; UInt8 thours; switch (timeFormat) { case tfColonAMPM: // 1:00 pm case tfDotAMPM: // 1.00 pm case tfHoursAMPM: // 1 pm thours = hours%12; if ( thours == 0 ) thours = 12; StrIToA (buffer, thours); Vstrcpy (pString, buffer); if ( timeFormat == tfColonAMPM ) Vstrcat (pString, ":"); else if ( timeFormat == tfDotAMPM ) Vstrcat (pString, "."); if ( timeFormat != tfHoursAMPM ) { StrIToA (buffer, minutes); if ( minutes < 10 ) Vstrcat (pString, "0"); Vstrcat (pString, buffer); } Vstrcat (pString, " "); if ( hours >= 12 ) Vstrcat (pString, "pm"); else Vstrcat (pString, "am"); break; case tfColon24h: // 13:00 case tfDto24h: // 13.00 case tfHours24h: // 13 case tfComma24h: // 13,00 StrIToA (buffer, hours); Vstrcpy (pString, buffer); if ( timeFormat == tfColonAMPM ) Vstrcat (pString, ":"); else if ( timeFormat == tfDotAMPM ) Vstrcat (pString, "."); else if ( timeFormat == tfComma24h ) Vstrcat (pString, ","); if ( timeFormat != tfHours24h ) { StrIToA (buffer, minutes); Vstrcat (pString, buffer); } break; } }
void DrawCurrScore() { Char msg[6]; if ( stor.flash && stor.scorethisroll == 0 ) { StrCopy( msg, NotApplicableString ); } else { StrIToA( msg, stor.scorethisroll ); } SetFieldTextFromStr(scoreRoll, msg); StrIToA( msg, stor.scorethisturn ); SetFieldTextFromStr(scoreTurn, msg); StrIToA( msg, stor.currscore ); SetFieldTextFromStr(scoreTot, msg); }
void Memo_Write2d(char* cp, long iVal) { char buf[10]; MemoWriteLen(cp, StrLen(cp)); if (iVal < 0) { MemoWriteLen("-", 1); iVal = -iVal; } StrIToA(buf, iVal); MemoWriteLen(buf, StrLen(buf)); }
static void PrvImgTest(WND wnd) { int fd; ruint16 i, j; char tmp[10]; struct img_data *picture; unsigned char *p; COLORVAL color; GdiLockScreen(wnd); MemSet(tmp, 0, 10); fd = RalOpenFile("test.jpg"); if (fd == -1 ) { GdiTextOut(wnd, "File Not Found", StrLen("File Not Found"), 10, 10); return ; } //GdiTextOut(wnd, "check", StrLen("test"), 140, 10); picture = img_jpeg_read(fd, 240, 320); if (picture == NULL) { GdiTextOut(wnd, "JPG Read fail", StrLen("JPG Read fail"), 20, 300); return ; } StrIToA(picture->size, tmp); GdiTextOut(wnd, tmp, StrLen(tmp), 140, 10); p = picture->data; for(i=0; i<picture->height; i++) { for(j=0; j<picture->width; j++) { color = *p <<8 | (*(p+1) ); GdiSetPixel(wnd, j, i, color ); p += 2; } } if (picture) { if (picture->data) free(picture->data); free(picture); } GdiUnlockScreen(wnd); }
long strtol(const char *s, char **endptr, int base) { // WARNING : only base = 10 supported long val = StrAToI(s); if (endptr) { Char str[maxStrIToALen]; StrIToA(str, val); if (StrNCompare(s, str, StrLen(str)) == 0) *endptr = (char *)s + StrLen(str); } return val; }
// ************************************************************************* // Draw an item on the screen // ************************************************************************* static void DrawItem( char* Name, int y, long Price ) { int j; FntSetFont( stdFont ); DrawChars( Name, 30, y ); EraseRectangle( 110, y, 56, 9 ); StrIToA( SBuf, Price ); StrCat( SBuf, " cr." ); j = MAXDIGITS - StrLen( SBuf ); if (Price > 0) DrawChars( SBuf, 124+j*5, y ); else DrawChars( "not sold", 122, y ); }
static void MusicTabInit() { ControlType *cck1P, *cck2P; ListType *list1P, *list2P, *list3P; FieldType *fld1P; MemHandle tempoH; Char *tempoP; cck1P = (ControlType *)GetObjectPtr(TabMusicMusicCheckbox); cck2P = (ControlType *)GetObjectPtr(TabMusicMultiMidiCheckbox); list1P = (ListType *)GetObjectPtr(TabMusicDriverList); list2P = (ListType *)GetObjectPtr(TabMusicRateList); list3P = (ListType *)GetObjectPtr(TabMusicQualityList); fld1P = (FieldType *)GetObjectPtr(TabMusicTempoField); CtlSetValue(cck1P, gameInfoP->musicInfo.sound.music); CtlSetValue(cck2P, gameInfoP->musicInfo.sound.multiMidi); if (gameInfoP->musicInfo.sound.drvMusic > 5) gameInfoP->musicInfo.sound.drvMusic = 0; LstSetSelection(list1P, gameInfoP->musicInfo.sound.drvMusic); LstSetTopItem(list1P, gameInfoP->musicInfo.sound.drvMusic); CtlSetLabel((ControlType *)GetObjectPtr(TabMusicDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); LstSetSelection(list2P, gameInfoP->musicInfo.sound.rate); LstSetTopItem(list2P, gameInfoP->musicInfo.sound.rate); CtlSetLabel((ControlType *)GetObjectPtr(TabMusicRatePopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P))); LstSetSelection(list3P, gameInfoP->fmQuality); CtlSetLabel((ControlType *)GetObjectPtr(TabMusicQualityPopTrigger), LstGetSelectionText(list3P, LstGetSelection(list3P))); tempoH = MemHandleNew(FldGetMaxChars(fld1P)+1); tempoP = (Char *)MemHandleLock(tempoH); StrIToA(tempoP, gameInfoP->musicInfo.sound.tempo); MemHandleUnlock(tempoH); FldSetTextHandle(fld1P, tempoH); }
void DrawPlayerScore(Short player) { Char msg[MaxName]; StrIToA( msg, stor.player[player].score ); SetFieldTextFromStr( fieldScorePlayer[player], msg ); if ( stor.player[player].lost ) { CrossPlayer(player); return; } if ( player == stor.currplayer ) { InvertPlayer(player); return; } if ( player == stor.leader ) { SetFieldTextFromStr( fieldMarkPlayer[player], LeadSymbol ); return; } ClearFieldText( fieldMarkPlayer[player] ); }
void DialogVarients() { FormPtr prevForm, frm; Word hitButton; Word fldIndex; Char tmpString[3]; CharPtr text; // Save previous form prevForm = FrmGetActiveForm(); // Init new form frm = FrmInitForm( frmVariants ); // Set it FrmSetActiveForm(frm); FrmDrawForm(frm); // Set Controls CtlSetValue( GetObjectPtr(check_Bump ), stor.flags & flag_Bump ); CtlSetValue( GetObjectPtr(check_Eclipse ), stor.flags & flag_Eclipse ); CtlSetValue( GetObjectPtr(check_Sampler ), stor.flags & flag_Sampler ); CtlSetValue( GetObjectPtr(check_nTW ), stor.flags & flag_nTW ); CtlSetValue( GetObjectPtr(check_FullHouse), stor.flags & flag_FullHouse ); CtlSetValue( GetObjectPtr(check_Suspend ), stor.flags & flag_Suspend ); // Fill in WinScore with previous value. StrIToA( tmpString, stor.nTrainWrecks ); SetFieldTextFromStr( fldnTrainWrecks, tmpString ); StrIToA( tmpString, stor.nSuspend ); SetFieldTextFromStr( fldnSuspend, tmpString ); // Set the focus to this field so the user can just start typing. fldIndex = FrmGetObjectIndex(frm, fldnTrainWrecks); FrmSetFocus( frm, fldIndex ); // Set the handler FrmSetEventHandler(frm, DialogVariantsHandleEvent); hitButton = FrmDoDialog(frm); // Get Controls text = FldGetTextPtr( FrmGetObjectPtr( frm, fldIndex ) ); if( text != NULL ) { stor.nTrainWrecks = StrAToI( text ); } else { stor.nTrainWrecks = 3; } fldIndex = FrmGetObjectIndex(frm, fldnSuspend); text = FldGetTextPtr( FrmGetObjectPtr( frm, fldIndex ) ); if( text != NULL ) { stor.nSuspend = StrAToI( text ); } else { stor.nSuspend = 10; } // Delete the form, we're not using it FrmDeleteForm(frm); // Restore previous form. if (prevForm) { FrmSetActiveForm(prevForm); } }
void DialogNewGame() { FormPtr prevForm, frm; Word hitButton; Char tmpString[5]; CharPtr text; Word fldIndex; Int x; // Save previous form prevForm = FrmGetActiveForm(); // Init new form frm = FrmInitForm( frmNewGame ); // Set it FrmSetActiveForm(frm); FrmDrawForm(frm); // Set Controls // cbtnVal & pbtnVal stor.tmpplayers = stor.numplayers; stor.tmpcomputers = stor.numcomputers; if ( stor.numplayers > 0 ) { x = stor.numplayers; } else { x = 1; } CtlSetValue( GetObjectPtr( pbtnVal[x - 1] ), true ); if ( stor.numcomputers > 0 ) { x = stor.numcomputers; } else { x = 0; } CtlSetValue( GetObjectPtr( cbtnVal[x] ), true ); // Fill in WinScore with previous value. if ( stor.winscore > 9999 ) { // Sanity check... stor.winscore = 300; } StrIToA( tmpString, stor.winscore ); SetFieldTextFromStr( fld_winscore, tmpString ); // Set the focus to this field so the user can just start typing. fldIndex = FrmGetObjectIndex(frm, fld_winscore); FrmSetFocus( frm, fldIndex ); // Set the handler FrmSetEventHandler(frm, DialogNewGameHandleEvent); hitButton = FrmDoDialog(frm); if ( hitButton == btn_OK_frmNewGame ) { text = FldGetTextPtr( FrmGetObjectPtr (frm, fldIndex) ); if ( text != NULL ) { stor.winscore = StrAToI( text ); } else { stor.winscore = 300; } stor.numplayers = stor.tmpplayers; stor.numcomputers = stor.tmpcomputers; } // Delete the form, we're not using it FrmDeleteForm(frm); // Restore previous form. if (prevForm) { FrmSetActiveForm(prevForm); } if ( hitButton == btn_OK_frmNewGame ) { NewGame(); } DrawState(); }
Boolean StartScummVM() { Char **argvP; UInt8 lightspeed, argc = 0; UInt32 stackSize; Boolean toLauncher, direct, isARM; UInt8 engine; Char num[6]; UInt16 index = GamGetSelected(); argvP = ArgsInit(); direct = false; // start command line (exec name) ArgsAdd(&argvP[argc], "-", NULL, &argc); // no game selected if (index == dmMaxRecordIndex) { ListPtr listP; UInt16 whichButton; // init form FormPtr frmP = FrmInitForm(EngineForm); listP = (ListType *)FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, EngineListList)); itemsText = (Char **)MemPtrNew(ENGINE_COUNT * sizeof(Char *)); for (int i = 0; i < ENGINE_COUNT; i++) itemsText[i] = (Char *)engines[i].nameP; LstSetListChoices (listP, itemsText, ENGINE_COUNT); LstSetSelection(listP, 0); whichButton = FrmDoDialog(frmP); engine = LstGetSelection(listP); FrmDeleteForm(frmP); MemPtrFree(itemsText); itemsText = NULL; if (whichButton == EngineCancelButton) { if (bDirectMode) { // and force exit if nothing selected EventType event; event.eType = keyDownEvent; event.data.keyDown.chr = vchrLaunch; event.data.keyDown.modifiers = commandKeyMask; EvtAddUniqueEventToQueue(&event, 0, true); } // free args ArgsFree(argvP); return false; } // default values if (bDirectMode) gPrefs->card.volRefNum = parseCards(); // always use the first removable card available (?) gVars->filter = true; gVars->palmVolume = 50; gVars->fmQuality = FM_QUALITY_INI; direct = true; // somthing selected } else { Char pathP[256]; MemHandle recordH; GameInfoType *gameInfoP; recordH = DmQueryRecord(gameDB,index); gameInfoP = (GameInfoType *)MemHandleLock(recordH); engine = gameInfoP->engine; // build path StrCopy(pathP,"/Palm/Programs/ScummVM/Games/"); if (gameInfoP->pathP[0] == '/') StrCopy(pathP, gameInfoP->pathP); else if (!(gameInfoP->pathP[0] == '.' && StrLen(gameInfoP->pathP) == 1)) StrCat(pathP, gameInfoP->pathP); // path ArgsAdd(&argvP[argc], "-p", pathP, &argc); // language if (gameInfoP->language > 0) { const Char *lang = "zh\0cz\0gb\0en\0fr\0de\0hb\0it\0jp\0kr\0pl\0pt\0ru\0es\0se\0"; ArgsAdd(&argvP[argc], "-q", (lang + (gameInfoP->language - 1) * 3), &argc); } // fullscreen ? if (gameInfoP->fullscreen) ArgsAdd(&argvP[argc], "-f", NULL, &argc); // aspect-ratio ? ArgsAdd(&argvP[argc], (gameInfoP->aspectRatio ? "--aspect-ratio" : "--no-aspect-ratio"), NULL, &argc); // gfx mode gVars->filter = gameInfoP->filter; switch (gameInfoP->renderMode) { case 1: ArgsAdd(&argvP[argc], "--render-mode=", "amiga", &argc); break; case 2: ArgsAdd(&argvP[argc], "--render-mode=", "cga", &argc); break; case 3: ArgsAdd(&argvP[argc], "--render-mode=", "ega", &argc); break; case 4: ArgsAdd(&argvP[argc], "--render-mode=", "hercAmber", &argc); break; case 5: ArgsAdd(&argvP[argc], "--render-mode=", "hercGreen", &argc); break; } switch (gameInfoP->gfxMode) { case 1: ArgsAdd(&argvP[argc], "-g", "wide", &argc); break; default: ArgsAdd(&argvP[argc], "-g", "1x", &argc); break; } // load state if (gameInfoP->autoLoad) { StrIToA(num, gameInfoP->loadSlot); ArgsAdd(&argvP[argc], "-x", num, &argc); } // boot script parameter if (gameInfoP->bootParam) { StrIToA(num, gameInfoP->bootValue); ArgsAdd(&argvP[argc], "-b", num, &argc); } // not a PC version if (gameInfoP->setPlatform) { static const char *platform[] = { "3do", "acorn", "amiga", "atari", "c64", "pc", "fmtowns", "linux", "mac", "nes", "segacd", "windows" }; ArgsAdd(&argvP[argc], "--platform=", platform[gameInfoP->platform], &argc); } // subtitles if (gameInfoP->subtitles) ArgsAdd(&argvP[argc], "-n", NULL, &argc); // multi midi ? if (gameInfoP->musicInfo.sound.multiMidi) ArgsAdd(&argvP[argc], "--multi-midi", NULL, &argc); if (engine == ENGINE_SCUMM) { // music tempo StrIToA(num, gameInfoP->musicInfo.sound.tempo); ArgsAdd(&argvP[argc], "--tempo=", num, &argc); } // talk speed if (gameInfoP->talkSpeed) { StrIToA(num, gameInfoP->talkValue); ArgsAdd(&argvP[argc], "--talkspeed=", num, &argc); } // music driver if (gameInfoP->musicInfo.sound.music) { static char *drv[] = { "auto", "null", "adlib", "towns", "pcjr", "native", "pcspk" }; if (StrCompare(drv[gameInfoP->musicInfo.sound.drvMusic], "native") == 0) { if (OPTIONS_TST(kOptDeviceZodiac)) ArgsAdd(&argvP[argc], "-e", "zodiac", &argc); // Tapwave Zodiac else if (OPTIONS_TST(kOptSonyPa1LibAPI)) ArgsAdd(&argvP[argc], "-e", "ypa1", &argc); // Pa1Lib devices else ArgsAdd(&argvP[argc], "-e", "auto", &argc); // no driver, switch to auto } else { ArgsAdd(&argvP[argc], "-e", drv[gameInfoP->musicInfo.sound.drvMusic], &argc); } // output rate UInt32 rates[] = {4000, 8000, 11025, 22050, 44100}; StrIToA(num, rates[gameInfoP->musicInfo.sound.rate]); ArgsAdd(&argvP[argc], "--output-rate=", num, &argc); // FM quality gVars->fmQuality = gameInfoP->fmQuality; } else { ArgsAdd(&argvP[argc], "-e", "null", &argc); } // volume control StrIToA(num, gameInfoP->musicInfo.volume.sfx); ArgsAdd(&argvP[argc], "-s", num, &argc); StrIToA(num, gameInfoP->musicInfo.volume.music); ArgsAdd(&argvP[argc], "-m", num, &argc); StrIToA(num, gameInfoP->musicInfo.volume.speech); ArgsAdd(&argvP[argc], "-r", num, &argc); // game name ArgsAdd(&argvP[argc], gameInfoP->gameP, NULL, &argc); // others globals data gVars->CD.enable = gameInfoP->musicInfo.sound.CD; gVars->CD.driver = gameInfoP->musicInfo.sound.drvCD; gVars->CD.format = gameInfoP->musicInfo.sound.frtCD; gVars->CD.volume = gameInfoP->musicInfo.volume.audiocd; gVars->CD.defaultTrackLength = gameInfoP->musicInfo.sound.defaultTrackLength; gVars->CD.firstTrack = gameInfoP->musicInfo.sound.firstTrack; gVars->palmVolume = gameInfoP->musicInfo.sound.music ? gameInfoP->musicInfo.volume.palm : 0; MemHandleUnlock(recordH); } // end no game / game selected // common command line options // debug level if (gPrefs->debug) { StrIToA(num, gPrefs->debugLevel); ArgsAdd(&argvP[argc], "-d", num, &argc); } if (engine == ENGINE_QUEEN || engine == ENGINE_SKY) { // alternative intro ? if (gPrefs->altIntro) ArgsAdd(&argvP[argc], "--alt-intro", NULL, &argc); } if (engine == ENGINE_SCUMM) { // demo mode ? if (gPrefs->demoMode) ArgsAdd(&argvP[argc], "--demo-mode", NULL, &argc); } // copy protection ? if (gPrefs->copyProtection) ArgsAdd(&argvP[argc], "--copy-protection", NULL, &argc); // exceed max args ? if (argc > MAX_ARG) FrmCustomAlert(FrmErrorAlert, "Too many parameters.",0,0); // set some common options stackSize = (gPrefs->setStack ? STACK_LARGER : STACK_DEFAULT); lightspeed= (gPrefs->lightspeed.enable ? gPrefs->lightspeed.mode : 255); toLauncher= (gPrefs->exitLauncher); // gVars values // (gVars->HRrefNum defined in checkHRmode on Clié) gVars->VFS.volRefNum = gPrefs->card.volRefNum; gVars->vibrator = gPrefs->vibrator; gVars->stdPalette = gPrefs->stdPalette; gVars->VFS.cacheSize = (gPrefs->card.useCache ? gPrefs->card.cacheSize : 0); gVars->indicator.showLED= gPrefs->card.showLED; gVars->stylusClick = gPrefs->stylusClick; gVars->autoSave = (gPrefs->autoSave ? gPrefs->autoSavePeriod : -1); gVars->advancedMode = gPrefs->advancedMode; gVars->arrowKeys = gPrefs->arrowKeys; // user params HWR_RSTALL(); if (gPrefs->goLCD) HWR_SET(INIT_GOLCD); else OPTIONS_RST(kOptGoLcdAPI); if (!gPrefs->autoOff) HWR_SET(INIT_AUTOOFF); if (gVars->vibrator) HWR_SET(INIT_VIBRATOR); /* ???? if ( musicDriver == 1 || musicDriver == 3 || musicDriver == 4 || musicDriver == sysInvalidRefNum) { HWR_SET(INIT_PA1LIB); } */ if (ModImport(gVars->VFS.volRefNum, engine, &isARM) != errNone) { if (bDirectMode) { // and force exit if nothing selected EventType event; event.eType = keyDownEvent; event.data.keyDown.chr = vchrLaunch; event.data.keyDown.modifiers = commandKeyMask; EvtAddUniqueEventToQueue(&event, 0, true); } ArgsFree(argvP); return false; } // reset mode if screen rotation occured (DIA only) if (!direct && OPTIONS_TST(kOptCollapsible)) { UInt8 mode = PalmScreenSize(0,0, &(gVars->screenFullWidth), &(gVars->screenFullHeight)); OPTIONS_RST(kOptModeLandscape); OPTIONS_SET((mode == PALM_LANDSCAPE) ? kOptModeLandscape : kOptNone); } // free and save globals pref memory GamCloseDatabase(false); FrmCloseAllForms(); SavePrefs(); { UInt16 cardNo; UInt32 dbID; LaunchParamType *cmdPBP = (LaunchParamType *)MemPtrNew(sizeof(LaunchParamType)); MemPtrSetOwner(cmdPBP, 0); MemPtrSetOwner(gVars, 0); ArgsSetOwner(argvP, 0); cardNo = 0; dbID = DmFindDatabase(0, "ScummVM-Engine"); if (isARM) FtrSet(appFileCreator, ftrStack , (stackSize * 4)); else ModSetStack(stackSize, cardNo, dbID); cmdPBP->args.argc = argc; cmdPBP->args.argv = argvP; cmdPBP->gVars = gVars; cmdPBP->lightspeed = lightspeed; cmdPBP->exitLauncher = toLauncher; SysUIAppSwitch(cardNo, dbID, sysAppLaunchCmdNormalLaunch, cmdPBP); bLaunched = true; } return false; }
void ErrDisplayFileLineMsg(const Char * const filename, UInt16 lineNo, const Char * const msg) { #if (EMULATION_LEVEL != EMULATION_NONE) StubErrDisplayFileLineMsg(filename, lineNo, msg); #else UInt16 fatalAlertResult; Char text[textBufferLen + 1]; SysEventType event; // Form the error message. Use PrvStrNCat everywhere to reduce the // number of utility routines we need to copy into this file. text[0] = '\0'; PrvStrNCat(text, filename, maxErrFilenameLen + 1); PrvStrNCat(text, ", Line:", textBufferLen + 1); StrIToA(text + StrLen(text), lineNo); PrvStrNCat(text, ", ", textBufferLen + 1); PrvStrNCat(text, msg, textBufferLen + 1); // If the UI has not been initialized yet, we can't put up an alert // so we'll force entry into the Debugger. // DOLATER kwk - shouldn't this check be in SysFatalAlert? Also // check for interrupt level; currently AMX kernal generates fatal // alert if 68K vector checksum has changed, but you can't safely // draw at that time. if (!(GSysMiscFlags & sysMiscFlagUIInitialized)) { GDbgWasEntered |= dbgEnteredFlagTrue; DbgBreak(); } // If the debugger was entered already, go to it if (GDbgWasEntered & dbgEnteredFlagTrue) { DbgMessage(text); DbgMessage("\n"); DbgBreak(); } // Else, show a fatal alert else { // If we re-entered, something terrible is wrong so just loop indefinitely so that // we don't eat up stack space. if (GSysMiscFlags & sysMiscFlagInFatalAlert) while(1) ; // Set flag to detect re-entry GSysMiscFlags |= sysMiscFlagInFatalAlert; // Display alert and reset if the first button (0) is pressed. if ( (fatalAlertResult = SysFatalAlert(text)) == fatalReset ) { #ifdef _DEBUG_ERROR_MGR DbgMessage("Reset Pressed\n"); #endif SysReset(); } // If the the second button(1) is pressed (can only happen with // full error checking on) go into Debugger. else if ( fatalAlertResult != fatalDoNothing ) { #ifdef _DEBUG_ERROR_MGR DbgMessage("Debug Pressed\n"); #endif DbgBreak(); } #ifdef _DEBUG_ERROR_MGR else DbgMessage("Continue Pressed\n"); #endif // Flush all events out. do { SysEventGet(&event, 1); } while (event.eType != nilEvent); // Clear re-entry detector GSysMiscFlags &= ~sysMiscFlagInFatalAlert; } #endif }
static int find_cache_item(unsigned rec_num,int assign_uncompressed) {int i=cache_head,d=get_current_db_idx(),idle_item=(cache_head+1)&cache_length_mask; if(assign_uncompressed)uncompressed=0; if(saved_uncompressed&&cache[idle_item].chunk.d>=0 &&saved_uncompressed==cache[idle_item].content) idle_item=(idle_item+1)&cache_length_mask; if(facunde) {char s[0x33];StrCopy(s,"cache find ");StrCat(s,"("); StrIToA(s+StrLen(s),d);StrCat(s,":"); StrIToA(s+StrLen(s),rec_num);StrCat(s,")"); draw_chars(s,0,0); } do {if(facunde) {char s[0x33];StrCopy(s,"cache ");StrIToA(s+StrLen(s),i);StrCat(s,":("); StrIToA(s+StrLen(s),cache[i].db_idx);StrCat(s,":"); StrIToA(s+StrLen(s),cache[i].rec_num);StrCat(s,");"); StrIToA(s+StrLen(s),cache[i].chunk.d);StrCat(s," "); draw_chars(s,0,0); } if(cache[i].chunk.d<0){idle_item=i;goto next_i;} if(d==cache[i].db_idx&&rec_num==cache[i].rec_num) {if(facunde) {char s[0x33];StrCopy(s,"found ");StrCat(s," "); StrIToA(s+StrLen(s),i);StrCat(s,":("); StrIToA(s+StrLen(s),d);StrCat(s,":"); StrIToA(s+StrLen(s),rec_num);StrCat(s,")"); StrIToH(s+StrLen(s),(UInt32)(cache[i].content));StrCat(s," "); draw_chars(s,0,0); }if(assign_uncompressed)uncompressed=cache[i].content;return i; } next_i:i=(i-1)&cache_length_mask; }while(i!=cache_head); if(facunde) {char s[0x33];StrCopy(s,"cache loop done ");StrIToA(s+StrLen(s),idle_item);StrCat(s,":("); StrIToA(s+StrLen(s),cache[idle_item].db_idx);StrCat(s,":"); StrIToA(s+StrLen(s),cache[idle_item].rec_num);StrCat(s,");"); StrIToA(s+StrLen(s),cache[idle_item].chunk.d);StrCat(s," "); draw_chars(s,0,0); } if(cache[idle_item].chunk.d>=0) {free_chunk(cache[idle_item].chunk); cache[idle_item].chunk.d=invalid_chunk_descriptor; }i=(idle_item+1)&cache_length_mask; while(i!=idle_item) {cache[idle_item].chunk=alloc_chunk(dh.record_size); if(cache[idle_item].chunk.d>=0){cache_head=idle_item;break;} while(i!=idle_item) {int i_prev=i;i=(i+1)&cache_length_mask; if(cache[i_prev].chunk.d>=0&& (!saved_uncompressed||saved_uncompressed!=cache[i_prev].content)) {free_chunk(cache[i_prev].chunk); cache[i_prev].chunk.d=invalid_chunk_descriptor;break; } } } if(facunde) {char s[0x33];StrCopy(s,"idle alloc ");StrIToA(s+StrLen(s),idle_item);StrCat(s,":("); StrIToA(s+StrLen(s),d);StrCat(s,":"); StrIToA(s+StrLen(s),rec_num);StrCat(s,");"); StrIToA(s+StrLen(s),cache[idle_item].chunk.d);StrCat(s," "); draw_chars(s,0,0); } if(cache[idle_item].chunk.d>=0) {if(inflate_into_chunk(cache[idle_item].chunk)) {free_chunk(cache[idle_item].chunk); cache[idle_item].chunk.d=invalid_chunk_descriptor; }else {const char*uc=lock_chunk(cache[idle_item].chunk); cache[idle_item].rec_num=rec_num;cache[idle_item].db_idx=d; cache[idle_item].content=uc;if(assign_uncompressed)uncompressed=uc; return idle_item; } }return-1; }
/*************************************************************************** * Function: cryptSwitch * Description: handles changing the system password based upon the * password change screen. Basically checks that current password is correct, * checks that the new password was entered correctly, then re-encrypts the * databases based upon the new password. * ************************************************************************/ static void cryptSwitch (int v) { // total number of records to re-write UInt16 totalAItems = DmNumRecordsInCategory (AccountDB, dmAllCategories); UInt16 totalSItems = DmNumRecordsInCategory (SystemDB, dmAllCategories); MemPtr pac = NULL, scratch = NULL, scratch2 = NULL; UInt16 i = 0, senc = 0, aenc = 0; MemHandle rH; char s[5], a[5]; StripPrefType prefs; UInt16 prefsSize, prefsVersion; FormType *preF = FrmGetActiveForm (); FormType *f = FrmInitForm (pleaseWait); FrmDrawForm (f); // re-encrypt the password if ((rH = DmGetRecord (PasswordDB, 0))) { if ((scratch = MemPtrNew (getSCSize(sizeof(md_hash))))) { PackPassword (scratch, &NewSysPass); writeRecord (scratch, rH); MemPtrFree (scratch); } DmReleaseRecord (PasswordDB, 0, true); } // loop through the systems and re-encrypt for (i = 0; i < totalSItems; i++) { System_old sys; if ((rH = DmGetRecord (SystemDB, i))) { pac = MemHandleLock (rH); if ((scratch = MemPtrNew (MemPtrSize (pac)))) { // decrypt the system with old password switch (v) { case 0: UnpackSystem_old (&sys, pac, scratch, SysPass, MemHandleSize (rH), true, 1); scratch2 = MemPtrNew (getSystemSize((System *)&sys, true)); break; case 1: UnpackSystem_old (&sys, pac, scratch, SysPass, MemHandleSize (rH), true, 2); scratch2 = MemPtrNew (getSystemSize ((System *)&sys,true) ); break; case 2: UnpackSystem_old (&sys, pac, scratch, SysPass, MemHandleSize (rH), true, 0); scratch2 = MemPtrNew (getSystemSize ((System *)&sys, true )); break; } if (scratch2) { PackSystem(scratch2, *((System *) &sys), &NewSysPass, true); MemHandleUnlock (rH); writeRecord (scratch2, rH); senc++; MemPtrFree (scratch2); } MemPtrFree (scratch); } DmReleaseRecord (SystemDB, i, true); } } // loop through the accounts and re-encrypt for (i = 0; i < totalAItems; i++) { Account_old ac; Account ac_new; if ((rH = DmGetRecord (AccountDB, i))) { pac = MemHandleLock (rH); if ((scratch = MemPtrNew (MemPtrSize (pac)))) { // decrypt the system with old password switch (v) { case 0: UnpackAccount_old(&ac, pac, scratch, SysPass, MemHandleSize (rH), true, true, 1); ChangeAccountFormat(i, &ac, &ac_new); scratch2 = MemPtrNew (getAccountSize(&ac_new, true)); break; case 1: UnpackAccount_old (&ac, pac, scratch, SysPass, MemHandleSize (rH), true, true, 2); ChangeAccountFormat(i, &ac, &ac_new); scratch2 = MemPtrNew (getAccountSize(&ac_new, true)); break; case 2: UnpackAccount_old(&ac, pac, scratch, SysPass, MemHandleSize (rH), true, true, 0); ChangeAccountFormat(i, &ac, &ac_new); scratch2 = MemPtrNew (getAccountSize(&ac_new,true)); break; } if (scratch2) { PackAccount(scratch2, ac_new, &NewSysPass, true); MemHandleUnlock (rH); writeRecord (scratch2, rH); aenc++; MemPtrFree (scratch2); } MemPtrFree (scratch); } DmReleaseRecord (AccountDB, i, true); } } FrmEraseForm (f); FrmDeleteForm (f); FrmSetActiveForm (preF); // close databases. DmCloseDatabase (SystemDB); DmCloseDatabase (AccountDB); DmCloseDatabase (PasswordDB); { UInt16 cardNo; UInt32 type; LocalID dbID; DmSearchStateType search; type = systemDBType; DmGetNextDatabaseByTypeCreator(true, &search, systemDBTypeOld, StripCreator, true, &cardNo, &dbID); DmSetDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &type, NULL); type = accountDBType; DmGetNextDatabaseByTypeCreator(true, &search, accountDBTypeOld, StripCreator, true, &cardNo, &dbID); DmSetDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &type, NULL); type = passwordDBType; DmGetNextDatabaseByTypeCreator(true, &search, passwordDBTypeOld, StripCreator, true, &cardNo, &dbID); DmSetDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &type, NULL); } prefsSize = sizeof (StripPrefType); prefsVersion = PrefGetAppPreferences (StripCreator, StripPrefID, &prefs, &prefsSize, true); if (prefsVersion != StripVersionNumber) { prefs.smart_beaming = false; PrefSetAppPreferences (StripCreator, StripPrefID, StripVersionNumber, &prefs, sizeof (StripPrefType), true); prefsVersion = PrefGetAppPreferences (StripCreator, StripPrefID, &prefs, &prefsSize, true); } StrIToA (s, senc); StrIToA (a, aenc); FrmCustomAlert (infoDialog, s, a, NULL); StopApplication (); SysReset (); }
static void PrvImgView(WND wnd) { int fd, len; ruint16 i, j; char tmp[10]; struct img_data *picture; unsigned char *p; COLORVAL color; MemSet(tmp, 0, 10); fd = RalOpenFile((char *)&fileList[imgfocusedList]); if (fd == -1 ) { GdiTextOut(wnd, "File Not Found", StrLen("File Not Found"), 20, 300); return ; } //GdiTextOut(wnd, "check", StrLen("test"), 140, 10); picture = NULL; len = StrLen(fileList[imgfocusedList]); p = &fileList[imgfocusedList][len-3]; if ( !StrNCmp(p, "jpg", 3) || !StrNCmp(p, "JPG", 3) ) { picture = img_jpeg_read(fd, 240, 320); } else if ( !StrNCmp(p, "gif", 3) || !StrNCmp(p, "GIF", 3) ) { picture = img_gif_read(fd, 240, 320); } else if ( !StrNCmp(p, "png", 3) || !StrNCmp(p, "PNG", 3) ) { picture = img_png_read(fd, 240, 320); } if (picture == NULL) { GdiTextOut(wnd, "Image File Read fail", StrLen("Image File Read fail"), 20, 300); return ; } imgStateID = IMAGEVIEW_STATE_FILE_SHOW; GdiLockScreen(wnd); GdiClrScreen(wnd, COLOR_BLACK); StrIToA(picture->size, tmp); //GdiTextOut(wnd, tmp, StrLen(tmp), 100, 310); p = picture->data; for(i=0; i<picture->height; i++) { for(j=0; j<picture->width; j++) { color = *p <<8 | (*(p+1) ); GdiSetPixel(wnd, j, i, color ); p += 2; } } GdiTextOut(wnd, fileList[imgfocusedList], StrLen(fileList[imgfocusedList]), 80, 300); if (picture) { if (picture->data) free(picture->data); free(picture); } GdiUnlockScreen(wnd); }
static void DrawCurrentShipForm() { FormPtr frmP = FrmGetActiveForm(); int i, j, k, Line, FirstEmptySlot; RectangularShortcuts( frmP, CurrentShipBButton ); FrmDrawForm( frmP ); FntSetFont( boldFont ); DrawChars( "Type:", 0, 18 ); DrawChars( "Equipment:", 0, 32 ); FntSetFont( stdFont ); if (ScarabStatus == 3) { StrCopy( SBuf, Shiptype[Ship.Type].Name); StrCat ( SBuf, "/hardened hull"); DrawChars( SBuf, 60, 18 ); } else DrawChars( Shiptype[Ship.Type].Name, 60, 18 ); Line = 32; for (i=0; i<MAXWEAPONTYPE+EXTRAWEAPONS; ++i) { j = 0; for (k=0; k<MAXWEAPON; ++k) { if (Ship.Weapon[k] == i) ++j; } if (j > 0) { SBuf[0] = '\0'; SBufMultiples( j, Weapontype[i].Name ); StrToLower( SBuf2, SBuf ); DrawChars( SBuf2, 60, Line ); Line += 14; } } for (i=0; i<MAXSHIELDTYPE+EXTRASHIELDS; ++i) { j = 0; for (k=0; k<MAXSHIELD; ++k) { if (Ship.Shield[k] == i) ++j; } if (j > 0) { SBuf[0] = '\0'; SBufMultiples( j, Shieldtype[i].Name ); StrToLower( SBuf2, SBuf ); DrawChars( SBuf2, 60, Line ); Line += 14; } } for (i=0; i<MAXGADGETTYPE+EXTRAGADGETS; ++i) { j = 0; for (k=0; k<MAXGADGET; ++k) { if (Ship.Gadget[k] == i) ++j; } if (j > 0) { if (i == EXTRABAYS) { j = j*5; StrIToA( SBuf, j ); StrCat( SBuf, " extra cargo bays" ); } else { StrCopy(SBuf, Gadgettype[i].Name ); } StrToLower( SBuf2, SBuf ); DrawChars( SBuf2, 60, Line ); Line += 14; } } if (EscapePod) { DrawChars( "an escape pod", 60, Line ); Line += 14; } if (AnyEmptySlots(&Ship)) { FntSetFont( boldFont ); DrawChars( "Unfilled: ", 0, Line ); FntSetFont( stdFont ); FirstEmptySlot = GetFirstEmptySlot( Shiptype[Ship.Type].WeaponSlots, Ship.Weapon ); if (FirstEmptySlot >= 0) { SBuf[0] = '\0'; SBufMultiples( Shiptype[Ship.Type].WeaponSlots - FirstEmptySlot, "weapon slot" ); DrawChars( SBuf, 60, Line ); Line += 14; } FirstEmptySlot = GetFirstEmptySlot( Shiptype[Ship.Type].ShieldSlots, Ship.Shield ); if (FirstEmptySlot >= 0) { SBuf[0] = '\0'; SBufMultiples( Shiptype[Ship.Type].ShieldSlots - FirstEmptySlot, "shield slot" ); DrawChars( SBuf, 60, Line ); Line += 14; } FirstEmptySlot = GetFirstEmptySlot( Shiptype[Ship.Type].GadgetSlots, Ship.Gadget ); if (FirstEmptySlot >= 0) { SBuf[0] = '\0'; SBufMultiples( Shiptype[Ship.Type].GadgetSlots - FirstEmptySlot, "gadget slot" ); DrawChars( SBuf, 60, Line ); Line += 14; } } }
/*********************************************************************** * * FUNCTION: RepeatSetUIValues * * DESCRIPTION: This routine sets the current repeat settings of the * ui gadgets in the repeat dialog box * * PARAMETERS: frm - pointer to the Repeat Dialog * repeatP - pointer to a RepeatInfoType structure. * * RETURNED: nothing * ***********************************************************************/ void RepeatSetUIValues(FormType* frm, RepeatInfoType* repeatP) { UInt16 i; UInt16 id; UInt16 oldFreq; MemHandle freqH; Char* freqP = NULL; Boolean on = false; FieldType* fld = NULL; const Int8 startOfWeek = PrefGetPreference(prefWeekStartDay); /* Set the selection of the "repeat type" push button group. */ id = repeatP->repeatType + RepeatNone; if (repeatP->repeatType > repeatMonthlyByDay) id--; FrmSetControlGroupSelection (frm, RepeatTypeGroup, id); /* Set the frequency field */ if (repeatP->repeatType != repeatNone) { fld = GetObjectPointer(frm, RepeatFrequenceField); freqH = FldGetTextHandle(fld); if (freqH) { freqP = MemHandleLock(freqH); oldFreq = StrAToI(freqP); } else { freqH = MemHandleNew(maxFrequenceFieldLen); ASSERT(freqH); freqP = MemHandleLock(freqH); oldFreq = 0; } if (oldFreq != repeatP->repeatFrequency) { StrIToA(freqP, repeatP->repeatFrequency); FldSetTextHandle(fld, freqH); if (FrmVisible(frm)) { FldEraseField(fld); FldDrawField(fld); } } MemHandleUnlock (freqH); } /* Set the selection of the "repeat on" push button groups. */ if (repeatP->repeatType == repeatWeekly) { /* ** If the appointment has a different start-day-of-week than ** the dialog-box's current start-day-of-week, rearrange the ** labels on the days-of-week push buttons. ** Note that this will only handle button-label shifts of one day. */ if (startOfWeek != d.repeat_start_of_week) { const Char* sundayLabel = CtlGetLabel(GetObjectPointer(frm, RepeatDayOfWeek1PushButton)); for (id = RepeatDayOfWeek1PushButton; id < RepeatDayOfWeek7PushButton; id++) CtlSetLabel(GetObjectPointer(frm, id), CtlGetLabel(GetObjectPointer(frm, id + 1))); CtlSetLabel(GetObjectPointer(frm, RepeatDayOfWeek7PushButton), sundayLabel); d.repeat_start_of_week = startOfWeek; } /* Turn on the push buttons for the days the appointment repeats on. */ for (i = 0; i < daysInWeek; i++) { on = ((repeatP->repeatOn & (1 << i) ) != 0); id = RepeatDayOfWeek1PushButton + ((i - startOfWeek + daysInWeek) % daysInWeek); CtlSetValue(GetObjectPointer(frm, id), on); } } /* Set the selection of the "repeat by" push button groups. */ if (repeatP->repeatType == repeatMonthlyByDate) FrmSetControlGroupSelection(frm, RepeatByGroup, RepeatByDatePushButton); else FrmSetControlGroupSelection(frm, RepeatByGroup, RepeatByDayPushButton); /* Set the "end on" trigger label and popup list selection. */ if (repeatP->repeatType != repeatNone) RepeatSetDateTrigger(repeatP->repeatEndDate); }
//////////////////////////////////////////////////////////////////////// // FUNCTION: DateToAscii // // DESCRIPTION: This routine convert the date passed to a string using // the format specified by the dateFormat parameter. // // PARAMETERS: (UInt8) months - Months. // (UInt8) days - Days // (UInt16) years - Years // (DateFormatType) dateFormat - Any DateFormatType format. // (Char *) pString - Pointer to string which gets the result. // // RETURNED: Returns nothing. // // REVISION HISTORY: // Name Date Description // ---- ---- ----------- // Jerry 5/10/01 Initial Revision //////////////////////////////////////////////////////////////////////// void DateToAscii (UInt8 months, UInt8 days, UInt16 years, DateFormatType dateFormat, Char *pString) { char buffer[5]; char spliter[2]; switch (dateFormat) { case dfMDYWithSlashes: // 12/31/95 StrIToA (buffer, months); Vstrcpy (pString, buffer); Vstrcat (pString, "//"); StrIToA (buffer, days); Vstrcat (pString, buffer); Vstrcat (pString, "//"); StrIToA (buffer, (years%100)); Vstrcat (pString, buffer); break; case dfDMYWithSlashes: // 31/12/95 case dfDMYithDots: // 31.12.95 case dfDMYWithDashes: // 31-12-95 if ( dateFormat == dfDMYWithSlashes ) { Vstrcpy (spliter, "//"); } else if ( dateFormat == dfDMYithDots ) { Vstrcpy (spliter, "."); } else { Vstrcpy (spliter, "-"); } StrIToA (buffer, days); Vstrcpy (pString, buffer); Vstrcat (pString, spliter); StrIToA (buffer, months); Vstrcat (pString, buffer); Vstrcat (pString, spliter); StrIToA (buffer, (years%100)); Vstrcat (pString, buffer); break; case dfYMDWithSlases: // 95/12/31 case dfYMDWithDots: // 95.12.31 case dfYMDWithDashes: // 95-12-31 if ( dateFormat == dfYMDWithSlases ) { Vstrcpy (spliter, "//"); } else if ( dateFormat == dfYMDWithDots ) { Vstrcpy (spliter, "."); } else { Vstrcpy (spliter, "-"); } StrIToA (buffer, (years%100)); Vstrcpy (pString, buffer); Vstrcat (pString, spliter); StrIToA (buffer, months); Vstrcat (pString, buffer); Vstrcat (pString, spliter); StrIToA (buffer, days); Vstrcat (pString, buffer); break; case dfMDYLongWithComma: // Dec 31, 1995 case dfDMYLongNoDay: // Dec 1995 Vstrcpy (pString, cMonth[months-1]); Vstrcat (pString, " "); if ( dateFormat == dfMDYLongWithComma ) { StrIToA (buffer, days); Vstrcat (pString, buffer); Vstrcat (pString, ", "); } StrIToA (buffer, years); Vstrcat (pString, buffer); break; case dfDMYLong: // 31 Dec 1995 case dfDMYLongWithDot: // 31. Dec 1995 case dfDMYLongWithComma: // 31 Dec, 1995 StrIToA (buffer, days); Vstrcat (pString, buffer); if ( dateFormat == dfDMYLongWithComma ) { Vstrcat (pString, "."); } Vstrcat (pString, " "); Vstrcpy (pString, cMonth[months-1]); if ( dateFormat == dfDMYLongWithComma ) { Vstrcat (pString, ","); } Vstrcat (pString, " "); StrIToA (buffer, years); Vstrcat (pString, buffer); break; case dfYMDLongWithDot: // 1995.12.31 StrIToA (buffer, years); Vstrcpy (pString, buffer); Vstrcat (pString, "."); StrIToA (buffer, months); Vstrcat (pString, buffer); Vstrcat (pString, "."); StrIToA (buffer, days); Vstrcat (pString, buffer); break; case dfYMDLongWithSpace: // 1995 Dec 31 StrIToA (buffer, years); Vstrcpy (pString, buffer); Vstrcat (pString, " "); Vstrcat (pString, cMonth[months]-1); Vstrcat (pString, " "); StrIToA (buffer, days); Vstrcat (pString, buffer); break; case dfMYMed: // Dec '95 case dfMYMedNoPost: // Dec 95 Vstrcpy (pString, cMonth[months]-1); Vstrcat (pString, " "); if ( dateFormat == dfMYMed ) { Vstrcat (pString, "'"); } StrIToA (buffer, (years%100)); Vstrcat (pString, buffer); break; } }
void DialogNewGame() { FormPtr prevForm, frm; UInt16 hitButton; Char tmpString[5]; Char *text; UInt16 x; UInt16 num; // Save previous form prevForm = FrmGetActiveForm(); FrmSetFocus( prevForm, noFocus ); // Init new form frm = FrmInitForm( frmNewGame ); // Set it FrmSetActiveForm(frm); FrmDrawForm(frm); for( x = 0; x < MaxPlayers; x++ ) { tmppref[x].type = GetPlayerType( x ); StrCopy( tmppref[x].hname, pref.player[x].hname ); StrCopy( tmppref[x].aname, pref.player[x].aname ); DrawUserType( x, tmppref[x].type ); NewGameSetPlayerName( fldNGname0+x, x ); } // Fill in WinScore with previous value. if ( pref.winscore > 9999 ) { // Sanity check... pref.winscore = DEFAULT_WINSCORE; } StrIToA( tmpString, pref.winscore ); SetFieldTextFromStr( fld_winscore, tmpString ); // Fill in Opening Roll with previous value. if ( pref.openingroll > pref.winscore || pref.openingroll <= 0 ) { // Sanity check... pref.openingroll = DEFAULT_OPENINGROLL; } StrIToA( tmpString, pref.openingroll ); SetFieldTextFromStr( fld_openingroll, tmpString ); SetFocus( fld_openingroll ); // Set the handler FrmSetEventHandler(frm, DialogNewGameHandleEvent); hitButton = FrmDoDialog(frm); FrmSetFocus( frm, noFocus ); if ( hitButton == btn_OK_frmNewGame ) { /* Get the score needed to win */ pref.winscore = DEFAULT_WINSCORE; text = FldGetTextPtr( GetObjectPtr( fld_winscore ) ); if ( text != NULL ) { num = StrAToI( text ); if( num <= 9999 && num >= 50 ) { pref.winscore = num; } } /* Get the score needed to open game */ pref.openingroll = DEFAULT_OPENINGROLL; text = FldGetTextPtr( GetObjectPtr( fld_openingroll ) ); if ( text != NULL ) { num = StrAToI( text ); if( num <= pref.winscore && num >= 0 ) { pref.openingroll = num; } } pref.totalplayers = 0; for( x = 0; x < MaxPlayers; x++ ) { pref.player[x].type = tmppref[x].type; NewGameGetPlayerName( fldNGname0 + x, x ); StrCopy( pref.player[x].hname, tmppref[x].hname ); StrCopy( pref.player[x].aname, tmppref[x].aname ); if( tmppref[x].type != PlayerNone ) { pref.totalplayers++; } } if( pref.totalplayers > 0 ) { NewGame(); } } // Delete the form, we're not using it FrmDeleteForm(frm); // Restore previous form. if (prevForm) { FrmSetActiveForm(prevForm); } DrawState(); }
/*********************************************************************** * * FUNCTION: SelectOneTime * * DESCRIPTION: Display a form showing a time and allow the user * to select a different time. This is the single time * dialog as seen in general panel * * PARAMETERS: hour - pointer to hour to change minute - pointer to minute to change * title - string title for the dialog * * RETURNED: true if the OK button was pressed * if true the parameters passed are changed * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * roger 12/2/94 Initial Revision in General Panel * gavin 3/20/98 Extracted into separate system function * ***********************************************************************/ Boolean SelectOneTime(Int16 *hour,Int16 *minute, const Char * titleP) { FormType * originalForm, * frm; EventType event; Boolean confirmed = false; Boolean handled = false; Boolean done = false; TimeFormatType timeFormat; // Format to display time in Int16 curHour; UInt16 currentTimeButton; UInt8 hoursTimeButtonValue; Char hoursTimeButtonString[3]; UInt8 minuteTensButtonValue; Char minuteTensButtonString[2]; UInt8 minuteOnesButtonValue; Char minuteOnesButtonString[2]; Char separatorString[3]; timeFormat = (TimeFormatType)PrefGetPreference(prefTimeFormat); originalForm = FrmGetActiveForm(); frm = (FormType *) FrmInitForm (SelectOneTimeDialog); if (titleP) FrmSetTitle (frm, (Char *) titleP); FrmSetActiveForm (frm); curHour = *hour; if (Use24HourFormat(timeFormat)) { // Hide the AM & PM ui FrmHideObject (frm, FrmGetObjectIndex (frm, timeAMCheckbox)); FrmHideObject (frm, FrmGetObjectIndex (frm, timePMCheckbox)); } else { if (curHour < 12) CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeAMCheckbox)), true); else { CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timePMCheckbox)), true); curHour -= 12; } if (curHour == 0) curHour = 12; } // Set the time seperator to the system defined one separatorString[0] = TimeSeparator(timeFormat); separatorString[1] = '\0'; FrmCopyLabel(frm, timeSeparatorLabel, separatorString); // Now set the time displayed in the push buttons. hoursTimeButtonValue = curHour; StrIToA(hoursTimeButtonString, hoursTimeButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeHourButton)), hoursTimeButtonString); minuteTensButtonValue = *minute / 10; StrIToA(minuteTensButtonString, minuteTensButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesTensButton)), minuteTensButtonString); minuteOnesButtonValue = *minute % 10; StrIToA(minuteOnesButtonString, minuteOnesButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesOnesButton)), minuteOnesButtonString); // Set the hour time button to be the one set by the arrows currentTimeButton = defaultTimeButton; CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, defaultTimeButton)), true); FrmDrawForm (frm); while (!done) { EvtGetEvent (&event, evtWaitForever); if (! SysHandleEvent ((EventType *)&event)) FrmHandleEvent (frm,&event); if (event.eType == ctlSelectEvent) { switch (event.data.ctlSelect.controlID) { case timeOkButton: frm = FrmGetActiveForm(); // Set the new time (seconds are cleared). if (Use24HourFormat(timeFormat)) *hour = hoursTimeButtonValue; else { *hour = hoursTimeButtonValue % 12 + // 12am is 0 hours! (CtlGetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timePMCheckbox))) ? 12 : 0); } *minute = minuteTensButtonValue * 10 + minuteOnesButtonValue; done = true; confirmed = true; break; case timeCancelButton: done = true; break; case timeDecreaseButton: case timeIncreaseButton: frm = FrmGetActiveForm(); switch (currentTimeButton) { // MemHandle increasing and decreasing the time for each time digit case timeHourButton: if (event.data.ctlSelect.controlID == timeDecreaseButton) { if (Use24HourFormat(timeFormat)) if (hoursTimeButtonValue > 0) hoursTimeButtonValue--; else hoursTimeButtonValue = 23; else if (hoursTimeButtonValue > 1) hoursTimeButtonValue--; else hoursTimeButtonValue = 12; } else { if (Use24HourFormat(timeFormat)) if (hoursTimeButtonValue < 23) hoursTimeButtonValue++; else hoursTimeButtonValue = 0; else if (hoursTimeButtonValue < 12) hoursTimeButtonValue++; else hoursTimeButtonValue = 1; } StrIToA(hoursTimeButtonString, hoursTimeButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeHourButton)), hoursTimeButtonString); break; case timeMinutesTensButton: if (event.data.ctlSelect.controlID == timeDecreaseButton) { if (minuteTensButtonValue > 0) minuteTensButtonValue--; else minuteTensButtonValue = 5; } else { if (minuteTensButtonValue < 5) minuteTensButtonValue++; else minuteTensButtonValue = 0; } StrIToA(minuteTensButtonString, minuteTensButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesTensButton)), minuteTensButtonString); break; case timeMinutesOnesButton: if (event.data.ctlSelect.controlID == timeDecreaseButton) { if (minuteOnesButtonValue > 0) minuteOnesButtonValue--; else minuteOnesButtonValue = 9; } else { if (minuteOnesButtonValue < 9) minuteOnesButtonValue++; else minuteOnesButtonValue = 0; } StrIToA(minuteOnesButtonString, minuteOnesButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesOnesButton)), minuteOnesButtonString); break; } handled = true; break; // timeDecreaseButton & timeIncreaseButton case timeHourButton: currentTimeButton = timeHourButton; break; case timeMinutesTensButton: currentTimeButton = timeMinutesTensButton; break; case timeMinutesOnesButton: currentTimeButton = timeMinutesOnesButton; break; } } else if (event.eType == appStopEvent) { EvtAddEventToQueue (&event); done = true; break; } } // end while true FrmEraseForm (frm); FrmDeleteForm (frm); FrmSetActiveForm(originalForm); return (confirmed); }
static Boolean DialogNewGameHandleEvent (EventPtr e) { Boolean handled = false; Char tmpString[5]; FormPtr frm; UInt8 p; switch (e->eType) { case frmOpenEvent: frm = FrmGetActiveForm(); FrmDrawForm(frm); handled = true; break; case penUpEvent: if( e->screenX > NewGameUser && e->screenX < (NewGameUser + NewGameUserSize) && e->screenY > NewGameTop && e->screenY < (NewGameTop + 12 * MaxPlayers) ) { p = (UInt8) ( ( e->screenY - NewGameTop ) / 12 ); NewGameToggleType( p ); if( tmppref[p].type != PlayerNone ) { SetFocus( fldNGname0 + p ); } handled = true; } break; case ctlSelectEvent: switch(e->data.ctlSelect.controlID) { case btn_Variants_frmNewGame: DialogVariants(); handled = true; break; case btn_OK_frmNewGame: handled = !NewGamePlayerCount(); break; case btn_Default_frmNewGame: StrIToA( tmpString, DEFAULT_WINSCORE ); SetFieldTextFromStr( fld_winscore, tmpString ); StrIToA( tmpString, DEFAULT_OPENINGROLL ); SetFieldTextFromStr( fld_openingroll, tmpString ); handled = true; break; } break; default: break; } return handled; }