Statistics
| Branch: | Tag: | Revision:

root / Client / UfrmTileInfo.pas @ 0:95bd93c28625

History | View | Annotate | Download (4.6 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 2007 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, LMessages, 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; overload; reintroduce;
52
    procedure Show(ATileID: Word); overload;
53
  end; 
54
55
var
56
  frmTileInfo: TfrmTileInfo;
57
58
implementation
59
60
uses
61
  UGameResources, UTiledata;
62
63
{ TfrmTileInfo }
64
65
procedure TfrmTileInfo.tmHideTimer(Sender: TObject);
66
begin
67
  tmHide.Enabled := False;
68
  Hide;
69
end;
70
71
procedure TfrmTileInfo.FormShow(Sender: TObject);
72
begin
73
  tmHide.Enabled := True;
74
  Left := Mouse.CursorPos.x + 8;
75
  Top := Mouse.CursorPos.y + 8;
76
end;
77
78
procedure TfrmTileInfo.Update(ATileID: Word);
79
var
80
  tileData: TTiledata;
81
  prefix, flags: string;
82
  
83
  procedure UpdateFlags(AFlag: LongWord; AName: string);
84
  begin
85
    if tileData.HasFlag(AFlag) then
86
    begin
87
      if flags <> '' then
88
        flags := flags + ', ' + AName
89
      else
90
        flags := AName;
91
    end;
92
  end;
93
  
94
begin
95
  if Visible then
96
  begin
97
    Left := Mouse.CursorPos.x + 8;
98
    Top := Mouse.CursorPos.y + 8;
99
  end;
100
101
  flags := '';
102
103
  if ATileID < $4000 then
104
  begin
105
    tileData := ResMan.Tiledata.LandTiles[ATileID];
106
    if TLandTiledata(tileData).TextureID > 0 then
107
      flags := 'Stretchable';
108
  end else
109
  begin
110
    Dec(ATileID, $4000);
111
    tileData := ResMan.Tiledata.StaticTiles[ATileID];
112
  end;
113
114
  if tileData.HasFlag(tdfArticleA) then
115
    prefix := 'a '
116
  else if tileData.HasFlag(tdfArticleAn) then
117
    prefix := 'an '
118
  else
119
    prefix := '';
120
121
  lblName.Caption := AnsiProperCase(Format('%s%s', [prefix, tileData.TileName]), [' ']);
122
  lblTileID.Caption := Format('Tile ID: $%x (%0:d)', [ATileID]);
123
  
124
  UpdateFlags(tdfBackground, 'Background');
125
  UpdateFlags(tdfWeapon, 'Weapon');
126
  UpdateFlags(tdfTransparent, 'Transparent');
127
  UpdateFlags(tdfTranslucent, 'Translucent');
128
  UpdateFlags(tdfWall, 'Wall');
129
  UpdateFlags(tdfDamaging, 'Damaging');
130
  UpdateFlags(tdfImpassable, 'Impassable');
131
  UpdateFlags(tdfWet, 'Wet');
132
  UpdateFlags(tdfSurface, 'Surface');
133
  UpdateFlags(tdfBridge, 'Bridge');
134
  UpdateFlags(tdfGeneric, 'Generic');
135
  UpdateFlags(tdfWindow, 'Window');
136
  UpdateFlags(tdfNoShoot, 'NoShoot');
137
  UpdateFlags(tdfInternal, 'Internal');
138
  UpdateFlags(tdfFoliage, 'Foliage');
139
  UpdateFlags(tdfPartialHue, 'PartialHue');
140
  UpdateFlags(tdfMap, 'Map');
141
  UpdateFlags(tdfContainer, 'Container');
142
  UpdateFlags(tdfWearable, 'Wearable');
143
  UpdateFlags(tdfLightSource, 'Lightsource');
144
  UpdateFlags(tdfAnimation, 'Animation');
145
  UpdateFlags(tdfNoDiagonal, 'NoDiagonal');
146
  UpdateFlags(tdfArmor, 'Armor');
147
  UpdateFlags(tdfRoof, 'Roof');
148
  UpdateFlags(tdfDoor, 'Door');
149
  UpdateFlags(tdfStairBack, 'StairBack');
150
  UpdateFlags(tdfStairRight, 'StairRight');
151
  
152
  lblFlags.Caption := Format('Flags = [%s]', [flags]);
153
  
154
  if tmHide.Enabled then
155
  begin
156
    tmHide.Enabled := False;
157
    tmHide.Enabled := True; //Refresh timer
158
  end;
159
end;
160
161
{procedure TfrmTileInfo.Show;
162
begin
163
  ShowWindow(Handle, SW_SHOWNOACTIVATE);
164
  Include(FormState, fsVisible);
165
  VisibleChanging;
166
  try
167
    Perform(CM_VISIBLECHANGED, WParam(Ord(True)), 0);
168
    AdjustSize;
169
    RequestAlign;
170
  finally
171
    VisibleChanged;
172
  end;
173
  //FormShow(Self);
174
end;}
175
176
procedure TfrmTileInfo.Show(ATileID: Word);
177
begin
178
  Update(ATileID);
179
  Show;
180
end;
181
182
initialization
183
  {$I UfrmTileInfo.lrs}
184
185
end.
186