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

Comparing:
oup/rewrite/Main.pas (file contents), Revision 97 by alloc, Mon Jan 22 23:05:45 2007 UTC vs.
oup/current/Main.pas (file contents), 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,
13 <  Preview;
14 < //  BinEdit, Extractor, RawEdit, TxmpReplace;
9 >  Functions, Settings, Template,
10 >  RawEdit, BinEdit, Extractor, Preview, TxmpReplace;
11  
12   type
13    TForm_Main = class(TForm)
# Line 138 | Line 134 | var
134  
135   implementation
136  
137 + uses
138 +  LevelDB;
139 +
140   {$R *.dfm}
141  
142  
# Line 161 | Line 160 | begin
160    if RepMsg = SM_OK then
161    begin
162      UpdateStatBar;
163 +    UpdateConLists;
164    end;
165   end;
166  
# 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';
257    AppSettings.FilenumbersAsHex := False;
263      AppSettings.CharSet        := DEFAULT_CHARSET;
264      AppSettings.HideUnusedData := False;
265    end;
# Line 441 | Line 446 | var
446    position: TTBDockPosition;
447    mode: TTBItemDisplayMode;
448    i: Integer;
444  isEnabled: Boolean;
449   begin
450    toolbar := TTBToolbar(Sender);
451    if toolbar.Floating then
# Line 496 | Line 500 | end;
500  
501   procedure TForm_Main.LoadFile(typedb: Boolean);
502   var
503 <  ext: String;
503 >  i: Integer;
504   begin
505    opend.InitialDir := AppSettings.DatPath;
506    opend.Filter     := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
# Line 506 | Line 510 | begin
510      opend.FilterIndex := 2;
511    if opend.Execute then
512    begin
513 <    ext := ExtractFileExt(opend.FileName);
514 <    if ext = '.dat' then
515 <    begin
512 <      CreateConnection(opend.FileName);
513 <    end else if ext = '.oldb' then
514 <    begin
515 <      CreateConnection(opend.FileName);
516 <    end else
517 <      ShowMessage('Incompatible file');
513 >    if opend.Files.Count > 0 then
514 >      for i := 0 to opend.Files.Count - 1 do
515 >        CreateConnection(opend.Files.Strings[i]);
516      AppSettings.DatPath := ExtractFilepath(opend.FileName);
517    end;
518    UpdateStatBar;
# Line 553 | 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);
564 }
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);
578 }
575   end;
576  
577  
# Line 680 | Line 676 | end;
676   procedure TForm_Main.menu_conns_itemClick(Sender: TObject);
677   var
678    name: String;
683  i: Integer;
679    index: Integer;
680    RepMsg: TStatusMessages;
681   begin
# Line 692 | Line 687 | begin
687    begin
688      CheckConnectionCloseable(index);
689      ConManager.CloseConnectionByIndex(index, RepMsg);
690 +    ShowOpenMsg(RepMsg);
691 +    UpdateConLists;
692    end;
693    UpdateStatBar;
694   end;
# Line 730 | 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;
737  caption_end: String;
750    iconindex:   Integer;
751   begin
752    Result := nil;
# Line 746 | Line 758 | begin
758          tag := MDIChildren[i].Tag + 1;
759  
760    iconindex := -1;
749  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;
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
771 < //    toolform         := TForm_RawEdit.Create(Self);
772 <    toolform.Caption := 'Binary .raw-Editor ' + caption_end;
773 <    iconindex        := 6;
774 <  end;
775 <  if window_context = 'txmpreplace' then
776 <  begin
777 < //    toolform         := TForm_TxmpReplace.Create(Application);
778 <    toolform.Caption := 'TXMP Replacer ' + caption_end;
779 <    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)