mirror of
https://github.com/softdorothy/Glider4.git
synced 2024-06-08 13:29:32 +00:00
1 line
21 KiB
OpenEdge ABL
1 line
21 KiB
OpenEdge ABL
|
unit RoomStuff;
interface
uses
Palettes, Globals, Utilities, Drawing;
procedure SortObjects;
function InsertNewRoom: Boolean;
procedure FlushRoom (var whichRoom: roomData);
procedure DoGotoDial;
function roomFltr (theDlg: DialogPtr; var theEvnt: EventRecord; var itemHit: integer): boolean;
procedure DoRoomBackInfo (var shouldOpen: Boolean);
procedure DoRoomCondInfo (var shouldOpen: Boolean);
implementation
const
roomCondID = 129;
roomBackID = 130;
var
tempTile: array[0..7] of Integer;
backNumber: Integer;
{=================================}
procedure SortObjects;
var
holdActive, i, count, itemType: Integer;
holdRoom: RoomData;
begin
FlushRoom(holdRoom);
count := 0;
holdActive := oneActive;
for i := 1 to 16 do
begin
itemType := thisRoom.theObjects[i].objectIs;
if ((itemType <> paintg) and (itemType <> mirror) and (itemType <> window) and (itemType <> 0)) then
begin
count := count + 1;
if (oneActive = i) then
holdActive := count;
holdRoom.theObjects[count] := thisRoom.theObjects[i];
thisRoom.theObjects[i].objectIs := 0;
end;
end;
for i := 1 to 16 do
begin
itemType := thisRoom.theObjects[i].objectIs;
if (itemType <> 0) then
begin
count := count + 1;
if (oneActive = i) then
holdActive := count;
holdRoom.theObjects[count] := thisRoom.theObjects[i];
end;
end;
for i := 1 to thisRoom.numberOObjects do
thisRoom.theObjects[i] := holdRoom.theObjects[i];
with thisRoom do
if (count <> numberOObjects) then {*** Check for agreement}
begin
count := 0; {*** Run a second check}
for i := 1 to 16 do
if (theObjects[i].objectIs <> 0) then
count := count + 1;
numberOObjects := count; {*** We'll go with this #}
if (numberOObjects < 16) then
for i := numberOObjects + 1 to 16 do
begin
theObjects[i].objectIs := 0; {*** Zero-out excess fields}
theObjects[i].boundRect := nullRect;
theObjects[i].amount := 0;
theObjects[i].extra := 0;
theObjects[i].isOn := FALSE;
end;
end;
oneActive := holdActive; {*** Restore active object}
end;
{=================================}
function InsertNewRoom;
var
i: Integer;
begin
InsertNewRoom := FALSE;
if (thisHouse.numberORooms >= 40) then {trying to add 41 rooms}
begin
GenericAlert(kErrTooManyRooms);
Exit(InsertNewRoom);
end;
thisHouse.theRooms[roomAt] := thisRoom; {insert room to date}
if (roomAt < thisHouse.numberORooms) then {shift only if in middle}
for i := thisHouse.numberORooms downto roomAt + 1 do
thisHouse.theRooms[i + 1] := thisHouse.theRooms[i]; {shift rooms right}
roomAt := roomAt + 1; {kick active over to right}
FlushRoom(thisRoom); {flush new room copy}
thisHouse.theRooms[roomAt] := thisRoom; {copy active into house}
thisHouse.numberORooms := thisHouse.numberORooms + 1; {one more room}
InsertNewRoom := TRUE;
end;
{=================================}
procedure FlushRoom;
var
index: Integer;
defaultName: Str255;
begin
NumToString(roomAt, defaultName);
defaultName := CONCAT('Room # ', defaultName);
with whichRoom do
begin
roomName := defaultName;
numberOObjects := 0;
backPictID := 200;
for index := 0 to 7 do
tileOrder[index] := 0;
animateKind := 0;
animateNumber := 0;
animateDelay := 0;
conditionCode := 0;
for index := 1 to 16 do
begin
theObjects[index].objectIs := 0;
theObjects[index].boundRect := nullRect;
theObjects[index].amount := 0;
theObjects[index].extra := 0;
theObjects[index].isOn := FALSE;
end;
end;
end;
{=================================}
procedure DoGotoDial;
const
okayBut = 1;
cancelBut = 2;
gotoEdit = 3;
numOfStat = 4;
currStat = 5;
var
leaveDlg: Boolean;
tempLong: LongInt;
theDlgPtr: DialogPtr;
tempRect: Rect;
cntlType, index, itemHit, tempInt, rightOff, downOff: Integer;
dlgItem: Handle;
cntlHand, tempCntlHand: controlhandle;
strTemp: Str255;
{-------------------------}
proc
|