7 |
|
MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst, |
8 |
|
Data, TypeDefs, ConnectionManager, |
9 |
|
// Functions, Exporters, DataStructures, |
10 |
+ |
Functions, |
11 |
|
Settings, {Helper_LevelDB, } |
12 |
< |
Template, BinEdit, Extractor, Preview, RawEdit, TxmpReplace; |
12 |
> |
Template, |
13 |
> |
Preview; |
14 |
> |
// BinEdit, Extractor, RawEdit, TxmpReplace; |
15 |
|
|
16 |
|
type |
17 |
|
TForm_Main = class(TForm) |
94 |
|
Y: Integer); |
95 |
|
procedure ToolbarDockChanged(Sender: TObject); |
96 |
|
procedure CreateConnection(filename: String); |
97 |
+ |
function CheckConnectionCloseable(index: Integer): Boolean; |
98 |
|
|
99 |
|
procedure menu_loadfileClick(Sender: TObject); |
100 |
|
procedure menu_loaddbClick(Sender: TObject); |
129 |
|
|
130 |
|
procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA; |
131 |
|
private |
128 |
– |
ConnectionManager: TConnectionManager; |
132 |
|
public |
133 |
|
procedure DefaultHandler(var Message); override; |
134 |
|
end; |
156 |
|
var |
157 |
|
RepMsg: TStatusMessages; |
158 |
|
begin |
159 |
< |
ConnectionManager.OpenConnection(filename, RepMsg); |
159 |
> |
ConManager.OpenConnection(filename, RepMsg); |
160 |
|
ShowOpenMsg(RepMsg); |
161 |
|
if RepMsg = SM_OK then |
162 |
|
begin |
164 |
|
end; |
165 |
|
end; |
166 |
|
|
167 |
+ |
function TForm_Main.CheckConnectionCloseable(index: Integer): Boolean; |
168 |
+ |
var |
169 |
+ |
i: Integer; |
170 |
+ |
toolform: TForm_ToolTemplate; |
171 |
+ |
begin |
172 |
+ |
if MDITab.MDIChildCount > 0 then |
173 |
+ |
begin |
174 |
+ |
for i := 0 to MDITab.MDIChildCount - 1 do |
175 |
+ |
begin |
176 |
+ |
if MDITab.MDIChildren[i] is TForm_ToolTemplate then |
177 |
+ |
begin |
178 |
+ |
toolform := TForm_ToolTemplate(MDITab.MDIChildren[i]); |
179 |
+ |
if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then |
180 |
+ |
begin |
181 |
+ |
if not toolform.Closeable then |
182 |
+ |
ShowMessage('Can not close toolwindow: ' + toolform.Caption); |
183 |
+ |
end; |
184 |
+ |
end; |
185 |
+ |
end; |
186 |
+ |
end; |
187 |
+ |
end; |
188 |
+ |
|
189 |
+ |
|
190 |
|
{ Eine zweite Instanz hat uns ihre Kommandozeilenparameter geschickt } |
191 |
|
procedure TForm_Main.WMCopyData(var Msg: TWMCopyData); |
192 |
|
var |
240 |
|
Self.Caption := 'Oni Un/Packer ' + version; |
241 |
|
Self.FormResize(Self); |
242 |
|
|
243 |
< |
ConnectionManager := TConnectionManager.Create; |
218 |
< |
ConnectionManager.OnCoonnectionListChanged := UpdateConLists; |
243 |
> |
ConManager.OnCoonnectionListChanged := UpdateConLists; |
244 |
|
|
245 |
|
if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then |
246 |
|
begin |
317 |
|
pt: TPoint; |
318 |
|
tabIndex: Integer; |
319 |
|
hint: String; |
320 |
+ |
tool: TForm_ToolTemplate; |
321 |
|
begin |
322 |
|
pt.X := X; |
323 |
|
pt.Y := Y; |
328 |
|
begin |
329 |
|
if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then |
330 |
|
begin |
331 |
< |
if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).Connection <> nil then |
331 |
> |
tool := TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]); |
332 |
> |
if tool.ConnectionID > -1 then |
333 |
|
hint := 'Connection: ' + |
334 |
< |
ExtractFileName(TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).Connection.FileName) + #13+#10 |
334 |
> |
ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) + #13+#10 |
335 |
|
else |
336 |
|
hint := 'Connection: none' + #13+#10; |
337 |
< |
if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.ID >= 0 then |
337 |
> |
if tool.SelectedFile.ID > -1 then |
338 |
|
hint := hint + 'Selected File: ' + |
339 |
< |
TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.FileName |
339 |
> |
FormatNumber(tool.SelectedFile.ID, 5, '0') + '-' + |
340 |
> |
tool.SelectedFile.Name + '.' + |
341 |
> |
tool.SelectedFile.Extension |
342 |
|
else |
343 |
|
hint := hint + 'Selected File: none'; |
344 |
|
end |
415 |
|
|
416 |
|
procedure TForm_Main.UpdateStatBar; |
417 |
|
begin |
418 |
< |
if Length(DataConnections) > 0 then |
418 |
> |
if ConManager.Count > 0 then |
419 |
|
begin |
420 |
|
Self.Caption := 'Oni Un/Packer ' + version; |
421 |
|
ActivateTools(True); |
422 |
< |
statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(Length(DataConnections)); |
422 |
> |
statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(ConManager.Count); |
423 |
|
end |
424 |
|
else |
425 |
|
begin |
429 |
|
statbar.Panels.Items[2].Text := ''; |
430 |
|
ActivateTools(False); |
431 |
|
end; |
432 |
< |
menu_conns.Enabled := Length(DataConnections) > 0; |
432 |
> |
menu_conns.Enabled := ConManager.Count > 0; |
433 |
|
end; |
434 |
|
|
435 |
|
|
479 |
|
TForm_ToolTemplate(MDITab.MDIChildren[i]).UpdateConList; |
480 |
|
|
481 |
|
menu_conns.Clear; |
482 |
< |
if ConnectionManager.Count > 0 then |
482 |
> |
if ConManager.Count > 0 then |
483 |
|
begin |
484 |
< |
for i := 0 to ConnectionManager.Count - 1 do |
484 |
> |
for i := 0 to ConManager.Count - 1 do |
485 |
|
begin |
486 |
|
entry := TTBItem.Create(menu_conns); |
487 |
< |
entry.Caption := ExtractFileName(DataConnections[i].FileName); |
487 |
> |
entry.Caption := ExtractFileName(ConManager.ConnectionByIndex[i].FileName); |
488 |
|
entry.Name := 'menu_conn_' + IntToStr(i); |
489 |
|
entry.OnClick := menu_conns_itemClick; |
490 |
|
menu_conns.Add(entry); |
584 |
|
{#################################} |
585 |
|
procedure TForm_Main.menu_previewClick(Sender: TObject); |
586 |
|
begin |
587 |
< |
open_child('preview', nil, -1); |
587 |
> |
open_child('preview', -1, -1); |
588 |
|
end; |
589 |
|
|
590 |
|
procedure TForm_Main.menu_bineditClick(Sender: TObject); |
591 |
|
begin |
592 |
< |
open_child('binedit', nil, -1); |
592 |
> |
open_child('binedit', -1, -1); |
593 |
|
end; |
594 |
|
|
595 |
|
procedure TForm_Main.menu_raweditClick(Sender: TObject); |
596 |
|
begin |
597 |
< |
open_child('rawedit', nil, -1); |
597 |
> |
open_child('rawedit', -1, -1); |
598 |
|
end; |
599 |
|
|
600 |
|
procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject); |
601 |
|
begin |
602 |
< |
open_child('txmpreplace', nil, -1); |
602 |
> |
open_child('txmpreplace', -1, -1); |
603 |
|
end; |
604 |
|
|
605 |
|
procedure TForm_Main.menu_extractorClick(Sender: TObject); |
606 |
|
begin |
607 |
< |
open_child('extractor', nil, -1); |
607 |
> |
open_child('extractor', -1, -1); |
608 |
|
end; |
609 |
|
|
610 |
|
procedure TForm_Main.menu_metaClick(Sender: TObject); |
614 |
|
|
615 |
|
procedure TForm_Main.menu_filecompareClick(Sender: TObject); |
616 |
|
begin |
617 |
< |
open_child('compare', nil, -1); |
617 |
> |
open_child('compare', -1, -1); |
618 |
|
end; |
619 |
|
|
620 |
|
|
681 |
|
var |
682 |
|
name: String; |
683 |
|
i: Integer; |
684 |
+ |
index: Integer; |
685 |
+ |
RepMsg: TStatusMessages; |
686 |
|
begin |
687 |
< |
name := TTBItem(Sender).Caption; |
687 |
> |
// name := TTBItem(Sender).Caption; |
688 |
> |
index := TTBItem(Sender).Parent.IndexOf(TTBItem(Sender)); |
689 |
> |
name := ExtractFileName(ConManager.ConnectionByIndex[index].FileName); |
690 |
|
if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+ |
691 |
|
name + '?'), PChar('Close?'), MB_YESNO + MB_ICONQUESTION) = ID_YES then |
692 |
|
begin |
693 |
< |
for i := 0 to High(DataConnections) do |
694 |
< |
if ExtractFileName(DataConnections[i].FileName) = name then |
662 |
< |
begin |
663 |
< |
CloseDataConnection(DataConnections[i]); |
664 |
< |
Break; |
665 |
< |
end; |
693 |
> |
CheckConnectionCloseable(index); |
694 |
> |
ConManager.CloseConnectionByIndex(index, RepMsg); |
695 |
|
end; |
696 |
|
UpdateStatBar; |
697 |
|
end; |
750 |
|
|
751 |
|
if window_context = 'binedit' then |
752 |
|
begin |
753 |
< |
toolform := TForm_BinEdit.Create(Self); |
753 |
> |
// toolform := TForm_BinEdit.Create(Self); |
754 |
|
toolform.Caption := 'Binary .dat-Editor ' + caption_end; |
755 |
|
iconindex := 5; |
756 |
|
end; |
757 |
|
if window_context = 'extractor' then |
758 |
|
begin |
759 |
< |
toolform := TForm_Extractor.Create(Self); |
759 |
> |
// toolform := TForm_Extractor.Create(Self); |
760 |
|
toolform.Caption := 'Extractor ' + caption_end; |
761 |
|
iconindex := 8; |
762 |
|
end; |
768 |
|
end; |
769 |
|
if window_context = 'rawedit' then |
770 |
|
begin |
771 |
< |
toolform := TForm_RawEdit.Create(Self); |
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); |
777 |
> |
// toolform := TForm_TxmpReplace.Create(Application); |
778 |
|
toolform.Caption := 'TXMP Replacer ' + caption_end; |
779 |
|
iconindex := 7; |
780 |
|
end; |
785 |
|
toolform.Tag := tag; |
786 |
|
MDITab.AddTab(TForm(toolform), iconindex); |
787 |
|
toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); |
788 |
< |
if (fileid > -1) and (connection <> nil) then |
788 |
> |
if connection > -1 then |
789 |
|
begin |
790 |
< |
toolform.SelectFileID(connection, fileid); |
790 |
> |
toolform.SelectConnection(connection); |
791 |
> |
if fileid > -1 then |
792 |
> |
toolform.SelectFileID(connection, fileid); |
793 |
|
end; |
794 |
|
Result := toolform; |
795 |
|
end; |