Scaled blit, plus fix some level editor things

This commit is contained in:
elasota
2020-01-02 01:32:00 -05:00
parent 1c6ab800a7
commit 1da2851d3a
42 changed files with 571 additions and 273 deletions

View File

@@ -4,12 +4,15 @@
//----------------------------------------------------------------------------
//============================================================================
#include "PLArrayView.h"
#include "PLKeyEncoding.h"
#include "PLControlDefinitions.h"
#include "PLNumberFormatting.h"
#include "PLResources.h"
#include "PLSound.h"
#include "PLPasStr.h"
#include "PLSysCalls.h"
#include "PLWidgets.h"
#include "About.h"
#include "DialogManager.h"
#include "DialogUtils.h"
@@ -17,15 +20,16 @@
#include "Externs.h"
#include "HostSystemServices.h"
#include "ScanlineMask.h"
#include "PLTimeTaggedVOSEvent.h"
static void HiLiteOkayButton (DrawSurface *surface);
static void UnHiLiteOkayButton (DrawSurface *surface);
static void UpdateMainPict (Dialog *);
static Boolean AboutFilter (Dialog *, EventRecord *theEvent, short *hit);
static int16_t AboutFilter(Dialog *, const TimeTaggedVOSEvent &evt);
static PortabilityLayer::ScanlineMask *okayButtScanlineMask;
static Point okayButtLowerV, okayButtUpperV;
static Rect okayButtonBounds, mainPICTBounds;
static Boolean okayButtIsHiLit, clickedDownInOkay;
@@ -45,7 +49,7 @@ void DoAbout (void)
StringPtr messagePtr;
VersRecHndl version;
ControlHandle itemHandle;
short itemType, hit, wasResFile;
short hit, wasResFile;
wasResFile = CurResFile();
UseResFile(thisMac.thisResFile);
@@ -62,31 +66,25 @@ void DoAbout (void)
BlockMove((Ptr)messagePtr, &longVersion, ((UInt8)*messagePtr) + 1);
SetDialogString(aboutDialog, kTextItemVers, longVersion);
}
GetDialogItem(aboutDialog, kOkayButton, &itemType, &itemHandle, &okayButtonBounds);
#if 0
PL_NotYetImplemented_TODO("Misc");
okayButtRgn = NewRgn(); // Create diagonal button region
OpenRgn();
MoveTo(okayButtonBounds.left + 1, okayButtonBounds.top + 45);
Line(44, -44); // These lines define the region
Line(16, 16);
Line(-44, 44);
Line(-16, -16);
CloseRgn(okayButtRgn);
#endif
okayButtonBounds = aboutDialog->GetItems()[kOkayButton - 1].GetWidget()->GetRect();
okayButtUpperV = Point::Create(okayButtonBounds.left + 45, okayButtonBounds.top + 1);
okayButtLowerV = Point::Create(okayButtUpperV.h - 28, okayButtUpperV.v + 60);
okayButtIsHiLit = false; // Initially, button is not hilit
clickedDownInOkay = false; // Initially, didn't click in okay button
GetDialogItem(aboutDialog, kPictItemMain, &itemType, &itemHandle, &mainPICTBounds);
mainPICTBounds = aboutDialog->GetItems()[kPictItemMain - 1].GetWidget()->GetRect();
UpdateMainPict(aboutDialog);
do // Loop until user wants to exit
{
ModalDialog(AboutFilter, &hit);
hit = aboutDialog->ExecuteModal(AboutFilter);
}
while ((hit != kOkayButton) && (okayButtScanlineMask != nil));
if (okayButtScanlineMask != nil)
okayButtScanlineMask->Destroy(); // Clean up!
while (hit != kOkayButton);
aboutDialog->Destroy();
UseResFile(wasResFile);
@@ -99,7 +97,7 @@ void DoAbout (void)
static void HiLiteOkayButton (DrawSurface *surface)
{
#define kOkayButtPICTHiLit 151 // res ID of unhilit button PICT
PicHandle thePict;
THandle<Picture> thePict;
if (!okayButtIsHiLit)
{
@@ -121,7 +119,7 @@ static void HiLiteOkayButton (DrawSurface *surface)
static void UnHiLiteOkayButton (DrawSurface *surface)
{
#define kOkayButtPICTNotHiLit 150 // res ID of hilit button PICT
PicHandle thePict;
THandle<Picture> thePict;
if (okayButtIsHiLit)
{
@@ -143,8 +141,6 @@ static void UpdateMainPict (Dialog *theDial)
{
Str255 theStr, theStr2;
uint64_t freeMemory;
DrawDialog(theDial);
freeMemory = PortabilityLayer::HostSystemServices::GetInstance()->GetFreeMemoryCosmetic();
@@ -168,96 +164,93 @@ static void UpdateMainPict (Dialog *theDial)
DrawDialogUserText2(theDial, 8, theStr);
}
static bool PointIsInDiagonalOkayButton(const Point &pt)
{
const Point upperVPt = pt - okayButtUpperV;
const Point lowerVPt = pt - okayButtLowerV;
const bool edge1 = (upperVPt.h + upperVPt.v) >= 0;
const bool edge2 = (-upperVPt.h + upperVPt.v) >= 0;
const bool edge3 = (lowerVPt.h - lowerVPt.v) >= 0;
const bool edge4 = (-lowerVPt.h - lowerVPt.v) >= 0;
return edge1 && edge2 && edge3 && edge4;
}
//-------------------------------------------------------------- AboutFilter
// Dialog filter for the About dialog.
static Boolean AboutFilter (Dialog *theDial, EventRecord *theEvent, short *hit)
static int16_t AboutFilter(Dialog *dialog, const TimeTaggedVOSEvent &evt)
{
Point mousePt;
UInt32 dummyLong;
Boolean handledIt;
bool handledIt = false;
int16_t hit = -1;
DrawSurface *surface = theDial->GetWindow()->GetDrawSurface();
if (Button() && clickedDownInOkay)
Window *window = dialog->GetWindow();
DrawSurface *surface = window->GetDrawSurface();
if (evt.IsKeyDownEvent())
{
GetMouse(&mousePt);
if(PointInScanlineMask(mousePt, okayButtScanlineMask))
HiLiteOkayButton(surface);
else
UnHiLiteOkayButton(surface);
}
switch (theEvent->what)
{
case keyDown:
switch (theEvent->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):
HiLiteOkayButton(surface);
Delay(8, &dummyLong);
PLSysCalls::Sleep(8);
UnHiLiteOkayButton(surface);
*hit = kOkayButton;
hit = kOkayButton;
handledIt = true;
break;
default:
handledIt = false;
}
break;
case mouseDown:
mousePt = theEvent->where;
GlobalToLocal(&mousePt);
if(PointInScanlineMask(mousePt, okayButtScanlineMask))
{
clickedDownInOkay = true;
handledIt = false;
}
else
handledIt = false;
break;
case mouseUp:
mousePt = theEvent->where;
GlobalToLocal(&mousePt);
if(PointInScanlineMask(mousePt, okayButtScanlineMask) && clickedDownInOkay)
{
UnHiLiteOkayButton(surface);
*hit = kOkayButton;
handledIt = true;
}
else
{
clickedDownInOkay = false;
handledIt = false;
}
break;
case updateEvt:
if ((WindowPtr)theEvent->message == mainWindow)
{
SetPort((GrafPtr)mainWindow);
UpdateMainWindow();
EndUpdate((WindowPtr)theEvent->message);
SetPortDialogPort(theDial);
handledIt = true;
}
else if ((WindowPtr)theEvent->message == (WindowPtr)theDial)
{
SetPortDialogPort(theDial);
UpdateMainPict(theDial);
EndUpdate((WindowPtr)theEvent->message);
handledIt = false;
}
break;
default:
handledIt = false;
break;
handledIt = false;
break;
}
}
return (handledIt);
else if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kMouseInput)
{
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
const Point mousePt = window->MouseToLocal(mouseEvt);
if (mouseEvt.m_eventType == GpMouseEventTypes::kDown)
{
if (PointIsInDiagonalOkayButton(mousePt))
{
HiLiteOkayButton(surface);
clickedDownInOkay = true;
handledIt = false;
}
else
handledIt = false;
}
else if (mouseEvt.m_eventType == GpMouseEventTypes::kUp)
{
if (PointIsInDiagonalOkayButton(mousePt) && clickedDownInOkay)
{
UnHiLiteOkayButton(surface);
hit = kOkayButton;
handledIt = true;
}
else
{
clickedDownInOkay = false;
handledIt = false;
}
}
else if (mouseEvt.m_eventType == GpMouseEventTypes::kMove)
{
if (clickedDownInOkay)
{
if (PointIsInDiagonalOkayButton(mousePt))
HiLiteOkayButton(surface);
else
UnHiLiteOkayButton(surface);
}
}
}
if (!handledIt)
return -1;
return hit;
}

View File

@@ -394,12 +394,7 @@ void GetDialogString (Dialog *theDialog, short item, StringPtr theString)
void SetDialogString (Dialog *theDialog, short item, const PLPasStr &theString)
{
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
SetDialogItemText(itemHandle, theString);
theDialog->GetItems()[item - 1].GetWidget()->SetString(theString);
}
//-------------------------------------------------------------- GetDialogStringLen
@@ -662,8 +657,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
{
Rect iRect;
ControlHandle iHandle;
;
Str255 stringCopy;
short iType;
@@ -671,7 +665,8 @@ void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None);
PasStringCopy(text, stringCopy);
GetDialogItem(dial, item, &iType, &iHandle, &iRect);
const Rect iRect = dial->GetItems()[item - 1].GetWidget()->GetRect();
if ((surface->MeasureString(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(surface, stringCopy, iRect.right - iRect.left - 2);
@@ -687,7 +682,7 @@ void LoadDialogPICT (Dialog *theDialog, short item, short theID)
{
Rect iRect;
ControlHandle iHandle;
PicHandle thePict;
THandle<Picture> thePict;
short iType;
GetDialogItem(theDialog, item, &iType, &iHandle, &iRect);

View File

@@ -14,6 +14,7 @@
#include "Externs.h"
#include "Environ.h"
#include "FileManager.h"
#include "HostFileSystem.h"
#include "House.h"
#include "IOStream.h"
#include "ObjectEdit.h"
@@ -960,52 +961,7 @@ void YellowAlert (short whichAlert, short identifier)
//-------------------------------------------------------------- IsFileReadOnly
Boolean IsFileReadOnly (const VFileSpec &)
Boolean IsFileReadOnly (const VFileSpec &spec)
{
PL_NotYetImplemented_TODO("FileSystem");
return true;
/*
Str255 tempStr;
ParamBlockRec theBlock;
HParamBlockRec hBlock;
VolumeParam *volPtr;
PLError_t theErr;
volPtr = (VolumeParam *)&theBlock;
volPtr->ioCompletion = nil;
volPtr->ioVolIndex = 0;
volPtr->ioNamePtr = tempStr;
volPtr->ioVRefNum = theSpec->vRefNum;
theErr = PBGetVInfo(&theBlock, false);
if (CheckFileError(theErr, "\pRead/Write"))
{
if (((volPtr->ioVAtrb & 0x0080) == 0x0080) ||
((volPtr->ioVAtrb & 0x8000) == 0x8000))
return (true); // soft/hard locked bits
else
{
hBlock.fileParam.ioCompletion = nil;
hBlock.fileParam.ioVRefNum = theSpec->vRefNum;
hBlock.fileParam.ioFVersNum = 0;
hBlock.fileParam.ioFDirIndex = 0;
hBlock.fileParam.ioNamePtr = theSpec->name;
hBlock.fileParam.ioDirID = theSpec->parID;
theErr = PBHGetFInfo(&hBlock, false);
if (CheckFileError(theErr, "\pRead/Write"))
{
if ((hBlock.fileParam.ioFlAttrib & 0x0001) == 0x0001)
return (true);
else
return (false);
}
else
return (false);
}
}
else
return (false);
*/
return PortabilityLayer::FileManager::GetInstance()->FileLocked(spec.m_dir, spec.m_name);
}

View File

@@ -9,6 +9,7 @@
#include "Externs.h"
#include "Environ.h"
#include "Map.h"
#include "MenuManager.h"
#include "PLKeyEncoding.h"
#include "RectUtils.h"
#include "Tools.h"
@@ -64,7 +65,7 @@ void InitializeMenus (void)
InsertMenu(optionsMenu, 0);
menusUp = true;
DrawMenuBar();
PortabilityLayer::MenuManager::GetInstance()->SetMenuVisible(true);
houseMenu = GetMenu(kHouseMenuID);
if (houseMenu == nil)

View File

@@ -198,7 +198,7 @@ void OpenMainWindow (void)
if (theMode == kEditMode)
{
if (menuWindow != nil)
DisposeWindow(menuWindow);
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(menuWindow);
menuWindow = nil;
QSetRect(&mainWindowRect, 0, 0, 512, 322);
@@ -289,6 +289,12 @@ void OpenMainWindow (void)
SetPortWindowPort(mainWindow);
}
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&mainWindowRect, &mainWindowRect, srcCopy);
mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
//-------------------------------------------------------------- CloseMainWindow
@@ -298,11 +304,11 @@ void OpenMainWindow (void)
void CloseMainWindow (void)
{
if (mainWindow != nil)
DisposeWindow(mainWindow);
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(mainWindow);
mainWindow = nil;
if (boardWindow != nil)
DisposeWindow(boardWindow);
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(boardWindow);
boardWindow = nil;
}

View File

@@ -161,7 +161,7 @@ void FindNewActiveRoomRect (void)
void LoadGraphicPlus (DrawSurface *surface, short resID, const Rect &theRect)
{
PicHandle thePicture;
THandle<Picture> thePicture;
thePicture = GetPicture(resID);
if (thePicture == nil)

View File

@@ -15,6 +15,7 @@
#include "DialogUtils.h"
#include "Externs.h"
#include "House.h"
#include "MenuManager.h"
#include "ObjectEdit.h"
@@ -250,10 +251,15 @@ void UpdateMenus (Boolean newMode)
if (newMode)
{
PortabilityLayer::MenuManager *mm = PortabilityLayer::MenuManager::GetInstance();
if (theMode == kEditMode)
InsertMenu(houseMenu, 0);
else
DeleteMenu(kHouseMenuID);
{
THandle<Menu> houseMenu = mm->GetMenuByID(kHouseMenuID);
if (houseMenu)
mm->RemoveMenu(houseMenu);
}
}
if (theMode == kEditMode)
@@ -270,8 +276,6 @@ void UpdateMenus (Boolean newMode)
}
else
UpdateMenusNonEditMode();
DrawMenuBar();
}
//-------------------------------------------------------------- DoAppleMenu
@@ -619,8 +623,6 @@ void DoMenuChoice (long menuChoice)
DoHouseMenu(theItem);
break;
}
HiliteMenu(0);
}
//-------------------------------------------------------------- UpdateMapCheckmark

View File

@@ -1045,7 +1045,7 @@ void DrawCalendar (Rect *theRect)
{
DateTimeRec timeRec;
Rect bounds;
PicHandle thePicture;
THandle<Picture> thePicture;
Str255 monthStr;
DrawSurface *wasCPort;
@@ -1076,7 +1076,7 @@ void DrawCalendar (Rect *theRect)
void DrawBulletin (Rect *theRect)
{
Rect bounds;
PicHandle thePicture;
THandle<Picture> thePicture;
thePicture = GetPicture(kBulletinPictID);
if (thePicture == nil)
@@ -1094,7 +1094,7 @@ void DrawBulletin (Rect *theRect)
void DrawPictObject (short what, Rect *theRect)
{
Rect bounds;
PicHandle thePicture;
THandle<Picture> thePicture;
short pictID;
switch (what)

View File

@@ -2004,7 +2004,7 @@ void SelectPrevObject (void)
#ifndef COMPILEDEMO
void GetThisRoomsObjRects (void)
{
PicHandle thePict;
THandle<Picture> thePict;
short i, wide, tall;
isFirstRoom = (GetFirstRoomNumber() == thisRoomNumber);

View File

@@ -31,7 +31,7 @@ extern short nHotSpots, numChimes;
void GetObjectRect (objectPtr who, Rect *itsRect)
{
PicHandle thePict;
THandle<Picture> thePict;
short wide, tall;
switch (who->what)

View File

@@ -451,7 +451,7 @@ void PlayGame (void)
{
Rect bounds;
PicHandle thePicture;
THandle<Picture> thePicture;
SInt16 hOffset;
if (boardSrcRect.right >= 640)
@@ -495,7 +495,7 @@ void PlayGame (void)
{
Rect bounds;
PicHandle thePicture;
THandle<Picture> thePicture;
SInt16 hOffset;
if (boardSrcRect.right >= 640)

View File

@@ -10,6 +10,7 @@
#include "PLPasStr.h"
#include "PLStandardColors.h"
#include "Externs.h"
#include "FontFamily.h"
#include "House.h"
#include "MainWindow.h"
#include "RectUtils.h"
@@ -236,7 +237,7 @@ Boolean CreateNewRoom (short h, short v)
void ReadyBackground (short theID, short *theTiles)
{
Rect src, dest;
PicHandle thePicture;
THandle<Picture> thePicture;
short i;
if ((noRoomAtAll) || (!houseUnlocked))
@@ -244,6 +245,7 @@ void ReadyBackground (short theID, short *theTiles)
LtGrayForeColor(workSrcMap);
workSrcMap->FillRect(workSrcRect);
workSrcMap->SetForeColor(StdColors::Black());
workSrcMap->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None);
const Point textPoint = Point::Create(10, 20);
if (houseUnlocked)
@@ -319,11 +321,19 @@ void ReflectCurrentRoom (Boolean forceMapRedraw)
}
}
GenerateRetroLinks();
DebugPixMap(backSrcMap->m_port.GetPixMap(), "DebugData/EditorSplash1");
UpdateEditWindowTitle();
DebugPixMap(backSrcMap->m_port.GetPixMap(), "DebugData/EditorSplash2");
ReadyBackground(thisRoom->background, thisRoom->tiles);
DebugPixMap(backSrcMap->m_port.GetPixMap(), "DebugData/EditorSplash3");
GetThisRoomsObjRects();
DebugPixMap(backSrcMap->m_port.GetPixMap(), "DebugData/EditorSplash4");
DrawThisRoomsObjects();
InvalWindowRect(mainWindow, &mainWindowRect);
DebugPixMap(backSrcMap->m_port.GetPixMap(), "DebugData/EditorSplash5");
PL_NotYetImplemented_TODO("FixMe");
DebugPixMap(backSrcMap->m_port.GetPixMap(), "DebugData/EditorSplash6");
//InvalWindowRect(mainWindow, &mainWindowRect);
#endif
}

View File

@@ -131,7 +131,7 @@ void DrawLocale (void)
void LoadGraphicSpecial (DrawSurface *surface, short resID)
{
Rect bounds;
PicHandle thePicture;
THandle<Picture> thePicture;
thePicture = GetPicture(resID);
if (thePicture == nil)

View File

@@ -857,7 +857,7 @@ short ChooseOriginalArt (short was)
Boolean PictIDExists (short theID)
{
PicHandle thePicture;
THandle<Picture> thePicture;
// Handle resHandle;
// Str255 resName;
// ResType resType;

View File

@@ -513,7 +513,7 @@ void DoControlPrefs (void)
prefDlg = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kControlPrefsDialID, kPutInFront);
if (prefDlg == nil)
RedAlert(kErrDialogDidntLoad);
SetPort((GrafPtr)prefDlg);
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
for (i = 0; i < 4; i++)
{
GetDialogItemRect(prefDlg, i + kRightControl, &controlRects[i]);

View File

@@ -61,7 +61,7 @@ extern short wasScoreboardMode;
void InitScoreboardMap (void)
{
Rect bounds;
PicHandle thePicture;
THandle<Picture> thePicture;
DrawSurface *wasCPort;
PLError_t theErr;
short hOffset;

View File

@@ -282,7 +282,7 @@ void KillOffScreenBitMap (GrafPtr offScreen)
void LoadGraphic (DrawSurface *surface, short resID)
{
Rect bounds;
PicHandle thePicture;
THandle<Picture> thePicture;
thePicture = GetPicture(resID);
if (thePicture == nil)
@@ -302,7 +302,7 @@ void LoadGraphic (DrawSurface *surface, short resID)
void LoadScaledGraphic (DrawSurface *surface, short resID, Rect *theRect)
{
PicHandle thePicture;
THandle<Picture> thePicture;
thePicture = GetPicture(resID);
if (thePicture == nil)