diff --git a/FTagData/FTagData.vcxproj b/FTagData/FTagData.vcxproj
index 81c8622..fa0b4f6 100644
--- a/FTagData/FTagData.vcxproj
+++ b/FTagData/FTagData.vcxproj
@@ -60,21 +60,25 @@
+
+
+
+
diff --git a/GpApp/About.cpp b/GpApp/About.cpp
index a07f2ef..db6106c 100644
--- a/GpApp/About.cpp
+++ b/GpApp/About.cpp
@@ -21,8 +21,8 @@
static void HiLiteOkayButton (DrawSurface *surface);
static void UnHiLiteOkayButton (DrawSurface *surface);
-static void UpdateMainPict (DialogPtr);
-static Boolean AboutFilter (DialogPtr, EventRecord *theEvent, short *hit);
+static void UpdateMainPict (Dialog *);
+static Boolean AboutFilter (Dialog *, EventRecord *theEvent, short *hit);
static PortabilityLayer::ScanlineMask *okayButtScanlineMask;
@@ -40,7 +40,7 @@ void DoAbout (void)
#define kTextItemVers 2 // item number of version text
#define kPictItemMain 4 // item number of main PICT
- DialogPtr aboutDialog;
+ Dialog *aboutDialog;
Str255 longVersion;
StringPtr messagePtr;
VersRecHndl version;
@@ -143,7 +143,7 @@ static void UnHiLiteOkayButton (DrawSurface *surface)
//-------------------------------------------------------------- UpdateMainPict
// Redraws the main graphic in the dialog (in response to an update event).
-static void UpdateMainPict (DialogPtr theDial)
+static void UpdateMainPict (Dialog *theDial)
{
Str255 theStr, theStr2;
uint64_t freeMemory;
@@ -175,7 +175,7 @@ static void UpdateMainPict (DialogPtr theDial)
//-------------------------------------------------------------- AboutFilter
// Dialog filter for the About dialog.
-static Boolean AboutFilter (DialogPtr theDial, EventRecord *theEvent, short *hit)
+static Boolean AboutFilter (Dialog *theDial, EventRecord *theEvent, short *hit)
{
Point mousePt;
UInt32 dummyLong;
diff --git a/GpApp/DialogUtils.cpp b/GpApp/DialogUtils.cpp
index 8134f5b..029c92f 100644
--- a/GpApp/DialogUtils.cpp
+++ b/GpApp/DialogUtils.cpp
@@ -5,6 +5,7 @@
//============================================================================
#include "DialogManager.h"
+#include "PLArrayView.h"
#include "PLControlDefinitions.h"
#include "PLLowMem.h"
#include "PLNumberFormatting.h"
@@ -25,7 +26,7 @@
// Given a dialog pointer and a resource ID, this function brings it upÉ
// centered, visible, and with the default button outlined.
-void BringUpDialog (DialogPtr *theDialog, short dialogID)
+void BringUpDialog (Dialog **theDialog, short dialogID)
{
*theDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(dialogID, kPutInFront);
@@ -141,13 +142,15 @@ void CenterDialog (SInt16 dialogID)
void GetDialogRect (Rect *bounds, short dialogID)
{
- DialogTHndl dlogHandle;
Byte wasState;
- dlogHandle = GetResource('DLOG', dialogID).StaticCast();
+ Handle dlogHandle = GetResource('DLOG', dialogID).StaticCast();
if (dlogHandle != nil)
{
- *bounds = (**dlogHandle).boundsRect;
+ BERect dataRect = **dlogHandle.StaticCast();
+ *bounds = dataRect.ToRect();
+
+ dlogHandle.Dispose();
}
}
@@ -333,7 +336,7 @@ void ZoomOutAlertRect (short alertID)
// Flashes the default dialog button (item = 1) so as to make it appearÉ
// as though the user clicked on it.
-void FlashDialogButton (DialogPtr theDialog, short itemNumber)
+void FlashDialogButton (Dialog *theDialog, short itemNumber)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -350,23 +353,33 @@ void FlashDialogButton (DialogPtr theDialog, short itemNumber)
// Draws a fat outline around the default item (item = 1). This is theÉ
// item that is selected if the user hits the Return key.
-void DrawDefaultButton (DialogPtr theDialog)
+void DrawDefaultButton (Dialog *theDialog)
{
- Rect itemRect;
- ControlHandle itemHandle;
- short itemType;
-
- GetDialogItem(theDialog, 1, &itemType, &itemHandle, &itemRect);
+ DialogItem *firstItem = *theDialog->GetItems().begin();
+ Rect itemRect = firstItem->GetRect();
+
+ DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
+
InsetRect(&itemRect, -4, -4);
- PenSize(3, 3);
- FrameRoundRect(&itemRect, 16, 16);
+
+ surface->SetForeColor(StdColors::Black());
+
+ for (int xOffset = 0; xOffset < 3; xOffset++)
+ {
+ for (int yOffset = 0; yOffset < 3; yOffset++)
+ {
+ const Rect offsetRect = itemRect + Point::Create(xOffset, yOffset);
+ surface->FrameRoundRect(itemRect, 8, 8);
+ }
+ }
+
PenNormal();
}
//-------------------------------------------------------------- GetDialogString
// Returns a string from a specific dialog item.
-void GetDialogString (DialogPtr theDialog, short item, StringPtr theString)
+void GetDialogString (Dialog *theDialog, short item, StringPtr theString)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -379,7 +392,7 @@ void GetDialogString (DialogPtr theDialog, short item, StringPtr theString)
//-------------------------------------------------------------- SetDialogString
// Sets a specific string to a specific dialog item.
-void SetDialogString (DialogPtr theDialog, short item, const PLPasStr &theString)
+void SetDialogString (Dialog *theDialog, short item, const PLPasStr &theString)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -392,7 +405,7 @@ void SetDialogString (DialogPtr theDialog, short item, const PLPasStr &theString
//-------------------------------------------------------------- GetDialogStringLen
// Returns the length of a dialog item string (text).
-short GetDialogStringLen (DialogPtr theDialog, short item)
+short GetDialogStringLen (Dialog *theDialog, short item)
{
Rect itemRect;
Str255 theString;
@@ -408,7 +421,7 @@ short GetDialogStringLen (DialogPtr theDialog, short item)
// Returns the value or "state" of a dialog item. For checkboxes andÉ
// radio buttons, this may be a 1 or 0.
-void GetDialogItemValue (DialogPtr theDialog, short item, short *theState)
+void GetDialogItemValue (Dialog *theDialog, short item, short *theState)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -422,7 +435,7 @@ void GetDialogItemValue (DialogPtr theDialog, short item, short *theState)
// Sets a specific dialogf items value or state (can set or clearÉ
// checkboxes, radio buttons, etc.).
-void SetDialogItemValue (DialogPtr theDialog, short item, short theState)
+void SetDialogItemValue (Dialog *theDialog, short item, short theState)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -435,7 +448,7 @@ void SetDialogItemValue (DialogPtr theDialog, short item, short theState)
//-------------------------------------------------------------- ToggleDialogItemValue
// If item is a checkbox or radio button, its state is toggled.
-void ToggleDialogItemValue (DialogPtr theDialog, short item)
+void ToggleDialogItemValue (Dialog *theDialog, short item)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -454,7 +467,7 @@ void ToggleDialogItemValue (DialogPtr theDialog, short item)
// Function accepts an integer, converts it to a string and sets aÉ
// dialog items text to this string.
-void SetDialogNumToStr (DialogPtr theDialog, short item, long theNumber)
+void SetDialogNumToStr (Dialog *theDialog, short item, long theNumber)
{
Str255 theString;
Rect itemRect;
@@ -470,7 +483,7 @@ void SetDialogNumToStr (DialogPtr theDialog, short item, long theNumber)
// Function extracts the text from a dialog item and converts it to anÉ
// integer for returning.
-void GetDialogNumFromStr (DialogPtr theDialog, short item, long *theNumber)
+void GetDialogNumFromStr (Dialog *theDialog, short item, long *theNumber)
{
Str255 theString;
Rect itemRect;
@@ -485,19 +498,16 @@ void GetDialogNumFromStr (DialogPtr theDialog, short item, long *theNumber)
//-------------------------------------------------------------- GetDialogItemRect
// Returns the bounding rectangle of the specified dialog item.
-void GetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
+void GetDialogItemRect (Dialog *theDialog, short item, Rect *theRect)
{
- ControlHandle itemHandle;
- short itemType;
-
- GetDialogItem(theDialog, item, &itemType, &itemHandle, theRect);
+ *theRect = theDialog->GetItems()[item - 1]->GetRect();
}
//-------------------------------------------------------------- SetDialogItemRect
// Sets the bounding rectangle of the specified dialog item. Used toÉ
// resize or move a control.
-void SetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
+void SetDialogItemRect (Dialog *theDialog, short item, Rect *theRect)
{
Rect oldRect;
ControlHandle itemHandle;
@@ -511,7 +521,7 @@ void SetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
//-------------------------------------------------------------- OffsetDialogItemRect
// Moves a dialog item by h and v.
-void OffsetDialogItemRect (DialogPtr theDialog, short item, short h, short v)
+void OffsetDialogItemRect (Dialog *theDialog, short item, short h, short v)
{
Rect oldRect;
ControlHandle itemHandle;
@@ -527,7 +537,7 @@ void OffsetDialogItemRect (DialogPtr theDialog, short item, short h, short v)
// clears the whole range of them but sets the one specified (as thoughÉ
// the radio buttons are linked and only one can be set at a time).
-void SelectFromRadioGroup (DialogPtr dial, short which, short first, short last)
+void SelectFromRadioGroup (Dialog *dial, short which, short first, short last)
{
Rect iRect;
ControlHandle iHandle;
@@ -547,7 +557,7 @@ void SelectFromRadioGroup (DialogPtr dial, short which, short first, short last)
// Assigns a menu handle to a pop-up dialog item - thus, giving thatÉ
// pop-up item something to pop up.
/*
-void AddMenuToPopUp (DialogPtr theDialog, short whichItem, MenuHandle theMenu)
+void AddMenuToPopUp (Dialog *theDialog, short whichItem, MenuHandle theMenu)
{
Rect iRect;
Handle iHandle;
@@ -560,7 +570,7 @@ void AddMenuToPopUp (DialogPtr theDialog, short whichItem, MenuHandle theMenu)
//-------------------------------------------------------------- GetPopUpMenuValu
// Returns which item is currently selected in a pop-up menu.
-void GetPopUpMenuValue (DialogPtr theDialog, short whichItem, short *value)
+void GetPopUpMenuValue (Dialog *theDialog, short whichItem, short *value)
{
Rect iRect;
ControlHandle iHandle;
@@ -573,7 +583,7 @@ void GetPopUpMenuValue (DialogPtr theDialog, short whichItem, short *value)
//-------------------------------------------------------------- SetPopUpMenuValue
// Forces a specific item to be set (as though selected) in a pop-up menu.
-void SetPopUpMenuValue (DialogPtr theDialog, short whichItem, short value)
+void SetPopUpMenuValue (Dialog *theDialog, short whichItem, short value)
{
Rect iRect;
ControlHandle iHandle;
@@ -586,7 +596,7 @@ void SetPopUpMenuValue (DialogPtr theDialog, short whichItem, short value)
//-------------------------------------------------------------- MyEnableControl
// "Un-grays" or enables a dialog item (usually a button).
-void MyEnableControl (DialogPtr theDialog, short whichItem)
+void MyEnableControl (Dialog *theDialog, short whichItem)
{
Rect iRect;
ControlHandle iHandle;
@@ -599,7 +609,7 @@ void MyEnableControl (DialogPtr theDialog, short whichItem)
//-------------------------------------------------------------- MyDisableControl
// "Grays out" or disables a dialog item (usually a button).
-void MyDisableControl (DialogPtr theDialog, short whichItem)
+void MyDisableControl (Dialog *theDialog, short whichItem)
{
Rect iRect;
ControlHandle iHandle;
@@ -614,7 +624,7 @@ void MyDisableControl (DialogPtr theDialog, short whichItem)
// within the bounding rect of the item. Dialog item assumed to beÉ
// a "user item" (invisible item with only bounds).
-void DrawDialogUserText (DialogPtr dial, short item, StringPtr text, Boolean invert)
+void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean invert)
{
Rect iRect;
ControlHandle iHandle;
@@ -658,7 +668,7 @@ void DrawDialogUserText (DialogPtr dial, short item, StringPtr text, Boolean inv
// it truncates the string (and appends "É") to the end in order thatÉ
// the string fits within the dialog item's bounds.
-void DrawDialogUserText2 (DialogPtr dial, short item, StringPtr text)
+void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
{
Rect iRect;
ControlHandle iHandle;
@@ -681,7 +691,7 @@ void DrawDialogUserText2 (DialogPtr dial, short item, StringPtr text)
// Draws a 'PICT' specified by ID within the bounds of the specifiedÉ
// dialog item.
-void LoadDialogPICT (DialogPtr theDialog, short item, short theID)
+void LoadDialogPICT (Dialog *theDialog, short item, short theID)
{
Rect iRect;
ControlHandle iHandle;
@@ -697,7 +707,7 @@ void LoadDialogPICT (DialogPtr theDialog, short item, short theID)
//-------------------------------------------------------------- FrameDialogItem
// Given a dialog item, this function draws a box around it.
-void FrameDialogItem (DialogPtr theDialog, short item)
+void FrameDialogItem (Dialog *theDialog, short item)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -711,7 +721,7 @@ void FrameDialogItem (DialogPtr theDialog, short item)
//-------------------------------------------------------------- FrameDialogItemC
// Given a dialog item, this function draws a color (specified) box around it.
-void FrameDialogItemC (DialogPtr theDialog, short item, long color)
+void FrameDialogItemC (Dialog *theDialog, short item, long color)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -729,7 +739,7 @@ void FrameDialogItemC (DialogPtr theDialog, short item, long color)
//-------------------------------------------------------------- FrameOvalDialogItem
// Given a dialog item, this function draws an oval around it.
-void FrameOvalDialogItem (DialogPtr theDialog, short item)
+void FrameOvalDialogItem (Dialog *theDialog, short item)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -744,7 +754,7 @@ void FrameOvalDialogItem (DialogPtr theDialog, short item)
// Given a dialog item, this function draws any combination of 4 sidesÉ
// of a box around it. Which sides get drawn is encoded in "sides".
-void BorderDialogItem (DialogPtr theDialog, short item, short sides)
+void BorderDialogItem (Dialog *theDialog, short item, short sides)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -791,7 +801,7 @@ void BorderDialogItem (DialogPtr theDialog, short item, short sides)
//-------------------------------------------------------------- ShadowDialogItem
// Draws a drop shadow to the right and below a specified dialog item.
-void ShadowDialogItem (DialogPtr theDialog, short item, short thickness)
+void ShadowDialogItem (Dialog *theDialog, short item, short thickness)
{
Rect itemRect;
ControlHandle itemHandle;
@@ -813,7 +823,7 @@ void ShadowDialogItem (DialogPtr theDialog, short item, short thickness)
//-------------------------------------------------------------- EraseDialogItem
// Erases (but doesn't physically remove) a dialog item.
-void EraseDialogItem (DialogPtr theDialog, short item)
+void EraseDialogItem (Dialog *theDialog, short item)
{
Rect itemRect;
ControlHandle itemHandle;
diff --git a/GpApp/DialogUtils.h b/GpApp/DialogUtils.h
index da0f150..948b5e8 100644
--- a/GpApp/DialogUtils.h
+++ b/GpApp/DialogUtils.h
@@ -8,7 +8,7 @@
#include "PLDialogs.h"
-void BringUpDialog (DialogPtr *theDialog, short dialogID);
+void BringUpDialog (Dialog **theDialog, short dialogID);
//void GetPutDialogCorner (Point *);
//void GetGetDialogCorner (Point *);
//void CenterDialog (short);
@@ -17,31 +17,31 @@ void GetDialogRect (Rect *, short);
//void CenterAlert (short);
//void ZoomOutDialogRect (short);
//void ZoomOutAlertRect (short);
-void FlashDialogButton (DialogPtr, short);
-void DrawDefaultButton (DialogPtr);
-void GetDialogString (DialogPtr, short, StringPtr);
-void SetDialogString (DialogPtr, short, const PLPasStr&);
-short GetDialogStringLen (DialogPtr, short);
-void GetDialogItemValue (DialogPtr, short, short *);
-void SetDialogItemValue (DialogPtr, short, short);
-void ToggleDialogItemValue (DialogPtr, short);
-void SetDialogNumToStr (DialogPtr, short, long);
-void GetDialogNumFromStr (DialogPtr, short, long *);
-void GetDialogItemRect (DialogPtr, short, Rect *);
-void SetDialogItemRect (DialogPtr, short, Rect *);
-void OffsetDialogItemRect (DialogPtr, short, short, short);
-void SelectFromRadioGroup (DialogPtr, short, short, short);
-//void AddMenuToPopUp (DialogPtr, short, MenuHandle);
-void GetPopUpMenuValue (DialogPtr, short, short *);
-void SetPopUpMenuValue (DialogPtr, short, short);
-void MyEnableControl(DialogPtr, short);
-void MyDisableControl(DialogPtr, short);
-void DrawDialogUserText (DialogPtr, short, StringPtr, Boolean);
-void DrawDialogUserText2 (DialogPtr, short, StringPtr);
-void LoadDialogPICT (DialogPtr, short, short);
-void FrameDialogItem (DialogPtr, short);
-void FrameDialogItemC (DialogPtr, short, long);
-void FrameOvalDialogItem (DialogPtr, short);
-void BorderDialogItem (DialogPtr, short, short);
-void ShadowDialogItem (DialogPtr, short, short);
-void EraseDialogItem (DialogPtr, short);
+void FlashDialogButton (Dialog *, short);
+void DrawDefaultButton (Dialog *);
+void GetDialogString (Dialog *, short, StringPtr);
+void SetDialogString (Dialog *, short, const PLPasStr&);
+short GetDialogStringLen (Dialog *, short);
+void GetDialogItemValue (Dialog *, short, short *);
+void SetDialogItemValue (Dialog *, short, short);
+void ToggleDialogItemValue (Dialog *, short);
+void SetDialogNumToStr (Dialog *, short, long);
+void GetDialogNumFromStr (Dialog *, short, long *);
+void GetDialogItemRect (Dialog *, short, Rect *);
+void SetDialogItemRect (Dialog *, short, Rect *);
+void OffsetDialogItemRect (Dialog *, short, short, short);
+void SelectFromRadioGroup (Dialog *, short, short, short);
+//void AddMenuToPopUp (Dialog *, short, MenuHandle);
+void GetPopUpMenuValue (Dialog *, short, short *);
+void SetPopUpMenuValue (Dialog *, short, short);
+void MyEnableControl(Dialog *, short);
+void MyDisableControl(Dialog *, short);
+void DrawDialogUserText (Dialog *, short, StringPtr, Boolean);
+void DrawDialogUserText2 (Dialog *, short, StringPtr);
+void LoadDialogPICT (Dialog *, short, short);
+void FrameDialogItem (Dialog *, short);
+void FrameDialogItemC (Dialog *, short, long);
+void FrameOvalDialogItem (Dialog *, short);
+void BorderDialogItem (Dialog *, short, short);
+void ShadowDialogItem (Dialog *, short, short);
+void EraseDialogItem (Dialog *, short);
diff --git a/GpApp/HighScores.cpp b/GpApp/HighScores.cpp
index 3807d62..8ba455d 100644
--- a/GpApp/HighScores.cpp
+++ b/GpApp/HighScores.cpp
@@ -41,11 +41,11 @@ namespace PortabilityLayer
void DrawHighScores (DrawSurface *);
-void UpdateNameDialog (DialogPtr);
-Boolean NameFilter (DialogPtr, EventRecord *, short *);
+void UpdateNameDialog (Dialog *);
+Boolean NameFilter (Dialog *, EventRecord *, short *);
void GetHighScoreName (short);
-void UpdateBannerDialog (DialogPtr);
-Boolean BannerFilter (DialogPtr, EventRecord *, short *);
+void UpdateBannerDialog (Dialog *);
+Boolean BannerFilter (Dialog *, EventRecord *, short *);
void GetHighScoreBanner (void);
Boolean OpenHighScoresFile (const VFileSpec &spec, PortabilityLayer::IOStream *&outStream);
@@ -419,7 +419,7 @@ Boolean TestHighScore (void)
//-------------------------------------------------------------- UpdateNameDialog
// Redraws the "Enter High Score Name" dialog.
-void UpdateNameDialog (DialogPtr theDialog)
+void UpdateNameDialog (Dialog *theDialog)
{
short nChars;
@@ -433,7 +433,7 @@ void UpdateNameDialog (DialogPtr theDialog)
//-------------------------------------------------------------- NameFilter
// Dialog filter for the "Enter High Score Name" dialog.
-Boolean NameFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean NameFilter (Dialog *dial, EventRecord *event, short *item)
{
short nChars;
@@ -487,7 +487,7 @@ Boolean NameFilter (DialogPtr dial, EventRecord *event, short *item)
void GetHighScoreName (short place)
{
- DialogPtr theDial;
+ Dialog *theDial;
Str255 scoreStr, placeStr, tempStr;
short item;
Boolean leaving;
@@ -525,7 +525,7 @@ void GetHighScoreName (short place)
//-------------------------------------------------------------- UpdateBannerDialog
// Redraws the "Enter Message" dialog.
-void UpdateBannerDialog (DialogPtr theDialog)
+void UpdateBannerDialog (Dialog *theDialog)
{
short nChars;
@@ -539,7 +539,7 @@ void UpdateBannerDialog (DialogPtr theDialog)
//-------------------------------------------------------------- BannerFilter
// Dialog filter for the "Enter Message" dialog.
-Boolean BannerFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean BannerFilter (Dialog *dial, EventRecord *event, short *item)
{
short nChars;
@@ -596,7 +596,7 @@ Boolean BannerFilter (DialogPtr dial, EventRecord *event, short *item)
void GetHighScoreBanner (void)
{
- DialogPtr theDial;
+ Dialog *theDial;
Str255 tempStr;
short item;
Boolean leaving;
diff --git a/GpApp/House.cpp b/GpApp/House.cpp
index 7f1699d..bfa3b8e 100644
--- a/GpApp/House.cpp
+++ b/GpApp/House.cpp
@@ -21,8 +21,8 @@
#define kGoToDialogID 1043
-void UpdateGoToDialog (DialogPtr);
-Boolean GoToFilter (DialogPtr, EventRecord *, short *);
+void UpdateGoToDialog (Dialog *);
+Boolean GoToFilter (Dialog *, EventRecord *, short *);
houseHand thisHouse;
@@ -593,7 +593,7 @@ void GenerateRetroLinks (void)
//-------------------------------------------------------------- UpdateGoToDialog
// Redraws the "Go To Room..." dialog.
-void UpdateGoToDialog (DialogPtr theDialog)
+void UpdateGoToDialog (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -603,7 +603,7 @@ void UpdateGoToDialog (DialogPtr theDialog)
//-------------------------------------------------------------- GoToFilter
// Dialog filter for the "Go To Room..." dialog.
-Boolean GoToFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean GoToFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -647,7 +647,7 @@ Boolean GoToFilter (DialogPtr dial, EventRecord *event, short *item)
#define kGoToFSButt 4
#define kFloorEditText 5
#define kSuiteEditText 6
- DialogPtr theDialog;
+ Dialog *theDialog;
long tempLong;
short item, roomToGoTo;
Boolean leaving, canceled;
diff --git a/GpApp/HouseInfo.cpp b/GpApp/HouseInfo.cpp
index 883903a..255f7e2 100644
--- a/GpApp/HouseInfo.cpp
+++ b/GpApp/HouseInfo.cpp
@@ -28,8 +28,8 @@
long CountTotalHousePoints (void);
-void UpdateHouseInfoDialog (DialogPtr);
-Boolean HouseFilter (DialogPtr, EventRecord *, short *);
+void UpdateHouseInfoDialog (Dialog *);
+Boolean HouseFilter (Dialog *, EventRecord *, short *);
Boolean WarnLockingHouse (void);
void HowToZeroScores (void);
@@ -103,7 +103,7 @@ long CountTotalHousePoints (void)
//-------------------------------------------------------------- UpdateHouseInfoDialog
-void UpdateHouseInfoDialog (DialogPtr theDialog)
+void UpdateHouseInfoDialog (Dialog *theDialog)
{
short nChars;
@@ -119,7 +119,7 @@ void UpdateHouseInfoDialog (DialogPtr theDialog)
//-------------------------------------------------------------- HouseFilter
-Boolean HouseFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean HouseFilter (Dialog *dial, EventRecord *event, short *item)
{
Point mouseIs;
short nChars;
@@ -202,7 +202,7 @@ Boolean HouseFilter (DialogPtr dial, EventRecord *event, short *item)
void DoHouseInfo (void)
{
- DialogPtr houseInfoDialog;
+ Dialog *houseInfoDialog;
Str255 versStr, loVers, nRoomsStr;
long h, v;
short item, numRooms, version;
diff --git a/GpApp/Input.cpp b/GpApp/Input.cpp
index 981835a..e92cfbc 100644
--- a/GpApp/Input.cpp
+++ b/GpApp/Input.cpp
@@ -32,7 +32,7 @@ Boolean QuerySaveGame (void);
demoPtr demoData;
KeyMap theKeys;
-DialogPtr saveDial;
+Dialog *saveDial;
short demoIndex, batteryFrame;
Boolean isEscPauseKey, paused, batteryWasEngaged;
diff --git a/GpApp/Menu.cpp b/GpApp/Menu.cpp
index 058a45d..6cbd872 100644
--- a/GpApp/Menu.cpp
+++ b/GpApp/Menu.cpp
@@ -26,8 +26,8 @@ void UpdateMenusEditMode (void);
void UpdateMenusNonEditMode (void);
void UpdateMenusHouseOpen (void);
void UpdateMenusHouseClosed (void);
-void UpdateResumeDialog (DialogPtr);
-Boolean ResumeFilter (DialogPtr, EventRecord *, short *);
+void UpdateResumeDialog (Dialog *);
+Boolean ResumeFilter (Dialog *, EventRecord *, short *);
short QueryResumeGame (void);
void HeyYourPissingAHighScore (void);
@@ -659,7 +659,7 @@ void UpdateCoordinateCheckmark (Boolean checkIt)
//-------------------------------------------------------------- UpdateResumeDialog
// Update function for Resume dialog (below).
-void UpdateResumeDialog (DialogPtr theDialog)
+void UpdateResumeDialog (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -668,7 +668,7 @@ void UpdateResumeDialog (DialogPtr theDialog)
//-------------------------------------------------------------- ResumeFilter
// Dialog filter for the Resume dialog (below).
-Boolean ResumeFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean ResumeFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -712,7 +712,7 @@ Boolean ResumeFilter (DialogPtr dial, EventRecord *event, short *item)
short QueryResumeGame (void)
{
#define kResumeGameDial 1025
- DialogPtr theDial;
+ Dialog *theDial;
houseType *thisHousePtr;
Str255 scoreStr, glidStr;
long hadPoints;
diff --git a/GpApp/ObjectInfo.cpp b/GpApp/ObjectInfo.cpp
index af984b6..30cbe48 100644
--- a/GpApp/ObjectInfo.cpp
+++ b/GpApp/ObjectInfo.cpp
@@ -65,32 +65,32 @@
#define kGotoButton2 14
-void UpdateBlowerInfo (DialogPtr);
-void UpdateFurnitureInfo (DialogPtr);
-void UpdateCustPictInfo (DialogPtr);
-void UpdateSwitchInfo (DialogPtr);
-void UpdateTriggerInfo (DialogPtr);
-void UpdateLightInfo (DialogPtr);
-void UpdateApplianceInfo (DialogPtr);
-void UpdateMicrowaveInfo (DialogPtr);
-void UpdateGreaseInfo (DialogPtr);
-void UpdateInvisBonusInfo (DialogPtr);
-void UpdateTransInfo (DialogPtr);
-void UpdateEnemyInfo (DialogPtr);
-void UpdateFlowerInfo (DialogPtr);
-Boolean BlowerFilter (DialogPtr, EventRecord *, short *);
-Boolean FurnitureFilter (DialogPtr, EventRecord *, short *);
-Boolean CustPictFilter (DialogPtr, EventRecord *, short *);
-Boolean SwitchFilter (DialogPtr, EventRecord *, short *);
-Boolean TriggerFilter (DialogPtr, EventRecord *, short *);
-Boolean LightFilter (DialogPtr, EventRecord *, short *);
-Boolean ApplianceFilter (DialogPtr, EventRecord *, short *);
-Boolean MicrowaveFilter (DialogPtr, EventRecord *, short *);
-Boolean GreaseFilter (DialogPtr, EventRecord *, short *);
-Boolean InvisBonusFilter (DialogPtr, EventRecord *, short *);
-Boolean TransFilter (DialogPtr, EventRecord *, short *);
-Boolean EnemyFilter (DialogPtr, EventRecord *, short *);
-Boolean FlowerFilter (DialogPtr, EventRecord *, short *);
+void UpdateBlowerInfo (Dialog *);
+void UpdateFurnitureInfo (Dialog *);
+void UpdateCustPictInfo (Dialog *);
+void UpdateSwitchInfo (Dialog *);
+void UpdateTriggerInfo (Dialog *);
+void UpdateLightInfo (Dialog *);
+void UpdateApplianceInfo (Dialog *);
+void UpdateMicrowaveInfo (Dialog *);
+void UpdateGreaseInfo (Dialog *);
+void UpdateInvisBonusInfo (Dialog *);
+void UpdateTransInfo (Dialog *);
+void UpdateEnemyInfo (Dialog *);
+void UpdateFlowerInfo (Dialog *);
+Boolean BlowerFilter (Dialog *, EventRecord *, short *);
+Boolean FurnitureFilter (Dialog *, EventRecord *, short *);
+Boolean CustPictFilter (Dialog *, EventRecord *, short *);
+Boolean SwitchFilter (Dialog *, EventRecord *, short *);
+Boolean TriggerFilter (Dialog *, EventRecord *, short *);
+Boolean LightFilter (Dialog *, EventRecord *, short *);
+Boolean ApplianceFilter (Dialog *, EventRecord *, short *);
+Boolean MicrowaveFilter (Dialog *, EventRecord *, short *);
+Boolean GreaseFilter (Dialog *, EventRecord *, short *);
+Boolean InvisBonusFilter (Dialog *, EventRecord *, short *);
+Boolean TransFilter (Dialog *, EventRecord *, short *);
+Boolean EnemyFilter (Dialog *, EventRecord *, short *);
+Boolean FlowerFilter (Dialog *, EventRecord *, short *);
void DoBlowerObjectInfo (short);
void DoFurnitureObjectInfo (void);
void DoCustPictObjectInfo (void);
@@ -120,7 +120,7 @@ extern Boolean linkerIsSwitch;
//============================================================== Functions
//-------------------------------------------------------------- UpdateBlowerInfo
-void UpdateBlowerInfo (DialogPtr theDialog)
+void UpdateBlowerInfo (Dialog *theDialog)
{
#define kArrowheadLength 4
Rect bounds;
@@ -232,7 +232,7 @@ void UpdateBlowerInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateFurnitureInfo
-void UpdateFurnitureInfo (DialogPtr theDialog)
+void UpdateFurnitureInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -241,7 +241,7 @@ void UpdateFurnitureInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateCustPictInfo
-void UpdateCustPictInfo (DialogPtr theDialog)
+void UpdateCustPictInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -250,7 +250,7 @@ void UpdateCustPictInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateSwitchInfo
-void UpdateSwitchInfo (DialogPtr theDialog)
+void UpdateSwitchInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -262,7 +262,7 @@ void UpdateSwitchInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateTriggerInfo
-void UpdateTriggerInfo (DialogPtr theDialog)
+void UpdateTriggerInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -272,7 +272,7 @@ void UpdateTriggerInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateLightInfo
-void UpdateLightInfo (DialogPtr theDialog)
+void UpdateLightInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -281,7 +281,7 @@ void UpdateLightInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateApplianceInfo
-void UpdateApplianceInfo (DialogPtr theDialog)
+void UpdateApplianceInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -290,7 +290,7 @@ void UpdateApplianceInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateMicrowaveInfo
-void UpdateMicrowaveInfo (DialogPtr theDialog)
+void UpdateMicrowaveInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -299,7 +299,7 @@ void UpdateMicrowaveInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateGreaseInfo
-void UpdateGreaseInfo (DialogPtr theDialog)
+void UpdateGreaseInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -308,7 +308,7 @@ void UpdateGreaseInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateInvisBonusInfo
-void UpdateInvisBonusInfo (DialogPtr theDialog)
+void UpdateInvisBonusInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -319,7 +319,7 @@ void UpdateInvisBonusInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateTransInfo
-void UpdateTransInfo (DialogPtr theDialog)
+void UpdateTransInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -329,7 +329,7 @@ void UpdateTransInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateEnemyInfo
-void UpdateEnemyInfo (DialogPtr theDialog)
+void UpdateEnemyInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -338,7 +338,7 @@ void UpdateEnemyInfo (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateFlowerInfo
-void UpdateFlowerInfo (DialogPtr theDialog)
+void UpdateFlowerInfo (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -347,7 +347,7 @@ void UpdateFlowerInfo (DialogPtr theDialog)
//-------------------------------------------------------------- BlowerFilter
-Boolean BlowerFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean BlowerFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -401,7 +401,7 @@ Boolean BlowerFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- FurnitureFilter
-Boolean FurnitureFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean FurnitureFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -436,7 +436,7 @@ Boolean FurnitureFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- CustPictFilter
-Boolean CustPictFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean CustPictFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -471,7 +471,7 @@ Boolean CustPictFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- SwitchFilter
-Boolean SwitchFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean SwitchFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -512,7 +512,7 @@ Boolean SwitchFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- TriggerFilter
-Boolean TriggerFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean TriggerFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -558,7 +558,7 @@ Boolean TriggerFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- LightFilter
-Boolean LightFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean LightFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -607,7 +607,7 @@ Boolean LightFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- ApplianceFilter
-Boolean ApplianceFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean ApplianceFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -661,7 +661,7 @@ Boolean ApplianceFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- MicrowaveFilter
-Boolean MicrowaveFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean MicrowaveFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -710,7 +710,7 @@ Boolean MicrowaveFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- GreaseFilter
-Boolean GreaseFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean GreaseFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -751,7 +751,7 @@ Boolean GreaseFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- InvisBonusFilter
-Boolean InvisBonusFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean InvisBonusFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -786,7 +786,7 @@ Boolean InvisBonusFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- TransFilter
-Boolean TransFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean TransFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -827,7 +827,7 @@ Boolean TransFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- EnemyFilter
-Boolean EnemyFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean EnemyFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -881,7 +881,7 @@ Boolean EnemyFilter (DialogPtr dial, EventRecord *event, short *item)
//-------------------------------------------------------------- EnemyFilter
-Boolean FlowerFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean FlowerFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -932,7 +932,7 @@ Boolean FlowerFilter (DialogPtr dial, EventRecord *event, short *item)
void DoBlowerObjectInfo (short what)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr, distStr;
short item, initial;
Boolean leaving, doReturn, leftFacing;
@@ -1105,7 +1105,7 @@ void DoBlowerObjectInfo (short what)
void DoFurnitureObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
short item;
Boolean leaving, doReturn;
@@ -1170,7 +1170,7 @@ void DoFurnitureObjectInfo (void)
void DoCustPictObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
long wasPict;
short item;
@@ -1267,7 +1267,7 @@ void DoCustPictObjectInfo (void)
void DoSwitchObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr, roomStr, tempStr, objStr;
short item, floor, suite;
Boolean leaving, doLink, doGoTo, doReturn;
@@ -1389,7 +1389,7 @@ void DoSwitchObjectInfo (void)
void DoTriggerObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr, roomStr, tempStr, objStr;
long delayIs;
short item, floor, suite;
@@ -1545,7 +1545,7 @@ void DoTriggerObjectInfo (void)
void DoLightObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
short item, initial;
Boolean leaving, doReturn;
@@ -1631,7 +1631,7 @@ void DoLightObjectInfo (void)
void DoApplianceObjectInfo (short what)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
long delay;
short item, initial;
@@ -1747,7 +1747,7 @@ void DoApplianceObjectInfo (short what)
void DoMicrowaveObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
short item, initial, kills;
Boolean leaving, doReturn;
@@ -1871,7 +1871,7 @@ void DoMicrowaveObjectInfo (void)
void DoGreaseObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
short item;
Boolean leaving, wasSpilled, doReturn;
@@ -1945,7 +1945,7 @@ void DoGreaseObjectInfo (void)
void DoInvisBonusObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
short item;
Boolean leaving, doReturn;
@@ -2058,7 +2058,7 @@ void DoInvisBonusObjectInfo (void)
void DoTransObjectInfo (short what)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr, roomStr, tempStr, objStr;
short item, floor, suite;
Boolean leaving, doLink, doGoTo, doReturn, wasState;
@@ -2181,7 +2181,7 @@ void DoTransObjectInfo (short what)
void DoEnemyObjectInfo (short what)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
long delay;
short item, initial;
@@ -2291,7 +2291,7 @@ void DoEnemyObjectInfo (short what)
void DoFlowerObjectInfo (void)
{
- DialogPtr infoDial;
+ Dialog *infoDial;
Str255 numberStr, kindStr;
short item, flower;
Boolean leaving, doReturn;
diff --git a/GpApp/Play.cpp b/GpApp/Play.cpp
index 406e4fc..2e71be3 100644
--- a/GpApp/Play.cpp
+++ b/GpApp/Play.cpp
@@ -247,7 +247,7 @@ void NewGame (short mode)
}
NilSavedMaps();
SetPortWindowPort(mainWindow);
- BlackenScoreboard(mainWindow->GetDrawSurface());
+
UpdateMenus(false);
if (!gameOver)
diff --git a/GpApp/RoomInfo.cpp b/GpApp/RoomInfo.cpp
index 79b9446..5f402dd 100644
--- a/GpApp/RoomInfo.cpp
+++ b/GpApp/RoomInfo.cpp
@@ -38,13 +38,13 @@
#define kFloorSupportCheck 12
-void UpdateRoomInfoDialog (DialogPtr);
+void UpdateRoomInfoDialog (Dialog *);
void DragMiniTile (DrawSurface *, Point, short *);
void HiliteTileOver (DrawSurface *, Point);
-Boolean RoomFilter (DialogPtr, EventRecord *, short *);
+Boolean RoomFilter (Dialog *, EventRecord *, short *);
short ChooseOriginalArt (short);
-void UpdateOriginalArt (DialogPtr);
-Boolean OriginalArtFilter (DialogPtr, EventRecord *, short *);
+void UpdateOriginalArt (Dialog *);
+Boolean OriginalArtFilter (Dialog *, EventRecord *, short *);
Boolean PictIDExists (short);
short GetFirstPICT (void);
void BitchAboutPICTNotFound (void);
@@ -66,7 +66,7 @@ extern short houseResFork, lastBackground;
//-------------------------------------------------------------- UpdateRoomInfoDialog
#ifndef COMPILEDEMO
-void UpdateRoomInfoDialog (DialogPtr theDialog)
+void UpdateRoomInfoDialog (Dialog *theDialog)
{
Rect src, dest;
short i;
@@ -346,7 +346,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
//-------------------------------------------------------------- RoomFilter
#ifndef COMPILEDEMO
-Boolean RoomFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean RoomFilter (Dialog *dial, EventRecord *event, short *item)
{
Point mouseIs;
short newTileOver;
@@ -428,7 +428,7 @@ void DoRoomInfo (void)
{
#ifndef COMPILEDEMO
#define kBackgroundsMenuID 140
- DialogPtr roomInfoDialog;
+ Dialog *roomInfoDialog;
MenuHandle backgroundsMenu;
Str255 floorStr, suiteStr, objectsStr, tempStr;
short item, i, newBack;
@@ -609,7 +609,7 @@ void DoRoomInfo (void)
//-------------------------------------------------------------- UpdateOriginalArt
#ifndef COMPILEDEMO
-void UpdateOriginalArt (DialogPtr theDialog)
+void UpdateOriginalArt (Dialog *theDialog)
{
Pattern dummyPattern;
@@ -663,7 +663,7 @@ void UpdateOriginalArt (DialogPtr theDialog)
//-------------------------------------------------------------- OriginalArtFilter
#ifndef COMPILEDEMO
-Boolean OriginalArtFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean OriginalArtFilter (Dialog *dial, EventRecord *event, short *item)
{
Point mouseIs;
@@ -746,7 +746,7 @@ Boolean OriginalArtFilter (DialogPtr dial, EventRecord *event, short *item)
#ifndef COMPILEDEMO
short ChooseOriginalArt (short was)
{
- DialogPtr theDialog;
+ Dialog *theDialog;
long longID;
short item, newPictID, tempShort, wasPictID;
Boolean leaving;
diff --git a/GpApp/SelectHouse.cpp b/GpApp/SelectHouse.cpp
index 28082b6..0f59a4b 100644
--- a/GpApp/SelectHouse.cpp
+++ b/GpApp/SelectHouse.cpp
@@ -39,10 +39,10 @@
#define kMaxExtraHouses 8
-void UpdateLoadDialog (DialogPtr);
-void PageUpHouses (DialogPtr);
-void PageDownHouses (DialogPtr);
-Boolean LoadFilter (DialogPtr, EventRecord *, short *);
+void UpdateLoadDialog (Dialog *);
+void PageUpHouses (Dialog *);
+void PageDownHouses (Dialog *);
+Boolean LoadFilter (Dialog *, EventRecord *, short *);
void SortHouseList (void);
void DoDirSearch (void);
@@ -63,7 +63,7 @@ extern UInt32 doubleTime;
//-------------------------------------------------------------- UpdateLoadWindow
#ifndef COMPILEDEMO
-void UpdateLoadDialog (DialogPtr theDialog)
+void UpdateLoadDialog (Dialog *theDialog)
{
Rect tempRect, dialogRect, dummyRect;
short houseStart, houseStop, i, wasResFile, isResFile, count;
@@ -138,7 +138,7 @@ void UpdateLoadDialog (DialogPtr theDialog)
//-------------------------------------------------------------- PageUpHouses
#ifndef COMPILEDEMO
-void PageUpHouses (DialogPtr theDial)
+void PageUpHouses (Dialog *theDial)
{
Rect tempRect;
DrawSurface *surface = theDial->GetWindow()->GetDrawSurface();
@@ -172,7 +172,7 @@ void PageUpHouses (DialogPtr theDial)
//-------------------------------------------------------------- PageDownHouses
#ifndef COMPILEDEMO
-void PageDownHouses (DialogPtr theDial)
+void PageDownHouses (Dialog *theDial)
{
Rect tempRect;
DrawSurface *surface = theDial->GetWindow()->GetDrawSurface();
@@ -205,7 +205,7 @@ void PageDownHouses (DialogPtr theDial)
//-------------------------------------------------------------- LoadFilter
#ifndef COMPILEDEMO
-Boolean LoadFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean LoadFilter (Dialog *dial, EventRecord *event, short *item)
{
short screenCount, i, wasIndex;
@@ -364,7 +364,7 @@ Boolean LoadFilter (DialogPtr dial, EventRecord *event, short *item)
void DoLoadHouse (void)
{
Rect tempRect;
- DialogPtr theDial;
+ Dialog *theDial;
short i, item, wasIndex, screenCount;
Boolean leaving, whoCares;
ModalFilterUPP loadFilterUPP;
diff --git a/GpApp/Settings.cpp b/GpApp/Settings.cpp
index 1eb99d2..d080602 100644
--- a/GpApp/Settings.cpp
+++ b/GpApp/Settings.cpp
@@ -59,29 +59,29 @@
#define kDoBitchDlgsCheck 14
-void SetBrainsToDefaults (DialogPtr);
-void UpdateSettingsBrains (DialogPtr);
-Boolean BrainsFilter (DialogPtr, EventRecord *, short *);
+void SetBrainsToDefaults (Dialog *);
+void UpdateSettingsBrains (Dialog *);
+Boolean BrainsFilter (Dialog *, EventRecord *, short *);
void DoBrainsPrefs (void);
-void SetControlsToDefaults (DialogPtr);
-void UpdateControlKeyName (DialogPtr);
-void UpdateSettingsControl (DialogPtr);
-Boolean ControlFilter (DialogPtr, EventRecord *, short *);
+void SetControlsToDefaults (Dialog *);
+void UpdateControlKeyName (Dialog *);
+void UpdateSettingsControl (Dialog *);
+Boolean ControlFilter (Dialog *, EventRecord *, short *);
void DoControlPrefs (void);
-void SoundDefaults (DialogPtr);
-void UpdateSettingsSound (DialogPtr);
+void SoundDefaults (Dialog *);
+void UpdateSettingsSound (Dialog *);
void HandleSoundMusicChange (short, Boolean);
-Boolean SoundFilter (DialogPtr, EventRecord *, short *);
+Boolean SoundFilter (Dialog *, EventRecord *, short *);
void DoSoundPrefs (void);
void DisplayDefaults (void);
-void FrameDisplayIcon (DialogPtr);
-void DisplayUpdate (DialogPtr);
-Boolean DisplayFilter (DialogPtr, EventRecord *, short *);
+void FrameDisplayIcon (Dialog *);
+void DisplayUpdate (Dialog *);
+Boolean DisplayFilter (Dialog *, EventRecord *, short *);
void DoDisplayPrefs (void);
void SetAllDefaults (void);
void FlashSettingsButton (short);
-void UpdateSettingsMain (DialogPtr);
-Boolean PrefsFilter (DialogPtr, EventRecord *, short *);
+void UpdateSettingsMain (Dialog *);
+Boolean PrefsFilter (Dialog *, EventRecord *, short *);
void BitchAboutChanges (void);
@@ -105,7 +105,7 @@ extern Boolean changeLockStateOfHouse, saveHouseLocked, doPrettyMap;
//============================================================== Functions
//-------------------------------------------------------------- SetBrainsToDefaults
-void SetBrainsToDefaults (DialogPtr theDialog)
+void SetBrainsToDefaults (Dialog *theDialog)
{
SetDialogNumToStr(theDialog, kMaxFilesItem, 24L);
#ifdef powerc
@@ -130,7 +130,7 @@ void SetBrainsToDefaults (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateSettingsBrains
-void UpdateSettingsBrains (DialogPtr theDialog)
+void UpdateSettingsBrains (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -143,7 +143,7 @@ void UpdateSettingsBrains (DialogPtr theDialog)
//-------------------------------------------------------------- BrainsFilter
-Boolean BrainsFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean BrainsFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -221,7 +221,7 @@ Boolean BrainsFilter (DialogPtr dial, EventRecord *event, short *item)
void DoBrainsPrefs (void)
{
- DialogPtr prefDlg;
+ Dialog *prefDlg;
long tempLong;
short itemHit, wasMaxFiles;
Boolean leaving;
@@ -325,7 +325,7 @@ void DoBrainsPrefs (void)
//-------------------------------------------------------------- SetControlsToDefaults
-void SetControlsToDefaults (DialogPtr theDialog)
+void SetControlsToDefaults (Dialog *theDialog)
{
PasStringCopy(PSTR("lf arrow"), tempLeftStr);
PasStringCopy(PSTR("rt arrow"), tempRightStr);
@@ -342,7 +342,7 @@ void SetControlsToDefaults (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateControlKeyName
-void UpdateControlKeyName (DialogPtr theDialog)
+void UpdateControlKeyName (Dialog *theDialog)
{
DrawDialogUserText(theDialog, kRightControl + 4, tempRightStr, whichCtrl == 0);
DrawDialogUserText(theDialog, kLeftControl + 4, tempLeftStr, whichCtrl == 1);
@@ -352,7 +352,7 @@ void UpdateControlKeyName (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateSettingsControl
-void UpdateSettingsControl (DialogPtr theDialog)
+void UpdateSettingsControl (Dialog *theDialog)
{
short i;
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
@@ -385,7 +385,7 @@ void UpdateSettingsControl (DialogPtr theDialog)
//-------------------------------------------------------------- ControlFilter
-Boolean ControlFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean ControlFilter (Dialog *dial, EventRecord *event, short *item)
{
intptr_t wasKeyMap;
@@ -508,7 +508,7 @@ Boolean ControlFilter (DialogPtr dial, EventRecord *event, short *item)
void DoControlPrefs (void)
{
- DialogPtr prefDlg;
+ Dialog *prefDlg;
short i, itemHit;
Boolean leaving;
ModalFilterUPP controlFilterUPP;
@@ -614,7 +614,7 @@ void DoControlPrefs (void)
//-------------------------------------------------------------- SoundDefaults
-void SoundDefaults (DialogPtr theDialog)
+void SoundDefaults (Dialog *theDialog)
{
wasIdle = true;
wasPlay = true;
@@ -627,7 +627,7 @@ void SoundDefaults (DialogPtr theDialog)
//-------------------------------------------------------------- UpdateSettingsSound
-void UpdateSettingsSound (DialogPtr theDialog)
+void UpdateSettingsSound (Dialog *theDialog)
{
short howLoudNow;
@@ -676,7 +676,7 @@ void HandleSoundMusicChange (short newVolume, Boolean sayIt)
//-------------------------------------------------------------- SoundFilter
-Boolean SoundFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean SoundFilter (Dialog *dial, EventRecord *event, short *item)
{
short newVolume;
@@ -772,7 +772,7 @@ Boolean SoundFilter (DialogPtr dial, EventRecord *event, short *item)
void DoSoundPrefs (void)
{
Rect tempRect;
- DialogPtr prefDlg;
+ Dialog *prefDlg;
short wasLoudness, tempVolume;
PLError_t theErr;
short itemHit;
@@ -907,7 +907,7 @@ void DisplayDefaults (void)
//-------------------------------------------------------------- FrameDisplayIcon
-void FrameDisplayIcon (DialogPtr theDialog)
+void FrameDisplayIcon (Dialog *theDialog)
{
Rect theRect;
@@ -941,7 +941,7 @@ void FrameDisplayIcon (DialogPtr theDialog)
//-------------------------------------------------------------- DisplayUpdate
-void DisplayUpdate (DialogPtr theDialog)
+void DisplayUpdate (Dialog *theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
@@ -962,7 +962,7 @@ void DisplayUpdate (DialogPtr theDialog)
//-------------------------------------------------------------- DisplayFilter
-Boolean DisplayFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean DisplayFilter (Dialog *dial, EventRecord *event, short *item)
{
switch (event->what)
{
@@ -1118,7 +1118,7 @@ Boolean DisplayFilter (DialogPtr dial, EventRecord *event, short *item)
void DoDisplayPrefs (void)
{
- DialogPtr prefDlg;
+ Dialog *prefDlg;
short itemHit, wasNeighbors;
Boolean leaving;
ModalFilterUPP displayFilterUPP;
@@ -1297,7 +1297,7 @@ void FlashSettingsButton (short who)
//-------------------------------------------------------------- UpdateSettingsMain
-void UpdateSettingsMain (DialogPtr theDialog)
+void UpdateSettingsMain (Dialog *theDialog)
{
Str255 theStr;
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
@@ -1323,7 +1323,7 @@ void UpdateSettingsMain (DialogPtr theDialog)
//-------------------------------------------------------------- PrefsFilter
-Boolean PrefsFilter (DialogPtr dial, EventRecord *event, short *item)
+Boolean PrefsFilter (Dialog *dial, EventRecord *event, short *item)
{
Point testPt;
short i;
@@ -1410,7 +1410,7 @@ Boolean PrefsFilter (DialogPtr dial, EventRecord *event, short *item)
void DoSettingsMain (void)
{
#define kAllDefaultsButton 11
- DialogPtr prefDlg;
+ Dialog *prefDlg;
short itemHit;
Boolean leaving;
ModalFilterUPP prefsFilterUPP;
diff --git a/PortabilityLayer/DialogManager.cpp b/PortabilityLayer/DialogManager.cpp
index 9324f9f..c15b208 100644
--- a/PortabilityLayer/DialogManager.cpp
+++ b/PortabilityLayer/DialogManager.cpp
@@ -1,5 +1,6 @@
#include "DialogManager.h"
#include "ResourceManager.h"
+#include "PLArrayView.h"
#include "PLDialogs.h"
#include "PLBigEndian.h"
#include "PLPasStr.h"
@@ -13,21 +14,247 @@
namespace PortabilityLayer
{
+ namespace SerializedDialogItemTypeCodes
+ {
+ enum SerializedDialogItemTypeCode
+ {
+ kUserItem = 0x00,
+ kButton = 0x04,
+ kCheckBox = 0x05,
+ kRadioButton = 0x06,
+ kCustomControl = 0x07,
+ kLabel = 0x08,
+ kEditBox = 0x10,
+ kIcon = 0x20,
+ kImage = 0x40,
+ };
+ }
+
+ typedef SerializedDialogItemTypeCodes::SerializedDialogItemTypeCode SerializedDialogItemTypeCode_t;
+
+ struct DialogTemplateItem
+ {
+ Rect m_rect;
+ int16_t m_id;
+ uint8_t m_serializedType;
+ bool m_enabled;
+ Str255 m_name;
+ };
+
+ class DialogItemImpl : public DialogItem
+ {
+ public:
+ DialogItemImpl(const DialogTemplateItem &templateItem);
+ virtual ~DialogItemImpl();
+
+ Rect GetRect() const override;
+
+ virtual bool Init() = 0;
+ virtual void Destroy() = 0;
+
+ protected:
+ Rect m_rect;
+ int16_t m_id;
+ bool m_enabled;
+ PascalStr<255> m_name;
+ };
+
+ template
+ class DialogItemSpec : public DialogItemImpl
+ {
+ public:
+ DialogItemSpec(const DialogTemplateItem &tmpl)
+ : DialogItemImpl(tmpl)
+ {
+ }
+
+ void Destroy() override
+ {
+ static_cast(this)->~T();
+ free(static_cast(this));
+ }
+
+ static DialogItemSpec *Create(const DialogTemplateItem &tmpl)
+ {
+ void *storage = malloc(sizeof(T));
+ if (!storage)
+ return nullptr;
+
+ T *item = new (storage) T(tmpl);
+
+ DialogItemImpl *dItem = static_cast(item);
+ if (!dItem->Init())
+ {
+ dItem->Destroy();
+ return nullptr;
+ }
+
+ return item;
+ }
+ };
+
+ class DialogItem_EditBox final : public DialogItemSpec
+ {
+ public:
+ explicit DialogItem_EditBox(const DialogTemplateItem &tmpl);
+ bool Init() override;
+ };
+
+ class DialogItem_Label final : public DialogItemSpec
+ {
+ public:
+ explicit DialogItem_Label(const DialogTemplateItem &tmpl);
+ bool Init() override;
+ };
+
+ class DialogItem_Unknown final : public DialogItemSpec
+ {
+ public:
+ explicit DialogItem_Unknown(const DialogTemplateItem &tmpl);
+ bool Init() override;
+ };
+
+ class DialogTemplate final
+ {
+ public:
+ DialogTemplate(DialogTemplateItem *itemStorage, size_t numItems);
+ void DeserializeItems(const uint8_t *data);
+ void Destroy();
+
+ ArrayView GetItems() const;
+
+ private:
+ DialogTemplateItem *m_items;
+ size_t m_numItems;
+ };
+
class DialogImpl final : public Dialog
{
public:
void Destroy() override;
Window *GetWindow() const override;
+ ArrayView GetItems() const override;
- static DialogImpl *Create(Window *window);
+ bool Populate(DialogTemplate *tmpl);
+
+ static DialogImpl *Create(Window *window, size_t numItems);
private:
- explicit DialogImpl(Window *window);
+ explicit DialogImpl(Window *window, DialogItem **items, size_t numItems);
~DialogImpl();
Window *m_window;
+ DialogItem **m_items;
+ size_t m_numItems;
};
+
+ DialogItemImpl::DialogItemImpl(const DialogTemplateItem &templateItem)
+ : m_enabled(templateItem.m_enabled)
+ , m_id(templateItem.m_id)
+ , m_name(PLPasStr(templateItem.m_name))
+ , m_rect(templateItem.m_rect)
+ {
+ }
+
+ DialogItemImpl::~DialogItemImpl()
+ {
+ }
+
+ Rect DialogItemImpl::GetRect() const
+ {
+ return m_rect;
+ }
+
+ DialogItem_EditBox::DialogItem_EditBox(const DialogTemplateItem &tmpl)
+ : DialogItemSpec(tmpl)
+ {
+ }
+
+ bool DialogItem_EditBox::Init()
+ {
+ return true;
+ }
+
+ DialogItem_Label::DialogItem_Label(const DialogTemplateItem &tmpl)
+ : DialogItemSpec(tmpl)
+ {
+ }
+
+ bool DialogItem_Label::Init()
+ {
+ return true;
+ }
+
+ DialogItem_Unknown::DialogItem_Unknown(const DialogTemplateItem &tmpl)
+ : DialogItemSpec(tmpl)
+ {
+ }
+
+ bool DialogItem_Unknown::Init()
+ {
+ return true;
+ }
+
+ DialogTemplate::DialogTemplate(DialogTemplateItem *itemStorage, size_t numItems)
+ : m_items(itemStorage)
+ , m_numItems(numItems)
+ {
+ }
+
+ void DialogTemplate::DeserializeItems(const uint8_t *data)
+ {
+ for (size_t i = 0; i < m_numItems; i++)
+ {
+ BERect itemRect;
+ uint8_t itemType;
+
+ data += 4; // Unused
+
+ memcpy(&itemRect, data, 8);
+ data += 8;
+
+ itemType = *data;
+ data++;
+
+ uint8_t nameLength = *data;
+ data++;
+
+ const uint8_t *nameBytes = data;
+
+ size_t nameLengthPadded = nameLength;
+ if ((nameLength & 1) == 1)
+ nameLengthPadded++;
+
+ data += nameLengthPadded;
+
+ DialogTemplateItem &item = m_items[i];
+ item.m_rect = itemRect.ToRect();
+ item.m_id = 0;
+ item.m_serializedType = (itemType & 0x7f);
+ item.m_enabled = ((itemType & 0x80) == 0);
+ item.m_name[0] = nameLength;
+ memcpy(item.m_name + 1, nameBytes, nameLength);
+
+ if (item.m_serializedType == SerializedDialogItemTypeCodes::kCustomControl || item.m_serializedType == SerializedDialogItemTypeCodes::kImage || item.m_serializedType == SerializedDialogItemTypeCodes::kIcon)
+ {
+ memcpy(&item.m_id, item.m_name + 1, 2);
+ ByteSwap::BigInt16(item.m_id);
+ }
+ }
+ }
+
+ void DialogTemplate::Destroy()
+ {
+ this->~DialogTemplate();
+ free(this);
+ }
+
+ ArrayView DialogTemplate::GetItems() const
+ {
+ return ArrayView(m_items, m_numItems);
+ }
+
void DialogImpl::Destroy()
{
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(m_window);
@@ -41,29 +268,85 @@ namespace PortabilityLayer
return m_window;
}
- DialogImpl *DialogImpl::Create(Window *window)
+ ArrayView DialogImpl::GetItems() const
{
- void *storage = malloc(sizeof(DialogImpl));
+ ArrayView iter(m_items, m_numItems);
+ return ArrayView(m_items, m_numItems);
+ }
+
+ bool DialogImpl::Populate(DialogTemplate *tmpl)
+ {
+ ArrayView templateItems = tmpl->GetItems();
+
+ const size_t numItems = templateItems.Count();
+
+ for (size_t i = 0; i < numItems; i++)
+ {
+ const DialogTemplateItem &templateItem = templateItems[i];
+
+ DialogItem *ditem = nullptr;
+
+ switch (templateItem.m_serializedType)
+ {
+ case SerializedDialogItemTypeCodes::kLabel:
+ ditem = DialogItem_Label::Create(templateItem);
+ break;
+ case SerializedDialogItemTypeCodes::kEditBox:
+ ditem = DialogItem_EditBox::Create(templateItem);
+ break;
+ default:
+ ditem = DialogItem_Unknown::Create(templateItem);
+ break;
+ }
+
+ if (!ditem)
+ return false;
+
+ m_items[i] = ditem;
+ }
+
+ return true;
+ }
+
+ DialogImpl *DialogImpl::Create(Window *window, size_t numItems)
+ {
+ size_t alignedSize = sizeof(DialogImpl) + PL_SYSTEM_MEMORY_ALIGNMENT + 1;
+ alignedSize -= alignedSize % PL_SYSTEM_MEMORY_ALIGNMENT;
+
+ const size_t itemsSize = sizeof(DialogItemImpl) * numItems;
+
+ void *storage = malloc(alignedSize + itemsSize);
if (!storage)
return nullptr;
- return new (storage) DialogImpl(window);
+ DialogItem **itemsList = reinterpret_cast(static_cast(storage) + alignedSize);
+ for (size_t i = 0; i < numItems; i++)
+ itemsList[i] = nullptr;
+
+ return new (storage) DialogImpl(window, itemsList, numItems);
}
- DialogImpl::DialogImpl(Window *window)
+ DialogImpl::DialogImpl(Window *window, DialogItem **itemsList, size_t numItems)
: m_window(window)
+ , m_items(itemsList)
+ , m_numItems(numItems)
{
}
DialogImpl::~DialogImpl()
{
+ for (size_t i = 0; i < m_numItems; i++)
+ {
+ if (DialogItem *item = m_items[i])
+ static_cast(item)->Destroy();
+ }
}
// DLOG resource format:
// DialogResourceDataHeader
// Variable-length PStr: Title
// Optional: Positioning (2 byte mask)
-
+
struct DialogResourceDataHeader
{
BERect m_rect;
@@ -80,6 +363,7 @@ namespace PortabilityLayer
{
public:
Dialog *LoadDialog(int16_t resID, Window *behindWindow) override;
+ DialogTemplate *LoadDialogTemplate(int16_t resID);
static DialogManagerImpl *GetInstance();
@@ -110,31 +394,83 @@ namespace PortabilityLayer
dlogH.Dispose();
+ DialogTemplate *dtemplate = LoadDialogTemplate(header.m_itemsResID);
+ const size_t numItems = (dtemplate == nullptr) ? 0 : dtemplate->GetItems().Count();
+
if (!rect.IsValid())
+ {
+ dtemplate->Destroy();
return nullptr;
+ }
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));
Window *window = wm->CreateWindow(wdef);
if (!window)
+ {
+ dtemplate->Destroy();
return nullptr;
+ }
wm->PutWindowBehind(window, behindWindow);
- THandle dtemplateH = rm->GetResource('DITL', header.m_itemsResID).StaticCast();
-
- Dialog *dialog = DialogImpl::Create(window);
+ DialogImpl *dialog = DialogImpl::Create(window, numItems);
if (!dialog)
{
+ dtemplate->Destroy();
wm->DestroyWindow(window);
return nullptr;
}
+ if (!dialog->Populate(dtemplate))
+ {
+ dialog->Destroy();
+ dtemplate->Destroy();
+ wm->DestroyWindow(window);
+
+ return nullptr;
+ }
+
return dialog;
}
+ DialogTemplate *DialogManagerImpl::LoadDialogTemplate(int16_t resID)
+ {
+ ResourceManager *rm = ResourceManager::GetInstance();
+
+ THandle dtemplateH = rm->GetResource('DITL', resID).StaticCast();
+
+ if (!dtemplateH)
+ return nullptr;
+
+ uint16_t numItems;
+ memcpy(&numItems, *dtemplateH, 2);
+ ByteSwap::BigUInt16(numItems);
+
+ size_t dtlAlignedSize = sizeof(DialogTemplate) + PL_SYSTEM_MEMORY_ALIGNMENT - 1;
+ dtlAlignedSize -= dtlAlignedSize % PL_SYSTEM_MEMORY_ALIGNMENT;
+
+ const size_t dtlItemSize = sizeof(DialogTemplateItem) * numItems;
+
+ void *storage = malloc(dtlAlignedSize + dtlItemSize);
+ if (!storage)
+ {
+ dtemplateH.Dispose();
+ return nullptr;
+ }
+
+ uint8_t *itemsLoc = static_cast(storage) + dtlAlignedSize;
+
+ DialogTemplate *dtemplate = new (storage) DialogTemplate(reinterpret_cast(itemsLoc), numItems);
+ dtemplate->DeserializeItems((*dtemplateH) + 2);
+
+ dtemplateH.Dispose();
+
+ return dtemplate;
+ }
+
DialogManagerImpl *DialogManagerImpl::GetInstance()
{
return &ms_instance;
diff --git a/PortabilityLayer/PLArrayView.h b/PortabilityLayer/PLArrayView.h
new file mode 100644
index 0000000..67ffb78
--- /dev/null
+++ b/PortabilityLayer/PLArrayView.h
@@ -0,0 +1,64 @@
+#pragma once
+
+#include
+
+template
+class ArrayViewIterator;
+
+template
+class ArrayView
+{
+public:
+ ArrayView(const T *items, size_t count);
+ ArrayView(const ArrayView &other);
+
+ size_t Count() const;
+ const T &operator[](size_t index) const;
+
+ ArrayViewIterator begin() const;
+ ArrayViewIterator end() const;
+
+private:
+ const T *m_items;
+ size_t m_count;
+};
+
+#include "PLArrayViewIterator.h"
+
+template
+inline ArrayView::ArrayView(const T *items, size_t count)
+ : m_items(items)
+ , m_count(count)
+{
+}
+
+template
+inline ArrayView::ArrayView(const ArrayView &other)
+ : m_items(other.m_items)
+ , m_count(other.m_count)
+{
+}
+
+template
+inline size_t ArrayView::Count() const
+{
+ return m_count;
+}
+
+template
+const T &ArrayView::operator[](size_t index) const
+{
+ return m_items[index];
+}
+
+template
+inline ArrayViewIterator ArrayView::begin() const
+{
+ return ArrayViewIterator(m_items);
+}
+
+template
+inline ArrayViewIterator ArrayView::end() const
+{
+ return ArrayViewIterator(m_items + m_count);
+}
diff --git a/PortabilityLayer/PLArrayViewIterator.h b/PortabilityLayer/PLArrayViewIterator.h
new file mode 100644
index 0000000..49951f6
--- /dev/null
+++ b/PortabilityLayer/PLArrayViewIterator.h
@@ -0,0 +1,102 @@
+#pragma once
+
+#include
+
+template
+class ArrayViewIterator
+{
+public:
+ ArrayViewIterator(T *item);
+ ArrayViewIterator(const ArrayViewIterator &other);
+
+ ArrayViewIterator operator++(int);
+ ArrayViewIterator &operator++();
+
+ ArrayViewIterator operator--(int);
+ ArrayViewIterator &operator--();
+
+ ArrayViewIterator &operator+=(ptrdiff_t delta);
+ ArrayViewIterator &operator-=(ptrdiff_t delta);
+
+ bool operator==(const ArrayViewIterator &other) const;
+ bool operator!=(const ArrayViewIterator &other) const;
+
+ operator T*() const;
+
+private:
+ T *m_iter;
+};
+
+template
+inline ArrayViewIterator::ArrayViewIterator(T *item)
+ : m_iter(item)
+{
+}
+
+template
+inline ArrayViewIterator::ArrayViewIterator(const ArrayViewIterator &other)
+ : m_iter(other.m_iter)
+{
+}
+
+template
+inline ArrayViewIterator ArrayViewIterator::operator++(int)
+{
+ ArrayViewIterator copy = *this;
+ m_iter++;
+ return copy;
+}
+
+template
+inline ArrayViewIterator &ArrayViewIterator::operator++()
+{
+ m_iter++;
+ return *this;
+}
+
+template
+inline ArrayViewIterator ArrayViewIterator::operator--(int)
+{
+ ArrayViewIterator copy = *this;
+ m_iter--;
+ return copy;
+}
+
+template
+inline ArrayViewIterator &ArrayViewIterator::operator--()
+{
+ m_iter--;
+ return *this;
+}
+
+template
+inline ArrayViewIterator &ArrayViewIterator::operator+=(ptrdiff_t delta)
+{
+ m_iter += delta;
+ return *this;
+}
+
+template
+inline ArrayViewIterator &ArrayViewIterator::operator-=(ptrdiff_t delta)
+{
+ m_iter += delta;
+ return *this;
+}
+
+template
+inline bool ArrayViewIterator::operator==(const ArrayViewIterator &other) const
+{
+ return m_iter == other.m_iter;
+}
+
+template
+inline bool ArrayViewIterator::operator!=(const ArrayViewIterator &other) const
+{
+ return m_iter == other.m_iter;
+}
+
+template
+inline ArrayViewIterator::operator T*() const
+{
+ return m_iter;
+}
diff --git a/PortabilityLayer/PLCore.cpp b/PortabilityLayer/PLCore.cpp
index c251475..c9d8d02 100644
--- a/PortabilityLayer/PLCore.cpp
+++ b/PortabilityLayer/PLCore.cpp
@@ -1020,5 +1020,5 @@ Window::Window()
DrawSurface *Window::GetDrawSurface() const
{
- return const_cast(&m_graf);
+ return const_cast(&m_graf);
}
diff --git a/PortabilityLayer/PLDialogs.cpp b/PortabilityLayer/PLDialogs.cpp
index a991e5d..288c57b 100644
--- a/PortabilityLayer/PLDialogs.cpp
+++ b/PortabilityLayer/PLDialogs.cpp
@@ -1,23 +1,23 @@
#include "PLDialogs.h"
-void DrawDialog(DialogPtr dialog)
+void DrawDialog(Dialog *dialog)
{
PL_NotYetImplemented();
}
-DialogPtr GetNewDialog(int resID, void *unknown, WindowPtr behind)
+Dialog *GetNewDialog(int resID, void *unknown, WindowPtr behind)
{
PL_NotYetImplemented();
return nullptr;
}
-DrawSurface *GetDialogPort(DialogPtr dialog)
+DrawSurface *GetDialogPort(Dialog *dialog)
{
PL_NotYetImplemented();
return nullptr;
}
-void GetDialogItem(DialogPtr dialog, int index, short *itemType, THandle *itemHandle, Rect *itemRect)
+void GetDialogItem(Dialog *dialog, int index, short *itemType, THandle *itemHandle, Rect *itemRect)
{
PL_NotYetImplemented();
}
@@ -27,7 +27,7 @@ void GetDialogItemText(THandle handle, StringPtr str)
PL_NotYetImplemented();
}
-void SetDialogItem(DialogPtr dialog, int index, short itemType, THandle itemHandle, const Rect *itemRect)
+void SetDialogItem(Dialog *dialog, int index, short itemType, THandle itemHandle, const Rect *itemRect)
{
PL_NotYetImplemented();
}
@@ -37,7 +37,7 @@ void SetDialogItemText(THandle handle, const PLPasStr &str)
PL_NotYetImplemented();
}
-void SelectDialogItemText(DialogPtr dialog, int item, int firstSelChar, int lastSelCharExclusive)
+void SelectDialogItemText(Dialog *dialog, int item, int firstSelChar, int lastSelCharExclusive)
{
PL_NotYetImplemented();
}
@@ -52,7 +52,7 @@ void ModalDialog(ModalFilterUPP filter, short *item)
PL_NotYetImplemented();
}
-void DisposeDialog(DialogPtr dialog)
+void DisposeDialog(Dialog *dialog)
{
PL_NotYetImplemented();
}
@@ -62,12 +62,12 @@ void DisposeModalFilterUPP(ModalFilterUPP upp)
PL_NotYetImplemented();
}
-void ShowDialogItem(DialogPtr dialog, int item)
+void ShowDialogItem(Dialog *dialog, int item)
{
PL_NotYetImplemented();
}
-void HideDialogItem(DialogPtr dialog, int item)
+void HideDialogItem(Dialog *dialog, int item)
{
PL_NotYetImplemented();
}
diff --git a/PortabilityLayer/PLDialogs.h b/PortabilityLayer/PLDialogs.h
index f27c688..1816834 100644
--- a/PortabilityLayer/PLDialogs.h
+++ b/PortabilityLayer/PLDialogs.h
@@ -4,19 +4,22 @@
#include "PLCore.h"
+template
+class ArrayView;
+
class PLPasStr;
struct Control;
+struct DialogItem
+{
+ virtual Rect GetRect() const = 0;
+};
+
struct Dialog
{
virtual void Destroy() = 0;
virtual Window *GetWindow() const = 0;
-};
-
-struct DialogTemplate
-{
- // FIXME: Audit
- Rect boundsRect;
+ virtual ArrayView GetItems() const = 0;
};
enum TEMode
@@ -24,33 +27,28 @@ enum TEMode
teCenter
};
-typedef Dialog *DialogPtr;
+typedef Boolean(*ModalFilterUPP)(Dialog *dial, EventRecord *event, short *item);
-typedef THandle DialogTHndl;
+void DrawDialog(Dialog *dialog);
+DrawSurface *GetDialogPort(Dialog *dialog);
-
-typedef Boolean(*ModalFilterUPP)(DialogPtr dial, EventRecord *event, short *item);
-
-void DrawDialog(DialogPtr dialog);
-DrawSurface *GetDialogPort(DialogPtr dialog);
-
-void GetDialogItem(DialogPtr dialog, int index, short *itemType, THandle *itemHandle, Rect *itemRect);
+void GetDialogItem(Dialog *dialog, int index, short *itemType, THandle *itemHandle, Rect *itemRect);
void GetDialogItemText(THandle handle, StringPtr str);
-void SetDialogItem(DialogPtr dialog, int index, short itemType, THandle itemHandle, const Rect *itemRect);
+void SetDialogItem(Dialog *dialog, int index, short itemType, THandle itemHandle, const Rect *itemRect);
void SetDialogItemText(THandle handle, const PLPasStr &str);
-void SelectDialogItemText(DialogPtr dialog, int item, int firstSelChar, int lastSelCharExclusive);
+void SelectDialogItemText(Dialog *dialog, int item, int firstSelChar, int lastSelCharExclusive);
ModalFilterUPP NewModalFilterUPP(ModalFilterUPP func);
void ModalDialog(ModalFilterUPP filter, short *item);
-void DisposeDialog(DialogPtr dialog);
+void DisposeDialog(Dialog *dialog);
void DisposeModalFilterUPP(ModalFilterUPP upp);
-void ShowDialogItem(DialogPtr dialog, int item);
-void HideDialogItem(DialogPtr dialog, int item);
+void ShowDialogItem(Dialog *dialog, int item);
+void HideDialogItem(Dialog *dialog, int item);
void TETextBox(const PLPasStr &str, short len, const Rect *rect, TEMode teMode);
diff --git a/PortabilityLayer/PLQDraw.cpp b/PortabilityLayer/PLQDraw.cpp
index 06cb656..9cb0214 100644
--- a/PortabilityLayer/PLQDraw.cpp
+++ b/PortabilityLayer/PLQDraw.cpp
@@ -1020,6 +1020,12 @@ void DrawSurface::FrameRect(const Rect &rect)
}
}
+void DrawSurface::FrameRoundRect(const Rect &rect, int quadrantWidth, int quadrantHeight)
+{
+ PL_NotYetImplemented_TODO("RoundRect");
+ this->FrameRect(rect);
+}
+
void DrawSurface::InvertFrameRect(const Rect &rect, const uint8_t *pattern)
{
PL_NotYetImplemented();
diff --git a/PortabilityLayer/PascalStr.h b/PortabilityLayer/PascalStr.h
index cc8af89..9604078 100644
--- a/PortabilityLayer/PascalStr.h
+++ b/PortabilityLayer/PascalStr.h
@@ -1,9 +1,8 @@
#pragma once
-#ifndef __PL_PASCALSTR_H__
-#define __PL_PASCALSTR_H__
-
-#include "UnsafePascalStr.h"
+#include "UnsafePascalStr.h"
+
+class PLPasStr;
namespace PortabilityLayer
{
@@ -12,11 +11,13 @@ namespace PortabilityLayer
{
public:
PascalStr();
- PascalStr(size_t size, const char *str);
+ PascalStr(size_t size, const char *str);
+ explicit PascalStr(const PLPasStr &pstr);
};
}
-#include
+#include
+#include "PLPasStr.h"
namespace PortabilityLayer
{
@@ -31,6 +32,10 @@ namespace PortabilityLayer
: UnsafePascalStr(size, str)
{
}
-}
-#endif
+ template
+ PascalStr::PascalStr(const PLPasStr &pstr)
+ : UnsafePascalStr(pstr.Length(), pstr.Chars())
+ {
+ }
+}
diff --git a/PortabilityLayer/PortabilityLayer.vcxproj b/PortabilityLayer/PortabilityLayer.vcxproj
index 0e11e5a..5da5390 100644
--- a/PortabilityLayer/PortabilityLayer.vcxproj
+++ b/PortabilityLayer/PortabilityLayer.vcxproj
@@ -186,6 +186,8 @@
+
+
diff --git a/PortabilityLayer/PortabilityLayer.vcxproj.filters b/PortabilityLayer/PortabilityLayer.vcxproj.filters
index 4c215b5..08b7465 100644
--- a/PortabilityLayer/PortabilityLayer.vcxproj.filters
+++ b/PortabilityLayer/PortabilityLayer.vcxproj.filters
@@ -402,6 +402,12 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
diff --git a/PortabilityLayer/QDGraf.h b/PortabilityLayer/QDGraf.h
index 38d1005..3c3114e 100644
--- a/PortabilityLayer/QDGraf.h
+++ b/PortabilityLayer/QDGraf.h
@@ -54,6 +54,7 @@ struct DrawSurface final
void FillRect(const Rect &rect);
void FillRectWithPattern8x8(const Rect &rect, const uint8_t *pattern);
void FrameRect(const Rect &rect);
+ void FrameRoundRect(const Rect &rect, int quadrantWidth, int quadrantHeight);
void InvertFrameRect(const Rect &rect, const uint8_t *pattern);
void InvertFillRect(const Rect &rect, const uint8_t *pattern);
diff --git a/PortabilityLayer/SharedTypes.h b/PortabilityLayer/SharedTypes.h
index 2b92ce2..d126438 100644
--- a/PortabilityLayer/SharedTypes.h
+++ b/PortabilityLayer/SharedTypes.h
@@ -26,6 +26,8 @@ struct Rect
bool IsValid() const;
Rect Intersect(const Rect &rect) const;
Rect MakeValid() const;
+ Rect operator-(const Point &point) const;
+ Rect operator+(const Point &point) const;
static Rect Create(int16_t top, int16_t left, int16_t bottom, int16_t right);
static Rect CreateFromPoints(const Point &topLeft, const Point &bottomRight);
@@ -152,6 +154,16 @@ inline Rect Rect::MakeValid() const
return result;
}
+inline Rect Rect::operator-(const Point &point) const
+{
+ return Rect::Create(this->top - point.v, this->left - point.h, this->bottom - point.v, this->right - point.h);
+}
+
+inline Rect Rect::operator+(const Point &point) const
+{
+ return Rect::Create(this->top + point.v, this->left + point.h, this->bottom + point.v, this->right + point.h);
+}
+
inline Rect Rect::Create(int16_t top, int16_t left, int16_t bottom, int16_t right)
{
Rect result;