mirror of
https://github.com/elasota/Aerofoil.git
synced 2026-03-01 21:34:15 +00:00
Level editor and resource loader fixups and refactors
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include "PLSound.h"
|
#include "PLSound.h"
|
||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
#include "PLSysCalls.h"
|
#include "PLSysCalls.h"
|
||||||
|
#include "PLTimeTaggedVOSEvent.h"
|
||||||
#include "PLWidgets.h"
|
#include "PLWidgets.h"
|
||||||
#include "About.h"
|
#include "About.h"
|
||||||
#include "DialogManager.h"
|
#include "DialogManager.h"
|
||||||
@@ -19,8 +20,8 @@
|
|||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "HostSystemServices.h"
|
#include "HostSystemServices.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
#include "ScanlineMask.h"
|
#include "ScanlineMask.h"
|
||||||
#include "PLTimeTaggedVOSEvent.h"
|
|
||||||
|
|
||||||
|
|
||||||
static void HiLiteOkayButton (DrawSurface *surface);
|
static void HiLiteOkayButton (DrawSurface *surface);
|
||||||
@@ -49,16 +50,13 @@ void DoAbout (void)
|
|||||||
StringPtr messagePtr;
|
StringPtr messagePtr;
|
||||||
VersRecHndl version;
|
VersRecHndl version;
|
||||||
ControlHandle itemHandle;
|
ControlHandle itemHandle;
|
||||||
short hit, wasResFile;
|
short hit;
|
||||||
|
|
||||||
wasResFile = CurResFile();
|
|
||||||
UseResFile(thisMac.thisResFile);
|
|
||||||
|
|
||||||
aboutDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kAboutDialogID, PL_GetPutInFrontWindowPtr());
|
aboutDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kAboutDialogID, PL_GetPutInFrontWindowPtr());
|
||||||
// if (aboutDialog == nil)
|
// if (aboutDialog == nil)
|
||||||
// RedAlert(kErrDialogDidntLoad);
|
// RedAlert(kErrDialogDidntLoad);
|
||||||
|
|
||||||
version = GetResource('vers', 1).StaticCast<VersionRecord>();
|
version = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('vers', 1).StaticCast<VersionRecord>();
|
||||||
if (version != nil)
|
if (version != nil)
|
||||||
{
|
{
|
||||||
messagePtr = (**version).shortVersion + 1 + (**version).shortVersion[0];
|
messagePtr = (**version).shortVersion + 1 + (**version).shortVersion[0];
|
||||||
@@ -86,8 +84,6 @@ void DoAbout (void)
|
|||||||
while (hit != kOkayButton);
|
while (hit != kOkayButton);
|
||||||
|
|
||||||
aboutDialog->Destroy();
|
aboutDialog->Destroy();
|
||||||
|
|
||||||
UseResFile(wasResFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================== Static Functions
|
//============================================================== Static Functions
|
||||||
@@ -101,7 +97,7 @@ static void HiLiteOkayButton (DrawSurface *surface)
|
|||||||
|
|
||||||
if (!okayButtIsHiLit)
|
if (!okayButtIsHiLit)
|
||||||
{
|
{
|
||||||
thePict = GetPicture(kOkayButtPICTHiLit);
|
thePict = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kOkayButtPICTHiLit).StaticCast<BitmapImage>();
|
||||||
if (thePict != nil)
|
if (thePict != nil)
|
||||||
{
|
{
|
||||||
surface->DrawPicture(thePict, okayButtonBounds);
|
surface->DrawPicture(thePict, okayButtonBounds);
|
||||||
@@ -123,7 +119,7 @@ static void UnHiLiteOkayButton (DrawSurface *surface)
|
|||||||
|
|
||||||
if (okayButtIsHiLit)
|
if (okayButtIsHiLit)
|
||||||
{
|
{
|
||||||
thePict = GetPicture(kOkayButtPICTNotHiLit);
|
thePict = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kOkayButtPICTNotHiLit).StaticCast<BitmapImage>();
|
||||||
if (thePict != nil)
|
if (thePict != nil)
|
||||||
{
|
{
|
||||||
surface->DrawPicture(thePict, okayButtonBounds);
|
surface->DrawPicture(thePict, okayButtonBounds);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "HostDisplayDriver.h"
|
#include "HostDisplayDriver.h"
|
||||||
#include "IGpColorCursor.h"
|
#include "IGpColorCursor.h"
|
||||||
#include "IGpDisplayDriver.h"
|
#include "IGpDisplayDriver.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
|
|
||||||
#define rAcurID 128
|
#define rAcurID 128
|
||||||
@@ -97,7 +98,7 @@ void InitAnimatedCursor (acurHandle ballCursH)
|
|||||||
compiledAcurHandle compiledBallCursorH;
|
compiledAcurHandle compiledBallCursorH;
|
||||||
|
|
||||||
if (ballCursH == nil)
|
if (ballCursH == nil)
|
||||||
ballCursH = GetResource('acur', 128).StaticCast<acurRec>();
|
ballCursH = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('acur', 128).StaticCast<acurRec>();
|
||||||
if (ballCursH && ballCursH != animCursorH)
|
if (ballCursH && ballCursH != animCursorH)
|
||||||
{
|
{
|
||||||
compiledBallCursorH = NewHandle(sizeof(compiledAcurRec) * (*ballCursH)->n).StaticCast<compiledAcurRec>();
|
compiledBallCursorH = NewHandle(sizeof(compiledAcurRec) * (*ballCursH)->n).StaticCast<compiledAcurRec>();
|
||||||
@@ -122,7 +123,7 @@ void InitAnimatedCursor (acurHandle ballCursH)
|
|||||||
|
|
||||||
void LoadCursors (void)
|
void LoadCursors (void)
|
||||||
{
|
{
|
||||||
InitAnimatedCursor(GetResource('acur', rAcurID).StaticCast<acurRec>());
|
InitAnimatedCursor(PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('acur', rAcurID).StaticCast<acurRec>());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- DisposCursors
|
//-------------------------------------------------------------- DisposCursors
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "Marquee.h"
|
#include "Marquee.h"
|
||||||
#include "ObjectEdit.h"
|
#include "ObjectEdit.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
#include "WindowDef.h"
|
||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -126,13 +127,15 @@ void OpenCoordWindow (void)
|
|||||||
|
|
||||||
if (coordWindow == nil)
|
if (coordWindow == nil)
|
||||||
{
|
{
|
||||||
|
const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar;
|
||||||
|
|
||||||
QSetRect(&coordWindowRect, 0, 0, 50, 38);
|
QSetRect(&coordWindowRect, 0, 0, 50, 38);
|
||||||
if (thisMac.hasColor)
|
if (thisMac.hasColor)
|
||||||
coordWindow = NewCWindow(nil, &coordWindowRect,
|
coordWindow = NewCWindow(nil, &coordWindowRect,
|
||||||
PSTR("Tools"), false, kWindoidWDEF, kPutInFront, true, 0L);
|
PSTR("Tools"), false, windowStyle, kPutInFront, true, 0L);
|
||||||
else
|
else
|
||||||
coordWindow = NewWindow(nil, &coordWindowRect,
|
coordWindow = NewWindow(nil, &coordWindowRect,
|
||||||
PSTR("Tools"), false, kWindoidWDEF, kPutInFront, true, 0L);
|
PSTR("Tools"), false, windowStyle, kPutInFront, true, 0L);
|
||||||
|
|
||||||
if (coordWindow == nil)
|
if (coordWindow == nil)
|
||||||
RedAlert(kErrNoMemory);
|
RedAlert(kErrNoMemory);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include "DialogUtils.h"
|
#include "DialogUtils.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "FontFamily.h"
|
#include "FontFamily.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
#define kActive 0
|
#define kActive 0
|
||||||
#define kInactive 255
|
#define kInactive 255
|
||||||
@@ -144,7 +144,7 @@ void GetDialogRect (Rect *bounds, short dialogID)
|
|||||||
{
|
{
|
||||||
Byte wasState;
|
Byte wasState;
|
||||||
|
|
||||||
Handle dlogHandle = GetResource('DLOG', dialogID).StaticCast<void>();
|
Handle dlogHandle = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('DLOG', dialogID).StaticCast<void>();
|
||||||
if (dlogHandle != nil)
|
if (dlogHandle != nil)
|
||||||
{
|
{
|
||||||
BERect dataRect = **dlogHandle.StaticCast<BERect>();
|
BERect dataRect = **dlogHandle.StaticCast<BERect>();
|
||||||
@@ -693,7 +693,7 @@ void LoadDialogPICT (Dialog *theDialog, short item, short theID)
|
|||||||
|
|
||||||
Rect iRect = theDialog->GetItems()[item - 1].GetWidget()->GetRect();;
|
Rect iRect = theDialog->GetItems()[item - 1].GetWidget()->GetRect();;
|
||||||
|
|
||||||
thePict = GetPicture(theID);
|
thePict = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', theID).StaticCast<BitmapImage>();
|
||||||
if (thePict)
|
if (thePict)
|
||||||
theDialog->GetWindow()->GetDrawSurface()->DrawPicture(thePict, iRect);
|
theDialog->GetWindow()->GetDrawSurface()->DrawPicture(thePict, iRect);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,7 +279,6 @@ short HowManyUsableScreens (Boolean use1Bit, Boolean use4Bit, Boolean use8Bit)
|
|||||||
|
|
||||||
void CheckOurEnvirons (void)
|
void CheckOurEnvirons (void)
|
||||||
{
|
{
|
||||||
thisMac.thisResFile = CurResFile();
|
|
||||||
thisMac.vRefNum = 0; // TEMP
|
thisMac.vRefNum = 0; // TEMP
|
||||||
thisMac.dirID = 0; // TEMP
|
thisMac.dirID = 0; // TEMP
|
||||||
thisMac.hasGestalt = true; // TEMP
|
thisMac.hasGestalt = true; // TEMP
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ typedef struct
|
|||||||
Rect screen, gray;
|
Rect screen, gray;
|
||||||
long dirID;
|
long dirID;
|
||||||
short wasDepth, isDepth;
|
short wasDepth, isDepth;
|
||||||
short thisResFile;
|
|
||||||
short numScreens;
|
short numScreens;
|
||||||
short vRefNum;
|
short vRefNum;
|
||||||
Boolean can1Bit;
|
Boolean can1Bit;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
class ResourceArchive;
|
class ResourceArchive;
|
||||||
class ScanlineMask;
|
class ScanlineMask;
|
||||||
|
class ResTypeID;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define kPreferredDepth 8
|
#define kPreferredDepth 8
|
||||||
@@ -174,6 +175,8 @@ void SetAppMemorySize (long);
|
|||||||
|
|
||||||
Boolean CheckFileError (short, const PLPasStr &); // --- File Error.c
|
Boolean CheckFileError (short, const PLPasStr &); // --- File Error.c
|
||||||
|
|
||||||
|
THandle<void> LoadHouseResource(const PortabilityLayer::ResTypeID &resTypeID, int16_t resID); // --- HouseIO.c
|
||||||
|
|
||||||
Boolean SavePrefs (prefsInfo *, short); // --- Prefs.c
|
Boolean SavePrefs (prefsInfo *, short); // --- Prefs.c
|
||||||
Boolean LoadPrefs (prefsInfo *, short);
|
Boolean LoadPrefs (prefsInfo *, short);
|
||||||
|
|
||||||
@@ -193,8 +196,10 @@ void FindOurDevice (void);
|
|||||||
short RandomInt (short);
|
short RandomInt (short);
|
||||||
long RandomLong (long);
|
long RandomLong (long);
|
||||||
void RedAlert (short);
|
void RedAlert (short);
|
||||||
void LoadGraphic (DrawSurface *, short);
|
void LoadGraphic (DrawSurface *surface, short resID); // Only loads from app resources
|
||||||
void LoadScaledGraphic (DrawSurface *, short, Rect *);
|
void LoadGraphicCustom (DrawSurface *surface, short resID); // Supports custom graphics
|
||||||
|
void LoadScaledGraphic (DrawSurface *, short, Rect *); // Only loads from app resources
|
||||||
|
void LoadScaledGraphicCustom (DrawSurface *, short, Rect *); // Supports custom graphics
|
||||||
bool LargeIconPlot (DrawSurface *, PortabilityLayer::ResourceArchive *, short, const Rect &);
|
bool LargeIconPlot (DrawSurface *, PortabilityLayer::ResourceArchive *, short, const Rect &);
|
||||||
void DrawCIcon (DrawSurface *surface, short, short, short);
|
void DrawCIcon (DrawSurface *surface, short, short, short);
|
||||||
char KeyMapOffsetFromRawKey (char);
|
char KeyMapOffsetFromRawKey (char);
|
||||||
@@ -226,6 +231,7 @@ void CloseThisWindow (WindowPtr *);
|
|||||||
// THREEWORDINLINE(0x4218, 0x10B8, 0x0260);
|
// THREEWORDINLINE(0x4218, 0x10B8, 0x0260);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "GliderDefines.h"
|
#include "GliderDefines.h"
|
||||||
#include "GliderStructs.h"
|
#include "GliderStructs.h"
|
||||||
#include "GliderVars.h"
|
#include "GliderVars.h"
|
||||||
|
|||||||
@@ -528,8 +528,6 @@
|
|||||||
#define kInitialGliderSelected -2
|
#define kInitialGliderSelected -2
|
||||||
#define kLeftGliderSelected -3
|
#define kLeftGliderSelected -3
|
||||||
#define kRightGliderSelected -4
|
#define kRightGliderSelected -4
|
||||||
#define kWindoidWDEF 2048
|
|
||||||
#define kWindoidGrowWDEF 2064
|
|
||||||
#define kTicksPerFrame 2
|
#define kTicksPerFrame 2
|
||||||
#define kStarPictID 1995
|
#define kStarPictID 1995
|
||||||
#define kNumUndergroundFloors 8
|
#define kNumUndergroundFloors 8
|
||||||
|
|||||||
@@ -242,8 +242,9 @@ void WhereDoesGliderBegin (Rect *theRect, short mode)
|
|||||||
Boolean HouseHasOriginalPicts (void)
|
Boolean HouseHasOriginalPicts (void)
|
||||||
{
|
{
|
||||||
short nPicts;
|
short nPicts;
|
||||||
|
|
||||||
nPicts = Count1Resources('PICT');
|
PL_NotYetImplemented(); nPicts = 0;
|
||||||
|
//nPicts = Count1Resources('PICT');
|
||||||
return (nPicts > 0);
|
return (nPicts > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "FileManager.h"
|
#include "FileManager.h"
|
||||||
#include "HostFileSystem.h"
|
#include "HostFileSystem.h"
|
||||||
|
#include "HostSystemServices.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
#include "IOStream.h"
|
#include "IOStream.h"
|
||||||
#include "ObjectEdit.h"
|
#include "ObjectEdit.h"
|
||||||
@@ -34,12 +35,14 @@ Boolean IsFileReadOnly (const VFileSpec &);
|
|||||||
|
|
||||||
Movie theMovie;
|
Movie theMovie;
|
||||||
Rect movieRect;
|
Rect movieRect;
|
||||||
short houseResFork, wasHouseVersion;
|
PortabilityLayer::ResourceArchive *houseResFork;
|
||||||
|
short wasHouseVersion;
|
||||||
PortabilityLayer::IOStream *houseStream;
|
PortabilityLayer::IOStream *houseStream;
|
||||||
Boolean houseOpen, fileDirty, gameDirty;
|
Boolean houseOpen, fileDirty, gameDirty;
|
||||||
Boolean changeLockStateOfHouse, saveHouseLocked, houseIsReadOnly;
|
Boolean changeLockStateOfHouse, saveHouseLocked, houseIsReadOnly;
|
||||||
Boolean hasMovie, tvInRoom;
|
Boolean hasMovie, tvInRoom;
|
||||||
|
|
||||||
|
|
||||||
extern VFileSpec *theHousesSpecs;
|
extern VFileSpec *theHousesSpecs;
|
||||||
extern short thisHouseIndex, tvWithMovieNumber;
|
extern short thisHouseIndex, tvWithMovieNumber;
|
||||||
extern short numberRooms, housesFound;
|
extern short numberRooms, housesFound;
|
||||||
@@ -324,8 +327,28 @@ void ByteSwapRect(Rect *rect)
|
|||||||
PortabilityLayer::ByteSwap::BigInt16(rect->right);
|
PortabilityLayer::ByteSwap::BigInt16(rect->right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<size_t TSize>
|
||||||
|
void SanitizePascalStr(uint8_t(&chars)[TSize])
|
||||||
|
{
|
||||||
|
const size_t maxLength = TSize - 1;
|
||||||
|
size_t strLength = chars[0];
|
||||||
|
if (strLength > maxLength)
|
||||||
|
{
|
||||||
|
strLength = maxLength;
|
||||||
|
chars[0] = static_cast<uint8_t>(maxLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 1 + strLength; i < TSize; i++)
|
||||||
|
chars[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ByteSwapScores(scoresType *scores)
|
void ByteSwapScores(scoresType *scores)
|
||||||
{
|
{
|
||||||
|
SanitizePascalStr(scores->banner);
|
||||||
|
|
||||||
|
for (int i = 0; i < kMaxScores; i++)
|
||||||
|
SanitizePascalStr(scores->names[i]);
|
||||||
|
|
||||||
for (int i = 0; i < kMaxScores; i++)
|
for (int i = 0; i < kMaxScores; i++)
|
||||||
PortabilityLayer::ByteSwap::BigInt32(scores->scores[i]);
|
PortabilityLayer::ByteSwap::BigInt32(scores->scores[i]);
|
||||||
|
|
||||||
@@ -568,6 +591,8 @@ void ByteSwapObject(objectType *obj)
|
|||||||
|
|
||||||
void ByteSwapRoom(roomType *room)
|
void ByteSwapRoom(roomType *room)
|
||||||
{
|
{
|
||||||
|
SanitizePascalStr(room->name);
|
||||||
|
|
||||||
PortabilityLayer::ByteSwap::BigInt16(room->bounds);
|
PortabilityLayer::ByteSwap::BigInt16(room->bounds);
|
||||||
|
|
||||||
PortabilityLayer::ByteSwap::BigInt16(room->background);
|
PortabilityLayer::ByteSwap::BigInt16(room->background);
|
||||||
@@ -590,19 +615,23 @@ bool ByteSwapHouse(housePtr house, size_t sizeInBytes)
|
|||||||
PortabilityLayer::ByteSwap::BigInt32(house->timeStamp);
|
PortabilityLayer::ByteSwap::BigInt32(house->timeStamp);
|
||||||
PortabilityLayer::ByteSwap::BigInt32(house->flags);
|
PortabilityLayer::ByteSwap::BigInt32(house->flags);
|
||||||
ByteSwapPoint(&house->initial);
|
ByteSwapPoint(&house->initial);
|
||||||
|
SanitizePascalStr(house->banner);
|
||||||
|
SanitizePascalStr(house->trailer);
|
||||||
ByteSwapScores(&house->highScores);
|
ByteSwapScores(&house->highScores);
|
||||||
ByteSwapSavedGame(&house->savedGame);
|
ByteSwapSavedGame(&house->savedGame);
|
||||||
PortabilityLayer::ByteSwap::BigInt16(house->firstRoom);
|
PortabilityLayer::ByteSwap::BigInt16(house->firstRoom);
|
||||||
PortabilityLayer::ByteSwap::BigInt16(house->nRooms);
|
PortabilityLayer::ByteSwap::BigInt16(house->nRooms);
|
||||||
|
|
||||||
const size_t roomDataSize = sizeInBytes - houseType::kBinaryDataSize;
|
const size_t roomDataSize = sizeInBytes - houseType::kBinaryDataSize;
|
||||||
if (house->nRooms < 1 || roomDataSize / sizeof(roomType) < static_cast<size_t>(house->nRooms))
|
if (house->nRooms < 0 || roomDataSize / sizeof(roomType) < static_cast<size_t>(house->nRooms))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const size_t nRooms = static_cast<size_t>(house->nRooms);
|
const size_t nRooms = static_cast<size_t>(house->nRooms);
|
||||||
for (size_t i = 0; i < nRooms; i++)
|
for (size_t i = 0; i < nRooms; i++)
|
||||||
ByteSwapRoom(house->rooms + i);
|
ByteSwapRoom(house->rooms + i);
|
||||||
|
|
||||||
|
house->padding = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,8 +777,6 @@ Boolean WriteHouse (Boolean checkIt)
|
|||||||
UInt32 timeStamp;
|
UInt32 timeStamp;
|
||||||
long byteCount;
|
long byteCount;
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
|
|
||||||
if (!houseOpen)
|
if (!houseOpen)
|
||||||
{
|
{
|
||||||
@@ -772,9 +799,10 @@ Boolean WriteHouse (Boolean checkIt)
|
|||||||
|
|
||||||
if (fileDirty)
|
if (fileDirty)
|
||||||
{
|
{
|
||||||
GetDateTime(&timeStamp);
|
int64_t currentTime = PortabilityLayer::HostSystemServices::GetInstance()->GetTime();
|
||||||
timeStamp &= 0x7FFFFFFF;
|
if (currentTime > 0x7fffffff)
|
||||||
|
currentTime = 0x7fffffff;
|
||||||
|
|
||||||
if (changeLockStateOfHouse)
|
if (changeLockStateOfHouse)
|
||||||
houseUnlocked = !saveHouseLocked;
|
houseUnlocked = !saveHouseLocked;
|
||||||
|
|
||||||
@@ -869,13 +897,11 @@ Boolean CloseHouse (void)
|
|||||||
void OpenHouseResFork (void)
|
void OpenHouseResFork (void)
|
||||||
{
|
{
|
||||||
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
|
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
|
||||||
if (houseResFork == -1)
|
if (houseResFork == nullptr)
|
||||||
{
|
{
|
||||||
houseResFork = rm->OpenResFork(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name);
|
houseResFork = rm->LoadResFile(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name);
|
||||||
if (houseResFork < 0)
|
if (!houseResFork)
|
||||||
YellowAlert(kYellowFailedResOpen, PLErrors::kResourceError);
|
YellowAlert(kYellowFailedResOpen, PLErrors::kResourceError);
|
||||||
else
|
|
||||||
UseResFile(houseResFork);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -884,12 +910,12 @@ void OpenHouseResFork (void)
|
|||||||
|
|
||||||
void CloseHouseResFork (void)
|
void CloseHouseResFork (void)
|
||||||
{
|
{
|
||||||
if (houseResFork != -1)
|
if (houseResFork)
|
||||||
{
|
{
|
||||||
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
|
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
|
||||||
|
|
||||||
rm->CloseResFile(houseResFork);
|
houseResFork->Destroy();
|
||||||
houseResFork = -1;
|
houseResFork = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -965,3 +991,14 @@ Boolean IsFileReadOnly (const VFileSpec &spec)
|
|||||||
{
|
{
|
||||||
return PortabilityLayer::FileManager::GetInstance()->FileLocked(spec.m_dir, spec.m_name);
|
return PortabilityLayer::FileManager::GetInstance()->FileLocked(spec.m_dir, spec.m_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------- LoadHousePicture
|
||||||
|
|
||||||
|
THandle<void> LoadHouseResource(const PortabilityLayer::ResTypeID &resTypeID, int16_t resID)
|
||||||
|
{
|
||||||
|
THandle<void> hdl = houseResFork->LoadResource(resTypeID, resID);
|
||||||
|
if (hdl != nullptr)
|
||||||
|
return hdl;
|
||||||
|
|
||||||
|
return PortabilityLayer::ResourceManager::GetInstance()->GetAppResource(resTypeID, resID);
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ extern long incrementModeTime;
|
|||||||
extern UInt32 doubleTime;
|
extern UInt32 doubleTime;
|
||||||
extern short fadeInSequence[], idleMode;
|
extern short fadeInSequence[], idleMode;
|
||||||
extern short toolSelected, lastBackground, wasFlower, numExtraHouses;
|
extern short toolSelected, lastBackground, wasFlower, numExtraHouses;
|
||||||
extern short houseResFork, lastHighScore, maxFiles, willMaxFiles;
|
extern short lastHighScore, maxFiles, willMaxFiles;
|
||||||
extern Boolean quitting, playing, fadeGraysOut;
|
extern Boolean quitting, playing, fadeGraysOut;
|
||||||
extern Boolean houseOpen, newRoomNow, evenFrame, menusUp, demoGoing;
|
extern Boolean houseOpen, newRoomNow, evenFrame, menusUp, demoGoing;
|
||||||
extern Boolean twoPlayerGame, paused, hasMirror, splashDrawn;
|
extern Boolean twoPlayerGame, paused, hasMirror, splashDrawn;
|
||||||
@@ -151,7 +151,6 @@ void VariableInit (void)
|
|||||||
thisRoomNumber = 0;
|
thisRoomNumber = 0;
|
||||||
previousRoom = -1;
|
previousRoom = -1;
|
||||||
toolSelected = kSelectTool;
|
toolSelected = kSelectTool;
|
||||||
houseResFork = -1;
|
|
||||||
lastBackground = kBaseBackgroundID;
|
lastBackground = kBaseBackgroundID;
|
||||||
wasFlower = RandomInt(kNumFlowers);
|
wasFlower = RandomInt(kNumFlowers);
|
||||||
lastHighScore = -1;
|
lastHighScore = -1;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
#include "PLButtonWidget.h"
|
#include "PLButtonWidget.h"
|
||||||
#include "PLWidgets.h"
|
#include "PLWidgets.h"
|
||||||
|
#include "WindowDef.h"
|
||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
|
|
||||||
#define kLinkControlID 130
|
#define kLinkControlID 130
|
||||||
@@ -220,13 +221,15 @@ void OpenLinkWindow (void)
|
|||||||
|
|
||||||
if (linkWindow == nil)
|
if (linkWindow == nil)
|
||||||
{
|
{
|
||||||
|
const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar;
|
||||||
|
|
||||||
QSetRect(&linkWindowRect, 0, 0, 129, 30);
|
QSetRect(&linkWindowRect, 0, 0, 129, 30);
|
||||||
if (thisMac.hasColor)
|
if (thisMac.hasColor)
|
||||||
linkWindow = NewCWindow(nil, &linkWindowRect,
|
linkWindow = NewCWindow(nil, &linkWindowRect,
|
||||||
PSTR("Link"), false, kWindoidWDEF, kPutInFront, true, 0L);
|
PSTR("Link"), false, windowStyle, kPutInFront, true, 0L);
|
||||||
else
|
else
|
||||||
linkWindow = NewWindow(nil, &linkWindowRect,
|
linkWindow = NewWindow(nil, &linkWindowRect,
|
||||||
PSTR("Link"), false, kWindoidWDEF, kPutInFront, true, 0L);
|
PSTR("Link"), false, windowStyle, kPutInFront, true, 0L);
|
||||||
|
|
||||||
MoveWindow(linkWindow, isLinkH, isLinkV, true);
|
MoveWindow(linkWindow, isLinkH, isLinkV, true);
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void OpenMainWindow (void)
|
|||||||
Rect scorebarRect = thisMac.screen;
|
Rect scorebarRect = thisMac.screen;
|
||||||
scorebarRect.bottom = scorebarRect.top + kScoreboardTall;
|
scorebarRect.bottom = scorebarRect.top + kScoreboardTall;
|
||||||
|
|
||||||
PortabilityLayer::WindowDef windowDef = PortabilityLayer::WindowDef::Create(scorebarRect, 0, true, false, 0, 0, PSTR("Scoreboard"));
|
PortabilityLayer::WindowDef windowDef = PortabilityLayer::WindowDef::Create(scorebarRect, PortabilityLayer::WindowStyleFlags::kBorderless, true, false, 0, 0, PSTR("Scoreboard"));
|
||||||
boardWindow = windowManager->CreateWindow(windowDef);
|
boardWindow = windowManager->CreateWindow(windowDef);
|
||||||
if (boardWindow != nil)
|
if (boardWindow != nil)
|
||||||
windowManager->PutWindowBehind(boardWindow, PL_GetPutInFrontWindowPtr());
|
windowManager->PutWindowBehind(boardWindow, PL_GetPutInFrontWindowPtr());
|
||||||
|
|||||||
@@ -167,10 +167,10 @@ void LoadGraphicPlus (DrawSurface *surface, short resID, const Rect &theRect)
|
|||||||
{
|
{
|
||||||
THandle<BitmapImage> thePicture;
|
THandle<BitmapImage> thePicture;
|
||||||
|
|
||||||
thePicture = GetPicture(resID);
|
thePicture = LoadHouseResource('PICT', resID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
{
|
{
|
||||||
thePicture = GetResource('Date', resID).StaticCast<BitmapImage>();
|
thePicture = LoadHouseResource('Date', resID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -361,7 +361,9 @@ void OpenMapWindow (void)
|
|||||||
mapRoomsWide * kMapRoomWidth + kMapScrollBarWidth - 2,
|
mapRoomsWide * kMapRoomWidth + kMapScrollBarWidth - 2,
|
||||||
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth - 2);
|
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth - 2);
|
||||||
|
|
||||||
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mapWindowRect, kWindoidGrowWDEF, false, true, 0, 0, PSTR("Map"));
|
const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kResizable | PortabilityLayer::WindowStyleFlags::kMiniBar;
|
||||||
|
|
||||||
|
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mapWindowRect, windowStyle, false, true, 0, 0, PSTR("Map"));
|
||||||
|
|
||||||
mapWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(wdef);
|
mapWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(wdef);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "HostMutex.h"
|
#include "HostMutex.h"
|
||||||
#include "HostSystemServices.h"
|
#include "HostSystemServices.h"
|
||||||
#include "MemoryManager.h"
|
#include "MemoryManager.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
|
|
||||||
#define kBaseBufferMusicID 2000
|
#define kBaseBufferMusicID 2000
|
||||||
@@ -212,7 +213,7 @@ PLError_t LoadMusicSounds (void)
|
|||||||
|
|
||||||
for (i = 0; i < kMaxMusic; i++)
|
for (i = 0; i < kMaxMusic; i++)
|
||||||
{
|
{
|
||||||
theSound = ParseAndConvertSound(GetResource('snd ', i + kBaseBufferMusicID));
|
theSound = ParseAndConvertSound(PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('snd ', i + kBaseBufferMusicID));
|
||||||
if (theSound == nil)
|
if (theSound == nil)
|
||||||
return PLErrors::kOutOfMemory;
|
return PLErrors::kOutOfMemory;
|
||||||
|
|
||||||
@@ -364,24 +365,18 @@ void KillMusic (void)
|
|||||||
|
|
||||||
long MusicBytesNeeded (void)
|
long MusicBytesNeeded (void)
|
||||||
{
|
{
|
||||||
Handle theSound;
|
size_t totalBytes;
|
||||||
long totalBytes;
|
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
totalBytes = 0L;
|
totalBytes = 0L;
|
||||||
SetResLoad(false);
|
|
||||||
for (i = 0; i < kMaxMusic; i++)
|
for (i = 0; i < kMaxMusic; i++)
|
||||||
{
|
{
|
||||||
theSound = GetResource('snd ', i + kBaseBufferMusicID);
|
size_t resSize = 0;
|
||||||
if (theSound == nil)
|
if (!PortabilityLayer::ResourceManager::GetInstance()->GetAppResourceArchive()->GetResourceSize('snd ', i + kBaseBufferMusicID, resSize))
|
||||||
{
|
|
||||||
SetResLoad(true);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
totalBytes += GetMaxResourceSize(theSound);
|
totalBytes += static_cast<long>(resSize);
|
||||||
// ReleaseResource(theSound);
|
|
||||||
}
|
}
|
||||||
SetResLoad(true);
|
|
||||||
return totalBytes;
|
return totalBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "Objects.h"
|
#include "Objects.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
#include "Room.h"
|
#include "Room.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "PLHacks.h"
|
#include "PLHacks.h"
|
||||||
@@ -1052,7 +1053,7 @@ void DrawCalendar (Rect *theRect)
|
|||||||
wasCPort = GetGraphicsPort();
|
wasCPort = GetGraphicsPort();
|
||||||
SetGraphicsPort(backSrcMap);
|
SetGraphicsPort(backSrcMap);
|
||||||
|
|
||||||
thePicture = GetPicture(kCalendarPictID);
|
thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kCalendarPictID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
RedAlert(kErrFailedGraphicLoad);
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
|
|
||||||
@@ -1078,7 +1079,7 @@ void DrawBulletin (Rect *theRect)
|
|||||||
Rect bounds;
|
Rect bounds;
|
||||||
THandle<BitmapImage> thePicture;
|
THandle<BitmapImage> thePicture;
|
||||||
|
|
||||||
thePicture = GetPicture(kBulletinPictID);
|
thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kBulletinPictID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
RedAlert(kErrFailedGraphicLoad);
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
|
|
||||||
@@ -1128,7 +1129,7 @@ void DrawPictObject (short what, Rect *theRect)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
thePicture = GetPicture(pictID);
|
thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', pictID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
RedAlert(kErrFailedGraphicLoad);
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
|
|
||||||
@@ -1295,7 +1296,7 @@ void DrawCustPictSansWhite (short pictID, Rect *theRect)
|
|||||||
bounds = *theRect;
|
bounds = *theRect;
|
||||||
ZeroRectCorner(&bounds);
|
ZeroRectCorner(&bounds);
|
||||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat);
|
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat);
|
||||||
LoadGraphic(tempMap, pictID);
|
LoadGraphicCustom(tempMap, pictID);
|
||||||
|
|
||||||
CopyBits((BitMap *)*GetGWorldPixMap(tempMap),
|
CopyBits((BitMap *)*GetGWorldPixMap(tempMap),
|
||||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "Objects.h"
|
#include "Objects.h"
|
||||||
#include "Play.h"
|
#include "Play.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
#include "Room.h"
|
#include "Room.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -2237,7 +2238,7 @@ void GetThisRoomsObjRects (void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kCustomPict:
|
case kCustomPict:
|
||||||
thePict = GetPicture(thisRoom->objects[i].data.g.height);
|
thePict = LoadHouseResource('PICT', thisRoom->objects[i].data.g.height).StaticCast<BitmapImage>();
|
||||||
if (thePict == nil)
|
if (thePict == nil)
|
||||||
{
|
{
|
||||||
thisRoom->objects[i].data.g.height = 10000;
|
thisRoom->objects[i].data.g.height = 10000;
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ void GetObjectRect (objectPtr who, Rect *itsRect)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kCustomPict:
|
case kCustomPict:
|
||||||
thePict = GetPicture(who->data.g.height);
|
thePict = LoadHouseResource('PICT', who->data.g.height).StaticCast<BitmapImage>();
|
||||||
if (thePict == nil)
|
if (thePict == nil)
|
||||||
{
|
{
|
||||||
who->data.g.height = 10000;
|
who->data.g.height = 10000;
|
||||||
|
|||||||
@@ -261,10 +261,10 @@ void ReadyBackground (short theID, short *theTiles)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
thePicture = GetPicture(theID);
|
thePicture = LoadHouseResource('PICT', theID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
{
|
{
|
||||||
thePicture = GetResource('Date', theID).StaticCast<BitmapImage>();
|
thePicture = LoadHouseResource('Date', theID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
{
|
{
|
||||||
YellowAlert(kYellowNoBackground, 0);
|
YellowAlert(kYellowNoBackground, 0);
|
||||||
@@ -907,7 +907,10 @@ short GetOriginalBounding (short theID)
|
|||||||
boundsHand boundsRes;
|
boundsHand boundsRes;
|
||||||
short boundCode;
|
short boundCode;
|
||||||
|
|
||||||
boundsRes = GetResource('bnds', theID).StaticCast<boundsType>();
|
boundsRes = LoadHouseResource('bnds', theID).StaticCast<boundsType>();
|
||||||
|
if (boundsRes.MMBlock()->m_size != sizeof(boundsType))
|
||||||
|
return 0; // Corrupted resource
|
||||||
|
|
||||||
if (boundsRes == nil)
|
if (boundsRes == nil)
|
||||||
{
|
{
|
||||||
if (PictIDExists(theID))
|
if (PictIDExists(theID))
|
||||||
|
|||||||
@@ -134,13 +134,13 @@ void LoadGraphicSpecial (DrawSurface *surface, short resID)
|
|||||||
Rect bounds;
|
Rect bounds;
|
||||||
THandle<BitmapImage> thePicture;
|
THandle<BitmapImage> thePicture;
|
||||||
|
|
||||||
thePicture = GetPicture(resID);
|
thePicture = LoadHouseResource('PICT', resID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
{
|
{
|
||||||
thePicture = GetResource('Date', resID).StaticCast<BitmapImage>();
|
thePicture = LoadHouseResource('Date', resID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
{
|
{
|
||||||
thePicture = GetPicture(2000);
|
thePicture = LoadHouseResource('PICT', 2000).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
RedAlert(kErrFailedGraphicLoad);
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ Boolean originalLeftOpen, originalTopOpen, originalRightOpen, originalBottomOpe
|
|||||||
Boolean originalFloor;
|
Boolean originalFloor;
|
||||||
|
|
||||||
extern Cursor handCursor;
|
extern Cursor handCursor;
|
||||||
extern short houseResFork, lastBackground;
|
extern short lastBackground;
|
||||||
|
|
||||||
|
|
||||||
//============================================================== Functions
|
//============================================================== Functions
|
||||||
@@ -459,9 +459,9 @@ void DoRoomInfo (void)
|
|||||||
}
|
}
|
||||||
if ((tempBack == 2002) || (tempBack == 2011) ||
|
if ((tempBack == 2002) || (tempBack == 2011) ||
|
||||||
(tempBack == 2016) || (tempBack == 2017))
|
(tempBack == 2016) || (tempBack == 2017))
|
||||||
LoadScaledGraphic(tileSrcMap, tempBack - 800, &tileSrcRect);
|
LoadScaledGraphicCustom(tileSrcMap, tempBack - 800, &tileSrcRect);
|
||||||
else
|
else
|
||||||
LoadScaledGraphic(tileSrcMap, tempBack, &tileSrcRect);
|
LoadScaledGraphicCustom(tileSrcMap, tempBack, &tileSrcRect);
|
||||||
|
|
||||||
for (i = 0; i < kNumTiles; i++)
|
for (i = 0; i < kNumTiles; i++)
|
||||||
tempTiles[i] = thisRoom->tiles[i];
|
tempTiles[i] = thisRoom->tiles[i];
|
||||||
@@ -547,7 +547,7 @@ void DoRoomInfo (void)
|
|||||||
if ((tempBack != newBack) || (forceDraw))
|
if ((tempBack != newBack) || (forceDraw))
|
||||||
{
|
{
|
||||||
tempBack = newBack;
|
tempBack = newBack;
|
||||||
LoadScaledGraphic(tileSrcMap, tempBack, &tileSrcRect);
|
LoadScaledGraphicCustom(tileSrcMap, tempBack, &tileSrcRect);
|
||||||
InvalWindowRect(roomInfoDialog->GetWindow(), &tileSrc);
|
InvalWindowRect(roomInfoDialog->GetWindow(), &tileSrc);
|
||||||
InvalWindowRect(roomInfoDialog->GetWindow(), &tileDest);
|
InvalWindowRect(roomInfoDialog->GetWindow(), &tileDest);
|
||||||
}
|
}
|
||||||
@@ -573,9 +573,9 @@ void DoRoomInfo (void)
|
|||||||
tempBack = newBack;
|
tempBack = newBack;
|
||||||
if ((tempBack == 2002) || (tempBack == 2011) ||
|
if ((tempBack == 2002) || (tempBack == 2011) ||
|
||||||
(tempBack == 2016) || (tempBack == 2017))
|
(tempBack == 2016) || (tempBack == 2017))
|
||||||
LoadScaledGraphic(tileSrcMap, tempBack - 800, &tileSrcRect);
|
LoadScaledGraphicCustom(tileSrcMap, tempBack - 800, &tileSrcRect);
|
||||||
else
|
else
|
||||||
LoadScaledGraphic(tileSrcMap, tempBack, &tileSrcRect);
|
LoadScaledGraphicCustom(tileSrcMap, tempBack, &tileSrcRect);
|
||||||
InvalWindowRect(roomInfoDialog->GetWindow(), &tileSrc);
|
InvalWindowRect(roomInfoDialog->GetWindow(), &tileSrc);
|
||||||
InvalWindowRect(roomInfoDialog->GetWindow(), &tileDest);
|
InvalWindowRect(roomInfoDialog->GetWindow(), &tileDest);
|
||||||
}
|
}
|
||||||
@@ -586,7 +586,7 @@ void DoRoomInfo (void)
|
|||||||
if (tempBack != newBack)
|
if (tempBack != newBack)
|
||||||
{
|
{
|
||||||
tempBack = newBack;
|
tempBack = newBack;
|
||||||
LoadScaledGraphic(tileSrcMap, tempBack, &tileSrcRect);
|
LoadScaledGraphicCustom(tileSrcMap, tempBack, &tileSrcRect);
|
||||||
InvalWindowRect(roomInfoDialog->GetWindow(), &tileSrc);
|
InvalWindowRect(roomInfoDialog->GetWindow(), &tileSrc);
|
||||||
InvalWindowRect(roomInfoDialog->GetWindow(), &tileDest);
|
InvalWindowRect(roomInfoDialog->GetWindow(), &tileDest);
|
||||||
}
|
}
|
||||||
@@ -857,7 +857,7 @@ short ChooseOriginalArt (short was)
|
|||||||
|
|
||||||
Boolean PictIDExists (short theID)
|
Boolean PictIDExists (short theID)
|
||||||
{
|
{
|
||||||
THandle<BitmapImage> thePicture;
|
THandle<void> thePicture;
|
||||||
// Handle resHandle;
|
// Handle resHandle;
|
||||||
// Str255 resName;
|
// Str255 resName;
|
||||||
// ResType resType;
|
// ResType resType;
|
||||||
@@ -867,10 +867,10 @@ Boolean PictIDExists (short theID)
|
|||||||
|
|
||||||
foundIt = true;
|
foundIt = true;
|
||||||
|
|
||||||
thePicture = GetPicture(theID);
|
thePicture = LoadHouseResource('PICT', theID);
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
{
|
{
|
||||||
thePicture = GetResource('Date', theID).StaticCast<BitmapImage>();
|
thePicture = LoadHouseResource('Date', theID);
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
{
|
{
|
||||||
foundIt = false;
|
foundIt = false;
|
||||||
@@ -907,8 +907,11 @@ short GetFirstPICT (void)
|
|||||||
{
|
{
|
||||||
Handle resHandle;
|
Handle resHandle;
|
||||||
Str255 resName;
|
Str255 resName;
|
||||||
|
|
||||||
resHandle = Get1IndResource('PICT', 1);
|
PL_NotYetImplemented();
|
||||||
|
|
||||||
|
//resHandle = Get1IndResource('PICT', 1);
|
||||||
|
resHandle = Handle();
|
||||||
if (resHandle != nil)
|
if (resHandle != nil)
|
||||||
{
|
{
|
||||||
const PortabilityLayer::ResourceArchiveRef *resRef = PortabilityLayer::ResourceManager::GetInstance()->ResourceForHandle(resHandle.MMBlock());
|
const PortabilityLayer::ResourceArchiveRef *resRef = PortabilityLayer::ResourceManager::GetInstance()->ResourceForHandle(resHandle.MMBlock());
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "PLSound.h"
|
#include "PLSound.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "MemoryManager.h"
|
#include "MemoryManager.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
#include "SoundSync.h"
|
#include "SoundSync.h"
|
||||||
#include "VirtualDirectory.h"
|
#include "VirtualDirectory.h"
|
||||||
#include "WaveFormat.h"
|
#include "WaveFormat.h"
|
||||||
@@ -187,7 +188,7 @@ PLError_t LoadTriggerSound (short soundID)
|
|||||||
|
|
||||||
theErr = PLErrors::kNone;
|
theErr = PLErrors::kNone;
|
||||||
|
|
||||||
theSound = ParseAndConvertSound(GetResource('snd ', soundID));
|
theSound = ParseAndConvertSound(LoadHouseResource('snd ', soundID));
|
||||||
if (theSound == nil)
|
if (theSound == nil)
|
||||||
{
|
{
|
||||||
theErr = PLErrors::kFileNotFound;
|
theErr = PLErrors::kFileNotFound;
|
||||||
@@ -234,7 +235,7 @@ PLError_t LoadBufferSounds (void)
|
|||||||
|
|
||||||
for (i = 0; i < kMaxSounds - 1; i++)
|
for (i = 0; i < kMaxSounds - 1; i++)
|
||||||
{
|
{
|
||||||
theSound = ParseAndConvertSound(GetResource('snd ', i + kBaseBufferSoundID));
|
theSound = ParseAndConvertSound(PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('snd ', i + kBaseBufferSoundID));
|
||||||
if (theSound == nil)
|
if (theSound == nil)
|
||||||
return (PLErrors::kOutOfMemory);
|
return (PLErrors::kOutOfMemory);
|
||||||
|
|
||||||
@@ -369,24 +370,20 @@ void KillSound (void)
|
|||||||
|
|
||||||
long SoundBytesNeeded (void)
|
long SoundBytesNeeded (void)
|
||||||
{
|
{
|
||||||
Handle theSound;
|
|
||||||
long totalBytes;
|
long totalBytes;
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
totalBytes = 0L;
|
totalBytes = 0L;
|
||||||
SetResLoad(false);
|
|
||||||
for (i = 0; i < kMaxSounds - 1; i++)
|
for (i = 0; i < kMaxSounds - 1; i++)
|
||||||
{
|
{
|
||||||
theSound = GetResource('snd ', i + kBaseBufferSoundID);
|
size_t resSize = 0;
|
||||||
if (theSound == nil)
|
if (!PortabilityLayer::ResourceManager::GetInstance()->GetAppResourceArchive()->GetResourceSize('snd ', i + kBaseBufferSoundID, resSize))
|
||||||
{
|
|
||||||
SetResLoad(true);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
totalBytes += GetMaxResourceSize(theSound);
|
totalBytes += static_cast<long>(resSize);
|
||||||
// ReleaseResource(theSound);
|
// ReleaseResource(theSound);
|
||||||
}
|
}
|
||||||
SetResLoad(true);
|
|
||||||
return totalBytes;
|
return totalBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Play.h"
|
#include "Play.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
#include "RubberBands.h"
|
#include "RubberBands.h"
|
||||||
#include "Scoreboard.h"
|
#include "Scoreboard.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
@@ -77,7 +78,7 @@ void InitScoreboardMap (void)
|
|||||||
hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2;
|
hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2;
|
||||||
else
|
else
|
||||||
hOffset = -576;
|
hOffset = -576;
|
||||||
thePicture = GetPicture(kScoreboardPictID);
|
thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kScoreboardPictID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
RedAlert(kErrFailedGraphicLoad);
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
bounds = (*thePicture)->GetRect();
|
bounds = (*thePicture)->GetRect();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Objects.h"
|
#include "Objects.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
#include "Room.h"
|
#include "Room.h"
|
||||||
#include "RoomGraphics.h"
|
#include "RoomGraphics.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
@@ -260,7 +261,7 @@ void CreatePointers (void)
|
|||||||
demoData = (demoPtr)NewPtr(kDemoLength);
|
demoData = (demoPtr)NewPtr(kDemoLength);
|
||||||
if (demoData == nil)
|
if (demoData == nil)
|
||||||
RedAlert(kErrNoMemory);
|
RedAlert(kErrNoMemory);
|
||||||
tempHandle = GetResource('demo', 128);
|
tempHandle = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('demo', 128);
|
||||||
if (tempHandle == nil)
|
if (tempHandle == nil)
|
||||||
RedAlert(kErrNoMemory);
|
RedAlert(kErrNoMemory);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -300,7 +300,9 @@ void OpenToolsWindow (void)
|
|||||||
QOffsetRect(&toolTextRect, 0, 157 - 15);
|
QOffsetRect(&toolTextRect, 0, 157 - 15);
|
||||||
|
|
||||||
{
|
{
|
||||||
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(toolsWindowRect, kWindoidWDEF, false, true, 0, 0, PSTR("Tools"));
|
const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar;
|
||||||
|
|
||||||
|
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(toolsWindowRect, windowStyle, false, true, 0, 0, PSTR("Tools"));
|
||||||
toolsWindow = wm->CreateWindow(wdef);
|
toolsWindow = wm->CreateWindow(wdef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,6 @@ PLError_t CreateOffScreenGWorld (DrawSurface **theGWorld, Rect *bounds, GpPixelF
|
|||||||
return theErr;
|
return theErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------- KillOffScreenPixMap
|
//-------------------------------------------------------------- KillOffScreenPixMap
|
||||||
// Destroys memory allocated by an offscreen pix map.
|
// Destroys memory allocated by an offscreen pix map.
|
||||||
/*
|
/*
|
||||||
@@ -255,7 +254,7 @@ void LoadGraphic (DrawSurface *surface, short resID)
|
|||||||
Rect bounds;
|
Rect bounds;
|
||||||
THandle<BitmapImage> thePicture;
|
THandle<BitmapImage> thePicture;
|
||||||
|
|
||||||
thePicture = GetPicture(resID);
|
thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', resID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
RedAlert(kErrFailedGraphicLoad);
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
|
|
||||||
@@ -266,6 +265,24 @@ void LoadGraphic (DrawSurface *surface, short resID)
|
|||||||
thePicture.Dispose();
|
thePicture.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------- LoadGraphicCustom
|
||||||
|
// Same as LoadGraphic but supports custom graphics
|
||||||
|
void LoadGraphicCustom(DrawSurface *surface, short resID)
|
||||||
|
{
|
||||||
|
Rect bounds;
|
||||||
|
THandle<BitmapImage> thePicture;
|
||||||
|
|
||||||
|
thePicture = LoadHouseResource('PICT', resID).StaticCast<BitmapImage>();
|
||||||
|
if (thePicture == nil)
|
||||||
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
|
|
||||||
|
bounds = (*thePicture)->GetRect();
|
||||||
|
OffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||||
|
surface->DrawPicture(thePicture, bounds);
|
||||||
|
|
||||||
|
thePicture.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- LoadScaledGraphic
|
//-------------------------------------------------------------- LoadScaledGraphic
|
||||||
// Loads the specified 'PICT' and draws it mapped to the rectangleÉ
|
// Loads the specified 'PICT' and draws it mapped to the rectangleÉ
|
||||||
// specified. If this rect isn't the same size of the 'PICT', scalingÉ
|
// specified. If this rect isn't the same size of the 'PICT', scalingÉ
|
||||||
@@ -275,7 +292,23 @@ void LoadScaledGraphic (DrawSurface *surface, short resID, Rect *theRect)
|
|||||||
{
|
{
|
||||||
THandle<BitmapImage> thePicture;
|
THandle<BitmapImage> thePicture;
|
||||||
|
|
||||||
thePicture = GetPicture(resID);
|
thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', resID).StaticCast<BitmapImage>();
|
||||||
|
if (thePicture == nil)
|
||||||
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
|
surface->DrawPicture(thePicture, *theRect);
|
||||||
|
thePicture.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------- LoadScaledGraphic
|
||||||
|
// Loads the specified 'PICT' and draws it mapped to the rectangleÉ
|
||||||
|
// specified. If this rect isn't the same size of the 'PICT', scalingÉ
|
||||||
|
// will occur.
|
||||||
|
|
||||||
|
void LoadScaledGraphicCustom(DrawSurface *surface, short resID, Rect *theRect)
|
||||||
|
{
|
||||||
|
THandle<BitmapImage> thePicture;
|
||||||
|
|
||||||
|
thePicture = LoadHouseResource('PICT', resID).StaticCast<BitmapImage>();
|
||||||
if (thePicture == nil)
|
if (thePicture == nil)
|
||||||
RedAlert(kErrFailedGraphicLoad);
|
RedAlert(kErrFailedGraphicLoad);
|
||||||
surface->DrawPicture(thePicture, *theRect);
|
surface->DrawPicture(thePicture, *theRect);
|
||||||
@@ -287,7 +320,7 @@ void LoadScaledGraphic (DrawSurface *surface, short resID, Rect *theRect)
|
|||||||
|
|
||||||
bool LargeIconPlot (DrawSurface *surface, PortabilityLayer::ResourceArchive *resFile, short resID, const Rect &theRect)
|
bool LargeIconPlot (DrawSurface *surface, PortabilityLayer::ResourceArchive *resFile, short resID, const Rect &theRect)
|
||||||
{
|
{
|
||||||
Handle hdl = resFile->GetResource('icl8', resID, true);
|
Handle hdl = resFile->LoadResource('icl8', resID);
|
||||||
if (hdl)
|
if (hdl)
|
||||||
{
|
{
|
||||||
THandle<PortabilityLayer::PixMapImpl> img = PortabilityLayer::IconLoader::GetInstance()->LoadSimpleColorIcon(hdl);
|
THandle<PortabilityLayer::PixMapImpl> img = PortabilityLayer::IconLoader::GetInstance()->LoadSimpleColorIcon(hdl);
|
||||||
@@ -302,7 +335,7 @@ bool LargeIconPlot (DrawSurface *surface, PortabilityLayer::ResourceArchive *res
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
hdl = resFile->GetResource('ICN#', resID, true);
|
hdl = resFile->LoadResource('ICN#', resID);
|
||||||
if (hdl)
|
if (hdl)
|
||||||
{
|
{
|
||||||
THandle<PortabilityLayer::PixMapImpl> img = PortabilityLayer::IconLoader::GetInstance()->LoadBWIcon(hdl);
|
THandle<PortabilityLayer::PixMapImpl> img = PortabilityLayer::IconLoader::GetInstance()->LoadBWIcon(hdl);
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "PLStandardColors.h"
|
#include "PLStandardColors.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
#include "WindowDef.h"
|
||||||
|
#include "WindowManager.h"
|
||||||
|
|
||||||
#define kFloatingKind 2048
|
#define kFloatingKind 2048
|
||||||
#define kMessageWindowTall 48
|
#define kMessageWindowTall 48
|
||||||
@@ -101,16 +102,16 @@ Boolean IsWindowFloating (WindowPtr theWindow)
|
|||||||
|
|
||||||
void OpenMessageWindow (const PLPasStr &title)
|
void OpenMessageWindow (const PLPasStr &title)
|
||||||
{
|
{
|
||||||
|
const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar;
|
||||||
|
|
||||||
Rect mssgWindowRect;
|
Rect mssgWindowRect;
|
||||||
|
|
||||||
SetRect(&mssgWindowRect, 0, 0, 256, kMessageWindowTall);
|
SetRect(&mssgWindowRect, 0, 0, 256, kMessageWindowTall);
|
||||||
if (thisMac.hasColor)
|
|
||||||
mssgWindow = NewCWindow(nil, &mssgWindowRect,
|
const PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mssgWindowRect, windowStyle, false, false, 0, 0, title);
|
||||||
title, false, noGrowDocProc, kPutInFront, false, 0L);
|
|
||||||
else
|
mssgWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(wdef);
|
||||||
mssgWindow = NewWindow(nil, &mssgWindowRect,
|
|
||||||
title, false, noGrowDocProc, kPutInFront, false, 0L);
|
|
||||||
|
|
||||||
if (mssgWindow != nil)
|
if (mssgWindow != nil)
|
||||||
{
|
{
|
||||||
ShowWindow(mssgWindow);
|
ShowWindow(mssgWindow);
|
||||||
@@ -155,9 +156,7 @@ void SetMessageWindowMessage (StringPtr message)
|
|||||||
|
|
||||||
void CloseMessageWindow (void)
|
void CloseMessageWindow (void)
|
||||||
{
|
{
|
||||||
if (mssgWindow != nil)
|
CloseThisWindow(&mssgWindow);
|
||||||
DisposeWindow(mssgWindow);
|
|
||||||
mssgWindow = nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- CloseThisWindow
|
//-------------------------------------------------------------- CloseThisWindow
|
||||||
@@ -168,7 +167,7 @@ void CloseMessageWindow (void)
|
|||||||
void CloseThisWindow (WindowPtr *theWindow)
|
void CloseThisWindow (WindowPtr *theWindow)
|
||||||
{
|
{
|
||||||
if (*theWindow != nil)
|
if (*theWindow != nil)
|
||||||
DisposeWindow(*theWindow);
|
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(*theWindow);
|
||||||
*theWindow = nil;
|
*theWindow = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
ResourceManager *rm = ResourceManager::GetInstance();
|
ResourceManager *rm = ResourceManager::GetInstance();
|
||||||
|
|
||||||
THandle<uint8_t> dlogH = rm->GetResource('DLOG', resID).StaticCast<uint8_t>();
|
THandle<uint8_t> dlogH = rm->GetAppResource('DLOG', resID).StaticCast<uint8_t>();
|
||||||
const uint8_t *dlogData = *dlogH;
|
const uint8_t *dlogData = *dlogH;
|
||||||
const uint8_t *dlogDataEnd = dlogData + dlogH.MMBlock()->m_size;
|
const uint8_t *dlogDataEnd = dlogData + dlogH.MMBlock()->m_size;
|
||||||
|
|
||||||
@@ -434,7 +434,7 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||||
|
|
||||||
WindowDef wdef = WindowDef::Create(rect, 0, header.m_visible != 0, header.m_hasCloseBox != 0, header.m_referenceConstant, positionSpec, PLPasStr(titlePStr));
|
WindowDef wdef = WindowDef::Create(rect, WindowStyleFlags::kAlert, header.m_visible != 0, header.m_hasCloseBox != 0, header.m_referenceConstant, positionSpec, PLPasStr(titlePStr));
|
||||||
Window *window = wm->CreateWindow(wdef);
|
Window *window = wm->CreateWindow(wdef);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
@@ -499,7 +499,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
ResourceManager *rm = ResourceManager::GetInstance();
|
ResourceManager *rm = ResourceManager::GetInstance();
|
||||||
|
|
||||||
THandle<uint8_t> dtemplateH = rm->GetResource('DITL', resID).StaticCast<uint8_t>();
|
THandle<uint8_t> dtemplateH = rm->GetAppResource('DITL', resID).StaticCast<uint8_t>();
|
||||||
|
|
||||||
if (!dtemplateH)
|
if (!dtemplateH)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
bool IconLoaderImpl::LoadColorIcon(const int16_t id, THandle<PixMapImpl> &outColorImage, THandle<PixMapImpl> &outBWImage, THandle<PixMapImpl> &outMaskImage)
|
bool IconLoaderImpl::LoadColorIcon(const int16_t id, THandle<PixMapImpl> &outColorImage, THandle<PixMapImpl> &outBWImage, THandle<PixMapImpl> &outMaskImage)
|
||||||
{
|
{
|
||||||
THandle<const uint8_t> data = PortabilityLayer::ResourceManager::GetInstance()->GetResource('cicn', id).StaticCast<const uint8_t>();
|
THandle<const uint8_t> data = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('cicn', id).StaticCast<const uint8_t>();
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -595,8 +595,8 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
ResourceManager *resManager = ResourceManager::GetInstance();
|
ResourceManager *resManager = ResourceManager::GetInstance();
|
||||||
|
|
||||||
Handle icsHandle = GetResource('ics#', kIconResID);
|
Handle icsHandle = resManager->GetAppResource('ics#', kIconResID);
|
||||||
Handle ics8Handle = GetResource('ics8', kIconResID);
|
Handle ics8Handle = resManager->GetAppResource('ics8', kIconResID);
|
||||||
|
|
||||||
if (icsHandle && ics8Handle)
|
if (icsHandle && ics8Handle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ Rect BERect::ToRect() const
|
|||||||
|
|
||||||
CursHandle GetCursor(int cursorID)
|
CursHandle GetCursor(int cursorID)
|
||||||
{
|
{
|
||||||
return GetResource('CURS', cursorID).ReinterpretCast<Cursor>();
|
return PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('CURS', cursorID).ReinterpretCast<Cursor>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HideCursor()
|
void HideCursor()
|
||||||
@@ -119,17 +119,6 @@ short Alert(int dialogID, void *unknown)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle GetResource(int32_t resType, int id)
|
|
||||||
{
|
|
||||||
return PortabilityLayer::ResourceManager::GetInstance()->GetResource(PortabilityLayer::ResTypeID(resType), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle GetResource(const char(&resTypeLiteral)[5], int id)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
short FindWindow(Point point, WindowPtr *window)
|
short FindWindow(Point point, WindowPtr *window)
|
||||||
{
|
{
|
||||||
short part = 0;
|
short part = 0;
|
||||||
@@ -198,7 +187,7 @@ void GetWindowBounds(WindowPtr window, WindowRegionType windowRegion, Rect *rect
|
|||||||
|
|
||||||
WindowPtr GetNewCWindow(int resID, void *storage, WindowPtr behind)
|
WindowPtr GetNewCWindow(int resID, void *storage, WindowPtr behind)
|
||||||
{
|
{
|
||||||
Handle windowResource = GetResource('WIND', resID);
|
Handle windowResource = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('WIND', resID);
|
||||||
|
|
||||||
if (!windowResource)
|
if (!windowResource)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -361,7 +350,7 @@ void GetIndString(unsigned char *str, int stringsID, int fnameIndex)
|
|||||||
if (fnameIndex < 1)
|
if (fnameIndex < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
THandle<uint8_t> istrRes = PortabilityLayer::ResourceManager::GetInstance()->GetResource('STR#', stringsID).StaticCast<uint8_t>();
|
THandle<uint8_t> istrRes = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('STR#', stringsID).StaticCast<uint8_t>();
|
||||||
if (istrRes && *istrRes)
|
if (istrRes && *istrRes)
|
||||||
{
|
{
|
||||||
const uint8_t *contentsBytes = *istrRes;
|
const uint8_t *contentsBytes = *istrRes;
|
||||||
@@ -626,7 +615,7 @@ void *NewPtrClear(Size size)
|
|||||||
|
|
||||||
void DisposePtr(void *ptr)
|
void DisposePtr(void *ptr)
|
||||||
{
|
{
|
||||||
PL_NotYetImplemented();
|
PortabilityLayer::MemoryManager::GetInstance()->Release(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockMove(const void *src, void *dest, Size size)
|
void BlockMove(const void *src, void *dest, Size size)
|
||||||
|
|||||||
@@ -222,11 +222,6 @@ enum EventCode
|
|||||||
kHighLevelEvent,
|
kHighLevelEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BuiltinWDEFs
|
|
||||||
{
|
|
||||||
noGrowDocProc = 4, // Movable, not resizable
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int everyEvent = -1;
|
static const int everyEvent = -1;
|
||||||
|
|
||||||
static const int iBeamCursor = 1;
|
static const int iBeamCursor = 1;
|
||||||
@@ -251,9 +246,6 @@ void SetBuiltinCursor(int builtinCursor);
|
|||||||
void Delay(int ticks, UInt32 *endTickCount);
|
void Delay(int ticks, UInt32 *endTickCount);
|
||||||
short Alert(int dialogID, void *unknown);
|
short Alert(int dialogID, void *unknown);
|
||||||
|
|
||||||
Handle GetResource(int32_t resType, int id);
|
|
||||||
Handle GetResource(const char(&resTypeLiteral)[5], int id);
|
|
||||||
|
|
||||||
short FindWindow(Point point, WindowPtr *window); // Translates global coordinates to window coordinates, returns a region ID
|
short FindWindow(Point point, WindowPtr *window); // Translates global coordinates to window coordinates, returns a region ID
|
||||||
void DragWindow(WindowPtr window, Point start, Rect *bounds); // Drags the window (probably not implemented)
|
void DragWindow(WindowPtr window, Point start, Rect *bounds); // Drags the window (probably not implemented)
|
||||||
void SendBehind(WindowPtr window, WindowPtr behind);
|
void SendBehind(WindowPtr window, WindowPtr behind);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
bool ImageWidget::Init(const WidgetBasicState &state)
|
bool ImageWidget::Init(const WidgetBasicState &state)
|
||||||
{
|
{
|
||||||
m_pict = PortabilityLayer::ResourceManager::GetInstance()->GetResource('PICT', state.m_resID).StaticCast<BitmapImage>();
|
m_pict = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', state.m_resID).StaticCast<BitmapImage>();
|
||||||
|
|
||||||
if (!m_pict)
|
if (!m_pict)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "MenuManager.h"
|
#include "MenuManager.h"
|
||||||
#include "QDManager.h"
|
#include "QDManager.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
// Menu resource structure:
|
// Menu resource structure:
|
||||||
// uint16 menu ID
|
// uint16 menu ID
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
|
|
||||||
MenuHandle GetMenu(int resID)
|
MenuHandle GetMenu(int resID)
|
||||||
{
|
{
|
||||||
Handle menuRes = GetResource('MENU', resID);
|
Handle menuRes = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('MENU', resID);
|
||||||
|
|
||||||
if (!menuRes)
|
if (!menuRes)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -36,11 +36,6 @@ PixMapHandle GetGWorldPixMap(DrawSurface *gworld)
|
|||||||
return gworld->m_port.GetPixMap();
|
return gworld->m_port.GetPixMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
THandle<BitmapImage> GetPicture(short resID)
|
|
||||||
{
|
|
||||||
return PortabilityLayer::ResourceManager::GetInstance()->GetResource('PICT', resID).StaticCast<BitmapImage>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OffsetRect(Rect *rect, int right, int down)
|
void OffsetRect(Rect *rect, int right, int down)
|
||||||
{
|
{
|
||||||
rect->left += right;
|
rect->left += right;
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ void DisposeGWorld(DrawSurface *gworld);
|
|||||||
|
|
||||||
PixMapHandle GetGWorldPixMap(DrawSurface *gworld);
|
PixMapHandle GetGWorldPixMap(DrawSurface *gworld);
|
||||||
|
|
||||||
THandle<BitmapImage> GetPicture(short resID);
|
|
||||||
|
|
||||||
void OffsetRect(Rect *rect, int right, int down);
|
void OffsetRect(Rect *rect, int right, int down);
|
||||||
|
|
||||||
DrawSurface *GetGraphicsPort();
|
DrawSurface *GetGraphicsPort();
|
||||||
|
|||||||
@@ -1382,7 +1382,7 @@ void GetIndPattern(Pattern *pattern, int patListID, int index)
|
|||||||
if (index < 1)
|
if (index < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
THandle<uint8_t> patternList = PortabilityLayer::ResourceManager::GetInstance()->GetResource('PAT#', patListID).StaticCast<uint8_t>();
|
THandle<uint8_t> patternList = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PAT#', patListID).StaticCast<uint8_t>();
|
||||||
const uint8_t *patternRes = *patternList;
|
const uint8_t *patternRes = *patternList;
|
||||||
|
|
||||||
int numPatterns = (patternRes[0] << 8) | patternRes[1];
|
int numPatterns = (patternRes[0] << 8) | patternRes[1];
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "ZipFileProxy.h"
|
#include "ZipFileProxy.h"
|
||||||
#include "ZipFile.h"
|
#include "ZipFile.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace ResourceValidationRules
|
namespace ResourceValidationRules
|
||||||
{
|
{
|
||||||
@@ -104,75 +104,42 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
void Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
void SetResLoad(bool load) override;
|
THandle<void> GetAppResource(const ResTypeID &resTypeID, int16_t resID) const override;
|
||||||
|
ResourceArchive *GetAppResourceArchive() const override;
|
||||||
|
|
||||||
ResourceArchive *LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const override;
|
ResourceArchive *LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const override;
|
||||||
short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) override;
|
|
||||||
void CloseResFile(short ref) override;
|
|
||||||
PLError_t CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) override;
|
PLError_t CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) override;
|
||||||
|
|
||||||
THandle<void> GetResource(const ResTypeID &resType, int id) override;
|
|
||||||
|
|
||||||
short GetCurrentResFile() const override;
|
|
||||||
void SetCurrentResFile(short ref) override;
|
|
||||||
|
|
||||||
void DissociateHandle(MMHandleBlock *hdl) const override;
|
void DissociateHandle(MMHandleBlock *hdl) const override;
|
||||||
const ResourceArchiveRef *ResourceForHandle(MMHandleBlock *hdl) const override;
|
const ResourceArchiveRef *ResourceForHandle(MMHandleBlock *hdl) const override;
|
||||||
|
|
||||||
static ResourceManagerImpl *GetInstance();
|
static ResourceManagerImpl *GetInstance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ResFileSlot
|
|
||||||
{
|
|
||||||
short m_prevFile;
|
|
||||||
short m_nextFile;
|
|
||||||
ResourceArchive *m_resourceArchive;
|
|
||||||
};
|
|
||||||
|
|
||||||
void UnloadAndDestroyResourceFile(ResourceArchive *rf);
|
void UnloadAndDestroyResourceFile(ResourceArchive *rf);
|
||||||
|
|
||||||
std::vector<ResFileSlot> m_resFiles;
|
ResourceArchive *m_appResArchive;
|
||||||
short m_firstResFile;
|
|
||||||
short m_lastResFile;
|
|
||||||
short m_currentResFile;
|
|
||||||
bool m_load;
|
|
||||||
|
|
||||||
static ResourceManagerImpl ms_instance;
|
static ResourceManagerImpl ms_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
ResourceManagerImpl::ResourceManagerImpl()
|
ResourceManagerImpl::ResourceManagerImpl()
|
||||||
: m_currentResFile(-1)
|
: m_appResArchive(nullptr)
|
||||||
, m_firstResFile(-1)
|
|
||||||
, m_lastResFile(-1)
|
|
||||||
, m_load(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManagerImpl::Init()
|
void ResourceManagerImpl::Init()
|
||||||
{
|
{
|
||||||
m_currentResFile = OpenResFork(VirtualDirectories::kApplicationData, PSTR("ApplicationResources"));
|
m_appResArchive = LoadResFile(VirtualDirectories::kApplicationData, PSTR("ApplicationResources"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManagerImpl::Shutdown()
|
void ResourceManagerImpl::Shutdown()
|
||||||
{
|
{
|
||||||
for (std::vector<ResFileSlot>::iterator it = m_resFiles.begin(), itEnd = m_resFiles.end(); it != itEnd; ++it)
|
if (m_appResArchive)
|
||||||
{
|
m_appResArchive->Destroy();
|
||||||
if (it->m_resourceArchive)
|
|
||||||
UnloadAndDestroyResourceFile(it->m_resourceArchive);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_resFiles.clear();
|
m_appResArchive = nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
short ResourceManagerImpl::GetCurrentResFile() const
|
|
||||||
{
|
|
||||||
return m_currentResFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResourceManagerImpl::SetCurrentResFile(short ref)
|
|
||||||
{
|
|
||||||
m_currentResFile = ref;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManagerImpl::DissociateHandle(MMHandleBlock *hdl) const
|
void ResourceManagerImpl::DissociateHandle(MMHandleBlock *hdl) const
|
||||||
@@ -198,11 +165,6 @@ namespace PortabilityLayer
|
|||||||
return &ms_instance;
|
return &ms_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManagerImpl::SetResLoad(bool load)
|
|
||||||
{
|
|
||||||
m_load = load;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceArchive *ResourceManagerImpl::LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const
|
ResourceArchive *ResourceManagerImpl::LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const
|
||||||
{
|
{
|
||||||
IOStream *fStream = nullptr;
|
IOStream *fStream = nullptr;
|
||||||
@@ -227,82 +189,6 @@ namespace PortabilityLayer
|
|||||||
return archive;
|
return archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
short ResourceManagerImpl::OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename)
|
|
||||||
{
|
|
||||||
const size_t numSlots = m_resFiles.size();
|
|
||||||
size_t resFileIndex = numSlots;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < numSlots; i++)
|
|
||||||
{
|
|
||||||
if (m_resFiles[i].m_resourceArchive == nullptr)
|
|
||||||
{
|
|
||||||
resFileIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resFileIndex == 0x7fff)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
|
||||||
ResourceArchive *resFile = LoadResFile(virtualDir, filename);
|
|
||||||
|
|
||||||
if (!resFile)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
ResFileSlot slot;
|
|
||||||
slot.m_resourceArchive = resFile;
|
|
||||||
slot.m_prevFile = m_lastResFile;
|
|
||||||
slot.m_nextFile = -1;
|
|
||||||
|
|
||||||
if (resFileIndex == numSlots)
|
|
||||||
m_resFiles.push_back(slot);
|
|
||||||
else
|
|
||||||
m_resFiles[resFileIndex] = slot;
|
|
||||||
|
|
||||||
const short rfid = static_cast<short>(resFileIndex);
|
|
||||||
|
|
||||||
if (m_firstResFile < 0)
|
|
||||||
m_firstResFile = rfid;
|
|
||||||
|
|
||||||
if (m_lastResFile >= 0)
|
|
||||||
m_resFiles[m_lastResFile].m_nextFile = rfid;
|
|
||||||
|
|
||||||
m_lastResFile = rfid;
|
|
||||||
m_currentResFile = rfid; // Resource Manager is supposed to reset the search stack on new file open
|
|
||||||
|
|
||||||
return rfid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResourceManagerImpl::CloseResFile(short ref)
|
|
||||||
{
|
|
||||||
ResFileSlot &slot = m_resFiles[ref];
|
|
||||||
|
|
||||||
assert(slot.m_resourceArchive != nullptr);
|
|
||||||
|
|
||||||
slot.m_resourceArchive->Destroy();
|
|
||||||
slot.m_resourceArchive = nullptr;
|
|
||||||
|
|
||||||
if (m_lastResFile == ref)
|
|
||||||
m_lastResFile = slot.m_prevFile;
|
|
||||||
|
|
||||||
if (slot.m_prevFile >= 0)
|
|
||||||
{
|
|
||||||
ResFileSlot &prevFileSlot = m_resFiles[slot.m_prevFile];
|
|
||||||
prevFileSlot.m_nextFile = slot.m_nextFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (slot.m_nextFile >= 0)
|
|
||||||
{
|
|
||||||
ResFileSlot &nextFileSlot = m_resFiles[slot.m_nextFile];
|
|
||||||
nextFileSlot.m_prevFile = slot.m_prevFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
slot.m_nextFile = slot.m_prevFile = -1;
|
|
||||||
|
|
||||||
m_currentResFile = m_lastResFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
PLError_t ResourceManagerImpl::CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename)
|
PLError_t ResourceManagerImpl::CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename)
|
||||||
{
|
{
|
||||||
PortabilityLayer::IOStream *stream = nullptr;
|
PortabilityLayer::IOStream *stream = nullptr;
|
||||||
@@ -331,22 +217,17 @@ namespace PortabilityLayer
|
|||||||
return PLErrors::kNone;
|
return PLErrors::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
THandle<void> ResourceManagerImpl::GetResource(const ResTypeID &resType, int id)
|
THandle<void> ResourceManagerImpl::GetAppResource(const ResTypeID &resType, int16_t resID) const
|
||||||
{
|
{
|
||||||
short searchIndex = m_currentResFile;
|
if (!m_appResArchive)
|
||||||
while (searchIndex >= 0)
|
return THandle<void>();
|
||||||
{
|
|
||||||
const ResFileSlot& slot = m_resFiles[searchIndex];
|
|
||||||
assert(slot.m_resourceArchive);
|
|
||||||
|
|
||||||
THandle<void> resHdl = slot.m_resourceArchive->GetResource(resType, id, m_load);
|
return m_appResArchive->LoadResource(resType, resID);
|
||||||
if (resHdl != nullptr)
|
}
|
||||||
return resHdl;
|
|
||||||
|
|
||||||
searchIndex = slot.m_prevFile;
|
ResourceArchive *ResourceManagerImpl::GetAppResourceArchive() const
|
||||||
}
|
{
|
||||||
|
return m_appResArchive;
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceManagerImpl ResourceManagerImpl::ms_instance;
|
ResourceManagerImpl ResourceManagerImpl::ms_instance;
|
||||||
@@ -395,6 +276,23 @@ namespace PortabilityLayer
|
|||||||
PortabilityLayer::MemoryManager::GetInstance()->Release(this);
|
PortabilityLayer::MemoryManager::GetInstance()->Release(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
THandle<void> ResourceArchive::LoadResource(const ResTypeID &resTypeID, int id)
|
||||||
|
{
|
||||||
|
return GetResource(resTypeID, id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ResourceArchive::GetResourceSize(const ResTypeID &resTypeID, int id, size_t &outSize)
|
||||||
|
{
|
||||||
|
THandle<void> hdl = GetResource(resTypeID, id, false);
|
||||||
|
if (const PortabilityLayer::MMHandleBlock *hdlBlock = hdl.MMBlock())
|
||||||
|
{
|
||||||
|
outSize = hdlBlock->m_rmSelfRef->m_size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
THandle<void> ResourceArchive::GetResource(const ResTypeID &resTypeID, int id, bool load)
|
THandle<void> ResourceArchive::GetResource(const ResTypeID &resTypeID, int id, bool load)
|
||||||
{
|
{
|
||||||
const char *extension = ".bin";
|
const char *extension = ".bin";
|
||||||
|
|||||||
@@ -9,46 +9,6 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
struct PLOpenedResFile
|
|
||||||
{
|
|
||||||
bool m_isOpen;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const unsigned int kPLMaxOpenedResFiles = 64;
|
|
||||||
static PLOpenedResFile gs_resFiles[kPLMaxOpenedResFiles];
|
|
||||||
|
|
||||||
short CurResFile()
|
|
||||||
{
|
|
||||||
return PortabilityLayer::ResourceManager::GetInstance()->GetCurrentResFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UseResFile(short fid)
|
|
||||||
{
|
|
||||||
PortabilityLayer::ResourceManager::GetInstance()->SetCurrentResFile(fid);
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle Get1Resource(UInt32 resID, int index)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle Get1IndResource(UInt32 resID, int index)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Count1Resources(UInt32 resType)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetResLoad(Boolean load)
|
|
||||||
{
|
|
||||||
PortabilityLayer::ResourceManager::GetInstance()->SetResLoad(load != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
long GetMaxResourceSize(Handle res)
|
long GetMaxResourceSize(Handle res)
|
||||||
{
|
{
|
||||||
@@ -56,9 +16,3 @@ long GetMaxResourceSize(Handle res)
|
|||||||
const PortabilityLayer::ResourceArchiveRef *resRef = hBlock->m_rmSelfRef;
|
const PortabilityLayer::ResourceArchiveRef *resRef = hBlock->m_rmSelfRef;
|
||||||
return resRef->m_size;
|
return resRef->m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
short HOpenResFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &name, int permissions)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,24 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __PL_RESOURCES_H__
|
|
||||||
#define __PL_RESOURCES_H__
|
|
||||||
|
|
||||||
#include "PLCore.h"
|
#include "PLCore.h"
|
||||||
|
|
||||||
|
|
||||||
class PLPasStr;
|
class PLPasStr;
|
||||||
|
|
||||||
short CurResFile();
|
|
||||||
void UseResFile(short fid);
|
|
||||||
Handle Get1Resource(UInt32 resID, int index);
|
|
||||||
Handle Get1IndResource(UInt32 resID, int index);
|
|
||||||
int Count1Resources(UInt32 resType);
|
|
||||||
|
|
||||||
void SetResLoad(Boolean load); // Sets whether resources should be loaded when requested
|
|
||||||
|
|
||||||
long GetMaxResourceSize(Handle res);
|
long GetMaxResourceSize(Handle res);
|
||||||
|
|
||||||
// This should return -1 on error?
|
|
||||||
short HOpenResFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &name, int permissions);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -30,12 +30,15 @@ namespace PortabilityLayer
|
|||||||
static ResourceArchive *Create(ZipFileProxy *zipFileProxy, IOStream *stream);
|
static ResourceArchive *Create(ZipFileProxy *zipFileProxy, IOStream *stream);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
THandle<void> GetResource(const ResTypeID &resTypeID, int id, bool load);
|
THandle<void> LoadResource(const ResTypeID &resTypeID, int id);
|
||||||
|
bool GetResourceSize(const ResTypeID &resTypeID, int id, size_t &outSize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResourceArchive(ZipFileProxy *zipFileProxy, IOStream *stream, ResourceArchiveRef *resourceHandles);
|
ResourceArchive(ZipFileProxy *zipFileProxy, IOStream *stream, ResourceArchiveRef *resourceHandles);
|
||||||
~ResourceArchive();
|
~ResourceArchive();
|
||||||
|
|
||||||
|
THandle<void> GetResource(const ResTypeID &resTypeID, int id, bool load);
|
||||||
|
|
||||||
ZipFileProxy *m_zipFileProxy;
|
ZipFileProxy *m_zipFileProxy;
|
||||||
IOStream *m_stream;
|
IOStream *m_stream;
|
||||||
ResourceArchiveRef *m_resourceHandles;
|
ResourceArchiveRef *m_resourceHandles;
|
||||||
@@ -47,18 +50,12 @@ namespace PortabilityLayer
|
|||||||
virtual void Init() = 0;
|
virtual void Init() = 0;
|
||||||
virtual void Shutdown() = 0;
|
virtual void Shutdown() = 0;
|
||||||
|
|
||||||
virtual void SetResLoad(bool load) = 0;
|
virtual THandle<void> GetAppResource(const ResTypeID &resTypeID, int16_t resID) const = 0;
|
||||||
|
virtual ResourceArchive *GetAppResourceArchive() const = 0;
|
||||||
|
|
||||||
virtual ResourceArchive *LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const = 0;
|
virtual ResourceArchive *LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const = 0;
|
||||||
virtual short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
|
|
||||||
virtual void CloseResFile(short ref) = 0;
|
|
||||||
virtual PLError_t CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
|
virtual PLError_t CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
|
||||||
|
|
||||||
virtual THandle<void> GetResource(const ResTypeID &resType, int id) = 0;
|
|
||||||
|
|
||||||
virtual short GetCurrentResFile() const = 0;
|
|
||||||
virtual void SetCurrentResFile(short ref) = 0;
|
|
||||||
|
|
||||||
virtual void DissociateHandle(MMHandleBlock *hdl) const = 0;
|
virtual void DissociateHandle(MMHandleBlock *hdl) const = 0;
|
||||||
virtual const ResourceArchiveRef *ResourceForHandle(MMHandleBlock *hdl) const = 0;
|
virtual const ResourceArchiveRef *ResourceForHandle(MMHandleBlock *hdl) const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,34 @@ namespace PortabilityLayer
|
|||||||
uint8_t m_titleLength;
|
uint8_t m_titleLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum WDefPositionSpecs
|
||||||
|
{
|
||||||
|
kPosSpec_CommonBits = 0x200a,
|
||||||
|
|
||||||
|
kPosSpec_LocationMask = 0x1800,
|
||||||
|
kPosSpec_Location_Center = 0x0800,
|
||||||
|
kPosSpec_Location_AlertPosition = 0x1000,
|
||||||
|
kPosSpec_Location_Stagger = 0x1800,
|
||||||
|
|
||||||
|
kPosSpec_SubsetMask = 0xc000,
|
||||||
|
kPosSpec_Subset_MainScreen = 0x0000,
|
||||||
|
kPosSpec_Subset_ParentWindow = 0x8000,
|
||||||
|
kPosSpec_Subset_ParentWindowsScreen = 0x4000,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Styles
|
||||||
|
{
|
||||||
|
kStyle_BarResizable = 0,
|
||||||
|
kStyle_Bar = 4,
|
||||||
|
kStyle_BarResizableExpandable = 8,
|
||||||
|
kStyle_BarExpandable = 12,
|
||||||
|
kStyle_Box = 2,
|
||||||
|
kStyle_BoxShadow = 3,
|
||||||
|
kStyle_BarCloseBoxBlack = 16,
|
||||||
|
kStyle_Alert = 1,
|
||||||
|
kStyle_BarNoMinimize = 5,
|
||||||
|
};
|
||||||
|
|
||||||
GP_STATIC_ASSERT(sizeof(WindowDefPart1) == 19);
|
GP_STATIC_ASSERT(sizeof(WindowDefPart1) == 19);
|
||||||
|
|
||||||
WindowDefPart1 wdefPart1;
|
WindowDefPart1 wdefPart1;
|
||||||
@@ -26,8 +54,23 @@ namespace PortabilityLayer
|
|||||||
if (stream->Read(&wdefPart1, sizeof(wdefPart1)) != sizeof(wdefPart1))
|
if (stream->Read(&wdefPart1, sizeof(wdefPart1)) != sizeof(wdefPart1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
uint16_t styleFlags = 0;
|
||||||
|
|
||||||
|
switch (static_cast<int>(wdefPart1.m_wdefResID))
|
||||||
|
{
|
||||||
|
case kStyle_Bar:
|
||||||
|
case kStyle_BarNoMinimize:
|
||||||
|
styleFlags = WindowStyleFlags::kTitleBar;
|
||||||
|
break;
|
||||||
|
case kStyle_Box:
|
||||||
|
styleFlags = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false; // Unsupported window style
|
||||||
|
}
|
||||||
|
|
||||||
m_initialRect = wdefPart1.m_initialRect.ToRect();
|
m_initialRect = wdefPart1.m_initialRect.ToRect();
|
||||||
m_wdefResID = wdefPart1.m_wdefResID;
|
m_styleFlags = styleFlags;
|
||||||
m_visibilityStatus = wdefPart1.m_visibilityStatus;
|
m_visibilityStatus = wdefPart1.m_visibilityStatus;
|
||||||
m_hasCloseBox = wdefPart1.m_hasCloseBox;
|
m_hasCloseBox = wdefPart1.m_hasCloseBox;
|
||||||
m_referenceConstant = wdefPart1.m_referenceConstant;
|
m_referenceConstant = wdefPart1.m_referenceConstant;
|
||||||
@@ -44,11 +87,11 @@ namespace PortabilityLayer
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowDef WindowDef::Create(const Rect &initialRect, int16_t wdefID, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title)
|
WindowDef WindowDef::Create(const Rect &initialRect, uint16_t styleFlags, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title)
|
||||||
{
|
{
|
||||||
WindowDef wdef;
|
WindowDef wdef;
|
||||||
wdef.m_initialRect = initialRect;
|
wdef.m_initialRect = initialRect;
|
||||||
wdef.m_wdefResID = wdefID;
|
wdef.m_styleFlags = styleFlags;
|
||||||
wdef.m_visibilityStatus = isVisible ? 1 : 0;
|
wdef.m_visibilityStatus = isVisible ? 1 : 0;
|
||||||
wdef.m_hasCloseBox = hasCloseBox ? 1 : 0;
|
wdef.m_hasCloseBox = hasCloseBox ? 1 : 0;
|
||||||
wdef.m_referenceConstant = refConstant;
|
wdef.m_referenceConstant = refConstant;
|
||||||
|
|||||||
@@ -9,10 +9,22 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
class IOStream;
|
class IOStream;
|
||||||
|
|
||||||
|
namespace WindowStyleFlags
|
||||||
|
{
|
||||||
|
enum WindowStyleFlag
|
||||||
|
{
|
||||||
|
kTitleBar = 1,
|
||||||
|
kBorderless = 2,
|
||||||
|
kResizable = 4,
|
||||||
|
kMiniBar = 8,
|
||||||
|
kAlert = 16,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
struct WindowDef
|
struct WindowDef
|
||||||
{
|
{
|
||||||
Rect m_initialRect;
|
Rect m_initialRect;
|
||||||
int16_t m_wdefResID;
|
uint16_t m_styleFlags;
|
||||||
uint16_t m_visibilityStatus;
|
uint16_t m_visibilityStatus;
|
||||||
uint16_t m_hasCloseBox;
|
uint16_t m_hasCloseBox;
|
||||||
uint32_t m_referenceConstant;
|
uint32_t m_referenceConstant;
|
||||||
@@ -21,6 +33,6 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
bool Deserialize(IOStream *stream);
|
bool Deserialize(IOStream *stream);
|
||||||
|
|
||||||
static WindowDef Create(const Rect &initialRect, int16_t wdefID, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title);
|
static WindowDef Create(const Rect &initialRect, uint16_t styleFlags, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user