Subversion Repositories spk

Rev

Rev 123 | Rev 127 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 123 Rev 126
Line 477... Line 477...
477
				if ( to && to->Length ) {
477
				if ( to && to->Length ) {
478
					Utils::String exportFilename = CFileIO(sFile).ChangeFileExtension("zip").ToString();
478
					Utils::String exportFilename = CFileIO(sFile).ChangeFileExtension("zip").ToString();
479
					if ( game ) {
479
					if ( game ) {
480
						exportFilename = CFileIO(exportFilename).dir() + "/" + CFileIO(exportFilename).baseName() + "_" + CBaseFile::ConvertGameToString(game) + ".zip";
480
						exportFilename = CFileIO(exportFilename).dir() + "/" + CFileIO(exportFilename).baseName() + "_" + CBaseFile::ConvertGameToString(game) + ".zip";
481
					}
481
					}
482
					if ( p->SaveToArchive(exportFilename, game) ) {
482
					if ( p->SaveToArchive(exportFilename, game, m_pPackages->GetGameExe()) ) {
483
						String ^message = "Export: " + file + "\nTo: " + _US(CFileIO(exportFilename).filename());
483
						String ^message = "Export: " + file + "\nTo: " + _US(CFileIO(exportFilename).filename());
484
						if ( game ) {
484
						if ( game ) {
485
							message += "\nGame: " + SystemStringFromCyString(m_pPackages->GetGameExe()->GetGame(game - 1)->sName);
485
							message += "\nGame: " + SystemStringFromCyString(m_pPackages->GetGameExe()->GetGame(game - 1)->sName);
486
						}
486
						}
487
						MessageBox::Show(this, message, "Exported Package", MessageBoxButtons::OK, MessageBoxIcon::Information);
487
						MessageBox::Show(this, message, "Exported Package", MessageBoxButtons::OK, MessageBoxIcon::Information);
Line 568... Line 568...
568
					Utils::String exportto = package->exportFilename();
568
					Utils::String exportto = package->exportFilename();
569
					if ( !exportto.empty() ) {
569
					if ( !exportto.empty() ) {
570
						exportto = exportto.findReplace("$DEFAULTDIR", CFileIO(sFile).dir() + "/");
570
						exportto = exportto.findReplace("$DEFAULTDIR", CFileIO(sFile).dir() + "/");
571
						exportto = exportto.findReplace("$PATH", CFileIO(sFile).dir());
571
						exportto = exportto.findReplace("$PATH", CFileIO(sFile).dir());
572
						exportto = exportto.asFilename();
572
						exportto = exportto.asFilename();
573
						if ( package->SaveToArchive(exportto, 0) ) {
573
						if ( package->SaveToArchive(exportto, 0, m_pPackages->GetGameExe()) ) {
574
							message += "\nExported to:\n" + _US(exportto) + "\n";
574
							message += "\nExported to:\n" + _US(exportto) + "\n";
575
							if ( package->IsAnyGameInPackage() ) {
575
							if ( package->IsAnyGameInPackage() ) {
576
								for ( int i = 0; i < m_pPackages->GetGameExe()->GetNumGames(); i++ ) {
576
								for ( int i = 0; i < m_pPackages->GetGameExe()->GetNumGames(); i++ ) {
577
									if ( package->IsGameInPackage(i + 1) ) {
577
									if ( package->IsGameInPackage(i + 1) ) {
578
										Utils::String exportFile = CFileIO(saveto).dir() + "/" + CFileIO(saveto).baseName() + "_" + CBaseFile::ConvertGameToString(i + 1) + "." + CFileIO(exportto).extension();
578
										Utils::String exportFile = CFileIO(saveto).dir() + "/" + CFileIO(saveto).baseName() + "_" + CBaseFile::ConvertGameToString(i + 1) + "." + CFileIO(exportto).extension();
579
										if ( package->SaveToArchive(exportFile, i + 1) ) {
579
										if ( package->SaveToArchive(exportFile, i + 1, m_pPackages->GetGameExe()) ) {
580
											message += _US(CFileIO(exportFile).filename()) + "\n";
580
											message += _US(CFileIO(exportFile).filename()) + "\n";
581
										}
581
										}
582
									}
582
									}
583
								}
583
								}
584
							}
584
							}
Line 742... Line 742...
742
		{
742
		{
743
			FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
743
			FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
744
			fbd->Description = "Select the path to generate the list from";
744
			fbd->Description = "Select the path to generate the list from";
745
			if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
745
			if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
746
			{
746
			{
747
				CyStringList filedata;
747
				Utils::CStringList filedata;
748
				for ( int type = 0; type < 2; type++ )
748
				for ( int type = 0; type < 2; type++ )
749
				{
749
				{
750
					array <System::String ^> ^Files = nullptr;
750
					array <System::String ^> ^Files = nullptr;
751
					if ( type == 0 )
751
					if ( type == 0 )
752
						Files = Directory::GetFiles(fbd->SelectedPath, "*.spk");
752
						Files = Directory::GetFiles(fbd->SelectedPath, "*.spk");
Line 755... Line 755...
755
					else
755
					else
756
						break;
756
						break;
757
 
757
 
758
					for ( int i = 0; i < Files->Length; i++ )
758
					for ( int i = 0; i < Files->Length; i++ )
759
					{
759
					{
760
						CyString file = CyStringFromSystemString(Files[i]);
760
						Utils::String file = _S(Files[i]);
761
						int error = 0;
761
						int error = 0;
762
						CBaseFile *p = m_pPackages->OpenPackage(file, &error, 0, SPKREAD_NODATA);
762
						CBaseFile *p = m_pPackages->OpenPackage(file, &error, 0, SPKREAD_NODATA);
763
						if ( !p )
763
						if ( !p )
764
							continue;
764
							continue;
765
 
765
 
766
						filedata.PushBack(CPackages::FormatAvailablePackageData(p));
766
						filedata.pushBack(CPackages::FormatAvailablePackageData(p));
767
						delete p;
767
						delete p;
768
					}
768
					}
769
				}
769
				}
770
 
770
 
771
				if ( filedata.Empty() )
771
				if ( filedata.empty() )
772
					MessageBox::Show(this, "No package files found in " + fbd->SelectedPath + "\nSelect a directory that contains spk/xsp files", "No Packages", MessageBoxButtons::OK, MessageBoxIcon::Error);
772
					MessageBox::Show(this, "No package files found in " + fbd->SelectedPath + "\nSelect a directory that contains spk/xsp files", "No Packages", MessageBoxButtons::OK, MessageBoxIcon::Error);
773
				else
773
				else
774
				{
774
				{
775
					CFileIO File(CyStringFromSystemString(fbd->SelectedPath) + "/xpackagedata.dat");
775
					CFileIO File(_S(fbd->SelectedPath) + "/xpackagedata.dat");
776
					if ( File.WriteFile(&filedata) )
776
					if ( File.writeFile(&filedata) )
777
						MessageBox::Show(this, "Data file generated for " + filedata.Count() + " packages\nDirectory: " + fbd->SelectedPath, "Web File Generated", MessageBoxButtons::OK, MessageBoxIcon::Information);
777
						MessageBox::Show(this, "Data file generated for " + filedata.size() + " packages\nDirectory: " + fbd->SelectedPath, "Web File Generated", MessageBoxButtons::OK, MessageBoxIcon::Information);
778
					else
778
					else
779
						MessageBox::Show(this, "Unable to write web data file in " + fbd->SelectedPath, "File Write Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
779
						MessageBox::Show(this, "Unable to write web data file in " + fbd->SelectedPath, "File Write Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
780
				}
780
				}
781
			}
781
			}
782
		}
782
		}