| 6 |
|
MPHexEditor, ToolWin, ImgList, Tabs, |
| 7 |
|
MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst, |
| 8 |
|
Data, TypeDefs, ConnectionManager, |
| 9 |
< |
// Functions, Exporters, DataStructures, |
| 10 |
< |
Settings, {Helper_LevelDB, } |
| 11 |
< |
Template, BinEdit, Extractor, Preview, RawEdit, TxmpReplace; |
| 9 |
> |
Functions, Settings, |
| 10 |
> |
RawEdit, BinEdit, Extractor, Preview, TxmpReplace, |
| 11 |
> |
_BaseTemplate, _TemplateFile, _TemplateFileList; |
| 12 |
|
|
| 13 |
|
type |
| 14 |
|
TForm_Main = class(TForm) |
| 44 |
|
menu_windows_previous: TTBItem; |
| 45 |
|
menu_sep2: TTBSeparatorItem; |
| 46 |
|
menu_About: TTBItem; |
| 47 |
< |
Toolbar: TTBToolbar; |
| 47 |
> |
Toolbar_main: TTBToolbar; |
| 48 |
|
tbOpen: TTBItem; |
| 49 |
|
DockLeft: TTBDock; |
| 50 |
|
DockRight: TTBDock; |
| 57 |
|
menu_view_statusbar: TTBItem; |
| 58 |
|
menu_view_toolbar: TTBItem; |
| 59 |
|
tb_separator1: TTBSeparatorItem; |
| 60 |
– |
tb_preview: TTBItem; |
| 61 |
– |
tb_structure: TTBItem; |
| 62 |
– |
tb_compare: TTBItem; |
| 63 |
– |
tb_extractor: TTBItem; |
| 64 |
– |
tb_txmpreplacer: TTBItem; |
| 65 |
– |
tb_rawedit: TTBItem; |
| 66 |
– |
tb_datedit: TTBItem; |
| 60 |
|
menu_windows_tilevert: TTBItem; |
| 68 |
– |
tb_meta: TTBItem; |
| 61 |
|
menu_meta: TTBItem; |
| 62 |
|
TBSeparatorItem1: TTBSeparatorItem; |
| 63 |
|
tb_db2dat: TTBItem; |
| 67 |
|
Images_Close: TImageList; |
| 68 |
|
menu_conns: TTBSubmenuItem; |
| 69 |
|
menu_windows: TTBSubmenuItem; |
| 70 |
+ |
menu_filemanager: TTBItem; |
| 71 |
+ |
Toolbar_tools: TTBToolbar; |
| 72 |
+ |
tb_preview: TTBItem; |
| 73 |
+ |
tb_datedit: TTBItem; |
| 74 |
+ |
tb_rawedit: TTBItem; |
| 75 |
+ |
tb_txmpreplacer: TTBItem; |
| 76 |
+ |
tb_extractor: TTBItem; |
| 77 |
+ |
tb_meta: TTBItem; |
| 78 |
+ |
tb_filemanager: TTBItem; |
| 79 |
+ |
tb_compare: TTBItem; |
| 80 |
+ |
tb_structure: TTBItem; |
| 81 |
+ |
menu_view_toolbar_tools: TTBItem; |
| 82 |
|
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
| 83 |
|
procedure FormResize(Sender: TObject); |
| 84 |
|
procedure FormCreate(Sender: TObject); |
| 93 |
|
Shift: TShiftState; X, Y: Integer); |
| 94 |
|
procedure MDITabMouseMove(Sender: TObject; Shift: TShiftState; X, |
| 95 |
|
Y: Integer); |
| 96 |
< |
procedure ToolbarDockChanged(Sender: TObject); |
| 96 |
> |
procedure Toolbar_mainDockChanged(Sender: TObject); |
| 97 |
|
procedure CreateConnection(filename: String); |
| 98 |
+ |
function CheckConnectionCloseable(index: Integer): Boolean; |
| 99 |
|
|
| 100 |
|
procedure menu_loadfileClick(Sender: TObject); |
| 101 |
|
procedure menu_loaddbClick(Sender: TObject); |
| 112 |
|
procedure menu_txmpreplaceClick(Sender: TObject); |
| 113 |
|
procedure menu_previewClick(Sender: TObject); |
| 114 |
|
procedure menu_metaClick(Sender: TObject); |
| 110 |
– |
function open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate; |
| 115 |
|
|
| 116 |
|
procedure menu_windows_cascadeClick(Sender: TObject); |
| 117 |
|
procedure menu_windows_tilevertClick(Sender: TObject); |
| 128 |
|
procedure menu_AboutClick(Sender: TObject); |
| 129 |
|
|
| 130 |
|
procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA; |
| 131 |
+ |
procedure menu_filemanagerClick(Sender: TObject); |
| 132 |
+ |
procedure menu_view_toolbar_toolsClick(Sender: TObject); |
| 133 |
|
private |
| 128 |
– |
ConnectionManager: TConnectionManager; |
| 134 |
|
public |
| 135 |
+ |
function open_child(window_context: String; Connection, FileID: Integer): TForm_BaseTemplate; overload; |
| 136 |
+ |
function open_child(window_context: String; Connection: Integer): TForm_BaseTemplate; overload; |
| 137 |
+ |
function open_child(window_context: String): TForm_BaseTemplate; overload; |
| 138 |
|
procedure DefaultHandler(var Message); override; |
| 139 |
|
end; |
| 140 |
|
|
| 143 |
|
|
| 144 |
|
implementation |
| 145 |
|
|
| 146 |
+ |
uses |
| 147 |
+ |
LevelDB, MetaEditor, FileManager; |
| 148 |
+ |
|
| 149 |
|
{$R *.dfm} |
| 150 |
|
|
| 151 |
|
|
| 164 |
|
var |
| 165 |
|
RepMsg: TStatusMessages; |
| 166 |
|
begin |
| 167 |
< |
ConnectionManager.OpenConnection(filename, RepMsg); |
| 167 |
> |
ConManager.OpenConnection(filename, RepMsg); |
| 168 |
|
ShowOpenMsg(RepMsg); |
| 169 |
|
if RepMsg = SM_OK then |
| 170 |
|
begin |
| 171 |
|
UpdateStatBar; |
| 172 |
+ |
UpdateConLists; |
| 173 |
|
end; |
| 174 |
|
end; |
| 175 |
|
|
| 176 |
+ |
function TForm_Main.CheckConnectionCloseable(index: Integer): Boolean; |
| 177 |
+ |
var |
| 178 |
+ |
i: Integer; |
| 179 |
+ |
toolform: TForm_BaseTemplate; |
| 180 |
+ |
begin |
| 181 |
+ |
Result := True; |
| 182 |
+ |
if MDITab.MDIChildCount > 0 then |
| 183 |
+ |
begin |
| 184 |
+ |
for i := 0 to MDITab.MDIChildCount - 1 do |
| 185 |
+ |
begin |
| 186 |
+ |
if MDITab.MDIChildren[i] is TForm_BaseTemplate then |
| 187 |
+ |
begin |
| 188 |
+ |
toolform := TForm_BaseTemplate(MDITab.MDIChildren[i]); |
| 189 |
+ |
if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then |
| 190 |
+ |
begin |
| 191 |
+ |
if not toolform.Closeable then |
| 192 |
+ |
begin |
| 193 |
+ |
ShowMessage('Can not close toolwindow: ' + toolform.Caption); |
| 194 |
+ |
Result := False; |
| 195 |
+ |
end; |
| 196 |
+ |
end; |
| 197 |
+ |
end; |
| 198 |
+ |
end; |
| 199 |
+ |
end; |
| 200 |
+ |
end; |
| 201 |
+ |
|
| 202 |
+ |
|
| 203 |
|
{ Eine zweite Instanz hat uns ihre Kommandozeilenparameter geschickt } |
| 204 |
|
procedure TForm_Main.WMCopyData(var Msg: TWMCopyData); |
| 205 |
|
var |
| 247 |
|
|
| 248 |
|
|
| 249 |
|
procedure TForm_Main.FormCreate(Sender: TObject); |
| 211 |
– |
var |
| 212 |
– |
RepMsg: TStatusMessages; |
| 250 |
|
begin |
| 251 |
|
Self.Caption := 'Oni Un/Packer ' + version; |
| 252 |
|
Self.FormResize(Self); |
| 253 |
|
|
| 254 |
< |
ConnectionManager := TConnectionManager.Create; |
| 218 |
< |
ConnectionManager.OnCoonnectionListChanged := UpdateConLists; |
| 254 |
> |
ConManager.OnCoonnectionListChanged := UpdateConLists; |
| 255 |
|
|
| 256 |
|
if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then |
| 257 |
|
begin |
| 263 |
|
end |
| 264 |
|
else |
| 265 |
|
begin |
| 266 |
+ |
ShowMessage('Warning!' + #13#10 + |
| 267 |
+ |
'It seems like this is the first time you OUP.' + #13#10 + |
| 268 |
+ |
'I do not take any responsibility for messed up data files' + #13+#10 + |
| 269 |
+ |
'Do not forget to make backup copies of your *.dat/*.raw/*.sep files!'); |
| 270 |
|
AppSettings.DatPath := ExtractFilepath(Application.EXEname); |
| 271 |
|
AppSettings.ExtractPath := ExtractFilepath(Application.EXEname) + '\extract'; |
| 232 |
– |
AppSettings.FilenumbersAsHex := False; |
| 272 |
|
AppSettings.CharSet := DEFAULT_CHARSET; |
| 273 |
|
AppSettings.HideUnusedData := False; |
| 274 |
|
end; |
| 331 |
|
pt: TPoint; |
| 332 |
|
tabIndex: Integer; |
| 333 |
|
hint: String; |
| 334 |
+ |
tool: TForm_BaseTemplate; |
| 335 |
|
begin |
| 336 |
|
pt.X := X; |
| 337 |
|
pt.Y := Y; |
| 340 |
|
|
| 341 |
|
if tabIndex >= 0 then |
| 342 |
|
begin |
| 343 |
< |
if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then |
| 343 |
> |
if MDITab.MDIChildren[tabIndex] is TForm_BaseTemplate then |
| 344 |
|
begin |
| 345 |
< |
if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).Connection <> nil then |
| 345 |
> |
tool := TForm_BaseTemplate(MDITab.MDIChildren[tabIndex]); |
| 346 |
> |
if tool.ConnectionID > -1 then |
| 347 |
|
hint := 'Connection: ' + |
| 348 |
< |
ExtractFileName(TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).Connection.FileName) + #13+#10 |
| 308 |
< |
else |
| 309 |
< |
hint := 'Connection: none' + #13+#10; |
| 310 |
< |
if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.ID >= 0 then |
| 311 |
< |
hint := hint + 'Selected File: ' + |
| 312 |
< |
TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.FileName |
| 348 |
> |
ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) |
| 349 |
|
else |
| 350 |
< |
hint := hint + 'Selected File: none'; |
| 350 |
> |
hint := 'Connection: none'; |
| 351 |
> |
if tool is TForm_TemplateFile then |
| 352 |
> |
begin |
| 353 |
> |
if TForm_TemplateFile(tool).SelectedFile.ID > -1 then |
| 354 |
> |
hint := hint + #13+#10 + 'Selected File: ' + |
| 355 |
> |
FormatNumber(TForm_TemplateFile(tool).SelectedFile.ID, 5, '0') + '-' + |
| 356 |
> |
TForm_TemplateFile(tool).SelectedFile.Name + '.' + |
| 357 |
> |
TForm_TemplateFile(tool).SelectedFile.Extension |
| 358 |
> |
else |
| 359 |
> |
hint := hint + #13+#10 + 'Selected File: none'; |
| 360 |
> |
end; |
| 361 |
|
end |
| 362 |
|
else |
| 363 |
|
hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption; |
| 426 |
|
tb_rawedit.Enabled := active; |
| 427 |
|
tb_txmpreplacer.Enabled := active; |
| 428 |
|
tb_extractor.Enabled := active; |
| 429 |
+ |
tb_meta.Enabled := active; |
| 430 |
|
// tb_compare.Enabled := active; |
| 431 |
|
// tb_structure.Enabled := active; |
| 432 |
|
end; |
| 433 |
|
|
| 434 |
|
procedure TForm_Main.UpdateStatBar; |
| 435 |
|
begin |
| 436 |
< |
if Length(DataConnections) > 0 then |
| 436 |
> |
if ConManager.Count > 0 then |
| 437 |
|
begin |
| 438 |
|
Self.Caption := 'Oni Un/Packer ' + version; |
| 439 |
|
ActivateTools(True); |
| 440 |
< |
statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(Length(DataConnections)); |
| 440 |
> |
statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(ConManager.Count); |
| 441 |
|
end |
| 442 |
|
else |
| 443 |
|
begin |
| 447 |
|
statbar.Panels.Items[2].Text := ''; |
| 448 |
|
ActivateTools(False); |
| 449 |
|
end; |
| 450 |
< |
menu_conns.Enabled := Length(DataConnections) > 0; |
| 450 |
> |
menu_conns.Enabled := ConManager.Count > 0; |
| 451 |
|
end; |
| 452 |
|
|
| 453 |
|
|
| 454 |
|
|
| 455 |
|
|
| 456 |
< |
procedure TForm_Main.ToolbarDockChanged(Sender: TObject); |
| 456 |
> |
procedure TForm_Main.Toolbar_mainDockChanged(Sender: TObject); |
| 457 |
|
var |
| 458 |
|
toolbar: TTBToolbar; |
| 459 |
|
position: TTBDockPosition; |
| 460 |
|
mode: TTBItemDisplayMode; |
| 461 |
|
i: Integer; |
| 415 |
– |
isEnabled: Boolean; |
| 462 |
|
begin |
| 463 |
|
toolbar := TTBToolbar(Sender); |
| 464 |
|
if toolbar.Floating then |
| 492 |
|
begin |
| 493 |
|
if MDITab.MDIChildCount > 0 then |
| 494 |
|
for i := 0 to MDITab.MDIChildCount - 1 do |
| 495 |
< |
if MDITab.MDIChildren[i] is TForm_ToolTemplate then |
| 496 |
< |
TForm_ToolTemplate(MDITab.MDIChildren[i]).UpdateConList; |
| 495 |
> |
if MDITab.MDIChildren[i] is TForm_BaseTemplate then |
| 496 |
> |
TForm_BaseTemplate(MDITab.MDIChildren[i]).UpdateConList; |
| 497 |
|
|
| 498 |
|
menu_conns.Clear; |
| 499 |
< |
if ConnectionManager.Count > 0 then |
| 499 |
> |
if ConManager.Count > 0 then |
| 500 |
|
begin |
| 501 |
< |
for i := 0 to ConnectionManager.Count - 1 do |
| 501 |
> |
for i := 0 to ConManager.Count - 1 do |
| 502 |
|
begin |
| 503 |
|
entry := TTBItem.Create(menu_conns); |
| 504 |
< |
entry.Caption := ExtractFileName(DataConnections[i].FileName); |
| 504 |
> |
entry.Caption := ExtractFileName(ConManager.ConnectionByIndex[i].FileName); |
| 505 |
|
entry.Name := 'menu_conn_' + IntToStr(i); |
| 506 |
|
entry.OnClick := menu_conns_itemClick; |
| 507 |
|
menu_conns.Add(entry); |
| 513 |
|
|
| 514 |
|
procedure TForm_Main.LoadFile(typedb: Boolean); |
| 515 |
|
var |
| 516 |
< |
ext: String; |
| 516 |
> |
i: Integer; |
| 517 |
|
begin |
| 518 |
|
opend.InitialDir := AppSettings.DatPath; |
| 519 |
|
opend.Filter := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*'; |
| 523 |
|
opend.FilterIndex := 2; |
| 524 |
|
if opend.Execute then |
| 525 |
|
begin |
| 526 |
< |
ext := ExtractFileExt(opend.FileName); |
| 527 |
< |
if ext = '.dat' then |
| 528 |
< |
begin |
| 483 |
< |
CreateConnection(opend.FileName); |
| 484 |
< |
end else if ext = '.oldb' then |
| 485 |
< |
begin |
| 486 |
< |
CreateConnection(opend.FileName); |
| 487 |
< |
end else |
| 488 |
< |
ShowMessage('Incompatible file'); |
| 526 |
> |
if opend.Files.Count > 0 then |
| 527 |
> |
for i := 0 to opend.Files.Count - 1 do |
| 528 |
> |
CreateConnection(opend.Files.Strings[i]); |
| 529 |
|
AppSettings.DatPath := ExtractFilepath(opend.FileName); |
| 530 |
|
end; |
| 531 |
|
UpdateStatBar; |
| 564 |
|
{####################################} |
| 565 |
|
procedure TForm_Main.menu_createdbClick(Sender: TObject); |
| 566 |
|
begin |
| 527 |
– |
ShowMessage('Not yet usable'); |
| 528 |
– |
{ |
| 567 |
|
opend.Filter := 'Oni-Dat-Files|*.dat'; |
| 568 |
|
saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
| 569 |
|
saved.DefaultExt := 'oldb'; |
| 570 |
|
if opend.Execute then |
| 571 |
|
if saved.Execute then |
| 572 |
|
Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName); |
| 535 |
– |
} |
| 573 |
|
end; |
| 574 |
|
|
| 575 |
|
|
| 576 |
|
procedure TForm_Main.menu_createlvlClick(Sender: TObject); |
| 577 |
|
begin |
| 541 |
– |
ShowMessage('Not yet usable'); |
| 542 |
– |
{ |
| 578 |
|
opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
| 579 |
|
saved.Filter := 'Oni-Dat-Files|*.dat'; |
| 580 |
|
saved.DefaultExt := 'dat'; |
| 581 |
|
if opend.Execute then |
| 582 |
|
if saved.Execute then |
| 583 |
|
Form_LevelDB.CreateLevel(opend.FileName, saved.FileName); |
| 549 |
– |
} |
| 584 |
|
end; |
| 585 |
|
|
| 586 |
|
|
| 589 |
|
{#################################} |
| 590 |
|
procedure TForm_Main.menu_previewClick(Sender: TObject); |
| 591 |
|
begin |
| 592 |
< |
open_child('preview', nil, -1); |
| 592 |
> |
open_child('preview'); |
| 593 |
|
end; |
| 594 |
|
|
| 595 |
|
procedure TForm_Main.menu_bineditClick(Sender: TObject); |
| 596 |
|
begin |
| 597 |
< |
open_child('binedit', nil, -1); |
| 597 |
> |
open_child('binedit'); |
| 598 |
|
end; |
| 599 |
|
|
| 600 |
|
procedure TForm_Main.menu_raweditClick(Sender: TObject); |
| 601 |
|
begin |
| 602 |
< |
open_child('rawedit', nil, -1); |
| 602 |
> |
open_child('rawedit'); |
| 603 |
|
end; |
| 604 |
|
|
| 605 |
|
procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject); |
| 606 |
|
begin |
| 607 |
< |
open_child('txmpreplace', nil, -1); |
| 607 |
> |
open_child('txmpreplace'); |
| 608 |
|
end; |
| 609 |
|
|
| 610 |
|
procedure TForm_Main.menu_extractorClick(Sender: TObject); |
| 611 |
|
begin |
| 612 |
< |
open_child('extractor', nil, -1); |
| 612 |
> |
open_child('extractor'); |
| 613 |
|
end; |
| 614 |
|
|
| 615 |
|
procedure TForm_Main.menu_metaClick(Sender: TObject); |
| 616 |
|
begin |
| 617 |
< |
ShowMessage('TBD'); |
| 617 |
> |
open_child('meta'); |
| 618 |
|
end; |
| 619 |
|
|
| 620 |
|
procedure TForm_Main.menu_filecompareClick(Sender: TObject); |
| 621 |
|
begin |
| 622 |
< |
open_child('compare', nil, -1); |
| 622 |
> |
open_child('compare'); |
| 623 |
|
end; |
| 624 |
|
|
| 625 |
|
|
| 626 |
< |
{#################################} |
| 626 |
> |
procedure TForm_Main.menu_filemanagerClick(Sender: TObject); |
| 627 |
> |
begin |
| 628 |
> |
open_child('filemanager'); |
| 629 |
> |
end; |
| 630 |
> |
|
| 631 |
> |
{#################################} |
| 632 |
|
{##### View-Menu-Handlers #####} |
| 633 |
|
{#################################} |
| 634 |
|
procedure TForm_Main.menu_windows_cascadeClick(Sender: TObject); |
| 690 |
|
procedure TForm_Main.menu_conns_itemClick(Sender: TObject); |
| 691 |
|
var |
| 692 |
|
name: String; |
| 693 |
< |
i: Integer; |
| 693 |
> |
index: Integer; |
| 694 |
> |
RepMsg: TStatusMessages; |
| 695 |
|
begin |
| 696 |
< |
name := TTBItem(Sender).Caption; |
| 696 |
> |
index := TTBItem(Sender).Parent.IndexOf(TTBItem(Sender)); |
| 697 |
> |
name := ExtractFileName(ConManager.ConnectionByIndex[index].FileName); |
| 698 |
|
if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+ |
| 699 |
|
name + '?'), PChar('Close?'), MB_YESNO + MB_ICONQUESTION) = ID_YES then |
| 700 |
|
begin |
| 701 |
< |
for i := 0 to High(DataConnections) do |
| 702 |
< |
if ExtractFileName(DataConnections[i].FileName) = name then |
| 703 |
< |
begin |
| 704 |
< |
CloseDataConnection(DataConnections[i]); |
| 664 |
< |
Break; |
| 665 |
< |
end; |
| 701 |
> |
CheckConnectionCloseable(index); |
| 702 |
> |
ConManager.CloseConnectionByIndex(index, RepMsg); |
| 703 |
> |
ShowOpenMsg(RepMsg); |
| 704 |
> |
UpdateConLists; |
| 705 |
|
end; |
| 706 |
|
UpdateStatBar; |
| 707 |
|
end; |
| 713 |
|
procedure TForm_Main.menu_view_toolbarClick(Sender: TObject); |
| 714 |
|
begin |
| 715 |
|
menu_view_toolbar.Checked := not menu_view_toolbar.Checked; |
| 716 |
< |
Toolbar.Visible := menu_view_toolbar.Checked; |
| 716 |
> |
Toolbar_main.Visible := menu_view_toolbar.Checked; |
| 717 |
> |
end; |
| 718 |
> |
|
| 719 |
> |
procedure TForm_Main.menu_view_toolbar_toolsClick(Sender: TObject); |
| 720 |
> |
begin |
| 721 |
> |
menu_view_toolbar_tools.Checked := not menu_view_toolbar_tools.Checked; |
| 722 |
> |
Toolbar_tools.Visible := menu_view_toolbar_tools.Checked; |
| 723 |
|
end; |
| 724 |
|
|
| 725 |
|
procedure TForm_Main.menu_view_statusbarClick(Sender: TObject); |
| 745 |
|
|
| 746 |
|
|
| 747 |
|
|
| 748 |
< |
function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate; |
| 748 |
> |
function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_BaseTemplate; |
| 749 |
> |
type |
| 750 |
> |
TTemplate = class of TForm_BaseTemplate; |
| 751 |
> |
TTool = record |
| 752 |
> |
name: String; |
| 753 |
> |
icon: Integer; |
| 754 |
> |
caption: String; |
| 755 |
> |
classt: TTemplate; |
| 756 |
> |
end; |
| 757 |
> |
const |
| 758 |
> |
Tools: array[0..6] of TTool = ( |
| 759 |
> |
(name: 'binedit'; icon: 5; caption: 'Binary .dat-Editor'; classt: TForm_BinEdit), |
| 760 |
> |
(name: 'extractor'; icon: 8; caption: 'Extractor'; classt: TForm_Extractor), |
| 761 |
> |
(name: 'preview'; icon: 4; caption: 'Preview-Window'; classt: TForm_Preview), |
| 762 |
> |
(name: 'rawedit'; icon: 6; caption: 'Binary .raw-Editor'; classt: TForm_RawEdit), |
| 763 |
> |
(name: 'txmpreplace'; icon: 7; caption: 'TXMP Replacer'; classt: TForm_TxmpReplace), |
| 764 |
> |
(name: 'filemanager'; icon:-1; caption: 'FileManager'; classt: TForm_FileManager), |
| 765 |
> |
(name: 'meta'; icon: 11; caption: 'MetaEditor'; classt: TForm_Meta) |
| 766 |
> |
); |
| 767 |
|
var |
| 768 |
< |
toolform: TForm_ToolTemplate; |
| 768 |
> |
toolform: TForm_BaseTemplate; |
| 769 |
|
i: Integer; |
| 770 |
|
tag: Integer; |
| 708 |
– |
caption_end: String; |
| 771 |
|
iconindex: Integer; |
| 772 |
|
begin |
| 773 |
|
Result := nil; |
| 779 |
|
tag := MDIChildren[i].Tag + 1; |
| 780 |
|
|
| 781 |
|
iconindex := -1; |
| 720 |
– |
caption_end := IntToStr(tag) + ' '; |
| 782 |
|
|
| 783 |
< |
if window_context = 'binedit' then |
| 784 |
< |
begin |
| 785 |
< |
toolform := TForm_BinEdit.Create(Self); |
| 786 |
< |
toolform.Caption := 'Binary .dat-Editor ' + caption_end; |
| 787 |
< |
iconindex := 5; |
| 788 |
< |
end; |
| 789 |
< |
if window_context = 'extractor' then |
| 790 |
< |
begin |
| 791 |
< |
toolform := TForm_Extractor.Create(Self); |
| 792 |
< |
toolform.Caption := 'Extractor ' + caption_end; |
| 793 |
< |
iconindex := 8; |
| 794 |
< |
end; |
| 734 |
< |
if window_context = 'preview' then |
| 735 |
< |
begin |
| 736 |
< |
toolform := TForm_Preview.Create(Self); |
| 737 |
< |
toolform.Caption := 'Preview-Window ' + caption_end; |
| 738 |
< |
iconindex := 4; |
| 739 |
< |
end; |
| 740 |
< |
if window_context = 'rawedit' then |
| 741 |
< |
begin |
| 742 |
< |
toolform := TForm_RawEdit.Create(Self); |
| 743 |
< |
toolform.Caption := 'Binary .raw-Editor ' + caption_end; |
| 744 |
< |
iconindex := 6; |
| 745 |
< |
end; |
| 746 |
< |
if window_context = 'txmpreplace' then |
| 747 |
< |
begin |
| 748 |
< |
toolform := TForm_TxmpReplace.Create(Application); |
| 749 |
< |
toolform.Caption := 'TXMP Replacer ' + caption_end; |
| 750 |
< |
iconindex := 7; |
| 783 |
> |
toolform := nil; |
| 784 |
> |
|
| 785 |
> |
for i := 0 to High(Tools) do |
| 786 |
> |
if Tools[i].name = window_context then |
| 787 |
> |
Break; |
| 788 |
> |
if i < Length(Tools) then |
| 789 |
> |
begin |
| 790 |
> |
toolform := TTemplate(Tools[i].classt).Create(Self); |
| 791 |
> |
toolform.Caption := Tools[i].caption + ' ' + IntToStr(tag) + ' '; |
| 792 |
> |
iconindex := Tools[i].icon; |
| 793 |
> |
end else begin |
| 794 |
> |
ShowMessage('WindowContext not found!'); |
| 795 |
|
end; |
| 796 |
|
|
| 797 |
|
if Assigned(toolform) then |
| 800 |
|
toolform.Tag := tag; |
| 801 |
|
MDITab.AddTab(TForm(toolform), iconindex); |
| 802 |
|
toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); |
| 803 |
< |
if (fileid > -1) and (connection <> nil) then |
| 803 |
> |
if Connection > -1 then |
| 804 |
|
begin |
| 805 |
< |
toolform.SelectFileID(connection, fileid); |
| 805 |
> |
toolform.SelectConnection(connection); |
| 806 |
> |
if (FileID > -1) and (toolform is TForm_TemplateFile) then |
| 807 |
> |
TForm_TemplateFile(toolform).SelectFileID(Connection, FileID); |
| 808 |
|
end; |
| 809 |
|
Result := toolform; |
| 810 |
|
end; |
| 811 |
|
end; |
| 812 |
|
|
| 813 |
+ |
function TForm_Main.open_child(window_context: String; Connection: Integer): TForm_BaseTemplate; |
| 814 |
+ |
begin |
| 815 |
+ |
Result := open_child(window_context, Connection, -1); |
| 816 |
+ |
end; |
| 817 |
+ |
|
| 818 |
+ |
function TForm_Main.open_child(window_context: String): TForm_BaseTemplate; |
| 819 |
+ |
begin |
| 820 |
+ |
Result := open_child(window_context, -1, -1); |
| 821 |
+ |
end; |
| 822 |
+ |
|
| 823 |
|
end. |