Subversion Repositories spk

Rev

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

Rev 196 Rev 197
Line 29... Line 29...
29
	Utils::WStringList dirList;
29
	Utils::WStringList dirList;
30
	Utils::WStringList remDirList;
30
	Utils::WStringList remDirList;
31
	System::String ^gameArgs;
31
	System::String ^gameArgs;
32
	System::String ^openPackage;
32
	System::String ^openPackage;
33
 
33
 
34
	CLanguages::Instance()->SetLanguage(44);
34
	CLanguages::Instance()->setLanguage(44);
35
 
35
 
36
	bool Advanced = false, fromLauncher = false, silent = false, gamerun = false;
36
	bool Advanced = false, fromLauncher = false, silent = false, gamerun = false;
37
	for ( int i = 0; i < args->Length; i++ )
37
	for ( int i = 0; i < args->Length; i++ )
38
	{
38
	{
39
		Utils::WString arg = _WS(args[i]);
39
		Utils::WString arg = _WS(args[i]);
Line 65... Line 65...
65
				}
65
				}
66
 
66
 
67
				if (rest.right(1) == L"\"")
67
				if (rest.right(1) == L"\"")
68
					rest.truncate(rest.length() - 1);
68
					rest.truncate(rest.length() - 1);
69
			}
69
			}
70
			if ( argSwitch == "--dir" && !rest.empty() )
70
			if ( argSwitch == L"--dir" && !rest.empty() )
71
			{
71
			{
72
				Utils::String gameName = packages.getGameName(rest.toString());
72
				Utils::WString gameName = packages.getGameName(rest);
73
				if ( !gameName.empty() )
73
				if ( !gameName.empty() )
74
					dirList.pushBack(rest, gameName);
74
					dirList.pushBack(rest, gameName);
75
			}
75
			}
76
 
76
 
77
			if ( argSwitch == "--advanced" )
77
			if ( argSwitch == L"--advanced" )
78
				Advanced = true;
78
				Advanced = true;
79
			else if ( argSwitch == "--fromlauncher" )
79
			else if ( argSwitch == L"--fromlauncher" )
80
				fromLauncher = true;
80
				fromLauncher = true;
81
			else if ( argSwitch == "--silent" )
81
			else if ( argSwitch == L"--silent" )
82
				silent = true;
82
				silent = true;
83
			else if ( argSwitch == "--forceemp" )
83
			else if ( argSwitch == L"--forceemp" )
84
				packages.SetForceEMP(true);
84
				packages.SetForceEMP(true);
85
			else if (argSwitch == "--gamerun" && !rest.empty())
85
			else if (argSwitch == L"--gamerun" && !rest.empty())
86
			{
86
			{
87
				gameArgs = _US(rest);
87
				gameArgs = _US(rest);
88
				break;
88
				break;
89
			}
89
			}
90
			else if ( argSwitch == "--gamerun" ) {
90
			else if ( argSwitch == L"--gamerun" ) {
91
				gamerun = true;
91
				gamerun = true;
92
			}
92
			}
93
			else if ( argSwitchFirst == "--gamerun" ) {
93
			else if ( argSwitchFirst == L"--gamerun" ) {
94
				gamerun = true;
94
				gamerun = true;
95
				gameArgs = _US(arg.tokens(L" ", 2));
95
				gameArgs = _US(arg.tokens(L" ", 2));
96
			}
96
			}
97
			else if ( argSwitch == "--noresume" )
97
			else if ( argSwitch == L"--noresume" )
98
			{
98
			{
99
				RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
99
				RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
100
				if ( searchKey )
100
				if ( searchKey )
101
					searchKey->SetValue("DontAutoResume", 1);
101
					searchKey->SetValue("DontAutoResume", 1);
102
			}
102
			}
103
			else if ( argSwitch == "--resume" )
103
			else if ( argSwitch == L"--resume" )
104
			{
104
			{
105
				int zero = 0;
105
				int zero = 0;
106
				RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
106
				RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
107
				if ( searchKey )
107
				if ( searchKey )
108
					searchKey->SetValue("DontAutoResume", zero);
108
					searchKey->SetValue("DontAutoResume", zero);
109
			}
109
			}
110
			else if ( argSwitch == "--debug" ) {
110
			else if ( argSwitch == L"--debug" ) {
111
				CFileLog *log = dynamic_cast<CFileLog *>(CFileLog::create());
111
				CFileLog *log = dynamic_cast<CFileLog *>(CFileLog::create());
112
				log->setFile(_S(mydoc) + "/Egosoft/pluginmanager.log");
112
				log->setFile(_WS(mydoc) + L"/Egosoft/pluginmanager.log");
113
				log->setFilter(CLog::Log_Install | CLog::Log_Uninstall | CLog::Log_IO | CLog::Log_Directory | CLog::Log_File);
113
				log->setFilter(CLog::Log_Install | CLog::Log_Uninstall | CLog::Log_IO | CLog::Log_Directory | CLog::Log_File);
114
				log->setLevel(rest.toInt());
114
				log->setLevel(rest.toInt());
115
			}
115
			}
116
		}
116
		}
117
		// otherwise it must be a file to open
117
		// otherwise it must be a file to open
Line 119... Line 119...
119
			openPackage = _US(arg);
119
			openPackage = _US(arg);
120
	}
120
	}
121
 
121
 
122
#if _DEBUG
122
#if _DEBUG
123
	CFileLog *log = dynamic_cast<CFileLog *>(CFileLog::create());
123
	CFileLog *log = dynamic_cast<CFileLog *>(CFileLog::create());
124
	log->setFile(_S(mydoc) + "/Egosoft/pluginmanager.log");
124
	log->setFile(_WS(mydoc) + L"/Egosoft/pluginmanager.log");
125
	log->setFilter(CLog::Log_Install | CLog::Log_Uninstall | CLog::Log_IO | CLog::Log_Directory | CLog::Log_File);
125
	log->setFilter(CLog::Log_Install | CLog::Log_Uninstall | CLog::Log_IO | CLog::Log_Directory | CLog::Log_File);
126
	log->setLevel(5);
126
	log->setLevel(5);
127
	Advanced = true;
127
	Advanced = true;
128
#endif
128
#endif
129
 
129
 
Line 134... Line 134...
134
	RegistryKey ^searchKeyLang = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
134
	RegistryKey ^searchKeyLang = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
135
	if ( searchKeyLang )
135
	if ( searchKeyLang )
136
	{
136
	{
137
		int lang = System::Convert::ToInt32(searchKeyLang->GetValue("Language"));
137
		int lang = System::Convert::ToInt32(searchKeyLang->GetValue("Language"));
138
		if ( lang )
138
		if ( lang )
139
			CLanguages::Instance()->SetLanguage(lang);
139
			CLanguages::Instance()->setLanguage(lang);
140
	}
140
	}
141
 
141
 
142
 
142
 
143
	bool firstInstance = false;
143
	bool firstInstance = false;
144
	System::Threading::Mutex ^mut = gcnew System::Threading::Mutex(false, "Local\\XPluginManagerLite", firstInstance);
144
	System::Threading::Mutex ^mut = gcnew System::Threading::Mutex(false, "Local\\XPluginManagerLite", firstInstance);
Line 190... Line 190...
190
	if ( File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
190
	if ( File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
191
		File::Delete(mydoc + "\\Egosoft\\pluginmanager_load.dat");
191
		File::Delete(mydoc + "\\Egosoft\\pluginmanager_load.dat");
192
	if ( File::Exists(tempDir + "\\AutoUpdater_old.exe") )
192
	if ( File::Exists(tempDir + "\\AutoUpdater_old.exe") )
193
		File::Delete(tempDir + "\\AutoUpdater_old.exe");
193
		File::Delete(tempDir + "\\AutoUpdater_old.exe");
194
 
194
 
195
	packages.startup(".", _S(tempDir), _S(mydoc), "");
195
	packages.startup(L".", _WS(tempDir), _WS(mydoc), L"");
196
	packages.SetRenameText(true);
196
	packages.SetRenameText(true);
197
 
197
 
198
	// Create the main window and run it
198
	// Create the main window and run it
199
	MainGui ^gui = gcnew MainGui(&packages, &dirList, &remDirList, Advanced);
199
	MainGui ^gui = gcnew MainGui(&packages, &dirList, &remDirList, Advanced);
200
	gui->AddGameArgs(gameArgs);
200
	gui->AddGameArgs(gameArgs);
201
 
201
 
202
 
202
 
203
	// load in the config file
203
	// load in the config file
204
	CFileIO configFile(_S(mydoc) + "/Egosoft/pluginmanager.dat");
204
	CFileIO configFile(_WS(mydoc) + L"/Egosoft/pluginmanager.dat");
205
	bool anyDirs = false;
205
	bool anyDirs = false;
206
	if ( configFile.exists() )
206
	if ( configFile.exists() )
207
	{
207
	{
208
		std::vector<Utils::String> *readFile = configFile.readLines();
208
		std::vector<Utils::String> *readFile = configFile.readLines();
209
		if ( readFile )
209
		if ( readFile )
Line 217... Line 217...
217
				if ( cmd == "dir" )
217
				if ( cmd == "dir" )
218
				{
218
				{
219
					// first check its on the list
219
					// first check its on the list
220
					if ( !dirList.findString(rest) )
220
					if ( !dirList.findString(rest) )
221
					{
221
					{
222
						Utils::String gameName = packages.getGameName(rest);
222
						Utils::WString gameName = packages.getGameName(rest);
223
						if ( !gameName.empty() )
223
						if ( !gameName.empty() )
224
						{
224
						{
225
							int lang = packages.getGameLanguage(rest);
225
							int lang = packages.getGameLanguage(rest);
226
							if ( lang )
226
							if ( lang )
227
								dirList.pushBack(rest, Utils::String::Number(lang) + "|" + gameName);
227
								dirList.pushBack(rest, Utils::WString::Number(lang) + L"|" + gameName);
228
							else
228
							else
229
								dirList.pushBack(rest, gameName);
229
								dirList.pushBack(rest, gameName);
230
							anyDirs = true;
230
							anyDirs = true;
231
						}
231
						}
232
					}
232
					}
Line 424... Line 424...
424
			}
424
			}
425
		}
425
		}
426
	}
426
	}
427
 
427
 
428
	// write config
428
	// write config
429
	std::vector<Utils::String> writeLines;
429
	std::vector<Utils::WString> writeLines;
430
	for(auto itr = dirList.begin(); itr != dirList.end(); itr++)
430
	for(auto itr = dirList.begin(); itr != dirList.end(); itr++)
431
	{
431
	{
432
		writeLines.push_back("Dir:" + (*itr)->str.toString());
432
		writeLines.push_back(L"Dir:" + (*itr)->str);
433
		Utils::WString data;
433
		Utils::WString data;
434
		if ((*itr)->data.isin("|") )
434
		if ((*itr)->data.isin(L"|") )
435
		{
435
		{
436
			data = CPackages::ConvertLanguage((*itr)->data.token(L"|", 1).toInt()).toWString() + L"|";
436
			data = CPackages::ConvertLanguage((*itr)->data.token(L"|", 1).toInt()).toWString() + L"|";
437
			data += (*itr)->data.tokens(L"|", 2);
437
			data += (*itr)->data.tokens(L"|", 2);
438
		}
438
		}
439
		else
439
		else
440
			data = (*itr)->data;
440
			data = (*itr)->data;
441
 
441
 
442
		Utils::WString exe = CFileIO(packages.GetGameExe()->GetGameRunExe((*itr)->str.toString())).fullFilename();
442
		Utils::WString exe = CFileIO(packages.GetGameExe()->gameRunExe((*itr)->str)).fullFilename();
443
		writeLines.push_back((L"DirExe:" + data + L"|" + exe).toString());
443
		writeLines.push_back(L"DirExe:" + data + L"|" + exe);
444
 
444
 
445
		// do the log files
445
		// do the log files
446
		writeLines.push_back("GameLog:" + packages.logDirectory(exe.toString()) + "|" + exe.toString());
446
		writeLines.push_back(L"GameLog:" + packages.logDirectory(exe.toString()) + "|" + exe);
447
 
447
 
448
	}
448
	}
449
	for (auto itr = remDirList.begin(); itr != remDirList.end(); itr++)
449
	for (auto itr = remDirList.begin(); itr != remDirList.end(); itr++)
450
		writeLines.push_back("RemDir:" + (*itr)->str.toString());
450
		writeLines.push_back(L"RemDir:" + (*itr)->str);
451
	if ( gui->IsExperimental() )
451
	if ( gui->IsExperimental() )
452
		writeLines.push_back("Experimental:");
452
		writeLines.push_back(L"Experimental:");
453
	if ( gui->IsShips() )
453
	if ( gui->IsShips() )
454
		writeLines.push_back("FilterShips:");
454
		writeLines.push_back(L"FilterShips:");
455
	if ( gui->IsOnlySigned() )
455
	if ( gui->IsOnlySigned() )
456
		writeLines.push_back("FilterSigned:");
456
		writeLines.push_back(L"FilterSigned:");
457
	if ( gui->IsCheat() )
457
	if ( gui->IsCheat() )
458
		writeLines.push_back("Cheat:");
458
		writeLines.push_back(L"Cheat:");
459
	writeLines.push_back(Utils::String("SaveGameManager:";) + (long)gui->GetSaveGameManager());
459
	writeLines.push_back(L"SaveGameManager:"; + Utils::WString::Number(gui->GetSaveGameManager()));
460
	if ( gui->IsDownloadable() )
460
	if ( gui->IsDownloadable() )
461
		writeLines.push_back("Downloadable:");
461
		writeLines.push_back(L"Downloadable:");
462
	if ( gui->IsModSelectorDetailsShowing() )
462
	if ( gui->IsModSelectorDetailsShowing() )
463
		writeLines.push_back("ModSelectorDetails:");
463
		writeLines.push_back(L"ModSelectorDetails:");
464
	if ( !gui->IsAutoUpdate() )
464
	if ( !gui->IsAutoUpdate() )
465
		writeLines.push_back("NoAutoUpdate:");
465
		writeLines.push_back(L"NoAutoUpdate:");
466
	if ( gui->WindowState == FormWindowState::Normal )
466
	if ( gui->WindowState == FormWindowState::Normal )
467
	{
467
	{
468
		writeLines.push_back(Utils::String("ManagerSize:") + (long)gui->Size.Height + " " + (long)gui->Size.Width);
468
		writeLines.push_back(L"ManagerSize:" + Utils::WString::Number(gui->Size.Height) + L" " + Utils::WString::Number(gui->Size.Width));
469
		writeLines.push_back(Utils::String("ManagerPos:") + (long)gui->Location.X + " " + (long)gui->Location.Y);
469
		writeLines.push_back(L"ManagerPos:" + Utils::WString::Number(gui->Location.X) + L" " + Utils::WString::Number(gui->Location.Y));
470
	}
470
	}
471
	else
471
	else
472
	{
472
	{
473
		writeLines.push_back(Utils::String("ManagerPos:") + (long)gui->RestoreBounds.Location.X + &quot; &quot; + (long)gui->RestoreBounds.Location.Y);
473
		writeLines.push_back(L"ManagerPos:" + Utils::WString::Number(gui->RestoreBounds.Location.X) + L&quot; &quot; + Utils::WString::Number(gui->RestoreBounds.Location.Y));
474
		writeLines.push_back(Utils::String("ManagerSize:") + (long)gui->RestoreBounds.Size.Height + &quot; &quot; + (long)gui->RestoreBounds.Size.Width);
474
		writeLines.push_back(L"ManagerSize:" + Utils::WString::Number(gui->RestoreBounds.Size.Height) + L&quot; &quot; + Utils::WString::Number(gui->RestoreBounds.Size.Width));
475
	}
475
	}
476
 
476
 
477
	if ( gui->WindowState == FormWindowState::Maximized )
477
	if ( gui->WindowState == FormWindowState::Maximized )
478
		writeLines.push_back("ManagerMax:");
478
		writeLines.push_back(L"ManagerMax:");
479
	if ( gui->GetIgnoreJoy() )
479
	if ( gui->GetIgnoreJoy() )
480
		writeLines.push_back(Utils::String(";IgnoreJoy:";) + gui->GetIgnoreJoy());
480
		writeLines.push_back(L";IgnoreJoy:"; + Utils::WString::Number(gui->GetIgnoreJoy()));
481
 
481
 
482
	for ( int i = 0; i < gui->GetMaxTips(); i++ )
482
	for ( int i = 0; i < gui->GetMaxTips(); i++ )
483
	{
483
	{
484
		int tips = gui->GetTips(i);
484
		int tips = gui->GetTips(i);
485
		if ( tips == -1 )
485
		if ( tips == -1 )
486
			continue;
486
			continue;
487
		writeLines.push_back(Utils::String(&quot;Tips: ") + (long)i + " " + (long)tips);
487
		writeLines.push_back(L&quot;Tips: " + Utils::WString::Number(i) + L" " + Utils::WString::Number(tips));
488
	}
488
	}
489
 
489
 
490
	for (auto rm = restoreModified.begin(); rm != restoreModified.end(); rm++) {
490
	for (auto rm = restoreModified.begin(); rm != restoreModified.end(); rm++) {
491
		writeLines.push_back("RestoreModified: " + (*rm)->str.toString());
491
		writeLines.push_back(L"RestoreModified: " + (*rm)->str);
492
	}
492
	}
493
 
493
 
494
	// write settings
494
	// write settings
495
	configFile.writeFile(&writeLines);
495
	configFile.writeFile(writeLines);
496
 
496
 
497
	return 0;
497
	return 0;
498
}
498
}