| Line 12... |
Line 12... |
| 12 |
|
12 |
|
| 13 |
using namespace System::Windows;
|
13 |
using namespace System::Windows;
|
| 14 |
using namespace System::Windows::Forms;
|
14 |
using namespace System::Windows::Forms;
|
| 15 |
|
15 |
|
| 16 |
namespace SpkExplorer {
|
16 |
namespace SpkExplorer {
|
| - |
|
17 |
SpkForm::SpkForm(System::Windows::Forms::Form ^parent, System::Windows::Forms::TabControl ^ctrl, System::Windows::Forms::TabPage ^page)
|
| - |
|
18 |
{
|
| - |
|
19 |
InitializeComponent();
|
| - |
|
20 |
this->AllowDrop = true;
|
| - |
|
21 |
|
| - |
|
22 |
ImageList ^list1 = gcnew ImageList();
|
| - |
|
23 |
ImageList ^list2 = gcnew ImageList();
|
| - |
|
24 |
list1->ImageSize.Height = 32;
|
| - |
|
25 |
list1->ImageSize.Width = 32;
|
| - |
|
26 |
list2->ImageSize.Height = 16;
|
| - |
|
27 |
list2->ImageSize.Width = 16;
|
| - |
|
28 |
|
| - |
|
29 |
this->AddImage("$IMAGELIST:script.png", list1, _US(Utils::String::Number(FILETYPE_SCRIPT)));
|
| - |
|
30 |
this->AddImage("$IMAGELIST:textfile.png", list1, _US(Utils::String::Number(FILETYPE_TEXT)));
|
| - |
|
31 |
this->AddImage("$IMAGELIST:readme.png", list1, _US(Utils::String::Number(FILETYPE_README)));
|
| - |
|
32 |
this->AddImage("$IMAGELIST:map.png", list1, _US(Utils::String::Number(FILETYPE_MAP)));
|
| - |
|
33 |
this->AddImage("$IMAGELIST:mods.png", list1, _US(Utils::String::Number(FILETYPE_MOD)));
|
| - |
|
34 |
this->AddImage("$IMAGELIST:uninstall.png", list1, _US(Utils::String::Number(FILETYPE_UNINSTALL)));
|
| - |
|
35 |
this->AddImage("$IMAGELIST:sound.png", list1, _US(Utils::String::Number(FILETYPE_SOUND)));
|
| - |
|
36 |
this->AddImage("$IMAGELIST:extras.png", list1, _US(Utils::String::Number(FILETYPE_EXTRA)));
|
| - |
|
37 |
this->AddImage("$IMAGELIST:screenshot.png", list1, _US(Utils::String::Number(FILETYPE_SCREEN)));
|
| - |
|
38 |
this->AddImage("$IMAGELIST:backup.png", list1, _US(Utils::String::Number(FILETYPE_BACKUP)));
|
| - |
|
39 |
this->AddImage("$IMAGELIST:mission.png", list1, _US(Utils::String::Number(FILETYPE_MISSION)));
|
| - |
|
40 |
this->AddImage("$IMAGELIST:advert.png", list1, _US(Utils::String::Number(FILETYPE_ADVERT)));
|
| - |
|
41 |
this->AddImage("$IMAGELIST:shipother.png", list1, _US(Utils::String::Number(FILETYPE_SHIPOTHER)));
|
| - |
|
42 |
this->AddImage("$IMAGELIST:shipmodel.png", list1, _US(Utils::String::Number(FILETYPE_SHIPMODEL)));
|
| - |
|
43 |
this->AddImage("$IMAGELIST:shipscene.png", list1, _US(Utils::String::Number(FILETYPE_SHIPSCENE)));
|
| - |
|
44 |
this->AddImage("$IMAGELIST:cockpitscene.png", list1, _US(Utils::String::Number(FILETYPE_COCKPITSCENE)));
|
| - |
|
45 |
|
| - |
|
46 |
this->AddImage("$IMAGELIST:script.png", list2, _US(Utils::String::Number(FILETYPE_SCRIPT)));
|
| - |
|
47 |
this->AddImage("$IMAGELIST:textfile.png", list2, _US(Utils::String::Number(FILETYPE_TEXT)));
|
| - |
|
48 |
this->AddImage("$IMAGELIST:readme.png", list2, _US(Utils::String::Number(FILETYPE_README)));
|
| - |
|
49 |
this->AddImage("$IMAGELIST:map.png", list2, _US(Utils::String::Number(FILETYPE_MAP)));
|
| - |
|
50 |
this->AddImage("$IMAGELIST:mods.png", list2, _US(Utils::String::Number(FILETYPE_MOD)));
|
| - |
|
51 |
this->AddImage("$IMAGELIST:uninstall.png", list2, _US(Utils::String::Number(FILETYPE_UNINSTALL)));
|
| - |
|
52 |
this->AddImage("$IMAGELIST:sound.png", list2, _US(Utils::String::Number(FILETYPE_SOUND)));
|
| - |
|
53 |
this->AddImage("$IMAGELIST:extras.png", list2, _US(Utils::String::Number(FILETYPE_EXTRA)));
|
| - |
|
54 |
this->AddImage("$IMAGELIST:screenshot.png", list2, _US(Utils::String::Number(FILETYPE_SCREEN)));
|
| - |
|
55 |
this->AddImage("$IMAGELIST:backup.png", list2, _US(Utils::String::Number(FILETYPE_BACKUP)));
|
| - |
|
56 |
this->AddImage("$IMAGELIST:mission.png", list2, _US(Utils::String::Number(FILETYPE_MISSION)));
|
| - |
|
57 |
this->AddImage("$IMAGELIST:advert.png", list2, _US(Utils::String::Number(FILETYPE_ADVERT)));
|
| - |
|
58 |
this->AddImage("$IMAGELIST:shipother.png", list2, _US(Utils::String::Number(FILETYPE_SHIPOTHER)));
|
| - |
|
59 |
this->AddImage("$IMAGELIST:shipmodel.png", list2, _US(Utils::String::Number(FILETYPE_SHIPMODEL)));
|
| - |
|
60 |
this->AddImage("$IMAGELIST:shipscene.png", list2, _US(Utils::String::Number(FILETYPE_SHIPSCENE)));
|
| - |
|
61 |
this->AddImage("$IMAGELIST:cockpitscene.png", list2, _US(Utils::String::Number(FILETYPE_COCKPITSCENE)));
|
| - |
|
62 |
|
| - |
|
63 |
listView1->LargeImageList = list1;
|
| - |
|
64 |
listView1->SmallImageList = list2;
|
| - |
|
65 |
|
| - |
|
66 |
m_bLoading = false;
|
| - |
|
67 |
this->MdiParent = parent;
|
| - |
|
68 |
m_pTabCtrl = ctrl;
|
| - |
|
69 |
m_pTabPage = page;
|
| - |
|
70 |
|
| - |
|
71 |
m_bSortingAsc = true;
|
| - |
|
72 |
m_iSortingCol = 1;
|
| - |
|
73 |
m_bSortingAsc2 = true;
|
| - |
|
74 |
m_iSortingCol2 = 1;
|
| - |
|
75 |
m_pListItem = nullptr;
|
| - |
|
76 |
|
| - |
|
77 |
_pPackages = new CPackages();
|
| - |
|
78 |
_pPackages->startup(".", ".", ".");
|
| - |
|
79 |
|
| - |
|
80 |
this->Closing += gcnew CancelEventHandler(this, &SpkForm::Event_Closing);
|
| - |
|
81 |
this->Activated += gcnew System::EventHandler(this, &SpkForm::Event_Activated);
|
| - |
|
82 |
this->listView1->ColumnClick += gcnew ColumnClickEventHandler(this, &SpkForm::SortList);
|
| - |
|
83 |
this->contextMenuStrip1->Opening += gcnew CancelEventHandler(this, &SpkExplorer::SpkForm::OpenContextMenu);
|
| - |
|
84 |
this->listView1->DragOver += gcnew DragEventHandler(this, &SpkExplorer::SpkForm::DragEnterEvent);
|
| - |
|
85 |
this->listView1->ItemDrag += gcnew ItemDragEventHandler(this, &SpkExplorer::SpkForm::ItemDragEvent);
|
| - |
|
86 |
|
| - |
|
87 |
m_pSelectedPackage = NULL;
|
| - |
|
88 |
m_pPackage = NULL;
|
| - |
|
89 |
m_pMultiPackage = NULL;
|
| - |
|
90 |
}
|
| - |
|
91 |
|
| - |
|
92 |
SpkForm::~SpkForm()
|
| - |
|
93 |
{
|
| - |
|
94 |
delete m_pMenuItem;
|
| - |
|
95 |
if (components)
|
| - |
|
96 |
{
|
| - |
|
97 |
delete components;
|
| - |
|
98 |
}
|
| - |
|
99 |
|
| - |
|
100 |
delete _pPackages;
|
| - |
|
101 |
}
|
| - |
|
102 |
|
| - |
|
103 |
bool SpkForm::IsMultiPackage()
|
| - |
|
104 |
{
|
| - |
|
105 |
return (m_pMultiPackage) ? true : false;
|
| - |
|
106 |
}
|
| - |
|
107 |
|
| - |
|
108 |
void SpkForm::SetToolButton(ToolStripMenuItem ^menu)
|
| - |
|
109 |
{
|
| - |
|
110 |
m_pMenuItem = menu;
|
| - |
|
111 |
}
|
| - |
|
112 |
|
| 17 |
void SpkForm::SetPackage(CBaseFile *p, System::String ^filename)
|
113 |
void SpkForm::SetPackage(CBaseFile *p, System::String ^filename)
|
| 18 |
{
|
114 |
{
|
| 19 |
this->splitContainer1->Panel1Collapsed = true;
|
115 |
this->splitContainer1->Panel1Collapsed = true;
|
| 20 |
m_pPackage = p;
|
116 |
m_pPackage = p;
|
| 21 |
|
117 |
|
| Line 83... |
Line 179... |
| 83 |
}
|
179 |
}
|
| 84 |
|
180 |
|
| 85 |
void SpkForm::UpdateView(bool onlyPackage)
|
181 |
void SpkForm::UpdateView(bool onlyPackage)
|
| 86 |
{
|
182 |
{
|
| 87 |
m_bLoading = true;
|
183 |
m_bLoading = true;
|
| 88 |
|
184 |
|
| 89 |
m_bSortingAsc = true;
|
185 |
m_bSortingAsc = true;
|
| 90 |
m_iSortingCol = 0;
|
186 |
m_iSortingCol = 0;
|
| 91 |
|
187 |
|
| 92 |
m_bSortingAsc2 = true;
|
188 |
m_bSortingAsc2 = true;
|
| 93 |
m_iSortingCol2 = 0;
|
189 |
m_iSortingCol2 = 0;
|
| 94 |
|
190 |
|
| 95 |
this->listView1->Items->Clear();
|
191 |
this->listView1->Items->Clear();
|
| 96 |
|
192 |
|
| 97 |
if ( m_pPackage )
|
193 |
if ( m_pPackage )
|
| 98 |
{
|
194 |
{
|
| 99 |
int pos = 0;
|
195 |
int pos = 0;
|
| Line 107... |
Line 203... |
| 107 |
|
203 |
|
| 108 |
this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
204 |
this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
| 109 |
this->listView1->ListViewItemSorter = gcnew ListViewItemComparer(m_iSortingCol, !m_bSortingAsc);
|
205 |
this->listView1->ListViewItemSorter = gcnew ListViewItemComparer(m_iSortingCol, !m_bSortingAsc);
|
| 110 |
|
206 |
|
| 111 |
if ( m_pMultiPackage && !onlyPackage )
|
207 |
if ( m_pMultiPackage && !onlyPackage )
|
| 112 |
{
|
208 |
{
|
| 113 |
this->listView2->Items->Clear();
|
209 |
this->listView2->Items->Clear();
|
| 114 |
int pos = 0;
|
210 |
int pos = 0;
|
| 115 |
for ( SMultiSpkFile *file = m_pMultiPackage->GetFileList()->First(); file; file = m_pMultiPackage->GetFileList()->Next() )
|
211 |
for ( SMultiSpkFile *file = m_pMultiPackage->GetFileList()->First(); file; file = m_pMultiPackage->GetFileList()->Next() )
|
| 116 |
{
|
212 |
{
|
| 117 |
file->iPos = pos++;
|
213 |
file->iPos = pos++;
|
| 118 |
this->AddMultiFile(file);
|
214 |
this->AddMultiFile(file);
|
| 119 |
}
|
215 |
}
|
| 120 |
listView2->ArrangeIcons();
|
216 |
listView2->ArrangeIcons();
|
| 121 |
|
217 |
|
| 122 |
this->listView2->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
218 |
this->listView2->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
| 123 |
this->listView2->ListViewItemSorter = gcnew ListViewItemComparer(m_iSortingCol2, !m_bSortingAsc2);
|
219 |
this->listView2->ListViewItemSorter = gcnew ListViewItemComparer(m_iSortingCol2, !m_bSortingAsc2);
|
| 124 |
}
|
220 |
}
|
| 125 |
|
221 |
|
| 126 |
|
222 |
|
| Line 131... |
Line 227... |
| 131 |
{
|
227 |
{
|
| 132 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SpkForm::typeid));
|
228 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SpkForm::typeid));
|
| 133 |
|
229 |
|
| 134 |
bool added = false;
|
230 |
bool added = false;
|
| 135 |
if ( filename->StartsWith("$RESOURCE:") )
|
231 |
if ( filename->StartsWith("$RESOURCE:") )
|
| 136 |
{
|
232 |
{
|
| 137 |
filename = filename->Remove(0, 10);
|
233 |
filename = filename->Remove(0, 10);
|
| 138 |
if ( filename->StartsWith("BITMAP:") )
|
234 |
if ( filename->StartsWith("BITMAP:") )
|
| 139 |
{
|
235 |
{
|
| 140 |
filename = filename->Remove(0, 7);
|
236 |
filename = filename->Remove(0, 7);
|
| 141 |
System::Drawing::Bitmap ^bitmap = (cli::safe_cast<System::Drawing::Bitmap^ >(resources->GetObject(filename)));
|
237 |
System::Drawing::Bitmap ^bitmap = (cli::safe_cast<System::Drawing::Bitmap^ >(resources->GetObject(filename)));
|
| Line 179... |
Line 275... |
| 179 |
{
|
275 |
{
|
| 180 |
IntPtr Hicon = myBitmap->GetHicon();
|
276 |
IntPtr Hicon = myBitmap->GetHicon();
|
| 181 |
System::Drawing::Icon ^newIcon = ::Icon::FromHandle(Hicon);
|
277 |
System::Drawing::Icon ^newIcon = ::Icon::FromHandle(Hicon);
|
| 182 |
list->Images->Add(key, newIcon);
|
278 |
list->Images->Add(key, newIcon);
|
| 183 |
added = true;
|
279 |
added = true;
|
| 184 |
}
|
280 |
}
|
| 185 |
}
|
281 |
}
|
| 186 |
}
|
282 |
}
|
| 187 |
|
283 |
|
| 188 |
if ( !added )
|
284 |
if ( !added )
|
| 189 |
{
|
285 |
{
|
| 190 |
System::Drawing::Icon ^icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
|
286 |
System::Drawing::Icon ^icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
|
| 191 |
list->Images->Add(key, icon);
|
287 |
list->Images->Add(key, icon);
|
| 192 |
}
|
288 |
}
|
| Line 198... |
Line 294... |
| 198 |
item->SubItems->Add(SystemStringFromCyString(file->GetUncompressedSizeString()));
|
294 |
item->SubItems->Add(SystemStringFromCyString(file->GetUncompressedSizeString()));
|
| 199 |
item->SubItems->Add(SystemStringFromCyString(file->GetFileTypeString()));
|
295 |
item->SubItems->Add(SystemStringFromCyString(file->GetFileTypeString()));
|
| 200 |
|
296 |
|
| 201 |
item->SubItems->Add(SystemStringFromCyString(file->GetCreationTimeString()));
|
297 |
item->SubItems->Add(SystemStringFromCyString(file->GetCreationTimeString()));
|
| 202 |
|
298 |
|
| 203 |
item->Tag = SystemStringFromCyString(CyString::Number(file->GetPos()));
|
299 |
item->Tag = _US(Utils::String::Number(file->GetPos()));
|
| 204 |
|
- |
|
| 205 |
item->ImageKey = SystemStringFromCyString(CyString::Number(file->GetFileType()));
|
- |
|
| 206 |
|
300 |
|
| - |
|
301 |
item->ImageKey = _US(Utils::String::Number(file->GetFileType()));
|
| - |
|
302 |
|
| 207 |
if ( !file->GetGame() ) {
|
303 |
if ( !file->game() || file->game() == GAME_ALLNEW) {
|
| 208 |
item->SubItems->Add("All Games");
|
304 |
item->SubItems->Add("All Games");
|
| 209 |
}
|
305 |
}
|
| 210 |
else {
|
306 |
else {
|
| - |
|
307 |
if (file->game() & GAME_ALLNEW)
|
| - |
|
308 |
{
|
| 211 |
CPackages p;
|
309 |
Utils::String sGames = "";
|
| - |
|
310 |
for (int i = 0; i < 31; ++i)
|
| - |
|
311 |
{
|
| - |
|
312 |
if (file->game() & (1 << i))
|
| - |
|
313 |
{
|
| 212 |
p.Startup(".", ".", ".");
|
314 |
Utils::String sGame;
|
| 213 |
SGameExe *exe = p.GetGameExe()->GetGame(file->GetGame() - 1);
|
315 |
SGameExe *exe = _pPackages->GetGameExe()->GetGame(i - 1);
|
| - |
|
316 |
sGame = (exe) ? exe->sName : ("Game: " + Utils::String::Number(i));
|
| - |
|
317 |
|
| 214 |
if ( exe ) {
|
318 |
if (sGames.empty())
|
| - |
|
319 |
sGames = sGame;
|
| - |
|
320 |
else
|
| - |
|
321 |
sGames = sGames + "\n" + sGame;
|
| - |
|
322 |
}
|
| - |
|
323 |
}
|
| - |
|
324 |
if(sGames.empty())
|
| 215 |
item->SubItems->Add(SystemStringFromCyString(exe->sName));
|
325 |
item->SubItems->Add(_US("All Games"));
|
| - |
|
326 |
else
|
| - |
|
327 |
item->SubItems->Add(_US(sGames));
|
| 216 |
}
|
328 |
}
|
| - |
|
329 |
else
|
| - |
|
330 |
{
|
| - |
|
331 |
SGameExe *exe = _pPackages->GetGameExe()->GetGame(file->game() - 1);
|
| - |
|
332 |
if (exe) {
|
| - |
|
333 |
item->SubItems->Add(_US(exe->sName));
|
| - |
|
334 |
}
|
| 217 |
else {
|
335 |
else {
|
| 218 |
item->SubItems->Add("Game: " + file->GetGame());
|
336 |
item->SubItems->Add("Game: " + file->game());
|
| - |
|
337 |
}
|
| 219 |
}
|
338 |
}
|
| 220 |
}
|
339 |
}
|
| 221 |
|
340 |
|
| 222 |
this->listView1->Items->Add(item);
|
341 |
this->listView1->Items->Add(item);
|
| 223 |
}
|
342 |
}
|
| Line 230... |
Line 349... |
| 230 |
else
|
349 |
else
|
| 231 |
item->SubItems->Add("Package");
|
350 |
item->SubItems->Add("Package");
|
| 232 |
item->SubItems->Add(SystemStringFromCyString(SPK::GetSizeString(file->lSize)));
|
351 |
item->SubItems->Add(SystemStringFromCyString(SPK::GetSizeString(file->lSize)));
|
| 233 |
|
352 |
|
| 234 |
|
353 |
|
| 235 |
item->Tag = SystemStringFromCyString(CyString::Number(file->iPos));
|
354 |
item->Tag = _US(Utils::String::Number(file->iPos));
|
| 236 |
|
355 |
|
| 237 |
if ( this->imageList1->Images->IndexOfKey(SystemStringFromCyString(file->sName)) == -1 )
|
356 |
if ( this->imageList1->Images->IndexOfKey(SystemStringFromCyString(file->sName)) == -1 )
|
| 238 |
item->ImageKey = "package";
|
357 |
item->ImageKey = "package";
|
| 239 |
else
|
358 |
else
|
| 240 |
item->ImageKey = SystemStringFromCyString(file->sName);
|
359 |
item->ImageKey = SystemStringFromCyString(file->sName);
|
| Line 318... |
Line 437... |
| 318 |
|
437 |
|
| 319 |
// read the spk file to memory before trying to extract its files
|
438 |
// read the spk file to memory before trying to extract its files
|
| 320 |
if ( !this->ReadMultiPackage() )
|
439 |
if ( !this->ReadMultiPackage() )
|
| 321 |
return;
|
440 |
return;
|
| 322 |
|
441 |
|
| 323 |
ExtractDialog ^ed = gcnew ExtractDialog(list, toDir, m_pPackage, game);
|
442 |
ExtractDialog ^ed = gcnew ExtractDialog(list, toDir, m_pPackage, game, _pPackages);
|
| 324 |
ed->ShowDialog((Form1 ^)this->MdiParent);
|
443 |
ed->ShowDialog((Form1 ^)this->MdiParent);
|
| 325 |
|
444 |
|
| 326 |
if ( ed->OK() && !ed->Canceled() && ed->ExtractedCount() )
|
445 |
if ( ed->OK() && !ed->Canceled() && ed->ExtractedCount() )
|
| 327 |
MessageBox::Show(this, "Files have been extracting successfully to:\n" + toDir, "Extacted", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
446 |
MessageBox::Show(this, "Files have been extracting successfully to:\n" + toDir, "Extacted", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
| 328 |
}
|
447 |
}
|
| Line 350... |
Line 469... |
| 350 |
void SpkForm::DoPackageExtract(CLinkList<SMultiSpkFile> *list, System::String ^toDir)
|
469 |
void SpkForm::DoPackageExtract(CLinkList<SMultiSpkFile> *list, System::String ^toDir)
|
| 351 |
{
|
470 |
{
|
| 352 |
if ( !toDir )
|
471 |
if ( !toDir )
|
| 353 |
return;
|
472 |
return;
|
| 354 |
|
473 |
|
| 355 |
ExtractDialog ^ed = gcnew ExtractDialog(list, toDir, m_pMultiPackage);
|
474 |
ExtractDialog ^ed = gcnew ExtractDialog(list, toDir, m_pMultiPackage, _pPackages);
|
| 356 |
ed->ShowDialog((Form1 ^)this->MdiParent);
|
475 |
ed->ShowDialog((Form1 ^)this->MdiParent);
|
| 357 |
|
476 |
|
| 358 |
if ( ed->OK() && !ed->Canceled() )
|
477 |
if ( ed->OK() && !ed->Canceled() )
|
| 359 |
MessageBox::Show(this, "Files have been extracting successfully to:\n" + toDir, "Extacted", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
478 |
MessageBox::Show(this, "Files have been extracting successfully to:\n" + toDir, "Extacted", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
| 360 |
}
|
479 |
}
|