diff --git a/Aerofoil/Aerofoil.vcxproj b/Aerofoil/Aerofoil.vcxproj
index f91463d..1aaa703 100644
--- a/Aerofoil/Aerofoil.vcxproj
+++ b/Aerofoil/Aerofoil.vcxproj
@@ -170,7 +170,7 @@
-
+
diff --git a/Aerofoil/GpColorCursor_Win32.cpp b/Aerofoil/GpColorCursor_Win32.cpp
index cd23440..17a8c39 100644
--- a/Aerofoil/GpColorCursor_Win32.cpp
+++ b/Aerofoil/GpColorCursor_Win32.cpp
@@ -1,14 +1,14 @@
-#include "GpColorCursor_Win32.h"
+#include "GpCursor_Win32.h"
#include
#include
-void GpColorCursor_Win32::Destroy()
+void GpCursor_Win32::Destroy()
{
this->DecRef();
}
-IGpColorCursor_Win32 *GpColorCursor_Win32::Load(const wchar_t *path)
+IGpCursor_Win32 *GpCursor_Win32::Load(const wchar_t *path)
{
HANDLE imageH = LoadImageW(nullptr, path, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
@@ -16,43 +16,43 @@ IGpColorCursor_Win32 *GpColorCursor_Win32::Load(const wchar_t *path)
return nullptr;
HCURSOR cursor = reinterpret_cast(imageH);
- void *storage = malloc(sizeof(GpColorCursor_Win32));
+ void *storage = malloc(sizeof(GpCursor_Win32));
if (!storage)
{
DestroyCursor(cursor);
return nullptr;
}
- return new (storage) GpColorCursor_Win32(reinterpret_cast(cursor));
+ return new (storage) GpCursor_Win32(reinterpret_cast(cursor));
}
-GpColorCursor_Win32::GpColorCursor_Win32(HCURSOR cursor)
+GpCursor_Win32::GpCursor_Win32(HCURSOR cursor)
: m_cursor(cursor)
, m_refCount(1)
{
}
-GpColorCursor_Win32::~GpColorCursor_Win32()
+GpCursor_Win32::~GpCursor_Win32()
{
DestroyCursor(m_cursor);
}
-const HCURSOR &GpColorCursor_Win32::GetHCursor() const
+const HCURSOR &GpCursor_Win32::GetHCursor() const
{
return m_cursor;
}
-void GpColorCursor_Win32::IncRef()
+void GpCursor_Win32::IncRef()
{
m_refCount++;
}
-void GpColorCursor_Win32::DecRef()
+void GpCursor_Win32::DecRef()
{
m_refCount--;
if (m_refCount == 0)
{
- this->~GpColorCursor_Win32();
+ this->~GpCursor_Win32();
free(this);
}
}
diff --git a/Aerofoil/GpMain_Win32.cpp b/Aerofoil/GpMain_Win32.cpp
index 7766c83..ec3990c 100644
--- a/Aerofoil/GpMain_Win32.cpp
+++ b/Aerofoil/GpMain_Win32.cpp
@@ -1,6 +1,6 @@
#include "GpMain.h"
#include "GpAudioDriverFactory.h"
-#include "GpColorCursor_Win32.h"
+#include "GpCursor_Win32.h"
#include "GpDisplayDriverFactory.h"
#include "GpGlobalConfig.h"
#include "GpFiber_Win32.h"
@@ -390,7 +390,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
g_gpWindowsGlobals.m_baseDir = GpFileSystem_Win32::GetInstance()->GetBasePath();
g_gpWindowsGlobals.m_createFiberFunc = GpFiber_Win32::Create;
- g_gpWindowsGlobals.m_loadColorCursorFunc = GpColorCursor_Win32::Load;
+ g_gpWindowsGlobals.m_loadCursorFunc = GpCursor_Win32::Load;
g_gpWindowsGlobals.m_translateWindowsMessageFunc = TranslateWindowsMessage;
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_D3D11;
diff --git a/ConvertColorCursors/ConvertColorCursors.cpp b/ConvertColorCursors/ConvertColorCursors.cpp
index 75c379b..a0ded11 100644
--- a/ConvertColorCursors/ConvertColorCursors.cpp
+++ b/ConvertColorCursors/ConvertColorCursors.cpp
@@ -1,4 +1,5 @@
#include "CFileStream.h"
+#include "BMPFormat.h"
#include "MMHandleBlock.h"
#include "ResourceCompiledTypeList.h"
#include "ResourceFile.h"
@@ -8,6 +9,7 @@
#include
#include
+#include
#include "stb_image_write.h"
@@ -53,6 +55,14 @@ struct CursorHeader
BEUInt32_t m_cursorResourceID;
};
+struct BWCursor
+{
+ uint8_t m_pixels[32];
+ uint8_t m_mask[32];
+ BEUInt16_t m_hotSpotX;
+ BEUInt16_t m_hotSpotY;
+};
+
struct IconDir
{
uint16_t m_reserved;
@@ -84,6 +94,108 @@ void WriteToFileCallback(void *context, void *data, int size)
fwrite(data, 1, size, static_cast(context));
}
+void WriteToVectorCallback(void *context, void *data, int size)
+{
+ std::vector *vec = static_cast*>(context);
+ for (int i = 0; i < size; i++)
+ vec->push_back(static_cast(data)[i]);
+}
+
+void ConvertBWCursors(PortabilityLayer::ResourceFile *resFile)
+{
+ const PortabilityLayer::ResourceCompiledTypeList *typeList = resFile->GetResourceTypeList('CURS');
+ if (!typeList)
+ return;
+
+ const size_t numRefs = typeList->m_numRefs;
+ for (size_t i = 0; i < numRefs; i++)
+ {
+ const int resID = typeList->m_firstRef[i].m_resID;
+ const THandle resHdl = resFile->LoadResource('CURS', resID);
+ const void *cursorDataBase = *resHdl;
+ const BWCursor *cursorData = static_cast(cursorDataBase);
+
+ char outPathDebug[64];
+ sprintf_s(outPathDebug, "Packaged\\WinCursors\\b%i.bmp", resID);
+
+ char outPath[64];
+ sprintf_s(outPath, "Packaged\\WinCursors\\b%i.cur", resID);
+
+ FILE *outF = nullptr;
+ errno_t outErr = fopen_s(&outF, outPath, "wb");
+
+ if (!outErr)
+ {
+ IconDir iconDir;
+ iconDir.m_reserved = 0;
+ iconDir.m_type = 2;
+ iconDir.m_numImages = 1;
+
+ IconDirEntry iconDirEntry;
+ iconDirEntry.m_width = 16;
+ iconDirEntry.m_height = 16;
+ iconDirEntry.m_numColors = 0;
+ iconDirEntry.m_reserved = 0;
+ iconDirEntry.m_numPlanes_HotSpotX = cursorData->m_hotSpotX;
+ iconDirEntry.m_bpp_HotSpotY = cursorData->m_hotSpotY;
+ iconDirEntry.m_imageDataSize = 0;
+ iconDirEntry.m_imageDataOffset = sizeof(IconDir) + sizeof(IconDirEntry);
+
+ fwrite(&iconDir, 1, sizeof(IconDir), outF);
+ fwrite(&iconDirEntry, 1, sizeof(IconDirEntry), outF);
+
+ long imageDataStart = ftell(outF);
+
+ PortabilityLayer::BitmapInfoHeader bmpHeader;
+ bmpHeader.m_thisStructureSize = sizeof(bmpHeader);
+ bmpHeader.m_width = 16;
+ bmpHeader.m_height = 32;
+ bmpHeader.m_planes = 1;
+ bmpHeader.m_bitsPerPixel = 1;
+ bmpHeader.m_compression = 0;
+ bmpHeader.m_imageSize = (16 * 16 / 8);
+ bmpHeader.m_xPixelsPerMeter = 0;
+ bmpHeader.m_yPixelsPerMeter = 0;
+ bmpHeader.m_numColors = 2;
+ bmpHeader.m_importantColorCount = 2;
+
+ fwrite(&bmpHeader, 1, sizeof(bmpHeader), outF);
+
+ const uint8_t paletteData[] = {
+ 0, 0, 0, 0,
+ 255, 255, 255, 0 };
+
+ fwrite(paletteData, 1, sizeof(paletteData), outF);
+ uint8_t padding[2] = { 0, 0 };
+
+ for (int y = 0; y < 16; y++)
+ {
+ const uint8_t *maskRow = cursorData->m_mask + (15 - y) * 2;
+ const uint8_t *row = cursorData->m_pixels + (15 - y) * 2;
+ const uint8_t modifiedRow[] = { row[0] ^ maskRow[0], row[1] ^ maskRow[1] };
+ fwrite(modifiedRow, 1, 2, outF);
+ fwrite(padding, 1, 2, outF);
+ }
+
+ for (int y = 0; y < 16; y++)
+ {
+ const uint8_t *row = cursorData->m_mask + (15 - y) * 2;
+ const uint8_t modifiedRow[] = { row[0] ^ 255, row[1] ^ 255 };
+ fwrite(modifiedRow, 1, 2, outF);
+ fwrite(padding, 1, 2, outF);
+ }
+
+ long imageDataEnd = ftell(outF);
+
+ fseek(outF, sizeof(IconDir), SEEK_SET);
+
+ iconDirEntry.m_imageDataSize = static_cast(imageDataEnd - imageDataStart);
+ fwrite(&iconDirEntry, 1, sizeof(IconDirEntry), outF);
+ fclose(outF);
+ }
+ }
+}
+
void ConvertCursors(PortabilityLayer::ResourceFile *resFile)
{
const PortabilityLayer::ResourceCompiledTypeList *typeList = resFile->GetResourceTypeList('crsr');
@@ -196,7 +308,7 @@ void ConvertCursors(PortabilityLayer::ResourceFile *resFile)
}
char outPath[64];
- sprintf_s(outPath, "Packaged\\WinCursors\\%i.cur", resID);
+ sprintf_s(outPath, "Packaged\\WinCursors\\c%i.cur", resID);
FILE *outF = nullptr;
errno_t outErr = fopen_s(&outF, outPath, "wb");
@@ -335,6 +447,7 @@ int main(int argc, const char **argv)
stream.Close();
ConvertCursors(resFile);
+ ConvertBWCursors(resFile);
ConvertIconFamily(resFile, 'ics#', 'ics8', "Small", 16);
ConvertIconFamily(resFile, 'ICN#', 'icl8', "Large", 32);
diff --git a/GpApp/AnimCursor.cpp b/GpApp/AnimCursor.cpp
index e2cb6d4..f97cbdc 100644
--- a/GpApp/AnimCursor.cpp
+++ b/GpApp/AnimCursor.cpp
@@ -11,7 +11,7 @@
#include "Externs.h"
#include "Environ.h"
#include "HostDisplayDriver.h"
-#include "IGpColorCursor.h"
+#include "IGpCursor.h"
#include "IGpDisplayDriver.h"
#include "ResourceManager.h"
@@ -37,7 +37,7 @@ typedef struct
{
struct
{
- IGpColorCursor *hwCursor;
+ IGpCursor *hwCursor;
} frame[1];
} compiledAcurRec;
@@ -61,7 +61,7 @@ compiledAcurHandle compiledAnimCursorH = nil;
Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCursH)
{
short i, j;
- IGpColorCursor *hwCursor;
+ IGpCursor *hwCursor;
Boolean result = true;
if (ballCursH)
@@ -70,7 +70,7 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
HideCursor(); // Hide the cursor
for (i = 0; i < j; i++) // Walk through the acur resource
{
- hwCursor = PortabilityLayer::HostDisplayDriver::GetInstance()->LoadColorCursor((*ballCursH)->frame[i].resID); // Get the cursor
+ hwCursor = PortabilityLayer::HostDisplayDriver::GetInstance()->LoadCursor(true, (*ballCursH)->frame[i].resID); // Get the cursor
if (hwCursor == nil) // Make sure a real cursor was returned
{ // If not, trash all cursors loaded
for (j = 0; j < i; j++)
@@ -81,7 +81,7 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
else // But, if the cursor loaded ok
{ // add it to our list or cursor handles
(*compiledBallCursH)->frame[i].hwCursor = hwCursor;
- PortabilityLayer::HostDisplayDriver::GetInstance()->SetColorCursor(hwCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(hwCursor);
}
}
InitCursor(); // Show the cursor again (as arrow)
@@ -168,10 +168,10 @@ void IncrementCursor (void)
(*animCursorH)->index++;
(*animCursorH)->index %= (*animCursorH)->n;
- PortabilityLayer::HostDisplayDriver::GetInstance()->SetColorCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
}
else
- SetBuiltinCursor(watchCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kWait);
}
//-------------------------------------------------------------- DecrementCursor
@@ -188,10 +188,10 @@ void DecrementCursor (void)
if (((*animCursorH)->index) < 0)
(*animCursorH)->index = ((*animCursorH)->n) - 1;
- PortabilityLayer::HostDisplayDriver::GetInstance()->SetColorCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
}
else
- SetBuiltinCursor(watchCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kWait);
}
//-------------------------------------------------------------- SpinCursor
diff --git a/GpApp/Coordinates.cpp b/GpApp/Coordinates.cpp
index a812486..5d05b97 100644
--- a/GpApp/Coordinates.cpp
+++ b/GpApp/Coordinates.cpp
@@ -127,15 +127,15 @@ void OpenCoordWindow (void)
if (coordWindow == nil)
{
- const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar;
+ const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar | PortabilityLayer::WindowStyleFlags::kCloseBox;
QSetRect(&coordWindowRect, 0, 0, 50, 38);
if (thisMac.hasColor)
coordWindow = NewCWindow(nil, &coordWindowRect,
- PSTR("Tools"), false, windowStyle, kPutInFront, true, 0L);
+ PSTR("Tools"), false, windowStyle, kPutInFront, 0L);
else
coordWindow = NewWindow(nil, &coordWindowRect,
- PSTR("Tools"), false, windowStyle, kPutInFront, true, 0L);
+ PSTR("Tools"), false, windowStyle, kPutInFront, 0L);
if (coordWindow == nil)
RedAlert(kErrNoMemory);
diff --git a/GpApp/DialogUtils.cpp b/GpApp/DialogUtils.cpp
index 2557ee7..9588044 100644
--- a/GpApp/DialogUtils.cpp
+++ b/GpApp/DialogUtils.cpp
@@ -397,7 +397,9 @@ void GetDialogString (Dialog *theDialog, short item, StringPtr theString)
void SetDialogString (Dialog *theDialog, short item, const PLPasStr &theString)
{
- theDialog->GetItems()[item - 1].GetWidget()->SetString(theString);
+ PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget();
+ widget->SetString(theString);
+ widget->DrawControl(theDialog->GetWindow()->GetDrawSurface());
}
//-------------------------------------------------------------- GetDialogStringLen
diff --git a/GpApp/DynamicMaps.cpp b/GpApp/DynamicMaps.cpp
index 14ee7f2..4814c4d 100644
--- a/GpApp/DynamicMaps.cpp
+++ b/GpApp/DynamicMaps.cpp
@@ -9,6 +9,7 @@
#include "Environ.h"
#include "MainWindow.h"
#include "Objects.h"
+#include "QDPixMap.h"
#include "RectUtils.h"
#include "Room.h"
#include "Utilities.h"
diff --git a/GpApp/Events.cpp b/GpApp/Events.cpp
index 760d7c2..b921baf 100644
--- a/GpApp/Events.cpp
+++ b/GpApp/Events.cpp
@@ -442,7 +442,7 @@ void HandleIdleTask (void)
{
if (theMode == kEditMode)
{
- SetPort((GrafPtr)mainWindow);
+ SetPort(&mainWindow->GetDrawSurface()->m_port);
DoMarquee();
if ((autoRoomEdit) && (newRoomNow))
diff --git a/GpApp/HighScores.cpp b/GpApp/HighScores.cpp
index c720e58..45bcb89 100644
--- a/GpApp/HighScores.cpp
+++ b/GpApp/HighScores.cpp
@@ -69,7 +69,7 @@ void DoHighScores (void)
Rect tempRect;
SpinCursor(3);
- SetPort((GrafPtr)workSrcMap);
+ SetPort(&workSrcMap->m_port);
workSrcMap->FillRect(workSrcRect);
QSetRect(&tempRect, 0, 0, 640, 480);
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
diff --git a/GpApp/House.cpp b/GpApp/House.cpp
index 41cd203..930dcb0 100644
--- a/GpApp/House.cpp
+++ b/GpApp/House.cpp
@@ -28,6 +28,8 @@
void UpdateGoToDialog (Dialog *);
Boolean GoToFilter (Dialog *, EventRecord *, short *);
+extern PortabilityLayer::ResourceArchive *houseResFork;
+
houseHand thisHouse;
linksPtr linksList;
@@ -241,11 +243,7 @@ void WhereDoesGliderBegin (Rect *theRect, short mode)
Boolean HouseHasOriginalPicts (void)
{
- short nPicts;
-
- PL_NotYetImplemented(); nPicts = 0;
- //nPicts = Count1Resources('PICT');
- return (nPicts > 0);
+ return houseResFork->HasAnyResourcesOfType('PICT');
}
//-------------------------------------------------------------- CountHouseLinks
diff --git a/GpApp/HouseInfo.cpp b/GpApp/HouseInfo.cpp
index aa42027..7fdc53b 100644
--- a/GpApp/HouseInfo.cpp
+++ b/GpApp/HouseInfo.cpp
@@ -12,6 +12,8 @@
#include "Externs.h"
#include "DialogManager.h"
#include "DialogUtils.h"
+#include "HostDisplayDriver.h"
+#include "IGpDisplayDriver.h"
#define kHouseInfoDialogID 1001
@@ -181,7 +183,7 @@ Boolean HouseFilter (Dialog *dial, EventRecord *event, short *item)
{
if (houseCursorIs != kBeamCursor)
{
- SetBuiltinCursor(iBeamCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kIBeam);
houseCursorIs = kBeamCursor;
}
}
@@ -231,7 +233,7 @@ void DoHouseInfo (void)
houseInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kHouseInfoDialogID, kPutInFront, &substitutions);
if (houseInfoDialog == nil)
RedAlert(kErrDialogDidntLoad);
- SetPort((GrafPtr)houseInfoDialog);
+ SetPort(&houseInfoDialog->GetWindow()->GetDrawSurface()->m_port);
ShowWindow(houseInfoDialog->GetWindow());
SetDialogString(houseInfoDialog, kBannerTextItem, banner);
diff --git a/GpApp/Input.cpp b/GpApp/Input.cpp
index 64d5ea7..06a8453 100644
--- a/GpApp/Input.cpp
+++ b/GpApp/Input.cpp
@@ -12,6 +12,7 @@
#include "Externs.h"
#include "InputManager.h"
#include "MainWindow.h"
+#include "QDPixMap.h"
#include "RectUtils.h"
diff --git a/GpApp/InterfaceInit.cpp b/GpApp/InterfaceInit.cpp
index 28c45dd..fc6e25c 100644
--- a/GpApp/InterfaceInit.cpp
+++ b/GpApp/InterfaceInit.cpp
@@ -8,6 +8,8 @@
#include "Externs.h"
#include "Environ.h"
+#include "HostDisplayDriver.h"
+#include "IGpDisplayDriver.h"
#include "Map.h"
#include "MenuManager.h"
#include "PLKeyEncoding.h"
@@ -20,15 +22,14 @@
#define kHoriCursorID 130
#define kDiagCursorID 131
+struct IGpCursor;
extern THandle mirrorRects;
extern WindowPtr mapWindow, toolsWindow, linkWindow;
extern WindowPtr menuWindow;
extern Rect shieldRect, boardSrcRect, localRoomsDest[];
-extern CursHandle handCursorH, vertCursorH, horiCursorH;
-extern CursHandle diagCursorH;
-extern Cursor handCursor, vertCursor, horiCursor;
-extern Cursor diagCursor;
+extern IGpCursor *handCursor, *vertCursor, *horiCursor;
+extern IGpCursor *diagCursor;
extern MenuHandle appleMenu, gameMenu, optionsMenu, houseMenu;
extern Point shieldPt;
extern long incrementModeTime;
@@ -81,25 +82,21 @@ void InitializeMenus (void)
void GetExtraCursors (void)
{
- handCursorH = GetCursor(kHandCursorID);
- if (handCursorH == nil)
+ handCursor = PortabilityLayer::HostDisplayDriver::GetInstance()->LoadCursor(false, kHandCursorID);
+ if (handCursor == nil)
RedAlert(kErrFailedResourceLoad);
- handCursor = **handCursorH;
- vertCursorH = GetCursor(kVertCursorID);
- if (vertCursorH == nil)
+ vertCursor = PortabilityLayer::HostDisplayDriver::GetInstance()->LoadCursor(false, kVertCursorID);
+ if (vertCursor == nil)
RedAlert(kErrFailedResourceLoad);
- vertCursor = **vertCursorH;
- horiCursorH = GetCursor(kHoriCursorID);
- if (horiCursorH == nil)
+ horiCursor = PortabilityLayer::HostDisplayDriver::GetInstance()->LoadCursor(false, kHoriCursorID);
+ if (horiCursor == nil)
RedAlert(kErrFailedResourceLoad);
- horiCursor = **horiCursorH;
- diagCursorH = GetCursor(kDiagCursorID);
- if (diagCursorH == nil)
+ diagCursor = PortabilityLayer::HostDisplayDriver::GetInstance()->LoadCursor(false, kDiagCursorID);
+ if (diagCursor == nil)
RedAlert(kErrFailedResourceLoad);
- diagCursor = **diagCursorH;
}
//-------------------------------------------------------------- VariableInit
diff --git a/GpApp/Link.cpp b/GpApp/Link.cpp
index 65edaa5..1f81d6b 100644
--- a/GpApp/Link.cpp
+++ b/GpApp/Link.cpp
@@ -221,15 +221,15 @@ void OpenLinkWindow (void)
if (linkWindow == nil)
{
- const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar;
+ const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar | PortabilityLayer::WindowStyleFlags::kCloseBox;
QSetRect(&linkWindowRect, 0, 0, 129, 30);
if (thisMac.hasColor)
linkWindow = NewCWindow(nil, &linkWindowRect,
- PSTR("Link"), false, windowStyle, kPutInFront, true, 0L);
+ PSTR("Link"), false, windowStyle, kPutInFront, 0L);
else
linkWindow = NewWindow(nil, &linkWindowRect,
- PSTR("Link"), false, windowStyle, kPutInFront, true, 0L);
+ PSTR("Link"), false, windowStyle, kPutInFront, 0L);
MoveWindow(linkWindow, isLinkH, isLinkV, true);
diff --git a/GpApp/MainWindow.cpp b/GpApp/MainWindow.cpp
index 1a9a6d8..694d314 100644
--- a/GpApp/MainWindow.cpp
+++ b/GpApp/MainWindow.cpp
@@ -14,6 +14,7 @@
#include "House.h"
#include "InputManager.h"
#include "MenuManager.h"
+#include "QDPixMap.h"
#include "RectUtils.h"
#include "PLKeyEncoding.h"
#include "PLStandardColors.h"
@@ -35,10 +36,8 @@ CTabHandle theCTab;
PixMapHandle thePMap;
ColorSpec * wasColors;
ColorSpec * newColors;
-CursHandle handCursorH, vertCursorH, horiCursorH;
-CursHandle diagCursorH;
-Cursor handCursor, vertCursor, horiCursor;
-Cursor diagCursor;
+IGpCursor *handCursor, *vertCursor, *horiCursor;
+IGpCursor *diagCursor;
Rect workSrcRect;
DrawSurface *workSrcMap;
Rect mainWindowRect;
@@ -209,8 +208,8 @@ void OpenMainWindow (void)
if (OptionKeyDown())
{
- isEditH = 3;
- isEditV = 41;
+ isEditH = 10;
+ isEditV = 46;
}
MoveWindow(mainWindow, isEditH, isEditV, true);
ShowWindow(mainWindow);
@@ -242,7 +241,7 @@ void OpenMainWindow (void)
Rect scorebarRect = thisMac.screen;
scorebarRect.bottom = scorebarRect.top + kScoreboardTall;
- PortabilityLayer::WindowDef windowDef = PortabilityLayer::WindowDef::Create(scorebarRect, PortabilityLayer::WindowStyleFlags::kBorderless, true, false, 0, 0, PSTR("Scoreboard"));
+ PortabilityLayer::WindowDef windowDef = PortabilityLayer::WindowDef::Create(scorebarRect, PortabilityLayer::WindowStyleFlags::kBorderless, true, 0, 0, PSTR("Scoreboard"));
boardWindow = windowManager->CreateWindow(windowDef);
if (boardWindow != nil)
windowManager->PutWindowBehind(boardWindow, PL_GetPutInFrontWindowPtr());
diff --git a/GpApp/Map.cpp b/GpApp/Map.cpp
index 75b79b8..fb002e7 100644
--- a/GpApp/Map.cpp
+++ b/GpApp/Map.cpp
@@ -17,6 +17,7 @@
#include "PLWidgets.h"
#include "WindowDef.h"
#include "WindowManager.h"
+#include "QDPixMap.h"
#include "RectUtils.h"
#include "Utilities.h"
@@ -111,8 +112,7 @@ void FlagMapRoomsForUpdate (void)
return;
// SetPortWindowPort(mapWindow);
- InvalWindowRect(mapWindow, &wasActiveRoomRect);
- InvalWindowRect(mapWindow, &activeRoomRect);
+ UpdateMapWindow();
}
#endif
@@ -343,8 +343,8 @@ void ResizeMapWindow (short newH, short newV)
mapVScroll->SetPosition(Point::Create(mapWindowRect.right - kMapScrollBarWidth + 2, 0));
mapVScroll->Resize(kMapScrollBarWidth, mapWindowRect.bottom - kMapScrollBarWidth + 3);
mapTopRoom = mapVScroll->GetState();
-
- InvalWindowRect(mapWindow, &mapWindowRect);
+
+ UpdateMapWindow();
#endif
}
@@ -362,9 +362,9 @@ void OpenMapWindow (void)
mapRoomsWide * kMapRoomWidth + kMapScrollBarWidth - 2,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth - 2);
- const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kResizable | PortabilityLayer::WindowStyleFlags::kMiniBar;
+ const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kResizable | PortabilityLayer::WindowStyleFlags::kMiniBar | PortabilityLayer::WindowStyleFlags::kCloseBox;;
- PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mapWindowRect, windowStyle, false, true, 0, 0, PSTR("Map"));
+ PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mapWindowRect, windowStyle, false, 0, 0, PSTR("Map"));
mapWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(wdef);
@@ -386,7 +386,7 @@ void OpenMapWindow (void)
PortabilityLayer::WindowManager::GetInstance()->ShowWindow(mapWindow);
// FlagWindowFloating(mapWindow); TEMP - use flaoting windows
- SetPort((GrafPtr)mapWindow);
+ SetPort(&mapWindow->GetDrawSurface()->m_port);
QSetRect(&mapHScrollRect, -1, mapRoomsHigh * kMapRoomHeight,
mapRoomsWide * kMapRoomWidth + 1,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth);
@@ -425,6 +425,8 @@ void OpenMapWindow (void)
mapWindowRect.bottom + 2);
CenterMapOnRoom(thisRoom->suite, thisRoom->floor);
+
+ UpdateMapWindow();
}
UpdateMapCheckmark(true);
@@ -579,7 +581,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
{
#ifndef COMPILEDEMO
Rect aRoom;
- ControlHandle whichControl;
+ PortabilityLayer::Widget *whichControl = nullptr;
Point wherePt, globalWhere;
long controlRef;
short whichPart, localH, localV;
@@ -665,7 +667,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
}
else
{
- controlRef = GetControlReference(whichControl);
+ controlRef = whichControl->GetReferenceConstant();
if (controlRef == kHScrollRef)
{
switch (whichPart)
@@ -683,7 +685,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
case kControlIndicatorPart:
if (TrackControl(whichControl, wherePt, nil))
{
- mapLeftRoom = GetControlValue(whichControl);
+ mapLeftRoom = whichControl->GetState();
RedrawMapContents();
}
break;
@@ -706,7 +708,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
case kControlIndicatorPart:
if (TrackControl(whichControl, wherePt, nil))
{
- mapTopRoom = GetControlValue(whichControl);
+ mapTopRoom = whichControl->GetState();
RedrawMapContents();
}
break;
diff --git a/GpApp/Marquee.cpp b/GpApp/Marquee.cpp
index 8ce4c6f..b8fded1 100644
--- a/GpApp/Marquee.cpp
+++ b/GpApp/Marquee.cpp
@@ -6,11 +6,15 @@
#include "Externs.h"
+#include "HostDisplayDriver.h"
+#include "IGpDisplayDriver.h"
#include "Marquee.h"
#include "Objects.h"
#include "ObjectEdit.h"
#include "RectUtils.h"
+#include
+
#define kMarqueePatListID 128
#define kHandleSideLong 9
@@ -25,7 +29,7 @@ Rect marqueeGliderRect;
Boolean gliderMarqueeUp;
-extern Cursor handCursor, vertCursor, horiCursor, diagCursor;
+extern IGpCursor *handCursor, *vertCursor, *horiCursor, *diagCursor;
extern Rect leftStartGliderSrc;
@@ -216,7 +220,7 @@ void DragMarqueeRect (DrawSurface *surface, Point start, Rect *theRect, Boolean
Point wasPt, newPt;
short deltaH, deltaV;
- SetCursor(&handCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(handCursor);
StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
@@ -259,9 +263,9 @@ void DragMarqueeHandle (DrawSurface *surface, Point start, short *dragged)
short deltaH, deltaV;
if ((theMarquee.direction == kAbove) || (theMarquee.direction == kBelow))
- SetCursor(&vertCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(vertCursor);
else
- SetCursor(&horiCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(horiCursor);
StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
@@ -344,7 +348,7 @@ void DragMarqueeCorner (DrawSurface *surface, Point start, short *hDragged, shor
Point wasPt, newPt;
short deltaH, deltaV;
- SetCursor(&diagCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(diagCursor);
StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
@@ -428,11 +432,9 @@ Boolean PtInMarqueeHandle (Point where)
void DrawGliderMarquee (void)
{
- CopyBits((BitMap *)*GetGWorldPixMap(blowerMaskMap),
- GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
- &leftStartGliderSrc,
- &marqueeGliderRect,
- srcXor);
+ DrawSurface *surface = GetWindowPort(mainWindow);
+ ImageInvert(*GetGWorldPixMap(blowerMaskMap), GetPortBitMapForCopyBits(surface), leftStartGliderSrc, marqueeGliderRect);
+ surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
//-------------------------------------------------------------- SetMarqueeGliderCenter
@@ -488,7 +490,7 @@ void DrawMarquee (DrawSurface *surface, const uint8_t *pattern)
break;
}
- surface->InvertDrawLine(points[0], points[1], pattern);
+ surface->InvertFillRect(Rect::Create(points[0].v, points[0].h, points[1].v, points[1].h), pattern);
}
if (gliderMarqueeUp)
diff --git a/GpApp/Menu.cpp b/GpApp/Menu.cpp
index 1e7e646..9c336d2 100644
--- a/GpApp/Menu.cpp
+++ b/GpApp/Menu.cpp
@@ -747,7 +747,7 @@ short QueryResumeGame (void)
theDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kResumeGameDial, kPutInFront, &substitutions);
if (theDial == nil)
RedAlert(kErrDialogDidntLoad);
- SetPort((GrafPtr)theDial);
+ SetPort(&theDial->GetWindow()->GetDrawSurface()->m_port);
ShowWindow(theDial->GetWindow());
DrawDefaultButton(theDial);
diff --git a/GpApp/ObjectAdd.cpp b/GpApp/ObjectAdd.cpp
index a245382..8662ddd 100644
--- a/GpApp/ObjectAdd.cpp
+++ b/GpApp/ObjectAdd.cpp
@@ -789,7 +789,7 @@ Boolean AddNewObject (Point where, short what, Boolean showItNow)
ReadyBackground(thisRoom->background, thisRoom->tiles);
GetThisRoomsObjRects();
DrawThisRoomsObjects();
- InvalWindowRect(mainWindow, &mainWindowRect);
+ UpdateMainWindow();
if (handled)
{
diff --git a/GpApp/ObjectEdit.cpp b/GpApp/ObjectEdit.cpp
index a587c76..284d8da 100644
--- a/GpApp/ObjectEdit.cpp
+++ b/GpApp/ObjectEdit.cpp
@@ -2316,8 +2316,7 @@ void DrawThisRoomsObjects (void)
if (GetNumberOfLights(thisRoomNumber) <= 0)
{
surface->SetMaskMode(true);
- surface->SetPattern8x8(*GetQDGlobalsGray(&dummyPattern));
- surface->FillRect(backSrcRect);
+ surface->FillRectWithPattern8x8(backSrcRect, *GetQDGlobalsGray(&dummyPattern));
surface->SetMaskMode(false);
}
diff --git a/GpApp/ObjectInfo.cpp b/GpApp/ObjectInfo.cpp
index 1d904bb..aad1452 100644
--- a/GpApp/ObjectInfo.cpp
+++ b/GpApp/ObjectInfo.cpp
@@ -947,7 +947,7 @@ void DoBlowerObjectInfo (short what)
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kBlowerInfoDialogID, kPutInFront, &substitutions);
if (infoDial == nil)
RedAlert(kErrDialogDidntLoad);
- SetPort((GrafPtr)infoDial);
+ SetPort(&infoDial->GetWindow()->GetDrawSurface()->m_port);
newDirection = thisRoom->objects[objActive].data.a.vector & 0x0F;
if (thisRoom->objects[objActive].data.a.initial)
@@ -1544,7 +1544,7 @@ void DoLightObjectInfo (void)
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kLightInfoDialogID, kPutInFront, &substitutions);
if (infoDial == nil)
RedAlert(kErrDialogDidntLoad);
- SetPort((GrafPtr)infoDial);
+ SetPort(&infoDial->GetWindow()->GetDrawSurface()->m_port);
if (thisRoom->objects[objActive].data.f.initial)
SetDialogItemValue(infoDial, kInitialStateCheckbox, 1);
diff --git a/GpApp/Render.cpp b/GpApp/Render.cpp
index fba6932..d1c9f62 100644
--- a/GpApp/Render.cpp
+++ b/GpApp/Render.cpp
@@ -12,6 +12,7 @@
#include "Objects.h"
#include "Play.h"
#include "Player.h"
+#include "QDPixMap.h"
#include "RectUtils.h"
#include "Room.h"
#include "RubberBands.h"
@@ -148,7 +149,7 @@ void DrawReflection (gliderPtr thisGlider, Boolean oneOrTwo)
dest = thisGlider->dest;
QOffsetRect(&dest, playOriginH - 20, playOriginV - 16);
- SetPort((GrafPtr)workSrcMap);
+ SetPort(&workSrcMap->m_port);
long numMirrorRects = GetHandleSize(mirrorRects.StaticCast()) / sizeof(Rect);
diff --git a/GpApp/Room.cpp b/GpApp/Room.cpp
index e7fd4be..58d9c00 100644
--- a/GpApp/Room.cpp
+++ b/GpApp/Room.cpp
@@ -16,6 +16,7 @@
#include "House.h"
#include "InputManager.h"
#include "MainWindow.h"
+#include "MemoryManager.h"
#include "RectUtils.h"
@@ -197,13 +198,13 @@ Boolean CreateNewRoom (short h, short v)
if (availableRoom == -1) // found no available rooms
{
- howMuch = sizeof(roomType); // add new room to end of house
- theErr = PtrAndHand((Ptr)thisRoom, thisHouse.StaticCast(), howMuch);
- if (theErr != PLErrors::kNone)
+ // add new room to end of house
+ if (!PortabilityLayer::MemoryManager::GetInstance()->ResizeHandle(thisHouse.MMBlock(), thisHouse.MMBlock()->m_size + sizeof(roomType)))
{
- YellowAlert(kYellowUnaccounted, theErr);
+ YellowAlert(kYellowUnaccounted, PLErrors::kOutOfMemory);
return (false);
}
+ (*thisHouse)->rooms[(*thisHouse)->nRooms] = *thisRoom;
(*thisHouse)->nRooms++; // increment nRooms
numberRooms = (*thisHouse)->nRooms;
previousRoom = thisRoomNumber;
@@ -336,7 +337,7 @@ void ReflectCurrentRoom (Boolean forceMapRedraw)
PL_NotYetImplemented_TODO("FixMe");
DebugPixMap(backSrcMap->m_port.GetPixMap(), "DebugData/EditorSplash6");
- //InvalWindowRect(mainWindow, &mainWindowRect);
+ UpdateMainWindow();
#endif
}
diff --git a/GpApp/RoomInfo.cpp b/GpApp/RoomInfo.cpp
index 67b5228..6934ad9 100644
--- a/GpApp/RoomInfo.cpp
+++ b/GpApp/RoomInfo.cpp
@@ -14,7 +14,11 @@
#include "DialogManager.h"
#include "DialogUtils.h"
#include "Externs.h"
+#include "HostDisplayDriver.h"
+#include "IGpDisplayDriver.h"
#include "RectUtils.h"
+#include "PLTimeTaggedVOSEvent.h"
+#include "QDPixMap.h"
#include "ResourceCompiledRef.h"
#include "ResourceManager.h"
#include "Utilities.h"
@@ -41,7 +45,8 @@
void UpdateRoomInfoDialog (Dialog *);
void DragMiniTile (DrawSurface *, Point, short *);
void HiliteTileOver (DrawSurface *, Point);
-Boolean RoomFilter (Dialog *, EventRecord *, short *);
+int16_t RoomFilter (Dialog *dialog, const TimeTaggedVOSEvent *evt);
+
short ChooseOriginalArt (short);
void UpdateOriginalArt (Dialog *);
Boolean OriginalArtFilter (Dialog *, EventRecord *, short *);
@@ -58,7 +63,7 @@ short tileOver, tempBack, cursorIs;
Boolean originalLeftOpen, originalTopOpen, originalRightOpen, originalBottomOpen;
Boolean originalFloor;
-extern Cursor handCursor;
+extern IGpCursor *handCursor;
extern short lastBackground;
@@ -71,7 +76,6 @@ void UpdateRoomInfoDialog (Dialog *theDialog)
Rect src, dest;
short i;
- DrawDialog(theDialog);
if (tempBack >= kUserBackground)
SetPopUpMenuValue(theDialog, kRoomPopupItem, kOriginalArtworkItem);
else
@@ -81,7 +85,7 @@ void UpdateRoomInfoDialog (Dialog *theDialog)
CopyBits(GetPortBitMapForCopyBits(tileSrcMap),
- GetPortBitMapForCopyBits(GetDialogPort(theDialog)),
+ GetPortBitMapForCopyBits(theDialog->GetWindow()->GetDrawSurface()),
&tileSrcRect, &tileSrc, srcCopy);
/*
CopyBits(&((GrafPtr)tileSrcMap)->portBits,
@@ -96,7 +100,7 @@ void UpdateRoomInfoDialog (Dialog *theDialog)
QOffsetRect(&src, tempTiles[i] * kMiniTileWide, 0);
CopyBits(GetPortBitMapForCopyBits(tileSrcMap),
- GetPortBitMapForCopyBits(GetDialogPort(theDialog)),
+ GetPortBitMapForCopyBits(theDialog->GetWindow()->GetDrawSurface()),
&src, &dest, srcCopy);
/*
CopyBits(&((GrafPtr)tileSrcMap)->portBits,
@@ -263,7 +267,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
{
if (cursorIs != kHandCursor)
{
- SetCursor(&handCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(handCursor);
cursorIs = kHandCursor;
}
@@ -327,7 +331,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
{
if (cursorIs != kBeamCursor)
{
- SetBuiltinCursor(iBeamCursor);
+ PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kIBeam);
cursorIs = kBeamCursor;
}
}
@@ -346,78 +350,66 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
//-------------------------------------------------------------- RoomFilter
#ifndef COMPILEDEMO
-Boolean RoomFilter (Dialog *dial, EventRecord *event, short *item)
+int16_t RoomFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
{
Point mouseIs;
short newTileOver;
+ if (!evt)
+ return -1;
+
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
-
- switch (event->what)
+
+ if (evt->IsKeyDownEvent())
{
- case keyDown:
- switch (event->message)
+ switch (PackVOSKeyCode(evt->m_vosEvent.m_event.m_keyboardInputEvent))
{
- case PL_KEY_SPECIAL(kEnter):
- case PL_KEY_NUMPAD_SPECIAL(kEnter):
+ case PL_KEY_SPECIAL(kEnter):
+ case PL_KEY_NUMPAD_SPECIAL(kEnter):
FlashDialogButton(dial, kOkayButton);
- *item = kOkayButton;
- return(true);
- break;
+ return kOkayButton;
- case PL_KEY_SPECIAL(kEscape):
+ case PL_KEY_SPECIAL(kEscape):
FlashDialogButton(dial, kCancelButton);
- *item = kCancelButton;
- return(true);
- break;
+ return kCancelButton;
- case PL_KEY_SPECIAL(kTab):
+ case PL_KEY_SPECIAL(kTab):
SelectDialogItemText(dial, kRoomNameItem, 0, 1024);
- return(true);
- break;
-
- default:
- return(false);
- }
- break;
-
- case mouseDown:
- mouseIs = event->where;
- mouseIs -= dial->GetWindow()->TopLeftCoord();
- if (tileSrc.Contains(mouseIs))
- {
- if (StillDown())
- {
- DragMiniTile(surface, mouseIs, &newTileOver);
- if ((newTileOver >= 0) && (newTileOver < kNumTiles))
- {
- tempTiles[newTileOver] = tileOver;
- UpdateRoomInfoDialog(dial);
- }
- }
- return(true);
- }
- else
- return(false);
- break;
-
- case mouseUp:
- return(false);
- break;
-
- case updateEvt:
- SetPortDialogPort(dial);
- UpdateRoomInfoDialog(dial);
- EndUpdate(dial->GetWindow());
- event->what = nullEvent;
- return(false);
- break;
-
+ return 0;
+
default:
- GetMouse(&mouseIs);
- HiliteTileOver(surface, mouseIs);
- return(false);
- break;
+ return -1;
+ }
+ }
+ else if (evt->m_vosEvent.m_eventType == GpVOSEventTypes::kMouseInput)
+ {
+ const GpMouseInputEvent &mouseEvent = evt->m_vosEvent.m_event.m_mouseInputEvent;
+
+ if (evt->IsLMouseDownEvent())
+ {
+ mouseIs = Point::Create(mouseEvent.m_x, mouseEvent.m_y);
+ mouseIs -= dial->GetWindow()->TopLeftCoord();
+ if (tileSrc.Contains(mouseIs))
+ {
+ if (StillDown())
+ {
+ DragMiniTile(surface, mouseIs, &newTileOver);
+ if ((newTileOver >= 0) && (newTileOver < kNumTiles))
+ {
+ tempTiles[newTileOver] = tileOver;
+ UpdateRoomInfoDialog(dial);
+ }
+ }
+ return 0;
+ }
+ else
+ return -1;
+ }
+ else if (mouseEvent.m_eventType == GpMouseEventTypes::kMove)
+ {
+ mouseIs = dial->GetWindow()->MouseToLocal(mouseEvent);
+ HiliteTileOver(surface, mouseIs);
+ }
}
}
#endif
@@ -470,7 +462,7 @@ void DoRoomInfo (void)
roomInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kRoomInfoDialogID, kPutInFront, &substitutions);
if (roomInfoDialog == nil)
RedAlert(kErrDialogDidntLoad);
- SetPort((GrafPtr)roomInfoDialog);
+ SetPort(&roomInfoDialog->GetWindow()->GetDrawSurface()->m_port);
// Fix this later. TEMP
// AddMenuToPopUp(roomInfoDialog, kRoomPopupItem, backgroundsMenu);
@@ -497,10 +489,12 @@ void DoRoomInfo (void)
MyDisableControl(roomInfoDialog, kBoundsButton);
leaving = false;
+
+ UpdateRoomInfoDialog(roomInfoDialog);
while (!leaving)
{
- ModalDialog(RoomFilter, &item);
+ item = roomInfoDialog->ExecuteModal(RoomFilter);
if (item == kOkayButton)
{
diff --git a/GpApp/Scoreboard.cpp b/GpApp/Scoreboard.cpp
index d104ac1..41c7076 100644
--- a/GpApp/Scoreboard.cpp
+++ b/GpApp/Scoreboard.cpp
@@ -11,6 +11,7 @@
#include "Externs.h"
#include "Environ.h"
#include "MenuManager.h"
+#include "QDPixMap.h"
#include "QDStandardPalette.h"
#include "RectUtils.h"
diff --git a/GpApp/Tools.cpp b/GpApp/Tools.cpp
index 08d5f1b..171bdb0 100644
--- a/GpApp/Tools.cpp
+++ b/GpApp/Tools.cpp
@@ -14,6 +14,7 @@
#include "FontFamily.h"
#include "PLWidgets.h"
#include "PLPopupMenuWidget.h"
+#include "QDPixMap.h"
#include "RectUtils.h"
#include "Utilities.h"
#include "WindowDef.h"
@@ -199,7 +200,7 @@ void EraseSelectedTool (void)
if (toolsWindow == nil)
return;
- SetPort((GrafPtr)toolsWindow);
+ SetPort(&toolsWindow->GetDrawSurface()->m_port);
toolIcon = toolSelected;
if ((toolMode == kBlowerMode) && (toolIcon >= 7))
@@ -299,9 +300,9 @@ void OpenToolsWindow (void)
QOffsetRect(&toolTextRect, 0, 157 - 15);
{
- const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar;
+ const uint16_t windowStyle = PortabilityLayer::WindowStyleFlags::kTitleBar | PortabilityLayer::WindowStyleFlags::kMiniBar | PortabilityLayer::WindowStyleFlags::kCloseBox;
- PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(toolsWindowRect, windowStyle, false, true, 0, 0, PSTR("Tools"));
+ PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(toolsWindowRect, windowStyle, false, 0, 0, PSTR("Tools"));
toolsWindow = wm->CreateWindow(wdef);
}
@@ -333,6 +334,8 @@ void OpenToolsWindow (void)
classPopUp = PortabilityLayer::PopupMenuWidget::Create(state);
}
+ toolsWindow->DrawControls();
+
if (classPopUp == nil)
RedAlert(kErrFailedResourceLoad);
@@ -473,7 +476,7 @@ void HandleToolsClick (Point wherePt)
part = FindControl(wherePt, toolsWindow, &theControl);
if ((theControl != nil) && (part != 0))
{
- part = TrackControl(theControl, wherePt, nullptr);
+ part = theControl->Capture(wherePt, nullptr);
if (part != 0)
{
newMode = theControl->GetState();
diff --git a/GpApp/Transitions.cpp b/GpApp/Transitions.cpp
index e177eac..b394071 100644
--- a/GpApp/Transitions.cpp
+++ b/GpApp/Transitions.cpp
@@ -9,6 +9,7 @@
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
+#include "QDPixMap.h"
#include "PLQDraw.h"
#include "RectUtils.h"
diff --git a/GpApp/WindowUtils.cpp b/GpApp/WindowUtils.cpp
index 14b0af7..28e622e 100644
--- a/GpApp/WindowUtils.cpp
+++ b/GpApp/WindowUtils.cpp
@@ -108,7 +108,7 @@ void OpenMessageWindow (const PLPasStr &title)
SetRect(&mssgWindowRect, 0, 0, 256, kMessageWindowTall);
- const PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mssgWindowRect, windowStyle, false, false, 0, 0, title);
+ const PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mssgWindowRect, windowStyle, false, 0, 0, title);
mssgWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(wdef);
diff --git a/GpCommon/EGpStandardCursor.h b/GpCommon/EGpStandardCursor.h
index cde59a7..499655a 100644
--- a/GpCommon/EGpStandardCursor.h
+++ b/GpCommon/EGpStandardCursor.h
@@ -5,6 +5,8 @@ namespace EGpStandardCursors
enum EGpStandardCursor
{
kArrow,
+ kIBeam,
+ kWait,
kHidden,
};
}
diff --git a/GpCommon/GpColorCursor_Win32.h b/GpCommon/GpCursor_Win32.h
similarity index 50%
rename from GpCommon/GpColorCursor_Win32.h
rename to GpCommon/GpCursor_Win32.h
index 0c24d51..da45656 100644
--- a/GpCommon/GpColorCursor_Win32.h
+++ b/GpCommon/GpCursor_Win32.h
@@ -1,10 +1,10 @@
#pragma once
-#include "IGpColorCursor_Win32.h"
+#include "IGpCursor_Win32.h"
#include "GpWindows.h"
-class GpColorCursor_Win32 final : public IGpColorCursor_Win32
+class GpCursor_Win32 final : public IGpCursor_Win32
{
public:
void Destroy() override;
@@ -14,11 +14,11 @@ public:
void IncRef() override;
void DecRef() override;
- static GpColorCursor_Win32 *Load(const wchar_t *path);
+ static IGpCursor_Win32 *Load(const wchar_t *path);
private:
- GpColorCursor_Win32(HCURSOR cursor);
- ~GpColorCursor_Win32();
+ GpCursor_Win32(HCURSOR cursor);
+ ~GpCursor_Win32();
HCURSOR m_cursor;
int m_refCount;
diff --git a/GpCommon/GpWindows.h b/GpCommon/GpWindows.h
index 4ba6743..1bfb8a4 100644
--- a/GpCommon/GpWindows.h
+++ b/GpCommon/GpWindows.h
@@ -8,10 +8,11 @@
#undef CreateMutex
#undef DeleteFile
-
+#undef LoadCursor
struct IGpFiber;
-struct IGpColorCursor_Win32;
+struct IGpBWCursor_Win32;
+struct IGpCursor_Win32;
struct IGpVOSEventQueue;
struct GpWindowsGlobals
@@ -23,7 +24,6 @@ struct GpWindowsGlobals
int m_nCmdShow;
IGpFiber *(*m_createFiberFunc)(LPVOID fiber);
- IGpColorCursor_Win32 *(*m_loadColorCursorFunc)(const wchar_t *path);
+ IGpCursor_Win32 *(*m_loadCursorFunc)(const wchar_t *path);
void (*m_translateWindowsMessageFunc)(const MSG *msg, IGpVOSEventQueue *eventQueue);
};
-
diff --git a/GpCommon/IGpColorCursor.h b/GpCommon/IGpCursor.h
similarity index 68%
rename from GpCommon/IGpColorCursor.h
rename to GpCommon/IGpCursor.h
index f59fbc5..9e1b8d6 100644
--- a/GpCommon/IGpColorCursor.h
+++ b/GpCommon/IGpCursor.h
@@ -1,6 +1,6 @@
#pragma once
-struct IGpColorCursor
+struct IGpCursor
{
virtual void Destroy() = 0;
};
diff --git a/GpCommon/IGpColorCursor_Win32.h b/GpCommon/IGpCursor_Win32.h
similarity index 66%
rename from GpCommon/IGpColorCursor_Win32.h
rename to GpCommon/IGpCursor_Win32.h
index 480be90..44d3802 100644
--- a/GpCommon/IGpColorCursor_Win32.h
+++ b/GpCommon/IGpCursor_Win32.h
@@ -1,9 +1,9 @@
#pragma once
-#include "IGpColorCursor.h"
+#include "IGpCursor.h"
#include "GpWindows.h"
-struct IGpColorCursor_Win32 : public IGpColorCursor
+struct IGpCursor_Win32 : public IGpCursor
{
public:
virtual const HCURSOR &GetHCursor() const = 0;
diff --git a/GpCommon/IGpDisplayDriver.h b/GpCommon/IGpDisplayDriver.h
index 46cc590..a975ce6 100644
--- a/GpCommon/IGpDisplayDriver.h
+++ b/GpCommon/IGpDisplayDriver.h
@@ -4,7 +4,7 @@
#include "EGpStandardCursor.h"
struct IGpDisplayDriverSurface;
-struct IGpColorCursor;
+struct IGpCursor;
// Display drivers are responsible for timing and calling the game tick function.
struct IGpDisplayDriver
@@ -16,10 +16,10 @@ public:
virtual void GetDisplayResolution(unsigned int *width, unsigned int *height, GpPixelFormat_t *bpp) = 0;
virtual IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) = 0;
- virtual void DrawSurface(IGpDisplayDriverSurface *surface, size_t x, size_t y, size_t width, size_t height) = 0;
+ virtual void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height) = 0;
- virtual IGpColorCursor *LoadColorCursor(int cursorID) = 0;
- virtual void SetColorCursor(IGpColorCursor *colorCursor) = 0;
+ virtual IGpCursor *LoadCursor(bool isColor, int cursorID) = 0;
+ virtual void SetCursor(IGpCursor *cursor) = 0;
virtual void SetStandardCursor(EGpStandardCursor_t standardCursor) = 0;
virtual void UpdatePalette(const void *paletteData) = 0;
diff --git a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp
index 0f87ece..134abbc 100644
--- a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp
+++ b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp
@@ -3,7 +3,7 @@
#include "GpDisplayDriverD3D11.h"
#include "GpDisplayDriverSurfaceD3D11.h"
#include "GpWindows.h"
-#include "IGpColorCursor_Win32.h"
+#include "IGpCursor_Win32.h"
#include "IGpFiber.h"
#include
@@ -502,7 +502,7 @@ void GpDisplayDriverD3D11::SynchronizeCursors()
void GpDisplayDriverD3D11::ChangeToCursor(HCURSOR cursor)
{
if (m_mouseIsInClientArea)
- SetCursor(cursor);
+ ::SetCursor(cursor);
SetClassLongPtrW(m_hwnd, GCLP_HCURSOR, reinterpret_cast(cursor));
}
@@ -511,6 +511,12 @@ void GpDisplayDriverD3D11::ChangeToStandardCursor(EGpStandardCursor_t cursor)
{
switch (cursor)
{
+ case EGpStandardCursors::kIBeam:
+ ChangeToCursor(m_ibeamCursor);
+ break;
+ case EGpStandardCursors::kWait:
+ ChangeToCursor(m_waitCursor);
+ break;
case EGpStandardCursors::kArrow:
default:
ChangeToCursor(m_arrowCursor);
@@ -624,7 +630,7 @@ IGpDisplayDriverSurface *GpDisplayDriverD3D11::CreateSurface(size_t width, size_
return GpDisplayDriverSurfaceD3D11::Create(m_device, m_deviceContext, width, height, pixelFormat);
}
-void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, size_t x, size_t y, size_t width, size_t height)
+void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height)
{
ID3D11Buffer *vbPtr = m_quadVertexBuffer;
UINT vbStride = sizeof(float) * 2;
@@ -710,24 +716,30 @@ void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, size_t
m_deviceContext->DrawIndexed(6, 0, 0);
}
-IGpColorCursor *GpDisplayDriverD3D11::LoadColorCursor(int cursorID)
+IGpCursor *GpDisplayDriverD3D11::LoadCursor(bool isColor, int cursorID)
{
const size_t bufSize = MAX_PATH;
wchar_t path[bufSize];
- int sz = _snwprintf(path, bufSize, L"%sPackaged\\WinCursors\\%i.cur", m_osGlobals->m_baseDir, cursorID);
+ int sz = 0;
+ if (isColor)
+ sz = _snwprintf(path, bufSize, L"%sPackaged\\WinCursors\\c%i.cur", m_osGlobals->m_baseDir, cursorID);
+ else
+ sz = _snwprintf(path, bufSize, L"%sPackaged\\WinCursors\\b%i.cur", m_osGlobals->m_baseDir, cursorID);
+
if (sz < 0 || static_cast(sz) >= bufSize)
return nullptr;
- return m_osGlobals->m_loadColorCursorFunc(path);
+ return m_osGlobals->m_loadCursorFunc(path);
}
+
// We can't just set the cursor because we want to post WM_SETCURSOR to keep it limited
// to the game window area, but depending on the fiber implementation, this may not be
// the window thread.
-void GpDisplayDriverD3D11::SetColorCursor(IGpColorCursor *colorCursor)
+void GpDisplayDriverD3D11::SetCursor(IGpCursor *cursor)
{
- IGpColorCursor_Win32 *winCursor = static_cast(colorCursor);
+ IGpCursor_Win32 *winCursor = static_cast(cursor);
winCursor->IncRef();
@@ -797,6 +809,8 @@ GpDisplayDriverD3D11::GpDisplayDriverD3D11(const GpDisplayDriverProperties &prop
m_frameTimeSliceSize = m_QPFrequency.QuadPart * static_cast(properties.m_frameTimeLockNumerator) / static_cast(properties.m_frameTimeLockDenominator);
m_arrowCursor = reinterpret_cast(LoadImageW(nullptr, MAKEINTRESOURCEW(OCR_NORMAL), IMAGE_CURSOR, 0, 0, LR_SHARED));
+ m_ibeamCursor = reinterpret_cast(LoadImageW(nullptr, MAKEINTRESOURCEW(OCR_IBEAM), IMAGE_CURSOR, 0, 0, LR_SHARED));
+ m_waitCursor = reinterpret_cast(LoadImageW(nullptr, MAKEINTRESOURCEW(OCR_WAIT), IMAGE_CURSOR, 0, 0, LR_SHARED));
}
GpDisplayDriverD3D11::~GpDisplayDriverD3D11()
diff --git a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.h b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.h
index 4dcdca8..a9a61e2 100644
--- a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.h
+++ b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.h
@@ -11,7 +11,8 @@
#include "GpPixelFormat.h"
struct GpWindowsGlobals;
-struct IGpColorCursor_Win32;
+struct IGpCursor_Win32;
+struct IGpCursor;
struct IGpFiber;
struct IDXGISwapChain1;
@@ -37,10 +38,10 @@ public:
void GetDisplayResolution(unsigned int *width, unsigned int *height, GpPixelFormat_t *bpp) override;
IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) override;
- void DrawSurface(IGpDisplayDriverSurface *surface, size_t x, size_t y, size_t width, size_t height) override;
+ void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height) override;
- IGpColorCursor *LoadColorCursor(int cursorID) override;
- void SetColorCursor(IGpColorCursor *colorCursor) override;
+ IGpCursor *LoadCursor(bool isColor, int cursorID) override;
+ void SetCursor(IGpCursor *cursor) override;
void SetStandardCursor(EGpStandardCursor_t standardCursor) override;
void UpdatePalette(const void *paletteData) override;
@@ -109,8 +110,8 @@ private:
DWORD m_windowWidth;
DWORD m_windowHeight;
- IGpColorCursor_Win32 *m_activeCursor;
- IGpColorCursor_Win32 *m_pendingCursor;
+ IGpCursor_Win32 *m_activeCursor;
+ IGpCursor_Win32 *m_pendingCursor;
EGpStandardCursor_t m_currentStandardCursor;
EGpStandardCursor_t m_pendingStandardCursor;
bool m_mouseIsInClientArea;
@@ -119,5 +120,7 @@ private:
GpWindowsGlobals *m_osGlobals;
HCURSOR m_arrowCursor;
+ HCURSOR m_waitCursor;
+ HCURSOR m_ibeamCursor;
HWND m_hwnd;
};
diff --git a/PortabilityLayer/BitmapImage.h b/PortabilityLayer/BitmapImage.h
index defa68b..15a3e99 100644
--- a/PortabilityLayer/BitmapImage.h
+++ b/PortabilityLayer/BitmapImage.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "BMPFormat.h"
#include "SharedTypes.h"
diff --git a/PortabilityLayer/DialogManager.cpp b/PortabilityLayer/DialogManager.cpp
index 8ff3ad2..c0c6ca6 100644
--- a/PortabilityLayer/DialogManager.cpp
+++ b/PortabilityLayer/DialogManager.cpp
@@ -328,11 +328,6 @@ namespace PortabilityLayer
if (isVisible)
widget->DrawControl(surface);
- else
- {
- surface->SetForeColor(StdColors::Red());
- surface->FrameRect(surface->m_port.GetRect());
- }
}
}
@@ -621,7 +616,11 @@ namespace PortabilityLayer
WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
- WindowDef wdef = WindowDef::Create(rect, WindowStyleFlags::kAlert, visible, hasCloseBox, referenceConstant, positionSpec, title);
+ uint16_t styleFlags = WindowStyleFlags::kAlert;
+ if (hasCloseBox)
+ styleFlags |= PortabilityLayer::WindowStyleFlags::kCloseBox;
+
+ WindowDef wdef = WindowDef::Create(rect, styleFlags, visible, referenceConstant, positionSpec, title);
Window *window = wm->CreateWindow(wdef);
if (!window)
{
diff --git a/PortabilityLayer/HostDisplayDriver.h b/PortabilityLayer/HostDisplayDriver.h
index 518a7a1..00c6125 100644
--- a/PortabilityLayer/HostDisplayDriver.h
+++ b/PortabilityLayer/HostDisplayDriver.h
@@ -5,7 +5,7 @@
#include "GpPixelFormat.h"
#include "EGpStandardCursor.h"
-struct IGpColorCursor;
+struct IGpCursor;
struct IGpDisplayDriver;
namespace PortabilityLayer
diff --git a/PortabilityLayer/MenuManager.cpp b/PortabilityLayer/MenuManager.cpp
index 04b2965..55fb306 100644
--- a/PortabilityLayer/MenuManager.cpp
+++ b/PortabilityLayer/MenuManager.cpp
@@ -131,6 +131,11 @@ namespace PortabilityLayer
void SetItemChecked(const THandle