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