source: oup/current/Main.pas@ 138

Last change on this file since 138 was 129, checked in by alloc, 18 years ago
File size: 22.2 KB
RevLine 
[93]1unit Main;
2interface
3uses
4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
5 Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids,
6 MPHexEditor, ToolWin, ImgList, Tabs,
7 MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst,
8 Data, TypeDefs, ConnectionManager,
9// Functions, Exporters, DataStructures,
[97]10 Functions,
[93]11 Settings, {Helper_LevelDB, }
[97]12 Template,
[105]13 RawEdit, BinEdit, Extractor, Preview, TxmpReplace;
[93]14
15type
16 TForm_Main = class(TForm)
17 saved: TSaveDialog;
18 opend: TOpenDialog;
19 statbar: TStatusBar;
20 MenuImages: TImageList;
21 DockTop: TTBDock;
22 MainMenu: TTBToolbar;
23 menu_main: TTBSubmenuItem;
24 menu_loadfile: TTBItem;
25 menu_sep1: TTBSeparatorItem;
26 menu_settings: TTBItem;
27 menu_sep4: TTBSeparatorItem;
28 menu_exit: TTBItem;
29 menu_convert: TTBSubmenuItem;
30 menu_createdb: TTBItem;
31 menu_createlvl: TTBItem;
32 menu_tools: TTBSubmenuItem;
33 menu_preview: TTBItem;
34 menu_binedit: TTBItem;
35 menu_rawedit: TTBItem;
36 menu_txmpreplace: TTBItem;
37 menu_extractor: TTBItem;
38 menu_filecompare: TTBItem;
39 menu_levelstructedit: TTBItem;
40 menu_view: TTBSubmenuItem;
41 menu_windows_cascade: TTBItem;
42 menu_windows_tile: TTBItem;
43 menu_windows_closeall: TTBItem;
44 menu_sep3: TTBSeparatorItem;
45 menu_windows_next: TTBItem;
46 menu_windows_previous: TTBItem;
47 menu_sep2: TTBSeparatorItem;
48 menu_About: TTBItem;
49 Toolbar: TTBToolbar;
50 tbOpen: TTBItem;
51 DockLeft: TTBDock;
52 DockRight: TTBDock;
53 DockBottom: TTBDock;
54 MDIToolbar: TTBToolbar;
55 TBControlItem1: TTBControlItem;
56 MDITab: TMDITab;
57 menu_toolbars: TTBSubmenuItem;
58 menu_view_mdibar: TTBItem;
59 menu_view_statusbar: TTBItem;
60 menu_view_toolbar: TTBItem;
61 tb_separator1: TTBSeparatorItem;
62 tb_preview: TTBItem;
63 tb_structure: TTBItem;
64 tb_compare: TTBItem;
65 tb_extractor: TTBItem;
66 tb_txmpreplacer: TTBItem;
67 tb_rawedit: TTBItem;
68 tb_datedit: TTBItem;
69 menu_windows_tilevert: TTBItem;
70 tb_meta: TTBItem;
71 menu_meta: TTBItem;
72 TBSeparatorItem1: TTBSeparatorItem;
73 tb_db2dat: TTBItem;
74 tb_dat2db: TTBItem;
75 menu_loaddb: TTBItem;
76 tb_opendb: TTBItem;
77 Images_Close: TImageList;
78 menu_conns: TTBSubmenuItem;
79 menu_windows: TTBSubmenuItem;
80 procedure FormClose(Sender: TObject; var Action: TCloseAction);
81 procedure FormResize(Sender: TObject);
82 procedure FormCreate(Sender: TObject);
83 procedure ActivateTools(active: Boolean);
84 procedure UpdateStatBar;
85 procedure UpdateConLists;
86 procedure LoadFile(typedb: Boolean);
87 function TryCloseAll: Boolean;
88 procedure MDITabDrawTab(Control: TCustomTabControl; TabIndex: Integer;
89 const Rect: TRect; Active: Boolean);
90 procedure MDITabMouseUp(Sender: TObject; Button: TMouseButton;
91 Shift: TShiftState; X, Y: Integer);
92 procedure MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
93 Y: Integer);
94 procedure ToolbarDockChanged(Sender: TObject);
95 procedure CreateConnection(filename: String);
[97]96 function CheckConnectionCloseable(index: Integer): Boolean;
[93]97
98 procedure menu_loadfileClick(Sender: TObject);
99 procedure menu_loaddbClick(Sender: TObject);
100 procedure menu_settingsClick(Sender: TObject);
101 procedure menu_exitClick(Sender: TObject);
102
103 procedure menu_createlvlClick(Sender: TObject);
104 procedure menu_createdbClick(Sender: TObject);
105
106 procedure menu_bineditClick(Sender: TObject);
107 procedure menu_filecompareClick(Sender: TObject);
108 procedure menu_raweditClick(Sender: TObject);
109 procedure menu_extractorClick(Sender: TObject);
110 procedure menu_txmpreplaceClick(Sender: TObject);
111 procedure menu_previewClick(Sender: TObject);
112 procedure menu_metaClick(Sender: TObject);
113 function open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
114
115 procedure menu_windows_cascadeClick(Sender: TObject);
116 procedure menu_windows_tilevertClick(Sender: TObject);
117 procedure menu_windows_tileClick(Sender: TObject);
118 procedure menu_windows_closeallClick(Sender: TObject);
119 procedure menu_windows_previousClick(Sender: TObject);
120 procedure menu_windows_nextClick(Sender: TObject);
121 procedure menu_conns_itemClick(Sender: TObject);
122 procedure menu_windows_itemClick(Sender: TObject);
123 procedure menu_view_mdibarClick(Sender: TObject);
124 procedure menu_view_statusbarClick(Sender: TObject);
125 procedure menu_view_toolbarClick(Sender: TObject);
126
127 procedure menu_AboutClick(Sender: TObject);
128
129 procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
130 private
131 public
132 procedure DefaultHandler(var Message); override;
133 end;
134
135var
136 Form_Main: TForm_Main;
137
138implementation
139
[129]140uses
141 LevelDB;
142
[93]143{$R *.dfm}
144
145
146procedure ShowOpenMsg(msg: TStatusMessages);
147begin
148 case msg of
149 SM_AlreadyOpened: ShowMessage('File already opened.');
150 SM_FileNotFound: ShowMessage('File not found.');
151 SM_UnknownExtension: ShowMessage('Unknown extension.');
152 SM_IncompatibleFile: ShowMessage('Incompatible file format.');
153 SM_UnknownError: ShowMessage('Unknown error.');
154 end;
155end;
156
157procedure TForm_Main.CreateConnection(filename: String);
158var
159 RepMsg: TStatusMessages;
160begin
[97]161 ConManager.OpenConnection(filename, RepMsg);
[93]162 ShowOpenMsg(RepMsg);
163 if RepMsg = SM_OK then
164 begin
165 UpdateStatBar;
[105]166 UpdateConLists;
[93]167 end;
168end;
169
[97]170function TForm_Main.CheckConnectionCloseable(index: Integer): Boolean;
171var
172 i: Integer;
173 toolform: TForm_ToolTemplate;
174begin
[113]175 Result := True;
[97]176 if MDITab.MDIChildCount > 0 then
177 begin
178 for i := 0 to MDITab.MDIChildCount - 1 do
179 begin
180 if MDITab.MDIChildren[i] is TForm_ToolTemplate then
181 begin
182 toolform := TForm_ToolTemplate(MDITab.MDIChildren[i]);
183 if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then
184 begin
185 if not toolform.Closeable then
[113]186 begin
187 ShowMessage('Can not close toolwindow: ' + toolform.Caption);
188 Result := False;
189 end;
[97]190 end;
191 end;
192 end;
193 end;
194end;
195
196
[93]197{ Eine zweite Instanz hat uns ihre Kommandozeilenparameter geschickt }
198procedure TForm_Main.WMCopyData(var Msg: TWMCopyData);
199var
200 strings: TStringList;
201begin
202 if (Msg.CopyDataStruct.dwData = SecondInstMsgId) and (SecondInstMsgId <> 0) then
203 begin
204 Application.BringToFront;
205
206 strings := TStringList.Create;
207 strings.Text := ParamBlobToStr(Msg.CopyDataStruct.lpData);
208 if strings.Count = 2 then
209 begin
210 if strings.Strings[0] = 'opf' then
211 begin
212 ShowMessage('Load OPF-File: ' + ParamStr(2));
213 end
214 else if (strings.Strings[0] = 'oldb') or (strings.Strings[0] = 'dat') then
215 begin
216 CreateConnection(strings.Strings[1]);
217 end;
218 end;
219 end
220 else
221 inherited;
222end;
223
224{----------------------------------------------------------------------------}
225{ Wir überschreiben den DefaultHandler, der alle Nachrichten zuerst bekommt, }
226{ damit wir auf die Nachricht mit der ID SecondInstMsgId reagieren können. }
227{ (Dies ist notwendig, da wir jetzt noch nicht wissen welchen Wert }
228{ die ID haben wird, weswegen wir keine statische Message-Prozedure, }
229{ so wie bei WM_COPYDATA, schreiben können.) }
230{----------------------------------------------------------------------------}
231procedure TForm_Main.DefaultHandler(var Message);
232begin
233 if TMessage(Message).Msg = SecondInstMsgId then
234 { Eine zweite Instanz hat uns nach dem Handle gefragt }
235 { Es wird in die Message-Queue des Threads gepostet. }
236 PostThreadMessage(TMessage(Message).WParam, SecondInstMsgId, Handle, 0)
237 else
238 inherited;
239end;
240
241
242
243procedure TForm_Main.FormCreate(Sender: TObject);
244begin
245 Self.Caption := 'Oni Un/Packer ' + version;
246 Self.FormResize(Self);
247
[97]248 ConManager.OnCoonnectionListChanged := UpdateConLists;
[93]249
250 if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
251 begin
252 AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) +
253 '\oniunpacker.ini');
254 Reset(AppSettingsFile);
255 Read(AppSettingsFile, AppSettings);
256 CloseFile(AppSettingsFile);
257 end
258 else
259 begin
260 AppSettings.DatPath := ExtractFilepath(Application.EXEname);
261 AppSettings.ExtractPath := ExtractFilepath(Application.EXEname) + '\extract';
262 AppSettings.CharSet := DEFAULT_CHARSET;
263 AppSettings.HideUnusedData := False;
264 end;
265
266 if MidStr(ParamStr(1), 1, 3) = 'opf' then
267 begin
268 ShowMessage('Load OPF-File: ' + ParamStr(2));
269 end
270 else if (MidStr(ParamStr(1), 1, 4) = 'oldb') or (MidStr(ParamStr(1), 1, 3) = 'dat') then
271 begin
272 CreateConnection(ParamStr(2));
273 end;
274 UpdateStatBar;
275end;
276
277
278
279
280procedure TForm_Main.FormResize(Sender: TObject);
281begin
282 statbar.Panels.Items[0].Width := Self.Width - 200;
283 MDITab.Width := Self.Width - 20;
284end;
285
286
287
288
289procedure TForm_Main.MDITabDrawTab(Control: TCustomTabControl;
290 TabIndex: Integer; const Rect: TRect; Active: Boolean);
291var
292 x, y: Integer;
293 iconindex: Integer;
294 caption: String;
295begin
296 iconindex := TMDITab(Control).Glyphs[TabIndex];
297 caption := TMDITab(Control).Captions[TabIndex];
298 if active then
299 begin
300 Control.Canvas.Font.Style := Control.Canvas.Font.Style + [fsItalic];
301 y := Rect.Top + 1;
302 end else
303 y := Rect.Top;
304 if iconindex >= 0 then
305 begin
306 TMDITab(Control).Images.Draw(Control.Canvas, Rect.Left + 4, y, iconindex);
307 x := Rect.Left + 26;
308 end else
309 x := Rect.Left + 4;
310 Control.Canvas.TextOut(x, y + 2, caption);
311 if active then
312 Images_Close.Draw(Control.Canvas, Rect.Right - 18, y, 0)
313 else
314 Images_Close.Draw(Control.Canvas, Rect.Right - 18, y, 1);
315end;
316
317
318procedure TForm_Main.MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
319 Y: Integer);
320var
321 pt: TPoint;
322 tabIndex: Integer;
323 hint: String;
[97]324 tool: TForm_ToolTemplate;
[93]325begin
326 pt.X := X;
327 pt.Y := Y;
328 tabIndex := MDITab.GetTabAtPos(pt);
329 hint := '';
330
331 if tabIndex >= 0 then
332 begin
333 if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then
334 begin
[97]335 tool := TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]);
336 if tool.ConnectionID > -1 then
[93]337 hint := 'Connection: ' +
[97]338 ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) + #13+#10
[93]339 else
340 hint := 'Connection: none' + #13+#10;
[97]341 if tool.SelectedFile.ID > -1 then
[93]342 hint := hint + 'Selected File: ' +
[97]343 FormatNumber(tool.SelectedFile.ID, 5, '0') + '-' +
344 tool.SelectedFile.Name + '.' +
345 tool.SelectedFile.Extension
[93]346 else
347 hint := hint + 'Selected File: none';
348 end
349 else
350 hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption;
351 if hint <> MDITab.Hint then
352 begin
353 MDITab.Hint := hint;
354 MDITab.ShowHint := True;
355 end;
356 end
357 else
358 begin
359 MDITab.ShowHint := False;
360 MDITab.Hint := '';
361 end;
362end;
363
364procedure TForm_Main.MDITabMouseUp(Sender: TObject; Button: TMouseButton;
365 Shift: TShiftState; X, Y: Integer);
366var
367 pt: TPoint;
368 tabIndex: Integer;
369 tabRect: TRect;
370 tabX, tabY, tabWidth: Integer;
371begin
372 pt.X := X;
373 pt.Y := Y;
374 tabIndex := MDITab.GetTabAtPos(pt);
375
376// if (Button = mbRight) and (tabIndex >= 0) then
377// MDITab.MDIChildren[tabIndex].Close;
378
379 if (Button = mbLeft) and (tabIndex >= 0) then
380 begin
381 tabrect := MDITab.TabRect(tabIndex);
382 tabX := X - tabrect.Left;
383 tabY := Y - tabrect.Top;
384 tabwidth := tabrect.Right - tabrect.Left;
385 if (tabY >= 4) and (tabY <= 17) then
386 if (tabX >= tabwidth - 19) and (tabX <= tabwidth - 7) then
387 MDITab.MDIChildren[tabIndex].Close;
388 end;
389end;
390
391
392
393
394procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
395begin
396 AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) + '\oniunpacker.ini');
397 if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
398 Reset(AppSettingsFile)
399 else
400 Rewrite(AppSettingsFile);
401 Write(AppSettingsFile, AppSettings);
402 CloseFile(AppSettingsFile);
403 Action := caFree;
404end;
405
406
407
408procedure TForm_Main.ActivateTools(active: Boolean);
409begin
410 menu_tools.Enabled := active;
411 tb_preview.Enabled := active;
412 tb_datedit.Enabled := active;
413 tb_rawedit.Enabled := active;
414 tb_txmpreplacer.Enabled := active;
415 tb_extractor.Enabled := active;
416// tb_compare.Enabled := active;
417// tb_structure.Enabled := active;
418end;
419
420procedure TForm_Main.UpdateStatBar;
421begin
[97]422 if ConManager.Count > 0 then
[93]423 begin
424 Self.Caption := 'Oni Un/Packer ' + version;
425 ActivateTools(True);
[97]426 statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(ConManager.Count);
[93]427 end
428 else
429 begin
430 Self.Caption := 'Oni Un/Packer ' + version;
431 statbar.Panels.Items[0].Text := '';
432 statbar.Panels.Items[1].Text := 'Connections: -';
433 statbar.Panels.Items[2].Text := '';
434 ActivateTools(False);
435 end;
[97]436 menu_conns.Enabled := ConManager.Count > 0;
[93]437end;
438
439
440
441
442procedure TForm_Main.ToolbarDockChanged(Sender: TObject);
443var
444 toolbar: TTBToolbar;
445 position: TTBDockPosition;
446 mode: TTBItemDisplayMode;
447 i: Integer;
448begin
449 toolbar := TTBToolbar(Sender);
450 if toolbar.Floating then
451 mode := nbdmImageAndText
452 else begin
453 position := toolbar.CurrentDock.Position;
454 if position in [dpLeft, dpRight] then
455 mode := nbdmDefault
456 else
457 mode := nbdmImageAndText;
458 end;
459 for i := 0 to toolbar.Items.Count - 1 do
460 toolbar.Items.Items[i].DisplayMode := mode;
461end;
462
463function TForm_Main.TryCloseAll: Boolean;
464begin
465 menu_windows_closeallClick(Self);
466 Application.ProcessMessages;
467 if MDITab.MDIChildCount = 0 then
468 Result := True
469 else
470 Result := False;
471end;
472
473
474procedure TForm_Main.UpdateConLists;
475var
476 i: Integer;
477 entry: TTBItem;
478begin
479 if MDITab.MDIChildCount > 0 then
480 for i := 0 to MDITab.MDIChildCount - 1 do
481 if MDITab.MDIChildren[i] is TForm_ToolTemplate then
482 TForm_ToolTemplate(MDITab.MDIChildren[i]).UpdateConList;
483
484 menu_conns.Clear;
[97]485 if ConManager.Count > 0 then
[93]486 begin
[97]487 for i := 0 to ConManager.Count - 1 do
[93]488 begin
489 entry := TTBItem.Create(menu_conns);
[97]490 entry.Caption := ExtractFileName(ConManager.ConnectionByIndex[i].FileName);
[93]491 entry.Name := 'menu_conn_' + IntToStr(i);
492 entry.OnClick := menu_conns_itemClick;
493 menu_conns.Add(entry);
494 entry := nil;
495 end;
496 end;
497end;
498
499
500procedure TForm_Main.LoadFile(typedb: Boolean);
501var
[105]502 i: Integer;
[93]503begin
504 opend.InitialDir := AppSettings.DatPath;
505 opend.Filter := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
506 if typedb then
507 opend.FilterIndex := 3
508 else
509 opend.FilterIndex := 2;
510 if opend.Execute then
511 begin
[105]512 if opend.Files.Count > 0 then
513 for i := 0 to opend.Files.Count - 1 do
514 CreateConnection(opend.Files.Strings[i]);
[93]515 AppSettings.DatPath := ExtractFilepath(opend.FileName);
516 end;
517 UpdateStatBar;
518end;
519
520
521 {#################################}
522 {##### Main-Menu-Handlers #####}
523 {#################################}
524procedure TForm_Main.menu_loaddbClick(Sender: TObject);
525begin
526 LoadFile(True);
527end;
528
529procedure TForm_Main.menu_loadfileClick(Sender: TObject);
530begin
531 LoadFile(False);
532end;
533
534
535procedure TForm_Main.menu_settingsClick(Sender: TObject);
536begin
537 Form_Settings.Visible := True;
538 Self.Enabled := False;
539end;
540
541
542procedure TForm_Main.menu_exitClick(Sender: TObject);
543begin
544 Self.Close;
545end;
546
547
548 {####################################}
549 {##### Converters-Menu-Handlers #####}
550 {####################################}
551procedure TForm_Main.menu_createdbClick(Sender: TObject);
552begin
553 ShowMessage('Not yet usable');
554{
555 opend.Filter := 'Oni-Dat-Files|*.dat';
556 saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
557 saved.DefaultExt := 'oldb';
558 if opend.Execute then
559 if saved.Execute then
560 Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
561}
562end;
563
564
565procedure TForm_Main.menu_createlvlClick(Sender: TObject);
566begin
[129]567// ShowMessage('Not yet usable');
568
[93]569 opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
570 saved.Filter := 'Oni-Dat-Files|*.dat';
571 saved.DefaultExt := 'dat';
572 if opend.Execute then
573 if saved.Execute then
574 Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
[129]575
[93]576end;
577
578
579 {#################################}
580 {##### Tools-Menu-Handlers #####}
581 {#################################}
582procedure TForm_Main.menu_previewClick(Sender: TObject);
583begin
[97]584 open_child('preview', -1, -1);
[93]585end;
586
587procedure TForm_Main.menu_bineditClick(Sender: TObject);
588begin
[97]589 open_child('binedit', -1, -1);
[93]590end;
591
592procedure TForm_Main.menu_raweditClick(Sender: TObject);
593begin
[97]594 open_child('rawedit', -1, -1);
[93]595end;
596
597procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
598begin
[97]599 open_child('txmpreplace', -1, -1);
[93]600end;
601
602procedure TForm_Main.menu_extractorClick(Sender: TObject);
603begin
[97]604 open_child('extractor', -1, -1);
[93]605end;
606
607procedure TForm_Main.menu_metaClick(Sender: TObject);
608begin
609 ShowMessage('TBD');
610end;
611
612procedure TForm_Main.menu_filecompareClick(Sender: TObject);
613begin
[97]614 open_child('compare', -1, -1);
[93]615end;
616
617
618 {#################################}
619 {##### View-Menu-Handlers #####}
620 {#################################}
621procedure TForm_Main.menu_windows_cascadeClick(Sender: TObject);
622begin
623 Self.Cascade;
624end;
625
626procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject);
627begin
628 Self.TileMode := tbVertical;
629 Self.Tile;
630end;
631
632procedure TForm_Main.menu_windows_tileClick(Sender: TObject);
633begin
634 Self.TileMode := tbHorizontal;
635 Self.Tile;
636end;
637
638procedure TForm_Main.menu_windows_closeallClick(Sender: TObject);
639begin
640 MDITab.CloseAll;
641end;
642
643procedure TForm_Main.menu_windows_nextClick(Sender: TObject);
644begin
645 if MDIChildCount > 1 then
646 if MDITab.TabIndex = MDITab.MDIChildCount - 1 then
647 MDITab.MDIChildren[0].BringToFront
648 else
649 MDITab.MDIChildren[MDITab.TabIndex + 1].BringToFront;
650end;
651
652procedure TForm_Main.menu_windows_previousClick(Sender: TObject);
653begin
654 if MDIChildCount > 1 then
655 if MDITab.TabIndex = 0 then
656 MDITab.MDIChildren[MDITab.MDIChildCount - 1].BringToFront
657 else
658 MDITab.MDIChildren[MDITab.TabIndex - 1].BringToFront;
659end;
660
661
662 {##################################}
663 {##### Windows-Menu-Handlers #####}
664 {##################################}
665procedure TForm_Main.menu_windows_itemClick(Sender: TObject);
666var
667 name: String;
668begin
669 name := TTBItem(Sender).Name;
670end;
671
672
673
674 {######################################}
675 {##### Connections-Menu-Handlers #####}
676 {######################################}
677procedure TForm_Main.menu_conns_itemClick(Sender: TObject);
678var
679 name: String;
[97]680 index: Integer;
681 RepMsg: TStatusMessages;
[93]682begin
[97]683// name := TTBItem(Sender).Caption;
684 index := TTBItem(Sender).Parent.IndexOf(TTBItem(Sender));
685 name := ExtractFileName(ConManager.ConnectionByIndex[index].FileName);
[93]686 if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+
687 name + '?'), PChar('Close?'), MB_YESNO + MB_ICONQUESTION) = ID_YES then
688 begin
[97]689 CheckConnectionCloseable(index);
690 ConManager.CloseConnectionByIndex(index, RepMsg);
[105]691 ShowOpenMsg(RepMsg);
692 UpdateConLists;
[93]693 end;
694 UpdateStatBar;
695end;
696
697
698 {###################################}
699 {##### Toolbars-Menu-Handlers #####}
700 {###################################}
701procedure TForm_Main.menu_view_toolbarClick(Sender: TObject);
702begin
703 menu_view_toolbar.Checked := not menu_view_toolbar.Checked;
704 Toolbar.Visible := menu_view_toolbar.Checked;
705end;
706
707procedure TForm_Main.menu_view_statusbarClick(Sender: TObject);
708begin
709 menu_view_statusbar.Checked := not menu_view_statusbar.Checked;
710 statbar.Visible := menu_view_statusbar.Checked;
711end;
712
713procedure TForm_Main.menu_view_mdibarClick(Sender: TObject);
714begin
715 menu_view_mdibar.Checked := not menu_view_mdibar.Checked;
716 mditoolbar.Visible := menu_view_mdibar.Checked;
717end;
718
719
720
721procedure TForm_Main.menu_AboutClick(Sender: TObject);
722begin
723 ShowMessage('Will be implemented later ;)');
724end;
725
726
727
728
729
730function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
731var
732 toolform: TForm_ToolTemplate;
733 i: Integer;
734 tag: Integer;
735 caption_end: String;
736 iconindex: Integer;
737begin
738 Result := nil;
739
740 tag := 1;
741 if MDIChildCount > 0 then
742 for i := 0 to MDIChildCount - 1 do
743 if MDIChildren[i].Tag >= tag then
744 tag := MDIChildren[i].Tag + 1;
745
746 iconindex := -1;
747 caption_end := IntToStr(tag) + ' ';
748
[113]749 toolform := nil;
750
[93]751 if window_context = 'binedit' then
752 begin
[105]753 toolform := TForm_BinEdit.Create(Self);
[93]754 toolform.Caption := 'Binary .dat-Editor ' + caption_end;
755 iconindex := 5;
756 end;
757 if window_context = 'extractor' then
758 begin
[105]759 toolform := TForm_Extractor.Create(Self);
[93]760 toolform.Caption := 'Extractor ' + caption_end;
761 iconindex := 8;
762 end;
763 if window_context = 'preview' then
764 begin
765 toolform := TForm_Preview.Create(Self);
766 toolform.Caption := 'Preview-Window ' + caption_end;
767 iconindex := 4;
768 end;
769 if window_context = 'rawedit' then
770 begin
[105]771 toolform := TForm_RawEdit.Create(Self);
[93]772 toolform.Caption := 'Binary .raw-Editor ' + caption_end;
773 iconindex := 6;
774 end;
775 if window_context = 'txmpreplace' then
776 begin
[105]777 toolform := TForm_TxmpReplace.Create(Self);
[93]778 toolform.Caption := 'TXMP Replacer ' + caption_end;
779 iconindex := 7;
780 end;
781
782 if Assigned(toolform) then
783 begin
784 toolform.Name := window_context + IntToStr(tag);
785 toolform.Tag := tag;
786 MDITab.AddTab(TForm(toolform), iconindex);
787 toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', '');
[97]788 if connection > -1 then
[93]789 begin
[97]790 toolform.SelectConnection(connection);
791 if fileid > -1 then
792 toolform.SelectFileID(connection, fileid);
[93]793 end;
794 Result := toolform;
795 end;
796end;
797
798end.
Note: See TracBrowser for help on using the repository browser.