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 197 by alloc, Sat May 26 18:42:15 2007 UTC

# Line 6 | Line 6 | uses
6    MPHexEditor, ToolWin, ImgList, Tabs,
7    MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst,
8    Data, TypeDefs, ConnectionManager,
9 < //  Functions, Exporters, DataStructures,
10 <  Functions,
11 <  Settings, {Helper_LevelDB, }
12 <  Template,
9 >  Functions, Settings, Template,
10    RawEdit, BinEdit, Extractor, Preview, TxmpReplace;
11  
12   type
# Line 137 | Line 134 | var
134  
135   implementation
136  
137 + uses
138 +  LevelDB;
139 +
140   {$R *.dfm}
141  
142  
# Line 169 | Line 169 | var
169    i: Integer;
170    toolform: TForm_ToolTemplate;
171   begin
172 +  Result := True;
173    if MDITab.MDIChildCount > 0 then
174    begin
175      for i := 0 to MDITab.MDIChildCount - 1 do
# Line 179 | Line 180 | begin
180          if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then
181          begin
182            if not toolform.Closeable then
183 <            ShowMessage('Can not close toolwindow: ' + toolform.Caption);
183 >          begin
184 >            ShowMessage('Can not close toolwindow: ' + toolform.Caption);
185 >            Result := False;
186 >          end;
187          end;
188        end;
189      end;
# Line 234 | Line 238 | end;
238  
239  
240   procedure TForm_Main.FormCreate(Sender: TObject);
237 var
238  RepMsg: TStatusMessages;
241   begin
242    Self.Caption := 'Oni Un/Packer ' + version;
243    Self.FormResize(Self);
# Line 252 | Line 254 | begin
254    end
255    else
256    begin
257 +    ShowMessage('Warning!' + #13#10 +
258 +                'It seems like this is the first time you OUP.' + #13#10 +
259 +                'I do not take any responsibility for messed up data files' + #13+#10 +
260 +                'Do not forget to make backup copies of your *.dat/*.raw/*.sep files!');
261      AppSettings.DatPath        := ExtractFilepath(Application.EXEname);
262      AppSettings.ExtractPath    := ExtractFilepath(Application.EXEname) + '\extract';
263      AppSettings.CharSet        := DEFAULT_CHARSET;
# Line 440 | Line 446 | var
446    position: TTBDockPosition;
447    mode: TTBItemDisplayMode;
448    i: Integer;
443  isEnabled: Boolean;
449   begin
450    toolbar := TTBToolbar(Sender);
451    if toolbar.Floating then
# Line 546 | Line 551 | end;
551   {####################################}
552   procedure TForm_Main.menu_createdbClick(Sender: TObject);
553   begin
554 <  ShowMessage('Not yet usable');
555 < {
554 > //  ShowMessage('Not yet usable');
555 >
556    opend.Filter     := 'Oni-Dat-Files|*.dat';
557    saved.Filter     := 'OUP-Level-DB (*.oldb)|*.oldb';
558    saved.DefaultExt := 'oldb';
559    if opend.Execute then
560      if saved.Execute then
561        Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
557 }
562   end;
563  
564  
565   procedure TForm_Main.menu_createlvlClick(Sender: TObject);
566   begin
567 <  ShowMessage('Not yet usable');
568 < {
567 > //  ShowMessage('Not yet usable');
568 >
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);
571 }
575   end;
576  
577  
# Line 673 | Line 676 | end;
676   procedure TForm_Main.menu_conns_itemClick(Sender: TObject);
677   var
678    name: String;
676  i: Integer;
679    index: Integer;
680    RepMsg: TStatusMessages;
681   begin
# Line 725 | Line 727 | end;
727  
728  
729   function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
730 + type
731 +  TTemplate = class of TForm_ToolTemplate;
732 +  TTool = record
733 +      name: String;
734 +      icon: Integer;
735 +      caption: String;
736 +      classt: TTemplate;
737 +  end;
738 + const
739 +  Tools: array[0..4] of TTool = (
740 +    (name: 'binedit';     icon: 5; caption: 'Binary .dat-Editor'; classt: TForm_BinEdit),
741 +    (name: 'extractor';   icon: 8; caption: 'Extractor';          classt: TForm_Extractor),
742 +    (name: 'preview';     icon: 4; caption: 'Preview-Window';     classt: TForm_Preview),
743 +    (name: 'rawedit';     icon: 6; caption: 'Binary .raw-Editor'; classt: TForm_RawEdit),
744 +    (name: 'txmpreplace'; icon: 7; caption: 'TXMP Replacer';      classt: TForm_TxmpReplace)
745 +  );
746   var
747    toolform:    TForm_ToolTemplate;
748    i:           Integer;
749    tag:         Integer;
732  caption_end: String;
750    iconindex:   Integer;
751   begin
752    Result := nil;
# Line 741 | Line 758 | begin
758          tag := MDIChildren[i].Tag + 1;
759  
760    iconindex := -1;
744  caption_end := IntToStr(tag) + '       ';
761  
762 <  if window_context = 'binedit' then
763 <  begin
764 <    toolform         := TForm_BinEdit.Create(Self);
765 <    toolform.Caption := 'Binary .dat-Editor ' + caption_end;
766 <    iconindex        := 5;
767 <  end;
768 <  if window_context = 'extractor' then
769 <  begin
770 <    toolform         := TForm_Extractor.Create(Self);
771 <    toolform.Caption := 'Extractor ' + caption_end;
772 <    iconindex        := 8;
773 <  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;
762 >  toolform := nil;
763 >
764 >  for i := 0 to High(Tools) do
765 >    if Tools[i].name = window_context then
766 >      Break;
767 >  if i < Length(Tools) then
768 >  begin
769 >    toolform         := TTemplate(Tools[i].classt).Create(Self);
770 >    toolform.Caption := Tools[i].caption + ' ' + IntToStr(tag) + '       ';
771 >    iconindex        := Tools[i].icon;
772 >  end else begin
773 >    ShowMessage('WindowContext not found!');
774    end;
775  
776    if Assigned(toolform) then

Diff Legend

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