mirror of
https://github.com/softdorothy/GliderPRO.git
synced 2025-02-19 07:30:50 +00:00
1 line
12 KiB
C
1 line
12 KiB
C
|
//============================================================================
//----------------------------------------------------------------------------
// Scrap.c
//----------------------------------------------------------------------------
//============================================================================
/*
#include "Externs.h"
#include "Environ.h"
#include <Drag.h>
Boolean DropLocationIsTrash (AEDesc *);
Boolean hasScrap, scrapIsARoom;
extern WindowPtr mapWindow;
extern Rect roomObjectRects[];
extern short objActive;
//============================================================== Functions
//-------------------------------------------------------------- PutRoomScrap
#ifndef COMPILEDEMO
void PutRoomScrap (void)
{
// this function copies the current room into the clipboard
Rect largeBounds, smallBounds;
PicHandle smallPict;
long theErr;
theErr = ZeroScrap();
if (theErr == noErr)
{
SetRect(&largeBounds, 0, 0, kRoomWide, kTileHigh);
SetRect(&smallBounds, 0, 0, kRoomWide / 4, kTileHigh / 4);
smallPict = OpenPicture(&smallBounds);
CopyBits(&(((GrafPtr)mainWindow)->portBits), &(((GrafPtr)mainWindow)->portBits),
&largeBounds, &smallBounds, srcCopy, nil);
ClosePicture();
HLock((Handle)smallPict);
theErr = PutScrap(GetHandleSize((Handle)smallPict), 'PICT', (Ptr)(*smallPict));
theErr = PutScrap(sizeof(roomType), 'Room', (Ptr)thisRoom);
if (theErr == noErr)
{
if (!hasScrap)
{
hasScrap = true;
UpdateMenus(false);
}
scrapIsARoom = true;
}
else
YellowAlert(kYellowScrapError, theErr);
KillPicture(smallPict);
}
else
YellowAlert(kYellowScrapError, theErr);
}
#endif
//-------------------------------------------------------------- PutObjectScrap
#ifndef COMPILEDEMO
void PutObjectScrap (void)
{
// this function copies the currently selected object into the clipboard
Str255 kindStr;
objectPtr scrapObjPtr;
long theErr;
theErr = ZeroScrap();
if (theErr == noErr)
{
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
theErr = PutScrap(kindStr[0], 'TEXT', (Ptr)(kindStr + 1));
scrapObjPtr = &(thisRoom->objects[objActive]);
theErr = PutScrap(sizeof(objectType), 'Obj.', (Ptr)scrapObjPtr);
if (theErr == noErr)
{
if (!hasScrap)
{
hasScrap = true;
UpdateMenus(false);
}
scrapIsARoom = false;
}
else
YellowAlert(kYellowScrapError, theErr);
}
else
YellowAlert(kYellowScrapError, theErr);
}
#endif
//-------------------------------------------------------------- GetRoomScrap
#ifndef COMPILEDEMO
void GetRoomScrap (void)
{
// this function pastes a room from the clipboard
Handle tempRoom;
long theErr, scrapOffset;
short wasFloor, wasSuite, srcRoomNumber, destRoomNumber, i;
short linkRoomNumber;
tempRoom = NewHandle(0L);
if (tempRoom == nil)
{
YellowAlert(kYellowNoMemory, 0);
return;
}
theErr = GetScrap(tempRoom, 'Room', &scrapOffset);
if (theErr < 0)
YellowAlert(kYellowScrapError, theErr);
else
{
DeselectObject();
wasFloor = thisRoom->floor;
wasSuite = thisRoom->suite;
destRoomNumber = GetRoomNumber(thisRoom->floor, thisRoom->suite);
HLock(tempRoom);
BlockMove(*tempRoom, (Ptr)thisRoom, sizeof(roomType));
HUnlock(tempRoom);
DisposeHandle(tempRoom);
srcRoomNumber = GetRoomNumber(thisRoom->floor, thisRoom->suite);
thisRoom->floor = wasFloor;
thisRoom->suite = wasSuite;
for (i = 0; i < kMaxRoomObs; i++) // fix links
{ // first see if a linkable object
if ((ObjectIsLinkTransport(&thisRoom->objects[i])) ||
(ObjectIsLinkSwitch(&thisRoom->objects[i])))
{
linkRoomNumber = GetRoomLinked (&thisRoom->objects[i]);
if (linkRoomNumber == srcRoomNumber)
{ // if linked to an object in same room<6F>
if (ObjectIsLinkSwitch(&thisRoom->objects[i]))
{ // point to new room location
thisRoom->objects[i].data.d.where =
(wasSuite * 100) + wasFloor + kNumUndergroundFloors;
}
else
{ // point to new room location
thisRoom->objects[
|