forked from P33a/SimTwo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChooseScene.pas
113 lines (93 loc) · 2.67 KB
/
ChooseScene.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
unit ChooseScene;
{$MODE Delphi}
interface
uses
SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IniPropStorage;
type
{ TFChooseScene }
TFChooseScene = class(TForm)
IniPropStorage: TIniPropStorage;
LBScenes: TListBox;
ImageSnapshot: TImage;
BOK: TButton;
BCancel: TButton;
ImageEmpty: TImage;
procedure FormShow(Sender: TObject);
procedure BOKClick(Sender: TObject);
procedure LBScenesDblClick(Sender: TObject);
procedure LBScenesClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
SelectedDir: string;
end;
var
FChooseScene: TFChooseScene;
implementation
uses ProjConfig;
{$R *.lfm}
procedure TFChooseScene.FormShow(Sender: TObject);
var i: integer;
sr: TSearchRec;
FileAttrs: Integer;
begin
LBScenes.Clear;
FileAttrs := faDirectory;
if FindFirst('..\*', FileAttrs, sr) = 0 then begin
repeat
if (sr.Attr and FileAttrs) = FileAttrs then begin // Only directories
if pos('.',sr.Name) = 1 then continue; // no dot files
if sr.Name = 'base' then continue; // "base" is a reserved name
if not fileexists('..\' + sr.Name + '\scene.xml') then continue; // must have a scene.xml file
LBScenes.Items.Add(sr.Name);
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
for i := 0 to LBScenes.Count - 1 do begin
if ExpandFileName('..\' + LBScenes.Items[i]) = GetCurrentDir then begin
LBScenes.ItemIndex := i;
LBScenesClick(sender);
break;
end;
end;
//LBScenes.Items.Add(GetCurrentDir);
//LBScenes.Items.Add(ExpandFileName('.'));
end;
procedure TFChooseScene.BOKClick(Sender: TObject);
var i: integer;
begin
i := LBScenes.ItemIndex;
if i >= 0 then begin
SelectedDir := LBScenes.Items[i];
end else begin
SelectedDir := GetCurrentDir;
end;
IniPropStorage.Save;
end;
procedure TFChooseScene.LBScenesDblClick(Sender: TObject);
begin
BOK.Click;
end;
procedure TFChooseScene.LBScenesClick(Sender: TObject);
var s: string;
begin
if LBScenes.ItemIndex < 0 then exit;
s := '..\' + LBScenes.Items[LBScenes.ItemIndex] + '\Snapshot.jpg';
if fileexists(s) then begin
ImageEmpty.Visible := false;
ImageSnapshot.Picture.LoadFromFile(s);
ImageSnapshot.Visible := true;
end else begin
ImageSnapshot.Visible := false;
ImageEmpty.Visible := true;
end;
end;
procedure TFChooseScene.FormCreate(Sender: TObject);
begin
IniPropStorage.IniFileName := GetIniFineName(copy(name, 2, MaxInt));
end;
end.