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.
oup/releases/0.33a/Main.pas (file contents), Revision 76 by alloc, Thu Jan 11 23:38:49 2007 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 +    menu_loaddb: TTBItem;
75 +    tb_opendb: TTBItem;
76 +    procedure LoadFile(typedb: Boolean);
77      function TryCloseAll: Boolean;
78      procedure menu_AboutClick(Sender: TObject);
79      procedure menu_settingsClick(Sender: TObject);
# Line 76 | Line 85 | type
85      procedure menu_windows_previousClick(Sender: TObject);
86      procedure menu_windows_nextClick(Sender: TObject);
87      procedure menu_windows_tileClick(Sender: TObject);
88 <    function open_child(window_context: String): Boolean;
88 >    function open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
89      procedure menu_windows_closeallClick(Sender: TObject);
90      procedure menu_windows_cascadeClick(Sender: TObject);
91      procedure menu_bineditClick(Sender: TObject);
# Line 96 | Line 105 | type
105      procedure ActivateTools(active: Boolean);
106      procedure MDITabMouseUp(Sender: TObject; Button: TMouseButton;
107        Shift: TShiftState; X, Y: Integer);
108 +    procedure menu_windows_tilevertClick(Sender: TObject);
109 +    procedure menu_metaClick(Sender: TObject);
110 +    procedure ToolbarDockChanged(Sender: TObject);
111 +    procedure menu_loaddbClick(Sender: TObject);
112    private
113    public
114    end;
# Line 277 | Line 290 | end;
290  
291  
292  
293 + procedure TForm_Main.ToolbarDockChanged(Sender: TObject);
294 + var
295 +  toolbar: TTBToolbar;
296 +  position: TTBDockPosition;
297 +  mode: TTBItemDisplayMode;
298 +  i: Integer;
299 +  isEnabled: Boolean;
300 + begin
301 +  toolbar := TTBToolbar(Sender);
302 +  if toolbar.Floating then
303 +    mode := nbdmImageAndText
304 +  else begin
305 +    position := toolbar.CurrentDock.Position;
306 +    if position in [dpLeft, dpRight] then
307 +      mode := nbdmDefault
308 +    else
309 +      mode := nbdmImageAndText;
310 +  end;
311 +  for i := 0 to toolbar.Items.Count - 1 do
312 +    toolbar.Items.Items[i].DisplayMode := mode;
313 + end;
314 +
315   function TForm_Main.TryCloseAll: Boolean;
316   begin
317    menu_windows_closeallClick(Self);
# Line 288 | Line 323 | begin
323   end;
324  
325  
326 < {#################################}
327 < {##### Main-Menu-Handlers    #####}
293 < {#################################}
294 < procedure TForm_Main.menu_loadfileClick(Sender: TObject);
326 >
327 > procedure TForm_Main.LoadFile(typedb: Boolean);
328   var
329    ext: String;
330   begin
# Line 300 | Line 333 | begin
333      CloseDataConnection;
334      opend.InitialDir := AppSettings.DatPath;
335      opend.Filter     := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
336 +    if typedb then
337 +      opend.FilterIndex := 3
338 +    else
339 +      opend.FilterIndex := 2;
340      if opend.Execute then
341      begin
342        ext := ExtractFileExt(opend.FileName);
343        if ext = '.dat' then
344 +      begin
345          if not CreateDataConnection(opend.FileName, ODB_Dat) then
346            ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
347 <            CrLf + 'Perhaps not an Oni-.dat-file?')
348 <      else if ext = '.oldb' then
347 >            CrLf + 'Perhaps not an Oni-.dat-file?');
348 >      end else if ext = '.oldb' then
349 >      begin
350          if not CreateDataConnection(opend.FileName, ODB_ADB) then
351            ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
352 <            CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?')
353 <      else
352 >            CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
353 >      end else
354          ShowMessage('Incompatible file');
355        AppSettings.DatPath := ExtractFilepath(opend.FileName);
356      end;
# Line 320 | Line 359 | begin
359   end;
360  
361  
362 + {#################################}
363 + {##### Main-Menu-Handlers    #####}
364 + {#################################}
365 + procedure TForm_Main.menu_loaddbClick(Sender: TObject);
366 + begin
367 +  LoadFile(True);
368 + end;
369 +
370 + procedure TForm_Main.menu_loadfileClick(Sender: TObject);
371 + begin
372 +  LoadFile(False);
373 + end;
374 +
375 +
376  
377  
378   procedure TForm_Main.menu_settingsClick(Sender: TObject);
# Line 393 | Line 446 | end;
446   {#################################}
447   procedure TForm_Main.menu_previewClick(Sender: TObject);
448   begin
449 <  open_child('preview');
449 >  open_child('preview', -1);
450   end;
451  
452  
453   procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
454   begin
455 <  open_child('txmpreplace');
455 >  open_child('txmpreplace', -1);
456   end;
457  
458  
459   procedure TForm_Main.menu_bineditClick(Sender: TObject);
460   begin
461 <  open_child('binedit');
461 >  open_child('binedit', -1);
462   end;
463  
464  
465   procedure TForm_Main.menu_raweditClick(Sender: TObject);
466   begin
467 <  open_child('rawedit');
467 >  open_child('rawedit', -1);
468   end;
469  
470  
471   procedure TForm_Main.menu_extractorClick(Sender: TObject);
472   begin
473 <  open_child('extractor');
473 >  open_child('extractor', -1);
474 > end;
475 >
476 >
477 > procedure TForm_Main.menu_metaClick(Sender: TObject);
478 > begin
479 >  ShowMessage('TBD');
480   end;
481  
482  
483   procedure TForm_Main.menu_filecompareClick(Sender: TObject);
484   begin
485 <  open_child('compare');
485 >  open_child('compare', -1);
486   end;
487  
488  
# Line 472 | Line 531 | begin
531    Self.Tile;
532   end;
533  
534 + procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject);
535 + begin
536 +  Self.TileMode := tbVertical;
537 +  Self.Tile;
538 + end;
539  
540  
541   procedure TForm_Main.menu_windows_closeallClick(Sender: TObject);
# Line 514 | Line 578 | end;
578  
579  
580  
581 < function TForm_Main.open_child(window_context: String): Boolean;
581 > function TForm_Main.open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
582   var
583 <  form:    TCustomForm;
583 >  toolform: TForm_ToolTemplate;
584    i:       Integer;
585    tag:     Integer;
586    iconindex: Integer;
587   begin
588 <  Result := True;
588 >  Result := nil;
589  
590    tag := 1;
591    if MDIChildCount > 0 then
# Line 533 | Line 597 | begin
597  
598    if window_context = 'binedit' then
599    begin
600 <    form      := TForm_BinEdit.Create(Application);
601 <    TForm_BinEdit(form).Recreatelist;
602 <    form.Caption := 'Binary .dat-Editor ' + IntToStr(tag);
539 <    iconindex := 0;
600 >    toolform         := TForm_BinEdit.Create(Self);
601 >    toolform.Caption := 'Binary .dat-Editor ' + IntToStr(tag);
602 >    iconindex        := 5;
603    end;
604 <  if window_context = 'rawedit' then
604 >  if window_context = 'extractor' then
605    begin
606 <    form      := TForm_RawEdit.Create(Application);
607 <    TForm_RawEdit(form).Recreatelist;
608 <    form.Caption := 'Binary .raw-Editor ' + IntToStr(tag);
606 >    toolform         := TForm_Extractor.Create(Self);
607 >    toolform.Caption := 'Extractor ' + IntToStr(tag);
608 >    iconindex        := 8;
609    end;
610    if window_context = 'preview' then
611    begin
612 <    form      := TForm_Preview.Create(Application);
613 <    TForm_Preview(form).Recreatelist;
614 <    form.Caption := 'Preview-Window ' + IntToStr(tag);
612 >    toolform         := TForm_Preview.Create(Self);
613 >    toolform.Caption := 'Preview-Window ' + IntToStr(tag);
614 >    iconindex        := 4;
615    end;
616 <  if window_context = 'txmpreplace' then
616 >  if window_context = 'rawedit' then
617    begin
618 <    form      := TForm_TxmpReplace.Create(Application);
619 <    TForm_TxmpReplace(form).Recreatelist;
620 <    form.Caption := 'TXMP Replacer ' + IntToStr(tag);
618 >    toolform         := TForm_RawEdit.Create(Self);
619 >    toolform.Caption := 'Binary .raw-Editor ' + IntToStr(tag);
620 >    iconindex        := 6;
621    end;
622 <  if window_context = 'extractor' then
622 >  if window_context = 'txmpreplace' then
623    begin
624 <    form      := TForm_Extractor.Create(Application);
625 <    TForm_Extractor(form).Recreatelist;
626 <    form.Caption := 'Extractor ' + IntToStr(tag);
624 >    toolform         := TForm_TxmpReplace.Create(Application);
625 >    toolform.Caption := 'TXMP Replacer ' + IntToStr(tag);
626 >    iconindex        := 7;
627    end;
628  
629 <  form.Name := window_context + IntToStr(tag);
630 <  form.Tag  := tag;
631 <
632 <  MDITab.AddTab(TForm(form), iconindex);
629 >  if Assigned(toolform) then
630 >  begin
631 >    toolform.Name    := window_context + IntToStr(tag);
632 >    toolform.Tag     := tag;
633 >    MDITab.AddTab(TForm(toolform), iconindex);
634 >    if fileid > -1 then
635 >      toolform.SelectFileID(fileid);
636 >    Result := toolform;
637 >  end;
638   end;
639  
640   end.

Diff Legend

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