Statistics
| Branch: | Tag: | Revision:

root / Client / UfrmTileInfo.pas @ 119:66352054ce4d

History | View | Annotate | Download (4.3 kB)

1
(*
2
 * CDDL HEADER START
3
 *
4
 * The contents of this file are subject to the terms of the
5
 * Common Development and Distribution License, Version 1.0 only
6
 * (the "License").  You may not use this file except in compliance
7
 * with the License.
8
 *
9
 * You can obtain a copy of the license at
10
 * http://www.opensource.org/licenses/cddl1.php.
11
 * See the License for the specific language governing permissions
12
 * and limitations under the License.
13
 *
14
 * When distributing Covered Code, include this CDDL HEADER in each
15
 * file and include the License file at
16
 * http://www.opensource.org/licenses/cddl1.php.  If applicable,
17
 * add the following below this CDDL HEADER, with the fields enclosed
18
 * by brackets "[]" replaced with your own identifying * information:
19
 *      Portions Copyright [yyyy] [name of copyright owner]
20
 *
21
 * CDDL HEADER END
22
 *
23
 *
24
 *      Portions Copyright 2009 Andreas Schneider
25
 *)
26
unit UfrmTileInfo;
27
28
{$mode objfpc}{$H+}
29
30
interface
31
32
uses
33
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
34
  ExtCtrls, LCLIntf, LCLType, strutils;
35
36
type
37
38
  { TfrmTileInfo }
39
40
  TfrmTileInfo = class(TForm)
41
    lblName: TLabel;
42
    lblFlags: TLabel;
43
    lblTileID: TLabel;
44
    tmHide: TTimer;
45
    procedure FormShow(Sender: TObject);
46
    procedure tmHideTimer(Sender: TObject);
47
  private
48
    { private declarations }
49
  public
50
    procedure Update(ATileID: Word);
51
    procedure Show(ATileID: Word); overload;
52
  end; 
53
54
var
55
  frmTileInfo: TfrmTileInfo;
56
57
implementation
58
59
uses
60
  UGameResources, UTiledata;
61
62
{ TfrmTileInfo }
63
64
procedure TfrmTileInfo.tmHideTimer(Sender: TObject);
65
begin
66
  tmHide.Enabled := False;
67
  Hide;
68
end;
69
70
procedure TfrmTileInfo.FormShow(Sender: TObject);
71
begin
72
  tmHide.Enabled := True;
73
  Left := Mouse.CursorPos.x + 8;
74
  Top := Mouse.CursorPos.y + 8;
75
end;
76
77
procedure TfrmTileInfo.Update(ATileID: Word);
78
var
79
  tileData: TTiledata;
80
  prefix, flags: string;
81
  
82
  procedure UpdateFlags(AFlag: TTileDataFlag; AName: string);
83
  begin
84
    if AFlag in tileData.Flags then
85
    begin
86
      if flags <> '' then
87
        flags := flags + ', ' + AName
88
      else
89
        flags := AName;
90
    end;
91
  end;
92
  
93
begin
94
  if Visible then
95
  begin
96
    Left := Mouse.CursorPos.x + 8;
97
    Top := Mouse.CursorPos.y + 8;
98
  end;
99
100
  flags := '';
101
102
  if ATileID < $4000 then
103
  begin
104
    tileData := ResMan.Tiledata.LandTiles[ATileID];
105
    if TLandTiledata(tileData).TextureID > 0 then
106
      flags := 'Stretchable';
107
  end else
108
  begin
109
    Dec(ATileID, $4000);
110
    tileData := ResMan.Tiledata.StaticTiles[ATileID];
111
  end;
112
113
  if tdfArticleA in tileData.Flags then
114
    prefix := 'a '
115
  else if tdfArticleAn in tileData.Flags then
116
    prefix := 'an '
117
  else
118
    prefix := '';
119
120
  lblName.Caption := AnsiProperCase(Format('%s%s', [prefix, tileData.TileName]), [' ']);
121
  lblTileID.Caption := Format('Tile ID: $%x (%0:d)', [ATileID]);
122
  
123
  UpdateFlags(tdfBackground, 'Background');
124
  UpdateFlags(tdfWeapon, 'Weapon');
125
  UpdateFlags(tdfTransparent, 'Transparent');
126
  UpdateFlags(tdfTranslucent, 'Translucent');
127
  UpdateFlags(tdfWall, 'Wall');
128
  UpdateFlags(tdfDamaging, 'Damaging');
129
  UpdateFlags(tdfImpassable, 'Impassable');
130
  UpdateFlags(tdfWet, 'Wet');
131
  UpdateFlags(tdfSurface, 'Surface');
132
  UpdateFlags(tdfBridge, 'Bridge');
133
  UpdateFlags(tdfGeneric, 'Generic');
134
  UpdateFlags(tdfWindow, 'Window');
135
  UpdateFlags(tdfNoShoot, 'NoShoot');
136
  UpdateFlags(tdfInternal, 'Internal');
137
  UpdateFlags(tdfFoliage, 'Foliage');
138
  UpdateFlags(tdfPartialHue, 'PartialHue');
139
  UpdateFlags(tdfMap, 'Map');
140
  UpdateFlags(tdfContainer, 'Container');
141
  UpdateFlags(tdfWearable, 'Wearable');
142
  UpdateFlags(tdfLightSource, 'Lightsource');
143
  UpdateFlags(tdfAnimation, 'Animation');
144
  UpdateFlags(tdfNoDiagonal, 'NoDiagonal');
145
  UpdateFlags(tdfArmor, 'Armor');
146
  UpdateFlags(tdfRoof, 'Roof');
147
  UpdateFlags(tdfDoor, 'Door');
148
  UpdateFlags(tdfStairBack, 'StairBack');
149
  UpdateFlags(tdfStairRight, 'StairRight');
150
  
151
  lblFlags.Caption := Format('Flags = [%s]', [flags]);
152
  
153
  if tmHide.Enabled then
154
  begin
155
    tmHide.Enabled := False;
156
    tmHide.Enabled := True; //Refresh timer
157
  end;
158
end;
159
160
procedure TfrmTileInfo.Show(ATileID: Word);
161
begin
162
  Update(ATileID);
163
  Show;
164
end;
165
166
initialization
167
  {$I UfrmTileInfo.lrs}
168
169
end.
170