ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/releases/0.33a/Main.pas
(Generate patch)

Comparing oup/current/Main.pas (file contents):
Revision 43 by alloc, Mon Dec 18 23:35:30 2006 UTC vs.
Revision 51 by alloc, Sat Dec 23 22:16:42 2006 UTC

# Line 6 | Line 6 | uses
6    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7    Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids,
8    MPHexEditor, ToolWin, ImgList, Tabs,
9 <  Code_Functions, Data, Code_DataStructures,
10 <  Helper_LevelDB, Code_Exporters, Settings,
11 <  Tool_Preview, Tool_TxmpReplace, Tool_BinEdit, Tool_Extractor, Tool_RawEdit,
12 <  Code_OniDataClass, MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI;
9 >  MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI,
10 >  Data, Functions, DataStructures, OniDataClass, Exporters,
11 >  Helper_LevelDB, Settings, Template,
12 >  BinEdit, Extractor, Preview, RawEdit, TxmpReplace;
13  
14   type
15    TForm_Main = class(TForm)
# Line 65 | Line 65 | type
65      tb_txmpreplacer: TTBItem;
66      tb_rawedit: TTBItem;
67      tb_datedit: TTBItem;
68 +    menu_windows_tilevert: TTBItem;
69 +    tb_meta: TTBItem;
70 +    menu_meta: TTBItem;
71 +    TBSeparatorItem1: TTBSeparatorItem;
72 +    tb_db2dat: TTBItem;
73 +    tb_dat2db: TTBItem;
74      function TryCloseAll: Boolean;
75      procedure menu_AboutClick(Sender: TObject);
76      procedure menu_settingsClick(Sender: TObject);
# Line 76 | Line 82 | type
82      procedure menu_windows_previousClick(Sender: TObject);
83      procedure menu_windows_nextClick(Sender: TObject);
84      procedure menu_windows_tileClick(Sender: TObject);
85 <    function open_child(window_context: String): Boolean;
85 >    function open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
86      procedure menu_windows_closeallClick(Sender: TObject);
87      procedure menu_windows_cascadeClick(Sender: TObject);
88      procedure menu_bineditClick(Sender: TObject);
# Line 96 | Line 102 | type
102      procedure ActivateTools(active: Boolean);
103      procedure MDITabMouseUp(Sender: TObject; Button: TMouseButton;
104        Shift: TShiftState; X, Y: Integer);
105 +    procedure menu_windows_tilevertClick(Sender: TObject);
106 +    procedure menu_metaClick(Sender: TObject);
107 +    procedure ToolbarDockChanged(Sender: TObject);
108    private
109    public
110    end;
# Line 277 | Line 286 | end;
286  
287  
288  
289 + procedure TForm_Main.ToolbarDockChanged(Sender: TObject);
290 + var
291 +  toolbar: TTBToolbar;
292 +  position: TTBDockPosition;
293 +  mode: TTBItemDisplayMode;
294 +  i: Integer;
295 +  isEnabled: Boolean;
296 + begin
297 +  toolbar := TTBToolbar(Sender);
298 +  if toolbar.Floating then
299 +    mode := nbdmImageAndText
300 +  else begin
301 +    position := toolbar.CurrentDock.Position;
302 +    if position in [dpLeft, dpRight] then
303 +      mode := nbdmDefault
304 +    else
305 +      mode := nbdmImageAndText;
306 +  end;
307 +  for i := 0 to toolbar.Items.Count - 1 do
308 +    toolbar.Items.Items[i].DisplayMode := mode;
309 + end;
310 +
311   function TForm_Main.TryCloseAll: Boolean;
312   begin
313    menu_windows_closeallClick(Self);
# Line 304 | Line 335 | begin
335      begin
336        ext := ExtractFileExt(opend.FileName);
337        if ext = '.dat' then
338 +      begin
339          if not CreateDataConnection(opend.FileName, ODB_Dat) then
340            ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
341 <            CrLf + 'Perhaps not an Oni-.dat-file?')
342 <      else if ext = '.oldb' then
341 >            CrLf + 'Perhaps not an Oni-.dat-file?');
342 >      end else if ext = '.oldb' then
343 >      begin
344          if not CreateDataConnection(opend.FileName, ODB_ADB) then
345            ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
346 <            CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?')
347 <      else
346 >            CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
347 >      end else
348          ShowMessage('Incompatible file');
349        AppSettings.DatPath := ExtractFilepath(opend.FileName);
350      end;
# Line 393 | Line 426 | end;
426   {#################################}
427   procedure TForm_Main.menu_previewClick(Sender: TObject);
428   begin
429 <  open_child('preview');
429 >  open_child('preview', -1);
430   end;
431  
432  
433   procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
434   begin
435 <  open_child('txmpreplace');
435 >  open_child('txmpreplace', -1);
436   end;
437  
438  
439   procedure TForm_Main.menu_bineditClick(Sender: TObject);
440   begin
441 <  open_child('binedit');
441 >  open_child('binedit', -1);
442   end;
443  
444  
445   procedure TForm_Main.menu_raweditClick(Sender: TObject);
446   begin
447 <  open_child('rawedit');
447 >  open_child('rawedit', -1);
448   end;
449  
450  
451   procedure TForm_Main.menu_extractorClick(Sender: TObject);
452   begin
453 <  open_child('extractor');
453 >  open_child('extractor', -1);
454 > end;
455 >
456 >
457 > procedure TForm_Main.menu_metaClick(Sender: TObject);
458 > begin
459 >  ShowMessage('TBD');
460   end;
461  
462  
463   procedure TForm_Main.menu_filecompareClick(Sender: TObject);
464   begin
465 <  open_child('compare');
465 >  open_child('compare', -1);
466   end;
467  
468  
# Line 472 | Line 511 | begin
511    Self.Tile;
512   end;
513  
514 + procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject);
515 + begin
516 +  Self.TileMode := tbVertical;
517 +  Self.Tile;
518 + end;
519  
520  
521   procedure TForm_Main.menu_windows_closeallClick(Sender: TObject);
# Line 514 | Line 558 | end;
558  
559  
560  
561 < function TForm_Main.open_child(window_context: String): Boolean;
561 > function TForm_Main.open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
562   var
563 <  form:    TCustomForm;
563 >  toolform: TForm_ToolTemplate;
564    i:       Integer;
565    tag:     Integer;
566    iconindex: Integer;
567   begin
568 <  Result := True;
568 >  Result := nil;
569  
570    tag := 1;
571    if MDIChildCount > 0 then
# Line 533 | Line 577 | begin
577  
578    if window_context = 'binedit' then
579    begin
580 <    form      := TForm_BinEdit.Create(Application);
581 <    TForm_BinEdit(form).Recreatelist;
582 <    form.Caption := 'Binary .dat-Editor ' + IntToStr(tag);
539 <    iconindex := 0;
580 >    toolform         := TForm_BinEdit.Create(Self);
581 >    toolform.Caption := 'Binary .dat-Editor ' + IntToStr(tag);
582 >    iconindex        := 4;
583    end;
584 <  if window_context = 'rawedit' then
584 >  if window_context = 'extractor' then
585    begin
586 <    form      := TForm_RawEdit.Create(Application);
587 <    TForm_RawEdit(form).Recreatelist;
588 <    form.Caption := 'Binary .raw-Editor ' + IntToStr(tag);
586 >    toolform         := TForm_Extractor.Create(Self);
587 >    toolform.Caption := 'Extractor ' + IntToStr(tag);
588 >    iconindex        := 7;
589    end;
590    if window_context = 'preview' then
591    begin
592 <    form      := TForm_Preview.Create(Application);
593 <    TForm_Preview(form).Recreatelist;
594 <    form.Caption := 'Preview-Window ' + IntToStr(tag);
592 >    toolform         := TForm_Preview.Create(Self);
593 >    toolform.Caption := 'Preview-Window ' + IntToStr(tag);
594 >    iconindex        := 3;
595    end;
596 <  if window_context = 'txmpreplace' then
596 >  if window_context = 'rawedit' then
597    begin
598 <    form      := TForm_TxmpReplace.Create(Application);
599 <    TForm_TxmpReplace(form).Recreatelist;
600 <    form.Caption := 'TXMP Replacer ' + IntToStr(tag);
598 >    toolform         := TForm_RawEdit.Create(Self);
599 >    toolform.Caption := 'Binary .raw-Editor ' + IntToStr(tag);
600 >    iconindex        := 5;
601    end;
602 <  if window_context = 'extractor' then
602 >  if window_context = 'txmpreplace' then
603    begin
604 <    form      := TForm_Extractor.Create(Application);
605 <    TForm_Extractor(form).Recreatelist;
606 <    form.Caption := 'Extractor ' + IntToStr(tag);
604 >    toolform         := TForm_TxmpReplace.Create(Application);
605 >    toolform.Caption := 'TXMP Replacer ' + IntToStr(tag);
606 >    iconindex        := 6;
607    end;
608  
609 <  form.Name := window_context + IntToStr(tag);
610 <  form.Tag  := tag;
611 <
612 <  MDITab.AddTab(TForm(form), iconindex);
609 >  if Assigned(toolform) then
610 >  begin
611 >    toolform.Name    := window_context + IntToStr(tag);
612 >    toolform.Tag     := tag;
613 >    MDITab.AddTab(TForm(toolform), iconindex);
614 >    if fileid > -1 then
615 >      toolform.SelectFileID(fileid);
616 >    Result := toolform;
617 >  end;
618   end;
619  
620   end.

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)