mirror of
https://github.com/softdorothy/Glider4.git
synced 2024-06-08 13:29:32 +00:00
1 line
31 KiB
OpenEdge ABL
1 line
31 KiB
OpenEdge ABL
|
unit ObjectStuff;
interface
uses
Palettes, Globals, Utilities, Drawing, RoomStuff;
procedure AutoHideShow (hiding: Boolean);
procedure SetUpFields;
procedure DragObject (which: Integer);
procedure DragHandle;
procedure DragOffPalette (whatKind: Integer);
procedure CloseTools;
procedure UpdateTools;
procedure OpenTools;
procedure DoTools;
procedure BumpAPixel (hori, vert: Integer);
procedure DoObjectInfo;
function InsertObject: Boolean;
implementation
const
objectInfoID = 131;
{=================================}
procedure AutoHideShow (hiding: Boolean);
begin
if (hiding) then
begin
if (toolWndo <> nil) then
begin
SetPort(GrafPtr(toolWndo));
SetPt(holdCorner, toolWndo^.portRect.left, toolWndo^.portRect.top);
LocalToGlobal(holdCorner);
DisposeWindow(GrafPtr(toolWndo));
toolWndo := nil;
SetPort(GrafPtr(mainWndo));
end
else
SetPt(holdCorner, -1000, 0);
end
else {not hiding - showing}
begin
if (holdCorner.h <> -1000) then
begin
if (inColor) then
toolWndo := GetNewCWindow(128, nil, WindowPtr(-1))
else
toolWndo := GetNewWindow(128, nil, WindowPtr(-1));
if (toolWndo = nil) then
begin
GenericAlert(kErrLoadingRes);
ExitToShell;
end;
SetPort(GrafPtr(toolWndo));
MoveWindow(toolWndo, holdCorner.h, holdCorner.v, FALSE);
ShowWindow(toolWndo);
SetWRefCon(toolWndo, 1);
UpdateTools;
end;
end;
end;
{=================================}
procedure SetUpFields;
var
tempBool: Boolean;
tempAmount, tempExtra, what: Integer;
begin
what := thisRoom.theObjects[oneActive].objectIs;
case (what) of
flrVnt, ball, toastr, fshBwl:
tempAmount := ceilingVert + 20;
extRct, upStar, dnStar:
tempAmount := roomAt;
celVnt, celDct, drip:
tempAmount := floorVert - 20;
candle:
begin
tempAmount := thisRoom.theObjects[oneActive].boundRect.top - 100;
if (tempAmount < ceilingVert + 50) then
tempAmount := ceilingVert + 50;
end;
lftFan:
begin
tempAmount := thisRoom.theObjects[oneActive].boundRect.left - 100;
if (tempAmount < 0) then
tempAmount := 0;
end;
ritFan, grease:
begin
tempAmount := thisRoom.theObjects[oneActive].boundRect.right + 100;
if (tempAmount > 512) then
tempAmount := 512;
end;
clock, paper, bnsRct:
tempAmount := 1000;
rbrBnd:
tempAmount := 10;
battry:
tempAmount := 40;
outlet, teaKtl:
tempAmount := 120;
pwrSwt:
tempAmount := 0;
otherwise
tempAmount := 0;
end;
case (what) of
celDct, lftFan, ritFan, grease, shredr:
tempBool := TRUE;
otherwise
tempBool := FALSE;
end;
case (what) of
celDct:
tempExtra := roomAt;
drip, toastr, fshBwl:
tempExtra := 120;
otherwise
tempExtra := 0;
end;
with thisRoom.theObjects[oneActive] do
begin
objectIs := what;
amount := tempAmount;
extra := tempExtra;
isOn := tempBool;
end;
end;
{=================================}
procedure DragObject;
var
floorLockOn, ceilingLockOn, stairLockOn: Boolean;
isPt, wasPt, refPt: Point;
theSrc, oldRect, destRect: Rect;
what, errorIs: Integer;
begin
SetPort(GrafPtr(mainWndo));
what := thisRoom.theObjects[which].objectIs;
destRect := thisRoom.theObjects[which].boundRect;
oldRect := destRect;
theSrc := srcRect[what];
floorLockOn := FALSE;
ceilingLockOn := FALSE;
stairLockOn := FALSE;
if (what = flrVnt) then
floorLockOn := TRUE;
if ((what = celDct) or (what = celVnt)) then
ceilingLockOn := TRUE;
if ((what = upStar) or (what = dnStar)) then
stairLockOn := TRUE;
isPt := theEvent.where;
wasPt := isPt;
PenPat(gray);
PenMode(patXOr);
FrameRect(destRect);
while (WaitMouseUp) do
begin
GetMouse(isPt);
LocalToGlobal(isPt);
if ((isPt.h <> wasPt.h) or (isPt.v <> wasPt.v)) then
begin
FrameRect(destRect);
if ((floorLockOn) or (ceilingLockOn) or (stairLockOn)) then
OffsetRect(destRect, isPt.h - wasPt.h, 0)
else
OffsetRect(destRect, isPt.h - wasPt.
|