1 | UNIT Unit1_main;
|
---|
2 | INTERFACE
|
---|
3 | USES
|
---|
4 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
5 | Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids,
|
---|
6 | MPHexEditor, ToolWin, ImgList, Tabs,
|
---|
7 | Unit2_functions, Unit3_data, Unit9_data_structures,
|
---|
8 | Unit10_leveldb, Unit4_exporters, Unit14_settings,
|
---|
9 | Unit5_preview, Unit7_txmpreplace, Unit8_binedit, Unit11_extractor, Unit13_rawedit,
|
---|
10 | Unit15_Classes;
|
---|
11 |
|
---|
12 | TYPE
|
---|
13 | TForm1 = Class(TForm)
|
---|
14 | tabs: TTabSet;
|
---|
15 | saved: TSaveDialog;
|
---|
16 | opend: TOpenDialog;
|
---|
17 | statbar: TStatusBar;
|
---|
18 | menu: TMainMenu;
|
---|
19 | menu_main: TMenuItem;
|
---|
20 | menu_loaddat: TMenuItem;
|
---|
21 | menu_lvldb: TMenuItem;
|
---|
22 | menu_exit: TMenuItem;
|
---|
23 | menu_convert: TMenuItem;
|
---|
24 | menu_createdb: TMenuItem;
|
---|
25 | menu_createlvl: TMenuItem;
|
---|
26 | menu_tools: TMenuItem;
|
---|
27 | menu_preview: TMenuItem;
|
---|
28 | menu_txmpreplace: TMenuItem;
|
---|
29 | menu_binedit: TMenuItem;
|
---|
30 | menu_extractor: TMenuItem;
|
---|
31 | menu_windows: TMenuItem;
|
---|
32 | menu_windows_cascade: TMenuItem;
|
---|
33 | menu_windows_tile: TMenuItem;
|
---|
34 | menu_windows_closeall: TMenuItem;
|
---|
35 | menu_windows_next: TMenuItem;
|
---|
36 | menu_windows_previous: TMenuItem;
|
---|
37 | menu_sep1: TMenuItem;
|
---|
38 | menu_sep2: TMenuItem;
|
---|
39 | menu_sep3: TMenuItem;
|
---|
40 | menu_levelstructedit: TMenuItem;
|
---|
41 | menu_rawedit: TMenuItem;
|
---|
42 | menu_filecompare: TMenuItem;
|
---|
43 | menu_CloseFileDB: TMenuItem;
|
---|
44 | menu_sep4: TMenuItem;
|
---|
45 | menu_settings: TMenuItem;
|
---|
46 | menu_About: TMenuItem;
|
---|
47 | FUNCTION TryCloseAll:Boolean;
|
---|
48 | procedure menu_AboutClick(Sender: TObject);
|
---|
49 | PROCEDURE menu_settingsClick(Sender: TObject);
|
---|
50 | PROCEDURE menu_CloseFileDBClick(Sender: TObject);
|
---|
51 | PROCEDURE menu_filecompareClick(Sender: TObject);
|
---|
52 | PROCEDURE menu_raweditClick(Sender: TObject);
|
---|
53 | PROCEDURE menu_createlvlClick(Sender: TObject);
|
---|
54 | PROCEDURE menu_extractorClick(Sender: TObject);
|
---|
55 | PROCEDURE menu_lvldbClick(Sender: TObject);
|
---|
56 | PROCEDURE menu_createdbClick(Sender: TObject);
|
---|
57 | PROCEDURE SetActiveWindow(window_name:String);
|
---|
58 | PROCEDURE tabsChange(Sender: TObject; NewTab: Integer; var AllowChange: Boolean);
|
---|
59 | PROCEDURE close_window(window_name:String);
|
---|
60 | PROCEDURE menu_windows_previousClick(Sender: TObject);
|
---|
61 | PROCEDURE menu_windows_nextClick(Sender: TObject);
|
---|
62 | PROCEDURE menu_windows_tileClick(Sender: TObject);
|
---|
63 | FUNCTION open_child(window_context:String):Boolean;
|
---|
64 | PROCEDURE menu_windows_closeallClick(Sender: TObject);
|
---|
65 | PROCEDURE menu_windows_cascadeClick(Sender: TObject);
|
---|
66 | PROCEDURE menu_window_entryClick(Sender: TObject);
|
---|
67 | PROCEDURE menu_bineditClick(Sender: TObject);
|
---|
68 | PROCEDURE menu_loaddatClick(Sender: TObject);
|
---|
69 | PROCEDURE menu_txmpreplaceClick(Sender: TObject);
|
---|
70 | PROCEDURE menu_exitClick(Sender: TObject);
|
---|
71 | PROCEDURE menu_previewClick(Sender: TObject);
|
---|
72 | PROCEDURE FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
73 | PROCEDURE FormResize(Sender: TObject);
|
---|
74 | PROCEDURE FormCreate(Sender: TObject);
|
---|
75 | PROCEDURE UpdateStatBar;
|
---|
76 | PRIVATE
|
---|
77 | PUBLIC
|
---|
78 | END;
|
---|
79 |
|
---|
80 | VAR
|
---|
81 | Form1: TForm1;
|
---|
82 |
|
---|
83 | IMPLEMENTATION
|
---|
84 | {$R *.dfm}
|
---|
85 | VAR
|
---|
86 | tablist:Array OF String;
|
---|
87 |
|
---|
88 | PROCEDURE TForm1.FormCreate(Sender: TObject);
|
---|
89 | BEGIN
|
---|
90 | Form1.Caption:='Oni Un/Packer '+version;
|
---|
91 | Form1.FormResize(Form1);
|
---|
92 |
|
---|
93 | IF FileExists(ExtractFilepath(Application.EXEname)+'\oniunpacker.ini') THEN BEGIN
|
---|
94 | AssignFile(AppSettingsFile,ExtractFilepath(Application.EXEname)+'\oniunpacker.ini');
|
---|
95 | Reset(AppSettingsFile);
|
---|
96 | Read(AppSettingsFile,AppSettings);
|
---|
97 | CloseFile(AppSettingsFile);
|
---|
98 | END ELSE BEGIN
|
---|
99 | AppSettings.DatPath:='D:\Spiele\Oni\GameDataFolder';
|
---|
100 | AppSettings.ExtractPath:='C:\Dokumente und Einstellungen\Administrator\Desktop';
|
---|
101 | AppSettings.FilenumbersAsHex:=False;
|
---|
102 | AppSettings.CharSet:=DEFAULT_CHARSET;
|
---|
103 | AppSettings.HideUnusedData:=False;
|
---|
104 | END;
|
---|
105 |
|
---|
106 | IF MidStr(ParamStr(1),1,3)='opf' THEN BEGIN
|
---|
107 | ShowMessage('Load OPF-File: '+ParamStr(2));
|
---|
108 | END ELSE IF MidStr(ParamStr(1),1,4)='oldb' THEN BEGIN
|
---|
109 | IF NOT CreateDataConnection(ParamStr(2), ODB_ADB) THEN
|
---|
110 | ShowMessage('Error while loading the file:'+CrLf+ParamStr(2)+CrLf+'Perhaps not an OniUnPacker-LevelDatabase-file?');
|
---|
111 | END ELSE IF MidStr(ParamStr(1),1,3)='dat' THEN BEGIN
|
---|
112 | IF NOT CreateDataConnection(ParamStr(2), ODB_Dat) THEN
|
---|
113 | ShowMessage('Error while loading the file:'+CrLf+ParamStr(2)+CrLf+'Perhaps not an Oni-.dat-file?');
|
---|
114 | END;
|
---|
115 | UpdateStatBar;
|
---|
116 | END;
|
---|
117 |
|
---|
118 | PROCEDURE TForm1.FormResize(Sender: TObject);
|
---|
119 | CONST
|
---|
120 | MinWidth:Integer=750;
|
---|
121 | MinHeight:Integer=500;
|
---|
122 | BEGIN
|
---|
123 | IF Form1.Width<MinWidth THEN Form1.Width:=MinWidth;
|
---|
124 | IF Form1.Height<MinHeight THEN Form1.Height:=MinHeight;
|
---|
125 | Form1.statbar.Panels.Items[0].Width:=Form1.Width-200;
|
---|
126 | END;
|
---|
127 |
|
---|
128 | PROCEDURE TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
129 | BEGIN
|
---|
130 | AssignFile(AppSettingsFile,ExtractFilepath(Application.EXEname)+'\oniunpacker.ini');
|
---|
131 | IF FileExists(ExtractFilepath(Application.EXEname)+'\oniunpacker.ini') THEN
|
---|
132 | Reset(AppSettingsFile)
|
---|
133 | ELSE
|
---|
134 | Rewrite(AppSettingsFile);
|
---|
135 | Write(AppSettingsFile,AppSettings);
|
---|
136 | CloseFile(AppSettingsFile);
|
---|
137 | Action:=caFree;
|
---|
138 | END;
|
---|
139 |
|
---|
140 |
|
---|
141 | PROCEDURE TForm1.UpdateStatBar;
|
---|
142 | BEGIN
|
---|
143 | IF Assigned(OniDataConnection) THEN BEGIN
|
---|
144 | Form1.Caption:='Oni Un/Packer '+version+' ('+ExtractFileName(OniDataConnection.FileName)+')';
|
---|
145 | menu_tools.Enabled:=True;
|
---|
146 | menu_convert.Enabled:=False;
|
---|
147 | statbar.Panels.Items[1].Text:='Files: '+IntToStr(OniDataConnection.GetFilesCount);
|
---|
148 | statbar.Panels.Items[2].Text:='Extensions: '+IntToStr(Length(OniDataConnection.GetExtensionsList));
|
---|
149 | CASE OniDataConnection.Backend OF
|
---|
150 | ODB_Dat:
|
---|
151 | BEGIN
|
---|
152 | statbar.Panels.Items[0].Text:='.dat loaded: '+OniDataConnection.FileName;
|
---|
153 | END;
|
---|
154 | ODB_ADB:
|
---|
155 | BEGIN
|
---|
156 | statbar.Panels.Items[0].Text:='OLDB loaded: '+OniDataConnection.FileName;
|
---|
157 | END;
|
---|
158 | ELSE
|
---|
159 | Form1.Caption:='Oni Un/Packer '+version;
|
---|
160 | statbar.Panels.Items[0].Text:='Nothing loaded';
|
---|
161 | statbar.Panels.Items[1].Text:='Files: -';
|
---|
162 | statbar.Panels.Items[2].Text:='Extensions: -';
|
---|
163 | menu_tools.Enabled:=False;
|
---|
164 | menu_convert.Enabled:=True;
|
---|
165 | END;
|
---|
166 | END ELSE BEGIN
|
---|
167 | Form1.Caption:='Oni Un/Packer '+version;
|
---|
168 | statbar.Panels.Items[0].Text:='Nothing loaded';
|
---|
169 | statbar.Panels.Items[1].Text:='Files: -';
|
---|
170 | statbar.Panels.Items[2].Text:='Extensions: -';
|
---|
171 | menu_tools.Enabled:=False;
|
---|
172 | menu_convert.Enabled:=True;
|
---|
173 | END;
|
---|
174 | END;
|
---|
175 |
|
---|
176 |
|
---|
177 | FUNCTION TForm1.TryCloseAll:Boolean;
|
---|
178 | BEGIN
|
---|
179 | menu_windows_closeallClick(Self);
|
---|
180 | IF Length(tablist)=0 THEN
|
---|
181 | Result:=True
|
---|
182 | ELSE
|
---|
183 | Result:=False;
|
---|
184 | END;
|
---|
185 |
|
---|
186 |
|
---|
187 | {#################################}
|
---|
188 | {##### Main-Menu-Handlers #####}
|
---|
189 | {#################################}
|
---|
190 | PROCEDURE TForm1.menu_loaddatClick(Sender: TObject);
|
---|
191 | VAR i:LongWord;
|
---|
192 | answer:Boolean;
|
---|
193 | BEGIN
|
---|
194 | IF TryCloseAll THEN BEGIN
|
---|
195 | CloseDataConnection;
|
---|
196 | opend.InitialDir:=AppSettings.DatPath;
|
---|
197 | opend.Filter:='Oni-Dat-Files|*.dat';
|
---|
198 | IF opend.Execute THEN BEGIN
|
---|
199 | IF NOT CreateDataConnection(opend.FileName, ODB_Dat) THEN
|
---|
200 | ShowMessage('Error while loading the file:'+CrLf+opend.FileName+CrLf+'Perhaps not an Oni-.dat-file?');
|
---|
201 | AppSettings.DatPath:=ExtractFilepath(opend.FileName);
|
---|
202 | END;
|
---|
203 | END;
|
---|
204 | UpdateStatBar;
|
---|
205 | END;
|
---|
206 | PROCEDURE TForm1.menu_lvldbClick(Sender: TObject);
|
---|
207 | VAR answer:Boolean;
|
---|
208 | BEGIN
|
---|
209 | IF TryCloseAll THEN BEGIN
|
---|
210 | CloseDataConnection;
|
---|
211 | opend.InitialDir:=AppSettings.DatPath;
|
---|
212 | opend.Filter:='OUP-Level-DB (*.oldb)|*.oldb';
|
---|
213 | IF opend.Execute THEN BEGIN
|
---|
214 | IF NOT CreateDataConnection(opend.FileName, ODB_ADB) THEN
|
---|
215 | ShowMessage('Error while loading the file:'+CrLf+opend.FileName+CrLf+'Perhaps not an OniUnPacker-LevelDatabase-file?');
|
---|
216 | AppSettings.DatPath:=ExtractFilepath(opend.FileName);
|
---|
217 | END;
|
---|
218 | END;
|
---|
219 | UpdateStatBar;
|
---|
220 | END;
|
---|
221 | PROCEDURE TForm1.menu_CloseFileDBClick(Sender: TObject);
|
---|
222 | BEGIN
|
---|
223 | IF TryCloseAll THEN BEGIN
|
---|
224 | CloseDataConnection;
|
---|
225 | UpdateStatBar;
|
---|
226 | END;
|
---|
227 | END;
|
---|
228 | PROCEDURE TForm1.menu_settingsClick(Sender: TObject);
|
---|
229 | BEGIN
|
---|
230 | Form14.Visible:=True;
|
---|
231 | Self.Enabled:=False;
|
---|
232 | END;
|
---|
233 | PROCEDURE TForm1.menu_exitClick(Sender: TObject);
|
---|
234 | BEGIN
|
---|
235 | Form1.Close;
|
---|
236 | END;
|
---|
237 |
|
---|
238 | {####################################}
|
---|
239 | {##### Converters-Menu-Handlers #####}
|
---|
240 | {####################################}
|
---|
241 | PROCEDURE TForm1.menu_createdbClick(Sender: TObject);
|
---|
242 | BEGIN
|
---|
243 | opend.Filter:='Oni-Dat-Files|*.dat';
|
---|
244 | saved.Filter:='OUP-Level-DB (*.oldb)|*.oldb';
|
---|
245 | saved.DefaultExt:='oldb';
|
---|
246 | IF opend.Execute THEN BEGIN
|
---|
247 | IF saved.Execute THEN BEGIN
|
---|
248 | Form10.CreateDatabase(opend.FileName,saved.FileName);
|
---|
249 | END;
|
---|
250 | END;
|
---|
251 | END;
|
---|
252 | PROCEDURE TForm1.menu_createlvlClick(Sender: TObject);
|
---|
253 | BEGIN
|
---|
254 | opend.Filter:='OUP-Level-DB (*.oldb)|*.oldb';
|
---|
255 | saved.Filter:='Oni-Dat-Files|*.dat';
|
---|
256 | saved.DefaultExt:='dat';
|
---|
257 | IF opend.Execute THEN BEGIN
|
---|
258 | IF saved.Execute THEN BEGIN
|
---|
259 | Form10.CreateLevel(opend.FileName,saved.FileName);
|
---|
260 | END;
|
---|
261 | END;
|
---|
262 | END;
|
---|
263 |
|
---|
264 | {#################################}
|
---|
265 | {##### Tools-Menu-Handlers #####}
|
---|
266 | {#################################}
|
---|
267 | PROCEDURE TForm1.menu_previewClick(Sender: TObject);
|
---|
268 | BEGIN
|
---|
269 | open_child('preview');
|
---|
270 | END;
|
---|
271 | PROCEDURE TForm1.menu_txmpreplaceClick(Sender: TObject);
|
---|
272 | BEGIN
|
---|
273 | open_child('txmpreplace');
|
---|
274 | END;
|
---|
275 | PROCEDURE TForm1.menu_bineditClick(Sender: TObject);
|
---|
276 | BEGIN
|
---|
277 | open_child('binedit');
|
---|
278 | END;
|
---|
279 | PROCEDURE TForm1.menu_raweditClick(Sender: TObject);
|
---|
280 | BEGIN
|
---|
281 | open_child('rawedit');
|
---|
282 | END;
|
---|
283 |
|
---|
284 | PROCEDURE TForm1.menu_extractorClick(Sender: TObject);
|
---|
285 | BEGIN
|
---|
286 | open_child('extractor');
|
---|
287 | END;
|
---|
288 | PROCEDURE TForm1.menu_filecompareClick(Sender: TObject);
|
---|
289 | BEGIN
|
---|
290 | open_child('compare');
|
---|
291 | END;
|
---|
292 |
|
---|
293 |
|
---|
294 | {#################################}
|
---|
295 | {##### Window-Menu-Handlers #####}
|
---|
296 | {#################################}
|
---|
297 | PROCEDURE TForm1.menu_windows_cascadeClick(Sender: TObject);
|
---|
298 | BEGIN
|
---|
299 | Form1.Cascade;
|
---|
300 | END;
|
---|
301 | PROCEDURE TForm1.menu_windows_tileClick(Sender: TObject);
|
---|
302 | BEGIN
|
---|
303 | Form1.TileMode:=tbHorizontal;
|
---|
304 | Form1.Tile;
|
---|
305 | END;
|
---|
306 | PROCEDURE TForm1.menu_windows_closeallClick(Sender: TObject);
|
---|
307 | VAR
|
---|
308 | i:Byte;
|
---|
309 | BEGIN
|
---|
310 | IF MDIChildCount>0 THEN BEGIN
|
---|
311 | FOR i:=0 TO MDIChildCount-1 DO BEGIN
|
---|
312 | MDIChildren[i].Close;
|
---|
313 | END;
|
---|
314 | END;
|
---|
315 | tabs.Tabs.Clear;
|
---|
316 | END;
|
---|
317 | PROCEDURE TForm1.menu_windows_nextClick(Sender: TObject);
|
---|
318 | VAR i:Byte;
|
---|
319 | first_window:Byte;
|
---|
320 | current_focus:String;
|
---|
321 | BEGIN
|
---|
322 | IF MDIChildCount>1 THEN BEGIN
|
---|
323 | FOR i:=0 TO menu_windows.Count-1 DO BEGIN
|
---|
324 | IF Pos('menu_window_',menu_windows.Items[i].Name)=1 THEN BEGIN
|
---|
325 | first_window:=i;
|
---|
326 | Break;
|
---|
327 | END;
|
---|
328 | END;
|
---|
329 | current_focus:=ActiveMDIChild.Name;
|
---|
330 | FOR i:=first_window TO menu_windows.Count-1 DO
|
---|
331 | IF Pos(current_focus,menu_windows.Items[i].Name)>0 THEN
|
---|
332 | Break;
|
---|
333 | IF i=menu_windows.Count-1 THEN
|
---|
334 | menu_windows.Items[first_window].Click
|
---|
335 | ELSE
|
---|
336 | menu_windows.Items[i+1].Click;
|
---|
337 | FOR i:=0 TO High(tablist) DO BEGIN
|
---|
338 | IF tablist[i]=ActiveMDIChild.Name THEN BEGIN
|
---|
339 | tabs.TabIndex:=i;
|
---|
340 | END;
|
---|
341 | END;
|
---|
342 | END;
|
---|
343 | END;
|
---|
344 | PROCEDURE TForm1.menu_windows_previousClick(Sender: TObject);
|
---|
345 | VAR i:Byte;
|
---|
346 | first_window:Byte;
|
---|
347 | current_focus:String;
|
---|
348 | BEGIN
|
---|
349 | IF MDIChildCount>1 THEN BEGIN
|
---|
350 | FOR i:=0 TO menu_windows.Count-1 DO BEGIN
|
---|
351 | IF Pos('menu_window_',menu_windows.Items[i].Name)=1 THEN BEGIN
|
---|
352 | first_window:=i;
|
---|
353 | Break;
|
---|
354 | END;
|
---|
355 | END;
|
---|
356 | current_focus:=ActiveMDIChild.Name;
|
---|
357 | FOR i:=first_window TO menu_windows.Count-1 DO
|
---|
358 | IF Pos(current_focus,menu_windows.Items[i].Name)>0 THEN
|
---|
359 | Break;
|
---|
360 | IF i=first_window THEN
|
---|
361 | menu_windows.Items[menu_windows.Count-1].Click
|
---|
362 | ELSE
|
---|
363 | menu_windows.Items[i-1].Click;
|
---|
364 | FOR i:=0 TO High(tablist) DO BEGIN
|
---|
365 | IF tablist[i]=ActiveMDIChild.Name THEN BEGIN
|
---|
366 | tabs.TabIndex:=i;
|
---|
367 | END;
|
---|
368 | END;
|
---|
369 | END;
|
---|
370 | END;
|
---|
371 |
|
---|
372 | PROCEDURE TForm1.menu_window_entryClick(Sender: TObject);
|
---|
373 | VAR
|
---|
374 | i:Byte;
|
---|
375 | window_name:String;
|
---|
376 | BEGIN
|
---|
377 | window_name:=MidStr(TComponent(Sender).Name,Pos('window_',TComponent(Sender).Name)+7,Length(TComponent(Sender).Name)-Pos('window_',TComponent(Sender).Name)+7+1);
|
---|
378 | FOR i:=0 TO MDIChildCount-1 DO BEGIN
|
---|
379 | IF MDIChildren[i].Name=window_name THEN BEGIN
|
---|
380 | MDIChildren[i].BringToFront;
|
---|
381 | END;
|
---|
382 | END;
|
---|
383 | FOR i:=0 TO High(tablist) DO BEGIN
|
---|
384 | IF tablist[i]=ActiveMDIChild.Name THEN BEGIN
|
---|
385 | tabs.TabIndex:=i;
|
---|
386 | END;
|
---|
387 | END;
|
---|
388 | END;
|
---|
389 |
|
---|
390 | procedure TForm1.menu_AboutClick(Sender: TObject);
|
---|
391 | begin
|
---|
392 | ShowMessage('Will be implemented later ;)');
|
---|
393 | end;
|
---|
394 |
|
---|
395 |
|
---|
396 |
|
---|
397 |
|
---|
398 | FUNCTION TForm1.open_child(window_context:String):Boolean;
|
---|
399 | VAR
|
---|
400 | rawEdit:TForm13;
|
---|
401 | binEdit:TForm8;
|
---|
402 | preview:TForm5;
|
---|
403 | txmpreplacer:TForm7;
|
---|
404 | extractor:TForm11;
|
---|
405 | menu_button:TMenuItem;
|
---|
406 | used:Array[1..9] OF Boolean;
|
---|
407 | i:Byte;
|
---|
408 | caption:String;
|
---|
409 | name:String;
|
---|
410 | BEGIN
|
---|
411 | Result:=True;
|
---|
412 | FOR i:=1 TO 9 DO used[i]:=False;
|
---|
413 | IF MDIChildCount>0 THEN
|
---|
414 | FOR i:=0 TO MDIChildCount-1 DO
|
---|
415 | IF Pos(window_context,Form1.MDIChildren[i].Name)=1 THEN
|
---|
416 | used[StrToInt(RightStr(Form1.MDIChildren[i].Caption,1))]:=True;
|
---|
417 | FOR i:=1 TO 10 DO
|
---|
418 | IF i=10 THEN
|
---|
419 | Break
|
---|
420 | ELSE
|
---|
421 | IF NOT used[i] THEN Break;
|
---|
422 |
|
---|
423 | IF i<10 THEN BEGIN
|
---|
424 | name:=window_context+IntToStr(i);
|
---|
425 | IF window_context='binedit' THEN
|
---|
426 | caption:='Binary .dat-Editor '+IntToStr(i);
|
---|
427 | IF window_context='rawedit' THEN
|
---|
428 | caption:='Binary .raw-Editor '+IntToStr(i);
|
---|
429 | IF window_context='preview' THEN
|
---|
430 | caption:='Preview-Window '+IntToStr(i);
|
---|
431 | IF window_context='txmpreplace' THEN
|
---|
432 | caption:='TXMP Replacer '+IntToStr(i);
|
---|
433 | IF window_context='extractor' THEN
|
---|
434 | caption:='Extractor '+IntToStr(i);
|
---|
435 |
|
---|
436 | menu_button:=TMenuItem.Create(menu_windows);
|
---|
437 | menu_button.Caption:=caption;
|
---|
438 | menu_button.Name:='menu_window_'+name;
|
---|
439 | menu_button.OnClick:=Form1.menu_window_entryClick;
|
---|
440 | menu_windows.Add(menu_button);
|
---|
441 |
|
---|
442 | SetLength(tablist,Length(tablist)+1);
|
---|
443 | tablist[High(tablist)]:=name;
|
---|
444 | tabs.Tabs.Add(caption);
|
---|
445 |
|
---|
446 | IF window_context='binedit' THEN BEGIN
|
---|
447 | binEdit:=TForm8.Create(Application);
|
---|
448 | binEdit.Name:=name;
|
---|
449 | binEdit.Caption:=caption;
|
---|
450 | binEdit.Recreatelist;
|
---|
451 | END;
|
---|
452 | IF window_context='rawedit' THEN BEGIN
|
---|
453 | rawEdit:=TForm13.Create(Application);
|
---|
454 | rawEdit.Name:=name;
|
---|
455 | rawEdit.Caption:=caption;
|
---|
456 | rawEdit.Recreatelist;
|
---|
457 | END;
|
---|
458 | IF window_context='preview' THEN BEGIN
|
---|
459 | preview:=TForm5.Create(Application);
|
---|
460 | preview.Name:=name;
|
---|
461 | preview.Caption:=caption;
|
---|
462 | preview.Recreatelist;
|
---|
463 | END;
|
---|
464 | IF window_context='txmpreplace' THEN BEGIN
|
---|
465 | txmpreplacer:=TForm7.Create(Application);
|
---|
466 | txmpreplacer.Name:=name;
|
---|
467 | txmpreplacer.Caption:=caption;
|
---|
468 | txmpreplacer.Recreatelist;
|
---|
469 | END;
|
---|
470 | IF window_context='extractor' THEN BEGIN
|
---|
471 | extractor:=TForm11.Create(Application);
|
---|
472 | extractor.Name:=name;
|
---|
473 | extractor.Caption:=caption;
|
---|
474 | extractor.Recreatelist;
|
---|
475 | END;
|
---|
476 |
|
---|
477 | tabs.TabIndex:=High(tablist);
|
---|
478 | IF MDIChildCount=9 THEN menu_tools.Enabled:=False;
|
---|
479 | END ELSE BEGIN
|
---|
480 | Result:=False;
|
---|
481 | END;
|
---|
482 | END;
|
---|
483 |
|
---|
484 |
|
---|
485 | PROCEDURE TForm1.close_window(window_name:String);
|
---|
486 | VAR
|
---|
487 | i,j:Byte;
|
---|
488 | BEGIN
|
---|
489 | FOR i:=0 TO menu_windows.Count-1 DO BEGIN
|
---|
490 | IF menu_windows.Items[i].Name='menu_window_'+window_name THEN BEGIN
|
---|
491 | menu_windows.Items[i].Free;
|
---|
492 | Break;
|
---|
493 | END;
|
---|
494 | END;
|
---|
495 | FOR i:=0 TO High(tablist) DO BEGIN
|
---|
496 | IF tablist[i]=window_name THEN BEGIN
|
---|
497 | tabs.Tabs.Delete(i);
|
---|
498 | IF High(tablist)>0 THEN
|
---|
499 | FOR j:=i TO High(tablist)-1 DO
|
---|
500 | tablist[j]:=tablist[j+1];
|
---|
501 | SetLength(tablist,Length(tablist)-1);
|
---|
502 | Break;
|
---|
503 | END;
|
---|
504 | END;
|
---|
505 | menu_tools.Enabled:=True;
|
---|
506 | END;
|
---|
507 |
|
---|
508 |
|
---|
509 | PROCEDURE TForm1.tabsChange(Sender: TObject; NewTab: Integer; var AllowChange: Boolean);
|
---|
510 | VAR
|
---|
511 | i:Byte;
|
---|
512 | BEGIN
|
---|
513 | FOR i:=0 TO MDIChildCount-1 DO BEGIN
|
---|
514 | IF MDIChildren[i].Name=tablist[NewTab] THEN
|
---|
515 | MDIChildren[i].BringToFront;
|
---|
516 | END;
|
---|
517 | END;
|
---|
518 |
|
---|
519 | PROCEDURE TForm1.SetActiveWindow(window_name:String);
|
---|
520 | VAR
|
---|
521 | i:Byte;
|
---|
522 | BEGIN
|
---|
523 | IF Length(tablist)>0 THEN
|
---|
524 | FOR i:=0 TO High(tablist) DO
|
---|
525 | IF tablist[i]=window_name THEN
|
---|
526 | tabs.TabIndex:=i;
|
---|
527 | END;
|
---|
528 |
|
---|
529 |
|
---|
530 | END.
|
---|