Subversion Repositories spk

Rev

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

Rev 196 Rev 197
Line 95... Line 95...
95
	void MainGui::CheckProtectedDir()
95
	void MainGui::CheckProtectedDir()
96
	{
96
	{
97
		if (!m_pPackages || !m_pPackages->IsLoaded())
97
		if (!m_pPackages || !m_pPackages->IsLoaded())
98
			return;
98
			return;
99
 
99
 
100
		Utils::String dir = m_pPackages->getCurrentDirectory();
100
		Utils::WString dir = m_pPackages->getCurrentDirectory();
101
		if(!dir.empty())
101
		if(!dir.empty())
102
		{
102
		{
103
			m_bDirLocked = false;
103
			m_bDirLocked = false;
104
 
104
 
105
			// write a file in the directory
105
			// write a file in the directory
Line 145... Line 145...
145
					written = false;
145
					written = false;
146
				}
146
				}
147
			}
147
			}
148
 
148
 
149
			if ( !written ) {
149
			if ( !written ) {
150
				MessageBox::Show(this, _US(Utils::String::Format(CLanguages::Instance()->findText(LS_STARTUP, LANGSTARTUP_LOCKEDDIR), (char *)dir)), _US(CLanguages::Instance()->findText(LS_STARTUP, LANGSTARTUP_LOCKEDDIR_TITLE)), MessageBoxButtons::OK, MessageBoxIcon::Error);
150
				MessageBox::Show(this, _US(Utils::WString::Format(CLanguages::Instance()->findText(LS_STARTUP, LANGSTARTUP_LOCKEDDIR), dir.c_str())), _US(CLanguages::Instance()->findText(LS_STARTUP, LANGSTARTUP_LOCKEDDIR_TITLE)), MessageBoxButtons::OK, MessageBoxIcon::Error);
151
				m_bDirLocked = true;
151
				m_bDirLocked = true;
152
			}
152
			}
153
			else {
153
			else {
154
				dir = dir.findReplace("/", "\\");
154
				dir = dir.findReplace("/", "\\");
155
				bool found = false;
155
				bool found = false;
Line 210... Line 210...
210
		}
210
		}
211
 
211
 
212
		ComboDir->Items->Add("-- None --");
212
		ComboDir->Items->Add("-- None --");
213
		if (selected && selected->Length > 0)
213
		if (selected && selected->Length > 0)
214
			ComboDir->Text = selected;
214
			ComboDir->Text = selected;
215
		else if (current == "-- None --")
215
		else if (current == L"-- None --")
216
			ComboDir->Text = "-- None --";
216
			ComboDir->Text = "-- None --";
217
		else if(!foundCurrent || !ComboDir->Text || ComboDir->Text->Length < 1)
217
		else if(!foundCurrent || !ComboDir->Text || ComboDir->Text->Length < 1)
218
			ComboDir->Text = ComboDir->Items[0]->ToString();
218
			ComboDir->Text = ComboDir->Items[0]->ToString();
219
 
219
 
220
		this->UpdateRunButton();
220
		this->UpdateRunButton();
Line 229... Line 229...
229
		}
229
		}
230
 
230
 
231
		ButRun->Text = "Run: " + _US(m_pPackages->getGameName());
231
		ButRun->Text = "Run: " + _US(m_pPackages->getGameName());
232
		ButRun->Visible = true;
232
		ButRun->Visible = true;
233
		
233
		
234
		Utils::String exe = m_pPackages->GetGameExe()->GetGameRunExe(m_pPackages->getCurrentDirectory());
234
		Utils::WString exe = m_pPackages->GetGameExe()->gameRunExe(m_pPackages->getCurrentDirectory());
235
		if ( CFileIO(exe).exists() )
235
		if ( CFileIO(exe).exists() )
236
		{
236
		{
237
			exe = exe.findReplace("/", "\\");
237
			exe = exe.findReplace(L"/", L"\\");
238
			wchar_t wText[200];
-
 
239
			::MultiByteToWideChar(CP_ACP, NULL, (char *)exe.c_str(), -1, wText, exe.length() + 1);
-
 
240
 
238
 
241
			System::Drawing::Icon ^myIcon;
239
			System::Drawing::Icon ^myIcon;
242
			SHFILEINFO *shinfo = new SHFILEINFO();
240
			SHFILEINFO *shinfo = new SHFILEINFO();
243
 
241
 
244
			if ( FAILED(SHGetFileInfo(wText, 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_LARGEICON)) )
242
			if ( FAILED(SHGetFileInfo(exe.c_str(), 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_LARGEICON)) )
245
			{
243
			{
246
				if ( FAILED(SHGetFileInfo(wText, 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_SMALLICON)) )
244
				if ( FAILED(SHGetFileInfo(exe.c_str(), 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_SMALLICON)))
247
				{
245
				{
248
					System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MainGui::typeid));
246
					System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MainGui::typeid));
249
					this->ButRun->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"ButRun.Image")));
247
					this->ButRun->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"ButRun.Image")));
250
				}
248
				}
251
				else
249
				else
Line 673... Line 671...
673
						}
671
						}
674
					}
672
					}
675
 
673
 
676
					// check for compatabilities
674
					// check for compatabilities
677
					CLinkList<CBaseFile> packages;
675
					CLinkList<CBaseFile> packages;
678
					Utils::CStringList list;
676
					Utils::WStringList list;
679
					int compat = m_pPackages->checkCompatabilityAgainstPackages(package, &list, &packages);
677
					int compat = m_pPackages->checkCompatabilityAgainstPackages(package, &list, &packages);
680
					if ( compat )
678
					if ( compat )
681
					{
679
					{
682
						String ^message = "Conflicts with:\n";
680
						String ^message = "Conflicts with:\n";
683
						for ( CBaseFile *p = packages.First(); p; p = packages.Next() )
681
						for ( CBaseFile *p = packages.First(); p; p = packages.Next() )
Line 1148... Line 1146...
1148
		}
1146
		}
1149
 
1147
 
1150
		m_pPackages->Reset();
1148
		m_pPackages->Reset();
1151
	}
1149
	}
1152
 
1150
 
1153
	void MainGui::ChangeDirectory(const Utils::String &dir)
1151
	void MainGui::ChangeDirectory(const Utils::WString &dir)
1154
	{
1152
	{
1155
		if ( m_pPackages->isCurrentDir(dir) )
1153
		if ( m_pPackages->isCurrentDir(dir) )
1156
			return;
1154
			return;
1157
 
1155
 
1158
		CloseCurrentDirectory();
1156
		CloseCurrentDirectory();
Line 1802... Line 1800...
1802
					}
1800
					}
1803
					else
1801
					else
1804
					{
1802
					{
1805
						int lang = m_pPackages->getGameLanguage(dir.toString());
1803
						int lang = m_pPackages->getGameLanguage(dir.toString());
1806
						if ( lang )
1804
						if ( lang )
1807
							m_pDirList->pushFront(dir, Utils::WString::Number(lang) + L"|" + m_pPackages->getGameName(dir.toString()).toWString());
1805
							m_pDirList->pushFront(dir, Utils::WString::Number(lang) + L"|" + m_pPackages->getGameName(dir));
1808
						else
1806
						else
1809
							m_pDirList->pushFront(dir, m_pPackages->getGameName(dir.toString()));
1807
							m_pDirList->pushFront(dir, m_pPackages->getGameName(dir));
1810
					}
1808
					}
1811
				}
1809
				}
1812
			}
1810
			}
1813
 
1811
 
1814
			this->UpdateDirList(selectedDir);
1812
			this->UpdateDirList(selectedDir);
Line 1928... Line 1926...
1928
			return;
1926
			return;
1929
 
1927
 
1930
		// load the dir list
1928
		// load the dir list
1931
		if ( !m_pUpdateList )
1929
		if ( !m_pUpdateList )
1932
		{
1930
		{
1933
			m_pUpdateList = new CyStringList;
1931
			m_pUpdateList = new Utils::WStringList;
1934
 
1932
 
1935
			// TODO: read addresses from data
1933
			// TODO: read addresses from data
1936
 
1934
 
1937
			// hardcoded address
1935
			// hardcoded address
1938
			m_pUpdateList->PushBack("http://xpluginmanager.co.uk/pmupdate.dat", "", true);
1936
			m_pUpdateList->pushBack(L"http://xpluginmanager.co.uk/pmupdate.dat", L"");
1939
			if ( (int)PMLBETA )
1937
			if ( (int)PMLBETA )
1940
				m_pUpdateList->PushBack("http://xpluginmanager.co.uk/Beta/pmupdatebeta.dat", "", true);
1938
				m_pUpdateList->pushBack(L"http://xpluginmanager.co.uk/Beta/pmupdatebeta.dat", L"");
1941
		}
1939
		}
1942
 
1940
 
1943
		backgroundUpdater->RunWorkerAsync();
1941
		backgroundUpdater->RunWorkerAsync();
1944
	}
1942
	}
1945
 
1943
 
1946
	void MainGui::Updater_Finished(System::Object ^Sender, RunWorkerCompletedEventArgs ^E)
1944
	void MainGui::Updater_Finished(System::Object ^Sender, RunWorkerCompletedEventArgs ^E)
1947
	{
1945
	{
1948
		if ( !m_pUpdateList )
1946
		if ( !m_pUpdateList )
1949
			return;
1947
			return;
1950
		if ( !m_pUpdateList->Head() )
1948
		if (m_pUpdateList->empty())
1951
		{
1949
		{
1952
			delete m_pUpdateList;
1950
			delete m_pUpdateList;
1953
			m_pUpdateList = NULL;
1951
			m_pUpdateList = nullptr;
1954
			return;
1952
			return;
1955
		}
1953
		}
1956
 
1954
 
1957
		this->Enabled = false;
1955
		this->Enabled = false;
1958
 
1956
 
1959
		CyString server = m_pUpdateList->Head()->str;
1957
		Utils::WString server = (*m_pUpdateList)[0]->str;
1960
		CyString data = m_pUpdateList->Head()->data;
1958
		Utils::WString data = (*m_pUpdateList)[0]->data;
1961
 
1959
 
1962
		m_pUpdateList->PopFront();
1960
		m_pUpdateList->popFront();
1963
 
1961
 
1964
		// lets check if we have an update
1962
		// lets check if we have an update
1965
		if ( data.GetToken(" ", 1, 1) != "!ERROR!" )
1963
		if ( data.token(L" ", 1) != L"!ERROR!" )
1966
		{
1964
		{
1967
			CyString download;
1965
			Utils::WString download;
1968
			CyString message;
1966
			Utils::WString message;
1969
			int max;
1967
 
1970
			CyString *strs = data.SplitToken("\n";, &max);
1968
			std::vector<Utils::WString>; strs;
1971
			if ( strs )
1969
			if(data.tokenise(L"\n", strs))
1972
			{
1970
			{
1973
				for ( int i = 0; i <; max; i++ )
1971
				for (size_t i = 0; i <; strs.size(); i++)
1974
				{
1972
				{
1975
					CyString cmd = strs[i].GetToken(";:", 1, 1);
1973
					Utils::WString cmd = strs[i].token(L";:", 1);
1976
					CyString rest = strs[i].GetToken(":", 2);
1974
					Utils::WString rest = strs[i].tokens(L":", 2);
1977
					rest.RemoveFirstSpace();
1975
					rest.removeFirstSpace();
1978
					if ( cmd.Compare("SPKVERSION") )
1976
					if ( cmd.Compare(L"SPKVERSION") )
1979
					{
1977
					{
1980
						float v = rest.GetToken(" ", 1, 1).ToFloat();
1978
						float v = rest.token(L" ", 1).toFloat();
1981
						if ( v > GetLibraryVersion() )
1979
						if ( v > GetLibraryVersion() )
1982
						{
1980
						{
1983
							message += "New version of the SPK Libraries available\nCurrent = ";
1981
							message += L"New version of the SPK Libraries available\nCurrent = ";
1984
							message += CyString::CreateFromFloat(GetLibraryVersion(), 2);
1982
							message += Utils::WString::FromFloat(GetLibraryVersion(), 2);
1985
							message += "\nNew Version = ";
1983
							message += L"\nNew Version = ";
1986
							message += CyString::CreateFromFloat(v, 2);
1984
							message += Utils::WString::FromFloat(v, 2);
1987
							message += "\n\n";
1985
							message += L"\n\n";
1988
 
1986
 
1989
							CyString filename = rest.GetToken(" ", 2);
1987
							Utils::WString filename = rest.tokens(L" ", 2);
1990
							if ( download.Empty() )
1988
							if ( download.empty() )
1991
								download = filename;
1989
								download = filename;
1992
							else
1990
							else
1993
							{
1991
							{
1994
								download += "|";
1992
								download += L"|";
1995
								download += filename;
1993
								download += filename;
1996
							}
1994
							}
1997
						}
1995
						}
1998
					}
1996
					}
1999
					else if ( cmd.Compare("PMLVERSION") )
1997
					else if ( cmd.Compare(L"PMLVERSION") )
2000
					{
1998
					{
2001
						float v = rest.GetToken(" ", 1, 1).ToFloat();
1999
						float v = rest.token(L" ", 1).toFloat();
2002
						int beta = rest.GetToken(" ", 2, 2).ToInt();
2000
						int beta = rest.token(L" ", 2).toInt();
2003
 
2001
 
2004
						bool newVersion = false;
2002
						bool newVersion = false;
2005
						// new version
2003
						// new version
2006
						if ( v > (float)PMLVERSION )
2004
						if ( v > (float)PMLVERSION )
2007
							newVersion = true;
2005
							newVersion = true;
2008
						// same version, check beta/rc
2006
						// same version, check beta/rc
2009
						if ( v == (float)PMLVERSION )
2007
						if ( v == (float)PMLVERSION )
2010
						{
2008
						{
2011
							// newer beta version
2009
							// newer beta version
2012
							if ( beta > (int)PMLBETA && (int)PMLBETA > 0 )
2010
							if ( beta > (int)PMLBETA && (int)PMLBETA > 0 )
2013
								newVersion = true;
2011
								newVersion = true;
2014
							// current is beta, new is an RC
2012
							// current is beta, new is an RC
2015
							else if ( (int)PMLBETA > 0 && beta < 0 )
2013
							else if ( (int)PMLBETA > 0 && beta < 0 )
2016
								newVersion = true;
2014
								newVersion = true;
2017
							// current is rc, new is an rc
2015
							// current is rc, new is an rc
2018
							else if ( (int)PMLBETA < 0 && beta < 0 && beta < (int)PMLBETA )
2016
							else if ( (int)PMLBETA < 0 && beta < 0 && beta < (int)PMLBETA )
2019
								newVersion = true;
2017
								newVersion = true;
2020
							// current is beta or rc, new is not, so its newer
2018
							// current is beta or rc, new is not, so its newer
2021
							else if ( (int)PMLBETA != 0 && beta == 0 )
2019
							else if ( (int)PMLBETA != 0 && beta == 0 )
2022
								newVersion = true;
2020
								newVersion = true;
2023
						}
2021
						}
2024
 
2022
 
2025
						if ( newVersion )
2023
						if ( newVersion )
2026
						{
2024
						{
2027
							message += "New version of the ";
2025
							message += L"New version of the ";
2028
							message += CyStringFromSystemString(GetProgramName(m_bAdvanced));
2026
							message += _WS(GetProgramName(m_bAdvanced));
2029
							message += " available\nCurrent = ";
2027
							message += L" available\nCurrent = ";
2030
							message += CyStringFromSystemString(PluginManager::GetVersionString());
2028
							message += _WS(PluginManager::GetVersionString());
2031
							message += "\nNew Version = ";
2029
							message += L"\nNew Version = ";
2032
							message += CyStringFromSystemString(PluginManager::GetVersionString(v, beta));
2030
							message += _WS(PluginManager::GetVersionString(v, beta));
2033
							message += "\n\n";
2031
							message += L"\n\n";
2034
							if ( download.Empty() )
2032
							if ( download.empty() )
2035
								download = rest.GetToken(" ", 3);
2033
								download = rest.tokens(L" ", 3);
2036
							else
2034
							else
2037
							{
2035
							{
2038
								download += "|";
2036
								download += L"|";
2039
								download += rest.GetToken(" ", 3);
2037
								download += rest.tokens(L" ", 3);
2040
							}
2038
							}
2041
						}
2039
						}
2042
					}
2040
					}
2043
				}
2041
				}
2044
			}
2042
			}
2045
 
2043
 
2046
			CLEANSPLIT(strs, max)
-
 
2047
 
-
 
2048
			if ( !download.Empty() && !message.Empty() )
2044
			if ( !download.empty() && !message.empty() )
2049
			{
2045
			{
2050
				if ( this->DisplayMessageBox(false, "Updater", _US(message.ToString()) + "Do You wish to download and install it?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
2046
				if ( this->DisplayMessageBox(false, "Updater", _US(message) + "Do You wish to download and install it?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
2051
				{
2047
				{
2052
					// absolute address
2048
					// absolute address
2053
					CyString downloadFile;
2049
					Utils::WString downloadFile;
2054
 
2050
 
2055
					int max;
2051
					std::vector<Utils::WString> strs;
2056
					CyString *strs = download.SplitToken("|&quot;, &max);
2052
					data.tokenise(L"\n&quot;, strs);
-
 
2053
 
2057
					for ( int i = 0; i < max; i++ )
2054
					for (size_t i = 0; i < strs.size(); i++ )
2058
					{
2055
					{
2059
						CyString d = strs[i];
2056
						Utils::WString d = strs[i];
2060
						// relative address
2057
						// relative address
2061
						if ( !d.Left(7).Compare("http://") && !d.Left(4).Compare("www.") )
2058
						if ( !d.left(7).Compare(L"http://") && !d.left(4).Compare(L"www.") )
2062
							d = server.DelToken("/", server.NumToken("/")) + "/" + d;
2059
							d = server.remToken(L"/", server.countToken(L"/")) + L"/" + d;
2063
 
2060
 
2064
						if ( downloadFile.Empty() )
2061
						if ( downloadFile.empty() )
2065
							downloadFile = d;
2062
							downloadFile = d;
2066
						else
2063
						else
2067
						{
2064
						{
2068
							downloadFile += "|";
2065
							downloadFile += "|";
2069
							downloadFile += d;
2066
							downloadFile += d;
2070
						}
2067
						}
2071
					}
2068
					}
2072
 
2069
 
2073
					CLEANSPLIT(strs, max);
-
 
2074
 
-
 
2075
					if ( !downloadFile.Empty() )
2070
					if ( !downloadFile.empty() )
2076
					{
2071
					{
2077
						m_sDownload = _US(downloadFile.ToString());
2072
						m_sDownload = _US(downloadFile);
2078
						this->Close();
2073
						this->Close();
2079
						return;
2074
						return;
2080
					}
2075
					}
2081
				}
2076
				}
2082
			}
2077
			}
2083
		}
2078
		}
2084
 
2079
 
2085
		// otherwise, lets continue with the next server
2080
		// otherwise, lets continue with the next server
2086
		if ( m_pUpdateList->Head() )
2081
		if (!m_pUpdateList->empty())
2087
			backgroundUpdater->RunWorkerAsync();
2082
			backgroundUpdater->RunWorkerAsync();
2088
		else
2083
		else
2089
		{
2084
		{
2090
			delete m_pUpdateList;
2085
			delete m_pUpdateList;
2091
			m_pUpdateList = NULL;
2086
			m_pUpdateList = NULL;
Line 2144... Line 2139...
2144
 
2139
 
2145
	void MainGui::Updater_DoWork(System::Object ^Sender, DoWorkEventArgs ^E)
2140
	void MainGui::Updater_DoWork(System::Object ^Sender, DoWorkEventArgs ^E)
2146
	{
2141
	{
2147
		if ( !m_pUpdateList )
2142
		if ( !m_pUpdateList )
2148
			return;
2143
			return;
2149
		if ( !m_pUpdateList->Head() )
2144
		if (m_pUpdateList->empty())
2150
		{
2145
		{
2151
			delete m_pUpdateList;
2146
			delete m_pUpdateList;
2152
			m_pUpdateList = NULL;
2147
			m_pUpdateList = NULL;
2153
			return;
2148
			return;
2154
		}
2149
		}
2155
 
2150
 
2156
		try 
2151
		try 
2157
		{
2152
		{
2158
			System::Net::WebClient ^Client = gcnew System::Net::WebClient();
2153
			System::Net::WebClient ^Client = gcnew System::Net::WebClient();
2159
 
2154
 
2160
			System::IO::Stream ^strm = Client->OpenRead(_US(m_pUpdateList->Head()->str.ToString()));
2155
			System::IO::Stream ^strm = Client->OpenRead(_US(m_pUpdateList->front()));
2161
			System::IO::StreamReader ^sr = gcnew System::IO::StreamReader(strm);
2156
			System::IO::StreamReader ^sr = gcnew System::IO::StreamReader(strm);
2162
			System::String ^read = sr->ReadToEnd();
2157
			System::String ^read = sr->ReadToEnd();
2163
			strm->Close();
2158
			strm->Close();
2164
			sr->Close();
2159
			sr->Close();
2165
 
-
 
2166
			m_pUpdateList->Head()->data = _S(read);
2160
			m_pUpdateList->changeData(m_pUpdateList->front(), _WS(read));
2167
		}
2161
		}
2168
		catch (System::Net::WebException ^ex)
2162
		catch (System::Net::WebException ^ex)
2169
		{
2163
		{
2170
			m_pUpdateList->Head()->data = _S(";!ERROR! " + ex->ToString());
2164
			m_pUpdateList->changeData(m_pUpdateList->front(), _WS(";!ERROR! " + ex->ToString()));
2171
			if ( ex->Status == System::Net::WebExceptionStatus::ConnectFailure )
2165
			if ( ex->Status == System::Net::WebExceptionStatus::ConnectFailure )
2172
			{
-
 
2173
				m_pUpdateList->Head()->data = _S(";!ERROR! " + ex->ToString());
2166
				m_pUpdateList->changeData(m_pUpdateList->front(), _WS(";!ERROR! " + ex->ToString()));
2174
 
-
 
2175
			}
-
 
2176
		}
2167
		}
2177
	}
2168
	}
2178
 
2169
 
2179
	void MainGui::LaunchGame()
2170
	void MainGui::LaunchGame()
2180
	{
2171
	{
Line 2305... Line 2296...
2305
				this->viewReadmeToolStripMenuItem->DropDownItems->Clear();
2296
				this->viewReadmeToolStripMenuItem->DropDownItems->Clear();
2306
				if (p->countFiles(FILETYPE_README))
2297
				if (p->countFiles(FILETYPE_README))
2307
				{
2298
				{
2308
					for ( C_File *f = p->GetFirstFile(FILETYPE_README); f; f = p->GetNextFile(f) )
2299
					for ( C_File *f = p->GetFirstFile(FILETYPE_README); f; f = p->GetNextFile(f) )
2309
					{
2300
					{
2310
						if ( f->baseName().token(".", 1).isNumber() )
2301
						if ( f->baseName().token(L".", 1).isNumber() )
2311
						{
2302
						{
2312
							if ( f->baseName().token(".", 1).toInt() != m_pPackages->GetLanguage() )
2303
							if ( f->baseName().token(L".", 1).toInt() != m_pPackages->GetLanguage() )
2313
								continue;
2304
								continue;
2314
						}
2305
						}
2315
						if ( f->baseName().contains("-L") )
2306
						if ( f->baseName().contains(L"-L") )
2316
						{
2307
						{
2317
							int pos = f->baseName().findPos("-L");
2308
							int pos = f->baseName().findPos(L"-L");
2318
							int l = f->baseName().mid(pos + 2, 3).toInt();
2309
							int l = f->baseName().mid(pos + 2, 3).toInt();
2319
							if ( l != m_pPackages->GetLanguage() )
2310
							if ( l != m_pPackages->GetLanguage() )
2320
								continue;
2311
								continue;
2321
						}
2312
						}
2322
 
2313
 
Line 2349... Line 2340...
2349
						item->Text = _US(f->filename());
2340
						item->Text = _US(f->filename());
2350
						if ( this->imageList2->Images->IndexOfKey(_US(f->fileExt().lower())) > -1 )
2341
						if ( this->imageList2->Images->IndexOfKey(_US(f->fileExt().lower())) > -1 )
2351
							item->Image = this->imageList2->Images[this->imageList2->Images->IndexOfKey(_US(f->fileExt().lower()))];
2342
							item->Image = this->imageList2->Images[this->imageList2->Images->IndexOfKey(_US(f->fileExt().lower()))];
2352
						else
2343
						else
2353
						{
2344
						{
2354
							Utils::String exe = f->filePointer();
2345
							Utils::WString exe = f->filePointer();
2355
							exe = exe.findReplace("/", "\\");
2346
							exe = exe.findReplace(L"/", L"\\");
2356
							wchar_t wText[200];
-
 
2357
							::MultiByteToWideChar(CP_ACP, NULL, (char *)exe.c_str(), -1, wText, exe.length() + 1);
-
 
2358
 
2347
 
2359
							System::Drawing::Icon ^myIcon;
2348
							System::Drawing::Icon ^myIcon;
2360
							SHFILEINFO *shinfo = new SHFILEINFO();
2349
							SHFILEINFO *shinfo = new SHFILEINFO();
2361
 
2350
 
2362
							if ( FAILED(SHGetFileInfo(wText, 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_LARGEICON)) )
2351
							if ( FAILED(SHGetFileInfo(exe.c_str(), 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_LARGEICON)) )
2363
							{
2352
							{
2364
								if ( FAILED(SHGetFileInfo(wText, 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_SMALLICON)) )
2353
								if ( FAILED(SHGetFileInfo(exe.c_str(), 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_SMALLICON)))
2365
									item->Image = this->imageList2->Images[0];
2354
									item->Image = this->imageList2->Images[0];
2366
								else
2355
								else
2367
								{
2356
								{
2368
									myIcon = System::Drawing::Icon::FromHandle(IntPtr(shinfo->hIcon));
2357
									myIcon = System::Drawing::Icon::FromHandle(IntPtr(shinfo->hIcon));
2369
									item->Image = myIcon->ToBitmap();
2358
									item->Image = myIcon->ToBitmap();
Line 2580... Line 2569...
2580
		}
2569
		}
2581
	}
2570
	}
2582
 
2571
 
2583
	void MainGui::CheckFakePatchCompatability()
2572
	void MainGui::CheckFakePatchCompatability()
2584
	{
2573
	{
2585
		Utils::CStringList errorList;
2574
		Utils::WStringList errorList;
2586
		int count = 0;
2575
		int count = 0;
2587
		int packageCount = 0;
2576
		int packageCount = 0;
2588
		for ( CBaseFile *p = m_pPackages->GetFirstPackage(); p; p = m_pPackages->GetNextPackage(p) )
2577
		for ( CBaseFile *p = m_pPackages->GetFirstPackage(); p; p = m_pPackages->GetNextPackage(p) )
2589
		{
2578
		{
2590
			if ( !p->IsEnabled() ) continue;
2579
			if ( !p->IsEnabled() ) continue;
2591
			if ( !p->AnyFileType(FILETYPE_MOD) ) continue;
2580
			if ( !p->AnyFileType(FILETYPE_MOD) ) continue;
2592
 
2581
 
2593
			Utils::String packageName = p->getFullPackageName(m_pPackages->GetLanguage());
2582
			Utils::WString packageName = p->getFullPackageName(m_pPackages->GetLanguage());
2594
 
2583
 
2595
			// compare this file against all other packages
2584
			// compare this file against all other packages
2596
			for ( CBaseFile *comparePackage = m_pPackages->GetNextPackage(p); comparePackage; comparePackage = m_pPackages->GetNextPackage(comparePackage) )
2585
			for ( CBaseFile *comparePackage = m_pPackages->GetNextPackage(p); comparePackage; comparePackage = m_pPackages->GetNextPackage(comparePackage) )
2597
			{
2586
			{
2598
				if ( comparePackage == p ) continue; // dont include the same package
2587
				if ( comparePackage == p ) continue; // dont include the same package
2599
				if ( !comparePackage->IsEnabled() ) continue;
2588
				if ( !comparePackage->IsEnabled() ) continue;
2600
				if ( !comparePackage->AnyFileType(FILETYPE_MOD) ) continue;
2589
				if ( !comparePackage->AnyFileType(FILETYPE_MOD) ) continue;
2601
 
2590
 
2602
				Utils::CStringList list;
2591
				Utils::WStringList list;
2603
				if ( m_pPackages->checkCompatabilityBetweenMods(p, comparePackage, &list) )
2592
				if ( m_pPackages->checkCompatabilityBetweenMods(p, comparePackage, &list) )
2604
				{
2593
				{
2605
					Utils::String package2Name = comparePackage->getFullPackageName(m_pPackages->GetLanguage());
2594
					Utils::WString package2Name = comparePackage->getFullPackageName(m_pPackages->GetLanguage());
2606
					for(auto itr = list.begin(); itr != list.end(); itr++)
2595
					for(auto itr = list.begin(); itr != list.end(); itr++)
2607
					{
2596
					{
2608
						errorList.pushBack((*itr)->str + " (" + packageName + ")", (*itr)->data + " (" + package2Name + ")");
2597
						errorList.pushBack((*itr)->str + L" (" + packageName + L")", (*itr)->data + L" (" + package2Name + L")");
2609
						++count;
2598
						++count;
2610
					}
2599
					}
2611
					++packageCount;
2600
					++packageCount;
2612
				}
2601
				}
2613
			}
2602
			}
Line 2657... Line 2646...
2657
			this->DisplayLocked(false);
2646
			this->DisplayLocked(false);
2658
			return;
2647
			return;
2659
		}
2648
		}
2660
 
2649
 
2661
		//load globals
2650
		//load globals
2662
		Utils::CStringList globals;
2651
		Utils::WStringList globals;
2663
		m_pPackages->readGlobals(globals);
2652
		m_pPackages->readGlobals(globals);
2664
 
2653
 
2665
		EditGlobals ^edit = gcnew EditGlobals(&globals);
2654
		EditGlobals ^edit = gcnew EditGlobals(&globals);
2666
 
2655
 
2667
		// make our saved changes
2656
		// make our saved changes
2668
		auto& packageGlobals = m_pPackages->GetGlobals();
2657
		auto& packageGlobals = m_pPackages->getGlobals();
2669
		for(auto itr = packageGlobals.begin(); itr != packageGlobals.end(); itr++)
2658
		for(auto itr = packageGlobals.begin(); itr != packageGlobals.end(); itr++)
2670
			edit->SetEditedItem(_US((*itr)->str), _US((*itr)->data));
2659
			edit->SetEditedItem(_US((*itr)->str), _US((*itr)->data));
2671
 
2660
 
2672
		if ( edit->ShowDialog(this) == Windows::Forms::DialogResult::OK )
2661
		if ( edit->ShowDialog(this) == Windows::Forms::DialogResult::OK )
2673
		{
2662
		{
2674
			// compare whats different and save
2663
			// compare whats different and save
2675
			packageGlobals.clear();
2664
			packageGlobals.clear();
2676
			for (SStringList* str = edit->GetSavedSettings()->Head(); str; str = str->next)
2665
			for (auto itr = edit->GetSavedSettings()->begin(); itr != edit->GetSavedSettings()->end(); itr++)
2677
				packageGlobals.pushBack(str->str.ToString(), str->data.ToString());
2666
				packageGlobals.pushBack((*itr)->str, (*itr)->data);
2678
		}
2667
		}
2679
	}
2668
	}
2680
 
2669
 
2681
	void MainGui::ViewFileLog()
2670
	void MainGui::ViewFileLog()
2682
	{
2671
	{
Line 2687... Line 2676...
2687
			FileLog ^log = gcnew FileLog;
2676
			FileLog ^log = gcnew FileLog;
2688
			for(auto itr = m_pFileErrors->begin(); itr != m_pFileErrors->end(); itr++)
2677
			for(auto itr = m_pFileErrors->begin(); itr != m_pFileErrors->end(); itr++)
2689
			{
2678
			{
2690
				bool add = true;
2679
				bool add = true;
2691
				String ^status = "Unknown Error";
2680
				String ^status = "Unknown Error";
2692
				switch((*itr)->data.token(" ", 1).toInt())
2681
				switch((*itr)->data.token(L" ", 1).toInt())
2693
				{
2682
				{
2694
					case SPKINSTALL_CREATEDIRECTORY:
2683
					case SPKINSTALL_CREATEDIRECTORY:
2695
						status = "Created Directory";
2684
						status = "Created Directory";
2696
						break;
2685
						break;
2697
					case SPKINSTALL_CREATEDIRECTORY_FAIL:
2686
					case SPKINSTALL_CREATEDIRECTORY_FAIL:
Line 2789... Line 2778...
2789
						break;
2778
						break;
2790
				}
2779
				}
2791
 
2780
 
2792
				if ( add )
2781
				if ( add )
2793
				{
2782
				{
2794
					if ((*itr)->data.countToken(" ") > 1 )
2783
					if ((*itr)->data.countToken(L" ") > 1 )
2795
						log->AddItem(_US((*itr)->str.findReplace("~", " => ")), status, _US(SPK::ConvertTimeString((long)(*itr)->data.token(" ", 2).toLong())));
2784
						log->AddItem(_US((*itr)->str.findReplace(L"~", L" => ")), status, _US(SPK::ConvertTimeString((long)(*itr)->data.token(L" ", 2).toLong())));
2796
					else
2785
					else
2797
						log->AddItem(_US((*itr)->str.findReplace("~", " => ")), status, nullptr);
2786
						log->AddItem(_US((*itr)->str.findReplace(L"~", L" => ")), status, nullptr);
2798
				}
2787
				}
2799
			}
2788
			}
2800
			if ( log->ShowDialog(this) == Windows::Forms::DialogResult::Cancel )
2789
			if ( log->ShowDialog(this) == Windows::Forms::DialogResult::Cancel )
2801
			{
2790
			{
2802
				if ( MessageBox::Show(this, "Are you sure you want to clear the file log?", "Clear File Log", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == Windows::Forms::DialogResult::Yes )
2791
				if ( MessageBox::Show(this, "Are you sure you want to clear the file log?", "Clear File Log", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == Windows::Forms::DialogResult::Yes )
Line 2809... Line 2798...
2809
		}
2798
		}
2810
	}
2799
	}
2811
 
2800
 
2812
	void MainGui::VerifyInstalledFiles()
2801
	void MainGui::VerifyInstalledFiles()
2813
	{
2802
	{
2814
		Utils::CStringList missing;
2803
		Utils::WStringList missing;
2815
		int amount = m_pPackages->verifyInstalledFiles(&missing);
2804
		int amount = m_pPackages->verifyInstalledFiles(&missing);
2816
		if ( !amount )
2805
		if ( !amount )
2817
			MessageBox::Show(this, "All files are currently installed", "Verifying Installed Files", MessageBoxButtons::OK, MessageBoxIcon::Information);
2806
			MessageBox::Show(this, "All files are currently installed", "Verifying Installed Files", MessageBoxButtons::OK, MessageBoxIcon::Information);
2818
		else
2807
		else
2819
		{
2808
		{
2820
			String ^text;
2809
			String ^text;
2821
			for(auto itr = missing.begin(); itr != missing.end(); itr++)
2810
			for(auto itr = missing.begin(); itr != missing.end(); itr++)
2822
			{
2811
			{
2823
				text += _US((*itr)->str);
2812
				text += _US((*itr)->str);
2824
				text += "\n\t";
2813
				text += "\n\t";
2825
				text += _US((*itr)->data.findReplace("\n", "\t\n"));
2814
				text += _US((*itr)->data.findReplace(L"\n", L"\t\n"));
2826
				text += "\n\n";
2815
				text += "\n\n";
2827
			}
2816
			}
2828
			MessageBoxDetails::Show(this, "Verifing Installed Files", "Missing files detected\nAmount = " + amount, text, false, 600);
2817
			MessageBoxDetails::Show(this, "Verifing Installed Files", "Missing files detected\nAmount = " + amount, text, false, 600);
2829
		}
2818
		}
2830
	}
2819
	}