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

Comparing oup/current/Main.pas (file contents):
Revision 112 by alloc, Thu Feb 22 00:37:39 2007 UTC vs.
Revision 172 by alloc, Sun Apr 8 23:52:14 2007 UTC

# Line 137 | Line 137 | var
137  
138   implementation
139  
140 + uses
141 +  LevelDB;
142 +
143   {$R *.dfm}
144  
145  
# Line 169 | Line 172 | var
172    i: Integer;
173    toolform: TForm_ToolTemplate;
174   begin
175 +  Result := True;
176    if MDITab.MDIChildCount > 0 then
177    begin
178      for i := 0 to MDITab.MDIChildCount - 1 do
# Line 179 | Line 183 | begin
183          if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then
184          begin
185            if not toolform.Closeable then
186 <            ShowMessage('Can not close toolwindow: ' + toolform.Caption);
186 >          begin
187 >            ShowMessage('Can not close toolwindow: ' + toolform.Caption);
188 >            Result := False;
189 >          end;
190          end;
191        end;
192      end;
# Line 234 | Line 241 | end;
241  
242  
243   procedure TForm_Main.FormCreate(Sender: TObject);
237 var
238  RepMsg: TStatusMessages;
244   begin
245    Self.Caption := 'Oni Un/Packer ' + version;
246    Self.FormResize(Self);
# Line 440 | Line 445 | var
445    position: TTBDockPosition;
446    mode: TTBItemDisplayMode;
447    i: Integer;
443  isEnabled: Boolean;
448   begin
449    toolbar := TTBToolbar(Sender);
450    if toolbar.Floating then
# Line 546 | Line 550 | end;
550   {####################################}
551   procedure TForm_Main.menu_createdbClick(Sender: TObject);
552   begin
553 <  ShowMessage('Not yet usable');
554 < {
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);
557 }
561   end;
562  
563  
564   procedure TForm_Main.menu_createlvlClick(Sender: TObject);
565   begin
566 <  ShowMessage('Not yet usable');
567 < {
566 > //  ShowMessage('Not yet usable');
567 >
568    opend.Filter     := 'OUP-Level-DB (*.oldb)|*.oldb';
569    saved.Filter     := 'Oni-Dat-Files|*.dat';
570    saved.DefaultExt := 'dat';
571    if opend.Execute then
572      if saved.Execute then
573        Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
571 }
574   end;
575  
576  
# Line 673 | Line 675 | end;
675   procedure TForm_Main.menu_conns_itemClick(Sender: TObject);
676   var
677    name: String;
676  i: Integer;
678    index: Integer;
679    RepMsg: TStatusMessages;
680   begin
# Line 725 | Line 726 | end;
726  
727  
728   function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
729 + type
730 +  TTemplate = class of TForm_ToolTemplate;
731 +  TTool = record
732 +      name: String;
733 +      icon: Integer;
734 +      caption: String;
735 +      classt: TTemplate;
736 +  end;
737 + const
738 +  Tools: array[0..4] of TTool = (
739 +    (name: 'binedit';     icon: 5; caption: 'Binary .dat-Editor'; classt: TForm_BinEdit),
740 +    (name: 'extractor';   icon: 8; caption: 'Extractor';          classt: TForm_Extractor),
741 +    (name: 'preview';     icon: 4; caption: 'Preview-Window';     classt: TForm_Preview),
742 +    (name: 'rawedit';     icon: 6; caption: 'Binary .raw-Editor'; classt: TForm_RawEdit),
743 +    (name: 'txmpreplace'; icon: 7; caption: 'TXMP Replacer';      classt: TForm_TxmpReplace)
744 +  );
745   var
746    toolform:    TForm_ToolTemplate;
747    i:           Integer;
748    tag:         Integer;
732  caption_end: String;
749    iconindex:   Integer;
750   begin
751    Result := nil;
# Line 741 | Line 757 | begin
757          tag := MDIChildren[i].Tag + 1;
758  
759    iconindex := -1;
744  caption_end := IntToStr(tag) + '       ';
760  
761 <  if window_context = 'binedit' then
762 <  begin
763 <    toolform         := TForm_BinEdit.Create(Self);
764 <    toolform.Caption := 'Binary .dat-Editor ' + caption_end;
765 <    iconindex        := 5;
766 <  end;
767 <  if window_context = 'extractor' then
768 <  begin
769 <    toolform         := TForm_Extractor.Create(Self);
770 <    toolform.Caption := 'Extractor ' + caption_end;
771 <    iconindex        := 8;
772 <  end;
758 <  if window_context = 'preview' then
759 <  begin
760 <    toolform         := TForm_Preview.Create(Self);
761 <    toolform.Caption := 'Preview-Window ' + caption_end;
762 <    iconindex        := 4;
763 <  end;
764 <  if window_context = 'rawedit' then
765 <  begin
766 <    toolform         := TForm_RawEdit.Create(Self);
767 <    toolform.Caption := 'Binary .raw-Editor ' + caption_end;
768 <    iconindex        := 6;
769 <  end;
770 <  if window_context = 'txmpreplace' then
771 <  begin
772 <    toolform         := TForm_TxmpReplace.Create(Self);
773 <    toolform.Caption := 'TXMP Replacer ' + caption_end;
774 <    iconindex        := 7;
761 >  toolform := nil;
762 >
763 >  for i := 0 to High(Tools) do
764 >    if Tools[i].name = window_context then
765 >      Break;
766 >  if i < Length(Tools) then
767 >  begin
768 >    toolform         := TTemplate(Tools[i].classt).Create(Self);
769 >    toolform.Caption := Tools[i].caption + ' ' + IntToStr(tag) + '       ';
770 >    iconindex        := Tools[i].icon;
771 >  end else begin
772 >    ShowMessage('WindowContext not found!');
773    end;
774  
775    if Assigned(toolform) then

Diff Legend

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