Last change
on this file was 344, checked in by chronos, 4 weeks ago |
- Modified: Improved implementation of TItemList class to be generic class to avoid explicit typecasting.
|
File size:
1.2 KB
|
Line | |
---|
1 | unit Nation;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Graphics, ItemList;
|
---|
7 |
|
---|
8 | type
|
---|
9 |
|
---|
10 | { TNation }
|
---|
11 |
|
---|
12 | TNation = class(TItem)
|
---|
13 | Color: TColor;
|
---|
14 | class function GetFields: TItemFields; override;
|
---|
15 | procedure GetValue(Index: Integer; out Value); override;
|
---|
16 | procedure SetValue(Index: Integer; var Value); override;
|
---|
17 | class function GetClassSysName: string; override;
|
---|
18 | class function GetClassName: string; override;
|
---|
19 | end;
|
---|
20 |
|
---|
21 | { TNations }
|
---|
22 |
|
---|
23 | TNations = class(TItemList<TNation>)
|
---|
24 | end;
|
---|
25 |
|
---|
26 | resourcestring
|
---|
27 | SNation = 'Nation';
|
---|
28 | SColor = 'Color';
|
---|
29 |
|
---|
30 |
|
---|
31 | implementation
|
---|
32 |
|
---|
33 | uses
|
---|
34 | Common;
|
---|
35 |
|
---|
36 | { TNation }
|
---|
37 |
|
---|
38 | class function TNation.GetFields: TItemFields;
|
---|
39 | begin
|
---|
40 | Result := inherited;
|
---|
41 | Result.AddField(2, 'Color', SColor, dtColor);
|
---|
42 | end;
|
---|
43 |
|
---|
44 | procedure TNation.GetValue(Index: Integer; out Value);
|
---|
45 | begin
|
---|
46 | if Index = 1 then string(Value) := Name
|
---|
47 | else if Index = 2 then TColor(Value) := Color
|
---|
48 | else inherited;
|
---|
49 | end;
|
---|
50 |
|
---|
51 | procedure TNation.SetValue(Index: Integer; var Value);
|
---|
52 | begin
|
---|
53 | if Index = 1 then Name := string(Value)
|
---|
54 | else if Index = 2 then Color := TColor(Value)
|
---|
55 | else inherited;
|
---|
56 | end;
|
---|
57 |
|
---|
58 | class function TNation.GetClassSysName: string;
|
---|
59 | begin
|
---|
60 | Result := 'Nation';
|
---|
61 | end;
|
---|
62 |
|
---|
63 | class function TNation.GetClassName: string;
|
---|
64 | begin
|
---|
65 | Result := SNation;
|
---|
66 | end;
|
---|
67 |
|
---|
68 | end.
|
---|
69 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.