Exemplo n.º 1
0
void LoadImportPLUG( MADLibrary		*inMADDriver, short	No, FSSpec	*theSpec)
{
	Handle		theRes;
	short		fileID;
	Str255		tStr;

	
	inMADDriver->ThePlug[ No].file = *theSpec;
	
	{
		Boolean		targetIsFolder, wasAliased;
		
		ResolveAliasFile( &inMADDriver->ThePlug[ No].file, true, &targetIsFolder, &wasAliased);
	}

	pStrCpy( inMADDriver->ThePlug[ No].filename, inMADDriver->ThePlug[ No].file.name);
	
	fileID = FSpOpenResFile( theSpec, fsCurPerm);
	
	/** CODE du Plug-in **/
	
	GetIndString( tStr, 1000, 1);
	BlockMoveData( tStr + 1, &inMADDriver->ThePlug[ No].type, 4);
	inMADDriver->ThePlug[ No].type[ 4] = 0;
	
	GetIndString( tStr, 1000, 2);
	BlockMoveData( tStr + 1, &inMADDriver->ThePlug[ No].mode, 4);
	
	GetIndString( inMADDriver->ThePlug[ No].MenuName, 1000, 3);
	GetIndString( inMADDriver->ThePlug[ No].AuthorString, 1000, 4);
	
	CloseResFile( fileID);
}
Exemplo n.º 2
0
void NScanResource( MADLibrary *inMADDriver)
{
	short	i;
	
#define BASERES	1000
	
	for( i = 0; i < MAXPLUG; i++)
	{
		Boolean ResourceOK;
		Handle	aRes, bRes;
		
		ResourceOK = true;
		
		aRes = MADGet1Resource( 'CODE', BASERES + i, inMADDriver);
		if( aRes == NULL) ResourceOK = false;
		else
		{
			DisposeHandle( aRes);
			aRes = NULL;
		}
		
		bRes = MADGet1Resource( 'STR#', BASERES + i, inMADDriver);
		if( bRes == NULL) ResourceOK = false;
		else
		{
			DisposeHandle( bRes);
			bRes = NULL;
		}
		
		if( inMADDriver->TotalPlug < MAXPLUG && ResourceOK == true)
		{
			short		No = inMADDriver->TotalPlug;
			Handle		theRes;
			Str255		tStr;
			
		//	theName = LMGetCurApName();
			
			HGetVol( NULL, &inMADDriver->ThePlug[ No].file.vRefNum, &inMADDriver->ThePlug[ No].file.parID);
			pStrCpy( inMADDriver->ThePlug[ No].file.name, RSRCNAME);
			
			/** CODE du Plug-in **/
			
			GetIndString( tStr, BASERES+i, 1);
			BlockMoveData( tStr + 1, &inMADDriver->ThePlug[ No].type, 4);
			inMADDriver->ThePlug[ No].type[ 4] = 0;
			
			GetIndString( tStr, BASERES+i, 2);
			BlockMoveData( tStr + 1, &inMADDriver->ThePlug[ No].mode, 4);
			
			GetIndString( inMADDriver->ThePlug[ No].MenuName, BASERES+i, 3);
			GetIndString( inMADDriver->ThePlug[ No].AuthorString, BASERES+i, 4);
			
			inMADDriver->TotalPlug++;
		}
	}
}
Exemplo n.º 3
0
void oldsaveMacros(FSSpec *theFile)
{
	SFReply		whereReply;
	short 		refNum,exist;
	FSSpec		macroFile;
	long		junk;
	short 		i;
	char		temp[256], temp2[256];
	Point		where;
	OSErr		err;
	Str255		tempString,tempString2;

	where.h = 100; where.v = 100;

	GetIndString(tempString,MISC_STRINGS,SAVE_MACROS_STRING);
	GetIndString(tempString2,MISC_STRINGS,DEFAULT_MACRO_SET_NAME);

	if (theFile == 0) {
		SFPutFile( where, tempString, tempString2, 0L, &whereReply);

		if (!whereReply.good)
			return;

		BlockMoveData(&whereReply.fName, macroFile.name, (*whereReply.fName)+1); 
		GetWDInfo(whereReply.vRefNum, &macroFile.vRefNum, &macroFile.parID, &junk);
	}
	else
		macroFile = *theFile;

	if ((err = HCreate(macroFile.vRefNum, macroFile.parID, 
			macroFile.name, kNCSACreatorSignature, 'TEXT')) == dupFNErr)
		exist = 1;
	
	err = HOpenDF(macroFile.vRefNum, macroFile.parID, macroFile.name, fsWrPerm, &refNum);

	if (exist) 
		SetEOF(refNum, 0L);

	
	for (i = 0; i < 10; i++)
	{
		oldgetmacro(i, temp, sizeof(temp), 1);
		sprintf(temp2, "key%d = \"", i);
		CStringToFile(refNum,(unsigned char *) temp2);
		if (*temp)
		{
			CStringToFile(refNum,(unsigned char *) temp);
		}
		strcpy(temp2,"\"\015");
		CStringToFile(refNum,(unsigned char *) temp2);

	}
	FSClose(refNum);

}
// --------------------------------------------------------------------------------------
void AddRowsAndDataToIconList(ListHandle iconList, SInt16 iconFamilyBaseID)
{
	short dataLength, rowNumber;
	IconListCellDataRec cellData;
	Cell theCell;
	
	if (!gIconsRegistered)		// if we didn't register our icons already, we need to
	{
		OSErr error;
		FSSpec iconResFile;
		
			/* The first thing we need to do to register an IconRef is to get the FSSpec 
			   for the file containing the icon resources.  This could be the 
			   application file itself or a flattened resource file in a bundle.  Either 
			   way, in this program it's the "current" resource file so we call our 
			   utility function that converts the file reference number returned by 
			   CurResFile to an FSSpec. */
		error = getCurrentResourceFSSpec(&iconResFile);
		
		if (error != noErr)		// if we can't get our icons, this program is kind of useless
			ExitToShell();
		
			// we've got the FSSpec, now get the icons out of it
		dataLength = sizeof(IconListCellDataRec);
		
		for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++)
		{
			RegisterIconRefFromResource(kAppSignature, 'LIc0' + rowNumber, &iconResFile, 
										iconFamilyBaseID + rowNumber, &cellData.icon);
			GetIndString(cellData.name, rIconListStrings, rowNumber + 1);
			
			rowNumber = LAddRow(1, rowNumber, iconList);	// add each row to the 
			SetPt(&theCell, 0, rowNumber);					// bottom of the List
			LSetCell(&cellData, dataLength, theCell, iconList);
		}
		
		gIconsRegistered = true;
	}
	else	// the icons are already registered so we just have to get them
	{
		dataLength = sizeof(IconListCellDataRec);
		
		for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++)
		{
			GetIconRef(kOnSystemDisk, kAppSignature, 'LIc0' + rowNumber, &cellData.icon);
			
			GetIndString(cellData.name, rIconListStrings, rowNumber + 1);
				
			rowNumber = LAddRow(1, rowNumber, iconList);	// add each row to the 
			SetPt(&theCell, 0, rowNumber);					// bottom of the List
			LSetCell(&cellData, dataLength, theCell, iconList);
		}
	}
}
Exemplo n.º 5
0
void
gp_init (void)
{
    extern char    *gs_lib_default_path;
    extern char    *gs_init_file;

#if 0
    /*...Initialize Ghostscript's default library paths and initialization file...*/

    {
        int			i;
        char	  **p;


        for (i = iGSLibPathStr, p = &gs_lib_default_path;
                i <= iGSInitFileStr;
                i++, p = &gs_init_file)
        {
            GetIndString (string, MACSTRS_RES_ID, i);
            (void) PtoCstr (string);
            *p = malloc ((size_t) (strlen ((char *) string) + 1));
            strcpy (*p, (char *) string);
        }
    }
#endif
}
Exemplo n.º 6
0
OSErr	FindPrefs(FSSpec* where)
{
	OSErr		error = noErr;
	Str255	theString;
	Str255	name;
	FSSpec	spec;
	short		foundVRefNum;
	long		foundDirID;
	// Look for the prefs in the folder
	GetIndString(theString, kTransportPath, 1);
	p2cstr(theString);
	strncpy(name, theString, 63);
	strncat(name, "Modem prefs", 63);
	c2pstr(name);
	error = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &foundVRefNum, &foundDirID);
	if (error == noErr) {
		error = FSMakeFSSpec(foundVRefNum, foundDirID, name, where);
		if (error == fnfErr) {		// May need to create the file
			FSpCreateResFile(where, 'mwNT', 'pref', smSystemScript);
			error = ResError();
		}
	}

	return error;
}
Exemplo n.º 7
0
void SetBasePath(void)
{
	OSErr			error;
	FSSpec		where;
	//Handle		theString;
	Str255		name;
	short			vRef;
	long			dirID;
	long			nDirID;
	error = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &vRef, &dirID);
	GetIndString(name, kTransportPath, 1);
	if (name[0] != '0') {
		error = FSMakeFSSpec(vRef, dirID, name, &where);	// First, check to see if the directory exists
		if (error != noErr) {
			// Create it
			error = FSpDirCreate(&where, smSystemScript, &nDirID);
		}
		p2cstr(name);
		strncat((char *)name, "Serial", 63);	// It won't matter if this exists or not; we'll get the parent directory ID this way
		c2pstr((char *)name);
		error = FSMakeFSSpec(vRef, dirID, name, &where);
		gvRef = where.vRefNum;
		gparID = where.parID;
	}
}
Exemplo n.º 8
0
void display_help(short mode,short parent)
{
	Str255 get_text;
   long get_val;
   short item_hit;
	
	store_help_mode = mode;
	cur_entry = 3;

	make_cursor_sword();

	cd_create_dialog_parent_num(997,parent);

		get_str (get_text, 25 + mode, 1);
		csit( 997,6,(char *) get_text);
		GetIndString (get_text, 25 + mode, 2);
		StringToNum(get_text,&get_val);
		num_entries = (short) get_val;
		get_str (get_text, 25 + mode, cur_entry);
		csit( 997,7,(char *) get_text);
	
	
	item_hit = cd_run_dialog();	
	cd_kill_dialog(997);

}
Exemplo n.º 9
0
Boolean itworked(short errcode)
/* Return TRUE if it worked, do an error message and return false if it didn't. Error
   strings for native C errors are in STR#1999, Mac errs in STR 2000-errcode, e.g
   2108 for not enough memory */

{
	if (errcode != 0) {
		short		 itemHit;
		Str255 		 errdesc;
		StringHandle strh;
	
		errdesc[0] = '\0';
		if (errcode > 0) GetIndString(errdesc,stdIOErrID,errcode);  /* STDIO file rres, etc */
		else {
			strh = GetString(2000-errcode);
			if (strh != (StringHandle) nil) {
				memcpy(errdesc,*strh,256);
				ReleaseResource((Handle)strh);
			}
		}
		if (errdesc[0] == '\0') {  /* No description found, just give the number */
			sprintf((char *)&errdesc[1],"a %d error occurred",errcode);
			errdesc[0] = strlen((char*)&errdesc[1]);
		}
		SetCursor(&qd.arrow);
		ParamText(errdesc,(StringPtr)"",gActivities[gTopactivity],(StringPtr)"");
		itemHit = Alert(errAlertID, (ModalFilterUPP)nil);
	}
	return(errcode==0);
}
Exemplo n.º 10
0
void ErrorHandler(short errCode, Str255 msg)
{
// TO DO
//		* handle a "fatality" parameter for recovery

    Str255      pErrorStr;
    Str255      pMessage, errMsg;
    char        *cErrNo = 0;
    StringPtr   pErrNo = 0;
    AlertStdAlertParamRec *alertdlg;

    // only throw up the error dialog once (since we have no fatality param)
    static Boolean bErrHandled = false;
    if (bErrHandled)
        return;
    else
        bErrHandled = true;
        
    // if install.ini read failed
    if( errCode == eInstRead )
    {
        GetIndString(pErrorStr, rStringList, errCode);
        ParamText(pErrorStr, "\p", "\p", "\p");
        StopAlert(rAlrtError, nil);
        SysBeep(10);
        gDone = true;
        return;
    }
Exemplo n.º 11
0
void Init(void)
{
	Str255		 	winTitle;
	OSErr			err = noErr;
    Str255			instMode;
    Ptr				pinstMode;
	
	gDone = false;
	InitManagers();
	InitControlsObject();	
	CleanTemp();

	ParseInstall();

	gWPtr = GetNewCWindow(rRootWin, NULL, (WindowPtr) -1);	
    GetIndString( instMode, rTitleStrList, sNSInstTitle);
    pinstMode = PascalToC(instMode);
#if MOZILLA == 0
    GetResourcedString(winTitle, rInstList, sNsTitle);
#else
    GetResourcedString(winTitle, rInstList, sMoTitle);
#endif
	SetWTitle( gWPtr, winTitle );	
	SetWRefCon(gWPtr, kMIWMagic);
	MakeMenus();

	ParseConfig(); 
	InitOptObject();
	
	ShowWelcomeWin();	
	SetThemeWindowBackground(gWPtr, kThemeBrushDialogBackgroundActive, true); 
	
	/* Set menu */
	InitNewMenu();
}
Exemplo n.º 12
0
static boolean shellcheckprinterror (boolean flopening) {
	
	/*
	 returns false if there was a print error.
	 
	 1/18/93 dmb: take flopening parameter, & special case this error
	 */
	
	OSErr x;
	bigstring bserror;
	
#	ifdef MACVERSION
	
	//Code change by Timothy Paustian Friday, June 16, 2000 3:50:52 PM
	//Changed to Opaque call for Carbon
	// this is pointless --- explicitly excluded
#		if TARGET_API_MAC_CARBON == 1
	
	x = PMSessionError(shellprintinfo.printhandle);
	
#		else	
	
	x = PrError ();
	
#		endif
	
	if (x == noErr) /*no error, keep going*/
		return (true);
	
	if (x != iPrAbort) {
		
		if (flopening) 
		{
			GetIndString (bserror, interfacelistnumber, trychooserstring);
		}
		else {
			
			getsystemerrorstring (x, bserror);
			
			parsedialogstring (bserror, "\x06" ".Print", nil, nil, nil, bserror);
		}
		
		shellerrormessage (bserror);
	}
	
#	endif
	
#ifdef WIN95VERSION
	x = GetLastError();

	if (x == 0)
		return (true);

	getsystemerrorstring (x, bserror);

	shellerrormessage (bserror);
#endif
	
	return (false); /*there was an error*/
	} /*shellcheckprinterror*/
Exemplo n.º 13
0
McoStatus PrinterType::Save(void)
{
	int i;
	StandardFileReply 	soutReply;
	Str255				prompt;
	Str255				outname = "\p";
	McoStatus status = MCO_SUCCESS;
	FileFormat *filef;
	int   magic_num = PRINTERTYPE_MAGICNUM;
	int   version = PRINTERTYPE_VERSION;
	
	GetIndString(prompt,PROMPT_STRINGS,SETTINGS_PROMPT);
	
	StandardPutFile(prompt, outname, &soutReply);
	if(!soutReply.sfGood) return MCO_CANCEL;



	filef = new FileFormat;

	status = filef->createFilewithtype(&soutReply.sfFile,soutReply.sfScript,MONACO_SIG,'MCO6');
	if (status != MCO_SUCCESS) goto bail;

	status = filef->relWrite(sizeof(int),(char*)&magic_num);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(int),(char*)&version);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(ConData),(char*)&data);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(int),(char*)&num_hands);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(double)*31,(char*)x_hands);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(double)*31,(char*)y_hands);
	if (status != MCO_SUCCESS) goto bailclose;
	
	status = filef->relWrite(sizeof(int),(char*)&sim_num);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(int),(char*)&num_tweaks);
	if (status != MCO_SUCCESS) goto bailclose;

	for (i=0; i<num_tweaks; i++)
		{
		status = filef->relWrite(sizeof(Tweak_Element),(char*)tweaks[i]);
		if (status != MCO_SUCCESS) goto bailclose;
		}

	bailclose:
	filef->closeFile();
	bail:
	delete filef;
	return status;
}
Exemplo n.º 14
0
/* フォルダアイコンをチェック */
OSErr FolderIconCheck(const FSSpec *theFolderSpec,short *alertMode)
{
	OSErr	err;
	long	dirID;
	FSSpec	theIconFile;
	Str15	iconFileName;
	Boolean	isDirectory;
	#ifdef __MOREFILESX__
	FSRef	fsRef;
	FinderInfo	info;
	
	err = FSpMakeFSRef(theFolderSpec,&fsRef);
	if (err != noErr) return err;
	#else
	DInfo	dirInfo;
	#endif
	
	/* まず、カスタムアイコンフラグが立っているかどうかを調べる */
	/* ここでエラーが発生する場合はおそらくフォルダアイコン編集も不可能なのでそのまま返る */
	#ifdef __MOREFILESX__
	err = FSGetFinderInfo(&fsRef,&info,NULL,NULL);
	#else
	err=FSpGetDInfo(theFolderSpec,&dirInfo);
	#endif
	if (err!=noErr) return err;
	
	/* カスタムアイコンフラグが立っていなければ問題なし */
	#ifdef __MOREFILESX__
	if ((info.folder.finderFlags & kHasCustomIcon) == 0) return noErr;
	#else
	if ((dirInfo.frFlags & kHasCustomIcon) == 0) return noErr;
	#endif
	
	/* 立っている場合は、カスタムアイコンをチェック */
	#ifdef __MOREFILESX__
	err = FSGetNodeID(&fsRef,&dirID,&isDirectory);
	#else
	err=FSpGetDirectoryID(theFolderSpec,&dirID,&isDirectory);
	#endif
	if (err!=noErr) return err;
	
	GetIndString(iconFileName,140,3);
	err=FSMakeFSSpec(theFolderSpec->vRefNum,dirID,iconFileName,&theIconFile);
	if (err==fnfErr) /* アイコンファイルが見つからない場合は、フラグが間違っているわけだから修正 */
	{
		#ifdef __MOREFILESX__
		err = FSClearHasCustomIcon(&fsRef);
		#else
		err=FSpClearHasCustomIcon(theFolderSpec);
		#endif
		return noErr;
	}
	else if (err!=noErr) /* それ以外のエラーなら編集できないだろうから戻る */
		return err;
	
	return FileIconCheck(&theIconFile,alertMode);
}
Exemplo n.º 15
0
const CHXString& CHXString::SetFromIndString(short strlist, short item)
{
    Str255	theStr;

    GetIndString(theStr,strlist,item);

    SetFromStr255(theStr);

    return *this;
}
Exemplo n.º 16
0
short ModalMacros(NewMacroInfo *macrost)
{
	DialogPtr dtemp;
	short dItem;
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	SetUpMovableModalMenus();
	dtemp=GetNewMyDialog( MacroDLOG + 2, NULL, kInFront, (void *)ThirdCenterDialog);
	SetDialogDefaultItem(dtemp, 1);
	SetDialogCancelItem(dtemp, 2);
	SetDialogTracksCursor(dtemp, 1);
	HideDialogItem(dtemp, 25); // no save default in session macros dialog

	dialogPane = 0; // start with Command-[0-9]

	// RAB BetterTelnet 2.0b5 - fix cancel button so it works again
	oldMacros = macrost->handle;
	HandToHand(&oldMacros);
	oldMacroIndexes = *macrost;

	// now fix the strings
	for (i=0; i<10; i++) {
		GetIndString(temp, 7100, i + (10 * dialogPane) + 1);
		GetDialogItem(dtemp, i+3, &dItem, &rubbish, &dBox);
		if (!temp[0]) { HideDialogItem(dtemp, i+13); HideDialogItem(dtemp, i+3); }
		else { ShowDialogItem(dtemp, i+13); ShowDialogItem(dtemp, i+3); }
		SetDialogItemText(rubbish, temp);
	}

	for (i=0; i<10; i++) {
		getmacro(macrost, i, (char *) &temp, 256); /* BYU LSC */
		c2pstr((char *)temp);								/* BYU LSC */
		GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
		SetDialogItemText( MacString[i], temp );
		}

	TelInfo->macrosModeless = dtemp;

	dItem = 0;
	while ((dItem != 1) && (dItem != 2)) {
		movableModalDialog(0, &dItem);
		MacroDialog(macrost, dtemp, 0, dItem);
	}

	if (dItem == 2) CancelMacros(macrost, dtemp);
	else CloseMacros(macrost, dtemp);
	ResetMenus();
	return dItem;
}
Exemplo n.º 17
0
doZoneStatus(short mapH, short mapV)
{
  char localStr[256];
  char statusStr[5][256];
  short id;
  short x;
  short tileNum;
  short found;

  tileNum = Map[mapH][mapV] & LOMASK;

  if (tileNum >= COALSMOKE1 && tileNum < FOOTBALLGAME1)
    tileNum = COALBASE;

  found = 1;
  for (x = 1; x < 29 && found; x++) {
    if (tileNum < idArray[x]) {
      found = 0;
    }
  }
  x--;

  if (x < 1 || x > 28)
    x = 28;

  GetIndString(localStr, 219, x);

  for (x = 0; x < 5; x++) {
    id = getDensityStr(x, mapH, mapV);
    id++;
    if (id <= 0) id = 1;
    if (id > 20) id = 20;
    GetIndString(statusStr[x], 202, id);
  }

  DoShowZoneStatus(localStr, statusStr[0], statusStr[1],
		   statusStr[2], statusStr[3], statusStr[4], mapH, mapV);
}
Exemplo n.º 18
0
void SaveGlobalMacros(NewMacroInfo *macrost)
{
	OSErr err;
	FSSpec macroFile;
	Boolean dummy1, dummy2;
	Str255 tempString;

	GetIndString(tempString, MISC_STRINGS, MACROS_FILE_NAME);
	err = FSMakeFSSpec(TelInfo->PrefFolder.vRefNum, TelInfo->PrefFolder.parID, tempString, &macroFile);
	if ((!err) || (err == -43)) {
		ResolveAliasFile(&macroFile, FALSE, &dummy1, &dummy2);
		saveMacros(macrost, &macroFile);
	}
}
Exemplo n.º 19
0
void	Macros( void)
{
	DialogPtr dtemp;
	short dItem;
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	setLastCursor(theCursors[normcurs]);

	if (TelInfo->macrosModeless) {
		SelectWindow(TelInfo->macrosModeless);
		return;
	}

	dtemp=GetNewMyDialog( MacroDLOG, NULL, kInFront, (void *)ThirdCenterDialog);
	SetDialogDefaultItem(dtemp, 1);
	SetDialogCancelItem(dtemp, 2);
	SetDialogTracksCursor(dtemp, 1);

	dialogPane = 0; // start with Command-[0-9]

	// RAB BetterTelnet 2.0b5 - fix cancel button so it works again
	oldMacros = TelInfo->newMacros.handle;
	HandToHand(&oldMacros);
	oldMacroIndexes = TelInfo->newMacros;

	// now fix the strings
	for (i=0; i<10; i++) {
		GetIndString(temp, 7100, i + (10 * dialogPane) + 1);
		GetDialogItem(dtemp, i+3, &dItem, &rubbish, &dBox);
		if (!temp[0]) { HideDialogItem(dtemp, i+13); HideDialogItem(dtemp, i+3); }
		else { ShowDialogItem(dtemp, i+13); ShowDialogItem(dtemp, i+3); }
		SetDialogItemText(rubbish, temp);
	}

	for (i=0; i<10; i++) {
		getmacro(&TelInfo->newMacros, i, (char *) &temp, 256); /* BYU LSC */
		c2pstr((char *)temp);								/* BYU LSC */
		GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
		SetDialogItemText( MacString[i], temp );
		}
	TelInfo->macrosModeless = dtemp;
}
Exemplo n.º 20
0
void tip_of_day()
{
	char place_str[256];

	store_tip_page_on = get_ran(1,0,NUM_HINTS - 1);

	SetCursor(sword_curs);

	cd_create_dialog_parent_num(958,0);

	GetIndString(place_str,12,50 + store_tip_page_on);
	csit(958,3, place_str);

	cd_set_led(958,7,give_intro_hint);

	while (dialog_not_toast) ModalDialog();

	cd_kill_dialog(958,0);
    build_data_file(2);
}
Exemplo n.º 21
0
void CheckGlobalMacros(void)
{
	OSErr err;
	FSSpec macroFile;
	Boolean dummy1, dummy2;
	Str255 tempString;

// RAB BetterTelnet 2.0b5
// if there's no global file, we have to get our default from the resource fork...
// we load them first just in case we have OLD macros in the macros file, in which case
// we have to add them to the defaults rather than replace the default

	GetDefaultMacros();

	GetIndString(tempString, MISC_STRINGS, MACROS_FILE_NAME);
	err = FSMakeFSSpec(TelInfo->PrefFolder.vRefNum, TelInfo->PrefFolder.parID, tempString, &macroFile);
	if (!err) {
		ResolveAliasFile(&macroFile, FALSE, &dummy1, &dummy2);
		loadMacros(&TelInfo->newMacros, &macroFile);
	}
}
Exemplo n.º 22
0
Arquivo: main.cpp Projeto: boredzo/CCX
void Error( const char* extra )
{
#if TARGET_API_MAC_CARBON
	Str255 myString, extraP;
	
	CopyCStringToPascal( extra, extraP );
	ReleaseMonitor( );
	GetIndString( myString, 131, errUnknown );
	ParamText( myString, extraP, "\p", "\p" );
	Alert( dFatalErrorAlert, NULL );
	ExitToShell( );
#else
	char message[256];
	sprintf( message, "Sorry, a critical error has occurred. Please report the following error message:\n    %s", extra );
	#if WIN32
		MessageBox( NULL, message, "Candy Crisis", MB_OK );
	#else
		fprintf(stderr, "Candy Crisis: %s\n", message);
	#endif
	exit(0);
#endif
}
Exemplo n.º 23
0
void get_str(char *str,short i, short j)
{
	if (i == -1) {
		strcpy((char *) str,scen_item_list.monst_names[j]);
		return;
		}
	if (i == -2) {
		strcpy((char *) str,scen_item_list.scen_items[j].full_name);
		return;
		}
	if (i == -3) {
		strcpy((char *) str,button_strs[available_dlog_buttons[j]]);
		return;
		}
	if (i == -4) {
		strcpy((char *) str,scen_item_list.ter_names[j]);
		return;
		}
	if (i == -5) {
		get_str(str,40,j * 7 + 1);
		return;
		}
	GetIndString(str, i, j);
}
Exemplo n.º 24
0
void tip_of_day_event_filter (short item_hit)
{
	char place_str[256];

			switch (item_hit) {
				case 1:
					dialog_not_toast = false;
					break;

				case 5:
					store_tip_page_on++;
					if (store_tip_page_on == NUM_HINTS)
						store_tip_page_on = 0;
					GetIndString(place_str,12,50 + store_tip_page_on);
					csit(958,3, place_str);
					break;

				case 7:
					give_intro_hint = 1 - give_intro_hint;
					cd_set_led(958,7,give_intro_hint);
					break;
			}

}
Exemplo n.º 25
0
void handle_talk_event(POINT p)
{
	short i,j,force_special = 0,get_pc,s1 = -1,s2 = -1,s3 = -1;
	char asked[4];
	char place_string1[256] = "";
	char place_string2[256] = "";

	short a,b,c,d,ttype,which_talk_entry = -1;

	p.x -= 5;
	p.y -= 5;

	if (PtInRect(&talk_help_rect,p)) {
    	if (play_sounds == true) play_sound(37);
		party.help_received[5] = 0;
		give_help(205,6,0);
		return;
		}

	for (i = 0; i < 9; i++)
		if ((PtInRect(&preset_words[i].word_rect,p)) && ((talk_end_forced == false) || (i == 6) || (i == 5))) {
			click_talk_rect((char *) old_str1,(char *) old_str2,preset_words[i].word_rect);
			switch (i) {
				case 0: case 1: case 2: case 7: case 8:
					force_special = i + 1;
					break;
				case 3: case 4:
					force_special = i + 1;
					break;
				case 5: // save
					if (strnum1 <= 0) {
						MessageBeep(MB_OK);
						return;
						}
					for (j = 0; j < 120; j++)
						if ((party.talk_save[j].personality == store_personality) &&
						  (party.talk_save[j].str1 == strnum1) &&
						  (party.talk_save[j].str2 == strnum2)) {
						  	ASB("This is already saved.");
						  	print_buf();
						  	return;
						  	}
					for (j = 0; j < 120; j++)
						if (party.talk_save[j].personality <= 0) {
							give_help(57,0,0);
							play_sound(0);
							party.talk_save[j].personality = store_personality;
							party.talk_save[j].town_num = (unsigned char) c_town.town_num;
							party.talk_save[j].str1 = strnum1;
							party.talk_save[j].str2 = strnum2;
							ASB("Noted in journal.");
							j = 200;
							}
					if (j < 200) {
						MessageBeep(MB_OK);
						ASB("No more room in talking journal.");
						}
					print_buf();
					return;
					break;
				case 6: // quit
					end_talk_mode();

                	if(talk_end_forced == 10){ // party is in inn
                        talk_end_forced = true; // safety set
                        for(j=0; j < 700; j++){
                            party.age++;
                            // Specials countdowns
                            if ((party.age % 500 == 0) && (get_ran(1,0,5) == 3) && (adven.hasAbil(ITEM_DISEASE_PARTY) == true)) {
                                j = 900;
                                adven.disease(2);
                             }
                             // Plants and magic shops
                             if (party.age % 4000 == 0) refresh_store_items();

                             timed_special_happened = special_increase_age(0);//don't delay the trigger of the special, if there's a special

                             if(timed_special_happened && PSD[SDF_COMPATIBILITY_SPECIALS_INTERRUPT_REST] == 1){
                                j = 900;
               			        add_string_to_buf("  Rest interrupted.");
               			        print_buf();
                            }
                         }
                      }
					return;
					break;
				default:
					for (j = 0; j < 4; j++)
						asked[j] = preset_words[i].word[j];
					break;
				}
			i = 100;
			}
	if (i < 100) {
		for (i = 0; i < 50; i++)
			if ((PtInRect(&store_words[i].word_rect,p)) && (talk_end_forced == false)) {
				click_talk_rect((char *) old_str1,(char *) old_str2,store_words[i].word_rect);
				for (j = 0; j < 4; j++)
					asked[j] = store_words[i].word[j];

				i = 100;
				}
		}
    if(strcmp(talk_edit_string,"") != 0){
        for(j = 0; j < 4; j++)
            asked[j] = talk_edit_string[j];
        talk_edit_string[0] = '\0';
        i =  100;
        }

	if (i == 50) // no event
		return;
	if (force_special == 9) {
		get_text_response(1017,place_string1,0);
		asked[0] = place_string1[0];
		asked[1] = place_string1[1];
		asked[2] = place_string1[2];
		asked[3] = place_string1[3];
		}

	if ((asked[0] == 'n') && (asked[1] == 'a') &&(asked[2] == 'm') &&(asked[3] == 'e')) {
		force_special = 2;
		}
	if ((asked[0] == 'l') && (asked[1] == 'o') &&(asked[2] == 'o') &&(asked[3] == 'k')) {
		force_special = 1;
		}
	if (((asked[0] == 'j') && (asked[1] == 'o') &&(asked[2] == 'b')) ||
		((asked[0] == 'w') && (asked[1] == 'o') &&(asked[2] == 'r')&&(asked[3] == 'k')) ) {
		force_special = 3;
		}
	if((asked[0] == 'b') && (asked[1] == 'u') && (asked[2] == 'y'))
	   force_special = 4;
	if((asked[0] == 'b') && (asked[1] == 'y') && (asked[2] == 'e')){
		end_talk_mode();
        return;
        }

	if (force_special > 0) {
		switch (force_special) {
			case 1: case 2: case 3:
				GetIndString(place_string1,120 + ((store_personality - 1) / 10),
				 ((store_personality - 1) % 10) * 3 + 10 + force_special);
				sprintf((char *) place_string1,"%s",data_store3->talk_strs[store_personality % 10 + 10 * force_special]);

				oldstrnum1 = strnum1; oldstrnum2 = strnum2;
				strnum1 =  store_personality % 10 + 10 * force_special;
				strnum2 = 0;
				strcpy((char *) one_back1,(char *) old_str1);
				strcpy((char *) one_back2,(char *) old_str2);
				strcpy((char *) old_str1,(char *) place_string1);
				strcpy((char *) old_str2,(char *) place_string2);
				place_talk_str((char *) place_string1,(char *) place_string2,0,dummy_rect);
				return;
				break;
			case 4: // buy button
				asked[0] = 'p';asked[1] = 'u';asked[2] = 'r';asked[3] = 'c';
				if (scan_for_response(asked) >= 0)
					break;
				asked[0] = 's';asked[1] = 'a';asked[2] = 'l';asked[3] = 'e';
				if (scan_for_response(asked) >= 0)
					break;
				asked[0] = 'h';asked[1] = 'e';asked[2] = 'a';asked[3] = 'l';
				if (scan_for_response(asked) >= 0)
					break;
				asked[0] = 'i';asked[1] = 'd';asked[2] = 'e';asked[3] = 'n';
				if (scan_for_response(asked) >= 0)
					break;
				asked[0] = 't';asked[1] = 'r';asked[2] = 'a';asked[3] = 'i';
				if (scan_for_response(asked) >= 0)
					break;
				break;
			case 5: // sell button
				asked[0] = 's';asked[1] = 'e';asked[2] = 'l';asked[3] = 'l';
				if (scan_for_response(asked) >= 0)
					break;
				break;
			case 8: // back 1
				strnum1 = oldstrnum1; strnum2 = oldstrnum2;
				strcpy((char *) place_string1,(char *) one_back1);
				strcpy((char *) place_string2,(char *) one_back2);
				strcpy((char *) one_back1,(char *) old_str1);
				strcpy((char *) one_back2,(char *) old_str2);
				strcpy((char *) old_str1,(char *) place_string1);
				strcpy((char *) old_str2,(char *) place_string2);
				place_talk_str((char *) place_string1,(char *) place_string2,0,dummy_rect);
				return;
				break;
			}
		}

	which_talk_entry = scan_for_response(asked);
	if ((which_talk_entry < 0) || (which_talk_entry > 59)) {
		strcpy((char *) one_back1,(char *) old_str1);
		strcpy((char *) one_back2,(char *) old_str2);
		sprintf((char *) old_str2,"");
		sprintf((char *) old_str1,"%s",data_store3->talk_strs[store_personality % 10 + 160]);
		if (strlen((char *) old_str1) < 2)
			sprintf((char *) old_str1,"You get no response.");
		place_talk_str((char *) old_str1,(char *) old_str2,0,dummy_rect);
		strnum1 = -1;
		return;
		}

	ttype = talking.talk_nodes[which_talk_entry].type;
	a = talking.talk_nodes[which_talk_entry].extras[0];
	b = talking.talk_nodes[which_talk_entry].extras[1];
	c = talking.talk_nodes[which_talk_entry].extras[2];
	d = talking.talk_nodes[which_talk_entry].extras[3];

	sprintf(place_string1,"%s",data_store3->talk_strs[40 + which_talk_entry * 2]);
	sprintf(place_string2,"%s",data_store3->talk_strs[40 + which_talk_entry * 2 + 1]);

	oldstrnum1 = strnum1; oldstrnum2 = strnum2;
	strnum1 =  40 + which_talk_entry * 2; strnum2 = 40 + which_talk_entry * 2 + 1;

	switch(ttype) {
		case TALK_REGULAR:
			break;
		case TALK_DEP_ON_SDF:
			if (PSD[a][b] > c) {
				strnum1 = strnum2;
				strcpy(place_string1, place_string2);
				}
			sprintf(place_string2,"");
			strnum2 = 0;
			break;
		case TALK_SET_SDF:
			PSD[a][b] = 1;
			break;
		case TALK_INN:
			if (party.gold < a) {
				strnum1 = strnum2;
				strcpy(place_string1, place_string2);
				}
				else {
					talk_end_forced = true;
					party.gold -= a;
					put_pc_screen();
                    if(PSD[SDF_COMPATIBILITY_CHECK_TIMERS_WHILE_RESTING] == 1){
                       talk_end_forced = 10;
                       adven.heal(30 * b);
	                   adven.restoreSP(25 * b);
      				   c_town.p_loc.x = c;
	          		   c_town.p_loc.y = d;
			           center = c_town.p_loc;
                       }
					else{
                    adven.heal(30 * b);
					adven.restoreSP(25 * b);
					party.age += 700;
					c_town.p_loc.x = c;
					c_town.p_loc.y = d;
					center = c_town.p_loc;
                    }
				}
			strnum2 = 0;
			sprintf(place_string2,"");
			break;
		case TALK_DEP_ON_TIME:
			if (day_reached((unsigned char) a,0) == true) {
				strnum1 = strnum2;
				strcpy(place_string1, place_string2);
				}
			sprintf(place_string2,"");
			strnum2 = 0;
			break;
		case TALK_DEP_ON_TIME_AND_EVENT:
			if (day_reached((unsigned char) a,(unsigned char) b) == true) {
				strnum1 = strnum2;
				strcpy(place_string1, place_string2);
				}
			sprintf(place_string2,"");
			strnum2 = 0;
			break;
		case TALK_DEP_ON_TOWN:
			if (c_town.town_num != a) {
				strnum1 = strnum2;
				strcpy(place_string1, place_string2);
				}
			sprintf(place_string2,"");
			strnum2 = 0;
			break;
		case TALK_BUY_ITEMS:
			c = minmax(1,30,(int)c);
			start_shop_mode(SHOP_MISC_SHOP,b,
				b + c - 1,a, place_string1);
			strnum1 = -1;
			return;
		case TALK_TRAINING:
			if ((get_pc = char_select_pc(1,0,"Train who?")) < 6) {
				strnum1 = -1;
				spend_xp(get_pc,1, 0);
				}
			sprintf(place_string1, "You conclude your training.");
            put_pc_screen();
			return;

		case TALK_BUY_MAGE: case TALK_BUY_PRIEST: case TALK_BUY_ALCHEMY:
			c = minmax(1,30,(int)c);
			start_shop_mode(ttype + 1,b,
				b + c - 1,a, place_string1);
			strnum1 = -1;
			return;
		case TALK_BUY_HEALING: //healer
			start_shop_mode(SHOP_HEALER,0,0,a, place_string1);
			strnum1 = -1;
			return;
			break;
		case TALK_SELL_WEAPONS: // sell weap
			strnum1 = -1;
			stat_screen_mode = 3;
			put_item_screen(stat_window,1);
			give_help(42,43,0);
			break;
		case TALK_SELL_ARMOR: // sell armor
			strnum1 = -1;
			stat_screen_mode = 4;
			put_item_screen(stat_window,1);
			give_help(42,43,0);
			break;
		case TALK_SELL_ITEMS: // sell misc
			strnum1 = -1;
			stat_screen_mode = 5;
			put_item_screen(stat_window,1);
			give_help(42,43,0);
			break;
		case TALK_IDENTIFY: case TALK_ENCHANT: // ident, enchant
            strnum1 = -1;
			stat_screen_mode = (ttype == 16) ? 2 : 6;
			shop_identify_cost = a;
			put_item_screen(stat_window,1);
			give_help(ttype - 16 + 44,0,0);
			break;
		case TALK_BUY_INFO:
			if (party.gold < a) {
				strnum1 = strnum2;
				strcpy(place_string1, place_string2);
				}
				else {
					party.gold -= a;
					put_pc_screen();

					}
			sprintf(place_string2,"");
			strnum2 = 0;
			break;
		case TALK_BUY_SDF:
			if ((sd_legit(b,c) == true) && (PSD[b][c] == d)) {
				sprintf(place_string1, "You've already learned that.");
				strnum1 = -1;
				}
			else if (party.gold < a) {
				strnum1 = strnum2;
				strcpy(place_string1, place_string2);
				}
				else {
					party.gold -= a;
					put_pc_screen();
					if (sd_legit(b,c) == true)
						PSD[b][c] = d;
						else give_error("Invalid Stuff Done flag called in conversation.","",0);
					}
			strnum2 = 0;
			sprintf(place_string2,"");
			break;
		case TALK_BUY_SHIP:
			if (party.gold < a) {
				strnum1 = strnum2;
				strnum2 = 0;
				strcpy(place_string1, place_string2);
				sprintf(place_string2,"");
				break;
				}
				else {
					for (i = b; i <= b + c; i++)
						if ((i >= 0) && (i < 30) && (party.boats[i].property == true)) {
							party.gold -= a;
							put_pc_screen();
							party.boats[i].property = false;
							sprintf(place_string2,"");
							strnum2 = 0;
							i = 1000;
							}
					if (i >= 1000)
						break;
					}
			sprintf(place_string1, "There are no boats left.");
			sprintf(place_string2,"");
			strnum1 = -1;
			strnum2 = -1;
			break;
		case TALK_BUY_HORSE:
			if (party.gold < a) {
				strnum1 = strnum2;
				strnum2 = 0;
				strcpy(place_string1, place_string2);
				sprintf(place_string2,"");
				break;
				}
				else {
					for (i = b; i <= b + c; i++)
						if ((i >= 0) && (i < 30) && (party.horses[i].property == true)) {
							party.gold -= a;
							put_pc_screen();
							party.horses[i].property = false;
							sprintf(place_string2,"");
							strnum2 = 0;
							i = 1000;
							}
					if (i >= 1000)
						break;
					}
			sprintf(place_string1, "There are no horses left.");
			sprintf(place_string2,"");
			strnum1 = -1;
			strnum2 = -1;
			break;
		case TALK_BUY_SPEC_ITEM:
			if (party.spec_items[a] > 0) {
				sprintf(place_string1, "You already have it.");
				strnum1 = -1;
				}
			else if (party.gold < b) {
				strcpy(place_string1, place_string2);
				strnum1 = strnum2;
				}
				else {
					party.gold -= b;
					put_pc_screen();
					party.spec_items[a] = 1;
					}
			strnum2 = 0;
			sprintf(place_string2,"");
			break;
		case TALK_BUY_JUNK:
			start_shop_mode(SHOP_MAGIC_SHOP_1 + b,0,
				9,a, place_string1);
			strnum1 = -1;
			return;
		case TALK_BUY_TOWN_LOC:
			if (party.can_find_town[b] > 0) {
				}
				else if (party.gold < a) {
					strnum1 = strnum2;
					strcpy(place_string1, place_string2);
					}
					else {
						party.gold -= a;
						put_pc_screen();
						party.can_find_town[b] = 1;
						}
			strnum2 = 0;
			sprintf(place_string2,"");
			break;
		case TALK_END_FORCE:
			talk_end_forced = true;
			break;
		case TALK_END_FIGHT:
			c_town.monst.dudes[store_m_num].attitude = 1;
			c_town.monst.dudes[store_m_num].mobile = 1;
			talk_end_forced = true;
			break;
		case TALK_END_ALARM:
			set_town_status(0);
			talk_end_forced = true;
			break;
		case TALK_END_DIE:
			c_town.monst.dudes[store_m_num].active = 0;
            // Special killing effects
            if (sd_legit(c_town.monst.dudes[store_m_num].monst_start.spec1,c_town.monst.dudes[store_m_num].monst_start.spec2) == true)
                party.stuff_done[c_town.monst.dudes[store_m_num].monst_start.spec1][c_town.monst.dudes[store_m_num].monst_start.spec2] = 1;
			talk_end_forced = true;
			break;
		case TALK_CALL_TOWN_SPEC: // town special
			 run_special(SPEC_TALK,2,a,c_town.p_loc,&s1,&s2,&s3);
			// check s1 & s2 to see if we got diff str, and, if so, munch old strs
			if ((s1 >= 0) || (s2 >= 0)) {
				strnum1 = -1;
				strnum2 = -1;
				sprintf(place_string1,"");
				sprintf(place_string2,"");
				}
			 get_strs(place_string1, place_string2,2,s1,s2);
			 if (s1 >= 0) strnum1 = 2000 + s1;
			 if (s2 >= 0) strnum2 = 2000 + s2;
			 put_pc_screen();
			 put_item_screen(stat_window,0);
			 break;
		case TALK_CALL_SCEN_SPEC: // scen special
			 run_special(SPEC_TALK,0,a,c_town.p_loc,&s1,&s2,&s3);
			// check s1 & s2 to see if we got diff str, and, if so, munch old strs
			if ((s1 >= 0) || (s2 >= 0)) {
				strnum1 = -1;
				strnum2 = -1;
				sprintf(place_string1,"");
				sprintf(place_string2,"");
				}
			 get_strs(place_string1, place_string2,0,s1,s2);
			 if (s1 >= 0) strnum1 = 3000 + s1;
			 if (s2 >= 0) strnum2 = 3000 + s2;
			put_pc_screen();
			put_item_screen(stat_window,0);
			break;
		}

	strcpy(one_back1, old_str1);
	strcpy(one_back2, old_str2);
	strcpy(old_str1, place_string1);
	strcpy(old_str2, place_string2);
	place_talk_str(old_str1, old_str2,0,dummy_rect);
}
Exemplo n.º 26
0
TechkonDialog::TechkonDialog(ProfileDoc *dc,RawData *pD):InputDialog(dc,pD,1)
{
	short		iType;
	Handle		iHandle;
	Handle		sHandle;
	Rect 		iRect, r,pRect,tRect;	
	UserItemUPP  box3D;
	
	QDErr		error;
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	RGBColor	c,oldbackcolor,oldforecolor;
	WindowPtr	oldP;
	OSErr			err;
	int32 		i,wi,hi;
	double w,h;
	short		gtsl_ids[] = GTSL_IDS;
	Str255		theString;
	PixMapHandle	bigPixMap;
	McoStatus  	state;
	
	for (i=0; i<NumInputIDS; i++) ids[i] = gtsl_ids[i];

	WinType = TechkonWindow;
	WinNum = 0;

	setDialog(Input_Dialog);
	frame_button(ids[Ok_Box]);	

	

	
	// Added by James, 3D the box
	threeD_box(ids[ThreeDBox]);
	
	HideDItem(dp,ids[Redo]);
	
	GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &iRect );
	GetIndString(theString,Message_List_ID,6);
	SetIText(iHandle,theString);
	
	Scramble = FALSE;	
	
	if (Scramble)
		{
		voice_set = 1;
		}	
	else
		{
		Disable(dp,ids[VoiceSet]);
		voice_set = 2;
		}

	// initialize comminications with the device
	state = doc->openInputDevice(0,0,0);
	if (state != MCO_SUCCESS) McoErrorAlert(state);
	
	// initialize the big gworld 
	GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect);
	tRect = iRect;
	OffsetRect(&tRect,-iRect.left,-iRect.top);
	error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 );
	if (error != 0) 
		{
		delete this;
		return;
		} 
	GetGWorld(&oldGW,&oldGD);
	SetGWorld(BigGW,nil);	
	
	
//	GetBackColor(&oldbackcolor);
	GetForeColor(&oldforecolor);
	c.red = 65535;
	c.green = 65535;
	c.blue = 65535;
	RGBBackColor(&c);
	c.red = 0;
	c.green = 0;
	c.blue = 0;
	RGBForeColor(&c);		
	bigPixMap = GetGWorldPixMap ( BigGW );
	if (LockPixels ( bigPixMap ))	EraseRect( &tRect );
	
	SetGWorld(oldGW,oldGD);	
//	RGBBackColor(&oldbackcolor);
	RGBForeColor(&oldforecolor);	

//	SetPort(oldP);
		
	GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect);
	num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top);
	top_patch = 0;
						
//init the static members
	//current_patch = total_patches-1;
	//current_patch = 0;
	current_patch = 0;
	current_strip = 0;
	current_sheet = 0;
 		
 	_done = 0;
 	_waiting = 0;
	
	
	SetSheetStripText();
	
	current_top = current_patch - 2*num_display_patch/3;
	current_bottom = current_top + num_display_patch - 1;
	if (current_top < 0) 
		{
		current_top = 0;
		current_bottom = current_top + num_display_patch - 1;
		}
	if (current_bottom >= total_patches-1)
		{
		current_bottom = total_patches - 1;
		current_top = current_bottom - num_display_patch + 1;
		}
	
	current_disp = 2*num_display_patch/3;
	
	init();	
	getpatchRGB();
	
	
	Disable(dp,ids[Redo]);

	
	GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect);
	SetCtlMin((ControlHandle)iHandle,0);
	SetCtlMax((ControlHandle)iHandle,total_patches-1);
	
	GetDItem(dp, ids[VoiceSet], &iType, (Handle*)&iHandle, &pRect);
	SetCtlValue((ControlHandle)iHandle,1);
	//voice_set = 1;
	checkFinished();
	DrawWindow();
}	
Exemplo n.º 27
0
// NB: As of 2.0fc1, theEvent can be NULL! It isn't used anywhere, so don't _let_ it be
// used anywhere!
void MacroDialog(NewMacroInfo *macrost, DialogPtr dtemp, EventRecord *theEvent, short dItem)
{
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	switch (dItem) {
		case 27: // switch keyset (pane) - RAB BetterTelnet 2.0b5
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
			}
			dialogPane = GetCntlVal(dtemp, 27) - 1;
			// now fix the strings
			for (i=0; i<10; i++) {
				GetIndString(temp, 7100, i + (10 * dialogPane) + 1);
				GetDialogItem(dtemp, i+3, &dItem, &rubbish, &dBox);
				if (!temp[0]) { HideDialogItem(dtemp, i+13); HideDialogItem(dtemp, i+3); }
				else { ShowDialogItem(dtemp, i+13); ShowDialogItem(dtemp, i+3); }
				SetDialogItemText(rubbish, temp);
			}
			for (i=0; i<10; i++) {
				getmacro(macrost, i + (10 * dialogPane), (char *) &temp, 256);		
				c2pstr((char *)temp);								
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );
			}
		break;

		case (MacroExport):
			// we _used_ to get all the macros out, but now only the current set of 10
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
								// RAB BetterTelnet 2.0b5 (revised)
			}
			saveMacros(macrost, (FSSpec *) NULL);
			break;
		case 25:
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
			}
			SaveGlobalMacros(macrost);
			break;
		case (MacroImport):
			loadMacros(macrost, (FSSpec *) NULL);
			for (i=0; i<10; i++) {
				getmacro(macrost, i + (10 * dialogPane), (char *) &temp, 256);		
				c2pstr((char *)temp);								
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );
			}
			break;
		case 1:
		case 2:
			break;
		default:
			if (dItem >2 && dItem <13) 
			{
				i=dItem-3;
				getmacro(macrost, i + (dialogPane * 10), (char *) &temp, 256); /* BYU LSC */
				c2pstr((char *)temp);
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );				/* BYU LSC - Revert the mother */
				SelectDialogItemText( dtemp, i+13, 0, 32767);				/* And select it... */
			}	
			break;
	}
}
Exemplo n.º 28
0
McoStatus TechkonDialog::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data, Boolean &changed)
{
UserItemUPP myfilter;
Str255		theString;
short		itemtype;
Handle		cn1,sliderControl;
Rect		r;
short		part;
Point		mpoint;
int32		next_patch;
McoStatus	status;
WindowPtr	oldp;
int32		temp;
double 		m=1;

	GetPort(&oldp);
	SetPort(dp);

	Changed = FALSE;
	*numwc = 0;
	status = MCO_SUCCESS;

	if (isPressed(0x38)) m = 10;

	if (item != -1) {
		if ((item == TIMER_ITEM ) && (doc->tcom)) // a timer event has occured
			{   
			_last_tick_time2 = TickCount();
			if (_waiting)
				{
				if (!doc->tcom->IsBufferEmpty())	// has a strip been read in
					{
					changed = TRUE; 
					// check to see if a strip has been read in 
					if (doc->tcom->IsDataPresent()) 
						{
						doc->needsSave = TRUE;
						GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
						GetIndString(theString,Message_List_ID,4);
						SetIText(cn1,theString);
						readInPatches();
						Changed = TRUE;
						next_patch = findNextPatch();
						if (next_patch == -1)
							{
							GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
							GetIndString(theString,Message_List_ID,5);
							SetIText(cn1,theString);
							_done == TRUE;
							_waiting = FALSE;
							Disable(dp,ids[Redo]);
							Disable(dp,ids[Start]);
							Disable(dp,ids[Cancel]);
							Enable(dp,ids[Save_as]);	
							Enable(dp,OK);			
							}
						else
							{
							GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
							GetIndString(theString,Message_List_ID,7);
							SetIText(cn1,theString);
							}
						}
					}
				checkFinished();
				}
			}
		else if (item == ids[Slider])   // the slider has been adjusted
			{
			GetMouse(&mpoint);
			do {
				current_patch = GetSlider(mpoint,ids[Slider]);
				ShowPatchScroll(current_patch);
				SetSheetStripText();
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;	
				GetMouse(&mpoint);
				} while ( StillDown ( ) );
			checkError((current_patch/patch_per_strip)*patch_per_strip);
			//_waiting = 0;
			Enable(dp,ids[Redo]);
			SetSheetStripText();
			}
		else if (item == ids[Start]) // start or stop reading
			{
			status = MCO_SUCCESS;
			if (_first) 
				{
				
				status = doc->tcom->Calibrate();
				playSound(EndColumnNum);
				if (status != MCO_SUCCESS) 
					{
					McoMessAlert(MCO_FAIL_CALIB,0L);
					status = MCO_SUCCESS;
					goto bail;
					}
				}
			if (status == MCO_SUCCESS)
				{
				_waiting = 1;	
				current_patch = findNextPatch();  // reset the display, current patch, sheet, strip, and text
				ShowPatch(current_patch); // display the window
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;
				Disable(dp,ids[Start]);	 
				GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
				GetIndString(theString,Message_List_ID,7);
				SetIText(cn1,theString);
				SetSheetStripText();		
				_first = 0;
				}
			status = MCO_SUCCESS;
			}
		else if (item == ids[Save_as])
			{
			StorePatches();
			doc->patchtype = patchtype;
			doc->handle_save_datafile(patchD);
			ShowPatch(current_patch);
			}
		else if (item == ids[VoiceSet]) 
			{
			GetDItem(dp, ids[VoiceSet], &itemtype, (Handle*)&cn1, &r );
			voice_set = GetCtlValue((ControlHandle)cn1);
			}
		else if (item == ids[Strip_Rect])
			{
			GlobalToLocal(&clickPoint);
			temp = whichPatch(clickPoint);
			if (temp != -1)
				{
				current_patch = temp;
				current_disp = current_patch-current_top;
				GetDItem ( dp, ids[Slider], &itemtype, (Handle*)&sliderControl, &r );
				SetCtlValue ( (ControlHandle)sliderControl,current_patch);
				ShowPatch(current_patch);
				SetSheetStripText();
				}
			}
		else if (item == ids[Redo]) // Reread a strip
			{
			_waiting = 1;		   // reset the display, current patch, sheet, strip, and text
			Disable(dp,ids[Redo]);
			Disable(dp,ids[Start]);	 
			GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
			GetIndString(theString,Message_List_ID,7);
			SetIText(cn1,theString);
			}
		else if (item == OK)
			{
			StorePatches();
			doc->copyWaiting(patchD);
			doc->patchtype = patchtype;
			//doc->needsSave = TRUE;
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			}
		else if (item == Cancel)
			{
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			}
		}
bail:		
		
	SetPort(oldp);
	changed = Changed;
	return status;	    	
}
Exemplo n.º 29
0
void saveMacros(NewMacroInfo *macrost, FSSpec *theFile)
{
	SFReply		whereReply;
	short 		refNum,exist;
	FSSpec		macroFile;
	long		junk, len, len2;
	short 		i;
	Point		where;
	OSErr		err;
	Str255		tempString,tempString2;
	Handle		macroHandle;
	Ptr			pos;

	if (!macrost->handle) return; // sanity check

	where.h = 100; where.v = 100;

	GetIndString(tempString,MISC_STRINGS,SAVE_MACROS_STRING);
	GetIndString(tempString2,MISC_STRINGS,DEFAULT_MACRO_SET_NAME);

	if (theFile == 0) {
		SFPutFile( where, tempString, tempString2, 0L, &whereReply);

		if (!whereReply.good)
			return;

		BlockMoveData(&whereReply.fName, macroFile.name, (*whereReply.fName)+1); 
		GetWDInfo(whereReply.vRefNum, &macroFile.vRefNum, &macroFile.parID, &junk);
	}
	else
		macroFile = *theFile;

	if ((err = HCreate(macroFile.vRefNum, macroFile.parID, 
			macroFile.name, kNCSACreatorSignature, 'TEXT')) == dupFNErr)
		exist = 1;
	
	err = HOpenDF(macroFile.vRefNum, macroFile.parID, macroFile.name, fsWrPerm, &refNum);

	if (exist) 
		SetEOF(refNum, 0L);

// the new code - RAB BetterTelnet 2.0b5
	macroHandle = macrost->handle;
	HandToHand(&macroHandle);
	HLock(macroHandle);
	pos = *macroHandle;
	len = len2 = GetHandleSize(macroHandle);
	while (len) {
		if (*pos == 0) *pos = 13;
		pos++;
		len--;
	}

	pos = *macroHandle;
	junk = 2;
	FSWrite(refNum, &junk, "!\015");
	FSWrite(refNum, &len2, pos);
	DisposeHandle(macroHandle); // it's a copy anyway, get rid of it!

	FSClose(refNum);
}
char *QTTarg_GetStringFromUser (short thePromptStringIndex)
{
	short 			myItem;
	short 			mySavedResFile;
	GrafPtr			mySavedPort;
	DialogPtr		myDialog = NULL;
	short			myItemKind;
	Handle			myItemHandle;
	Rect			myItemRect;
	Str255			myString;
	char			*myCString = NULL;
	OSErr			myErr = noErr;

	//////////
	//
	// save the current resource file and graphics port
	//
	//////////

	mySavedResFile = CurResFile();
	GetPort(&mySavedPort);

	// set the application's resource file
	UseResFile(gAppResFile);

	//////////
	//
	// create the dialog box in which the user will enter a URL
	//
	//////////

	myDialog = GetNewDialog(kGetStr_DLOGID, NULL, (WindowPtr)-1L);
	if (myDialog == NULL)
		goto bail;

	QTFrame_ActivateController(QTFrame_GetFrontMovieWindow(), false);
	
	MacSetPort(GetDialogPort(myDialog));
	
	SetDialogDefaultItem(myDialog, kGetStr_OKButton);
	SetDialogCancelItem(myDialog, kGetStr_CancelButton);
	
	// set the prompt string	
	GetIndString(myString, kTextKindsResourceID, thePromptStringIndex);

	GetDialogItem(myDialog, kGetStr_StrLabelItem, &myItemKind, &myItemHandle, &myItemRect);
	SetDialogItemText(myItemHandle, myString);
	
	MacShowWindow(GetDialogWindow(myDialog));
	
	//////////
	//
	// display and handle events in the dialog box until the user clicks OK or Cancel
	//
	//////////
	
	do {
		ModalDialog(gModalFilterUPP, &myItem);
	} while ((myItem != kGetStr_OKButton) && (myItem != kGetStr_CancelButton));
	
	//////////
	//
	// handle the selected button
	//
	//////////
	
	if (myItem != kGetStr_OKButton) {
		myErr = userCanceledErr;
		goto bail;
	}
	
	// retrieve the edited text
	GetDialogItem(myDialog, kGetStr_StrTextItem, &myItemKind, &myItemHandle, &myItemRect);
	GetDialogItemText(myItemHandle, myString);
	myCString = QTUtils_ConvertPascalToCString(myString);
	
bail:
	// restore the previous resource file and graphics port
	MacSetPort(mySavedPort);
	UseResFile(mySavedResFile);
	
	if (myDialog != NULL)
		DisposeDialog(myDialog);

	return(myCString);
}