| 6 |
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
| 7 |
|
Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids, |
| 8 |
|
MPHexEditor, ToolWin, ImgList, Tabs, |
| 9 |
< |
MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, |
| 9 |
> |
MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst, |
| 10 |
|
Data, Functions, DataStructures, OniDataClass, Exporters, |
| 11 |
|
Helper_LevelDB, Settings, Template, |
| 12 |
|
BinEdit, Extractor, Preview, RawEdit, TxmpReplace; |
| 88 |
|
procedure menu_windows_previousClick(Sender: TObject); |
| 89 |
|
procedure menu_windows_nextClick(Sender: TObject); |
| 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 |
|
procedure menu_windows_closeallClick(Sender: TObject); |
| 93 |
|
procedure menu_windows_cascadeClick(Sender: TObject); |
| 94 |
|
procedure menu_bineditClick(Sender: TObject); |
| 115 |
|
procedure menu_loaddbClick(Sender: TObject); |
| 116 |
|
procedure MDITabMouseMove(Sender: TObject; Shift: TShiftState; X, |
| 117 |
|
Y: Integer); |
| 118 |
< |
private |
| 118 |
> |
|
| 119 |
> |
procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA; |
| 120 |
> |
public |
| 121 |
> |
procedure DefaultHandler(var Message); override; |
| 122 |
|
public |
| 123 |
|
end; |
| 124 |
|
|
| 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; |
| 187 |
+ |
|
| 188 |
+ |
|
| 189 |
+ |
|
| 190 |
|
procedure TForm_Main.FormCreate(Sender: TObject); |
| 191 |
|
begin |
| 192 |
|
Self.Caption := 'Oni Un/Packer ' + version; |
| 446 |
|
Break; |
| 447 |
|
end; |
| 448 |
|
end; |
| 449 |
+ |
UpdateStatBar; |
| 450 |
|
UpdateConLists; |
| 451 |
|
end; |
| 452 |
|
|
| 541 |
|
{####################################} |
| 542 |
|
procedure TForm_Main.menu_createdbClick(Sender: TObject); |
| 543 |
|
begin |
| 544 |
< |
{ if Assigned(OniDataConnection) then |
| 545 |
< |
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 |
> |
{ |
| 546 |
|
opend.Filter := 'Oni-Dat-Files|*.dat'; |
| 547 |
|
saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
| 548 |
|
saved.DefaultExt := 'oldb'; |
| 549 |
|
if opend.Execute then |
| 550 |
|
if saved.Execute then |
| 551 |
|
Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName); |
| 552 |
< |
}end; |
| 552 |
> |
} |
| 553 |
> |
end; |
| 554 |
|
|
| 555 |
|
|
| 556 |
|
|
| 557 |
|
|
| 558 |
|
procedure TForm_Main.menu_createlvlClick(Sender: TObject); |
| 559 |
|
begin |
| 560 |
< |
{ if Assigned(OniDataConnection) then |
| 561 |
< |
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 |
> |
{ |
| 562 |
|
opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
| 563 |
|
saved.Filter := 'Oni-Dat-Files|*.dat'; |
| 564 |
|
saved.DefaultExt := 'dat'; |
| 565 |
|
if opend.Execute then |
| 566 |
|
if saved.Execute then |
| 567 |
|
Form_LevelDB.CreateLevel(opend.FileName, saved.FileName); |
| 568 |
< |
}end; |
| 568 |
> |
} |
| 569 |
> |
end; |
| 570 |
|
|
| 571 |
|
{#################################} |
| 572 |
|
{##### Tools-Menu-Handlers #####} |
| 573 |
|
{#################################} |
| 574 |
|
procedure TForm_Main.menu_previewClick(Sender: TObject); |
| 575 |
|
begin |
| 576 |
< |
open_child('preview', -1); |
| 576 |
> |
open_child('preview', nil, -1); |
| 577 |
|
end; |
| 578 |
|
|
| 579 |
|
|
| 580 |
|
procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject); |
| 581 |
|
begin |
| 582 |
< |
open_child('txmpreplace', -1); |
| 582 |
> |
open_child('txmpreplace', nil, -1); |
| 583 |
|
end; |
| 584 |
|
|
| 585 |
|
|
| 586 |
|
procedure TForm_Main.menu_bineditClick(Sender: TObject); |
| 587 |
|
begin |
| 588 |
< |
open_child('binedit', -1); |
| 588 |
> |
open_child('binedit', nil, -1); |
| 589 |
|
end; |
| 590 |
|
|
| 591 |
|
|
| 592 |
|
procedure TForm_Main.menu_raweditClick(Sender: TObject); |
| 593 |
|
begin |
| 594 |
< |
open_child('rawedit', -1); |
| 594 |
> |
open_child('rawedit', nil, -1); |
| 595 |
|
end; |
| 596 |
|
|
| 597 |
|
|
| 598 |
|
procedure TForm_Main.menu_extractorClick(Sender: TObject); |
| 599 |
|
begin |
| 600 |
< |
open_child('extractor', -1); |
| 600 |
> |
open_child('extractor', nil, -1); |
| 601 |
|
end; |
| 602 |
|
|
| 603 |
|
|
| 609 |
|
|
| 610 |
|
procedure TForm_Main.menu_filecompareClick(Sender: TObject); |
| 611 |
|
begin |
| 612 |
< |
open_child('compare', -1); |
| 612 |
> |
open_child('compare', nil, -1); |
| 613 |
|
end; |
| 614 |
|
|
| 615 |
|
|
| 705 |
|
|
| 706 |
|
|
| 707 |
|
|
| 708 |
< |
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; |
| 709 |
|
var |
| 710 |
|
toolform: TForm_ToolTemplate; |
| 711 |
|
i: Integer; |
| 761 |
|
toolform.Tag := tag; |
| 762 |
|
MDITab.AddTab(TForm(toolform), iconindex); |
| 763 |
|
toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); |
| 764 |
< |
if fileid > -1 then |
| 765 |
< |
toolform.SelectFileID(fileid); |
| 764 |
> |
if (fileid > -1) and (connection <> nil) then |
| 765 |
> |
begin |
| 766 |
> |
toolform.SelectFileID(connection, fileid); |
| 767 |
> |
end; |
| 768 |
|
Result := toolform; |
| 769 |
|
end; |
| 770 |
|
end; |