mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Handle refactor
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
//============================================================================
|
||||
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLControlDefinitions.h"
|
||||
#include "PLNumberFormatting.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLSound.h"
|
||||
@@ -42,7 +43,7 @@ void DoAbout (void)
|
||||
Str255 longVersion;
|
||||
StringPtr messagePtr;
|
||||
VersRecHndl version;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType, hit, wasResFile;
|
||||
ModalFilterUPP aboutFilterUPP;
|
||||
|
||||
@@ -55,7 +56,7 @@ void DoAbout (void)
|
||||
// if (aboutDialog == nil)
|
||||
// RedAlert(kErrDialogDidntLoad);
|
||||
|
||||
version = (VersRecHndl)GetResource('vers', 1);
|
||||
version = GetResource('vers', 1).StaticCast<VersionRecord>();
|
||||
if (version != nil)
|
||||
{
|
||||
messagePtr = (**version).shortVersion + 1 + (**version).shortVersion[0];
|
||||
@@ -109,7 +110,7 @@ static void HiLiteOkayButton (void)
|
||||
if (thePict != nil)
|
||||
{
|
||||
DrawPicture(thePict, &okayButtonBounds);
|
||||
DisposeHandle((Handle)thePict);
|
||||
thePict.Dispose();
|
||||
|
||||
okayButtIsHiLit = true;
|
||||
}
|
||||
@@ -131,7 +132,7 @@ static void UnHiLiteOkayButton (void)
|
||||
if (thePict != nil)
|
||||
{
|
||||
DrawPicture(thePict, &okayButtonBounds);
|
||||
DisposeHandle((Handle)thePict);
|
||||
thePict.Dispose();
|
||||
|
||||
okayButtIsHiLit = false;
|
||||
}
|
||||
|
@@ -25,15 +25,19 @@ typedef struct
|
||||
BEInt16_t resID;
|
||||
BEInt16_t reserved;
|
||||
} frame[1];
|
||||
} acurRec, *acurPtr, **acurHandle;
|
||||
} acurRec;
|
||||
|
||||
typedef THandle<acurRec> acurHandle;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
Handle cursorHdl;
|
||||
THandle<CCursor> cursorHdl;
|
||||
} frame[1];
|
||||
} compiledAcurRec, *compiledAcurPtr, **compiledAcurHandle;
|
||||
} compiledAcurRec;
|
||||
|
||||
typedef THandle<compiledAcurRec> compiledAcurHandle;
|
||||
|
||||
|
||||
Boolean GetColorCursors (acurHandle, compiledAcurHandle);
|
||||
@@ -73,7 +77,7 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
|
||||
}
|
||||
else // But, if the cursor loaded ok
|
||||
{ // add it to our list or cursor handles
|
||||
(*compiledBallCursH)->frame[i].cursorHdl = (Handle)cursHdl;
|
||||
(*compiledBallCursH)->frame[i].cursorHdl = cursHdl;
|
||||
SetCCursor((CCrsrHandle)(*compiledBallCursH)->frame[i].cursorHdl);
|
||||
}
|
||||
}
|
||||
@@ -93,10 +97,10 @@ void InitAnimatedCursor (acurHandle ballCursH)
|
||||
|
||||
useColor = thisMac.hasColor;
|
||||
if (ballCursH == nil)
|
||||
ballCursH = reinterpret_cast<acurHandle>(GetResource('acur', 128));
|
||||
ballCursH = GetResource('acur', 128).StaticCast<acurRec>();
|
||||
if (ballCursH && ballCursH != animCursorH)
|
||||
{
|
||||
compiledBallCursorH = (compiledAcurHandle)NewHandle(sizeof(compiledAcurRec) * (*ballCursH)->n);
|
||||
compiledBallCursorH = NewHandle(sizeof(compiledAcurRec) * (*ballCursH)->n).StaticCast<compiledAcurRec>();
|
||||
if (!compiledBallCursorH)
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
|
||||
@@ -120,7 +124,7 @@ void InitAnimatedCursor (acurHandle ballCursH)
|
||||
|
||||
void LoadCursors (void)
|
||||
{
|
||||
InitAnimatedCursor((acurHandle)GetResource('acur', rAcurID));
|
||||
InitAnimatedCursor(GetResource('acur', rAcurID).StaticCast<acurRec>());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DisposCursors
|
||||
@@ -147,16 +151,16 @@ void DisposCursors (void)
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
if ((*compiledAnimCursorH)->frame[i].cursorHdl != nil)
|
||||
DisposeHandle((Handle)(*compiledAnimCursorH)->frame[i].cursorHdl);
|
||||
(*compiledAnimCursorH)->frame[i].cursorHdl.Dispose();
|
||||
}
|
||||
}
|
||||
DisposeHandle((Handle)compiledAnimCursorH);
|
||||
compiledAnimCursorH.Dispose();
|
||||
compiledAnimCursorH = nil;
|
||||
}
|
||||
|
||||
if (animCursorH != nil)
|
||||
{
|
||||
DisposeHandle((Handle)animCursorH);
|
||||
animCursorH.Dispose();
|
||||
animCursorH = nil;
|
||||
}
|
||||
}
|
||||
|
@@ -140,7 +140,7 @@ void GetDialogRect (Rect *bounds, short dialogID)
|
||||
DialogTHndl dlogHandle;
|
||||
Byte wasState;
|
||||
|
||||
dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID);
|
||||
dlogHandle = GetResource('DLOG', dialogID).StaticCast<DialogTemplate>();
|
||||
if (dlogHandle != nil)
|
||||
{
|
||||
*bounds = (**dlogHandle).boundsRect;
|
||||
@@ -332,14 +332,14 @@ void ZoomOutAlertRect (short alertID)
|
||||
void FlashDialogButton (DialogPtr theDialog, short itemNumber)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
UInt32 dummyLong;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemRect);
|
||||
HiliteControl((ControlHandle)itemHandle, kControlButtonPart);
|
||||
HiliteControl(itemHandle, kControlButtonPart);
|
||||
Delay(8, &dummyLong);
|
||||
HiliteControl((ControlHandle)itemHandle, 0);
|
||||
HiliteControl(itemHandle, 0);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawDefaultButton
|
||||
@@ -349,7 +349,7 @@ void FlashDialogButton (DialogPtr theDialog, short itemNumber)
|
||||
void DrawDefaultButton (DialogPtr theDialog)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, 1, &itemType, &itemHandle, &itemRect);
|
||||
@@ -365,7 +365,7 @@ void DrawDefaultButton (DialogPtr theDialog)
|
||||
void GetDialogString (DialogPtr theDialog, short item, StringPtr theString)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
@@ -378,7 +378,7 @@ void GetDialogString (DialogPtr theDialog, short item, StringPtr theString)
|
||||
void SetDialogString (DialogPtr theDialog, short item, const PLPasStr &theString)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
@@ -392,7 +392,7 @@ short GetDialogStringLen (DialogPtr theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
Str255 theString;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
@@ -407,11 +407,11 @@ short GetDialogStringLen (DialogPtr theDialog, short item)
|
||||
void GetDialogItemValue (DialogPtr theDialog, short item, short *theState)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
*theState = GetControlValue((ControlHandle)itemHandle);
|
||||
*theState = GetControlValue(itemHandle);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SetDialogItemValue
|
||||
@@ -421,11 +421,11 @@ void GetDialogItemValue (DialogPtr theDialog, short item, short *theState)
|
||||
void SetDialogItemValue (DialogPtr theDialog, short item, short theState)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
SetControlValue((ControlHandle)itemHandle, theState);
|
||||
SetControlValue(itemHandle, theState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ToggleDialogItemValue
|
||||
@@ -434,16 +434,16 @@ void SetDialogItemValue (DialogPtr theDialog, short item, short theState)
|
||||
void ToggleDialogItemValue (DialogPtr theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType, theState;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
theState = GetControlValue((ControlHandle)itemHandle);
|
||||
theState = GetControlValue(itemHandle);
|
||||
if (theState == 0)
|
||||
theState = 1;
|
||||
else
|
||||
theState = 0;
|
||||
SetControlValue((ControlHandle)itemHandle, theState);
|
||||
SetControlValue(itemHandle, theState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SetDialogNumToStr
|
||||
@@ -454,7 +454,7 @@ void SetDialogNumToStr (DialogPtr theDialog, short item, long theNumber)
|
||||
{
|
||||
Str255 theString;
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
NumToString(theNumber, theString);
|
||||
@@ -470,7 +470,7 @@ void GetDialogNumFromStr (DialogPtr theDialog, short item, long *theNumber)
|
||||
{
|
||||
Str255 theString;
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
@@ -483,7 +483,7 @@ void GetDialogNumFromStr (DialogPtr theDialog, short item, long *theNumber)
|
||||
|
||||
void GetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
|
||||
{
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, theRect);
|
||||
@@ -496,7 +496,7 @@ void GetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
|
||||
void SetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
|
||||
{
|
||||
Rect oldRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &oldRect);
|
||||
@@ -510,7 +510,7 @@ void SetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
|
||||
void OffsetDialogItemRect (DialogPtr theDialog, short item, short h, short v)
|
||||
{
|
||||
Rect oldRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &oldRect);
|
||||
@@ -526,17 +526,17 @@ void OffsetDialogItemRect (DialogPtr theDialog, short item, short h, short v)
|
||||
void SelectFromRadioGroup (DialogPtr dial, short which, short first, short last)
|
||||
{
|
||||
Rect iRect;
|
||||
Handle iHandle;
|
||||
ControlHandle iHandle;
|
||||
short iType, i;
|
||||
|
||||
for (i = first; i <= last; i++)
|
||||
{
|
||||
GetDialogItem(dial, i, &iType, &iHandle, &iRect);
|
||||
SetControlValue((ControlHandle)iHandle, (short)false);
|
||||
SetControlValue(iHandle, (short)false);
|
||||
}
|
||||
|
||||
GetDialogItem(dial, which, &iType, &iHandle, &iRect);
|
||||
SetControlValue((ControlHandle)iHandle, (short)true);
|
||||
SetControlValue(iHandle, (short)true);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- AddMenuToPopUp
|
||||
@@ -559,11 +559,11 @@ void AddMenuToPopUp (DialogPtr theDialog, short whichItem, MenuHandle theMenu)
|
||||
void GetPopUpMenuValue (DialogPtr theDialog, short whichItem, short *value)
|
||||
{
|
||||
Rect iRect;
|
||||
Handle iHandle;
|
||||
ControlHandle iHandle;
|
||||
short iType;
|
||||
|
||||
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
|
||||
*value = GetControlValue((ControlHandle)iHandle);
|
||||
*value = GetControlValue(iHandle);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SetPopUpMenuValue
|
||||
@@ -572,11 +572,11 @@ void GetPopUpMenuValue (DialogPtr theDialog, short whichItem, short *value)
|
||||
void SetPopUpMenuValue (DialogPtr theDialog, short whichItem, short value)
|
||||
{
|
||||
Rect iRect;
|
||||
Handle iHandle;
|
||||
ControlHandle iHandle;
|
||||
short iType;
|
||||
|
||||
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
|
||||
SetControlValue((ControlHandle)iHandle, value);
|
||||
SetControlValue(iHandle, value);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- MyEnableControl
|
||||
@@ -585,11 +585,11 @@ void SetPopUpMenuValue (DialogPtr theDialog, short whichItem, short value)
|
||||
void MyEnableControl (DialogPtr theDialog, short whichItem)
|
||||
{
|
||||
Rect iRect;
|
||||
Handle iHandle;
|
||||
ControlHandle iHandle;
|
||||
short iType;
|
||||
|
||||
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
|
||||
HiliteControl((ControlHandle)iHandle, kActive);
|
||||
HiliteControl(iHandle, kActive);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- MyDisableControl
|
||||
@@ -598,11 +598,11 @@ void MyEnableControl (DialogPtr theDialog, short whichItem)
|
||||
void MyDisableControl (DialogPtr theDialog, short whichItem)
|
||||
{
|
||||
Rect iRect;
|
||||
Handle iHandle;
|
||||
ControlHandle iHandle;
|
||||
short iType;
|
||||
|
||||
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
|
||||
HiliteControl((ControlHandle)iHandle, kInactive);
|
||||
HiliteControl(iHandle, kInactive);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawDialogUserText
|
||||
@@ -613,7 +613,7 @@ void MyDisableControl (DialogPtr theDialog, short whichItem)
|
||||
void DrawDialogUserText (DialogPtr dial, short item, StringPtr text, Boolean invert)
|
||||
{
|
||||
Rect iRect;
|
||||
Handle iHandle;
|
||||
ControlHandle iHandle;
|
||||
Str255 newString, stringCopy;
|
||||
short iType, textLong, i, inset;
|
||||
|
||||
@@ -652,7 +652,7 @@ void DrawDialogUserText (DialogPtr dial, short item, StringPtr text, Boolean inv
|
||||
void DrawDialogUserText2 (DialogPtr dial, short item, StringPtr text)
|
||||
{
|
||||
Rect iRect;
|
||||
Handle iHandle;
|
||||
ControlHandle iHandle;
|
||||
Str255 stringCopy;
|
||||
short iType;
|
||||
|
||||
@@ -674,7 +674,7 @@ void DrawDialogUserText2 (DialogPtr dial, short item, StringPtr text)
|
||||
void LoadDialogPICT (DialogPtr theDialog, short item, short theID)
|
||||
{
|
||||
Rect iRect;
|
||||
Handle iHandle;
|
||||
ControlHandle iHandle;
|
||||
PicHandle thePict;
|
||||
short iType;
|
||||
|
||||
@@ -690,7 +690,7 @@ void LoadDialogPICT (DialogPtr theDialog, short item, short theID)
|
||||
void FrameDialogItem (DialogPtr theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
@@ -704,7 +704,7 @@ void FrameDialogItemC (DialogPtr theDialog, short item, long color)
|
||||
{
|
||||
RGBColor theRGBColor, wasColor;
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
@@ -721,7 +721,7 @@ void FrameDialogItemC (DialogPtr theDialog, short item, long color)
|
||||
void FrameOvalDialogItem (DialogPtr theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
@@ -735,7 +735,7 @@ void FrameOvalDialogItem (DialogPtr theDialog, short item)
|
||||
void BorderDialogItem (DialogPtr theDialog, short item, short sides)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
// 1 = left
|
||||
@@ -776,7 +776,7 @@ void BorderDialogItem (DialogPtr theDialog, short item, short sides)
|
||||
void ShadowDialogItem (DialogPtr theDialog, short item, short thickness)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
@@ -794,7 +794,7 @@ void ShadowDialogItem (DialogPtr theDialog, short item, short thickness)
|
||||
void EraseDialogItem (DialogPtr theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
Handle itemHandle;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
|
@@ -199,7 +199,9 @@ typedef struct
|
||||
roomType rooms[1]; // 348 * nRooms
|
||||
|
||||
static const size_t kBinaryDataSize = 866;
|
||||
} houseType, *housePtr, **houseHand; // total = 866 +
|
||||
} houseType, *housePtr; // total = 866 +
|
||||
|
||||
typedef THandle<houseType> houseHand;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -277,7 +279,10 @@ typedef struct
|
||||
Boolean top;
|
||||
Boolean right;
|
||||
Boolean bottom;
|
||||
} boundsType, *boundsPtr, **boundsHand;
|
||||
} boundsType, *boundsPtr;
|
||||
|
||||
typedef THandle<boundsType> boundsHand;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@@ -120,9 +120,9 @@ Boolean InitializeEmptyHouse (void)
|
||||
Str255 tempStr;
|
||||
|
||||
if (thisHouse != nil)
|
||||
DisposeHandle((Handle)thisHouse);
|
||||
thisHouse.Dispose();
|
||||
|
||||
thisHouse = (houseHand)NewHandle(sizeof(houseType));
|
||||
thisHouse = NewHandle(sizeof(houseType)).StaticCast<houseType>();
|
||||
|
||||
if (thisHouse == nil)
|
||||
{
|
||||
|
@@ -51,19 +51,19 @@ extern Boolean phoneBitSet, bannerStarCountOn;
|
||||
|
||||
void LoopMovie (void)
|
||||
{
|
||||
Handle theLoop;
|
||||
THandle<long> theLoop;
|
||||
UserData theUserData;
|
||||
short theCount;
|
||||
|
||||
theLoop = NewHandle(sizeof(long));
|
||||
(** (long **) theLoop) = 0;
|
||||
theLoop = NewHandle(sizeof(long)).StaticCast<long>();
|
||||
(**theLoop) = 0;
|
||||
theUserData = GetMovieUserData(theMovie);
|
||||
theCount = CountUserDataType(theUserData, 'LOOP');
|
||||
while (theCount--)
|
||||
{
|
||||
RemoveUserData(theUserData, 'LOOP', 1);
|
||||
}
|
||||
AddUserData(theUserData, theLoop, 'LOOP');
|
||||
AddUserData(theUserData, theLoop.StaticCast<void>(), 'LOOP');
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- OpenHouseMovie
|
||||
@@ -119,11 +119,11 @@ void OpenHouseMovie (void)
|
||||
if (theErr != PLErrors::kNone)
|
||||
{
|
||||
YellowAlert(kYellowQTMovieNotLoaded, theErr);
|
||||
DisposeHandle(spaceSaver);
|
||||
spaceSaver.Dispose();
|
||||
CloseHouseMovie();
|
||||
return;
|
||||
}
|
||||
DisposeHandle(spaceSaver);
|
||||
spaceSaver.Dispose();
|
||||
|
||||
theErr = PrerollMovie(theMovie, 0, 0x000F0000);
|
||||
if (theErr != PLErrors::kNone)
|
||||
@@ -642,12 +642,12 @@ Boolean ReadHouse (void)
|
||||
#endif
|
||||
|
||||
if (thisHouse != nil)
|
||||
DisposeHandle((Handle)thisHouse);
|
||||
thisHouse.Dispose();
|
||||
|
||||
// GP: Correct for padding
|
||||
const size_t alignmentPadding = sizeof(houseType) - sizeof(roomType) - houseType::kBinaryDataSize;
|
||||
|
||||
thisHouse = (houseHand)NewHandle(byteCount + alignmentPadding);
|
||||
thisHouse = NewHandle(byteCount + alignmentPadding).StaticCast<houseType>();
|
||||
if (thisHouse == nil)
|
||||
{
|
||||
YellowAlert(kYellowNoMemory, 10);
|
||||
@@ -767,7 +767,7 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
if (checkIt)
|
||||
CheckHouseForProblems();
|
||||
|
||||
byteCount = GetHandleSize((Handle)thisHouse);
|
||||
byteCount = GetHandleSize(thisHouse.StaticCast<void>());
|
||||
|
||||
if (fileDirty)
|
||||
{
|
||||
|
@@ -616,7 +616,7 @@ void ValidateNumberOfRooms (void)
|
||||
char wasState;
|
||||
|
||||
reportsRooms = (long)(*thisHouse)->nRooms;
|
||||
countedRooms = (GetHandleSize((Handle)thisHouse) -
|
||||
countedRooms = (GetHandleSize(thisHouse.StaticCast<void>()) -
|
||||
sizeof(houseType)) / sizeof(roomType);
|
||||
if (reportsRooms != countedRooms)
|
||||
{
|
||||
@@ -737,7 +737,7 @@ void LopOffExtraRooms (void)
|
||||
{
|
||||
r = (*thisHouse)->nRooms - count;
|
||||
newSize = sizeof(houseType) + (sizeof(roomType) * (long)r);
|
||||
if (SetHandleSize((Handle)thisHouse, newSize) != PLErrors::kNone) // resize house handle (shrink)
|
||||
if (SetHandleSize(thisHouse.StaticCast<void>(), newSize) != PLErrors::kNone) // resize house handle (shrink)
|
||||
{
|
||||
ForeColor(redColor);
|
||||
GetLocalizedString(16, message);
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#define kDiagCursorID 131
|
||||
|
||||
|
||||
extern Rect **mirrorRects;
|
||||
extern THandle<Rect> mirrorRects;
|
||||
extern WindowPtr mapWindow, toolsWindow, linkWindow;
|
||||
extern WindowPtr menuWindow;
|
||||
extern Rect shieldRect, boardSrcRect, localRoomsDest[];
|
||||
|
@@ -165,14 +165,14 @@ void LoadGraphicPlus (short resID, Rect *theRect)
|
||||
thePicture = GetPicture(resID);
|
||||
if (thePicture == nil)
|
||||
{
|
||||
thePicture = (PicHandle)GetResource('Date', resID);
|
||||
thePicture = GetResource('Date', resID).StaticCast<Picture>();
|
||||
if (thePicture == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
DrawPicture(thePicture, theRect);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- RedrawMapContents
|
||||
|
@@ -261,7 +261,7 @@ PLError_t LoadMusicSounds (void)
|
||||
return PLErrors::kOutOfMemory;
|
||||
|
||||
BlockMove((Ptr)(static_cast<Byte*>(*theSound) + 20L), theMusicData[i], soundDataSize);
|
||||
DisposeHandle(theSound);
|
||||
theSound.Dispose();
|
||||
}
|
||||
return (theErr);
|
||||
}
|
||||
|
@@ -1158,7 +1158,7 @@ void DrawCalendar (Rect *theRect)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, theRect->left, theRect->top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
|
||||
SetPort((GrafPtr)backSrcMap);
|
||||
TextFace(bold);
|
||||
@@ -1191,7 +1191,7 @@ void DrawBulletin (Rect *theRect)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, theRect->left, theRect->top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
@@ -1246,7 +1246,7 @@ void DrawPictObject (short what, Rect *theRect)
|
||||
bounds = srcRects[what];
|
||||
QOffsetRect(&bounds, theRect->left, theRect->top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
@@ -526,7 +526,7 @@ void PlayGame (void)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
}
|
||||
#else
|
||||
// ShowMenuBarOld(); // TEMP
|
||||
@@ -576,7 +576,7 @@ void PlayGame (void)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
@@ -29,13 +29,12 @@ void RenderStars (void);
|
||||
void RenderBands (void);
|
||||
void RenderShreds (void);
|
||||
void CopyRectsQD (void);
|
||||
void CopyRectsAssm (void);
|
||||
|
||||
|
||||
Rect work2MainRects[kMaxGarbageRects];
|
||||
Rect back2WorkRects[kMaxGarbageRects];
|
||||
Rect shieldRect;
|
||||
Rect **mirrorRects;
|
||||
THandle<Rect> mirrorRects;
|
||||
Point shieldPt;
|
||||
long nextFrame;
|
||||
short numWork2Main, numBack2Work;
|
||||
@@ -151,7 +150,7 @@ void DrawReflection (gliderPtr thisGlider, Boolean oneOrTwo)
|
||||
|
||||
SetPort((GrafPtr)workSrcMap);
|
||||
|
||||
long numMirrorRects = GetHandleSize(reinterpret_cast<Handle>(mirrorRects)) / sizeof(Rect);
|
||||
long numMirrorRects = GetHandleSize(mirrorRects.StaticCast<void>()) / sizeof(Rect);
|
||||
|
||||
for (long i = 0; i < numMirrorRects; i++)
|
||||
{
|
||||
@@ -743,16 +742,16 @@ void AddToMirrorRegion (Rect *theRect)
|
||||
{
|
||||
if (mirrorRects == nil)
|
||||
{
|
||||
mirrorRects = reinterpret_cast<Rect**>(NewHandle(sizeof(Rect)));
|
||||
mirrorRects = NewHandle(sizeof(Rect)).StaticCast<Rect>();
|
||||
if (mirrorRects != nil)
|
||||
**mirrorRects = *theRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
const long oldSize = GetHandleSize(reinterpret_cast<Handle>(mirrorRects));
|
||||
const long oldSize = GetHandleSize(mirrorRects.StaticCast<void>());
|
||||
const long newSize = oldSize + sizeof(Rect);
|
||||
|
||||
if (SetHandleSize(reinterpret_cast<Handle>(mirrorRects), newSize) == PLErrors::kNone)
|
||||
if (SetHandleSize(mirrorRects.StaticCast<void>(), newSize) == PLErrors::kNone)
|
||||
(*mirrorRects)[oldSize / sizeof(Rect)] = *theRect;
|
||||
}
|
||||
hasMirror = true;
|
||||
@@ -763,7 +762,7 @@ void AddToMirrorRegion (Rect *theRect)
|
||||
void ZeroMirrorRegion (void)
|
||||
{
|
||||
if (mirrorRects != nil)
|
||||
DisposeHandle(reinterpret_cast<Handle>(mirrorRects));
|
||||
mirrorRects.Dispose();
|
||||
mirrorRects = nil;
|
||||
hasMirror = false;
|
||||
}
|
||||
|
@@ -194,7 +194,7 @@ Boolean CreateNewRoom (short h, short v)
|
||||
if (availableRoom == -1) // found no available rooms
|
||||
{
|
||||
howMuch = sizeof(roomType); // add new room to end of house
|
||||
theErr = PtrAndHand((Ptr)thisRoom, (Handle)thisHouse, howMuch);
|
||||
theErr = PtrAndHand((Ptr)thisRoom, thisHouse.StaticCast<void>(), howMuch);
|
||||
if (theErr != PLErrors::kNone)
|
||||
{
|
||||
YellowAlert(kYellowUnaccounted, theErr);
|
||||
@@ -260,7 +260,7 @@ void ReadyBackground (short theID, short *theTiles)
|
||||
thePicture = GetPicture(theID);
|
||||
if (thePicture == nil)
|
||||
{
|
||||
thePicture = (PicHandle)GetResource('Date', theID);
|
||||
thePicture = GetResource('Date', theID).StaticCast<Picture>();
|
||||
if (thePicture == nil)
|
||||
{
|
||||
YellowAlert(kYellowNoBackground, 0);
|
||||
@@ -271,7 +271,7 @@ void ReadyBackground (short theID, short *theTiles)
|
||||
dest = (*thePicture)->picFrame.ToRect();
|
||||
QOffsetRect(&dest, -dest.left, -dest.top);
|
||||
DrawPicture(thePicture, &dest);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
|
||||
QSetRect(&src, 0, 0, kTileWide, kTileHigh);
|
||||
QSetRect(&dest, 0, 0, kTileWide, kTileHigh);
|
||||
@@ -895,7 +895,7 @@ short GetOriginalBounding (short theID)
|
||||
boundsHand boundsRes;
|
||||
short boundCode;
|
||||
|
||||
boundsRes = (boundsHand)GetResource('bnds', theID);
|
||||
boundsRes = GetResource('bnds', theID).StaticCast<boundsType>();
|
||||
if (boundsRes == nil)
|
||||
{
|
||||
if (PictIDExists(theID))
|
||||
@@ -913,7 +913,7 @@ short GetOriginalBounding (short theID)
|
||||
boundCode += 4;
|
||||
if ((*boundsRes)->bottom)
|
||||
boundCode += 8;
|
||||
DisposeHandle((Handle)boundsRes);
|
||||
boundsRes.Dispose();
|
||||
}
|
||||
|
||||
return (boundCode);
|
||||
|
@@ -134,7 +134,7 @@ void LoadGraphicSpecial (short resID)
|
||||
thePicture = GetPicture(resID);
|
||||
if (thePicture == nil)
|
||||
{
|
||||
thePicture = (PicHandle)GetResource('Date', resID);
|
||||
thePicture = GetResource('Date', resID).StaticCast<Picture>();
|
||||
if (thePicture == nil)
|
||||
{
|
||||
thePicture = GetPicture(2000);
|
||||
@@ -147,7 +147,7 @@ void LoadGraphicSpecial (short resID)
|
||||
OffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawRoomBackground
|
||||
|
@@ -839,16 +839,16 @@ Boolean PictIDExists (short theID)
|
||||
thePicture = GetPicture(theID);
|
||||
if (thePicture == nil)
|
||||
{
|
||||
thePicture = (PicHandle)GetResource('Date', theID);
|
||||
thePicture = GetResource('Date', theID).StaticCast<Picture>();
|
||||
if (thePicture == nil)
|
||||
{
|
||||
foundIt = false;
|
||||
}
|
||||
else
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
}
|
||||
else
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
|
||||
// foundIt = false;
|
||||
// numPicts = Count1Resources('PICT');
|
||||
@@ -880,8 +880,8 @@ short GetFirstPICT (void)
|
||||
resHandle = Get1IndResource('PICT', 1);
|
||||
if (resHandle != nil)
|
||||
{
|
||||
const PortabilityLayer::ResourceCompiledRef *resRef = PortabilityLayer::ResourceManager::GetInstance()->ResourceForHandle(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(resHandle));
|
||||
DisposeHandle(resHandle);
|
||||
const PortabilityLayer::ResourceCompiledRef *resRef = PortabilityLayer::ResourceManager::GetInstance()->ResourceForHandle(resHandle.MMBlock());
|
||||
resHandle.Dispose();
|
||||
return resRef->m_resID;
|
||||
}
|
||||
else
|
||||
|
@@ -228,13 +228,13 @@ PLError_t LoadTriggerSound (short soundID)
|
||||
theSoundData[kMaxSounds - 1] = NewPtr(soundDataSize);
|
||||
if (theSoundData[kMaxSounds - 1] == nil)
|
||||
{
|
||||
DisposeHandle(theSound);
|
||||
theSound.Dispose();
|
||||
theErr = PLErrors::kOutOfMemory;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[kMaxSounds - 1], soundDataSize);
|
||||
DisposeHandle(theSound);
|
||||
theSound.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,7 @@ PLError_t LoadBufferSounds (void)
|
||||
return (PLErrors::kOutOfMemory);
|
||||
|
||||
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[i], soundDataSize);
|
||||
DisposeHandle(theSound);
|
||||
theSound.Dispose();
|
||||
}
|
||||
|
||||
theSoundData[kMaxSounds - 1] = nil;
|
||||
|
@@ -84,7 +84,7 @@ void InitScoreboardMap (void)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
|
||||
QSetRect(&badgeSrcRect, 0, 0, 32, 66); // 2144 pixels
|
||||
theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect, kPreferredPixelFormat);
|
||||
|
@@ -289,7 +289,7 @@ void CreatePointers (void)
|
||||
else
|
||||
{
|
||||
BlockMove(*tempHandle, demoData, kDemoLength);
|
||||
DisposeHandle(tempHandle);
|
||||
tempHandle.Dispose();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -288,7 +288,7 @@ void LoadGraphic (short resID)
|
||||
OffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- LoadScaledGraphic
|
||||
@@ -304,7 +304,7 @@ void LoadScaledGraphic (short resID, Rect *theRect)
|
||||
if (thePicture == nil)
|
||||
RedAlert(kErrFailedGraphicLoad);
|
||||
DrawPicture(thePicture, theRect);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
thePicture.Dispose();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- LargeIconPlot
|
||||
|
@@ -533,10 +533,10 @@ namespace PortabilityLayer
|
||||
}
|
||||
|
||||
if (icsHandle)
|
||||
DisposeHandle(icsHandle);
|
||||
icsHandle.Dispose();
|
||||
|
||||
if (ics8Handle)
|
||||
DisposeHandle(ics8Handle);
|
||||
ics8Handle.Dispose();
|
||||
|
||||
m_haveIcon = true;
|
||||
}
|
||||
|
@@ -8,8 +8,7 @@ struct Control
|
||||
{
|
||||
};
|
||||
|
||||
typedef Control *ControlPtr;
|
||||
typedef ControlPtr *ControlHandle;
|
||||
typedef THandle<Control> ControlHandle;
|
||||
|
||||
typedef void(*ControlActionProc)(ControlHandle control, short part);
|
||||
typedef ControlActionProc ControlActionUPP;
|
||||
|
@@ -222,7 +222,7 @@ Rect BERect::ToRect() const
|
||||
|
||||
CursHandle GetCursor(int cursorID)
|
||||
{
|
||||
return reinterpret_cast<CursHandle>(GetResource('CURS', cursorID));
|
||||
return GetResource('CURS', cursorID).ReinterpretCast<Cursor>();
|
||||
}
|
||||
|
||||
CCrsrHandle GetCCursor(int cursorID)
|
||||
@@ -271,7 +271,7 @@ void DisposeCCursor(CCrsrHandle handle)
|
||||
{
|
||||
(*handle)->hwCursor->Destroy();
|
||||
|
||||
PortabilityLayer::MemoryManager::GetInstance()->ReleaseHandle(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(handle));
|
||||
PortabilityLayer::MemoryManager::GetInstance()->ReleaseHandle(handle.MMBlock());
|
||||
}
|
||||
|
||||
void Delay(int ticks, UInt32 *endTickCount)
|
||||
@@ -298,11 +298,7 @@ short Alert(int dialogID, void *unknown)
|
||||
|
||||
Handle GetResource(int32_t resType, int id)
|
||||
{
|
||||
PortabilityLayer::MMHandleBlock *block = PortabilityLayer::ResourceManager::GetInstance()->GetResource(PortabilityLayer::ResTypeID(resType), id);
|
||||
if (!block)
|
||||
return nullptr;
|
||||
|
||||
return &block->m_contents;
|
||||
return PortabilityLayer::ResourceManager::GetInstance()->GetResource(PortabilityLayer::ResTypeID(resType), id);
|
||||
}
|
||||
|
||||
Handle GetResource(const char(&resTypeLiteral)[5], int id)
|
||||
@@ -637,10 +633,10 @@ void GetIndString(unsigned char *str, int stringsID, int fnameIndex)
|
||||
if (fnameIndex < 1)
|
||||
return;
|
||||
|
||||
PortabilityLayer::MMHandleBlock *istrRes = PortabilityLayer::ResourceManager::GetInstance()->GetResource('STR#', stringsID);
|
||||
if (istrRes && istrRes->m_contents)
|
||||
THandle<uint8_t> istrRes = PortabilityLayer::ResourceManager::GetInstance()->GetResource('STR#', stringsID).StaticCast<uint8_t>();
|
||||
if (istrRes && *istrRes)
|
||||
{
|
||||
const uint8_t *contentsBytes = static_cast<const uint8_t *>(istrRes->m_contents);
|
||||
const uint8_t *contentsBytes = *istrRes;
|
||||
const BEUInt16_t *pArraySize = reinterpret_cast<const BEUInt16_t*>(contentsBytes);
|
||||
|
||||
const uint16_t arraySize = *pArraySize;
|
||||
@@ -922,18 +918,12 @@ Handle NewHandle(Size size)
|
||||
return &hBlock->m_contents;
|
||||
}
|
||||
|
||||
void DisposeHandle(Handle handle)
|
||||
{
|
||||
PortabilityLayer::MemoryManager::GetInstance()->ReleaseHandle(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(handle));
|
||||
}
|
||||
|
||||
long GetHandleSize(Handle handle)
|
||||
{
|
||||
if (!handle)
|
||||
return 0;
|
||||
|
||||
PortabilityLayer::MMHandleBlock *block = reinterpret_cast<PortabilityLayer::MMHandleBlock*>(handle);
|
||||
return static_cast<long>(block->m_size);
|
||||
return handle.MMBlock()->m_size;
|
||||
}
|
||||
|
||||
PLError_t PtrAndHand(const void *data, Handle handle, Size size)
|
||||
@@ -945,7 +935,7 @@ PLError_t PtrAndHand(const void *data, Handle handle, Size size)
|
||||
PLError_t SetHandleSize(Handle hdl, Size newSize)
|
||||
{
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
if (!mm->ResizeHandle(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(hdl), newSize))
|
||||
if (!mm->ResizeHandle(hdl.MMBlock(), newSize))
|
||||
return PLErrors::kOutOfMemory;
|
||||
|
||||
return PLErrors::kNone;
|
||||
|
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef __PL_CORE_H__
|
||||
#define __PL_CORE_H__
|
||||
|
||||
#include "DataTypes.h"
|
||||
#include "PLErrorCodes.h"
|
||||
@@ -9,6 +7,7 @@
|
||||
#include "QDGraf.h"
|
||||
#include "ResTypeID.h"
|
||||
#include "VirtualDirectory.h"
|
||||
#include "PLHandle.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(error:4311) // Pointer truncation to int
|
||||
@@ -44,7 +43,6 @@ struct CGraf;
|
||||
struct Menu;
|
||||
|
||||
typedef void *Ptr;
|
||||
typedef Ptr *Handle;
|
||||
|
||||
#define PL_DEAD(n) ((void)0)
|
||||
|
||||
@@ -172,10 +170,10 @@ typedef Menu *MenuPtr;
|
||||
typedef CInfoPBRec *CInfoPBPtr;
|
||||
typedef VersionRecord *VersRecPtr;
|
||||
|
||||
typedef CursPtr *CursHandle;
|
||||
typedef CCrsrPtr *CCrsrHandle;
|
||||
typedef MenuPtr *MenuHandle;
|
||||
typedef VersRecPtr *VersRecHndl;
|
||||
typedef THandle<Cursor> CursHandle;
|
||||
typedef THandle<CCursor> CCrsrHandle;
|
||||
typedef THandle<Menu> MenuHandle;
|
||||
typedef THandle<VersionRecord> VersRecHndl;
|
||||
|
||||
typedef WindowPtr WindowRef; // wtf?
|
||||
|
||||
@@ -332,7 +330,6 @@ void ExitToShell();
|
||||
void InvalWindowRect(WindowPtr window, const Rect *rect);
|
||||
|
||||
Handle NewHandle(Size size);
|
||||
void DisposeHandle(Handle handle);
|
||||
long GetHandleSize(Handle handle);
|
||||
|
||||
PLError_t PtrAndHand(const void *data, Handle handle, Size size); // Appends data to the end of a handle
|
||||
@@ -362,6 +359,3 @@ void PL_NotYetImplemented();
|
||||
void PL_NotYetImplemented_Minor();
|
||||
void PL_NotYetImplemented_TODO(const char *category);
|
||||
void PL_Init();
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -23,22 +23,22 @@ CGrafPtr GetDialogPort(DialogPtr dialog)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GetDialogItem(DialogPtr dialog, int index, short *itemType, Handle *itemHandle, Rect *itemRect)
|
||||
void GetDialogItem(DialogPtr dialog, int index, short *itemType, THandle<Control> *itemHandle, Rect *itemRect)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
void GetDialogItemText(Handle handle, StringPtr str)
|
||||
void GetDialogItemText(THandle<Control> handle, StringPtr str)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
void SetDialogItem(DialogPtr dialog, int index, short itemType, Handle itemHandle, const Rect *itemRect)
|
||||
void SetDialogItem(DialogPtr dialog, int index, short itemType, THandle<Control> itemHandle, const Rect *itemRect)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
void SetDialogItemText(Handle handle, const PLPasStr &str)
|
||||
void SetDialogItemText(THandle<Control> handle, const PLPasStr &str)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include "PLCore.h"
|
||||
|
||||
class PLPasStr;
|
||||
struct Control;
|
||||
|
||||
struct Dialog : public PortabilityLayer::QDPort
|
||||
{
|
||||
@@ -23,8 +24,7 @@ enum TEMode
|
||||
|
||||
typedef Dialog *DialogPtr;
|
||||
|
||||
typedef DialogTemplate *DialogTPtr;
|
||||
typedef DialogTPtr *DialogTHndl;
|
||||
typedef THandle<DialogTemplate> DialogTHndl;
|
||||
|
||||
|
||||
typedef Boolean(*ModalFilterUPP)(DialogPtr dial, EventRecord *event, short *item);
|
||||
@@ -34,11 +34,11 @@ WindowPtr GetDialogWindow(DialogPtr dialog);
|
||||
DialogPtr GetNewDialog(int resID, void *unknown, WindowPtr behind);
|
||||
CGrafPtr GetDialogPort(DialogPtr dialog);
|
||||
|
||||
void GetDialogItem(DialogPtr dialog, int index, short *itemType, Handle *itemHandle, Rect *itemRect);
|
||||
void GetDialogItemText(Handle handle, StringPtr str);
|
||||
void GetDialogItem(DialogPtr dialog, int index, short *itemType, THandle<Control> *itemHandle, Rect *itemRect);
|
||||
void GetDialogItemText(THandle<Control> handle, StringPtr str);
|
||||
|
||||
void SetDialogItem(DialogPtr dialog, int index, short itemType, Handle itemHandle, const Rect *itemRect);
|
||||
void SetDialogItemText(Handle handle, const PLPasStr &str);
|
||||
void SetDialogItem(DialogPtr dialog, int index, short itemType, THandle<Control> itemHandle, const Rect *itemRect);
|
||||
void SetDialogItemText(THandle<Control> handle, const PLPasStr &str);
|
||||
|
||||
void SelectDialogItemText(DialogPtr dialog, int item, int firstSelChar, int lastSelCharExclusive);
|
||||
|
||||
|
9
PortabilityLayer/PLHandle.cpp
Normal file
9
PortabilityLayer/PLHandle.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "PLHandle.h"
|
||||
|
||||
#include "MemoryManager.h"
|
||||
|
||||
void THandleBase::Dispose()
|
||||
{
|
||||
if (m_hdl)
|
||||
PortabilityLayer::MemoryManager::GetInstance()->ReleaseHandle(m_hdl);
|
||||
}
|
133
PortabilityLayer/PLHandle.h
Normal file
133
PortabilityLayer/PLHandle.h
Normal file
@@ -0,0 +1,133 @@
|
||||
#pragma once
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
struct MMHandleBlock;
|
||||
}
|
||||
|
||||
class THandleBase
|
||||
{
|
||||
public:
|
||||
explicit THandleBase(PortabilityLayer::MMHandleBlock *hdl);
|
||||
THandleBase(const THandleBase &other);
|
||||
|
||||
PortabilityLayer::MMHandleBlock *MMBlock() const;
|
||||
|
||||
void Dispose();
|
||||
|
||||
protected:
|
||||
PortabilityLayer::MMHandleBlock *m_hdl;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class THandle final : public THandleBase
|
||||
{
|
||||
public:
|
||||
THandle();
|
||||
THandle(T **hdl);
|
||||
explicit THandle(PortabilityLayer::MMHandleBlock *hdl);
|
||||
THandle(const THandle<T> &other);
|
||||
|
||||
operator T **() const;
|
||||
|
||||
template<class TOther>
|
||||
THandle<TOther> StaticCast() const;
|
||||
|
||||
template<class TOther>
|
||||
THandle<TOther> ReinterpretCast() const;
|
||||
|
||||
bool operator==(const THandle<T> &other) const;
|
||||
bool operator!=(const THandle<T> &other) const;
|
||||
|
||||
bool operator==(T** other) const;
|
||||
bool operator!=(T** other) const;
|
||||
};
|
||||
|
||||
typedef THandle<void> Handle;
|
||||
|
||||
#include "MMHandleBlock.h"
|
||||
|
||||
inline THandleBase::THandleBase(PortabilityLayer::MMHandleBlock *hdl)
|
||||
: m_hdl(hdl)
|
||||
{
|
||||
}
|
||||
|
||||
inline THandleBase::THandleBase(const THandleBase &other)
|
||||
: m_hdl(other.m_hdl)
|
||||
{
|
||||
}
|
||||
|
||||
inline PortabilityLayer::MMHandleBlock *THandleBase::MMBlock() const
|
||||
{
|
||||
return m_hdl;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline THandle<T>::THandle()
|
||||
: THandleBase(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline THandle<T>::THandle(T **hdl)
|
||||
: THandleBase(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(hdl))
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline THandle<T>::THandle(PortabilityLayer::MMHandleBlock *hdl)
|
||||
: THandleBase(hdl)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline THandle<T>::THandle(const THandle<T> &other)
|
||||
: THandleBase(other.m_hdl)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool THandle<T>::operator==(const THandle<T> &other) const
|
||||
{
|
||||
return m_hdl == other.m_hdl;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool THandle<T>::operator!=(const THandle<T> &other) const
|
||||
{
|
||||
return m_hdl != other.m_hdl;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool THandle<T>::operator==(T** other) const
|
||||
{
|
||||
return static_cast<void*>(&m_hdl->m_contents) == static_cast<void*>(other);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool THandle<T>::operator!=(T** other) const
|
||||
{
|
||||
return static_cast<void*>(&m_hdl->m_contents) != static_cast<void*>(other);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline THandle<T>::operator T**() const
|
||||
{
|
||||
return reinterpret_cast<T**>(&m_hdl->m_contents);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<class TOther>
|
||||
THandle<TOther> THandle<T>::StaticCast() const
|
||||
{
|
||||
(void)(static_cast<TOther*>(static_cast<T*>(nullptr)));
|
||||
return THandle<TOther>(m_hdl);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<class TOther>
|
||||
THandle<TOther> THandle<T>::ReinterpretCast() const
|
||||
{
|
||||
(void)(reinterpret_cast<TOther*>(static_cast<T*>(nullptr)));
|
||||
return THandle<TOther>(m_hdl);
|
||||
}
|
@@ -27,7 +27,7 @@ MenuHandle GetMenu(int resID)
|
||||
return nullptr;
|
||||
|
||||
const MenuHandle menu = PortabilityLayer::MenuManager::GetInstance()->DeserializeMenu(*menuRes);
|
||||
DisposeHandle(menuRes);
|
||||
menuRes.Dispose();
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
@@ -252,7 +252,7 @@ PixMapHandle GetGWorldPixMap(GWorldPtr gworld)
|
||||
|
||||
PicHandle GetPicture(short resID)
|
||||
{
|
||||
return reinterpret_cast<PicHandle>(PortabilityLayer::ResourceManager::GetInstance()->GetResource('PICT', resID));
|
||||
return PortabilityLayer::ResourceManager::GetInstance()->GetResource('PICT', resID).StaticCast<Picture>();
|
||||
}
|
||||
|
||||
void OffsetRect(Rect *rect, int right, int down)
|
||||
@@ -290,7 +290,7 @@ void DrawPicture(PicHandle pict, Rect *bounds)
|
||||
|
||||
PortabilityLayer::PixMapImpl *pixMap = static_cast<PortabilityLayer::PixMapImpl*>(*port->GetPixMap());
|
||||
|
||||
long handleSize = GetHandleSize(reinterpret_cast<Handle>(pict));
|
||||
long handleSize = pict.MMBlock()->m_size;
|
||||
PortabilityLayer::MemReaderStream stream(picPtr, handleSize);
|
||||
|
||||
// Adjust draw origin
|
||||
|
@@ -18,7 +18,7 @@ typedef PixMap *PixMapPtr;
|
||||
typedef PixMapPtr *PixMapHandle;
|
||||
|
||||
typedef Picture *PicPtr;
|
||||
typedef PicPtr *PicHandle;
|
||||
typedef THandle<Picture> PicHandle;
|
||||
|
||||
enum QDFlags
|
||||
{
|
||||
|
@@ -889,8 +889,8 @@ void GetIndPattern(Pattern *pattern, int patListID, int index)
|
||||
if (index < 1)
|
||||
return;
|
||||
|
||||
PortabilityLayer::MMHandleBlock *patternList = PortabilityLayer::ResourceManager::GetInstance()->GetResource('PAT#', patListID);
|
||||
const uint8_t *patternRes = static_cast<const uint8_t*>(patternList->m_contents);
|
||||
THandle<uint8_t> patternList = PortabilityLayer::ResourceManager::GetInstance()->GetResource('PAT#', patListID).StaticCast<uint8_t>();
|
||||
const uint8_t *patternRes = *patternList;
|
||||
|
||||
int numPatterns = (patternRes[0] << 8) | patternRes[1];
|
||||
if (index > numPatterns)
|
||||
|
@@ -33,7 +33,7 @@ namespace PortabilityLayer
|
||||
short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) override;
|
||||
void CloseResFile(short ref) override;
|
||||
|
||||
MMHandleBlock *GetResource(const ResTypeID &resType, int id) override;
|
||||
THandle<void> GetResource(const ResTypeID &resType, int id) override;
|
||||
|
||||
short GetCurrentResFile() const override;
|
||||
void SetCurrentResFile(short ref) override;
|
||||
@@ -224,7 +224,7 @@ namespace PortabilityLayer
|
||||
m_currentResFile = m_lastResFile;
|
||||
}
|
||||
|
||||
MMHandleBlock *ResourceManagerImpl::GetResource(const ResTypeID &resType, int id)
|
||||
THandle<void> ResourceManagerImpl::GetResource(const ResTypeID &resType, int id)
|
||||
{
|
||||
short searchIndex = m_currentResFile;
|
||||
while (searchIndex >= 0)
|
||||
@@ -233,7 +233,7 @@ namespace PortabilityLayer
|
||||
assert(slot.m_resourceFile);
|
||||
|
||||
if (MMHandleBlock *block = slot.m_resourceFile->GetResource(resType, id, m_load))
|
||||
return block;
|
||||
return THandle<void>(block);
|
||||
|
||||
searchIndex = slot.m_prevFile;
|
||||
}
|
||||
|
@@ -17,24 +17,6 @@ struct PLOpenedResFile
|
||||
static const unsigned int kPLMaxOpenedResFiles = 64;
|
||||
static PLOpenedResFile gs_resFiles[kPLMaxOpenedResFiles];
|
||||
|
||||
void DetachResource(Handle hdl)
|
||||
{
|
||||
if (!hdl)
|
||||
return;
|
||||
|
||||
PortabilityLayer::MMHandleBlock *block = reinterpret_cast<PortabilityLayer::MMHandleBlock*>(hdl);
|
||||
assert(block->m_rmSelfRef);
|
||||
assert(block->m_rmSelfRef->m_handle == block);
|
||||
block->m_rmSelfRef->m_handle = nullptr;
|
||||
block->m_rmSelfRef = nullptr;
|
||||
}
|
||||
|
||||
void ReleaseResource(Handle hdl)
|
||||
{
|
||||
DetachResource(hdl);
|
||||
DisposeHandle(hdl);
|
||||
}
|
||||
|
||||
short CurResFile()
|
||||
{
|
||||
return PortabilityLayer::ResourceManager::GetInstance()->GetCurrentResFile();
|
||||
@@ -76,7 +58,7 @@ void SetResLoad(Boolean load)
|
||||
|
||||
long GetMaxResourceSize(Handle res)
|
||||
{
|
||||
const PortabilityLayer::MMHandleBlock *hBlock = reinterpret_cast<PortabilityLayer::MMHandleBlock*>(res);
|
||||
const PortabilityLayer::MMHandleBlock *hBlock = res.MMBlock();
|
||||
const PortabilityLayer::ResourceCompiledRef *resRef = hBlock->m_rmSelfRef;
|
||||
return resRef->GetSize();
|
||||
}
|
||||
|
@@ -193,6 +193,7 @@
|
||||
<ClInclude Include="PLEventQueue.h" />
|
||||
<ClInclude Include="PLFolders.h" />
|
||||
<ClInclude Include="PLHacks.h" />
|
||||
<ClInclude Include="PLHandle.h" />
|
||||
<ClInclude Include="PLKeyEncoding.h" />
|
||||
<ClInclude Include="PLLowMem.h" />
|
||||
<ClInclude Include="PLMacTypes.h" />
|
||||
@@ -317,6 +318,7 @@
|
||||
<ClCompile Include="ResourceFile.cpp" />
|
||||
<ClCompile Include="ScanlineMaskIterator.cpp" />
|
||||
<ClCompile Include="SimpleGraphic.cpp" />
|
||||
<ClCompile Include="PLHandle.cpp" />
|
||||
<ClCompile Include="WindowDef.cpp" />
|
||||
<ClCompile Include="WindowManager.cpp" />
|
||||
<ClCompile Include="XModemCRC.cpp" />
|
||||
|
@@ -390,6 +390,9 @@
|
||||
<ClInclude Include="EllipsePlotter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PLHandle.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CFileStream.cpp">
|
||||
@@ -590,5 +593,8 @@
|
||||
<ClCompile Include="EllipsePlotter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PLHandle.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "VirtualDirectory.h"
|
||||
#include "PLHandle.h"
|
||||
|
||||
class PLPasStr;
|
||||
|
||||
@@ -21,7 +22,7 @@ namespace PortabilityLayer
|
||||
virtual short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
|
||||
virtual void CloseResFile(short ref) = 0;
|
||||
|
||||
virtual MMHandleBlock *GetResource(const ResTypeID &resType, int id) = 0;
|
||||
virtual THandle<void> GetResource(const ResTypeID &resType, int id) = 0;
|
||||
|
||||
virtual short GetCurrentResFile() const = 0;
|
||||
virtual void SetCurrentResFile(short ref) = 0;
|
||||
|
Reference in New Issue
Block a user