Changeset 92 for oup/current/Main.pas
- Timestamp:
- Jan 16, 2007, 12:35:04 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Main.pas
r87 r92 7 7 Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids, 8 8 MPHexEditor, ToolWin, ImgList, Tabs, 9 MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, 9 MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst, 10 10 Data, Functions, DataStructures, OniDataClass, Exporters, 11 11 Helper_LevelDB, Settings, Template, … … 89 89 procedure menu_windows_nextClick(Sender: TObject); 90 90 procedure menu_windows_tileClick(Sender: TObject); 91 function open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;91 function open_child(window_context: String; connection: TOniData; fileid: Integer): TForm_ToolTemplate; 92 92 procedure menu_windows_closeallClick(Sender: TObject); 93 93 procedure menu_windows_cascadeClick(Sender: TObject); … … 116 116 procedure MDITabMouseMove(Sender: TObject; Shift: TShiftState; X, 117 117 Y: Integer); 118 private 118 119 procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA; 119 120 public 121 procedure DefaultHandler(var Message); override; 122 public 120 123 end; 121 124 … … 126 129 127 130 {$R *.dfm} 131 132 133 134 { Eine zweite Instanz hat uns ihre Kommandozeilenparameter geschickt } 135 procedure TForm_Main.WMCopyData(var Msg: TWMCopyData); 136 var 137 strings: TStringList; 138 begin 139 if (Msg.CopyDataStruct.dwData = SecondInstMsgId) and (SecondInstMsgId <> 0) then 140 begin 141 Application.BringToFront; 142 143 strings := TStringList.Create; 144 strings.Text := ParamBlobToStr(Msg.CopyDataStruct.lpData); 145 if strings.Count = 2 then 146 begin 147 if strings.Strings[0] = 'opf' then 148 begin 149 ShowMessage('Load OPF-File: ' + ParamStr(2)); 150 end 151 else if strings.Strings[0] = 'oldb' then 152 begin 153 if CreateDataConnection(strings.Strings[1], ODB_ADB) = nil then 154 ShowMessage('Error while loading the file:' + CrLf + 155 strings.Strings[1] + CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?'); 156 end 157 else if strings.Strings[0] = 'dat' then 158 begin 159 if CreateDataConnection(strings.Strings[1], ODB_Dat) = nil then 160 ShowMessage('Error while loading the file:' + CrLf + 161 strings.Strings[1] + CrLf + 'Perhaps not an Oni-.dat-file?'); 162 end; 163 UpdateStatBar; 164 UpdateConLists; 165 end; 166 end 167 else 168 inherited; 169 end; 170 171 {----------------------------------------------------------------------------} 172 { Wir überschreiben den DefaultHandler, der alle Nachrichten zuerst bekommt, } 173 { damit wir auf die Nachricht mit der ID SecondInstMsgId reagieren können. } 174 { (Dies ist notwendig, da wir jetzt noch nicht wissen welchen Wert } 175 { die ID haben wird, weswegen wir keine statische Message-Prozedure, } 176 { so wie bei WM_COPYDATA, schreiben können.) } 177 {----------------------------------------------------------------------------} 178 procedure TForm_Main.DefaultHandler(var Message); 179 begin 180 if TMessage(Message).Msg = SecondInstMsgId then 181 { Eine zweite Instanz hat uns nach dem Handle gefragt } 182 { Es wird in die Message-Queue des Threads gepostet. } 183 PostThreadMessage(TMessage(Message).WParam, SecondInstMsgId, Handle, 0) 184 else 185 inherited; 186 end; 128 187 129 188 … … 388 447 end; 389 448 end; 449 UpdateStatBar; 390 450 UpdateConLists; 391 451 end; … … 482 542 procedure TForm_Main.menu_createdbClick(Sender: TObject); 483 543 begin 484 { if Assigned(OniDataConnection) then 485 if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' + 486 'Do you want to close it to continue?'), PChar('Close file?'), 487 MB_YESNO + MB_ICONQUESTION) = ID_NO then 488 Exit 489 else begin 490 if TryCloseAll then 491 begin 492 CloseDataConnection; 493 UpdateStatBar; 494 end else 495 Exit; 496 end; 544 ShowMessage('Not yet usable'); 545 { 497 546 opend.Filter := 'Oni-Dat-Files|*.dat'; 498 547 saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; … … 501 550 if saved.Execute then 502 551 Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName); 503 }end; 552 } 553 end; 504 554 505 555 … … 508 558 procedure TForm_Main.menu_createlvlClick(Sender: TObject); 509 559 begin 510 { if Assigned(OniDataConnection) then 511 if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' + 512 'Do you want to close it to continue?'), PChar('Close file?'), 513 MB_YESNO + MB_ICONQUESTION) = ID_NO then 514 Exit 515 else begin 516 if TryCloseAll then 517 begin 518 CloseDataConnection; 519 UpdateStatBar; 520 end else 521 Exit; 522 end; 560 ShowMessage('Not yet usable'); 561 { 523 562 opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; 524 563 saved.Filter := 'Oni-Dat-Files|*.dat'; … … 527 566 if saved.Execute then 528 567 Form_LevelDB.CreateLevel(opend.FileName, saved.FileName); 529 }end; 568 } 569 end; 530 570 531 571 {#################################} … … 534 574 procedure TForm_Main.menu_previewClick(Sender: TObject); 535 575 begin 536 open_child('preview', -1);576 open_child('preview', nil, -1); 537 577 end; 538 578 … … 540 580 procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject); 541 581 begin 542 open_child('txmpreplace', -1);582 open_child('txmpreplace', nil, -1); 543 583 end; 544 584 … … 546 586 procedure TForm_Main.menu_bineditClick(Sender: TObject); 547 587 begin 548 open_child('binedit', -1);588 open_child('binedit', nil, -1); 549 589 end; 550 590 … … 552 592 procedure TForm_Main.menu_raweditClick(Sender: TObject); 553 593 begin 554 open_child('rawedit', -1);594 open_child('rawedit', nil, -1); 555 595 end; 556 596 … … 558 598 procedure TForm_Main.menu_extractorClick(Sender: TObject); 559 599 begin 560 open_child('extractor', -1);600 open_child('extractor', nil, -1); 561 601 end; 562 602 … … 570 610 procedure TForm_Main.menu_filecompareClick(Sender: TObject); 571 611 begin 572 open_child('compare', -1);612 open_child('compare', nil, -1); 573 613 end; 574 614 … … 666 706 667 707 668 function TForm_Main.open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;708 function TForm_Main.open_child(window_context: String; connection: TOniData; fileid: Integer): TForm_ToolTemplate; 669 709 var 670 710 toolform: TForm_ToolTemplate; … … 722 762 MDITab.AddTab(TForm(toolform), iconindex); 723 763 toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); 724 if fileid > -1 then 725 toolform.SelectFileID(fileid); 764 if (fileid > -1) and (connection <> nil) then 765 begin 766 toolform.SelectFileID(connection, fileid); 767 end; 726 768 Result := toolform; 727 769 end;
Note:
See TracChangeset
for help on using the changeset viewer.