mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Refactoring
This commit is contained in:
@@ -109,7 +109,7 @@ static void HiLiteOkayButton (void)
|
||||
if (thePict != nil)
|
||||
{
|
||||
DrawPicture(thePict, &okayButtonBounds);
|
||||
ReleaseResource((Handle)thePict);
|
||||
DisposeHandle((Handle)thePict);
|
||||
|
||||
okayButtIsHiLit = true;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ static void UnHiLiteOkayButton (void)
|
||||
if (thePict != nil)
|
||||
{
|
||||
DrawPicture(thePict, &okayButtonBounds);
|
||||
ReleaseResource((Handle)thePict);
|
||||
DisposeHandle((Handle)thePict);
|
||||
|
||||
okayButtIsHiLit = false;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ typedef struct
|
||||
} compiledAcurRec, *compiledAcurPtr, **compiledAcurHandle;
|
||||
|
||||
|
||||
Boolean GetMonoCursors (acurHandle, compiledAcurHandle);
|
||||
Boolean GetColorCursors (acurHandle, compiledAcurHandle);
|
||||
void InitAnimatedCursor (acurHandle);
|
||||
|
||||
@@ -47,36 +46,6 @@ Boolean useColorCursor = false;
|
||||
|
||||
|
||||
//============================================================== Functions
|
||||
//-------------------------------------------------------------- GetMonoCursors
|
||||
|
||||
// Loads b&w cursors (for animated beach ball).
|
||||
|
||||
Boolean GetMonoCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCursH)
|
||||
{
|
||||
short i, j;
|
||||
CursHandle cursHdl;
|
||||
|
||||
if (ballCursH) // Were we passed a legit acur handle?
|
||||
{
|
||||
j = (*ballCursH)->n; // Get number of 'frames' in the acur
|
||||
for (i = 0; i < j; i++) // Start walking the frames
|
||||
{
|
||||
cursHdl = GetCursor((*ballCursH)->frame[i].resID);
|
||||
if (cursHdl == nil) // Did the cursor load? It didn't?...
|
||||
{ // Well then, toss what we got.
|
||||
for (j = 0; j < i; j++)
|
||||
DisposeHandle((*compiledBallCursH)->frame[j].cursorHdl);
|
||||
return(false); // And report this to mother.
|
||||
} // However!...
|
||||
else // If cursor loaded ok...
|
||||
{ // Detach it from the resource map...
|
||||
DetachResource((Handle)cursHdl); // And assign to our struct
|
||||
(*compiledBallCursH)->frame[i].cursorHdl = (Handle)cursHdl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- GetColorCursors
|
||||
|
||||
@@ -133,8 +102,6 @@ void InitAnimatedCursor (acurHandle ballCursH)
|
||||
|
||||
if (useColor)
|
||||
useColor = GetColorCursors(ballCursH, compiledBallCursorH);
|
||||
if (!useColor && !GetMonoCursors(ballCursH, compiledBallCursorH))
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
DisposCursors();
|
||||
|
||||
animCursorH = ballCursH;
|
||||
@@ -189,7 +156,7 @@ void DisposCursors (void)
|
||||
|
||||
if (animCursorH != nil)
|
||||
{
|
||||
ReleaseResource((Handle)animCursorH);
|
||||
DisposeHandle((Handle)animCursorH);
|
||||
animCursorH = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +93,10 @@ Boolean CreateNewHouse (void)
|
||||
theErr = fm->CreateFileAtCurrentTime(theSpec.m_dir, theSpec.m_name, 'ozm5', 'gliH');
|
||||
if (!CheckFileError(theErr, PSTR("New House")))
|
||||
return (false);
|
||||
HCreateResFile(theSpec.m_dir, theSpec.m_name);
|
||||
if (ResError() != PLErrors::kNone)
|
||||
YellowAlert(kYellowFailedResCreate, ResError());
|
||||
|
||||
theErr = HCreateResFile(theSpec.m_dir, theSpec.m_name);
|
||||
if (theErr != PLErrors::kNone)
|
||||
YellowAlert(kYellowFailedResCreate, theErr);
|
||||
|
||||
PasStringCopy(theSpec.m_name, thisHouseName);
|
||||
AddExtraHouse(theSpec);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "House.h"
|
||||
#include "IOStream.h"
|
||||
#include "ObjectEdit.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
|
||||
#define kSaveChangesAlert 1002
|
||||
@@ -866,11 +867,12 @@ Boolean CloseHouse (void)
|
||||
|
||||
void OpenHouseResFork (void)
|
||||
{
|
||||
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
|
||||
if (houseResFork == -1)
|
||||
{
|
||||
houseResFork = FSpOpenResFile(theHousesSpecs[thisHouseIndex], fsCurPerm);
|
||||
if (houseResFork == -1)
|
||||
YellowAlert(kYellowFailedResOpen, ResError());
|
||||
houseResFork = rm->OpenResFork(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name);
|
||||
if (houseResFork < 0)
|
||||
YellowAlert(kYellowFailedResOpen, PLErrors::kResourceError);
|
||||
else
|
||||
UseResFile(houseResFork);
|
||||
}
|
||||
@@ -883,7 +885,9 @@ void CloseHouseResFork (void)
|
||||
{
|
||||
if (houseResFork != -1)
|
||||
{
|
||||
CloseResFile(houseResFork);
|
||||
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
|
||||
|
||||
rm->CloseResFile(houseResFork);
|
||||
houseResFork = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ void LoadGraphicPlus (short resID, Rect *theRect)
|
||||
}
|
||||
}
|
||||
DrawPicture(thePicture, theRect);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- RedrawMapContents
|
||||
|
||||
@@ -261,7 +261,7 @@ PLError_t LoadMusicSounds (void)
|
||||
return PLErrors::kOutOfMemory;
|
||||
|
||||
BlockMove((Ptr)(static_cast<Byte*>(*theSound) + 20L), theMusicData[i], soundDataSize);
|
||||
ReleaseResource(theSound);
|
||||
DisposeHandle(theSound);
|
||||
}
|
||||
return (theErr);
|
||||
}
|
||||
@@ -418,7 +418,7 @@ long MusicBytesNeeded (void)
|
||||
if (theSound == nil)
|
||||
{
|
||||
SetResLoad(true);
|
||||
return ((long)ResError());
|
||||
return -1;
|
||||
}
|
||||
totalBytes += GetMaxResourceSize(theSound);
|
||||
// ReleaseResource(theSound);
|
||||
|
||||
@@ -1158,7 +1158,7 @@ void DrawCalendar (Rect *theRect)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, theRect->left, theRect->top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
|
||||
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);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
@@ -1246,7 +1246,7 @@ void DrawPictObject (short what, Rect *theRect)
|
||||
bounds = srcRects[what];
|
||||
QOffsetRect(&bounds, theRect->left, theRect->top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ void PlayGame (void)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
}
|
||||
#else
|
||||
// ShowMenuBarOld(); // TEMP
|
||||
@@ -576,7 +576,7 @@ void PlayGame (void)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ void ReadyBackground (short theID, short *theTiles)
|
||||
dest = (*thePicture)->picFrame.ToRect();
|
||||
QOffsetRect(&dest, -dest.left, -dest.top);
|
||||
DrawPicture(thePicture, &dest);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
|
||||
QSetRect(&src, 0, 0, kTileWide, kTileHigh);
|
||||
QSetRect(&dest, 0, 0, kTileWide, kTileHigh);
|
||||
@@ -913,7 +913,7 @@ short GetOriginalBounding (short theID)
|
||||
boundCode += 4;
|
||||
if ((*boundsRes)->bottom)
|
||||
boundCode += 8;
|
||||
ReleaseResource((Handle)boundsRes);
|
||||
DisposeHandle((Handle)boundsRes);
|
||||
}
|
||||
|
||||
return (boundCode);
|
||||
|
||||
@@ -147,7 +147,7 @@ void LoadGraphicSpecial (short resID)
|
||||
OffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawRoomBackground
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "DialogUtils.h"
|
||||
#include "Externs.h"
|
||||
#include "RectUtils.h"
|
||||
#include "ResourceCompiledRef.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
|
||||
@@ -843,10 +845,10 @@ Boolean PictIDExists (short theID)
|
||||
foundIt = false;
|
||||
}
|
||||
else
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
}
|
||||
else
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
|
||||
// foundIt = false;
|
||||
// numPicts = Count1Resources('PICT');
|
||||
@@ -874,15 +876,13 @@ short GetFirstPICT (void)
|
||||
{
|
||||
Handle resHandle;
|
||||
Str255 resName;
|
||||
ResType resType;
|
||||
short resID;
|
||||
|
||||
resHandle = Get1IndResource('PICT', 1);
|
||||
if (resHandle != nil)
|
||||
{
|
||||
GetResInfo(resHandle, &resID, &resType, resName);
|
||||
ReleaseResource(resHandle);
|
||||
return (resID);
|
||||
const PortabilityLayer::ResourceCompiledRef *resRef = PortabilityLayer::ResourceManager::GetInstance()->ResourceForHandle(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(resHandle));
|
||||
DisposeHandle(resHandle);
|
||||
return resRef->m_resID;
|
||||
}
|
||||
else
|
||||
return (-1);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "FileManager.h"
|
||||
#include "House.h"
|
||||
#include "RectUtils.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "VirtualDirectory.h"
|
||||
|
||||
|
||||
@@ -111,7 +112,7 @@ void UpdateLoadDialog (DialogPtr theDialog)
|
||||
else
|
||||
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
|
||||
kDefaultHousePict8);
|
||||
CloseResFile(isResFile);
|
||||
PortabilityLayer::ResourceManager::GetInstance()->CloseResFile(isResFile);
|
||||
}
|
||||
else
|
||||
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
|
||||
|
||||
@@ -228,13 +228,13 @@ PLError_t LoadTriggerSound (short soundID)
|
||||
theSoundData[kMaxSounds - 1] = NewPtr(soundDataSize);
|
||||
if (theSoundData[kMaxSounds - 1] == nil)
|
||||
{
|
||||
ReleaseResource(theSound);
|
||||
DisposeHandle(theSound);
|
||||
theErr = PLErrors::kOutOfMemory;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[kMaxSounds - 1], soundDataSize);
|
||||
ReleaseResource(theSound);
|
||||
DisposeHandle(theSound);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,7 @@ PLError_t LoadBufferSounds (void)
|
||||
return (PLErrors::kOutOfMemory);
|
||||
|
||||
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[i], soundDataSize);
|
||||
ReleaseResource(theSound);
|
||||
DisposeHandle(theSound);
|
||||
}
|
||||
|
||||
theSoundData[kMaxSounds - 1] = nil;
|
||||
@@ -436,7 +436,7 @@ long SoundBytesNeeded (void)
|
||||
if (theSound == nil)
|
||||
{
|
||||
SetResLoad(true);
|
||||
return ((long)ResError());
|
||||
return -1;
|
||||
}
|
||||
totalBytes += GetMaxResourceSize(theSound);
|
||||
// ReleaseResource(theSound);
|
||||
|
||||
@@ -84,7 +84,7 @@ void InitScoreboardMap (void)
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
|
||||
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);
|
||||
ReleaseResource(tempHandle);
|
||||
DisposeHandle(tempHandle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ void LoadGraphic (short resID)
|
||||
OffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- LoadScaledGraphic
|
||||
@@ -304,7 +304,7 @@ void LoadScaledGraphic (short resID, Rect *theRect)
|
||||
if (thePicture == nil)
|
||||
RedAlert(kErrFailedGraphicLoad);
|
||||
DrawPicture(thePicture, theRect);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
DisposeHandle((Handle)thePicture);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- LargeIconPlot
|
||||
@@ -317,7 +317,7 @@ void LargeIconPlot (Rect *theRect, short theID)
|
||||
|
||||
theErr = GetIconSuite(&theSuite, theID, svAllLargeData);
|
||||
if (theErr == PLErrors::kNone)
|
||||
theErr = PlotIconSuite(theRect, atNone, ttNone, theSuite);
|
||||
theErr = PlotIconSuite(theRect, theSuite);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawCIcon
|
||||
|
||||
Reference in New Issue
Block a user