mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Refactor QD ports so they no longer need to be the first member of draw surfaces
This commit is contained in:
@@ -66,7 +66,6 @@ void UpdateCoordWindow (void)
|
||||
{
|
||||
#ifndef COMPILEDEMO
|
||||
Str255 tempStr, numStr;
|
||||
GrafPtr wasPort;
|
||||
|
||||
if (coordWindow == nil)
|
||||
return;
|
||||
|
111
GpApp/Events.cpp
111
GpApp/Events.cpp
@@ -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))
|
||||
|
@@ -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())
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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))
|
||||
|
@@ -46,15 +46,10 @@ void OffsetRect(Rect *rect, int right, int down)
|
||||
|
||||
DrawSurface *GetGraphicsPort()
|
||||
{
|
||||
PortabilityLayer::QDPort *port = PortabilityLayer::QDManager::GetInstance()->GetPort();
|
||||
|
||||
DrawSurface *grafPtr = reinterpret_cast<DrawSurface *>(port);
|
||||
assert(&grafPtr->m_port == port);
|
||||
|
||||
return grafPtr;
|
||||
return PortabilityLayer::QDManager::GetInstance()->GetPort();
|
||||
}
|
||||
|
||||
void SetGraphicsPort(DrawSurface *gw)
|
||||
{
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(&gw->m_port);
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(gw);
|
||||
}
|
||||
|
@@ -38,13 +38,7 @@ static inline void InvertPixel8(uint8_t &pixel)
|
||||
pixel = 255 ^ pixel;
|
||||
}
|
||||
|
||||
|
||||
void GetPort(GrafPtr *graf)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
void SetPort(GrafPtr graf)
|
||||
void SetPort(DrawSurface *graf)
|
||||
{
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(graf);
|
||||
}
|
||||
@@ -65,7 +59,7 @@ void SetRect(Rect *rect, short left, short top, short right, short bottom)
|
||||
void SetPortWindowPort(WindowPtr window)
|
||||
{
|
||||
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(&window->GetDrawSurface()->m_port);
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(window->GetDrawSurface());
|
||||
}
|
||||
|
||||
void SetPortDialogPort(Dialog *dialog)
|
||||
|
@@ -58,16 +58,13 @@ private:
|
||||
typedef CIcon *CIconPtr;
|
||||
typedef CIconPtr *CIconHandle;
|
||||
|
||||
typedef PortabilityLayer::QDPort GrafPort;
|
||||
typedef GrafPort *GrafPtr;
|
||||
|
||||
typedef Byte Pattern[8];
|
||||
|
||||
void GetPort(GrafPtr *graf);
|
||||
void SetPort(GrafPtr graf);
|
||||
void SetPortWindowPort(WindowPtr window);
|
||||
void SetPortDialogPort(Dialog *dialog);
|
||||
|
||||
|
||||
void SetPort(DrawSurface *graf);
|
||||
void EndUpdate(WindowPtr graf);
|
||||
|
||||
void SetRect(Rect *rect, short left, short top, short right, short bottom);
|
||||
|
@@ -98,11 +98,10 @@ struct DrawSurface
|
||||
|
||||
PortabilityLayer::RenderedFont *ResolveFont(bool aa) const;
|
||||
|
||||
// Must be the first item
|
||||
PortabilityLayer::QDPort m_port;
|
||||
|
||||
IGpDisplayDriverSurface *m_ddSurface;
|
||||
|
||||
PortabilityLayer::AntiAliasTable *m_cachedAATable;
|
||||
PortabilityLayer::RGBAColor m_cachedAAColor;
|
||||
|
||||
PortabilityLayer::QDPort m_port;
|
||||
};
|
||||
|
@@ -16,8 +16,8 @@ namespace PortabilityLayer
|
||||
QDManagerImpl();
|
||||
|
||||
void Init() override;
|
||||
QDPort *GetPort() const override;
|
||||
void SetPort(QDPort *gw) override;
|
||||
DrawSurface *GetPort() const override;
|
||||
void SetPort(DrawSurface *gw) override;
|
||||
PLError_t NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) override;
|
||||
void DisposeGWorld(DrawSurface *gw) override;
|
||||
QDState *GetState() override;
|
||||
@@ -25,7 +25,7 @@ namespace PortabilityLayer
|
||||
static QDManagerImpl *GetInstance();
|
||||
|
||||
private:
|
||||
QDPort *m_port;
|
||||
DrawSurface *m_port;
|
||||
|
||||
static QDManagerImpl ms_instance;
|
||||
};
|
||||
@@ -39,16 +39,16 @@ namespace PortabilityLayer
|
||||
{
|
||||
}
|
||||
|
||||
QDPort *QDManagerImpl::GetPort() const
|
||||
DrawSurface *QDManagerImpl::GetPort() const
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
|
||||
void QDManagerImpl::SetPort(QDPort *gw)
|
||||
void QDManagerImpl::SetPort(DrawSurface *gw)
|
||||
{
|
||||
#if GP_DEBUG_CONFIG
|
||||
if (gw)
|
||||
gw->CheckPortSentinel();
|
||||
gw->m_port.CheckPortSentinel();
|
||||
#endif
|
||||
|
||||
m_port = gw;
|
||||
@@ -83,7 +83,7 @@ namespace PortabilityLayer
|
||||
|
||||
QDState *QDManagerImpl::GetState()
|
||||
{
|
||||
return m_port->GetState();
|
||||
return m_port->m_port.GetState();
|
||||
}
|
||||
|
||||
QDManagerImpl *QDManagerImpl::GetInstance()
|
||||
|
@@ -16,8 +16,8 @@ namespace PortabilityLayer
|
||||
{
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual QDPort *GetPort() const = 0;
|
||||
virtual void SetPort(QDPort *gw) = 0;
|
||||
virtual DrawSurface *GetPort() const = 0;
|
||||
virtual void SetPort(DrawSurface *gw) = 0;
|
||||
virtual PLError_t NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) = 0;
|
||||
virtual void DisposeGWorld(DrawSurface *gw) = 0;
|
||||
|
||||
|
@@ -35,7 +35,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
#if GP_DEBUG_CONFIG
|
||||
// Detach the port BEFORE destroying it!!
|
||||
assert(PortabilityLayer::QDManager::GetInstance()->GetPort() != this);
|
||||
assert(&PortabilityLayer::QDManager::GetInstance()->GetPort()->m_port != this);
|
||||
#endif
|
||||
|
||||
DisposePixMap();
|
||||
|
@@ -1102,7 +1102,7 @@ namespace PortabilityLayer
|
||||
|
||||
DetachWindow(window);
|
||||
|
||||
if (PortabilityLayer::QDManager::GetInstance()->GetPort() == &windowImpl->GetDrawSurface()->m_port)
|
||||
if (PortabilityLayer::QDManager::GetInstance()->GetPort() == windowImpl->GetDrawSurface())
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(nullptr);
|
||||
|
||||
windowImpl->~WindowImpl();
|
||||
|
Reference in New Issue
Block a user