DEADSOFTWARE

add build info
[d2df-editor.git] / src / editor / f_selectmap.pas
1 unit f_selectmap;
3 {$INCLUDE ../shared/a_modes.inc}
5 interface
7 uses
8 LCLIntf, LCLType, LMessages, SysUtils, Variants, Classes, Graphics,
9 Controls, Forms, Dialogs, StdCtrls, ExtCtrls, utils;
11 type
12 TSelectMapForm = class (TForm)
13 lbMapList: TListBox;
14 Panel1: TPanel;
15 bOK: TButton;
16 bCancel: TButton;
18 procedure GetMaps(FileName: String);
19 procedure FormActivate(Sender: TObject);
20 procedure lbMapListClick(Sender: TObject);
21 procedure bCancelClick(Sender: TObject);
23 private
24 { Private declarations }
25 public
26 { Public declarations }
27 end;
29 var
30 SelectMapForm: TSelectMapForm;
32 implementation
34 uses
35 MAPREADER, MAPSTRUCT, g_resources, sfs;
37 {$R *.lfm}
39 procedure TSelectMapForm.FormActivate(Sender: TObject);
40 begin
41 bOK.Enabled := (lbMapList.ItemIndex <> -1);
42 lbMapList.SetFocus();
43 end;
45 procedure TSelectMapForm.lbMapListClick(Sender: TObject);
46 begin
47 if lbMapList.ItemIndex <> -1 then
48 bOK.Enabled := True;
49 end;
51 procedure TSelectMapForm.bCancelClick(Sender: TObject);
52 begin
53 Close();
54 end;
56 procedure TSelectMapForm.GetMaps(FileName: String);
57 var
58 data: PByte;
59 list: TSFSFileList;
60 sign: Array [0..2] of Char;
61 i, len: Integer;
62 begin
63 lbMapList.Items.Clear();
65 list := SFSFileList(FileName);
66 if list = nil then Exit;
68 for i := 0 to list.Count - 1 do
69 begin
70 g_ReadResource(FileName, win2utf(list.Files[i].path), win2utf(list.Files[i].name), data, len);
72 if len >= 3 then
73 begin
74 sign[0] := chr(data[0]);
75 sign[1] := chr(data[1]);
76 sign[2] := chr(data[2]);
77 if sign = MAP_SIGNATURE then
78 lbMapList.Items.Add(win2utf(list.Files[i].name))
79 end;
81 if len > 0 then FreeMem(data)
82 end;
84 list.Destroy
85 end;
87 end.