Line 465... |
Line 465... |
465 |
else if ( p->IsAnyGameInPackage() ) {
|
465 |
else if ( p->IsAnyGameInPackage() ) {
|
466 |
game = p->FindFirstGameInPackage();
|
466 |
game = p->FindFirstGameInPackage();
|
467 |
}
|
467 |
}
|
468 |
|
468 |
|
469 |
if ( to && to->Length ) {
|
469 |
if ( to && to->Length ) {
|
470 |
CyString exportFilename = CFileIO(sFile).ChangeFileExtension("zip");
|
470 |
Utils::String exportFilename = CFileIO(sFile).ChangeFileExtension("zip").ToString();
|
471 |
if ( game ) {
|
471 |
if ( game ) {
|
472 |
exportFilename = CFileIO(exportFilename).GetDir() + "/" + CFileIO(exportFilename).baseName() + "_" + CBaseFile::ConvertGameToString(game) + ".zip";
|
472 |
exportFilename = CFileIO(exportFilename).dir() + "/" + CFileIO(exportFilename).baseName() + "_" + CBaseFile::ConvertGameToString(game) + ".zip";
|
473 |
}
|
473 |
}
|
474 |
if ( p->SaveToArchive(exportFilename, game) ) {
|
474 |
if ( p->SaveToArchive(exportFilename, game) ) {
|
475 |
String ^message = "Export: " + file + "\nTo: " + SystemStringFromCyString(CFileIO(exportFilename).GetFilename());
|
475 |
String ^message = "Export: " + file + "\nTo: " + _US(CFileIO(exportFilename).filename());
|
476 |
if ( game ) {
|
476 |
if ( game ) {
|
477 |
message += "\nGame: " + SystemStringFromCyString(m_pPackages->GetGameExe()->GetGame(game - 1)->sName);
|
477 |
message += "\nGame: " + SystemStringFromCyString(m_pPackages->GetGameExe()->GetGame(game - 1)->sName);
|
478 |
}
|
478 |
}
|
479 |
MessageBox::Show(this, message, "Exported Package", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
479 |
MessageBox::Show(this, message, "Exported Package", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
480 |
}
|
480 |
}
|
481 |
else {
|
481 |
else {
|
482 |
MessageBox::Show(this, "Error: Unable to export to:\n" + SystemStringFromCyString(exportFilename), "Error Export", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
482 |
MessageBox::Show(this, "Error: Unable to export to:\n" + _US(exportFilename), "Error Export", MessageBoxButtons::OK, MessageBoxIcon::Error); }
|
483 |
}
|
- |
|
484 |
}
|
483 |
}
|
485 |
}
|
484 |
}
|
486 |
}
|
485 |
}
|
487 |
|
486 |
|
488 |
void ExtractPackage(String ^file, bool here)
|
487 |
void ExtractPackage(String ^file, bool here)
|
489 |
{
|
488 |
{
|
490 |
CyString sFile = CyStringFromSystemString(file);
|
489 |
CyString sFile = CyStringFromSystemString(file);
|
491 |
int error = 0;
|
490 |
int error = 0;
|
492 |
|
491 |
|
493 |
CBaseFile *p = m_pPackages->OpenPackage(sFile, &error, 0, SPKREAD_NODATA);
|
492 |
CBaseFile *p = m_pPackages->OpenPackage(sFile, &error, 0, SPKREAD_NODATA);
|
494 |
if ( !p ) {
|
493 |
if ( !p ) {
|
495 |
MessageBox::Show(this, "Error: Unable to open package file\n" + file, "Error Opening", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
494 |
MessageBox::Show(this, "Error: Unable to open package file\n" + file, "Error Opening", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
Line 517... |
Line 516... |
517 |
else
|
516 |
else
|
518 |
to = nullptr;
|
517 |
to = nullptr;
|
519 |
}
|
518 |
}
|
520 |
else if ( p->IsAnyGameInPackage() ) {
|
519 |
else if ( p->IsAnyGameInPackage() ) {
|
521 |
game = p->FindFirstGameInPackage();
|
520 |
game = p->FindFirstGameInPackage();
|
522 |
}
|
521 |
}
|
523 |
|
522 |
|
524 |
if ( to && to->Length ) {
|
523 |
if ( to && to->Length ) {
|
525 |
if ( p->ExtractAll(CyStringFromSystemString(to), game, true) ) {
|
524 |
if ( p->ExtractAll(CyStringFromSystemString(to), game, true) ) {
|
526 |
String ^message = "Extracted: " + file + "\nTo: " + to;
|
525 |
String ^message = "Extracted: " + file + "\nTo: " + to;
|
527 |
if ( game ) {
|
526 |
if ( game ) {
|
Line 542... |
Line 541... |
542 |
CyString sFile = CyStringFromSystemString(file);
|
541 |
CyString sFile = CyStringFromSystemString(file);
|
543 |
CyStringList malformed, unknown;
|
542 |
CyStringList malformed, unknown;
|
544 |
CBaseFile *package = m_pPackages->LoadPackagerScript(sFile, -1, NULL, &malformed, &unknown);
|
543 |
CBaseFile *package = m_pPackages->LoadPackagerScript(sFile, -1, NULL, &malformed, &unknown);
|
545 |
if ( package )
|
544 |
if ( package )
|
546 |
{
|
545 |
{
|
547 |
CyString saveto = package->filename();
|
546 |
Utils::String saveto = package->filename();
|
548 |
saveto = saveto.FindReplace("$DEFAULTDIR", CFileIO(sFile).GetDir() + "/");
|
547 |
saveto = saveto.findReplace("$DEFAULTDIR", CFileIO(sFile).dir() + "/");
|
549 |
saveto = saveto.FindReplace("$PATH", CFileIO(sFile).GetDir());
|
548 |
saveto = saveto.findReplace("$PATH", CFileIO(sFile).dir());
|
550 |
saveto = saveto.FindReplace("\\", "/");
|
- |
|
551 |
saveto = saveto.FindReplace("//", "/");
|
549 |
saveto = saveto.asFilename();
|
- |
|
550 |
|
552 |
if ( !saveto.Right(4).Compare(".spk") && package->GetType() != TYPE_XSP )
|
551 |
if ( !saveto.right(4).Compare(".spk") && package->GetType() != TYPE_XSP )
|
553 |
saveto += ".spk";
|
552 |
saveto += ".spk";
|
554 |
else if ( !saveto.Right(4).Compare(".xsp") && package->GetType() == TYPE_XSP )
|
553 |
else if ( !saveto.right(4).Compare(".xsp") && package->GetType() == TYPE_XSP )
|
555 |
saveto += ".xsp";
|
554 |
saveto += ".xsp";
|
556 |
// write script
|
555 |
// write script
|
557 |
if ( package->WriteFile(saveto) ) {
|
556 |
if ( package->WriteFile(saveto) ) {
|
558 |
String ^message = "Package: " + SystemStringFromCyString(saveto) + " has been created\n";
|
557 |
String ^message = "Package: " + _US(saveto) + " has been created\n";
|
559 |
if ( package->AutoGenerateUpdateFile() )
|
558 |
if ( package->AutoGenerateUpdateFile() )
|
560 |
package->CreateUpdateFile(CFileIO(saveto).GetDir());
|
559 |
package->CreateUpdateFile(CFileIO(saveto).dir());
|
561 |
CyString exportto = package->exportFilename();
|
560 |
Utils::String exportto = package->exportFilename();
|
562 |
if ( !exportto.Empty() ) {
|
561 |
if ( !exportto.empty() ) {
|
563 |
exportto = exportto.FindReplace("$DEFAULTDIR", CFileIO(sFile).GetDir() + "/");
|
562 |
exportto = exportto.findReplace("$DEFAULTDIR", CFileIO(sFile).dir() + "/");
|
564 |
exportto = exportto.FindReplace("$PATH", CFileIO(sFile).GetDir());
|
563 |
exportto = exportto.findReplace("$PATH", CFileIO(sFile).dir());
|
565 |
exportto = exportto.FindReplace("\\", "/");
|
- |
|
566 |
exportto = exportto.FindReplace("//", "/");
|
564 |
exportto = exportto.asFilename();
|
567 |
if ( package->SaveToArchive(exportto, 0) ) {
|
565 |
if ( package->SaveToArchive(exportto, 0) ) {
|
568 |
message += "\nExported to:\n" + SystemStringFromCyString(exportto) + "\n";
|
566 |
message += "\nExported to:\n" + _US(exportto) + "\n";
|
569 |
if ( package->IsAnyGameInPackage() ) {
|
567 |
if ( package->IsAnyGameInPackage() ) {
|
570 |
for ( int i = 0; i < m_pPackages->GetGameExe()->GetNumGames(); i++ ) {
|
568 |
for ( int i = 0; i < m_pPackages->GetGameExe()->GetNumGames(); i++ ) {
|
571 |
if ( package->IsGameInPackage(i + 1) ) {
|
569 |
if ( package->IsGameInPackage(i + 1) ) {
|
572 |
CyString exportFile = CFileIO(saveto).GetDir() + "/" + CFileIO(saveto).baseName() + "_" + CBaseFile::ConvertGameToString(i + 1) + "." + CFileIO(exportto).GetFileExtension();
|
570 |
Utils::String exportFile = CFileIO(saveto).dir() + "/" + CFileIO(saveto).baseName() + "_" + CBaseFile::ConvertGameToString(i + 1) + "." + CFileIO(exportto).extension();
|
573 |
if ( package->SaveToArchive(exportFile, i + 1) ) {
|
571 |
if ( package->SaveToArchive(exportFile, i + 1) ) {
|
574 |
message += SystemStringFromCyString(CFileIO(exportFile).GetFilename()) + "\n";
|
572 |
message += _US(CFileIO(exportFile).filename()) + "\n";
|
575 |
}
|
573 |
}
|
576 |
}
|
574 |
}
|
577 |
}
|
575 |
}
|
578 |
}
|
576 |
}
|
579 |
}
|
577 |
}
|
Line 638... |
Line 636... |
638 |
if ( this->imageList1->Images->IndexOfKey(file) == -1 )
|
636 |
if ( this->imageList1->Images->IndexOfKey(file) == -1 )
|
639 |
{
|
637 |
{
|
640 |
if ( package->GetIcon() )
|
638 |
if ( package->GetIcon() )
|
641 |
{
|
639 |
{
|
642 |
package->ReadIconFileToMemory();
|
640 |
package->ReadIconFileToMemory();
|
643 |
CyString sIconFile = CyStringFromSystemString(IO::Path::GetTempPath()) + "\\" + CFileIO(sFile).baseName() + "." + package->GetIconExt();
|
641 |
Utils::String sIconFile = _S(IO::Path::GetTempPath()) + "\\" + CFileIO(sFile).baseName() + "." + package->GetIconExt().ToString();
|
644 |
if ( package->ExtractFile(package->GetIcon(), CFileIO(sIconFile).GetFullFilename(), false) )
|
642 |
if ( package->ExtractFile(package->GetIcon(), CFileIO(sIconFile).fullFilename(), false) )
|
645 |
{
|
643 |
{
|
646 |
String ^iconFile = SystemStringFromCyString(sIconFile);
|
644 |
String ^iconFile = _US(sIconFile);
|
647 |
if ( IO::File::Exists(iconFile) )
|
645 |
if ( IO::File::Exists(iconFile) )
|
648 |
{
|
646 |
{
|
649 |
String ^ext = System::IO::FileInfo(iconFile).Extension;
|
647 |
String ^ext = System::IO::FileInfo(iconFile).Extension;
|
650 |
if ( !String::Compare(ext, "bmp", false) || !String::Compare(ext, "ico", false) )
|
648 |
if ( !String::Compare(ext, "bmp", false) || !String::Compare(ext, "ico", false) )
|
651 |
this->imageList1->Images->Add(file, Bitmap::FromFile(iconFile));
|
649 |
this->imageList1->Images->Add(file, Bitmap::FromFile(iconFile));
|