Subversion Repositories spk

Rev

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

Rev 180 Rev 182
Line 59... Line 59...
59
			for (auto itr = dirs->begin(); itr != dirs->end(); itr++)
59
			for (auto itr = dirs->begin(); itr != dirs->end(); itr++)
60
			{
60
			{
61
				Utils::String dir = m_pPackages->getProperDir((*itr)->str);
61
				Utils::String dir = m_pPackages->getProperDir((*itr)->str);
62
				if (!m_pDirList->contains(dir))
62
				if (!m_pDirList->contains(dir))
63
				{
63
				{
64
					int lang = m_pPackages->GetGameLanguage(dir);
64
					int lang = m_pPackages->getGameLanguage(dir);
65
					if(lang > 0)
65
					if(lang > 0)
66
						m_pDirList->pushBack(dir, Utils::String::Number(lang) + "|" + (*itr)->data);
66
						m_pDirList->pushBack(dir, Utils::String::Number(lang) + "|" + (*itr)->data);
67
					else
67
					else
68
						m_pDirList->pushBack(dir, (*itr)->data);
68
						m_pDirList->pushBack(dir, (*itr)->data);
69
					changed = true;
69
					changed = true;
Line 77... Line 77...
77
		}
77
		}
78
	}
78
	}
79
 
79
 
80
	void MainGui::AboutDialog()
80
	void MainGui::AboutDialog()
81
	{
81
	{
82
		CBaseFile *pm = m_pPackages->FindScriptByAuthor("PluginManager");
82
		CBaseFile *pm = m_pPackages->findScriptByAuthor("PluginManager");
83
		System::String ^scriptVer = "None";
83
		System::String ^scriptVer = "None";
84
		if (pm)
84
		if (pm)
85
		{
85
		{
86
			scriptVer = _US(pm->version());
86
			scriptVer = _US(pm->version());
87
			if (!pm->creationDate().empty())
87
			if (!pm->creationDate().empty())
Line 594... Line 594...
594
		bool errored = false;
594
		bool errored = false;
595
 
595
 
596
		if ( file->Length )
596
		if ( file->Length )
597
		{
597
		{
598
			int error = INSTALLERR_NONE;
598
			int error = INSTALLERR_NONE;
599
			CBaseFile *package = m_pPackages->OpenPackage(CyStringFromSystemString(file), &error, 0, SPKREAD_NODATA, READFLAG_NOUNCOMPRESS);
599
			CBaseFile *package = m_pPackages->openPackage(_S(file), &error, 0, SPKREAD_NODATA, READFLAG_NOUNCOMPRESS);
600
			if ( error == INSTALLERR_NOMULTI )
600
			if ( error == INSTALLERR_NOMULTI )
601
			{
601
			{
602
				CLinkList<CBaseFile> erroredList;
602
				CLinkList<CBaseFile> erroredList;
603
				m_pPackages->PrepareMultiPackage(CyStringFromSystemString(file), &erroredList, &error, 0);
603
				m_pPackages->prepareMultiPackage(_S(file), &erroredList, &error, 0);
604
				if ( erroredList.size() )
604
				if ( erroredList.size() )
605
				{
605
				{
606
					System::String ^modified;
606
					System::String ^modified;
607
					for ( CBaseFile *p = erroredList.First(); p; p = erroredList.Next() )
607
					for ( CBaseFile *p = erroredList.First(); p; p = erroredList.Next() )
608
					{
608
					{
Line 661... Line 661...
661
					int errorNum = m_pPackages->PrepareInstallPackage(package, false, false, IC_ALL);
661
					int errorNum = m_pPackages->PrepareInstallPackage(package, false, false, IC_ALL);
662
					if ( errorNum != INSTALLCHECK_OK )
662
					if ( errorNum != INSTALLCHECK_OK )
663
					{
663
					{
664
						if ( errorNum == INSTALLCHECK_NOSHIP )
664
						if ( errorNum == INSTALLCHECK_NOSHIP )
665
						{
665
						{
666
							this->DisplayMessageBox(false, "No Ships", "Ships are not supported for " + SystemStringFromCyString(m_pPackages->GetGameName()), MessageBoxButtons::OK, MessageBoxIcon::Stop);
666
							this->DisplayMessageBox(false, "No Ships", "Ships are not supported for " + _US(m_pPackages->getGameName()), MessageBoxButtons::OK, MessageBoxIcon::Stop);
667
							errored = true;
667
							errored = true;
668
						}
668
						}
669
						else if ( m_pPackages->PrepareInstallPackage(package, false, false, IC_MODIFIED) != INSTALLCHECK_OK )
669
						else if ( m_pPackages->PrepareInstallPackage(package, false, false, IC_MODIFIED) != INSTALLCHECK_OK )
670
						{
670
						{
671
							this->DisplayMessageBox(false, "Installing", "Currently in Vanilla Mode, Package is not an Vanilla Package\n" + _US(package->name(m_pPackages->GetLanguage())) + "\n\nSwitch to modified mode if you wish to install this package", MessageBoxButtons::OK, MessageBoxIcon::Question);
671
							this->DisplayMessageBox(false, "Installing", "Currently in Vanilla Mode, Package is not an Vanilla Package\n" + _US(package->name(m_pPackages->GetLanguage())) + "\n\nSwitch to modified mode if you wish to install this package", MessageBoxButtons::OK, MessageBoxIcon::Question);
Line 673... Line 673...
673
						}
673
						}
674
					}
674
					}
675
 
675
 
676
					// check for compatabilities
676
					// check for compatabilities
677
					CLinkList<CBaseFile> packages;
677
					CLinkList<CBaseFile> packages;
678
					int compat = m_pPackages->CheckCompatabilityAgainstPackages(package, NULL, &packages);
678
					int compat = m_pPackages->checkCompatabilityAgainstPackages(package, NULL, &packages);
679
					if ( compat )
679
					if ( compat )
680
					{
680
					{
681
						String ^message = "\nConflicts with:\n";
681
						String ^message = "\nConflicts with:\n";
682
						for ( CBaseFile *p = packages.First(); p; p = packages.Next() )
682
						for ( CBaseFile *p = packages.First(); p; p = packages.Next() )
683
							message += _US(p->getFullPackageName(m_pPackages->GetLanguage())) + "\n";
683
							message += _US(p->getFullPackageName(m_pPackages->GetLanguage())) + "\n";
Line 724... Line 724...
724
		{
724
		{
725
			Utils::String sDisplay;
725
			Utils::String sDisplay;
726
			Utils::String sAfterText;
726
			Utils::String sAfterText;
727
			for ( CBaseFile *p = packageList.First(); p; p = packageList.Next() )
727
			for ( CBaseFile *p = packageList.First(); p; p = packageList.Next() )
728
			{
728
			{
729
				sAfterText = m_pPackages->GetUninstallAfterText(p).ToString();
729
				sAfterText = m_pPackages->getUninstallAfterText(p);
730
				m_pPi->AddPackageWithGroup(_US(p->name(m_pPackages->GetLanguage())), _US(p->author()), _US(p->version()), (sAfterText.empty() ? "Uninstalled" : SystemStringFromCyString(sAfterText)), "Uninstalled");
730
				m_pPi->AddPackageWithGroup(_US(p->name(m_pPackages->GetLanguage())), _US(p->author()), _US(p->version()), (sAfterText.empty() ? "Uninstalled" : SystemStringFromCyString(sAfterText)), "Uninstalled");
731
				sDisplay = p->getFullPackageName(m_pPackages->GetLanguage());
731
				sDisplay = p->getFullPackageName(m_pPackages->GetLanguage());
732
				delete p;
732
				delete p;
733
			}
733
			}
734
			for ( CBaseFile *p = disableList.First(); p; p = disableList.Next() )
734
			for ( CBaseFile *p = disableList.First(); p; p = disableList.Next() )
Line 803... Line 803...
803
			{
803
			{
804
				if ( installedPackages.size() == 1 && erroredPackages.size() == 0 )
804
				if ( installedPackages.size() == 1 && erroredPackages.size() == 0 )
805
				{
805
				{
806
					CBaseFile *p = installedPackages.Front()->Data();
806
					CBaseFile *p = installedPackages.Front()->Data();
807
					Utils::String packageName = p->getFullPackageName(m_pPackages->GetLanguage());
807
					Utils::String packageName = p->getFullPackageName(m_pPackages->GetLanguage());
808
					Utils::String afterText = m_pPackages->GetInstallAfterText(p).ToString();
808
					Utils::String afterText = m_pPackages->getInstallAfterText(p);
809
					if (afterText.empty())
809
					if (afterText.empty())
810
						this->DisplayMessageBox(frombackground, "Installed", "Package: " + _US(packageName) + " installed!\n\n", MessageBoxButtons::OK, MessageBoxIcon::Information);
810
						this->DisplayMessageBox(frombackground, "Installed", "Package: " + _US(packageName) + " installed!\n\n", MessageBoxButtons::OK, MessageBoxIcon::Information);
811
					else
811
					else
812
					{
812
					{
813
						afterText = afterText.stripHtml();
813
						afterText = afterText.stripHtml();
Line 821... Line 821...
821
					CyStringList packages;
821
					CyStringList packages;
822
					for ( CListNode<CBaseFile> *node = installedPackages.Front(); node; node = node->next() )
822
					for ( CListNode<CBaseFile> *node = installedPackages.Front(); node; node = node->next() )
823
					{
823
					{
824
						CBaseFile *p = node->Data();
824
						CBaseFile *p = node->Data();
825
						Utils::String packageName = p->getFullPackageName(m_pPackages->GetLanguage());
825
						Utils::String packageName = p->getFullPackageName(m_pPackages->GetLanguage());
826
						Utils::String afterText = m_pPackages->GetInstallAfterText(p).ToString();
826
						Utils::String afterText = m_pPackages->getInstallAfterText(p);
827
 
827
 
828
						if (afterText.empty())
828
						if (afterText.empty())
829
							afterText = "Installed";
829
							afterText = "Installed";
830
						m_pPi->AddPackage(_US(packageName), _US(p->author()), _US(p->version()), _US(afterText));
830
						m_pPi->AddPackage(_US(packageName), _US(p->author()), _US(p->version()), _US(afterText));
831
					}
831
					}
Line 1118... Line 1118...
1118
		if (m_pPackages->IsLoaded())
1118
		if (m_pPackages->IsLoaded())
1119
		{
1119
		{
1120
			if (m_pPackages->CloseDir(0, 0, true))
1120
			if (m_pPackages->CloseDir(0, 0, true))
1121
			{
1121
			{
1122
				// write the modname
1122
				// write the modname
1123
				if (!m_pPackages->GetModKey().Empty())
1123
				if (!m_pPackages->getModKey().empty())
1124
					PluginManager::WriteRegistryValue(m_pPackages->GetModKey(), m_pPackages->selectedModName());
1124
					PluginManager::WriteRegistryValue(m_pPackages->getModKey(), m_pPackages->selectedModName());
1125
				m_pPackages->Reset();
1125
				m_pPackages->Reset();
1126
			}
1126
			}
1127
			else
1127
			else
1128
			{
1128
			{
1129
				this->DisplayMessageBox(true, "Error", "unable to close directory", MessageBoxButtons::OK, MessageBoxIcon::Error);
1129
				this->DisplayMessageBox(true, "Error", "unable to close directory", MessageBoxButtons::OK, MessageBoxIcon::Error);
Line 1145... Line 1145...
1145
		{
1145
		{
1146
			//if ( m_iSaveGameManager == 1 )
1146
			//if ( m_iSaveGameManager == 1 )
1147
				//m_pPackages->RestoreSaves();
1147
				//m_pPackages->RestoreSaves();
1148
			m_pPackages->UpdatePackages();
1148
			m_pPackages->UpdatePackages();
1149
			m_pPackages->ReadGameLanguage(true);
1149
			m_pPackages->ReadGameLanguage(true);
1150
			System::String ^mod = PluginManager::ReadRegistryValue(m_pPackages->GetModKey());
1150
			System::String ^mod = PluginManager::ReadRegistryValue(m_pPackages->getModKey());
1151
			m_pPackages->setMod(_S(mod));
1151
			m_pPackages->setMod(_S(mod));
1152
			if(m_lAvailablePackages)
1152
			if(m_lAvailablePackages)
1153
				m_lAvailablePackages->clear();
1153
				m_lAvailablePackages->clear();
1154
			this->FindPackages();
1154
			this->FindPackages();
1155
		}
1155
		}
Line 1164... Line 1164...
1164
	{
1164
	{
1165
		if ( !item )
1165
		if ( !item )
1166
			return NULL;
1166
			return NULL;
1167
 
1167
 
1168
		System::String ^sNum = System::Convert::ToString(item->Tag);
1168
		System::String ^sNum = System::Convert::ToString(item->Tag);
1169
		int iNum = CyStringFromSystemString(sNum).ToInt();
1169
		int iNum = _S(sNum).toInt();
1170
 
1170
 
1171
		CBaseFile *p = m_pPackages->GetPackageAt(iNum);
1171
		CBaseFile *p = m_pPackages->GetPackageAt(iNum);
1172
		return p;
1172
		return p;
1173
	}
1173
	}
1174
 
1174
 
Line 1561... Line 1561...
1561
					if ( skipShips )
1561
					if ( skipShips )
1562
						continue;
1562
						continue;
1563
				}
1563
				}
1564
 
1564
 
1565
				// display uninstall text
1565
				// display uninstall text
1566
				Utils::String beforeText = m_pPackages->GetUninstallBeforeText(p).ToString();
1566
				Utils::String beforeText = m_pPackages->getUninstallBeforeText(p);
1567
				if ( !beforeText.empty() ) {
1567
				if ( !beforeText.empty() ) {
1568
					if ( this->DisplayMessageBox(false, "Uninstall Package", _US(p->getFullPackageName(m_pPackages->GetLanguage()) + "\n" + beforeText + "\n\nDo you want to uninstall this package?"), MessageBoxButtons::YesNo, MessageBoxIcon::Question) != System::Windows::Forms::DialogResult::Yes )
1568
					if ( this->DisplayMessageBox(false, "Uninstall Package", _US(p->getFullPackageName(m_pPackages->GetLanguage()) + "\n" + beforeText + "\n\nDo you want to uninstall this package?"), MessageBoxButtons::YesNo, MessageBoxIcon::Question) != System::Windows::Forms::DialogResult::Yes )
1569
						continue;
1569
						continue;
1570
				}
1570
				}
1571
 
1571
 
Line 1784... Line 1784...
1784
						m_pDirList->remove(dir, false);
1784
						m_pDirList->remove(dir, false);
1785
						m_pDirList->pushFront(dir, data);
1785
						m_pDirList->pushFront(dir, data);
1786
					}
1786
					}
1787
					else
1787
					else
1788
					{
1788
					{
1789
						int lang = m_pPackages->GetGameLanguage(dir);
1789
						int lang = m_pPackages->getGameLanguage(dir);
1790
						if ( lang )
1790
						if ( lang )
1791
							m_pDirList->pushFront(dir, Utils::String::Number(lang) + "|" + m_pPackages->getGameName(dir));
1791
							m_pDirList->pushFront(dir, Utils::String::Number(lang) + "|" + m_pPackages->getGameName(dir));
1792
						else
1792
						else
1793
							m_pDirList->pushFront(dir, m_pPackages->getGameName(dir));
1793
							m_pDirList->pushFront(dir, m_pPackages->getGameName(dir));
1794
					}
1794
					}
Line 1862... Line 1862...
1862
			bool installing = false;
1862
			bool installing = false;
1863
			array <System::String ^> ^Files = System::IO::Directory::GetFiles(dir, "*.spk");
1863
			array <System::String ^> ^Files = System::IO::Directory::GetFiles(dir, "*.spk");
1864
 
1864
 
1865
			for ( int i = 0; i < Files->Length; i++ )
1865
			for ( int i = 0; i < Files->Length; i++ )
1866
			{
1866
			{
1867
				CyString file = CyStringFromSystemString(Files[i]);
1867
				Utils::String file = _S(Files[i]);
1868
				int error;
1868
				int error;
1869
				CBaseFile *p = m_pPackages->OpenPackage(file, &error, 0, SPKREAD_NODATA);
1869
				CBaseFile *p = m_pPackages->openPackage(file, &error, 0, SPKREAD_NODATA);
1870
				if ( !p )
1870
				if ( !p )
1871
					continue;
1871
					continue;
1872
 
1872
 
1873
				if ( !((CSpkFile *)p)->IsLibrary() )
1873
				if ( !((CSpkFile *)p)->IsLibrary() )
1874
					continue;
1874
					continue;
1875
 
1875
 
1876
				if ( !p->CheckGameCompatability(m_pPackages->GetGame()) )
1876
				if ( !p->CheckGameCompatability(m_pPackages->GetGame()) )
1877
					continue;
1877
					continue;
1878
 
1878
 
1879
				// if its installed, check if we have a newer version
1879
				// if its installed, check if we have a newer version
1880
				CBaseFile *check = m_pPackages->FindSpkPackage(p->name(), p->author());
1880
				CBaseFile *check = m_pPackages->findSpkPackage(p->name(), p->author());
1881
				if ( check )
1881
				if ( check )
1882
				{
1882
				{
1883
					if ( check->version().compareVersion(p->version()) != COMPARE_OLDER )
1883
					if ( check->version().compareVersion(p->version()) != COMPARE_OLDER )
1884
					{
1884
					{
1885
						this->InstallPackage(Files[i], false, true, true);
1885
						this->InstallPackage(Files[i], false, true, true);
Line 2139... Line 2139...
2139
 
2139
 
2140
		try 
2140
		try 
2141
		{
2141
		{
2142
			System::Net::WebClient ^Client = gcnew System::Net::WebClient();
2142
			System::Net::WebClient ^Client = gcnew System::Net::WebClient();
2143
 
2143
 
2144
			System::IO::Stream ^strm = Client->OpenRead(SystemStringFromCyString(m_pUpdateList->Head()->str));
2144
			System::IO::Stream ^strm = Client->OpenRead(_US(m_pUpdateList->Head()->str.ToString()));
2145
			System::IO::StreamReader ^sr = gcnew System::IO::StreamReader(strm);
2145
			System::IO::StreamReader ^sr = gcnew System::IO::StreamReader(strm);
2146
			System::String ^read = sr->ReadToEnd();
2146
			System::String ^read = sr->ReadToEnd();
2147
			strm->Close();
2147
			strm->Close();
2148
			sr->Close();
2148
			sr->Close();
2149
 
2149
 
2150
			m_pUpdateList->Head()->data = CyStringFromSystemString(read);
2150
			m_pUpdateList->Head()->data = _S(read);
2151
		}
2151
		}
2152
		catch (System::Net::WebException ^ex)
2152
		catch (System::Net::WebException ^ex)
2153
		{
2153
		{
2154
			m_pUpdateList->Head()->data = CyStringFromSystemString("!ERROR! " + ex->ToString());
2154
			m_pUpdateList->Head()->data = _S("!ERROR! " + ex->ToString());
2155
			if ( ex->Status == System::Net::WebExceptionStatus::ConnectFailure )
2155
			if ( ex->Status == System::Net::WebExceptionStatus::ConnectFailure )
2156
			{
2156
			{
2157
				m_pUpdateList->Head()->data = CyStringFromSystemString("!ERROR! " + ex->ToString());
2157
				m_pUpdateList->Head()->data = _S("!ERROR! " + ex->ToString());
2158
 
2158
 
2159
			}
2159
			}
2160
		}
2160
		}
2161
	}
2161
	}
2162
 
2162
 
2163
	void MainGui::LaunchGame()
2163
	void MainGui::LaunchGame()
2164
	{
2164
	{
2165
		if ( !System::IO::File::Exists(".\\GameLauncher.exe") )
2165
		if ( !System::IO::File::Exists(".\\GameLauncher.exe") )
2166
			return;
2166
			return;
2167
 
2167
 
2168
		m_sRun = _US(m_pPackages->GetGameRunExe());
2168
		m_sRun = _US(m_pPackages->getGameRunExe());
2169
		this->Close();
2169
		this->Close();
2170
	}
2170
	}
2171
 
2171
 
2172
	bool MainGui::DisplayTip(int tipsection, int tip)
2172
	bool MainGui::DisplayTip(int tipsection, int tip)
2173
	{
2173
	{
Line 2564... Line 2564...
2564
		}
2564
		}
2565
	}
2565
	}
2566
 
2566
 
2567
	void MainGui::CheckFakePatchCompatability()
2567
	void MainGui::CheckFakePatchCompatability()
2568
	{
2568
	{
2569
		CyStringList errorList;
2569
		Utils::CStringList errorList;
2570
		int count = 0;
2570
		int count = 0;
2571
		int packageCount = 0;
2571
		int packageCount = 0;
2572
		for ( CBaseFile *p = m_pPackages->GetFirstPackage(); p; p = m_pPackages->GetNextPackage(p) )
2572
		for ( CBaseFile *p = m_pPackages->GetFirstPackage(); p; p = m_pPackages->GetNextPackage(p) )
2573
		{
2573
		{
2574
			if ( !p->IsEnabled() ) continue;
2574
			if ( !p->IsEnabled() ) continue;
Line 2581... Line 2581...
2581
			{
2581
			{
2582
				if ( comparePackage == p ) continue; // dont include the same package
2582
				if ( comparePackage == p ) continue; // dont include the same package
2583
				if ( !comparePackage->IsEnabled() ) continue;
2583
				if ( !comparePackage->IsEnabled() ) continue;
2584
				if ( !comparePackage->AnyFileType(FILETYPE_MOD) ) continue;
2584
				if ( !comparePackage->AnyFileType(FILETYPE_MOD) ) continue;
2585
 
2585
 
2586
				CyStringList list;
2586
				Utils::CStringList list;
2587
				if ( m_pPackages->CheckCompatabilityBetweenMods(p, comparePackage, &list) )
2587
				if ( m_pPackages->checkCompatabilityBetweenMods(p, comparePackage, &list) )
2588
				{
2588
				{
2589
					Utils::String package2Name = comparePackage->getFullPackageName(m_pPackages->GetLanguage());
2589
					Utils::String package2Name = comparePackage->getFullPackageName(m_pPackages->GetLanguage());
2590
					for ( SStringList *str = list.Head(); str; str = str->;next )
2590
					for(auto itr = list.begin(); itr != list.end(); itr++)
2591
					{
2591
					{
2592
						errorList.PushBack(str->;str + " (" + packageName + ")", str->data + " (" + package2Name + ")");
2592
						errorList.pushBack((*itr)->;str + " (" + packageName + ")", (*itr)->data + " (" + package2Name + ")");
2593
						++count;
2593
						++count;
2594
					}
2594
					}
2595
					++packageCount;
2595
					++packageCount;
2596
				}
2596
				}
2597
			}
2597
			}
Line 2793... Line 2793...
2793
		}
2793
		}
2794
	}
2794
	}
2795
 
2795
 
2796
	void MainGui::VerifyInstalledFiles()
2796
	void MainGui::VerifyInstalledFiles()
2797
	{
2797
	{
2798
		CyStringList missing;
2798
		Utils::CStringList missing;
2799
		int amount = m_pPackages->VerifyInstalledFiles(&missing);
2799
		int amount = m_pPackages->verifyInstalledFiles(&missing);
2800
		if ( !amount )
2800
		if ( !amount )
2801
			MessageBox::Show(this, "All files are currently installed", "Verifying Installed Files", MessageBoxButtons::OK, MessageBoxIcon::Information);
2801
			MessageBox::Show(this, "All files are currently installed", "Verifying Installed Files", MessageBoxButtons::OK, MessageBoxIcon::Information);
2802
		else
2802
		else
2803
		{
2803
		{
2804
			String ^text;
2804
			String ^text;
2805
			for ( SStringList *str = missing.Head(); str; str = str->;next )
2805
			for(auto itr = missing.begin(); itr != missing.end(); itr++)
2806
			{
2806
			{
2807
				text += SystemStringFromCyString(str->str);
2807
				text += _US((*itr)->str);
2808
				text += "\n\t";
2808
				text += "\n\t";
2809
				CyString data = str->data.findreplace("\n", "\t\n");
2809
				text += _US((*itr)->data.findReplace("\n", "\t\n"));
2810
				text += SystemStringFromCyString(data);
-
 
2811
				text += "\n\n";
2810
				text += "\n\n";
2812
			}
2811
			}
2813
			MessageBoxDetails::Show(this, "Verifing Installed Files", "Missing files detected\nAmount = " + amount, text, false, 600);
2812
			MessageBoxDetails::Show(this, "Verifing Installed Files", "Missing files detected\nAmount = " + amount, text, false, 600);
2814
		}
2813
		}
2815
	}
2814
	}