1 | UNIT Unit5_preview;
|
---|
2 | INTERFACE
|
---|
3 | USES
|
---|
4 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
5 | Dialogs, Math, ExtCtrls, Unit2_functions, Unit3_data, Unit4_exporters, Unit6_imgfuncs,
|
---|
6 | StdCtrls, StrUtils, Menus;
|
---|
7 |
|
---|
8 | TYPE
|
---|
9 | TForm5 = Class(TForm)
|
---|
10 | timer: TTimer;
|
---|
11 | panel_preview: TPanel;
|
---|
12 | img: TImage;
|
---|
13 | panel_buttons: TPanel;
|
---|
14 | btn_dec: TButton;
|
---|
15 | btn_startstop: TButton;
|
---|
16 | btn_inc: TButton;
|
---|
17 | panel_files: TPanel;
|
---|
18 | list: TListBox;
|
---|
19 | panel_extension: TPanel;
|
---|
20 | combo_extension: TComboBox;
|
---|
21 | Splitter1: TSplitter;
|
---|
22 | lbl_notpossible: TLabel;
|
---|
23 | popup: TPopupMenu;
|
---|
24 | popup_extractdat: TMenuItem;
|
---|
25 | popup_extractdatraw: TMenuItem;
|
---|
26 | popup_extractdatrawconvert: TMenuItem;
|
---|
27 | procedure FormActivate(Sender: TObject);
|
---|
28 | PROCEDURE Recreatelist;
|
---|
29 | PROCEDURE listClick(Sender: TObject);
|
---|
30 | PROCEDURE PreviewTXAN;
|
---|
31 | PROCEDURE PreviewTXMB;
|
---|
32 | PROCEDURE PreviewTXMP;
|
---|
33 | PROCEDURE panel_extensionResize(Sender: TObject);
|
---|
34 | PROCEDURE combo_extensionClick(Sender: TObject);
|
---|
35 | PROCEDURE btn_incClick(Sender: TObject);
|
---|
36 | PROCEDURE btn_decClick(Sender: TObject);
|
---|
37 | PROCEDURE FormResize(Sender: TObject);
|
---|
38 | PROCEDURE btn_startstopClick(Sender: TObject);
|
---|
39 | PROCEDURE panel_buttonsResize(Sender: TObject);
|
---|
40 | PROCEDURE timerTimer(Sender: TObject);
|
---|
41 | PROCEDURE FormCreate(Sender: TObject);
|
---|
42 | PROCEDURE FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
43 | PRIVATE
|
---|
44 | PUBLIC
|
---|
45 | END;
|
---|
46 |
|
---|
47 | VAR
|
---|
48 | Form5: TForm5;
|
---|
49 |
|
---|
50 | IMPLEMENTATION
|
---|
51 | {$R *.dfm}
|
---|
52 | USES Unit1_main;
|
---|
53 | VAR
|
---|
54 | memstreams:Array OF TMemoryStream;
|
---|
55 | actualimg:Byte;
|
---|
56 | _fileid:LongWord;
|
---|
57 |
|
---|
58 |
|
---|
59 | PROCEDURE TForm5.Recreatelist;
|
---|
60 | VAR
|
---|
61 | i:LongWord;
|
---|
62 | exts:TStringList;
|
---|
63 | BEGIN
|
---|
64 | combo_extension.Items.Clear;
|
---|
65 | combo_extension.Items.Add('_All files_ ('{+IntToStr(dat_header.Files)}+')');
|
---|
66 | exts:=GetExtensionsList;
|
---|
67 | FOR i:=0 TO High(exts) DO
|
---|
68 | combo_extension.Items.Add(exts[i]);
|
---|
69 | combo_extension.ItemIndex:=0;
|
---|
70 | combo_extensionClick(Self);
|
---|
71 | END;
|
---|
72 |
|
---|
73 |
|
---|
74 | PROCEDURE TForm5.listClick(Sender: TObject);
|
---|
75 | BEGIN
|
---|
76 | _fileid:=StrToInt(MidStr(list.Items.Strings[list.ItemIndex],1,5));
|
---|
77 | lbl_notpossible.Visible:=False;
|
---|
78 | Self.img.Visible:=True;
|
---|
79 | Self.timer.Enabled:=False;
|
---|
80 | Self.panel_buttons.Visible:=False;
|
---|
81 | IF RightStr(list.Items.Strings[list.ItemIndex],4)='TXAN' THEN PreviewTXAN
|
---|
82 | ELSE
|
---|
83 | IF RightStr(list.Items.Strings[list.ItemIndex],4)='TXMB' THEN PreviewTXMB
|
---|
84 | ELSE
|
---|
85 | IF RightStr(list.Items.Strings[list.ItemIndex],4)='TXMP' THEN PreviewTXMP
|
---|
86 | ELSE BEGIN
|
---|
87 | Self.lbl_notpossible.Visible:=True;
|
---|
88 | Self.img.Visible:=False;
|
---|
89 | END;
|
---|
90 | END;
|
---|
91 |
|
---|
92 |
|
---|
93 | PROCEDURE TForm5.panel_extensionResize(Sender: TObject);
|
---|
94 | BEGIN
|
---|
95 | combo_extension.Width:=panel_extension.Width-5;
|
---|
96 | END;
|
---|
97 |
|
---|
98 |
|
---|
99 | PROCEDURE TForm5.combo_extensionClick(Sender: TObject);
|
---|
100 | VAR
|
---|
101 | Extension:String[4];
|
---|
102 | files:TStringList;
|
---|
103 | i:LongWord;
|
---|
104 | BEGIN
|
---|
105 | Extension:=MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex],1,4);
|
---|
106 | list.Items.Clear;
|
---|
107 | IF Extension='_All' THEN
|
---|
108 | files:=GetFilesList('','',True)
|
---|
109 | ELSE
|
---|
110 | files:=GetFilesList(extension,'',True);
|
---|
111 | IF Length(files)>0 THEN
|
---|
112 | FOR i:=0 TO High(files) DO
|
---|
113 | list.Items.Add(files[i]);
|
---|
114 | END;
|
---|
115 |
|
---|
116 |
|
---|
117 | PROCEDURE TForm5.PreviewTXMB;
|
---|
118 | VAR
|
---|
119 | data:Tdata;
|
---|
120 | img:TImgPackage;
|
---|
121 | BEGIN
|
---|
122 | SetLength(memstreams,1);
|
---|
123 | img:=LoadTXMBconnected(_fileid);
|
---|
124 | data:=ImgdataToBmp(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata);
|
---|
125 |
|
---|
126 | memstreams[0].Clear;
|
---|
127 | memstreams[0].Write(data[0],Length(data));
|
---|
128 | memstreams[0].Seek(0,soFromBeginning);
|
---|
129 |
|
---|
130 | Self.img.Picture.Bitmap.LoadFromStream(memstreams[0]);
|
---|
131 | END;
|
---|
132 |
|
---|
133 | PROCEDURE TForm5.PreviewTXMP;
|
---|
134 | VAR
|
---|
135 | data:Tdata;
|
---|
136 | img:TImgPackage;
|
---|
137 | BEGIN
|
---|
138 | SetLength(memstreams,1);
|
---|
139 | img:=LoadImgData(_fileid);
|
---|
140 | data:=ImgdataToBmp(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata);
|
---|
141 |
|
---|
142 | memstreams[0].Clear;
|
---|
143 | memstreams[0].Write(data[0],Length(data));
|
---|
144 | memstreams[0].Seek(0,soFromBeginning);
|
---|
145 |
|
---|
146 | Self.img.Picture.Bitmap.LoadFromStream(memstreams[0]);
|
---|
147 | END;
|
---|
148 |
|
---|
149 | PROCEDURE TForm5.PreviewTXAN;
|
---|
150 | VAR
|
---|
151 | loop_speed:Word;
|
---|
152 | linkcount:LongWord;
|
---|
153 | link:LongWord;
|
---|
154 | i:Byte;
|
---|
155 | data:Tdata;
|
---|
156 | img:TImgPackage;
|
---|
157 | BEGIN
|
---|
158 | LoadDatFilePart(_fileid,$14,SizeOf(loop_speed),@loop_speed);
|
---|
159 | LoadDatFilePart(_fileid,$1C,SizeOf(linkcount),@linkcount);
|
---|
160 | SetLength(memstreams,linkcount);
|
---|
161 | FOR i:=0 TO linkcount-1 DO BEGIN
|
---|
162 | LoadDatFilePart(_fileid,$20+i*4,SizeOf(link),@link);
|
---|
163 | link:=link DIV 256;
|
---|
164 | IF link=0 THEN link:=_fileid-1;
|
---|
165 | memstreams[i]:=TMemoryStream.Create;
|
---|
166 | img:=LoadImgData(link);
|
---|
167 | data:=ImgdataToBmp(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata);
|
---|
168 | memstreams[i].Clear;
|
---|
169 | memstreams[i].Write(data[0],Length(data));
|
---|
170 | memstreams[i].Seek(0,soFromBeginning);
|
---|
171 | END;
|
---|
172 | actualimg:=254;
|
---|
173 | Self.timer.Interval:=Floor(loop_speed*(1/60)*1000);
|
---|
174 | Self.timer.Enabled:=False;
|
---|
175 | Self.btn_startstopClick(Self);
|
---|
176 | Self.panel_buttons.Visible:=True;
|
---|
177 | END;
|
---|
178 |
|
---|
179 |
|
---|
180 | PROCEDURE TForm5.FormCreate(Sender: TObject);
|
---|
181 | BEGIN
|
---|
182 | SetLength(memstreams,1);
|
---|
183 | memstreams[0]:=TMemoryStream.Create;
|
---|
184 | Self.Width:=260;
|
---|
185 | Self.Height:=300;
|
---|
186 | END;
|
---|
187 |
|
---|
188 | PROCEDURE TForm5.timerTimer(Sender: TObject);
|
---|
189 | BEGIN
|
---|
190 | Inc(actualimg);
|
---|
191 | IF actualimg>=Length(memstreams) THEN actualimg:=0;
|
---|
192 | Self.img.Picture.Bitmap.LoadFromStream(memstreams[actualimg]);
|
---|
193 | memstreams[actualimg].Seek(0,soFromBeginning);
|
---|
194 | Self.Caption:='Preview '+dat_files[_fileid].FileName+' ('+IntToStr(actualimg+1)+'/'+IntToStr(Length(memstreams))+')';
|
---|
195 | END;
|
---|
196 |
|
---|
197 | PROCEDURE TForm5.panel_buttonsResize(Sender: TObject);
|
---|
198 | BEGIN
|
---|
199 | btn_startstop.Width:=panel_buttons.Width-45;
|
---|
200 | btn_inc.Left:=panel_buttons.Width-23;
|
---|
201 | END;
|
---|
202 |
|
---|
203 | PROCEDURE TForm5.btn_startstopClick(Sender: TObject);
|
---|
204 | BEGIN
|
---|
205 | Self.timer.Enabled:=NOT Self.timer.Enabled;
|
---|
206 | Self.btn_dec.Enabled:=NOT Self.timer.Enabled;
|
---|
207 | Self.btn_inc.Enabled:=NOT Self.timer.Enabled;
|
---|
208 | IF Self.timer.Enabled THEN
|
---|
209 | Self.btn_startstop.Caption:='Stop automatic'
|
---|
210 | ELSE
|
---|
211 | Self.btn_startstop.Caption:='Start automatic';
|
---|
212 | END;
|
---|
213 |
|
---|
214 | PROCEDURE TForm5.FormResize(Sender: TObject);
|
---|
215 | BEGIN
|
---|
216 | IF Self.Width>=300 THEN BEGIN
|
---|
217 | END ELSE Self.Width:=300;
|
---|
218 | IF Self.Height>=200 THEN BEGIN
|
---|
219 | END ELSE Self.Height:=200;
|
---|
220 | END;
|
---|
221 |
|
---|
222 | PROCEDURE TForm5.btn_decClick(Sender: TObject);
|
---|
223 | BEGIN
|
---|
224 | IF actualimg>0 THEN
|
---|
225 | Dec(actualimg)
|
---|
226 | ELSE
|
---|
227 | actualimg:=High(memstreams);
|
---|
228 | Self.Caption:='Preview '+dat_files[_fileid].FileName+' ('+IntToStr(actualimg+1)+'/'+IntToStr(Length(memstreams))+')';
|
---|
229 | Self.img.Picture.Bitmap.LoadFromStream(memstreams[actualimg]);
|
---|
230 | memstreams[actualimg].Seek(0,soFromBeginning);
|
---|
231 | END;
|
---|
232 |
|
---|
233 | PROCEDURE TForm5.btn_incClick(Sender: TObject);
|
---|
234 | BEGIN
|
---|
235 | IF actualimg<High(memstreams) THEN
|
---|
236 | Inc(actualimg)
|
---|
237 | ELSE
|
---|
238 | actualimg:=0;
|
---|
239 | Self.Caption:='Preview '+dat_files[_fileid].FileName+' ('+IntToStr(actualimg+1)+'/'+IntToStr(Length(memstreams))+')';
|
---|
240 | Self.img.Picture.Bitmap.LoadFromStream(memstreams[actualimg]);
|
---|
241 | memstreams[actualimg].Seek(0,soFromBeginning);
|
---|
242 | END;
|
---|
243 |
|
---|
244 |
|
---|
245 | PROCEDURE TForm5.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
246 | BEGIN
|
---|
247 | Action:=caFree;
|
---|
248 | Form1.close_window(Self.Name);
|
---|
249 | END;
|
---|
250 |
|
---|
251 |
|
---|
252 | PROCEDURE TForm5.FormActivate(Sender: TObject);
|
---|
253 | BEGIN
|
---|
254 | Form1.SetActiveWindow(Self.Name);
|
---|
255 | END;
|
---|
256 |
|
---|
257 | END.
|
---|