Subversion Repositories spk

Rev

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

Rev 223 Rev 224
Line 528... Line 528...
528
						game = p->FindFirstGameInPackage();
528
						game = p->FindFirstGameInPackage();
529
					}
529
					}
530
 
530
 
531
					if ( to && to->Length ) 
531
					if ( to && to->Length ) 
532
					{
532
					{
533
						if (m_pPackages->extractAll(p, _S(to), game, true)) 
533
						if (m_pPackages->extractAll(p, _WS(to), game, true)) 
534
						{
534
						{
535
							String ^message = "Extracted: " + file + "\nTo: " + to;
535
							String ^message = "Extracted: " + file + "\nTo: " + to;
536
							if ( game )
536
							if ( game )
537
								message += "\nGame: " + _US(m_pPackages->GetGameExe()->game(game - 1)->sName);
537
								message += "\nGame: " + _US(m_pPackages->GetGameExe()->game(game - 1)->sName);
538
							MessageBox::Show(this, message, "Extracted Package", MessageBoxButtons::OK, MessageBoxIcon::Information);
538
							MessageBox::Show(this, message, "Extracted Package", MessageBoxButtons::OK, MessageBoxIcon::Information);
Line 546... Line 546...
546
 
546
 
547
		void SavePackagerScript(String ^file)
547
		void SavePackagerScript(String ^file)
548
		{
548
		{
549
			Utils::WString sFile = _WS(file);
549
			Utils::WString sFile = _WS(file);
550
			Utils::WStringList malformed, unknown;
550
			Utils::WStringList malformed, unknown;
551
			CBaseFile *package = m_pPackages->loadPackagerScript(sFile.toString(), -1, NULL, &malformed, &unknown);
551
			CBaseFile *package = m_pPackages->loadPackagerScript(sFile, -1, NULL, &malformed, &unknown);
552
			if ( package )
552
			if ( package )
553
			{
553
			{
554
				Utils::WString saveto = package->filename();
554
				Utils::WString saveto = package->filename();
555
				saveto = saveto.findReplace(L"$DEFAULTDIR", CFileIO(sFile).dir() + L"/");
555
				saveto = saveto.findReplace(L"$DEFAULTDIR", CFileIO(sFile).dir() + L"/");
556
				saveto = saveto.findReplace(L"$PATH", CFileIO(sFile).dir());
556
				saveto = saveto.findReplace(L"$PATH", CFileIO(sFile).dir());
Line 559... Line 559...
559
				if ( !saveto.right(4).Compare(L".spk") && package->GetType() != TYPE_XSP )
559
				if ( !saveto.right(4).Compare(L".spk") && package->GetType() != TYPE_XSP )
560
					saveto += L".spk";
560
					saveto += L".spk";
561
				else if ( !saveto.right(4).Compare(L".xsp") && package->GetType() == TYPE_XSP )
561
				else if ( !saveto.right(4).Compare(L".xsp") && package->GetType() == TYPE_XSP )
562
					saveto += L".xsp";
562
					saveto += L".xsp";
563
				// write script
563
				// write script
564
				if ( package->writeFile(saveto.toString()) ) {
564
				if ( package->writeFile(saveto) ) {
565
					String ^message = "Package: " + _US(saveto) + " has been created\n";
565
					String ^message = "Package: " + _US(saveto) + " has been created\n";
566
					if ( package->AutoGenerateUpdateFile() )
566
					if ( package->AutoGenerateUpdateFile() )
567
						package->createUpdateFile(CFileIO(saveto).dir());
567
						package->createUpdateFile(CFileIO(saveto).dir());
568
					Utils::WString exportto = package->exportFilename();
568
					Utils::WString exportto = package->exportFilename();
569
					if ( !exportto.empty() ) {
569
					if ( !exportto.empty() ) {
570
						exportto = exportto.findReplace(L"$DEFAULTDIR", CFileIO(sFile).dir() + L"/");
570
						exportto = exportto.findReplace(L"$DEFAULTDIR", CFileIO(sFile).dir() + L"/");
571
						exportto = exportto.findReplace(L"$PATH", CFileIO(sFile).dir());
571
						exportto = exportto.findReplace(L"$PATH", CFileIO(sFile).dir());
572
						exportto = exportto.asFilename();
572
						exportto = exportto.asFilename();
573
						if ( package->saveToArchive(exportto.toString(), 0, m_pPackages->GetGameExe())) {
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()->numGames(); i++ ) {
576
								for ( int i = 0; i < m_pPackages->GetGameExe()->numGames(); i++ ) {
577
									if ( package->IsGameInPackage(i + 1) ) {
577
									if ( package->IsGameInPackage(i + 1) ) {
578
										Utils::WString exportFile = CFileIO(saveto).dir() + L"/" + CFileIO(saveto).baseName() + L"_" + CBaseFile::ConvertGameToString(i + 1) + L"." + CFileIO(exportto).extension();
578
										Utils::WString exportFile = CFileIO(saveto).dir() + L"/" + CFileIO(saveto).baseName() + L"_" + CBaseFile::ConvertGameToString(i + 1) + L"." + CFileIO(exportto).extension();
579
										if ( package->saveToArchive(exportFile.toString(), i + 1, m_pPackages->GetGameExe())) {
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 646... Line 646...
646
			{
646
			{
647
				if ( package->icon() )
647
				if ( package->icon() )
648
				{
648
				{
649
					package->ReadIconFileToMemory();
649
					package->ReadIconFileToMemory();
650
					Utils::WString sIconFile = _WS(IO::Path::GetTempPath()) + L"\\" + CFileIO(sFile).baseName() + L"." + package->iconExt();
650
					Utils::WString sIconFile = _WS(IO::Path::GetTempPath()) + L"\\" + CFileIO(sFile).baseName() + L"." + package->iconExt();
651
					if ( package->extractFile(package->icon(), CFileIO(sIconFile).fullFilename().toString(), false))
651
					if ( package->extractFile(package->icon(), CFileIO(sIconFile).fullFilename(), false))
652
					{
652
					{
653
						String ^iconFile = _US(sIconFile);
653
						String ^iconFile = _US(sIconFile);
654
						if ( IO::File::Exists(iconFile) )
654
						if ( IO::File::Exists(iconFile) )
655
						{
655
						{
656
							String ^ext = System::IO::FileInfo(iconFile).Extension;
656
							String ^ext = System::IO::FileInfo(iconFile).Extension;
Line 718... Line 718...
718
 
718
 
719
					for ( int i = 0; i < Files->Length; i++ )
719
					for ( int i = 0; i < Files->Length; i++ )
720
					{
720
					{
721
						Utils::WString file = _WS(Files[i]);
721
						Utils::WString file = _WS(Files[i]);
722
						int error = 0;
722
						int error = 0;
723
						CBaseFile *p = m_pPackages->openPackage(file.toString(), &error, 0, SPKREAD_NODATA);
723
						CBaseFile *p = m_pPackages->openPackage(file, &error, 0, SPKREAD_NODATA);
724
						if ( !p )
724
						if ( !p )
725
							continue;
725
							continue;
726
 
726
 
727
						Utils::WString ufile = p->createUpdateFile(_WS(fbd->SelectedPath));
727
						Utils::WString ufile = p->createUpdateFile(_WS(fbd->SelectedPath));
728
						if ( !ufile.empty() )
728
						if ( !ufile.empty() )
Line 843... Line 843...
843
				{
843
				{
844
					CSpkFile *spkFile = CSpkFile::convertFromOld(_WS(file));
844
					CSpkFile *spkFile = CSpkFile::convertFromOld(_WS(file));
845
					if ( spkFile ) {
845
					if ( spkFile ) {
846
						loaded = true;
846
						loaded = true;
847
						spkFile->adjustChanged(true);
847
						spkFile->adjustChanged(true);
848
						spkFile->setFilename(_S(file));
848
						spkFile->setFilename(_WS(file));
849
						convertFile = spkFile;
849
						convertFile = spkFile;
850
					}
850
					}
851
				}
851
				}
852
 
852
 
853
				if ( !loaded )
853
				if ( !loaded )
Line 862... Line 862...
862
			bool loaded = false;
862
			bool loaded = false;
863
 
863
 
864
			int error;
864
			int error;
865
			if ( fileType == SPKFILE_MULTI )
865
			if ( fileType == SPKFILE_MULTI )
866
			{
866
			{
867
				CMultiSpkFile *mspk = m_pPackages->openMultiPackage(sFile.toString(), &error);
867
				CMultiSpkFile *mspk = m_pPackages->openMultiPackage(sFile, &error);
868
				if ( mspk )
868
				if ( mspk )
869
				{
869
				{
870
					loaded = true;
870
					loaded = true;
871
					BaseForm ^childForm = this->OpenPackage(display, mspk, file, "");
871
					BaseForm ^childForm = this->OpenPackage(display, mspk, file, "");
872
					childForm->Text = file;
872
					childForm->Text = file;
873
				}
873
				}
874
			}
874
			}
875
			else
875
			else
876
			{
876
			{
877
				CBaseFile *package = (convertFile) ? convertFile : m_pPackages->openPackage(sFile.toString(), &error);
877
				CBaseFile *package = (convertFile) ? convertFile : m_pPackages->openPackage(sFile, &error);
878
				if ( package )
878
				if ( package )
879
				{
879
				{
880
					loaded = true;
880
					loaded = true;
881
					PackageForm ^childForm = this->OpenPackage(display, package, file, "");
881
					PackageForm ^childForm = this->OpenPackage(display, package, file, "");
882
					if ( convertFile )
882
					if ( convertFile )
Line 1136... Line 1136...
1136
		}
1136
		}
1137
 
1137
 
1138
		void SaveData()
1138
		void SaveData()
1139
		{
1139
		{
1140
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
1140
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
1141
			CFileIO Config(_S(mydoc) + "/Egosoft/creator.dat");
1141
			CFileIO Config(_WS(mydoc) + L"/Egosoft/creator.dat");
1142
			Utils::WStringList lines;
1142
			Utils::WStringList lines;
1143
 
1143
 
1144
			if ( this->WindowState == FormWindowState::Normal )
1144
			if ( this->WindowState == FormWindowState::Normal )
1145
			{
1145
			{
1146
				lines.pushBack(Utils::WString(L"CreatorSize:") + Utils::WString::Number(this->Size.Width) + L" " + Utils::WString::Number(this->Size.Height));
1146
				lines.pushBack(Utils::WString(L"CreatorSize:") + Utils::WString::Number(this->Size.Width) + L" " + Utils::WString::Number(this->Size.Height));
Line 2108... Line 2108...
2108
private: System::Void fromArchiveToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2108
private: System::Void fromArchiveToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2109
			 OpenArchive();
2109
			 OpenArchive();
2110
		 }
2110
		 }
2111
private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
2111
private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
2112
			 Threading::Thread::Sleep(500);
2112
			 Threading::Thread::Sleep(500);
2113
			 m_pConverted = m_pPackages->createFromArchive(_S(m_sConvertFile));
2113
			 m_pConverted = m_pPackages->createFromArchive(_WS(m_sConvertFile));
2114
		 }
2114
		 }
2115
private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^  sender, System::ComponentModel::RunWorkerCompletedEventArgs^  e) {
2115
private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^  sender, System::ComponentModel::RunWorkerCompletedEventArgs^  e) {
2116
			 if ( m_pWait ) 
2116
			 if ( m_pWait ) 
2117
			 {
2117
			 {
2118
				 m_pWait->Close();
2118
				 m_pWait->Close();