| 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) |
| 134 |
|
|
| 135 |
|
implementation |
| 136 |
|
|
| 137 |
+ |
uses |
| 138 |
+ |
LevelDB, MetaEditor; |
| 139 |
+ |
|
| 140 |
|
{$R *.dfm} |
| 141 |
|
|
| 142 |
|
|
| 160 |
|
if RepMsg = SM_OK then |
| 161 |
|
begin |
| 162 |
|
UpdateStatBar; |
| 163 |
+ |
UpdateConLists; |
| 164 |
|
end; |
| 165 |
|
end; |
| 166 |
|
|
| 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 |
| 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; |
| 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); |
| 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; |
| 414 |
|
tb_rawedit.Enabled := active; |
| 415 |
|
tb_txmpreplacer.Enabled := active; |
| 416 |
|
tb_extractor.Enabled := active; |
| 417 |
+ |
tb_meta.Enabled := active; |
| 418 |
|
// tb_compare.Enabled := active; |
| 419 |
|
// tb_structure.Enabled := active; |
| 420 |
|
end; |
| 447 |
|
position: TTBDockPosition; |
| 448 |
|
mode: TTBItemDisplayMode; |
| 449 |
|
i: Integer; |
| 444 |
– |
isEnabled: Boolean; |
| 450 |
|
begin |
| 451 |
|
toolbar := TTBToolbar(Sender); |
| 452 |
|
if toolbar.Floating then |
| 501 |
|
|
| 502 |
|
procedure TForm_Main.LoadFile(typedb: Boolean); |
| 503 |
|
var |
| 504 |
< |
ext: String; |
| 504 |
> |
i: Integer; |
| 505 |
|
begin |
| 506 |
|
opend.InitialDir := AppSettings.DatPath; |
| 507 |
|
opend.Filter := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*'; |
| 511 |
|
opend.FilterIndex := 2; |
| 512 |
|
if opend.Execute then |
| 513 |
|
begin |
| 514 |
< |
ext := ExtractFileExt(opend.FileName); |
| 515 |
< |
if ext = '.dat' then |
| 516 |
< |
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'); |
| 514 |
> |
if opend.Files.Count > 0 then |
| 515 |
> |
for i := 0 to opend.Files.Count - 1 do |
| 516 |
> |
CreateConnection(opend.Files.Strings[i]); |
| 517 |
|
AppSettings.DatPath := ExtractFilepath(opend.FileName); |
| 518 |
|
end; |
| 519 |
|
UpdateStatBar; |
| 552 |
|
{####################################} |
| 553 |
|
procedure TForm_Main.menu_createdbClick(Sender: TObject); |
| 554 |
|
begin |
| 555 |
< |
ShowMessage('Not yet usable'); |
| 556 |
< |
{ |
| 555 |
> |
// ShowMessage('Not yet usable'); |
| 556 |
> |
|
| 557 |
|
opend.Filter := 'Oni-Dat-Files|*.dat'; |
| 558 |
|
saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
| 559 |
|
saved.DefaultExt := 'oldb'; |
| 560 |
|
if opend.Execute then |
| 561 |
|
if saved.Execute then |
| 562 |
|
Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName); |
| 564 |
– |
} |
| 563 |
|
end; |
| 564 |
|
|
| 565 |
|
|
| 566 |
|
procedure TForm_Main.menu_createlvlClick(Sender: TObject); |
| 567 |
|
begin |
| 568 |
< |
ShowMessage('Not yet usable'); |
| 569 |
< |
{ |
| 568 |
> |
// ShowMessage('Not yet usable'); |
| 569 |
> |
|
| 570 |
|
opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
| 571 |
|
saved.Filter := 'Oni-Dat-Files|*.dat'; |
| 572 |
|
saved.DefaultExt := 'dat'; |
| 573 |
|
if opend.Execute then |
| 574 |
|
if saved.Execute then |
| 575 |
|
Form_LevelDB.CreateLevel(opend.FileName, saved.FileName); |
| 578 |
– |
} |
| 576 |
|
end; |
| 577 |
|
|
| 578 |
|
|
| 605 |
|
end; |
| 606 |
|
|
| 607 |
|
procedure TForm_Main.menu_metaClick(Sender: TObject); |
| 608 |
+ |
var |
| 609 |
+ |
toolform: TForm_Meta; |
| 610 |
+ |
i: Integer; |
| 611 |
+ |
tag: Integer; |
| 612 |
+ |
iconindex: Integer; |
| 613 |
|
begin |
| 614 |
< |
ShowMessage('TBD'); |
| 614 |
> |
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; |
| 635 |
|
end; |
| 636 |
|
|
| 637 |
|
procedure TForm_Main.menu_filecompareClick(Sender: TObject); |
| 702 |
|
procedure TForm_Main.menu_conns_itemClick(Sender: TObject); |
| 703 |
|
var |
| 704 |
|
name: String; |
| 683 |
– |
i: Integer; |
| 705 |
|
index: Integer; |
| 706 |
|
RepMsg: TStatusMessages; |
| 707 |
|
begin |
| 713 |
|
begin |
| 714 |
|
CheckConnectionCloseable(index); |
| 715 |
|
ConManager.CloseConnectionByIndex(index, RepMsg); |
| 716 |
+ |
ShowOpenMsg(RepMsg); |
| 717 |
+ |
UpdateConLists; |
| 718 |
|
end; |
| 719 |
|
UpdateStatBar; |
| 720 |
|
end; |
| 753 |
|
|
| 754 |
|
|
| 755 |
|
function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate; |
| 756 |
+ |
type |
| 757 |
+ |
TTemplate = class of TForm_ToolTemplate; |
| 758 |
+ |
TTool = record |
| 759 |
+ |
name: String; |
| 760 |
+ |
icon: Integer; |
| 761 |
+ |
caption: String; |
| 762 |
+ |
classt: TTemplate; |
| 763 |
+ |
end; |
| 764 |
+ |
const |
| 765 |
+ |
Tools: array[0..4] of TTool = ( |
| 766 |
+ |
(name: 'binedit'; icon: 5; caption: 'Binary .dat-Editor'; classt: TForm_BinEdit), |
| 767 |
+ |
(name: 'extractor'; icon: 8; caption: 'Extractor'; classt: TForm_Extractor), |
| 768 |
+ |
(name: 'preview'; icon: 4; caption: 'Preview-Window'; classt: TForm_Preview), |
| 769 |
+ |
(name: 'rawedit'; icon: 6; caption: 'Binary .raw-Editor'; classt: TForm_RawEdit), |
| 770 |
+ |
(name: 'txmpreplace'; icon: 7; caption: 'TXMP Replacer'; classt: TForm_TxmpReplace) |
| 771 |
+ |
); |
| 772 |
|
var |
| 773 |
|
toolform: TForm_ToolTemplate; |
| 774 |
|
i: Integer; |
| 775 |
|
tag: Integer; |
| 737 |
– |
caption_end: String; |
| 776 |
|
iconindex: Integer; |
| 777 |
|
begin |
| 778 |
|
Result := nil; |
| 784 |
|
tag := MDIChildren[i].Tag + 1; |
| 785 |
|
|
| 786 |
|
iconindex := -1; |
| 749 |
– |
caption_end := IntToStr(tag) + ' '; |
| 787 |
|
|
| 788 |
< |
if window_context = 'binedit' then |
| 789 |
< |
begin |
| 790 |
< |
// toolform := TForm_BinEdit.Create(Self); |
| 791 |
< |
toolform.Caption := 'Binary .dat-Editor ' + caption_end; |
| 792 |
< |
iconindex := 5; |
| 793 |
< |
end; |
| 794 |
< |
if window_context = 'extractor' then |
| 795 |
< |
begin |
| 796 |
< |
// toolform := TForm_Extractor.Create(Self); |
| 797 |
< |
toolform.Caption := 'Extractor ' + caption_end; |
| 798 |
< |
iconindex := 8; |
| 799 |
< |
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; |
| 788 |
> |
toolform := nil; |
| 789 |
> |
|
| 790 |
> |
for i := 0 to High(Tools) do |
| 791 |
> |
if Tools[i].name = window_context then |
| 792 |
> |
Break; |
| 793 |
> |
if i < Length(Tools) then |
| 794 |
> |
begin |
| 795 |
> |
toolform := TTemplate(Tools[i].classt).Create(Self); |
| 796 |
> |
toolform.Caption := Tools[i].caption + ' ' + IntToStr(tag) + ' '; |
| 797 |
> |
iconindex := Tools[i].icon; |
| 798 |
> |
end else begin |
| 799 |
> |
ShowMessage('WindowContext not found!'); |
| 800 |
|
end; |
| 801 |
|
|
| 802 |
|
if Assigned(toolform) then |