Refactor QD ports so they no longer need to be the first member of draw surfaces

This commit is contained in:
elasota
2020-05-20 23:33:17 -04:00
parent f53dc21475
commit 66fc278ce9
18 changed files with 29 additions and 154 deletions

View File

@@ -66,7 +66,6 @@ void UpdateCoordWindow (void)
{
#ifndef COMPILEDEMO
Str255 tempStr, numStr;
GrafPtr wasPort;
if (coordWindow == nil)
return;

View File

@@ -315,115 +315,6 @@ void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent
}
}
//-------------------------------------------------------------- HandleUpdateEvent
// Handle an update event.
#if 0
void HandleUpdateEvent (EventRecord *theEvent)
{
if ((WindowPtr)theEvent->message == mainWindow)
{
SetPort((GrafPtr)mainWindow);
UpdateMainWindow();
EndUpdate(mainWindow);
}
else if ((WindowPtr)theEvent->message == mapWindow)
{
SetPort((GrafPtr)mapWindow);
UpdateMapWindow();
EndUpdate(mapWindow);
}
else if ((WindowPtr)theEvent->message == toolsWindow)
{
SetPort((GrafPtr)toolsWindow);
UpdateToolsWindow();
EndUpdate(toolsWindow);
}
else if ((WindowPtr)theEvent->message == linkWindow)
{
SetPort((GrafPtr)linkWindow);
UpdateLinkWindow();
EndUpdate(linkWindow);
}
else if ((WindowPtr)theEvent->message == coordWindow)
{
SetPort((GrafPtr)coordWindow);
UpdateCoordWindow();
EndUpdate(coordWindow);
}
}
//-------------------------------------------------------------- HandleOSEvent
// Handle an OS Event (MultiFinder - user has switched in or out of app).
void HandleOSEvent (EventRecord *theEvent)
{
PLError_t theErr;
short buttonHit;
if (theEvent->message & 0x01000000) // suspend or resume event
{
if (theEvent->message & 0x00000001) // resume event
{
if (WhatsOurDepth() != thisMac.isDepth)
{
buttonHit = BitchAboutColorDepth();
if (buttonHit == 1) // player wants to Quit
{
#ifndef COMPILEDEMO
if (QuerySaveChanges())
quitting = true;
#else
quitting = true;
#endif
}
else
{
SwitchToDepth(thisMac.isDepth, thisMac.wasColorOrGray);
}
}
switchedOut = false;
InitCursor();
if ((isPlayMusicIdle) && (theMode != kEditMode))
{
theErr = StartMusic();
if (theErr != PLErrors::kNone)
{
YellowAlert(kYellowNoMusic, theErr);
failedMusic = true;
}
}
incrementModeTime = TickCount() + kIdleSplashTicks;
#ifndef COMPILEDEMO
// if (theMode == kEditMode)
// SeeIfValidScrapAvailable(true);
#endif
}
else // suspend event
{
switchedOut = true;
InitCursor();
if ((isMusicOn) && (theMode != kEditMode))
StopTheMusic();
}
}
}
//-------------------------------------------------------------- HandleHighLevelEvent
// Handle an AppleEvent (Open Document, Quit Application, etc.).
void HandleHighLevelEvent (EventRecord *theEvent)
{
PLError_t theErr;
theErr = AEProcessAppleEvent(theEvent);
if ((theErr != PLErrors::kNone) && (theErr != errAEEventNotHandled))
YellowAlert(kYellowAppleEventErr, theErr);
}
#endif
//-------------------------------------------------------------- HandleSplashResolutionChange
void HandleSplashResolutionChange(void)
{
@@ -496,7 +387,7 @@ void HandleIdleTask (void)
HandleEditorResolutionChange();
}
SetPort(&mainWindow->GetDrawSurface()->m_port);
SetPort(mainWindow->GetDrawSurface());
DoMarquee();
if ((autoRoomEdit) && (newRoomNow))

View File

@@ -68,7 +68,7 @@ void DoGameOver (void)
DrawSurface *surface = mainWindow->GetDrawSurface();
playing = false;
SetUpFinalScreen();
SetPort((GrafPtr)mainWindow);
SetPort(mainWindow->GetDrawSurface());
ColorRect(surface, mainWindowRect, 244);
DoGameOverStarAnimation();
if (!TestHighScore())

View File

@@ -71,7 +71,7 @@ void DoHighScores (void)
Rect tempRect;
SpinCursor(3);
SetPort(&workSrcMap->m_port);
SetPort(workSrcMap);
workSrcMap->SetForeColor(StdColors::Black());
workSrcMap->FillRect(workSrcRect);
QSetRect(&tempRect, 0, 0, 640, 480);

View File

@@ -231,7 +231,7 @@ void DoHouseInfo (void)
houseInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kHouseInfoDialogID, kPutInFront, &substitutions);
if (houseInfoDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetPort(&houseInfoDialog->GetWindow()->GetDrawSurface()->m_port);
SetPort(houseInfoDialog->GetWindow()->GetDrawSurface());
ShowWindow(houseInfoDialog->GetWindow());
static_cast<PortabilityLayer::EditboxWidget*>(houseInfoDialog->GetItems()[kBannerTextItem - 1].GetWidget())->SetMultiLine(true);

View File

@@ -415,7 +415,7 @@ void OpenMapWindow (void)
PortabilityLayer::WindowManager::GetInstance()->ShowWindow(mapWindow);
// FlagWindowFloating(mapWindow); TEMP - use flaoting windows
SetPort(&mapWindow->GetDrawSurface()->m_port);
SetPort(mapWindow->GetDrawSurface());
QSetRect(&mapHScrollRect, -1, mapRoomsHigh * kMapRoomHeight,
mapRoomsWide * kMapRoomWidth + 1,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth);

View File

@@ -732,7 +732,7 @@ void DoBlowerObjectInfo (short what)
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kBlowerInfoDialogID, kPutInFront, &substitutions);
if (infoDial == nil)
RedAlert(kErrDialogDidntLoad);
SetPort(&infoDial->GetWindow()->GetDrawSurface()->m_port);
SetPort(infoDial->GetWindow()->GetDrawSurface());
newDirection = thisRoom->objects[objActive].data.a.vector & 0x0F;
if (thisRoom->objects[objActive].data.a.initial)
@@ -1349,7 +1349,7 @@ void DoLightObjectInfo (void)
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kLightInfoDialogID, kPutInFront, &substitutions);
if (infoDial == nil)
RedAlert(kErrDialogDidntLoad);
SetPort(&infoDial->GetWindow()->GetDrawSurface()->m_port);
SetPort(infoDial->GetWindow()->GetDrawSurface());
if (thisRoom->objects[objActive].data.f.initial)
SetDialogItemValue(infoDial, kInitialStateCheckbox, 1);

View File

@@ -147,7 +147,7 @@ void DrawReflection (gliderPtr thisGlider, Boolean oneOrTwo)
dest = thisGlider->dest;
QOffsetRect(&dest, playOriginH - 20, playOriginV - 16);
SetPort(&workSrcMap->m_port);
SetPort(workSrcMap);
long numMirrorRects = GetHandleSize(mirrorRects.StaticCast<void>()) / sizeof(Rect);

View File

@@ -465,7 +465,7 @@ void DoRoomInfo(void)
roomInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kRoomInfoDialogID, kPutInFront, &substitutions);
if (roomInfoDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetPort(&roomInfoDialog->GetWindow()->GetDrawSurface()->m_port);
SetPort(roomInfoDialog->GetWindow()->GetDrawSurface());
{
PortabilityLayer::WidgetBasicState state;

View File

@@ -200,7 +200,7 @@ void EraseSelectedTool (void)
if (toolsWindow == nil)
return;
SetPort(&toolsWindow->GetDrawSurface()->m_port);
SetPort(toolsWindow->GetDrawSurface());
toolIcon = toolSelected;
if ((toolMode == kBlowerMode) && (toolIcon >= 7))