1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
22 // ////////////////////////////////////////////////////////////////////////// //
29 function getIdx (idx
: Integer): Integer; inline;
30 procedure setIdx (idx
, v
: Integer); inline;
33 constructor Create (aw
, ah
: Integer);
35 function toString (): AnsiString;
37 function equals (constref a
: TLaySize
): Boolean; inline;
39 property item
[idx
: Integer]: Integer read getIdx write setIdx
; default
;
47 function getIdx (idx
: Integer): Integer; inline;
48 procedure setIdx (idx
, v
: Integer); inline;
51 constructor Create (ax
, ay
: Integer);
53 function toString (): AnsiString;
55 function equals (constref a
: TLayPos
): Boolean; inline;
58 property item
[idx
: Integer]: Integer read getIdx write setIdx
; default
;
68 // ////////////////////////////////////////////////////////////////////////// //
69 constructor TLaySize
.Create (aw
, ah
: Integer); begin w
:= aw
; h
:= ah
; end;
70 function TLaySize
.getIdx (idx
: Integer): Integer; inline; begin if (idx
= 0) then result
:= w
else if (idx
= 1) then result
:= h
else result
:= -1; end;
71 procedure TLaySize
.setIdx (idx
, v
: Integer); inline; begin if (idx
= 0) then w
:= v
else if (idx
= 1) then h
:= v
; end;
72 function TLaySize
.toString (): AnsiString; begin result
:= formatstrf('[%d,%d]', [w
, h
]); end;
73 function TLaySize
.equals (constref a
: TLaySize
): Boolean; inline; begin result
:= (w
= a
.w
) and (h
= a
.h
); end;
75 constructor TLayPos
.Create (ax
, ay
: Integer); begin x
:= ax
; y
:= ay
; end;
76 function TLayPos
.getIdx (idx
: Integer): Integer; inline; begin if (idx
= 0) then result
:= x
else if (idx
= 1) then result
:= y
else result
:= -1; end;
77 procedure TLayPos
.setIdx (idx
, v
: Integer); inline; begin if (idx
= 0) then x
:= v
else if (idx
= 1) then y
:= v
; end;
78 function TLayPos
.toString (): AnsiString; begin result
:= formatstrf('(%d,%d)', [x
, y
]); end;
79 function TLayPos
.equals (constref a
: TLayPos
): Boolean; inline; begin result
:= (x
= a
.x
) and (y
= a
.y
); end;