Glider4/RoomEditor_103/Sources/E-HouseStuff.p

1 line
8.9 KiB
OpenEdge ABL
Raw Normal View History

unit HouseStuff; interface uses Palettes, Globals, Utilities; function DeleteRoom: Boolean; function InsertRoom: Boolean; procedure DoHouseInfo; procedure ErrorCheckHouse; implementation {=================================} function DeleteRoom; var i: Integer; begin DeleteRoom := FALSE; {assume error} if (roomAt < thisHouse.numberORooms) then {if not on last room} for i := roomAt to thisHouse.numberORooms do thisHouse.theRooms[i] := thisHouse.theRooms[i + 1]; {shift rooms left} thisHouse.numberORooms := thisHouse.numberORooms - 1; {subtract 1 from #} if (roomAt > 1) then roomAt := roomAt - 1 {preceding room is activated} else begin roomAt := 1; if (thisHouse.numberORooms <= 1) then {if only one room} begin thisHouse.numberORooms := 1; {we'll call up the dlg} Exit(DeleteRoom); {for creating a room} end; end; DeleteRoom := TRUE; end; {=================================} function InsertRoom; var i: Integer; begin InsertRoom := FALSE; if (thisHouse.numberORooms >= 40) then {trying to add 41 rooms} begin GenericAlert(kErrTooManyRooms); Exit(InsertRoom); 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 roomAt over to right} thisHouse.theRooms[roomAt] := scrapRoom; {copy scrap into house} thisRoom := thisHouse.theRooms[roomAt]; {get copy for active room} thisHouse.numberORooms := thisHouse.numberORooms + 1; {one more room} InsertRoom := TRUE; end; {=================================} procedure DoFlushScores; var i: Integer; begin for i := 0 to 19 do begin thisHouse.hiScores[i] := 0; thisHouse.hiLevel[i] := 0; thisHouse.hiName[i] := 'no one...'; thisHouse.hiRoom[i] := 'no room...'; end; end; {=================================} procedure DoHouseInfo; const okayBut = 1; nameStat = 2; numOfStat = 3; versStat = 4; backStat = 5; firstEdit = 6; nextEdit = 7; flushBut = 8; lockBut = 17; cancelBut = 18; var leaveDlg, willLockIt: Boolean; theDlgPtr: DialogPtr; wasPort: GrafPtr; tempRect: Rect; cntlType, index, itemHit, tempInt, rightOff, downOff: Integer; dlgItem: Handle; cntlHand, tempCntlHand: controlhandle; tempStr, tempStr2: Str255; {-------------------------} procedure Redraw; var width: Integer; begin SetPort(theDlgPtr); {Point to our dialog window} GetDItem(theDlgPtr, okayBut, cntlType, dlgItem, tempRect);{Get the item handle} PenSize(3, 3); {Change pen to draw thick default outline} InsetRect(tempRect, -4, -4); {Draw outside the button by 1 pixel} FrameRoundRect(tempRect, 16, 16); {Draw the outline} PenNormal; with theDlgPtr^.portRect do width := right - left; MoveTo(4, 38); Line(width - 8, 0); MoveTo(4, 40); Line(width - 8, 0); GetKeys(theKeys); if (theKeys[$37]) then begin MoveTo(5, 37); NumToString(thisHouse.timeStamp, tempStr); DrawString(tempStr); end; end; {-------------------------} begin GetPort(wasPort); theDlgPtr := GetNewDialog(houseInfoID, nil, Pointer(-1)); with theDlgPtr^.portBits do begin rightOff := rightOffset - bounds.left; downOff := downOffset - bounds.top; end; MoveWindow(theDlgPtr, rightOff, downOff, FALSE); ShowWindow(theDlgPtr); SelectWindow(theDlgPtr); SetPort(theDlgPtr); GetDItem(theDlgPtr, nameStat, cntlType, dlgItem, tempRect); SetIText(dlgItem, housesName); with thisHouse do begin NumToString(numberORooms, tempStr); {pop in number of rooms} GetDItem(theDlgPtr, numOfStat, cntlType, dlgItem, tempRect); SetIText(dlgItem, tempStr); tempInt := version div 256; {compute version number} NumToString(tempInt, tempStr); tempInt := version mod 256; NumToString(tempInt, tempStr2);