| 6 |
|
MPHexEditor, ToolWin, ImgList, Tabs, |
| 7 |
|
MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst, |
| 8 |
|
Data, TypeDefs, ConnectionManager, |
| 9 |
< |
Functions, Settings, Template, |
| 10 |
< |
RawEdit, BinEdit, Extractor, Preview, 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; |
| 59 |
– |
tb_preview: TTBItem; |
| 60 |
– |
tb_structure: TTBItem; |
| 61 |
– |
tb_compare: TTBItem; |
| 62 |
– |
tb_extractor: TTBItem; |
| 63 |
– |
tb_txmpreplacer: TTBItem; |
| 64 |
– |
tb_rawedit: TTBItem; |
| 65 |
– |
tb_datedit: TTBItem; |
| 60 |
|
menu_windows_tilevert: TTBItem; |
| 67 |
– |
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 |
|
|
| 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 |
| 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 |
|
|
| 144 |
|
implementation |
| 145 |
|
|
| 146 |
|
uses |
| 147 |
< |
LevelDB, MetaEditor; |
| 147 |
> |
LevelDB, MetaEditor, FileManager; |
| 148 |
|
|
| 149 |
|
{$R *.dfm} |
| 150 |
|
|
| 176 |
|
function TForm_Main.CheckConnectionCloseable(index: Integer): Boolean; |
| 177 |
|
var |
| 178 |
|
i: Integer; |
| 179 |
< |
toolform: TForm_ToolTemplate; |
| 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_ToolTemplate then |
| 186 |
> |
if MDITab.MDIChildren[i] is TForm_BaseTemplate then |
| 187 |
|
begin |
| 188 |
< |
toolform := TForm_ToolTemplate(MDITab.MDIChildren[i]); |
| 188 |
> |
toolform := TForm_BaseTemplate(MDITab.MDIChildren[i]); |
| 189 |
|
if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then |
| 190 |
|
begin |
| 191 |
|
if not toolform.Closeable then |
| 331 |
|
pt: TPoint; |
| 332 |
|
tabIndex: Integer; |
| 333 |
|
hint: String; |
| 334 |
< |
tool: TForm_ToolTemplate; |
| 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 |
< |
tool := TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]); |
| 345 |
> |
tool := TForm_BaseTemplate(MDITab.MDIChildren[tabIndex]); |
| 346 |
|
if tool.ConnectionID > -1 then |
| 347 |
|
hint := 'Connection: ' + |
| 348 |
< |
ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) + #13+#10 |
| 348 |
> |
ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) |
| 349 |
|
else |
| 350 |
< |
hint := 'Connection: none' + #13+#10; |
| 351 |
< |
if tool.SelectedFile.ID > -1 then |
| 352 |
< |
hint := hint + 'Selected File: ' + |
| 353 |
< |
FormatNumber(tool.SelectedFile.ID, 5, '0') + '-' + |
| 354 |
< |
tool.SelectedFile.Name + '.' + |
| 355 |
< |
tool.SelectedFile.Extension |
| 356 |
< |
else |
| 357 |
< |
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; |
| 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; |
| 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 ConManager.Count > 0 then |
| 564 |
|
{####################################} |
| 565 |
|
procedure TForm_Main.menu_createdbClick(Sender: TObject); |
| 566 |
|
begin |
| 555 |
– |
// ShowMessage('Not yet usable'); |
| 556 |
– |
|
| 567 |
|
opend.Filter := 'Oni-Dat-Files|*.dat'; |
| 568 |
|
saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
| 569 |
|
saved.DefaultExt := 'oldb'; |
| 575 |
|
|
| 576 |
|
procedure TForm_Main.menu_createlvlClick(Sender: TObject); |
| 577 |
|
begin |
| 568 |
– |
// ShowMessage('Not yet usable'); |
| 569 |
– |
|
| 578 |
|
opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
| 579 |
|
saved.Filter := 'Oni-Dat-Files|*.dat'; |
| 580 |
|
saved.DefaultExt := 'dat'; |
| 589 |
|
{#################################} |
| 590 |
|
procedure TForm_Main.menu_previewClick(Sender: TObject); |
| 591 |
|
begin |
| 592 |
< |
open_child('preview', -1, -1); |
| 592 |
> |
open_child('preview'); |
| 593 |
|
end; |
| 594 |
|
|
| 595 |
|
procedure TForm_Main.menu_bineditClick(Sender: TObject); |
| 596 |
|
begin |
| 597 |
< |
open_child('binedit', -1, -1); |
| 597 |
> |
open_child('binedit'); |
| 598 |
|
end; |
| 599 |
|
|
| 600 |
|
procedure TForm_Main.menu_raweditClick(Sender: TObject); |
| 601 |
|
begin |
| 602 |
< |
open_child('rawedit', -1, -1); |
| 602 |
> |
open_child('rawedit'); |
| 603 |
|
end; |
| 604 |
|
|
| 605 |
|
procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject); |
| 606 |
|
begin |
| 607 |
< |
open_child('txmpreplace', -1, -1); |
| 607 |
> |
open_child('txmpreplace'); |
| 608 |
|
end; |
| 609 |
|
|
| 610 |
|
procedure TForm_Main.menu_extractorClick(Sender: TObject); |
| 611 |
|
begin |
| 612 |
< |
open_child('extractor', -1, -1); |
| 612 |
> |
open_child('extractor'); |
| 613 |
|
end; |
| 614 |
|
|
| 615 |
|
procedure TForm_Main.menu_metaClick(Sender: TObject); |
| 608 |
– |
var |
| 609 |
– |
toolform: TForm_Meta; |
| 610 |
– |
i: Integer; |
| 611 |
– |
tag: Integer; |
| 612 |
– |
iconindex: Integer; |
| 616 |
|
begin |
| 617 |
< |
tag := 1; |
| 615 |
< |
if MDIChildCount > 0 then |
| 616 |
< |
for i := 0 to MDIChildCount - 1 do |
| 617 |
< |
if MDIChildren[i].Tag >= tag then |
| 618 |
< |
tag := MDIChildren[i].Tag + 1; |
| 619 |
< |
|
| 620 |
< |
iconindex := -1; |
| 621 |
< |
|
| 622 |
< |
toolform := nil; |
| 623 |
< |
|
| 624 |
< |
toolform := TForm_Meta.Create(Self); |
| 625 |
< |
toolform.Caption := 'MetaEditor' + ' ' + IntToStr(tag) + ' '; |
| 626 |
< |
iconindex := 11; |
| 627 |
< |
|
| 628 |
< |
if Assigned(toolform) then |
| 629 |
< |
begin |
| 630 |
< |
toolform.Name := 'meta' + IntToStr(tag); |
| 631 |
< |
toolform.Tag := tag; |
| 632 |
< |
MDITab.AddTab(TForm(toolform), iconindex); |
| 633 |
< |
toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); |
| 634 |
< |
end; |
| 617 |
> |
open_child('meta'); |
| 618 |
|
end; |
| 619 |
|
|
| 620 |
|
procedure TForm_Main.menu_filecompareClick(Sender: TObject); |
| 621 |
|
begin |
| 622 |
< |
open_child('compare', -1, -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); |
| 693 |
|
index: Integer; |
| 694 |
|
RepMsg: TStatusMessages; |
| 695 |
|
begin |
| 708 |
– |
// 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+ |
| 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_ToolTemplate; |
| 750 |
> |
TTemplate = class of TForm_BaseTemplate; |
| 751 |
|
TTool = record |
| 752 |
|
name: String; |
| 753 |
|
icon: Integer; |
| 755 |
|
classt: TTemplate; |
| 756 |
|
end; |
| 757 |
|
const |
| 758 |
< |
Tools: array[0..4] of TTool = ( |
| 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) |
| 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; |
| 771 |
|
iconindex: Integer; |
| 800 |
|
toolform.Tag := tag; |
| 801 |
|
MDITab.AddTab(TForm(toolform), iconindex); |
| 802 |
|
toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); |
| 803 |
< |
if connection > -1 then |
| 803 |
> |
if Connection > -1 then |
| 804 |
|
begin |
| 805 |
|
toolform.SelectConnection(connection); |
| 806 |
< |
if fileid > -1 then |
| 807 |
< |
toolform.SelectFileID(connection, fileid); |
| 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 |
+ |
open_child(window_context, Connection, -1); |
| 816 |
+ |
end; |
| 817 |
+ |
|
| 818 |
+ |
function TForm_Main.open_child(window_context: String): TForm_BaseTemplate; |
| 819 |
+ |
begin |
| 820 |
+ |
open_child(window_context, -1, -1); |
| 821 |
+ |
end; |
| 822 |
+ |
|
| 823 |
|
end. |