Pararena2/Sources/ConfigureSound.c

1 line
7.7 KiB
C
Raw Normal View History

//============================================================ //============================================================ //== == //== Configure Sound Routines == //== == //============================================================ //============================================================ //======================================================== Includes #include "Globals.h" #include "UnivUtilities.h" #include "ConfigureSound.h" #include <Sound.h> //======================================================== Functions //======================================================== UpdateVolumeIcon void UpdateVolumeIcon (DialogPtr theDialog) { Str255 textStr; CIconHandle cicnHandle; Handle iHandle, iconHandle; Rect iRect; short iType; GetDItem(theDialog, kSoundIconRect, &iType, &iHandle, &iRect); if (isColor) { cicnHandle = GetCIcon(210 + soundVolume); PlotCIcon(&iRect, cicnHandle); DisposCIcon(cicnHandle); } else { iconHandle = GetIcon(210 + soundVolume); PlotIcon(&iRect, iconHandle); } GetDItem(theDialog, kSoundVolume, &iType, &iHandle, &iRect); NumToString((long)soundVolume, textStr); SetIText(iHandle, textStr); } //======================================================== UpdateSoundDialog void UpdateSoundDialog (DialogPtr theDialog) { PicHandle thePict; Str255 theTitle; Handle iHandle; Rect iRect; short iType; DrawDialog(theDialog); UpdateVolumeIcon(theDialog); GetDItem(theDialog, kSoundBalloon, &iType, &iHandle, &iRect); if (isColor) thePict = GetPicture(kBalloon4PictID); else thePict = GetPicture(kBalloon1PictID); if (thePict != kNilPointer) { DrawPicture(thePict, &iRect); ReleaseResource((Handle)thePict); } GetIndString(theTitle, rMiscStrings, 4); if (theTitle[0] == 0) PasStringCopy((StringPtr)"\pSound Options<6E>", (StringPtr)theTitle); MoveTo(kSoundTitleLeft, kSoundTitleTop); DrawString(theTitle); DrawDefaultButton(theDialog, kSoundOkay); } //======================================================== SoundFilter pascal Boolean SoundFilter (DialogPtr theDialog, EventRecord *theEvent, short *itemHit) { switch (theEvent->what) { case keyDown: switch ((theEvent->message) & charCodeMask) { case kReturnKeyASCII: case kEnterKeyASCII: FlashDialogButton(theDialog, kSoundOkay); *itemHit = kSoundOkay; return(TRUE); break; case kLeftArrowKeyASCII: case kDownArrowKeyASCII: *itemHit = kSoundSofter; return(TRUE); break; case kRightArrowKeyASCII: case kUpArrowKeyASCII: *itemHit = kSoundLouder; return(TRUE); break; case k0KeyASCII: case k1KeyASCII: case k2KeyASCII: case k3KeyASCII: case k4KeyASCII: case k5KeyASCII: case k6KeyASCII: case k7KeyASCII: soundVolume = ((theEvent->message) & charCodeMask) - k0KeyASCII; UpdateVolumeIcon(theDialog); return(TRUE); break; default: return(FALSE); } break; case updateEvt: BeginUpdate((GrafPtr)theDialog); UpdateSoundDialog(theDialog); EndUpdate((GrafPtr)theDialog); theEvent->what = nullEvent; return(FALSE); break; default: return(FALSE); break; } } //======================================================== DoConfigureSound Boolean DoConfigureSound (void) { DialogPtr soundDialog; Handle iHandle; Rect iRect; short itemHit, iType, wasVolume; Boolean leaveDialog, userOkayed, wasState; CenterDialog(rSoundDialogID); if (doZooms) ZoomOutDialogRect(rSoundDialogID); soundDialog = GetNewDialog(rSoundDialogID, kNilPointer, kPutInFront); SetPort((GrafPtr)soundDialog); ShowWindow((GrafPtr)soundDialog); wasVolume = soundVolume; UpdateSoundDialog(soundDialog); if (!soundOn) { GetDItem(soundDialog, kSoundBeam, &iType, &iHandle, &iRect); HiliteControl((ControlHandle)iHandle, 255); GetDItem(soundDialog, kSoundIncidental, &iType, &iHandle, &iRect); HiliteControl((ControlHandle)iHandle, 255); GetDItem(soundDialog, kSoundCollisions, &iType, &iHandl