-
Notifications
You must be signed in to change notification settings - Fork 2
/
LemPiece.pas
145 lines (125 loc) · 3.13 KB
/
LemPiece.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{$include lem_directives.inc}
unit LemPiece;
interface
uses
Classes, SysUtils,
SharedGlobals;
type
// Abstract ancestor for object, terrain and steel
TPieceClass = class of TPiece;
TPiece = class
private
protected
fLeft : Integer;
fTop : Integer;
public
procedure Assign(Source: TPiece); virtual;
published
property Left: Integer read fLeft write fLeft;
property Top: Integer read fTop write fTop;
end;
type
// Basically ancestor for object and terrain
TIdentifiedPiece = class(TPiece)
private
protected
fSet: String;
fPiece: String;
fLoadIdentifier: String;
fWidth: Integer;
fHeight: Integer;
function GetFlip: Boolean; virtual;
function GetInvert: Boolean; virtual;
function GetRotate: Boolean; virtual;
procedure SetFlip(aValue: Boolean); virtual;
procedure SetInvert(aValue: Boolean); virtual;
procedure SetRotate(aValue: Boolean); virtual;
function GetIdentifier: String;
public
procedure Assign(Source: TPiece); override;
published
property GS: String read fSet write fSet; // "Set" is a reserved keyword :(
property Piece: String read fPiece write fPiece;
property LoadIdentifier: String read fLoadIdentifier write fLoadIdentifier;
property Identifier: String read GetIdentifier;
property Width: Integer read fWidth write fWidth;
property Height: Integer read fHeight write fHeight;
property Flip : Boolean read GetFlip write SetFlip;
property Invert : Boolean read GetInvert write SetInvert;
property Rotate : Boolean read GetRotate write SetRotate;
end;
type
// Basically ancestor for steel
TSizedPiece = class(TPiece)
private
protected
fHeight: Integer;
fWidth: Integer;
public
procedure Assign(Source: TPiece); override;
published
property Width: Integer read fWidth write fWidth;
property Height: Integer read fHeight write fHeight;
end;
implementation
{ TPiece }
procedure TPiece.Assign(Source: TPiece);
begin
Left := Source.Left;
Top := Source.Top;
end;
{ TIdentifiedPiece }
procedure TIdentifiedPiece.Assign(Source: TPiece);
var
IP: TIdentifiedPiece absolute Source;
begin
if Source is TIdentifiedPiece then
begin
inherited;
GS := IP.GS;
Piece := IP.Piece;
LoadIdentifier := IP.LoadIdentifier;
Width := IP.Width;
Height := IP.Height;
end;
end;
procedure TIdentifiedPiece.SetFlip(aValue: Boolean);
begin
// Discard if not overridden
end;
procedure TIdentifiedPiece.SetInvert(aValue: Boolean);
begin
end;
procedure TIdentifiedPiece.SetRotate(aValue: Boolean);
begin
end;
function TIdentifiedPiece.GetFlip: Boolean;
begin
// False, if not overridden
Result := false;
end;
function TIdentifiedPiece.GetInvert: Boolean;
begin
Result := false;
end;
function TIdentifiedPiece.GetRotate: Boolean;
begin
Result := false;
end;
function TIdentifiedPiece.GetIdentifier: String;
begin
Result := fSet + ':' + fPiece;
end;
{ TSizedPiece }
procedure TSizedPiece.Assign(Source: TPiece);
var
SP: TSizedPiece absolute Source;
begin
if Source is TSizedPiece then
begin
inherited;
Width := SP.Width;
Height := SP.Height;
end;
end;
end.