mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Level editor work
This commit is contained in:
@@ -364,9 +364,9 @@ void DrawDefaultButton (Dialog *theDialog)
|
||||
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
|
||||
for (int xOffset = 0; xOffset < 3; xOffset++)
|
||||
for (int xOffset = -1; xOffset <= 1; xOffset++)
|
||||
{
|
||||
for (int yOffset = 0; yOffset < 3; yOffset++)
|
||||
for (int yOffset = -1; yOffset <= 1; yOffset++)
|
||||
{
|
||||
const Rect offsetRect = itemRect + Point::Create(xOffset, yOffset);
|
||||
surface->FrameRoundRect(offsetRect, 8, 8);
|
||||
@@ -646,7 +646,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
|
||||
if (invert)
|
||||
{
|
||||
OffsetRect(&iRect, 0, 1);
|
||||
InvertRect(&iRect);
|
||||
surface->InvertFillRect(iRect, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,12 +680,10 @@ void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
|
||||
|
||||
void LoadDialogPICT (Dialog *theDialog, short item, short theID)
|
||||
{
|
||||
Rect iRect;
|
||||
ControlHandle iHandle;
|
||||
THandle<Picture> thePict;
|
||||
short iType;
|
||||
|
||||
GetDialogItem(theDialog, item, &iType, &iHandle, &iRect);
|
||||
|
||||
Rect iRect = theDialog->GetItems()[item - 1].GetWidget()->GetRect();;
|
||||
|
||||
thePict = GetPicture(theID);
|
||||
if (thePict)
|
||||
theDialog->GetWindow()->GetDrawSurface()->DrawPicture(thePict, iRect);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class ResourceFile;
|
||||
class ScanlineMask;
|
||||
}
|
||||
|
||||
@@ -197,7 +198,7 @@ UInt32 RandomLongQUS (void);
|
||||
void RedAlert (short);
|
||||
void LoadGraphic (DrawSurface *, short);
|
||||
void LoadScaledGraphic (DrawSurface *, short, Rect *);
|
||||
void LargeIconPlot (Rect *, short);
|
||||
bool LargeIconPlot (DrawSurface *, PortabilityLayer::ResourceFile *, short, const Rect &);
|
||||
void DrawCIcon (DrawSurface *surface, short, short, short);
|
||||
char KeyMapOffsetFromRawKey (char);
|
||||
long LongSquareRoot (long);
|
||||
|
||||
@@ -994,6 +994,10 @@ void HandleSwitches (hotPtr who)
|
||||
roomLinked = masterObjects[whoLinked].roomLink;
|
||||
objectLinked = masterObjects[whoLinked].objectLink;
|
||||
linkIndex = masterObjects[whoLinked].localLink;
|
||||
|
||||
if (roomLinked < 0)
|
||||
return; // GP: Some objects (like Leviathan) have corrupted switch data
|
||||
|
||||
// change state of linked obj.
|
||||
if (SetObjectState(roomLinked, objectLinked,
|
||||
masterObjects[whoLinked].theObject.data.e.type, linkIndex))
|
||||
|
||||
@@ -346,7 +346,7 @@ void DoGameMenu (short theItem)
|
||||
Rect updateRect;
|
||||
|
||||
SetRect(&updateRect, splashOriginH + 474, splashOriginV + 304, splashOriginH + 474 + 166, splashOriginV + 304 + 12);
|
||||
InvalWindowRect(mainWindow, &updateRect);
|
||||
UpdateMainWindow();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -355,7 +355,7 @@ void AddTempManholeRect (Rect *manHole)
|
||||
Boolean SetObjectState (short room, short object, short action, short local)
|
||||
{
|
||||
char wasState;
|
||||
Boolean changed;
|
||||
Boolean changed = false;
|
||||
|
||||
switch ((*thisHouse)->rooms[room].objects[object].what)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "FileManager.h"
|
||||
#include "House.h"
|
||||
#include "RectUtils.h"
|
||||
#include "ResourceFile.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "VirtualDirectory.h"
|
||||
|
||||
|
||||
@@ -42,7 +44,7 @@
|
||||
void UpdateLoadDialog (Dialog *);
|
||||
void PageUpHouses (Dialog *);
|
||||
void PageDownHouses (Dialog *);
|
||||
Boolean LoadFilter (Dialog *, EventRecord *, short *);
|
||||
int16_t LoadFilter (Dialog *, const TimeTaggedVOSEvent &);
|
||||
void SortHouseList (void);
|
||||
void DoDirSearch (void);
|
||||
|
||||
@@ -66,12 +68,14 @@ extern UInt32 doubleTime;
|
||||
void UpdateLoadDialog (Dialog *theDialog)
|
||||
{
|
||||
Rect tempRect, dialogRect, dummyRect;
|
||||
short houseStart, houseStop, i, wasResFile, isResFile, count;
|
||||
short houseStart, houseStop, i, wasResFile, count;
|
||||
// char wasState;
|
||||
WindowRef theWindow;
|
||||
// RgnHandle theRegion;
|
||||
|
||||
|
||||
theWindow = theDialog->GetWindow();
|
||||
DrawSurface *surface = theWindow->GetDrawSurface();
|
||||
|
||||
GetWindowBounds(theWindow, kWindowContentRgn, &dialogRect);
|
||||
/*
|
||||
wasState = HGetState((Handle)(((DialogPeek)theDialog)->window).port.visRgn);
|
||||
@@ -79,8 +83,7 @@ void UpdateLoadDialog (Dialog *theDialog)
|
||||
dialogRect = (**((((DialogPeek)theDialog)->window).port.visRgn)).rgnBBox;
|
||||
HSetState((Handle)(((DialogPeek)theDialog)->window).port.visRgn, wasState);
|
||||
*/
|
||||
|
||||
DrawDialog(theDialog);
|
||||
|
||||
ColorFrameWHRect(theDialog->GetWindow()->GetDrawSurface(), 8, 39, 413, 184, kRedOrangeColor8); // box around files
|
||||
|
||||
houseStart = housePage;
|
||||
@@ -88,7 +91,6 @@ void UpdateLoadDialog (Dialog *theDialog)
|
||||
if ((houseStop - houseStart) > kDispFiles)
|
||||
houseStop = houseStart + kDispFiles;
|
||||
|
||||
wasResFile = CurResFile();
|
||||
count = 0;
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
@@ -103,17 +105,16 @@ void UpdateLoadDialog (Dialog *theDialog)
|
||||
|
||||
if (SectRect(&dialogRect, &tempRect, &dummyRect))
|
||||
{
|
||||
isResFile = HOpenResFile(theHousesSpecs[i].m_dir, theHousesSpecs[i].m_name, fsRdPerm);
|
||||
if (isResFile != -1)
|
||||
PortabilityLayer::ResourceFile *resFile = PortabilityLayer::ResourceManager::GetInstance()->LoadResFile(theHousesSpecs[i].m_dir, theHousesSpecs[i].m_name);
|
||||
if (resFile != nullptr)
|
||||
{
|
||||
if (Get1Resource('icl8', -16455) != nil)
|
||||
if (!LargeIconPlot(surface, resFile, -16455, tempRect))
|
||||
{
|
||||
LargeIconPlot(&tempRect, -16455);
|
||||
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
|
||||
kDefaultHousePict8);
|
||||
}
|
||||
else
|
||||
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
|
||||
kDefaultHousePict8);
|
||||
PortabilityLayer::ResourceManager::GetInstance()->CloseResFile(isResFile);
|
||||
|
||||
resFile->Destroy();
|
||||
}
|
||||
else
|
||||
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
|
||||
@@ -131,7 +132,6 @@ void UpdateLoadDialog (Dialog *theDialog)
|
||||
}
|
||||
|
||||
InitCursor();
|
||||
UseResFile(wasResFile);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -152,11 +152,11 @@ void PageUpHouses (Dialog *theDial)
|
||||
housePage -= kDispFiles;
|
||||
thisHouseIndex = kDispFiles - 1;
|
||||
|
||||
ShowDialogItem(theDial, kScrollDownItem);
|
||||
theDial->SetItemVisibility(kScrollDownItem - 1, true);
|
||||
if (housePage < kDispFiles)
|
||||
{
|
||||
GetDialogItemRect(theDial, kScrollUpItem, &tempRect);
|
||||
HideDialogItem(theDial, kScrollUpItem);
|
||||
theDial->SetItemVisibility(kScrollUpItem - 1, false);
|
||||
DrawCIcon(surface, kGrayedOutUpArrow, tempRect.left, tempRect.top);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,8 @@ void PageUpHouses (Dialog *theDial)
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillRect(tempRect);
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
InvalWindowRect(theDial->GetWindow(), &tempRect);
|
||||
|
||||
UpdateLoadDialog(theDial);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -186,11 +187,11 @@ void PageDownHouses (Dialog *theDial)
|
||||
housePage += kDispFiles;
|
||||
thisHouseIndex = 0;
|
||||
|
||||
ShowDialogItem(theDial, kScrollUpItem);
|
||||
theDial->SetItemVisibility(kScrollUpItem - 1, true);
|
||||
if (housePage >= (housesFound - kDispFiles))
|
||||
{
|
||||
GetDialogItemRect(theDial, kScrollDownItem, &tempRect);
|
||||
HideDialogItem(theDial, kScrollDownItem);
|
||||
theDial->SetItemVisibility(kScrollDownItem - 1, false);
|
||||
DrawCIcon(surface, kGrayedOutDownArrow, tempRect.left, tempRect.top);
|
||||
}
|
||||
|
||||
@@ -198,46 +199,39 @@ void PageDownHouses (Dialog *theDial)
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillRect(tempRect);
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
InvalWindowRect(theDial->GetWindow(), &tempRect);
|
||||
|
||||
UpdateLoadDialog(theDial);
|
||||
}
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------- LoadFilter
|
||||
#ifndef COMPILEDEMO
|
||||
|
||||
Boolean LoadFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
int16_t LoadFilter(Dialog *dial, const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
short screenCount, i, wasIndex;
|
||||
|
||||
switch (event->what)
|
||||
|
||||
if (evt.IsKeyDownEvent())
|
||||
{
|
||||
case keyDown:
|
||||
switch (event->message)
|
||||
const intptr_t keyCode = PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent);
|
||||
switch (keyCode)
|
||||
{
|
||||
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(kPageUp):
|
||||
*item = kScrollUpItem;
|
||||
return (true);
|
||||
break;
|
||||
case PL_KEY_SPECIAL(kPageUp):
|
||||
return kScrollUpItem;
|
||||
|
||||
case PL_KEY_SPECIAL(kPageDown):
|
||||
*item = kScrollDownItem;
|
||||
return (true);
|
||||
break;
|
||||
case PL_KEY_SPECIAL(kPageDown):
|
||||
return kScrollDownItem;
|
||||
|
||||
case PL_KEY_SPECIAL(kUpArrow):
|
||||
case PL_KEY_SPECIAL(kUpArrow):
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
thisHouseIndex -= 4;
|
||||
if (thisHouseIndex < 0)
|
||||
@@ -245,18 +239,17 @@ Boolean LoadFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
screenCount = housesFound - housePage;
|
||||
if (screenCount > kDispFiles)
|
||||
screenCount = kDispFiles;
|
||||
|
||||
|
||||
thisHouseIndex += 4;
|
||||
thisHouseIndex = (((screenCount - 1) / 4) * 4) +
|
||||
(thisHouseIndex % 4);
|
||||
thisHouseIndex = (((screenCount - 1) / 4) * 4) +
|
||||
(thisHouseIndex % 4);
|
||||
if (thisHouseIndex >= screenCount)
|
||||
thisHouseIndex -= 4;
|
||||
}
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
return(true);
|
||||
break;
|
||||
return 0;
|
||||
|
||||
case PL_KEY_SPECIAL(kDownArrow):
|
||||
case PL_KEY_SPECIAL(kDownArrow):
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
thisHouseIndex += 4;
|
||||
screenCount = housesFound - housePage;
|
||||
@@ -265,10 +258,10 @@ Boolean LoadFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
if (thisHouseIndex >= screenCount)
|
||||
thisHouseIndex %= 4;
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
return(true);
|
||||
break;
|
||||
|
||||
case PL_KEY_SPECIAL(kLeftArrow):
|
||||
return 0;
|
||||
|
||||
case PL_KEY_SPECIAL(kLeftArrow):
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
thisHouseIndex--;
|
||||
if (thisHouseIndex < 0)
|
||||
@@ -279,11 +272,10 @@ Boolean LoadFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
thisHouseIndex = screenCount - 1;
|
||||
}
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
return(true);
|
||||
break;
|
||||
return 0;
|
||||
|
||||
case PL_KEY_SPECIAL(kTab):
|
||||
case PL_KEY_SPECIAL(kRightArrow):
|
||||
case PL_KEY_SPECIAL(kTab):
|
||||
case PL_KEY_SPECIAL(kRightArrow):
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
thisHouseIndex++;
|
||||
screenCount = housesFound - housePage;
|
||||
@@ -292,13 +284,12 @@ Boolean LoadFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
if (thisHouseIndex >= screenCount)
|
||||
thisHouseIndex = 0;
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
return(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (PL_KEY_GET_EVENT_TYPE(event->message) == KeyEventType_ASCII)
|
||||
return 0;
|
||||
|
||||
default:
|
||||
if (PL_KEY_GET_EVENT_TYPE(keyCode) == KeyEventType_ASCII)
|
||||
{
|
||||
char theChar = static_cast<char>(PL_KEY_GET_VALUE(event->message));
|
||||
char theChar = static_cast<char>(PL_KEY_GET_VALUE(keyCode));
|
||||
|
||||
if (theChar >= 'A' && theChar <= 'Z')
|
||||
{
|
||||
@@ -325,35 +316,29 @@ Boolean LoadFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
InvalWindowRect(dial->GetWindow(), &loadHouseRects[thisHouseIndex]);
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case mouseDown:
|
||||
lastWhenClick = event->when - lastWhenClick;
|
||||
SubPt(event->where, &lastWhereClick);
|
||||
return(false);
|
||||
break;
|
||||
|
||||
case mouseUp:
|
||||
lastWhenClick = event->when;
|
||||
lastWhereClick = event->where;
|
||||
return(false);
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
UpdateLoadDialog(dial);
|
||||
EndUpdate(dial->GetWindow());
|
||||
event->what = nullEvent;
|
||||
return(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(false);
|
||||
break;
|
||||
}
|
||||
else if (evt.IsLMouseDownEvent())
|
||||
{
|
||||
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
|
||||
|
||||
lastWhenClick = evt.m_timestamp - lastWhenClick;
|
||||
lastWhereClick -= Point::Create(mouseEvt.m_x, mouseEvt.m_y);
|
||||
|
||||
return -1;
|
||||
}
|
||||
else if (evt.IsLMouseUpEvent())
|
||||
{
|
||||
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
|
||||
|
||||
lastWhenClick = evt.m_timestamp;
|
||||
lastWhereClick = Point::Create(mouseEvt.m_x, mouseEvt.m_y);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -365,7 +350,7 @@ void DoLoadHouse (void)
|
||||
{
|
||||
Rect tempRect;
|
||||
Dialog *theDial;
|
||||
short i, item, wasIndex, screenCount;
|
||||
short i, wasIndex, screenCount;
|
||||
Boolean leaving, whoCares;
|
||||
|
||||
BringUpDialog(&theDial, kLoadHouseDialogID);
|
||||
@@ -375,11 +360,11 @@ void DoLoadHouse (void)
|
||||
if (housesFound <= kDispFiles)
|
||||
{
|
||||
GetDialogItemRect(theDial, kScrollUpItem, &tempRect);
|
||||
HideDialogItem(theDial, kScrollUpItem);
|
||||
theDial->SetItemVisibility(kScrollUpItem - 1, false);
|
||||
DrawCIcon(surface, kGrayedOutUpArrow, tempRect.left, tempRect.top);
|
||||
|
||||
GetDialogItemRect(theDial, kScrollDownItem, &tempRect);
|
||||
HideDialogItem(theDial, kScrollDownItem);
|
||||
theDial->SetItemVisibility(kScrollDownItem - 1, false);
|
||||
DrawCIcon(surface, kGrayedOutDownArrow, tempRect.left, tempRect.top);
|
||||
}
|
||||
else
|
||||
@@ -387,13 +372,13 @@ void DoLoadHouse (void)
|
||||
if (thisHouseIndex < kDispFiles)
|
||||
{
|
||||
GetDialogItemRect(theDial, kScrollUpItem, &tempRect);
|
||||
HideDialogItem(theDial, kScrollUpItem);
|
||||
theDial->SetItemVisibility(kScrollUpItem - 1, false);
|
||||
DrawCIcon(surface, kGrayedOutUpArrow, tempRect.left, tempRect.top);
|
||||
}
|
||||
else if (thisHouseIndex > (housesFound - kDispFiles))
|
||||
{
|
||||
GetDialogItemRect(theDial, kScrollDownItem, &tempRect);
|
||||
HideDialogItem(theDial, kScrollDownItem);
|
||||
theDial->SetItemVisibility(kScrollDownItem - 1, false);
|
||||
DrawCIcon(surface, kGrayedOutDownArrow, tempRect.left, tempRect.top);
|
||||
}
|
||||
}
|
||||
@@ -412,10 +397,12 @@ void DoLoadHouse (void)
|
||||
}
|
||||
|
||||
leaving = false;
|
||||
|
||||
UpdateLoadDialog(theDial);
|
||||
|
||||
while (!leaving)
|
||||
{
|
||||
ModalDialog(LoadFilter, &item);
|
||||
int16_t item = theDial->ExecuteModal(LoadFilter);
|
||||
|
||||
if (item == kOkayButton)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "QDPixMap.h"
|
||||
#include "Externs.h"
|
||||
#include "IconLoader.h"
|
||||
#include "ResourceFile.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
|
||||
@@ -314,14 +315,39 @@ void LoadScaledGraphic (DrawSurface *surface, short resID, Rect *theRect)
|
||||
//-------------------------------------------------------------- LargeIconPlot
|
||||
// Draws a standard b&w icon (32 x 32) - resource is an 'ICON'.
|
||||
|
||||
void LargeIconPlot (Rect *theRect, short theID)
|
||||
bool LargeIconPlot (DrawSurface *surface, PortabilityLayer::ResourceFile *resFile, short resID, const Rect &theRect)
|
||||
{
|
||||
PLError_t theErr;
|
||||
Handle theSuite;
|
||||
|
||||
theErr = GetIconSuite(&theSuite, theID, svAllLargeData);
|
||||
if (theErr == PLErrors::kNone)
|
||||
theErr = PlotIconSuite(theRect, theSuite);
|
||||
Handle hdl = resFile->GetResource('icl8', resID, true);
|
||||
if (hdl)
|
||||
{
|
||||
THandle<PortabilityLayer::PixMapImpl> img = PortabilityLayer::IconLoader::GetInstance()->LoadSimpleColorIcon(hdl);
|
||||
|
||||
if (img)
|
||||
{
|
||||
CopyBits(*img, *surface->m_port.GetPixMap(), &(*img)->m_rect, &theRect, srcCopy);
|
||||
img.Dispose();
|
||||
}
|
||||
|
||||
hdl.Dispose();
|
||||
return true;
|
||||
}
|
||||
|
||||
hdl = resFile->GetResource('ICN#', resID, true);
|
||||
if (hdl)
|
||||
{
|
||||
THandle<PortabilityLayer::PixMapImpl> img = PortabilityLayer::IconLoader::GetInstance()->LoadBWIcon(hdl);
|
||||
|
||||
if (img)
|
||||
{
|
||||
CopyBits(*img, *surface->m_port.GetPixMap(), &(*img)->m_rect, &theRect, srcCopy);
|
||||
img.Dispose();
|
||||
}
|
||||
|
||||
hdl.Dispose();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawCIcon
|
||||
|
||||
Reference in New Issue
Block a user