1 |
cycrow |
1 |
#include "../StdAfx.h"
|
|
|
2 |
#include "SpkForm.h"
|
|
|
3 |
|
|
|
4 |
#include "Form1.h"
|
|
|
5 |
#include "ExtractDialog.h"
|
|
|
6 |
#include "AddDialog.h"
|
|
|
7 |
#include "DropFileDialog.h"
|
|
|
8 |
|
|
|
9 |
#include "..\..\Creator\src\Forms\SelectGame.h"
|
|
|
10 |
|
|
|
11 |
#include <spk.h>
|
|
|
12 |
|
|
|
13 |
using namespace System::Windows;
|
|
|
14 |
using namespace System::Windows::Forms;
|
|
|
15 |
|
|
|
16 |
namespace SpkExplorer {
|
|
|
17 |
void SpkForm::SetPackage(CBaseFile *p, System::String ^filename)
|
|
|
18 |
{
|
|
|
19 |
this->splitContainer1->Panel1Collapsed = true;
|
|
|
20 |
m_pPackage = p;
|
|
|
21 |
|
|
|
22 |
m_pTabPage->Text = System::IO::FileInfo(filename).Name;
|
|
|
23 |
if ( p->GetFilename().Empty() )
|
|
|
24 |
p->SetFilename(CyStringFromSystemString(filename));
|
|
|
25 |
this->UpdateView(false);
|
|
|
26 |
m_pPackage->SetChanged(false);
|
|
|
27 |
|
|
|
28 |
this->Text = filename;
|
|
|
29 |
|
|
|
30 |
m_sFilename = filename;
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
void SpkForm::SetMultiPackage(CMultiSpkFile *p, System::String ^filename)
|
|
|
34 |
{
|
|
|
35 |
this->splitContainer1->Panel1Collapsed = false;
|
|
|
36 |
m_pMultiPackage = p;
|
|
|
37 |
|
|
|
38 |
m_pTabPage->Text = System::IO::FileInfo(filename).Name;
|
|
|
39 |
if ( p->GetFilename().Empty() )
|
|
|
40 |
p->SetFilename(CyStringFromSystemString(filename));
|
|
|
41 |
|
|
|
42 |
this->UpdateView(false);
|
|
|
43 |
|
|
|
44 |
this->Text = filename;
|
|
|
45 |
|
|
|
46 |
m_sFilename = filename;
|
|
|
47 |
|
|
|
48 |
// read the icons
|
|
|
49 |
for ( SMultiSpkFile *package = p->GetFileList()->First(); package; package = p->GetFileList()->Next() )
|
|
|
50 |
{
|
|
|
51 |
if ( !package->pFile )
|
|
|
52 |
continue;
|
|
|
53 |
if ( package->pFile->GetIcon() )
|
|
|
54 |
{
|
|
|
55 |
package->pFile->ReadIconFileToMemory();
|
|
|
56 |
CyString sIconFile = CyStringFromSystemString(IO::Path::GetTempPath()) + "\\" + CFileIO(package->sName).GetBaseName() + "." + package->pFile->GetIconExt();
|
|
|
57 |
if ( package->pFile->ExtractFile(package->pFile->GetIcon(), CFileIO(sIconFile).GetFullFilename(), false) )
|
|
|
58 |
{
|
|
|
59 |
String ^iconFile = SystemStringFromCyString(sIconFile);
|
|
|
60 |
if ( IO::File::Exists(iconFile) )
|
|
|
61 |
{
|
|
|
62 |
String ^file = SystemStringFromCyString(package->sName);
|
|
|
63 |
String ^ext = System::IO::FileInfo(iconFile).Extension;
|
|
|
64 |
if ( !String::Compare(ext, "bmp", false) || !String::Compare(ext, "ico", false) )
|
|
|
65 |
this->imageList1->Images->Add(file, Bitmap::FromFile(iconFile));
|
|
|
66 |
else
|
|
|
67 |
{
|
|
|
68 |
Bitmap ^myBitmap = gcnew Bitmap(iconFile);
|
|
|
69 |
if ( myBitmap )
|
|
|
70 |
this->imageList1->Images->Add(file, myBitmap);
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
bool SpkForm::CheckFilename(System::String ^filename)
|
|
|
79 |
{
|
|
|
80 |
if ( filename == m_sFilename )
|
|
|
81 |
return true;
|
|
|
82 |
return false;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
void SpkForm::UpdateView(bool onlyPackage)
|
|
|
86 |
{
|
|
|
87 |
m_bLoading = true;
|
|
|
88 |
|
|
|
89 |
m_bSortingAsc = true;
|
|
|
90 |
m_iSortingCol = 0;
|
|
|
91 |
|
|
|
92 |
m_bSortingAsc2 = true;
|
|
|
93 |
m_iSortingCol2 = 0;
|
|
|
94 |
|
|
|
95 |
this->listView1->Items->Clear();
|
|
|
96 |
|
|
|
97 |
if ( m_pPackage )
|
|
|
98 |
{
|
|
|
99 |
int pos = 0;
|
|
|
100 |
for ( C_File *file = m_pPackage->GetFileList()->First(); file; file = m_pPackage->GetFileList()->Next() )
|
|
|
101 |
{
|
|
|
102 |
file->SetPos(pos++);
|
|
|
103 |
this->AddFile(file);
|
|
|
104 |
}
|
|
|
105 |
}
|
|
|
106 |
listView1->ArrangeIcons();
|
|
|
107 |
|
|
|
108 |
this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
109 |
this->listView1->ListViewItemSorter = gcnew ListViewItemComparer(m_iSortingCol, !m_bSortingAsc);
|
|
|
110 |
|
|
|
111 |
if ( m_pMultiPackage && !onlyPackage )
|
|
|
112 |
{
|
|
|
113 |
this->listView2->Items->Clear();
|
|
|
114 |
int pos = 0;
|
|
|
115 |
for ( SMultiSpkFile *file = m_pMultiPackage->GetFileList()->First(); file; file = m_pMultiPackage->GetFileList()->Next() )
|
|
|
116 |
{
|
|
|
117 |
file->iPos = pos++;
|
|
|
118 |
this->AddMultiFile(file);
|
|
|
119 |
}
|
|
|
120 |
listView2->ArrangeIcons();
|
|
|
121 |
|
|
|
122 |
this->listView2->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
123 |
this->listView2->ListViewItemSorter = gcnew ListViewItemComparer(m_iSortingCol2, !m_bSortingAsc2);
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
m_bLoading = false;
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
void SpkForm::AddImage(System::String ^filename, ImageList ^list, System::String ^key)
|
|
|
131 |
{
|
|
|
132 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SpkForm::typeid));
|
|
|
133 |
|
|
|
134 |
bool added = false;
|
|
|
135 |
if ( filename->StartsWith("$RESOURCE:") )
|
|
|
136 |
{
|
|
|
137 |
filename = filename->Remove(0, 10);
|
|
|
138 |
if ( filename->StartsWith("BITMAP:") )
|
|
|
139 |
{
|
|
|
140 |
filename = filename->Remove(0, 7);
|
|
|
141 |
System::Drawing::Bitmap ^bitmap = (cli::safe_cast<System::Drawing::Bitmap^ >(resources->GetObject(filename)));
|
|
|
142 |
if ( bitmap )
|
|
|
143 |
{
|
|
|
144 |
IntPtr Hicon = bitmap->GetHicon();
|
|
|
145 |
System::Drawing::Icon ^newIcon = ::Icon::FromHandle(Hicon);
|
|
|
146 |
list->Images->Add(key, newIcon);
|
|
|
147 |
added = true;
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
else
|
|
|
151 |
{
|
|
|
152 |
System::Drawing::Icon ^icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(filename)));
|
|
|
153 |
list->Images->Add(key, icon);
|
|
|
154 |
added = true;
|
|
|
155 |
}
|
|
|
156 |
}
|
|
|
157 |
else if ( filename->StartsWith("$IMAGELIST:") )
|
|
|
158 |
{
|
|
|
159 |
filename = filename->Remove(0, 11);
|
|
|
160 |
int index = this->imageList1->Images->IndexOfKey(filename);
|
|
|
161 |
if ( index != -1 )
|
|
|
162 |
{
|
|
|
163 |
list->Images->Add(key, this->imageList1->Images[index]);
|
|
|
164 |
added = true;
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
else if ( System::IO::File::Exists(filename) )
|
|
|
168 |
{
|
|
|
169 |
CyString sF = CyStringFromSystemString(filename);
|
|
|
170 |
if ( CFileIO(sF).CheckFileExtension("bmp") )
|
|
|
171 |
{
|
|
|
172 |
list->Images->Add(key, Bitmap::FromFile(filename));
|
|
|
173 |
added = true;
|
|
|
174 |
}
|
|
|
175 |
else
|
|
|
176 |
{
|
|
|
177 |
Bitmap ^myBitmap = gcnew Bitmap(filename);
|
|
|
178 |
if ( myBitmap )
|
|
|
179 |
{
|
|
|
180 |
IntPtr Hicon = myBitmap->GetHicon();
|
|
|
181 |
System::Drawing::Icon ^newIcon = ::Icon::FromHandle(Hicon);
|
|
|
182 |
list->Images->Add(key, newIcon);
|
|
|
183 |
added = true;
|
|
|
184 |
}
|
|
|
185 |
}
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
if ( !added )
|
|
|
189 |
{
|
|
|
190 |
System::Drawing::Icon ^icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
|
|
|
191 |
list->Images->Add(key, icon);
|
|
|
192 |
}
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
void SpkForm::AddFile(C_File *file)
|
|
|
196 |
{
|
|
|
197 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(file->GetNameDirectory(NULL)));
|
|
|
198 |
item->SubItems->Add(SystemStringFromCyString(file->GetUncompressedSizeString()));
|
|
|
199 |
item->SubItems->Add(SystemStringFromCyString(file->GetFileTypeString()));
|
|
|
200 |
|
|
|
201 |
item->SubItems->Add(SystemStringFromCyString(file->GetCreationTimeString()));
|
|
|
202 |
|
|
|
203 |
item->Tag = SystemStringFromCyString(CyString::Number(file->GetPos()));
|
|
|
204 |
|
|
|
205 |
item->ImageKey = SystemStringFromCyString(CyString::Number(file->GetFileType()));
|
|
|
206 |
|
|
|
207 |
if ( !file->GetGame() ) {
|
|
|
208 |
item->SubItems->Add("All Games");
|
|
|
209 |
}
|
|
|
210 |
else {
|
|
|
211 |
CPackages p;
|
|
|
212 |
p.Startup(".", ".", ".");
|
|
|
213 |
SGameExe *exe = p.GetGameExe()->GetGame(file->GetGame() - 1);
|
|
|
214 |
if ( exe ) {
|
|
|
215 |
item->SubItems->Add(SystemStringFromCyString(exe->sName));
|
|
|
216 |
}
|
|
|
217 |
else {
|
|
|
218 |
item->SubItems->Add("Game: " + file->GetGame());
|
|
|
219 |
}
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
this->listView1->Items->Add(item);
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
void SpkForm::AddMultiFile(SMultiSpkFile *file)
|
|
|
226 |
{
|
|
|
227 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(file->sName));
|
|
|
228 |
if ( file->iType == TYPE_XSP )
|
|
|
229 |
item->SubItems->Add("Ship");
|
|
|
230 |
else
|
|
|
231 |
item->SubItems->Add("Package");
|
|
|
232 |
item->SubItems->Add(SystemStringFromCyString(SPK::GetSizeString(file->lSize)));
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
item->Tag = SystemStringFromCyString(CyString::Number(file->iPos));
|
|
|
236 |
|
|
|
237 |
if ( this->imageList1->Images->IndexOfKey(SystemStringFromCyString(file->sName)) == -1 )
|
|
|
238 |
item->ImageKey = "package";
|
|
|
239 |
else
|
|
|
240 |
item->ImageKey = SystemStringFromCyString(file->sName);
|
|
|
241 |
|
|
|
242 |
this->listView2->Items->Add(item);
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
System::Void SpkForm::Event_Activated(System::Object^ sender, System::EventArgs^ e)
|
|
|
246 |
{
|
|
|
247 |
m_pTabCtrl->SelectedTab = m_pTabPage;
|
|
|
248 |
this->Text = m_pTabPage->Text;
|
|
|
249 |
|
|
|
250 |
((Form1 ^)this->MdiParent)->UpdateDisplay();
|
|
|
251 |
|
|
|
252 |
this->SelectedCheck();
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
System::Void SpkForm::Event_Closing(System::Object^ sender, CancelEventArgs^ e)
|
|
|
256 |
{
|
|
|
257 |
delete m_pPackage;
|
|
|
258 |
delete m_pTabPage;
|
|
|
259 |
|
|
|
260 |
m_sFilename = "";
|
|
|
261 |
|
|
|
262 |
((Form1 ^)this->MdiParent)->RemoveCopied(true);
|
|
|
263 |
|
|
|
264 |
((Form1 ^)this->MdiParent)->UpdateDisplay();
|
|
|
265 |
((Form1 ^)this->MdiParent)->SelectedFile(false);
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
void SpkForm::SelectedCheck()
|
|
|
269 |
{
|
|
|
270 |
if ( m_pMultiPackage )
|
|
|
271 |
{
|
|
|
272 |
((Form1 ^)this->MdiParent)->SelectedPackage(this->IsSelected(), this->IsPackageSelected());
|
|
|
273 |
if ( this->IsPackageSelected() )
|
|
|
274 |
{
|
|
|
275 |
Point ^mousePoint = this->listView2->PointToClient(this->listView2->MousePosition);
|
|
|
276 |
ListViewItem ^item = this->listView2->GetItemAt(mousePoint->X, mousePoint->Y);
|
|
|
277 |
if ( item )
|
|
|
278 |
{
|
|
|
279 |
int num = System::Convert::ToInt32(item->Tag);
|
|
|
280 |
m_pSelectedPackage = m_pMultiPackage->GetFileList()->Get(num);
|
|
|
281 |
if ( m_pSelectedPackage )
|
|
|
282 |
{
|
|
|
283 |
m_pPackage = m_pSelectedPackage->pFile;
|
|
|
284 |
this->UpdateView(true);
|
|
|
285 |
}
|
|
|
286 |
}
|
|
|
287 |
}
|
|
|
288 |
else
|
|
|
289 |
{
|
|
|
290 |
m_pPackage = NULL;
|
|
|
291 |
m_pSelectedPackage = NULL;
|
|
|
292 |
this->UpdateView(true);
|
|
|
293 |
}
|
|
|
294 |
}
|
|
|
295 |
else
|
|
|
296 |
((Form1 ^)this->MdiParent)->SelectedFile(this->IsSelected());
|
|
|
297 |
}
|
|
|
298 |
|
|
|
299 |
bool SpkForm::IsSelected()
|
|
|
300 |
{
|
|
|
301 |
if ( this->listView1->SelectedItems->Count )
|
|
|
302 |
return true;
|
|
|
303 |
return false;
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
bool SpkForm::IsPackageSelected()
|
|
|
307 |
{
|
|
|
308 |
if ( this->listView2->SelectedItems->Count )
|
|
|
309 |
return true;
|
|
|
310 |
return false;
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
void SpkForm::DoExtract(CLinkList<C_File> *list, System::String ^toDir, int game)
|
|
|
314 |
{
|
|
|
315 |
if ( !toDir )
|
|
|
316 |
return;
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
// read the spk file to memory before trying to extract its files
|
|
|
320 |
if ( !this->ReadMultiPackage() )
|
|
|
321 |
return;
|
|
|
322 |
|
|
|
323 |
ExtractDialog ^ed = gcnew ExtractDialog(list, toDir, m_pPackage, game);
|
|
|
324 |
ed->ShowDialog((Form1 ^)this->MdiParent);
|
|
|
325 |
|
|
|
326 |
if ( ed->OK() && !ed->Canceled() && ed->ExtractedCount() )
|
|
|
327 |
MessageBox::Show(this, "Files have been extracting successfully to:\n" + toDir, "Extacted", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
bool SpkForm::ReadSelectedMultiPackage()
|
|
|
331 |
{
|
|
|
332 |
if ( m_pMultiPackage && m_pSelectedPackage )
|
|
|
333 |
{
|
|
|
334 |
if ( !m_pMultiPackage->ReadSpk(m_pSelectedPackage, SPKREAD_ALL) )
|
|
|
335 |
return false;
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
return true;
|
|
|
339 |
}
|
|
|
340 |
bool SpkForm::ReadMultiPackage()
|
|
|
341 |
{
|
|
|
342 |
if ( m_pMultiPackage )
|
|
|
343 |
{
|
|
|
344 |
if ( !m_pMultiPackage->ReadAllPackages(SPKREAD_ALL) )
|
|
|
345 |
return false;
|
|
|
346 |
}
|
|
|
347 |
|
|
|
348 |
return true;
|
|
|
349 |
}
|
|
|
350 |
void SpkForm::DoPackageExtract(CLinkList<SMultiSpkFile> *list, System::String ^toDir)
|
|
|
351 |
{
|
|
|
352 |
if ( !toDir )
|
|
|
353 |
return;
|
|
|
354 |
|
|
|
355 |
ExtractDialog ^ed = gcnew ExtractDialog(list, toDir, m_pMultiPackage);
|
|
|
356 |
ed->ShowDialog((Form1 ^)this->MdiParent);
|
|
|
357 |
|
|
|
358 |
if ( ed->OK() && !ed->Canceled() )
|
|
|
359 |
MessageBox::Show(this, "Files have been extracting successfully to:\n" + toDir, "Extacted", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
System::String ^SpkForm::GetExtractDir(bool package)
|
|
|
363 |
{
|
|
|
364 |
FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
|
|
|
365 |
if ( package )
|
|
|
366 |
fbd->Description = "Select the path to extract packages to";
|
|
|
367 |
else
|
|
|
368 |
fbd->Description = "Select the path to extract files to";
|
|
|
369 |
if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
370 |
return fbd->SelectedPath;
|
|
|
371 |
|
|
|
372 |
return nullptr;
|
|
|
373 |
}
|
|
|
374 |
|
|
|
375 |
void SpkForm::ExtractSelected(System::String ^toDir)
|
|
|
376 |
{
|
|
|
377 |
if ( !m_pPackage )
|
|
|
378 |
return;
|
|
|
379 |
|
|
|
380 |
CyString sToDir = CyStringFromSystemString(toDir);
|
|
|
381 |
|
|
|
382 |
CLinkList<C_File> list;
|
|
|
383 |
|
|
|
384 |
for ( int i = 0; i < this->listView1->SelectedItems->Count; i++ )
|
|
|
385 |
{
|
|
|
386 |
int pos = CyStringFromSystemString(cli::safe_cast<System::String ^>(this->listView1->SelectedItems[i]->Tag)).ToInt();
|
|
|
387 |
C_File *f = m_pPackage->GetFileList()->Get(pos);
|
|
|
388 |
list.push_back(f);
|
|
|
389 |
}
|
|
|
390 |
|
|
|
391 |
this->DoExtract(&list, toDir, -1);
|
|
|
392 |
list.clear();
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
void SpkForm::ExtractSelectedPackage(System::String ^toDir)
|
|
|
396 |
{
|
|
|
397 |
if ( !m_pMultiPackage )
|
|
|
398 |
return;
|
|
|
399 |
|
|
|
400 |
CyString sToDir = CyStringFromSystemString(toDir);
|
|
|
401 |
|
|
|
402 |
CLinkList<SMultiSpkFile> list;
|
|
|
403 |
|
|
|
404 |
for ( int i = 0; i < this->listView2->SelectedItems->Count; i++ )
|
|
|
405 |
{
|
|
|
406 |
int pos = CyStringFromSystemString(cli::safe_cast<System::String ^>(this->listView2->SelectedItems[i]->Tag)).ToInt();
|
|
|
407 |
SMultiSpkFile *mp = m_pMultiPackage->GetFileList()->Get(pos);
|
|
|
408 |
if ( mp )
|
|
|
409 |
list.push_back(mp);
|
|
|
410 |
}
|
|
|
411 |
|
|
|
412 |
this->DoPackageExtract(&list, toDir);
|
|
|
413 |
list.clear();
|
|
|
414 |
}
|
|
|
415 |
|
|
|
416 |
void SpkForm::RemoveItem(ListViewItem ^item)
|
|
|
417 |
{
|
|
|
418 |
if ( !item )
|
|
|
419 |
return;
|
|
|
420 |
|
|
|
421 |
AddDialog ^ad = gcnew AddDialog(m_pPackage, m_pMultiPackage);
|
|
|
422 |
ad->SetRemove();
|
|
|
423 |
|
|
|
424 |
int pos = CyStringFromSystemString(cli::safe_cast<System::String ^>(item->Tag)).ToInt();
|
|
|
425 |
C_File *f = m_pPackage->GetFileList()->Get(pos);
|
|
|
426 |
if ( f )
|
|
|
427 |
ad->AddFile(SystemStringFromCyString(f->GetName()), SystemStringFromCyString(f->GetDir()), f->GetFileType(), f->GetGame());
|
|
|
428 |
|
|
|
429 |
// remove the dat or cat file as well
|
|
|
430 |
if ( f->GetFileType() == FILETYPE_MOD )
|
|
|
431 |
{
|
|
|
432 |
if ( f->CheckFileExt("cat") )
|
|
|
433 |
{
|
|
|
434 |
C_File *datFile = m_pPackage->FindFile(CFileIO(f).ChangeFileExtension("dat"), FILETYPE_MOD, "", f->GetGame());
|
|
|
435 |
if ( datFile )
|
|
|
436 |
ad->AddFile(SystemStringFromCyString(datFile->GetName()), SystemStringFromCyString(datFile->GetDir()), datFile->GetFileType(), datFile->GetGame());
|
|
|
437 |
}
|
|
|
438 |
else if ( f->CheckFileExt("dat") )
|
|
|
439 |
{
|
|
|
440 |
C_File *datFile = m_pPackage->FindFile(CFileIO(f).ChangeFileExtension("cat"), FILETYPE_MOD, "", f->GetGame());
|
|
|
441 |
if ( datFile )
|
|
|
442 |
ad->AddFile(SystemStringFromCyString(datFile->GetName()), SystemStringFromCyString(datFile->GetDir()), datFile->GetFileType(), datFile->GetGame());
|
|
|
443 |
}
|
|
|
444 |
}
|
|
|
445 |
ad->ShowDialog(this);
|
|
|
446 |
this->UpdateView(true);
|
|
|
447 |
}
|
|
|
448 |
void SpkForm::RemoveSelected()
|
|
|
449 |
{
|
|
|
450 |
if ( !m_pPackage )
|
|
|
451 |
return;
|
|
|
452 |
|
|
|
453 |
AddDialog ^ad = gcnew AddDialog(m_pPackage, m_pMultiPackage);
|
|
|
454 |
ad->SetRemove();
|
|
|
455 |
|
|
|
456 |
for ( int i = 0; i < this->listView1->SelectedItems->Count; i++ )
|
|
|
457 |
{
|
|
|
458 |
int pos = CyStringFromSystemString(cli::safe_cast<System::String ^>(this->listView1->SelectedItems[i]->Tag)).ToInt();
|
|
|
459 |
C_File *f = m_pPackage->GetFileList()->Get(pos);
|
|
|
460 |
if ( f )
|
|
|
461 |
ad->AddFile(SystemStringFromCyString(f->GetName()), SystemStringFromCyString(f->GetDir()), f->GetFileType(), f->GetGame());
|
|
|
462 |
|
|
|
463 |
// remove the dat or cat file as well
|
|
|
464 |
if ( f->GetFileType() == FILETYPE_MOD )
|
|
|
465 |
{
|
|
|
466 |
if ( f->CheckFileExt("cat") )
|
|
|
467 |
{
|
|
|
468 |
C_File *datFile = m_pPackage->FindFile(CFileIO(f).ChangeFileExtension("dat"), FILETYPE_MOD, "", f->GetGame());
|
|
|
469 |
if ( datFile )
|
|
|
470 |
ad->AddFile(SystemStringFromCyString(datFile->GetName()), SystemStringFromCyString(datFile->GetDir()), datFile->GetFileType(), datFile->GetGame());
|
|
|
471 |
}
|
|
|
472 |
else if ( f->CheckFileExt("dat") )
|
|
|
473 |
{
|
|
|
474 |
C_File *datFile = m_pPackage->FindFile(CFileIO(f).ChangeFileExtension("cat"), FILETYPE_MOD, "", f->GetGame());
|
|
|
475 |
if ( datFile )
|
|
|
476 |
ad->AddFile(SystemStringFromCyString(datFile->GetName()), SystemStringFromCyString(datFile->GetDir()), datFile->GetFileType(), datFile->GetGame());
|
|
|
477 |
}
|
|
|
478 |
}
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
ad->ShowDialog(this);
|
|
|
482 |
|
|
|
483 |
this->UpdateView(true);
|
|
|
484 |
}
|
|
|
485 |
|
|
|
486 |
void SpkForm::RemoveSelectedPackage()
|
|
|
487 |
{
|
|
|
488 |
if ( !m_pMultiPackage )
|
|
|
489 |
return;
|
|
|
490 |
|
|
|
491 |
AddDialog ^ad = gcnew AddDialog(NULL, m_pMultiPackage);
|
|
|
492 |
ad->SetRemove();
|
|
|
493 |
|
|
|
494 |
for ( int i = 0; i < this->listView2->SelectedItems->Count; i++ )
|
|
|
495 |
{
|
|
|
496 |
int pos = System::Convert::ToInt32(this->listView2->SelectedItems[i]->Tag);
|
|
|
497 |
SMultiSpkFile *mp = m_pMultiPackage->GetFileList()->Get(pos);
|
|
|
498 |
if ( mp )
|
|
|
499 |
ad->AddFile(SystemStringFromCyString(mp->sName), "", -1, 0);
|
|
|
500 |
}
|
|
|
501 |
|
|
|
502 |
if ( ad->AnyFiles() )
|
|
|
503 |
{
|
|
|
504 |
ad->ShowDialog(this);
|
|
|
505 |
this->UpdateView(false);
|
|
|
506 |
}
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
void SpkForm::ExtractAll(System::String ^toDir)
|
|
|
510 |
{
|
|
|
511 |
int game = 0;
|
|
|
512 |
if ( m_pPackage->IsMultipleGamesInPackage() ) {
|
|
|
513 |
Creator::SelectGame ^selGame = gcnew Creator::SelectGame("Select game to extract", NULL);
|
|
|
514 |
if ( selGame->ShowDialog(this) == Windows::Forms::DialogResult::OK ) {
|
|
|
515 |
game = selGame->GetGame() + 1;
|
|
|
516 |
}
|
|
|
517 |
else
|
|
|
518 |
return;
|
|
|
519 |
|
|
|
520 |
}
|
|
|
521 |
else if ( m_pPackage->IsAnyGameInPackage() ) {
|
|
|
522 |
game = m_pPackage->FindFirstGameInPackage();
|
|
|
523 |
}
|
|
|
524 |
this->DoExtract(m_pPackage->GetFileList(), toDir, game);
|
|
|
525 |
}
|
|
|
526 |
|
|
|
527 |
void SpkForm::ExtractAllPackage(System::String ^toDir)
|
|
|
528 |
{
|
|
|
529 |
if ( !m_pMultiPackage )
|
|
|
530 |
return;
|
|
|
531 |
this->DoPackageExtract(m_pMultiPackage->GetFileList(), toDir);
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
System::Void SpkForm::DragEnterEvent(System::Object ^Sender, DragEventArgs ^E)
|
|
|
535 |
{
|
|
|
536 |
E->Effect = DragDropEffects::None;
|
|
|
537 |
|
|
|
538 |
if ( !m_pPackage )
|
|
|
539 |
return;
|
|
|
540 |
|
|
|
541 |
if ( ((Form1 ^)this->MdiParent)->DragFromForm() && ((Form1 ^)this->MdiParent)->DragFromForm() != this )
|
|
|
542 |
{
|
|
|
543 |
if ((E->KeyState & 4) == 4 && (E->AllowedEffect & DragDropEffects::Move) == DragDropEffects::Move)
|
|
|
544 |
E->Effect = DragDropEffects::Move;
|
|
|
545 |
else if ((E->KeyState & 8) == 8 && (E->AllowedEffect & DragDropEffects::Copy) == DragDropEffects::Copy)
|
|
|
546 |
E->Effect = DragDropEffects::Copy;
|
|
|
547 |
else if ((E->AllowedEffect & DragDropEffects::Move) == DragDropEffects::Move)
|
|
|
548 |
E->Effect = DragDropEffects::Move;
|
|
|
549 |
}
|
|
|
550 |
else if ( E->Data->GetDataPresent(DataFormats::FileDrop) )
|
|
|
551 |
E->Effect = DragDropEffects::Copy;
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
void SpkForm::DropGetDirectories(String ^dir, CyStringList *list, bool packages)
|
|
|
555 |
{
|
|
|
556 |
cli::array<String ^> ^dirList = IO::Directory::GetFileSystemEntries(dir);
|
|
|
557 |
for ( int j = 0; j < dirList->Length; j++ )
|
|
|
558 |
{
|
|
|
559 |
if ( IO::DirectoryInfo(dirList[j]).Exists )
|
|
|
560 |
this->DropGetDirectories(dirList[j], list, packages);
|
|
|
561 |
else
|
|
|
562 |
{
|
|
|
563 |
if ( packages )
|
|
|
564 |
list->PushBack(CyStringFromSystemString(dirList[j]), "-1");
|
|
|
565 |
else
|
18 |
cycrow |
566 |
list->PushBack(CyStringFromSystemString(dirList[j]), CyString::Number(SPK::GetAutomaticFiletype(CyStringFromSystemString(dirList[j]), NULL, false)));
|
1 |
cycrow |
567 |
}
|
|
|
568 |
}
|
|
|
569 |
}
|
|
|
570 |
|
|
|
571 |
System::Void SpkForm::listView2_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ E)
|
|
|
572 |
{
|
|
|
573 |
if ( !m_pMultiPackage )
|
|
|
574 |
return;
|
|
|
575 |
|
|
|
576 |
if ( E->Data->GetDataPresent(DataFormats::FileDrop) )
|
|
|
577 |
{
|
|
|
578 |
CyStringList fileList;
|
|
|
579 |
cli::array<String ^> ^a = (cli::array<String ^> ^)E->Data->GetData(DataFormats::FileDrop, false);
|
|
|
580 |
int i;
|
|
|
581 |
for(i = 0; i < a->Length; i++)
|
|
|
582 |
{
|
|
|
583 |
if ( IO::DirectoryInfo(a[i]).Exists )
|
|
|
584 |
this->DropGetDirectories(a[i], &fileList, true);
|
|
|
585 |
else
|
|
|
586 |
fileList.PushBack(CyStringFromSystemString(a[i]), "-1");
|
|
|
587 |
}
|
|
|
588 |
|
|
|
589 |
// remove invalid files
|
|
|
590 |
if ( !fileList.Empty() )
|
|
|
591 |
{
|
|
|
592 |
AddDialog ^ad = gcnew AddDialog(NULL, m_pMultiPackage);
|
|
|
593 |
for ( SStringList *str = fileList.Head(); str; str = str->next )
|
|
|
594 |
{
|
|
|
595 |
if ( str->data != "-1" )
|
|
|
596 |
continue;
|
|
|
597 |
|
|
|
598 |
CyString ext = CFileIO(str->str).GetFileExtension();
|
|
|
599 |
if ( !ext.Compare("xsp") && !ext.Compare("spk") )
|
|
|
600 |
continue;
|
|
|
601 |
|
|
|
602 |
ad->AddFile(SystemStringFromCyString(str->str), "", -1, 0);
|
|
|
603 |
}
|
|
|
604 |
|
|
|
605 |
ad->ShowDialog(this);
|
|
|
606 |
this->UpdateView(false);
|
|
|
607 |
}
|
|
|
608 |
}
|
|
|
609 |
}
|
|
|
610 |
|
|
|
611 |
System::Void SpkForm::listView1_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ E)
|
|
|
612 |
{
|
|
|
613 |
// dropping from outside
|
|
|
614 |
if ( E->Data->GetDataPresent(DataFormats::FileDrop) )
|
|
|
615 |
{
|
|
|
616 |
CyStringList fileList;
|
|
|
617 |
cli::array<String ^> ^a = (cli::array<String ^> ^)E->Data->GetData(DataFormats::FileDrop, false);
|
|
|
618 |
int i;
|
|
|
619 |
for(i = 0; i < a->Length; i++)
|
|
|
620 |
{
|
|
|
621 |
if ( IO::DirectoryInfo(a[i]).Exists )
|
|
|
622 |
this->DropGetDirectories(a[i], &fileList, false);
|
|
|
623 |
else
|
18 |
cycrow |
624 |
fileList.PushBack(CyStringFromSystemString(a[i]), CyString::Number(SPK::GetAutomaticFiletype(CyStringFromSystemString(a[i]), NULL, false)));
|
1 |
cycrow |
625 |
}
|
|
|
626 |
|
|
|
627 |
SPK::AssignAutomaticFiletypes(&fileList);
|
|
|
628 |
|
|
|
629 |
if ( !fileList.Empty() )
|
|
|
630 |
{
|
|
|
631 |
DropFileDialog ^dropType = gcnew DropFileDialog(&fileList);
|
|
|
632 |
if ( dropType->ShowDialog(this) == Forms::DialogResult::OK )
|
|
|
633 |
{
|
|
|
634 |
AddDialog ^ad = gcnew AddDialog(m_pPackage, NULL);
|
|
|
635 |
for ( SStringList *str = fileList.Head(); str; str = str->next )
|
|
|
636 |
{
|
|
|
637 |
int type = str->data.GetToken(" ", 1, 1).ToInt();
|
|
|
638 |
if ( type == -1 )
|
|
|
639 |
continue;
|
|
|
640 |
ad->AddFile(SystemStringFromCyString(str->str), "", type, 0);
|
|
|
641 |
}
|
|
|
642 |
if ( ad->AnyFiles() )
|
|
|
643 |
{
|
|
|
644 |
ad->ShowDialog(this);
|
|
|
645 |
this->UpdateView(false);
|
|
|
646 |
}
|
|
|
647 |
}
|
|
|
648 |
}
|
|
|
649 |
return;
|
|
|
650 |
}
|
|
|
651 |
|
|
|
652 |
bool copy = false;
|
|
|
653 |
|
|
|
654 |
if ((E->KeyState & 8) == 8 && (E->AllowedEffect & DragDropEffects::Copy) == DragDropEffects::Copy)
|
|
|
655 |
copy = true;
|
|
|
656 |
|
|
|
657 |
((Form1 ^)this->MdiParent)->Dragged(this, copy);
|
|
|
658 |
}
|
|
|
659 |
|
|
|
660 |
System::Void SpkForm::ItemDragEvent(System::Object ^Sender, ItemDragEventArgs ^E)
|
|
|
661 |
{
|
|
|
662 |
if ( this->listView1->SelectedItems->Count )
|
|
|
663 |
{
|
|
|
664 |
ListView::SelectedListViewItemCollection^ selected = this->listView1->SelectedItems;
|
|
|
665 |
System::Collections::IEnumerator^ myEnum = selected->GetEnumerator();
|
|
|
666 |
ArrayList ^list = gcnew ArrayList();
|
|
|
667 |
while ( myEnum->MoveNext() )
|
|
|
668 |
{
|
|
|
669 |
C_File *f = this->GetFileFromItem(safe_cast<ListViewItem ^>(myEnum->Current));
|
|
|
670 |
((Form1 ^)this->MdiParent)->DragFile(f, this);
|
|
|
671 |
//f->GetFilePointer()
|
|
|
672 |
list->Add(safe_cast<ListViewItem ^>(myEnum->Current)->Text);
|
|
|
673 |
}
|
|
|
674 |
|
|
|
675 |
DataObject ^data = gcnew DataObject(DataFormats::FileDrop, list);
|
|
|
676 |
|
|
|
677 |
for ( int i = 0; i < list->Count; i++ )
|
|
|
678 |
data->SetData(DataFormats::StringFormat, Convert::ToString(list[i]));
|
|
|
679 |
|
|
|
680 |
this->listView1->DoDragDrop(data, DragDropEffects::Move | DragDropEffects::Copy);
|
|
|
681 |
}
|
|
|
682 |
}
|
|
|
683 |
|
|
|
684 |
System::Void SpkForm::OpenContextMenu(System::Object ^Sender, CancelEventArgs ^E)
|
|
|
685 |
{
|
|
|
686 |
ListViewItem ^item = this->FindSelectedItem();
|
|
|
687 |
if ( item )
|
|
|
688 |
{
|
|
|
689 |
m_pListItem = item;
|
|
|
690 |
this->ContextName->Text = System::IO::FileInfo(item->Text).Name;
|
|
|
691 |
if ( item->ImageKey )
|
|
|
692 |
{
|
|
|
693 |
int key = this->listView1->LargeImageList->Images->IndexOfKey(item->ImageKey);
|
|
|
694 |
if ( key != -1 )
|
|
|
695 |
this->ContextName->Image = this->listView1->LargeImageList->Images[key];
|
|
|
696 |
}
|
|
|
697 |
|
|
|
698 |
if ( ((Form1 ^)this->MdiParent)->CopiedFiles()->empty() )
|
|
|
699 |
this->ToolPaste->Enabled = false;
|
|
|
700 |
else
|
|
|
701 |
this->ToolPaste->Enabled = true;
|
|
|
702 |
|
|
|
703 |
E->Cancel = false;
|
|
|
704 |
}
|
|
|
705 |
else
|
|
|
706 |
E->Cancel = true;
|
|
|
707 |
|
|
|
708 |
}
|
|
|
709 |
|
|
|
710 |
ListViewItem ^SpkForm::FindSelectedItem()
|
|
|
711 |
{
|
|
|
712 |
Point ^mousePoint = this->listView1->PointToClient(this->contextMenuStrip1->MousePosition);
|
|
|
713 |
return this->listView1->GetItemAt(mousePoint->X, mousePoint->Y);
|
|
|
714 |
}
|
|
|
715 |
|
|
|
716 |
C_File *SpkForm::GetFileFromItem(ListViewItem ^item)
|
|
|
717 |
{
|
|
|
718 |
int num = System::Convert::ToInt32(item->Tag);
|
|
|
719 |
return m_pPackage->GetFileList()->Get(num);
|
|
|
720 |
}
|
|
|
721 |
|
|
|
722 |
void SpkForm::CopyFile()
|
|
|
723 |
{
|
|
|
724 |
if ( !m_pListItem )
|
|
|
725 |
return;
|
|
|
726 |
C_File *f = this->GetFileFromItem(m_pListItem);
|
|
|
727 |
if ( f )
|
|
|
728 |
{
|
|
|
729 |
if ( m_pMultiPackage && m_pSelectedPackage )
|
|
|
730 |
m_pMultiPackage->ReadSpk(m_pSelectedPackage, SPKREAD_ALL);
|
|
|
731 |
else if ( !m_pMultiPackage )
|
|
|
732 |
m_pPackage->ReadFileToMemory(f);
|
|
|
733 |
else
|
|
|
734 |
return;
|
|
|
735 |
|
|
|
736 |
f = this->GetFileFromItem(m_pListItem);
|
|
|
737 |
((Form1 ^)this->MdiParent)->CopyFile(f, true);
|
|
|
738 |
}
|
|
|
739 |
}
|
|
|
740 |
|
|
|
741 |
void SpkForm::CutFile()
|
|
|
742 |
{
|
|
|
743 |
if ( !m_pListItem )
|
|
|
744 |
return;
|
|
|
745 |
C_File *f = this->GetFileFromItem(m_pListItem);
|
|
|
746 |
if ( f )
|
|
|
747 |
{
|
|
|
748 |
if ( !this->ReadPackageFiles(false) )
|
|
|
749 |
return;
|
|
|
750 |
f = this->GetFileFromItem(m_pListItem);
|
|
|
751 |
if ( f )
|
|
|
752 |
{
|
|
|
753 |
((Form1 ^)this->MdiParent)->CutFile(f, this, true);
|
|
|
754 |
m_pPackage->GetFileList()->remove(f, false);
|
|
|
755 |
|
|
|
756 |
this->WritePackage();
|
|
|
757 |
this->UpdateView(true);
|
|
|
758 |
}
|
|
|
759 |
}
|
|
|
760 |
}
|
|
|
761 |
|
|
|
762 |
void SpkForm::DroppedFile(C_File *f)
|
|
|
763 |
{
|
|
|
764 |
if ( m_pPackage->GetFileList()->FindData(f) )
|
|
|
765 |
return;
|
|
|
766 |
|
|
|
767 |
this->ReadPackageFiles(false);
|
|
|
768 |
m_pPackage->AddFile(f);
|
|
|
769 |
this->WritePackage();
|
|
|
770 |
this->UpdateView(true);
|
|
|
771 |
}
|
|
|
772 |
|
|
|
773 |
void SpkForm::DraggedFile(C_File *f)
|
|
|
774 |
{
|
|
|
775 |
if ( !m_pPackage )
|
|
|
776 |
return;
|
|
|
777 |
|
|
|
778 |
if ( !m_pPackage->GetFileList()->FindData(f) )
|
|
|
779 |
return;
|
|
|
780 |
|
|
|
781 |
this->ReadPackageFiles(false);
|
|
|
782 |
m_pPackage->GetFileList()->remove(f, false);
|
|
|
783 |
this->WritePackage();
|
|
|
784 |
this->UpdateView(true);
|
|
|
785 |
}
|
|
|
786 |
|
|
|
787 |
bool SpkForm::ReadPackageFiles(bool all)
|
|
|
788 |
{
|
|
|
789 |
if ( m_pMultiPackage )
|
|
|
790 |
{
|
|
|
791 |
if ( all )
|
|
|
792 |
{
|
|
|
793 |
if ( !m_pMultiPackage->ReadAllPackages(SPKREAD_ALL) )
|
|
|
794 |
return false;
|
|
|
795 |
}
|
|
|
796 |
else if ( m_pSelectedPackage )
|
|
|
797 |
{
|
|
|
798 |
if ( !m_pMultiPackage->ReadSpk(m_pSelectedPackage, SPKREAD_ALL) )
|
|
|
799 |
return false;
|
|
|
800 |
}
|
|
|
801 |
}
|
|
|
802 |
else
|
|
|
803 |
m_pPackage->ReadAllFilesToMemory();
|
|
|
804 |
return true;
|
|
|
805 |
}
|
|
|
806 |
|
|
|
807 |
void SpkForm::WritePackage()
|
|
|
808 |
{
|
|
|
809 |
if ( m_pMultiPackage )
|
|
|
810 |
{
|
|
|
811 |
m_pMultiPackage->ReadAllPackages();
|
|
|
812 |
m_pMultiPackage->UpdatedPackage(m_pPackage);
|
|
|
813 |
m_pMultiPackage->WriteFile(m_pMultiPackage->GetFilename());
|
|
|
814 |
}
|
|
|
815 |
else
|
|
|
816 |
m_pPackage->WriteFile(m_pPackage->GetFilename());
|
|
|
817 |
}
|
|
|
818 |
|
|
|
819 |
void SpkForm::PasteFiles(CLinkList<C_File> *list)
|
|
|
820 |
{
|
|
|
821 |
if ( m_pMultiPackage && m_pSelectedPackage )
|
|
|
822 |
m_pMultiPackage->ReadSpk(m_pSelectedPackage, SPKREAD_ALL);
|
|
|
823 |
else if ( !m_pMultiPackage )
|
|
|
824 |
m_pPackage->ReadAllFilesToMemory();
|
|
|
825 |
else
|
|
|
826 |
return;
|
|
|
827 |
|
|
|
828 |
for ( C_File *f = list->First(); f; f= list->Next() )
|
|
|
829 |
{
|
|
|
830 |
// check if we copied this file already
|
|
|
831 |
if ( m_pPackage->GetFileList()->FindData(f) )
|
|
|
832 |
continue;
|
|
|
833 |
|
|
|
834 |
m_pPackage->AddFile(f);
|
|
|
835 |
}
|
|
|
836 |
((Form1 ^)this->MdiParent)->PastedFiles();
|
|
|
837 |
this->WritePackage();
|
|
|
838 |
this->UpdateView(true);
|
|
|
839 |
}
|
|
|
840 |
|
|
|
841 |
void SpkForm::PasteFile()
|
|
|
842 |
{
|
|
|
843 |
if ( ((Form1 ^)this->MdiParent)->CopiedFiles()->empty() )
|
|
|
844 |
return;
|
|
|
845 |
|
|
|
846 |
this->PasteFiles(((Form1 ^)this->MdiParent)->CopiedFiles());
|
|
|
847 |
}
|
|
|
848 |
|
|
|
849 |
void SpkForm::RestoreCut(CLinkList<C_File> *files)
|
|
|
850 |
{
|
|
|
851 |
for ( C_File *f = files->First(); f; f = files->Next() )
|
|
|
852 |
m_pPackage->AddFile(f);
|
|
|
853 |
this->WritePackage();
|
|
|
854 |
this->UpdateView(true);
|
|
|
855 |
}
|
|
|
856 |
|
|
|
857 |
void SpkForm::RunFile(ListViewItem ^item)
|
|
|
858 |
{
|
|
|
859 |
if ( !item )
|
|
|
860 |
return;
|
|
|
861 |
|
|
|
862 |
C_File *f = this->GetFileFromItem(item);
|
|
|
863 |
if ( !f )
|
|
|
864 |
return;
|
|
|
865 |
|
|
|
866 |
if ( m_pMultiPackage && m_pSelectedPackage )
|
|
|
867 |
{
|
|
|
868 |
m_pMultiPackage->ReadSpk(m_pSelectedPackage, SPKREAD_ALL);
|
|
|
869 |
C_File *f = this->GetFileFromItem(item);
|
|
|
870 |
if ( !f )
|
|
|
871 |
return;
|
|
|
872 |
}
|
|
|
873 |
|
|
|
874 |
Diagnostics::Process ^process = gcnew Diagnostics::Process();
|
|
|
875 |
try {
|
|
|
876 |
process->StartInfo->WorkingDirectory = IO::Path::GetTempPath();
|
|
|
877 |
|
|
|
878 |
switch ( f->GetFileType() )
|
|
|
879 |
{
|
|
|
880 |
case FILETYPE_SCRIPT:
|
|
|
881 |
case FILETYPE_UNINSTALL:
|
|
|
882 |
if ( m_pPackage->ExtractFile(f, CyStringFromSystemString(IO::Path::GetTempPath()), false) )
|
|
|
883 |
{
|
|
|
884 |
SPK::WriteScriptStyleSheet(CyStringFromSystemString(IO::Path::GetTempPath()));
|
|
|
885 |
process->StartInfo->FileName = IO::Path::GetTempPath() + "\\" + SystemStringFromCyString(f->GetName());
|
|
|
886 |
}
|
|
|
887 |
break;
|
|
|
888 |
|
|
|
889 |
case FILETYPE_MOD:
|
|
|
890 |
if ( m_pPackage->ExtractFile(f, CyStringFromSystemString(IO::Path::GetTempPath()), false) )
|
|
|
891 |
{
|
|
|
892 |
if ( f->CheckFileExt("cat") )
|
|
|
893 |
{
|
|
|
894 |
C_File *datFile = m_pPackage->FindFile(CFileIO(f).ChangeFileExtension("dat"), FILETYPE_MOD, "");
|
|
|
895 |
if ( datFile )
|
|
|
896 |
{
|
|
|
897 |
if ( m_pPackage->ExtractFile(datFile, CyStringFromSystemString(IO::Path::GetTempPath()), false) )
|
|
|
898 |
process->StartInfo->FileName = IO::Path::GetTempPath() + "\\" + SystemStringFromCyString(f->GetName());
|
|
|
899 |
}
|
|
|
900 |
}
|
|
|
901 |
else if ( f->CheckFileExt("dat") )
|
|
|
902 |
{
|
|
|
903 |
C_File *catFile = m_pPackage->FindFile(CFileIO(f).ChangeFileExtension("cat"), FILETYPE_MOD, "");
|
|
|
904 |
if ( catFile )
|
|
|
905 |
{
|
|
|
906 |
if ( m_pPackage->ExtractFile(catFile, CyStringFromSystemString(IO::Path::GetTempPath()), false) )
|
|
|
907 |
process->StartInfo->FileName = IO::Path::GetTempPath() + "\\" + SystemStringFromCyString(catFile->GetName());
|
|
|
908 |
}
|
|
|
909 |
}
|
|
|
910 |
}
|
|
|
911 |
break;
|
|
|
912 |
|
|
|
913 |
case FILETYPE_MAP:
|
|
|
914 |
break;
|
|
|
915 |
|
|
|
916 |
default:
|
|
|
917 |
if ( m_pPackage->ExtractFile(f, CyStringFromSystemString(IO::Path::GetTempPath()), false) )
|
|
|
918 |
process->StartInfo->FileName = IO::Path::GetTempPath() + "\\" + SystemStringFromCyString(f->GetName());
|
|
|
919 |
}
|
|
|
920 |
|
|
|
921 |
if ( process->StartInfo->FileName && process->StartInfo->FileName->Length )
|
|
|
922 |
{
|
|
|
923 |
process->StartInfo->CreateNoWindow = true;
|
|
|
924 |
process->Start();
|
|
|
925 |
}
|
|
|
926 |
}
|
|
|
927 |
catch (System::Exception ^E)
|
|
|
928 |
{
|
|
|
929 |
MessageBox::Show(this, "Error opening file:\n" + SystemStringFromCyString(f->GetName()) + "\n\nError: " + E->GetType()->Name, "Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
930 |
}
|
|
|
931 |
}
|
|
|
932 |
}
|