API cleanup, fix some lingering InvalWindowRects

This commit is contained in:
elasota
2020-03-14 06:38:46 -04:00
parent 3d37ded31d
commit cea0bde015
18 changed files with 37 additions and 213 deletions

View File

@@ -61,7 +61,7 @@ void DoAbout (void)
{
messagePtr = (**version).shortVersion + 1 + (**version).shortVersion[0];
BlockMove((Ptr)messagePtr, &longVersion, ((UInt8)*messagePtr) + 1);
memcpy(&longVersion, messagePtr, ((UInt8)*messagePtr) + 1);
SetDialogString(aboutDialog, kTextItemVers, longVersion);
}

View File

@@ -56,6 +56,7 @@ PLError_t DoOpenDocAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
DescType returnedType;
PLError_t theErr, whoCares;
short i;
bool redrawMainWindow = false;
theErr = AEGetParamDesc(theAE, keyDirectObject, typeAEList, &docList);
if (theErr != PLErrors::kNone)
@@ -112,7 +113,7 @@ PLError_t DoOpenDocAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
Rect updateRect;
SetRect(&updateRect, splashOriginH + 474, splashOriginV + 304, splashOriginH + 474 + 166, splashOriginV + 304 + 12);
InvalWindowRect(mainWindow, &updateRect);
redrawMainWindow = true;
}
}
}
@@ -120,6 +121,9 @@ PLError_t DoOpenDocAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
}
#endif
whoCares = AEDisposeDesc(&docList);
if (redrawMainWindow)
UpdateMainWindow();
return theErr;
}

View File

@@ -648,8 +648,8 @@ void CheckDuplicateFloorSuite (void)
{
bitPlace = (((*thisHouse)->rooms[i].floor + 7) * 128) +
(*thisHouse)->rooms[i].suite;
if ((bitPlace < 0) || (bitPlace >= 8192))
DebugStr(PSTR("Blew array"));
//if ((bitPlace < 0) || (bitPlace >= 8192))
// DebugStr(PSTR("Blew array"));
if (pidgeonHoles[bitPlace] != 0)
{
houseErrors++;

View File

@@ -173,7 +173,7 @@ void VariableInit (void)
fadeInSequence[14] = 9;
fadeInSequence[15] = 10;
doubleTime = GetDblTime();
doubleTime = 30; // PL_NotYetImplemented_TODO: Get this from the system settings
mirrorRects = nil;
mainWindow = nil;

View File

@@ -206,7 +206,6 @@ void UpdateLinkWindow (void)
return;
SetPortWindowPort(linkWindow);
DrawControls(linkWindow);
UpdateLinkControl();
#endif
}
@@ -259,6 +258,8 @@ void OpenLinkWindow (void)
linkObject = 255;
isLinkOpen = true;
UpdateLinkWindow();
}
#endif
}

View File

@@ -187,7 +187,7 @@ void UpdateClipboardMenus (void)
mm->SetItemText(houseMenu, iCopy - 1, title);
GetLocalizedString(38, title);
mm->SetItemText(houseMenu, iClear - 1, title);
mm->SetItemEnabled(houseMenu, iDuplicate - 1, false);
mm->SetItemEnabled(houseMenu, iDuplicate - 1, true);
}
else
{

View File

@@ -222,7 +222,7 @@ PLError_t LoadMusicSounds (void)
if (theMusicData[i] == nil)
return PLErrors::kOutOfMemory;
BlockMove(static_cast<Byte*>(*theSound), theMusicData[i], soundDataSize);
memcpy(theMusicData[i], static_cast<Byte*>(*theSound), soundDataSize);
theSound.Dispose();
}
return (theErr);

View File

@@ -306,7 +306,7 @@ void DragHandle (Window *window, DrawSurface *surface, Point where)
DragMarqueeHandle(window, surface, where, &hDelta);
thisRoom->objects[objActive].data.f.length = hDelta;
whoCares = KeepObjectLegal();
InvalWindowRect(mainWindow, &mainWindowRect);
redrawMainWindow = true;
GetThisRoomsObjRects();
ReadyBackground(thisRoom->background, thisRoom->tiles);
DrawThisRoomsObjects();
@@ -1150,6 +1150,7 @@ void DuplicateObject (void)
Point placePt;
short direction, dist;
Boolean handled;
bool redrawMainWindow = false;
tempObject = thisRoom->objects[objActive];
@@ -1313,7 +1314,7 @@ void DuplicateObject (void)
ReadyBackground(thisRoom->background, thisRoom->tiles);
GetThisRoomsObjRects();
DrawThisRoomsObjects();
InvalWindowRect(mainWindow, &mainWindowRect);
redrawMainWindow = true;
if (handled)
{
@@ -1323,6 +1324,9 @@ void DuplicateObject (void)
else
StartMarquee(&roomObjectRects[objActive]);
}
if (redrawMainWindow)
UpdateMainWindow();
}
//-------------------------------------------------------------- MoveObject
@@ -1657,51 +1661,6 @@ void MoveObject (short whichWay, Boolean shiftDown)
UpdateMenus(false);
GetThisRoomsObjRects();
if (objActive == kInitialGliderSelected)
{
InvalWindowRect(mainWindow, &wasRect);
InvalWindowRect(mainWindow, &initialGliderRect);
}
else if (objActive == kLeftGliderSelected)
{
InvalWindowRect(mainWindow, &wasRect);
InvalWindowRect(mainWindow, &leftStartGliderDest);
}
else if (objActive == kRightGliderSelected)
{
InvalWindowRect(mainWindow, &wasRect);
InvalWindowRect(mainWindow, &rightStartGliderDest);
}
else
{
switch (thisRoom->objects[objActive].what)
{
case kTiki:
case kTable:
case kShelf:
case kCabinet:
case kDeckTable:
case kStool:
case kCounter:
case kDresser:
case kGreaseRt:
case kGreaseLf:
case kSlider:
case kMailboxLf:
case kMailboxRt:
case kTrackLight:
case kMirror:
case kWallWindow:
InvalWindowRect(mainWindow, &mainWindowRect);
break;
default:
InvalWindowRect(mainWindow, &wasRect);
InvalWindowRect(mainWindow, &roomObjectRects[objActive]);
break;
}
}
ReadyBackground(thisRoom->background, thisRoom->tiles);
DrawThisRoomsObjects();
@@ -1721,6 +1680,8 @@ void MoveObject (short whichWay, Boolean shiftDown)
else
StartMarquee(&roomObjectRects[objActive]);
}
UpdateMainWindow();
#endif
}

View File

@@ -967,7 +967,6 @@ void BringSendFrontBack (Boolean bringFront)
fileDirty = true;
UpdateMenus(false);
InvalWindowRect(mainWindow, &mainWindowRect);
DeselectObject();
GetThisRoomsObjRects();
ReadyBackground(thisRoom->background, thisRoom->tiles);
@@ -975,6 +974,8 @@ void BringSendFrontBack (Boolean bringFront)
GenerateRetroLinks();
InitCursor();
UpdateMainWindow();
}
#endif

View File

@@ -229,7 +229,6 @@ int16_t LoadFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
return kScrollDownItem;
case PL_KEY_SPECIAL(kUpArrow):
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
thisHouseIndex -= 4;
if (thisHouseIndex < 0)
{
@@ -243,23 +242,20 @@ int16_t LoadFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
if (thisHouseIndex >= screenCount)
thisHouseIndex -= 4;
}
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
UpdateLoadDialog(dial);
return 0;
case PL_KEY_SPECIAL(kDownArrow):
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
thisHouseIndex += 4;
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
if (thisHouseIndex >= screenCount)
thisHouseIndex %= 4;
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
UpdateLoadDialog(dial);
return 0;
case PL_KEY_SPECIAL(kLeftArrow):
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
thisHouseIndex--;
if (thisHouseIndex < 0)
{
@@ -268,19 +264,18 @@ int16_t LoadFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
screenCount = kDispFiles;
thisHouseIndex = screenCount - 1;
}
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
UpdateLoadDialog(dial);
return 0;
case PL_KEY_SPECIAL(kTab):
case PL_KEY_SPECIAL(kRightArrow):
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
thisHouseIndex++;
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
if (thisHouseIndex >= screenCount)
thisHouseIndex = 0;
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
UpdateLoadDialog(dial);
return 0;
default:
@@ -308,10 +303,7 @@ int16_t LoadFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
thisHouseIndex = screenCount - 1;
}
if (wasIndex != thisHouseIndex)
{
InvalWindowRect(dial->GetWindow(), &loadHouseRects[wasIndex]);
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
}
UpdateLoadDialog(dial);
}
return 0;
}

View File

@@ -205,7 +205,7 @@ PLError_t LoadTriggerSound (short soundID)
}
else
{
BlockMove((Byte*)(*theSound), theSoundData[kMaxSounds - 1], soundDataSize);
memcpy(theSoundData[kMaxSounds - 1], (Byte*)(*theSound), soundDataSize);
theSound.Dispose();
}
}
@@ -246,7 +246,7 @@ PLError_t LoadBufferSounds (void)
if (theSoundData[i] == nil)
return (PLErrors::kOutOfMemory);
BlockMove(*theSound, theSoundData[i], soundDataSize);
memcpy(theSoundData[i], *theSound, soundDataSize);
theSound.Dispose();
}

View File

@@ -268,7 +268,7 @@ void CreatePointers (void)
{
GP_STATIC_ASSERT(sizeof(demoType) == 6);
BlockMove(*tempHandle, demoData, kDemoLength);
memcpy(demoData, *tempHandle, kDemoLength);
tempHandle.Dispose();
}
#endif

View File

@@ -114,7 +114,9 @@ void RedAlert (short errorNumber)
// CenterAlert(rDeathAlertID);
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rDeathAlertID, &substitutions);
ExitToShell();
//ExitToShell();
PL_NotYetImplemented_TODO("Exit");
}
//-------------------------------------------------------------- CreateOffScreenBitMap

View File

@@ -42,6 +42,9 @@ namespace PortabilityLayer
int16_t ButtonWidget::Capture(const Point &pos, WidgetUpdateCallback_t callback)
{
if (!m_enabled || !m_visible)
return 0;
bool drawingDownState = false;
bool isInBounds = m_rect.Contains(pos);
for (;;)

View File

@@ -3,12 +3,6 @@
#include "PLArrayViewIterator.h"
#include "PLWidgets.h"
int FindControl(Point point, WindowPtr window, ControlHandle *outControl)
{
PL_NotYetImplemented();
return 0;
}
int FindControl(Point point, WindowPtr window, PortabilityLayer::Widget **outControl)
{
// Returns clicked part
@@ -32,78 +26,3 @@ int FindControl(Point point, WindowPtr window, PortabilityLayer::Widget **outCon
*outControl = nullptr;
return 0;
}
void SetControlValue(ControlHandle control, int value)
{
PL_NotYetImplemented();
}
void SetControlMaximum(ControlHandle control, int value)
{
PL_NotYetImplemented();
}
void MoveControl(ControlHandle control, int x, int y)
{
PL_NotYetImplemented();
}
void SizeControl(ControlHandle control, int width, int height)
{
PL_NotYetImplemented();
}
int GetControlValue(ControlHandle control)
{
PL_NotYetImplemented();
return 0;
}
ControlHandle NewControl(WindowPtr window, const Rect *rect, const PLPasStr &label, Boolean visible, int value, int minValue, int maxValue, int cdef, long userdata)
{
PL_NotYetImplemented();
return nullptr;
}
ControlActionUPP NewControlActionUPP(ControlActionProc proc)
{
return proc;
}
void DisposeControlActionUPP(ControlActionUPP upp)
{
}
Boolean TrackControl(ControlHandle control, Point point, ControlActionUPP proc)
{
PL_NotYetImplemented();
return false;
}
Boolean TrackControl(PortabilityLayer::Widget *widget, Point point, ControlActionUPP proc)
{
PL_NotYetImplemented();
return false;
}
long GetControlReference(ControlHandle control)
{
PL_NotYetImplemented();
return 0;
}
ControlHandle GetNewControl(int resID, WindowPtr window)
{
PL_NotYetImplemented();
return nullptr;
}
void HiliteControl(ControlHandle control, int unknown)
{
PL_NotYetImplemented();
}
void HiliteControl(PortabilityLayer::Widget *widget, int unknown)
{
PL_NotYetImplemented();
}

View File

@@ -30,22 +30,5 @@ enum ControlParts
int FindControl(Point point, WindowPtr window, PortabilityLayer::Widget **outControl); // Returns part
int FindControl(Point point, WindowPtr window, ControlHandle *outControl);
void SetControlValue(ControlHandle control, int value);
void SetControlMaximum(ControlHandle control, int value);
void MoveControl(ControlHandle control, int x, int y);
void SizeControl(ControlHandle control, int width, int height);
int GetControlValue(ControlHandle control);
ControlHandle NewControl(WindowPtr window, const Rect *rect, const PLPasStr &label, Boolean visible, int value, int minValue, int maxValue, int cdef, long userdata);
ControlActionUPP NewControlActionUPP(ControlActionProc proc);
void DisposeControlActionUPP(ControlActionUPP upp);
Boolean TrackControl(ControlHandle control, Point point, ControlActionUPP proc);
Boolean TrackControl(PortabilityLayer::Widget *control, Point point, ControlActionUPP proc);
long GetControlReference(ControlHandle control); // Returns userdata
ControlHandle GetNewControl(int resID, WindowPtr window);
void HiliteControl(ControlHandle control, int unknown);
void HiliteControl(PortabilityLayer::Widget *widget, int unknown);
#endif

View File

@@ -538,12 +538,6 @@ void GetTime(DateTimeRec *dateTime)
dateTime->minute = minute;
}
UInt32 GetDblTime()
{
PL_NotYetImplemented_Minor();
return 30;
}
void FlushEvents(int mask, int unknown)
{
PortabilityLayer::EventQueue *queue = PortabilityLayer::EventQueue::GetInstance();
@@ -558,11 +552,6 @@ void ExitToShell()
PL_NotYetImplemented();
}
void InvalWindowRect(WindowPtr window, const Rect *rect)
{
PL_NotYetImplemented();
}
Handle NewHandle(Size size)
{
PortabilityLayer::MMHandleBlock *hBlock = PortabilityLayer::MemoryManager::GetInstance()->AllocHandle(size);
@@ -608,11 +597,6 @@ void DisposePtr(void *ptr)
PortabilityLayer::MemoryManager::GetInstance()->Release(ptr);
}
void BlockMove(const void *src, void *dest, Size size)
{
memcpy(dest, src, size);
}
bool WaitForEvent(TimeTaggedVOSEvent *eventOut, uint32_t ticks)
{
for (;;)
@@ -631,21 +615,6 @@ bool WaitForEvent(TimeTaggedVOSEvent *eventOut, uint32_t ticks)
return false;
}
void DrawControls(WindowPtr window)
{
PL_NotYetImplemented();
}
void DrawGrowIcon(WindowPtr window)
{
PL_NotYetImplemented();
}
void DebugStr(const PLPasStr &str)
{
PL_NotYetImplemented();
}
void PL_NotYetImplemented()
{
assert(false);

View File

@@ -247,7 +247,6 @@ static const int nullEvent = 0;
//void FlushEvents(int eventMask, int stopMask);
void InitCursor();
CursHandle GetCursor(int cursorID);
void HideCursor();
void Delay(int ticks, UInt32 *endTickCount);
@@ -295,12 +294,8 @@ Boolean WaitMouseUp();
short Random();
void GetTime(DateTimeRec *dateTime);
UInt32 GetDblTime();
void FlushEvents(int mask, int unknown);
void ExitToShell();
void InvalWindowRect(WindowPtr window, const Rect *rect);
Handle NewHandle(Size size);
long GetHandleSize(Handle handle);
@@ -311,15 +306,9 @@ void *NewPtr(Size size);
void *NewPtrClear(Size size);
void DisposePtr(void *ptr);
void BlockMove(const void *src, void *dest, Size size);
bool WaitForEvent(TimeTaggedVOSEvent *evt, uint32_t ticks);
void DrawControls(WindowPtr window);
void DrawGrowIcon(WindowPtr window);
void DebugStr(const PLPasStr &str);
static const Boolean PL_TRUE = 1;
static const Boolean PL_FALSE = 0;