Pararena2/Sources/About.c
John Calhoun 806b9b47db First check-in.
This project was originally compiled with THINK C for the Macintosh.
The project file is a THINK C project file. Then there is the assembly
static library (SMS) that is linked in to provide fast, 4-channel sound
(written by Patrick Buckland). Resource files, a balloon file for
“balloon help” when it was a thing…. Good luck to anyone trying to
bring this beast back to life.
2016-01-27 20:50:55 -08:00

1 line
5.1 KiB
C
Executable File

//============================================================
//============================================================
//== ==
//== About Dialog Routines ==
//== ==
//============================================================
//============================================================
//======================================================== Includes
#include "About.h"
#include "UnivUtilities.h"
//======================================================== Local Vars
static RgnHandle okayButtRgn;
static Rect okayButtonBounds, mainPICTBounds;
static Boolean okayButtIsHiLit, clickedDownInOkay;
//======================================================== Procedures
//======================================================== HiLiteOkayButton
void HiLiteOkayButton (void)
{
PicHandle thePict;
if (!okayButtIsHiLit)
{
thePict = GetPicture(kOkayButtPICTHiLit);
if (thePict != kNilPointer)
{
DrawPicture(thePict, &okayButtonBounds);
ReleaseResource((Handle)thePict);
okayButtIsHiLit = TRUE;
}
}
}
//======================================================== UnHiLiteOkayButton
void UnHiLiteOkayButton (void)
{
PicHandle thePict;
if (okayButtIsHiLit)
{
thePict = GetPicture(kOkayButtPICTNotHiLit);
if (thePict != kNilPointer)
{
DrawPicture(thePict, &okayButtonBounds);
ReleaseResource((Handle)thePict);
okayButtIsHiLit = FALSE;
}
}
}
//======================================================== UpdateMainPict
void UpdateMainPict (DialogPtr theDialog)
{
PicHandle thePict;
BeginUpdate((GrafPtr)theDialog);
DrawDialog((GrafPtr)theDialog);
if (isColor)
thePict = GetPicture(kAboutColorPICT);
else
thePict = GetPicture(kAboutBandWPICT);
if (thePict != kNilPointer)
{
DrawPicture(thePict, &mainPICTBounds);
ReleaseResource((Handle)thePict);
}
EndUpdate((GrafPtr)theDialog);
}
//======================================================== AboutFilter
pascal Boolean AboutFilter (DialogPtr theDialog, EventRecord *theEvent, short *itemHit)
{
Point mousePt;
long dummyLong;
if (Button() && clickedDownInOkay)
{
GetMouse(&mousePt);
if(PtInRgn(mousePt, okayButtRgn))
HiLiteOkayButton();
else
UnHiLiteOkayButton();
}
switch (theEvent->what)
{
case keyDown:
switch ((theEvent->message) & charCodeMask)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
HiLiteOkayButton();
Delay(8, &dummyLong);
UnHiLiteOkayButton();
*itemHit = buttItemOkay;
return(TRUE);
break;
default:
return(FALSE);
}
break;
case mouseDown:
mousePt = theEvent->where;
GlobalToLocal(&mousePt);
if(PtInRgn(mousePt, okayButtRgn))
{
clickedDownInOkay = TRUE;
return(FALSE);
}
else
return(FALSE);
break;
case mouseUp:
mousePt = theEvent->where;
GlobalToLocal(&mousePt);
if(PtInRgn(mousePt, okayButtRgn) && clickedDownInOkay)
{
UnHiLiteOkayButton();
*itemHit = buttItemOkay;
return(TRUE);
}
else
{
clickedDownInOkay = FALSE;
return(FALSE);
}
break;
case updateEvt:
UpdateMainPict(theDialog);
theEvent->what = nullEvent;
return(FALSE);
break;
default:
return(FALSE);
break;
}
}
//======================================================== DoAbout
void DoAbout (void)
{
DialogPtr aboutDialog;
Str255 longVersion;
StringPtr messagePtr;
VersRecHndl version;
Handle itemHandle;
Rect itemRect;
short itemType, itemHit;
CenterDialog(rAboutDialogID); // Call our universal centering routine
if (doZooms)
ZoomOutDialogRect(rAboutDialogID);
aboutDialog = GetNewDialog(rAboutDialogID, kNilPointer, kPutInFront);
if (aboutDialog == kNilPointer)
return;
SetPort((GrafPtr)aboutDialog); // Bring up the dialog
ShowWindow((GrafPtr)aboutDialog);
ParamText("\p", "\p", "\p", "\p");
#if kDemoVersion
ParamText("\pDEMO COPY", "\p", "\p", "\p");
#endif
// Get version info from 'vers' resource
version = (VersRecHndl)GetResource('vers', 1);
if (version != kNilPointer)
{
messagePtr = (StringPtr)(((unsigned long) &(**version).shortVersion[1])
+ ((**version).shortVersion[0]));
BlockMove((Ptr)messagePtr, &longVersion, ((unsigned char) *messagePtr) + 1);
GetDItem(aboutDialog, textItemVers, &itemType, &itemHandle, &itemRect);
SetIText(itemHandle, longVersion); // Modify text item to show vers
}
GetDItem(aboutDialog, buttItemOkay, &itemType, &itemHandle, &okayButtonBounds);
okayButtRgn = NewRgn(); // Create diagonal button region
OpenRgn();
MoveTo(okayButtonBounds.left + 1, okayButtonBounds.top + 45);
Line(44, -44);
Line(16, 16);
Line(-44, 44);
Line(-16, -16);
CloseRgn(okayButtRgn);
okayButtIsHiLit = FALSE; // Initially, button is not hilit
clickedDownInOkay = FALSE; // Initially, didn't click in okay button
GetDItem(aboutDialog, pictItemMain, &itemType, &itemHandle, &mainPICTBounds);
UpdateMainPict(aboutDialog);
do // Loop until user wants to exit
{
ModalDialog(AboutFilter, &itemHit);
} while (itemHit != buttItemOkay);
DisposeRgn(okayButtRgn); // Clean up!
DisposDialog(aboutDialog);
}