1 |
cycrow |
1 |
// PluginManager.cpp : main project file.
|
|
|
2 |
|
|
|
3 |
#include "stdafx.h"
|
|
|
4 |
#include "Forms\MainGui.h"
|
|
|
5 |
#include "Forms\StartUp.h"
|
|
|
6 |
#include "Languages.h"
|
|
|
7 |
|
|
|
8 |
using namespace PluginManager;
|
|
|
9 |
using namespace Microsoft::Win32;
|
|
|
10 |
using namespace System::IO;
|
|
|
11 |
|
|
|
12 |
#include <spk.h>
|
|
|
13 |
#undef GetTempPath
|
|
|
14 |
#undef GetCurrentDirectory
|
|
|
15 |
|
|
|
16 |
CPackages packages;
|
|
|
17 |
|
|
|
18 |
[STAThreadAttribute]
|
|
|
19 |
int main(array<System::String ^> ^args)
|
|
|
20 |
{
|
|
|
21 |
// Enabling Windows XP visual effects before any controls are created
|
|
|
22 |
Application::EnableVisualStyles();
|
|
|
23 |
Application::SetCompatibleTextRenderingDefault(false);
|
|
|
24 |
|
|
|
25 |
System::String ^tempDir = System::IO::Path::GetTempPath();
|
|
|
26 |
System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
|
|
|
27 |
System::String ^progfile = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles );
|
|
|
28 |
|
196 |
cycrow |
29 |
Utils::WStringList dirList;
|
|
|
30 |
Utils::WStringList remDirList;
|
1 |
cycrow |
31 |
System::String ^gameArgs;
|
|
|
32 |
System::String ^openPackage;
|
|
|
33 |
|
104 |
cycrow |
34 |
CLanguages::Instance()->SetLanguage(44);
|
1 |
cycrow |
35 |
|
64 |
cycrow |
36 |
bool Advanced = false, fromLauncher = false, silent = false, gamerun = false;
|
1 |
cycrow |
37 |
for ( int i = 0; i < args->Length; i++ )
|
|
|
38 |
{
|
191 |
cycrow |
39 |
Utils::WString arg = _WS(args[i]);
|
1 |
cycrow |
40 |
|
64 |
cycrow |
41 |
if ( gamerun ) {
|
|
|
42 |
if ( gameArgs && gameArgs->Length ) gameArgs += " ";
|
|
|
43 |
gameArgs += args[i];
|
|
|
44 |
}
|
1 |
cycrow |
45 |
// its a switch
|
191 |
cycrow |
46 |
else if ( arg.left(2) == L"--" )
|
1 |
cycrow |
47 |
{
|
191 |
cycrow |
48 |
Utils::WString argSwitch = arg.token(L":", 1).lower();
|
|
|
49 |
Utils::WString argSwitchFirst = arg.token(L" ", 1).lower();
|
|
|
50 |
Utils::WString rest = arg.tokens(L":", 2);
|
192 |
cycrow |
51 |
if (!rest.empty())
|
1 |
cycrow |
52 |
{
|
192 |
cycrow |
53 |
if (rest[0] == '"' && rest[rest.length() - 1] != '"')
|
1 |
cycrow |
54 |
{
|
192 |
cycrow |
55 |
rest.erase(0, 1);
|
|
|
56 |
while (i < args->Length)
|
|
|
57 |
{
|
|
|
58 |
i++;
|
|
|
59 |
Utils::WString argCheck = _WS(args[i]);
|
|
|
60 |
rest += " ";
|
|
|
61 |
rest += argCheck;
|
|
|
62 |
if (argCheck.right(1) == L"\"")
|
|
|
63 |
break;
|
|
|
64 |
}
|
1 |
cycrow |
65 |
}
|
192 |
cycrow |
66 |
|
|
|
67 |
if (rest.right(1) == L"\"")
|
|
|
68 |
rest.truncate(rest.length() - 1);
|
1 |
cycrow |
69 |
}
|
191 |
cycrow |
70 |
if ( argSwitch == "--dir" && !rest.empty() )
|
1 |
cycrow |
71 |
{
|
191 |
cycrow |
72 |
Utils::String gameName = packages.getGameName(rest.toString());
|
121 |
cycrow |
73 |
if ( !gameName.empty() )
|
196 |
cycrow |
74 |
dirList.pushBack(rest, gameName);
|
1 |
cycrow |
75 |
}
|
|
|
76 |
|
|
|
77 |
if ( argSwitch == "--advanced" )
|
|
|
78 |
Advanced = true;
|
|
|
79 |
else if ( argSwitch == "--fromlauncher" )
|
|
|
80 |
fromLauncher = true;
|
|
|
81 |
else if ( argSwitch == "--silent" )
|
|
|
82 |
silent = true;
|
|
|
83 |
else if ( argSwitch == "--forceemp" )
|
|
|
84 |
packages.SetForceEMP(true);
|
191 |
cycrow |
85 |
else if (argSwitch == "--gamerun" && !rest.empty())
|
1 |
cycrow |
86 |
{
|
191 |
cycrow |
87 |
gameArgs = _US(rest);
|
1 |
cycrow |
88 |
break;
|
|
|
89 |
}
|
64 |
cycrow |
90 |
else if ( argSwitch == "--gamerun" ) {
|
|
|
91 |
gamerun = true;
|
|
|
92 |
}
|
|
|
93 |
else if ( argSwitchFirst == "--gamerun" ) {
|
|
|
94 |
gamerun = true;
|
191 |
cycrow |
95 |
gameArgs = _US(arg.tokens(L" ", 2));
|
64 |
cycrow |
96 |
}
|
1 |
cycrow |
97 |
else if ( argSwitch == "--noresume" )
|
|
|
98 |
{
|
|
|
99 |
RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
|
|
|
100 |
if ( searchKey )
|
|
|
101 |
searchKey->SetValue("DontAutoResume", 1);
|
|
|
102 |
}
|
|
|
103 |
else if ( argSwitch == "--resume" )
|
|
|
104 |
{
|
|
|
105 |
int zero = 0;
|
|
|
106 |
RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
|
|
|
107 |
if ( searchKey )
|
|
|
108 |
searchKey->SetValue("DontAutoResume", zero);
|
|
|
109 |
}
|
55 |
cycrow |
110 |
else if ( argSwitch == "--debug" ) {
|
|
|
111 |
CFileLog *log = dynamic_cast<CFileLog *>(CFileLog::create());
|
|
|
112 |
log->setFile(_S(mydoc) + "/Egosoft/pluginmanager.log");
|
84 |
cycrow |
113 |
log->setFilter(CLog::Log_Install | CLog::Log_Uninstall | CLog::Log_IO | CLog::Log_Directory | CLog::Log_File);
|
191 |
cycrow |
114 |
log->setLevel(rest.toInt());
|
55 |
cycrow |
115 |
}
|
1 |
cycrow |
116 |
}
|
|
|
117 |
// otherwise it must be a file to open
|
|
|
118 |
else
|
191 |
cycrow |
119 |
openPackage = _US(arg);
|
1 |
cycrow |
120 |
}
|
|
|
121 |
|
84 |
cycrow |
122 |
#if _DEBUG
|
|
|
123 |
CFileLog *log = dynamic_cast<CFileLog *>(CFileLog::create());
|
|
|
124 |
log->setFile(_S(mydoc) + "/Egosoft/pluginmanager.log");
|
|
|
125 |
log->setFilter(CLog::Log_Install | CLog::Log_Uninstall | CLog::Log_IO | CLog::Log_Directory | CLog::Log_File);
|
|
|
126 |
log->setLevel(5);
|
86 |
cycrow |
127 |
Advanced = true;
|
84 |
cycrow |
128 |
#endif
|
|
|
129 |
|
1 |
cycrow |
130 |
//TODO: Load languge xml
|
|
|
131 |
//Language.LoadLanguages();
|
|
|
132 |
|
|
|
133 |
// get the last language used
|
|
|
134 |
RegistryKey ^searchKeyLang = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
|
|
|
135 |
if ( searchKeyLang )
|
|
|
136 |
{
|
|
|
137 |
int lang = System::Convert::ToInt32(searchKeyLang->GetValue("Language"));
|
|
|
138 |
if ( lang )
|
104 |
cycrow |
139 |
CLanguages::Instance()->SetLanguage(lang);
|
1 |
cycrow |
140 |
}
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
bool firstInstance = false;
|
|
|
144 |
System::Threading::Mutex ^mut = gcnew System::Threading::Mutex(false, "Local\\XPluginManagerLite", firstInstance);
|
|
|
145 |
if ( !firstInstance )
|
|
|
146 |
{
|
|
|
147 |
if ( openPackage )
|
|
|
148 |
{
|
|
|
149 |
if ( File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
|
|
|
150 |
{
|
|
|
151 |
StreamWriter ^sw = File::AppendText(mydoc + "\\Egosoft\\pluginmanager_load.dat");
|
|
|
152 |
try
|
|
|
153 |
{
|
|
|
154 |
sw->WriteLine("File: " + openPackage);
|
|
|
155 |
}
|
|
|
156 |
finally
|
|
|
157 |
{
|
|
|
158 |
if ( sw )
|
|
|
159 |
delete (IDisposable ^)sw;
|
|
|
160 |
}
|
|
|
161 |
}
|
|
|
162 |
else
|
|
|
163 |
{
|
|
|
164 |
StreamWriter ^sw = File::CreateText(mydoc + "\\Egosoft\\pluginmanager_load.dat");
|
|
|
165 |
try
|
|
|
166 |
{
|
|
|
167 |
sw->WriteLine("File: " + openPackage);
|
|
|
168 |
}
|
|
|
169 |
finally
|
|
|
170 |
{
|
|
|
171 |
if ( sw )
|
|
|
172 |
delete (IDisposable ^)sw;
|
|
|
173 |
}
|
|
|
174 |
}
|
|
|
175 |
}
|
|
|
176 |
else if ( !silent )
|
104 |
cycrow |
177 |
MessageBox::Show(_US(CLanguages::Instance()->findText(LS_STARTUP, LANGSTARTUP_ANOTHERINSTANCE)), _US(CLanguages::Instance()->findText(LS_STARTUP, LANGSTARTUP_ANOTHERINSTANCE_TITLE)), MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
1 |
cycrow |
178 |
return 0;
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
|
|
|
182 |
if ( searchKey )
|
|
|
183 |
{
|
|
|
184 |
searchKey->SetValue("Run", System::Windows::Forms::Application::ExecutablePath);
|
|
|
185 |
searchKey->SetValue("Version", (float)PMLVERSION);
|
|
|
186 |
searchKey->SetValue("Beta", (int)PMLBETA);
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
if ( File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
|
|
|
191 |
File::Delete(mydoc + "\\Egosoft\\pluginmanager_load.dat");
|
|
|
192 |
if ( File::Exists(tempDir + "\\AutoUpdater_old.exe") )
|
|
|
193 |
File::Delete(tempDir + "\\AutoUpdater_old.exe");
|
|
|
194 |
|
158 |
cycrow |
195 |
packages.startup(".", _S(tempDir), _S(mydoc), "");
|
1 |
cycrow |
196 |
packages.SetRenameText(true);
|
|
|
197 |
|
|
|
198 |
// Create the main window and run it
|
|
|
199 |
MainGui ^gui = gcnew MainGui(&packages, &dirList, &remDirList, Advanced);
|
|
|
200 |
gui->AddGameArgs(gameArgs);
|
|
|
201 |
|
50 |
cycrow |
202 |
|
1 |
cycrow |
203 |
// load in the config file
|
121 |
cycrow |
204 |
CFileIO configFile(_S(mydoc) + "/Egosoft/pluginmanager.dat");
|
1 |
cycrow |
205 |
bool anyDirs = false;
|
52 |
cycrow |
206 |
if ( configFile.exists() )
|
1 |
cycrow |
207 |
{
|
121 |
cycrow |
208 |
std::vector<Utils::String> *readFile = configFile.readLines();
|
1 |
cycrow |
209 |
if ( readFile )
|
|
|
210 |
{
|
|
|
211 |
for ( int i = 0; i < (int)readFile->size(); i++ )
|
|
|
212 |
{
|
121 |
cycrow |
213 |
Utils::String line(readFile->at(i));
|
|
|
214 |
Utils::String cmd = line.token(":", 1).lower();
|
|
|
215 |
Utils::String rest = line.tokens(":", 2).removeFirstSpace();
|
1 |
cycrow |
216 |
|
|
|
217 |
if ( cmd == "dir" )
|
|
|
218 |
{
|
|
|
219 |
// first check its on the list
|
121 |
cycrow |
220 |
if ( !dirList.findString(rest) )
|
1 |
cycrow |
221 |
{
|
182 |
cycrow |
222 |
Utils::String gameName = packages.getGameName(rest);
|
121 |
cycrow |
223 |
if ( !gameName.empty() )
|
1 |
cycrow |
224 |
{
|
182 |
cycrow |
225 |
int lang = packages.getGameLanguage(rest);
|
1 |
cycrow |
226 |
if ( lang )
|
121 |
cycrow |
227 |
dirList.pushBack(rest, Utils::String::Number(lang) + "|" + gameName);
|
1 |
cycrow |
228 |
else
|
121 |
cycrow |
229 |
dirList.pushBack(rest, gameName);
|
1 |
cycrow |
230 |
anyDirs = true;
|
|
|
231 |
}
|
|
|
232 |
}
|
|
|
233 |
}
|
|
|
234 |
else if ( cmd == "remdir" )
|
|
|
235 |
{
|
|
|
236 |
// first check its on the list
|
121 |
cycrow |
237 |
if ( !remDirList.findString(rest) )
|
1 |
cycrow |
238 |
{
|
121 |
cycrow |
239 |
remDirList.pushBack(rest);
|
1 |
cycrow |
240 |
anyDirs = true;
|
|
|
241 |
}
|
|
|
242 |
}
|
|
|
243 |
else if ( cmd == "experimental" )
|
|
|
244 |
gui->SetExperimental(true);
|
|
|
245 |
else if ( cmd == "filterships" )
|
|
|
246 |
gui->SetShips(true);
|
|
|
247 |
else if ( cmd == "filtersigned" )
|
|
|
248 |
gui->SetOnlySigned(true);
|
|
|
249 |
else if ( cmd == "modselectordetails" )
|
|
|
250 |
gui->SetModSelectorDetails(true);
|
|
|
251 |
else if ( cmd == "cheat" )
|
|
|
252 |
gui->SetCheat(true);
|
|
|
253 |
else if ( cmd == "downloadable" )
|
|
|
254 |
gui->SetDownloadable(true);
|
|
|
255 |
else if ( cmd == "noautoupdate" )
|
|
|
256 |
gui->SetAutoUpdate(false);
|
|
|
257 |
else if ( cmd == "managersize" )
|
121 |
cycrow |
258 |
gui->SetSize(rest.token(" ", 2).toLong(), rest.token(" ", 1).toLong());
|
1 |
cycrow |
259 |
else if ( cmd == "managerpos" )
|
121 |
cycrow |
260 |
gui->Location = System::Drawing::Point(rest.token(" ", 1).toLong(), rest.token(" ", 2).toLong());
|
1 |
cycrow |
261 |
else if ( cmd == "managermax" )
|
|
|
262 |
gui->WindowState = FormWindowState::Maximized;
|
|
|
263 |
else if ( cmd == "tips" )
|
121 |
cycrow |
264 |
gui->SetTips(rest.token(" ", 1).toInt(), rest.token(" ", 2).toInt());
|
1 |
cycrow |
265 |
else if ( cmd == "ignorejoy" )
|
121 |
cycrow |
266 |
gui->SetIgnoreJoy(rest.toInt());
|
1 |
cycrow |
267 |
else if ( cmd == "savegamemanager" )
|
121 |
cycrow |
268 |
gui->SetSaveGameManager(rest.toInt());
|
1 |
cycrow |
269 |
else if ( cmd == "restoremodified" ) {
|
|
|
270 |
CPackages p;
|
158 |
cycrow |
271 |
p.startup(".", _S(tempDir), _S(mydoc), "");
|
182 |
cycrow |
272 |
if ( p.read(rest) ) {
|
1 |
cycrow |
273 |
p.SetVanilla(false);
|
|
|
274 |
p.PrepareEnableFromVanilla();
|
183 |
cycrow |
275 |
p.enablePreparedPackages(0, 0, 0);
|
|
|
276 |
p.closeDir();
|
1 |
cycrow |
277 |
}
|
|
|
278 |
}
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
delete readFile;
|
|
|
282 |
}
|
|
|
283 |
}
|
|
|
284 |
|
121 |
cycrow |
285 |
// still no directories, quit
|
|
|
286 |
if (dirList.empty() && openPackage)
|
1 |
cycrow |
287 |
{
|
121 |
cycrow |
288 |
MessageBox::Show("You dont currently have any controlled directories", "Open Package", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
289 |
return 1;
|
1 |
cycrow |
290 |
}
|
|
|
291 |
|
196 |
cycrow |
292 |
Utils::WString dir = dirList.empty() ? L"" : dirList.first()->str;
|
1 |
cycrow |
293 |
|
|
|
294 |
StartUp ^startup = gcnew StartUp(&packages, &dir, (openPackage) ? true : false, Advanced);
|
|
|
295 |
Application::Run(startup);
|
|
|
296 |
|
|
|
297 |
// opening a package from command line
|
|
|
298 |
if ( openPackage )
|
|
|
299 |
{
|
|
|
300 |
if ( gui->InstallPackage(openPackage, true, false, false) )
|
|
|
301 |
{
|
182 |
cycrow |
302 |
if ( !packages.getModKey().empty() )
|
|
|
303 |
PluginManager::WriteRegistryValue(packages.getModKey(), packages.selectedModName());
|
183 |
cycrow |
304 |
packages.closeDir(0, 0, true);
|
1 |
cycrow |
305 |
return 0;
|
|
|
306 |
}
|
|
|
307 |
return 1;
|
|
|
308 |
}
|
|
|
309 |
|
121 |
cycrow |
310 |
gui->UpdateDirList("");
|
1 |
cycrow |
311 |
gui->UpdateControls();
|
|
|
312 |
gui->UpdatePackages();
|
|
|
313 |
gui->StartCheckTimer();
|
133 |
cycrow |
314 |
gui->FindPackages();
|
1 |
cycrow |
315 |
|
182 |
cycrow |
316 |
System::String ^mod = PluginManager::ReadRegistryValue(packages.getModKey());
|
160 |
cycrow |
317 |
packages.setMod(_S(mod));
|
1 |
cycrow |
318 |
|
|
|
319 |
gui->CheckProtectedDir();
|
|
|
320 |
Application::Run(gui);
|
|
|
321 |
|
|
|
322 |
// close directory
|
|
|
323 |
if ( packages.IsLoaded() )
|
|
|
324 |
{
|
182 |
cycrow |
325 |
if ( !packages.getModKey().empty() )
|
|
|
326 |
PluginManager::WriteRegistryValue(packages.getModKey(), packages.selectedModName());
|
1 |
cycrow |
327 |
if ( packages.AnyUnusedShared() )
|
|
|
328 |
{
|
|
|
329 |
if ( MessageBox::Show("You have some unused shared files, would you like to remove these?", "Remove Shared Files", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes)
|
183 |
cycrow |
330 |
packages.removeUnusedSharedFiles();
|
1 |
cycrow |
331 |
}
|
183 |
cycrow |
332 |
packages.closeDir(0, 0, true);
|
1 |
cycrow |
333 |
}
|
|
|
334 |
|
196 |
cycrow |
335 |
Utils::WStringList restoreModified;
|
1 |
cycrow |
336 |
if ( gui->GetDownloadFile() )
|
|
|
337 |
{
|
|
|
338 |
if ( System::IO::File::Exists(".\\AutoUpdater.exe") )
|
|
|
339 |
{
|
|
|
340 |
// rename the autoupdater
|
|
|
341 |
System::String ^dir = System::IO::FileInfo(System::Windows::Forms::Application::ExecutablePath).DirectoryName;
|
|
|
342 |
if ( System::IO::File::Exists(tempDir + "\\AutoUpdater_old.exe") )
|
|
|
343 |
System::IO::File::Delete(tempDir + "\\AutoUpdater_old.exe");
|
|
|
344 |
System::IO::File::Copy(dir + "\\AutoUpdater.exe", tempDir + "\\AutoUpdater_old.exe");
|
|
|
345 |
|
|
|
346 |
System::Diagnostics::ProcessStartInfo ^info = nullptr;
|
|
|
347 |
if ( System::IO::File::Exists(tempDir + "\\AutoUpdater_old.exe") )
|
|
|
348 |
info = gcnew System::Diagnostics::ProcessStartInfo(tempDir + "\\AutoUpdater_old.exe");
|
|
|
349 |
else
|
|
|
350 |
{
|
|
|
351 |
MessageBox::Show("Error trying to update the Plugin Manager\nUnable to load AutoUpdater", "AutoUpdate", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
352 |
System::Windows::Forms::Application::Restart();
|
|
|
353 |
return 0;
|
|
|
354 |
}
|
|
|
355 |
|
|
|
356 |
if ( info )
|
|
|
357 |
{
|
|
|
358 |
info->WorkingDirectory = dir;
|
|
|
359 |
info->Arguments = "\"" + gui->GetDownloadFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\"";
|
|
|
360 |
info->UseShellExecute = false;
|
|
|
361 |
info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
|
|
|
362 |
System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
|
|
|
363 |
}
|
|
|
364 |
}
|
|
|
365 |
else
|
|
|
366 |
{
|
|
|
367 |
MessageBox::Show("Error trying to update the Plugin Manager\nUnable to load AutoUpdater", "AutoUpdate", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
368 |
System::Windows::Forms::Application::Restart();
|
|
|
369 |
}
|
|
|
370 |
}
|
|
|
371 |
else if ( gui->GetRunFile() )
|
|
|
372 |
{
|
|
|
373 |
System::String ^dir = System::IO::FileInfo(System::Windows::Forms::Application::ExecutablePath).DirectoryName;
|
|
|
374 |
|
|
|
375 |
// manager was run from the launcher, ie the launcher is still running, send a message to run the game instead of loading another one
|
|
|
376 |
if ( fromLauncher )
|
|
|
377 |
{
|
|
|
378 |
StreamWriter ^sw = File::CreateText(mydoc + "\\Egosoft\\launchgame.dat");
|
|
|
379 |
try
|
|
|
380 |
{
|
|
|
381 |
sw->WriteLine("File:" + gui->GetRunFile());
|
|
|
382 |
if ( gui->GetGameArgs() && gui->GetGameArgs()->Length )
|
|
|
383 |
sw->WriteLine("Args:" + gui->GetGameArgs());
|
|
|
384 |
}
|
|
|
385 |
finally
|
|
|
386 |
{
|
|
|
387 |
if ( sw )
|
|
|
388 |
delete (IDisposable ^)sw;
|
|
|
389 |
}
|
|
|
390 |
}
|
|
|
391 |
else
|
|
|
392 |
{
|
|
|
393 |
if ( System::IO::File::Exists(dir + "\\GameLauncher.exe") )
|
|
|
394 |
{
|
|
|
395 |
System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(dir + "\\GameLauncher.exe");
|
|
|
396 |
if ( info )
|
|
|
397 |
{
|
|
|
398 |
if ( packages.GetCurrentGameFlags() & EXEFLAG_ADDON ) {
|
|
|
399 |
CPackages p;
|
158 |
cycrow |
400 |
p.startup(".", _S(tempDir), _S(mydoc), "");
|
196 |
cycrow |
401 |
Utils::WString baseDir = CFileIO(_S(gui->GetRunFile())).dir();
|
|
|
402 |
if ( p.read(baseDir.toString()) ) {
|
1 |
cycrow |
403 |
if ( !p.IsVanilla() ) {
|
|
|
404 |
p.SetVanilla(true);
|
|
|
405 |
p.PrepareDisableForVanilla();
|
183 |
cycrow |
406 |
p.enablePreparedPackages(0, 0, 0);
|
158 |
cycrow |
407 |
restoreModified.pushBack(baseDir);
|
1 |
cycrow |
408 |
}
|
183 |
cycrow |
409 |
p.closeDir();
|
1 |
cycrow |
410 |
}
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
info->WorkingDirectory = dir;
|
105 |
cycrow |
414 |
info->Arguments = "";
|
|
|
415 |
if ( Advanced ) info->Arguments = "--advanced ";
|
1 |
cycrow |
416 |
if ( gui->GetGameArgs() && gui->GetGameArgs()->Length )
|
105 |
cycrow |
417 |
info->Arguments += "\"" + gui->GetRunFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\" \"" + gui->GetGameArgs() + "\"";
|
1 |
cycrow |
418 |
else
|
105 |
cycrow |
419 |
info->Arguments += "\"" + gui->GetRunFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\"";
|
1 |
cycrow |
420 |
info->UseShellExecute = false;
|
|
|
421 |
info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
|
|
|
422 |
System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
|
|
|
423 |
}
|
|
|
424 |
}
|
|
|
425 |
}
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
// write config
|
121 |
cycrow |
429 |
std::vector<Utils::String> writeLines;
|
|
|
430 |
for(auto itr = dirList.begin(); itr != dirList.end(); itr++)
|
1 |
cycrow |
431 |
{
|
196 |
cycrow |
432 |
writeLines.push_back("Dir:" + (*itr)->str.toString());
|
|
|
433 |
Utils::WString data;
|
121 |
cycrow |
434 |
if ((*itr)->data.isin("|") )
|
1 |
cycrow |
435 |
{
|
196 |
cycrow |
436 |
data = CPackages::ConvertLanguage((*itr)->data.token(L"|", 1).toInt()).toWString() + L"|";
|
|
|
437 |
data += (*itr)->data.tokens(L"|", 2);
|
1 |
cycrow |
438 |
}
|
|
|
439 |
else
|
121 |
cycrow |
440 |
data = (*itr)->data;
|
1 |
cycrow |
441 |
|
196 |
cycrow |
442 |
Utils::WString exe = CFileIO(packages.GetGameExe()->GetGameRunExe((*itr)->str.toString())).fullFilename();
|
|
|
443 |
writeLines.push_back((L"DirExe:" + data + L"|" + exe).toString());
|
1 |
cycrow |
444 |
|
|
|
445 |
// do the log files
|
196 |
cycrow |
446 |
writeLines.push_back("GameLog:" + packages.logDirectory(exe.toString()) + "|" + exe.toString());
|
1 |
cycrow |
447 |
|
|
|
448 |
}
|
121 |
cycrow |
449 |
for (auto itr = remDirList.begin(); itr != remDirList.end(); itr++)
|
196 |
cycrow |
450 |
writeLines.push_back("RemDir:" + (*itr)->str.toString());
|
1 |
cycrow |
451 |
if ( gui->IsExperimental() )
|
|
|
452 |
writeLines.push_back("Experimental:");
|
|
|
453 |
if ( gui->IsShips() )
|
|
|
454 |
writeLines.push_back("FilterShips:");
|
|
|
455 |
if ( gui->IsOnlySigned() )
|
|
|
456 |
writeLines.push_back("FilterSigned:");
|
|
|
457 |
if ( gui->IsCheat() )
|
|
|
458 |
writeLines.push_back("Cheat:");
|
121 |
cycrow |
459 |
writeLines.push_back(Utils::String("SaveGameManager:") + (long)gui->GetSaveGameManager());
|
1 |
cycrow |
460 |
if ( gui->IsDownloadable() )
|
|
|
461 |
writeLines.push_back("Downloadable:");
|
|
|
462 |
if ( gui->IsModSelectorDetailsShowing() )
|
|
|
463 |
writeLines.push_back("ModSelectorDetails:");
|
|
|
464 |
if ( !gui->IsAutoUpdate() )
|
|
|
465 |
writeLines.push_back("NoAutoUpdate:");
|
|
|
466 |
if ( gui->WindowState == FormWindowState::Normal )
|
|
|
467 |
{
|
121 |
cycrow |
468 |
writeLines.push_back(Utils::String("ManagerSize:") + (long)gui->Size.Height + " " + (long)gui->Size.Width);
|
|
|
469 |
writeLines.push_back(Utils::String("ManagerPos:") + (long)gui->Location.X + " " + (long)gui->Location.Y);
|
1 |
cycrow |
470 |
}
|
|
|
471 |
else
|
|
|
472 |
{
|
121 |
cycrow |
473 |
writeLines.push_back(Utils::String("ManagerPos:") + (long)gui->RestoreBounds.Location.X + " " + (long)gui->RestoreBounds.Location.Y);
|
|
|
474 |
writeLines.push_back(Utils::String("ManagerSize:") + (long)gui->RestoreBounds.Size.Height + " " + (long)gui->RestoreBounds.Size.Width);
|
1 |
cycrow |
475 |
}
|
|
|
476 |
|
|
|
477 |
if ( gui->WindowState == FormWindowState::Maximized )
|
|
|
478 |
writeLines.push_back("ManagerMax:");
|
|
|
479 |
if ( gui->GetIgnoreJoy() )
|
121 |
cycrow |
480 |
writeLines.push_back(Utils::String("IgnoreJoy:") + gui->GetIgnoreJoy());
|
1 |
cycrow |
481 |
|
|
|
482 |
for ( int i = 0; i < gui->GetMaxTips(); i++ )
|
|
|
483 |
{
|
|
|
484 |
int tips = gui->GetTips(i);
|
|
|
485 |
if ( tips == -1 )
|
|
|
486 |
continue;
|
121 |
cycrow |
487 |
writeLines.push_back(Utils::String("Tips: ") + (long)i + " " + (long)tips);
|
1 |
cycrow |
488 |
}
|
|
|
489 |
|
158 |
cycrow |
490 |
for (auto rm = restoreModified.begin(); rm != restoreModified.end(); rm++) {
|
196 |
cycrow |
491 |
writeLines.push_back("RestoreModified: " + (*rm)->str.toString());
|
1 |
cycrow |
492 |
}
|
|
|
493 |
|
|
|
494 |
// write settings
|
121 |
cycrow |
495 |
configFile.writeFile(&writeLines);
|
1 |
cycrow |
496 |
|
|
|
497 |
return 0;
|
|
|
498 |
}
|