Subversion Repositories spk

Rev

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

Rev 125 Rev 126
Line 14... Line 14...
14
 
14
 
15
using System::Configuration::ApplicationSettingsBase;
15
using System::Configuration::ApplicationSettingsBase;
16
 
16
 
17
#undef GetEnvironmentVariable
17
#undef GetEnvironmentVariable
18
 
18
 
19
enum {LISTGROUP_INSTALLED, LISTGROUP_SHIP, LISTGROUP_FAKE, LISTGROUP_LIBRARY, LISTGROUP_MOD, LISTGROUP_ARCHIVE};
19
enum {LISTGROUP_INSTALLED, LISTGROUP_SHIP, LISTGROUP_FAKE, LISTGROUP_LIBRARY, LISTGROUP_MOD, LISTGROUP_MODADDON, LISTGROUP_MODS, LISTGROUP_ARCHIVE};
20
 
20
 
21
namespace PluginManager {
21
namespace PluginManager {
22
 
22
 
23
	void MainGui::OpenDirectoryControl()
23
	void MainGui::OpenDirectoryControl()
24
	{
24
	{
Line 268... Line 268...
268
	{
268
	{
269
		CLinkList<CBaseFile> packageList;
269
		CLinkList<CBaseFile> packageList;
270
 
270
 
271
		for ( CBaseFile *p = m_pPackages->FirstPackage(); p; p = m_pPackages->NextPackage() )
271
		for ( CBaseFile *p = m_pPackages->FirstPackage(); p; p = m_pPackages->NextPackage() )
272
		{
272
		{
273
			if ( p->IsMod() )
-
 
274
				continue;
-
 
275
			if ( p->author().Compare("PluginManager") )
273
			if ( p->author().Compare("PluginManager") )
276
				continue;
274
				continue;
277
			// if thier parent is a library dont add unless top level
275
			// if thier parent is a library dont add unless top level
278
			if ( currentParent && p->GetParent() && p->GetParent()->GetType() == TYPE_SPK && ((CSpkFile *)p->GetParent())->IsLibrary() )
276
			if ( currentParent && p->GetParent() && p->GetParent()->GetType() == TYPE_SPK && ((CSpkFile *)p->GetParent())->IsLibrary() )
279
				continue;
277
				continue;
Line 301... Line 299...
301
			else if ( m_iSortingColumn == SORT_CREATED ) // sort by author
299
			else if ( m_iSortingColumn == SORT_CREATED ) // sort by author
302
				aNames[i] = _US(p->creationDate().token("/", 3) + p->creationDate().token("/", 2) + p->creationDate().token("/", 1));
300
				aNames[i] = _US(p->creationDate().token("/", 3) + p->creationDate().token("/", 2) + p->creationDate().token("/", 1));
303
			else if ( m_iSortingColumn == SORT_ENABLE ) // sort by author
301
			else if ( m_iSortingColumn == SORT_ENABLE ) // sort by author
304
			{
302
			{
305
				if ( p->IsEnabled() )
303
				if ( p->IsEnabled() )
306
					aNames[i] = SystemStringFromCyString(CyString::Number(1));
304
					aNames[i] = _US(Utils::String::Number(1));
307
				else
305
				else
308
					aNames[i] = SystemStringFromCyString(CyString::Number(0));
306
					aNames[i] = _US(Utils::String::Number(0));
309
			}
307
			}
310
			else if ( m_iSortingColumn == SORT_SIGNED ) // sort by author
308
			else if ( m_iSortingColumn == SORT_SIGNED ) // sort by author
311
			{
309
			{
312
				if ( p->IsEnabled() )
310
				if ( p->IsEnabled() )
313
					aNames[i] = SystemStringFromCyString(CyString::Number(1));
311
					aNames[i] = _US(Utils::String::Number(1));
314
				else
312
				else
315
					aNames[i] = SystemStringFromCyString(CyString::Number(0));
313
					aNames[i] = _US(Utils::String::Number(0));
316
			}
314
			}
317
			else if ( m_iSortingColumn == SORT_TYPE ) // sort by type
315
			else if ( m_iSortingColumn == SORT_TYPE ) // sort by type
318
			{
316
			{
319
				if ( p->GetType() == TYPE_XSP )
317
				if ( p->GetType() == TYPE_XSP )
320
					aNames[i] = "Ship";
318
					aNames[i] = "Ship";
Line 396... Line 394...
396
				item->Group = useGroup;
394
				item->Group = useGroup;
397
			else
395
			else
398
			{
396
			{
399
				int addGroup = LISTGROUP_INSTALLED;
397
				int addGroup = LISTGROUP_INSTALLED;
400
				if ( p->GetParent() && p->GetParent() == m_pPackages->GetEnabledMod() )
398
				if ( p->GetParent() && p->GetParent() == m_pPackages->GetEnabledMod() )
401
					addGroup = LISTGROUP_MOD;
399
					addGroup = LISTGROUP_MODADDON;
-
 
400
				if (p->IsMod())
-
 
401
					addGroup = p->IsEnabled() ? LISTGROUP_MOD : LISTGROUP_MODS;
402
				else if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
402
				else if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
403
					addGroup = LISTGROUP_LIBRARY;
403
					addGroup = LISTGROUP_LIBRARY;
404
				else if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsFakePatch() )
404
				else if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsFakePatch() )
405
					addGroup = LISTGROUP_FAKE;
405
					addGroup = LISTGROUP_FAKE;
406
				else if ( p->GetType() == TYPE_XSP )
406
				else if ( p->GetType() == TYPE_XSP )
Line 516... Line 516...
516
			ListPackages->Groups->Add(shipGroup);
516
			ListPackages->Groups->Add(shipGroup);
517
			ListViewGroup ^fakeGroup = gcnew ListViewGroup("Fake Patches", HorizontalAlignment::Left);
517
			ListViewGroup ^fakeGroup = gcnew ListViewGroup("Fake Patches", HorizontalAlignment::Left);
518
			ListPackages->Groups->Add(fakeGroup);
518
			ListPackages->Groups->Add(fakeGroup);
519
			ListViewGroup ^libGroup = gcnew ListViewGroup("Script Libraries", HorizontalAlignment::Left);
519
			ListViewGroup ^libGroup = gcnew ListViewGroup("Script Libraries", HorizontalAlignment::Left);
520
			ListPackages->Groups->Add(libGroup);
520
			ListPackages->Groups->Add(libGroup);
-
 
521
			ListViewGroup ^activeModGroup = gcnew ListViewGroup("Current Active Mod", HorizontalAlignment::Left);
-
 
522
			ListPackages->Groups->Add(activeModGroup);
521
			ListViewGroup ^modGroup = gcnew ListViewGroup("Current Mod Addons", HorizontalAlignment::Left);
523
			ListViewGroup ^modGroup = gcnew ListViewGroup("Current Mod Addons", HorizontalAlignment::Left);
522
			ListPackages->Groups->Add(modGroup);
524
			ListPackages->Groups->Add(modGroup);
-
 
525
			ListViewGroup ^availModGroup = gcnew ListViewGroup("Available Mods", HorizontalAlignment::Left);
-
 
526
			ListPackages->Groups->Add(availModGroup);
523
			ListViewGroup ^arcGroup = gcnew ListViewGroup("Installed Archives", HorizontalAlignment::Left);
527
			ListViewGroup ^arcGroup = gcnew ListViewGroup("Installed Archives", HorizontalAlignment::Left);
524
			ListPackages->Groups->Add(arcGroup);
528
			ListPackages->Groups->Add(arcGroup);
525
 
529
 
526
			// sort the items
530
			// sort the items
527
			m_pPackages->AssignPackageNumbers();
531
			m_pPackages->AssignPackageNumbers();
Line 1016... Line 1020...
1016
 
1020
 
1017
		CloseCurrentDirectory();
1021
		CloseCurrentDirectory();
1018
 
1022
 
1019
		if ( m_pPackages->read(dir, 0) )
1023
		if ( m_pPackages->read(dir, 0) )
1020
		{
1024
		{
1021
			if ( m_iSaveGameManager == 1 )
1025
			//if ( m_iSaveGameManager == 1 )
1022
				m_pPackages->RestoreSaves();
1026
				//m_pPackages->RestoreSaves();
1023
			m_pPackages->UpdatePackages();
1027
			m_pPackages->UpdatePackages();
1024
			m_pPackages->ReadGameLanguage(true);
1028
			m_pPackages->ReadGameLanguage(true);
1025
			System::String ^mod = PluginManager::ReadRegistryValue(m_pPackages->GetModKey());
1029
			System::String ^mod = PluginManager::ReadRegistryValue(m_pPackages->GetModKey());
1026
			m_pPackages->SetMod(CyStringFromSystemString(mod));
1030
			m_pPackages->SetMod(CyStringFromSystemString(mod));
1027
		}
1031
		}
Line 1194... Line 1198...
1194
		int count = 0;
1198
		int count = 0;
1195
 
1199
 
1196
		for ( int i = 0; i < List->Count; i++ )
1200
		for ( int i = 0; i < List->Count; i++ )
1197
		{
1201
		{
1198
			CBaseFile *p = this->FindPackageFromList(cli::safe_cast<ListViewItem ^>(List[i]));
1202
			CBaseFile *p = this->FindPackageFromList(cli::safe_cast<ListViewItem ^>(List[i]));
1199
			if ( p )
1203
			if ( p )
1200
			{
1204
			{
1201
				if ( p->IsEnabled() )
1205
				if ( p->IsEnabled() )
1202
				{
1206
				{
1203
					if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
1207
					if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
1204
					{
1208
					{
1205
						if ( this->DisplayMessageBox(false, "Disable Library", "Package: " + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage())) + "\nThis is a library package and might be required for other installed packages\nDo you still wish to disable it?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No )
1209
						if ( this->DisplayMessageBox(false, "Disable Library", "Package: " + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage())) + "\nThis is a library package and might be required for other installed packages\nDo you still wish to disable it?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No )
1206
							continue;
1210
							continue;
1207
					}
1211
					}
1208
					if ( p->GetType() == TYPE_XSP )
1212
					if ( p->GetType() == TYPE_XSP )
1209
					{
1213
					{
Line 1221... Line 1225...
1221
				{
1225
				{
1222
					this->EnablePackage(p);
1226
					this->EnablePackage(p);
1223
					++count;
1227
					++count;
1224
				}
1228
				}
1225
			}
1229
			}
1226
		}
1230
		}
1227
 
1231
 
1228
		if ( count )
1232
		if ( count )
1229
		{
1233
		{
1230
			this->Enabled = false;
1234
			this->Enabled = false;
1231
			this->StartBackground(MGUI_BACKGROUND_DISABLE);
1235
			this->StartBackground(MGUI_BACKGROUND_DISABLE);
1232
		}
1236
		}
1233
	}
1237
	}
1234
 
1238
 
1235
	void MainGui::DisableEvent(System::Object ^Sender, System::EventArgs ^E)
1239
	void MainGui::DisableEvent(System::Object ^Sender, System::EventArgs ^E)
1236
	{
1240
	{
1237
		if ( !ListPackages->SelectedItems->Count )
1241
		if ( !ListPackages->SelectedItems->Count )
1238
			return;
1242
			return;
1239
 
1243
 
1240
		bool skipShips = false;
1244
		bool skipShips = false;
1241
 
1245
 
Line 1305... Line 1309...
1305
 
1309
 
1306
	void MainGui::CloseEvent(System::Object ^Sender, FormClosingEventArgs ^E)
1310
	void MainGui::CloseEvent(System::Object ^Sender, FormClosingEventArgs ^E)
1307
	{
1311
	{
1308
		int h = this->Size.Height;
1312
		int h = this->Size.Height;
1309
		int w = this->Size.Width;
1313
		int w = this->Size.Width;
1310
	}
1314
	}
1311
 
1315
 
1312
	void MainGui::DisplayLocked(bool inthread) 
1316
	void MainGui::DisplayLocked(bool inthread) 
1313
	{
1317
	{
1314
		this->DisplayMessageBox(inthread, "Directory Locked", "The current directory is locked and unable to make any changes\nYou may need to adjust the directory permissions", MessageBoxButtons::OK, MessageBoxIcon::Error);
1318
		this->DisplayMessageBox(inthread, "Directory Locked", "The current directory is locked and unable to make any changes\nYou may need to adjust the directory permissions", MessageBoxButtons::OK, MessageBoxIcon::Error);
1315
	}
1319
	}
1316
 
1320
 
1317
	void MainGui::ModSelectorEvent(System::Object ^Sender, System::EventArgs ^E)
1321
	void MainGui::OpenModSelecter()
1318
	{
1322
	{
1319
		if ( m_pPackages->IsVanilla() )
1323
		if (m_pPackages->IsVanilla())
1320
		{
1324
		{
1321
			this->DisplayMessageBox(false, "Mod Selector", "Currently in Vanilla Mode, You can only enable mods when in Modified Mode\n\nSwitch to modified mode if you wish to install mods", MessageBoxButtons::OK, MessageBoxIcon::Question);
1325
			this->DisplayMessageBox(false, "Mod Selector", "Currently in Vanilla Mode, You can only enable mods when in Modified Mode\n\nSwitch to modified mode if you wish to install mods", MessageBoxButtons::OK, MessageBoxIcon::Question);
1322
			return;
1326
			return;
1323
		}
1327
		}
1324
		this->Enabled = false;
1328
		this->Enabled = false;
1325
		ModSelector ^mod = gcnew ModSelector(m_pPackages, this->imageList1);
1329
		ModSelector ^mod = gcnew ModSelector(m_pPackages, this->imageList1);
1326
		
1330
 
1327
		if ( !mod->AnyPackages() )
1331
		if (!mod->AnyPackages())
1328
		{
1332
		{
1329
			this->DisplayMessageBox(false, "Mod Selector", "No available mods have been found", MessageBoxButtons::OK, MessageBoxIcon::Warning);
1333
			this->DisplayMessageBox(false, "Mod Selector", "No available mods have been found", MessageBoxButtons::OK, MessageBoxIcon::Warning);
1330
			this->Enabled = true;
1334
			this->Enabled = true;
1331
			return;
1335
			return;
1332
		}
1336
		}
1333
 
1337
 
1334
		if ( m_bDirLocked ) {
1338
		if (m_bDirLocked) {
1335
			this->DisplayLocked(false);
1339
			this->DisplayLocked(false);
1336
			this->Enabled = true;
1340
			this->Enabled = true;
1337
			return;
1341
			return;
1338
		}
1342
		}
1339
 
1343
 
1340
		if ( !m_bModSelectorDetails )
1344
		if (!m_bModSelectorDetails)
1341
		{
1345
		{
1342
			mod->HideDetails();
1346
			mod->HideDetails();
1343
			mod->Update();
1347
			mod->Update();
1344
		}
1348
		}
1345
		
1349
 
1346
		System::Windows::Forms::DialogResult result = mod->ShowDialog(this);
1350
		System::Windows::Forms::DialogResult result = mod->ShowDialog(this);
1347
		m_bModSelectorDetails = mod->ShowingDetails();
1351
		m_bModSelectorDetails = mod->ShowingDetails();
1348
 
1352
 
1349
		// install the selected mod
1353
		// install the selected mod
1350
		bool reEnable = true;
1354
		bool reEnable = true;
1351
 
1355
 
1352
		CBaseFile *p = mod->SelectedMod();
1356
		CBaseFile *p = mod->SelectedMod();
1353
		if ( result == System::Windows::Forms::DialogResult::OK )
1357
		if (result == System::Windows::Forms::DialogResult::OK)
1354
		{
1358
		{
1355
			if ( p )
1359
			if (p)
1356
			{
1360
			{
1357
				// from file
1361
				// from file
1358
				if ( p->GetNum() < 0 )
1362
				if (p->GetNum() < 0)
1359
				{
1363
				{
1360
					if ( m_pPackages->GetEnabledMod() )
1364
					if (m_pPackages->GetEnabledMod())
1361
						m_pPackages->DisablePackage(m_pPackages->GetEnabledMod(), 0, 0);
1365
						m_pPackages->DisablePackage(m_pPackages->GetEnabledMod(), 0, 0);
1362
					if ( this->;InstallPackage(_US(p->filename()), true, false, true) )
1366
					if (this->;InstallPackage(_US(p->filename()), true, false, true))
1363
						reEnable = false;
1367
						reEnable = false;
1364
				}
1368
				}
1365
				// otherwise just enable it
1369
				// otherwise just enable it
1366
				else
1370
				else
1367
				{
1371
				{
1368
					if ( this->EnablePackage(p) )
1372
					if (this->EnablePackage(p))
1369
					{
1373
					{
1370
						this->StartBackground(MGUI_BACKGROUND_DISABLE);
1374
						this->StartBackground(MGUI_BACKGROUND_DISABLE);
1371
						reEnable = false;
1375
						reEnable = false;
1372
					}
1376
					}
1373
				}
1377
				}
1374
			}
1378
			}
1375
		}
1379
		}
1376
 
1380
 
1377
		// install downloaded mods
1381
		// install downloaded mods
1378
		else if ( result == Windows::Forms::DialogResult::Yes )
1382
		else if (result == Windows::Forms::DialogResult::Yes)
1379
			this->StartInstalling(false, true);
1383
			this->StartInstalling(false, true);
1380
 
1384
 
1381
		// remove the current mod
1385
		// remove the current mod
1382
		else if ( result == System::Windows::Forms::DialogResult::Abort )
1386
		else if (result == System::Windows::Forms::DialogResult::Abort)
1383
		{
1387
		{
1384
			if ( m_pPackages->GetEnabledMod() )
1388
			if (m_pPackages->GetEnabledMod())
1385
			{
1389
			{
1386
				CBaseFile *mod = m_pPackages->GetEnabledMod();
1390
				CBaseFile *mod = m_pPackages->GetEnabledMod();
1387
				CyString message = mod->GetFullPackageName(m_pPackages->GetLanguage());
1391
				CyString message = mod->GetFullPackageName(m_pPackages->GetLanguage());
1388
				m_pPackages->DisablePackage(m_pPackages->GetEnabledMod(), 0, 0);			
1392
				m_pPackages->DisablePackage(m_pPackages->GetEnabledMod(), 0, 0);
1389
				this->DisplayMessageBox(false, "Mod Disabed", SystemStringFromCyString(message) + " has been disabled\nYour game is no longer using any mods\n", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
1393
				this->DisplayMessageBox(false, "Mod Disabed", SystemStringFromCyString(message) + " has been disabled\nYour game is no longer using any mods\n", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
1390
			}
1394
			}
1391
		}
1395
		}
1392
 
1396
 
1393
		// uninstall the selected mod
1397
		// uninstall the selected mod
1394
		else if ( result == System::Windows::Forms::DialogResult::Retry )
1398
		else if (result == System::Windows::Forms::DialogResult::Retry)
1395
		{
1399
		{
1396
			if ( p &&amp; p-&gt;GetNum() >= 0 )
1400
			if (p &amp;&amp; p->;GetNum() >= 0)
1397
			{
1401
			{
1398
				m_pPackages->PrepareUninstallPackage(p);
1402
				m_pPackages->PrepareUninstallPackage(p);
1399
				if ( m_pPackages->GetNumPackagesInQueue() )
1403
				if (m_pPackages->GetNumPackagesInQueue())
1400
				{
1404
				{
1401
					reEnable = false;
1405
					reEnable = false;
1402
					this->StartBackground(MGUI_BACKGROUND_UNINSTALL);
1406
					this->StartBackground(MGUI_BACKGROUND_UNINSTALL);
1403
				}
1407
				}
1404
			}
1408
			}
1405
		}
1409
		}
1406
 
1410
 
1407
		if ( reEnable )
1411
		if (reEnable)
1408
			this->Enabled = true;
1412
			this->Enabled = true;
1409
 
1413
 
1410
		mod->RemovePackages();
1414
		mod->RemovePackages();
-
 
1415
		this->UpdatePackages();
-
 
1416
	}
-
 
1417
 
-
 
1418
	void MainGui::ModSelectorEvent(System::Object ^Sender, System::EventArgs ^E)
-
 
1419
	{
-
 
1420
		OpenModSelecter();
1411
	}
1421
	}
1412
 
1422
 
1413
	void MainGui::UninstallList(ArrayList ^List)
1423
	void MainGui::UninstallList(ArrayList ^List)
1414
	{
1424
	{
1415
		bool skipShips = false;
1425
		bool skipShips = false;
Line 1469... Line 1479...
1469
		}
1479
		}
1470
		if ( m_pPackages->IsVanilla() )
1480
		if ( m_pPackages->IsVanilla() )
1471
		{
1481
		{
1472
			this->Enabled = false;
1482
			this->Enabled = false;
1473
			if ( this->DisplayMessageBox(false, "Modified Mode", "Enabling modified mode will allow you to use any modified content\nThis will however mark any games you save as modified and you will be unable to participate in Uplink\nAny current save games wil also be backed up and kept seperate from your modified save games\n\nDo you wish to enable modified mode?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
1483
			if ( this->DisplayMessageBox(false, "Modified Mode", "Enabling modified mode will allow you to use any modified content\nThis will however mark any games you save as modified and you will be unable to participate in Uplink\nAny current save games wil also be backed up and kept seperate from your modified save games\n\nDo you wish to enable modified mode?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
1474
			{
1484
			{
1475
				if ( m_iSaveGameManager == 1 )
1485
				if ( m_iSaveGameManager == 1 )
1476
				{
1486
				{
1477
					m_pPackages->BackupSaves(true);
1487
					m_pPackages->backupSaves(true);
1478
					m_pPackages->RestoreSaves(false);
1488
					m_pPackages->restoreSaves(false);
1479
				}
1489
				}
1480
				m_pPackages->SetVanilla(false);
1490
				m_pPackages->SetVanilla(false);
1481
				m_pMenuBar->Modified();
1491
				m_pMenuBar->Modified();
1482
				m_pPackages->PrepareEnableLibrarys();
1492
				m_pPackages->PrepareEnableLibrarys();
1483
				m_pPackages->PrepareEnableFromVanilla();
1493
				m_pPackages->PrepareEnableFromVanilla();
1484
				this->StartBackground(MGUI_BACKGROUND_DISABLE);
1494
				this->StartBackground(MGUI_BACKGROUND_DISABLE);
1485
			}
1495
			}
1486
			else
1496
			else
1487
				this->Enabled = true;
1497
				this->Enabled = true;
1488
		}
1498
		}
1489
	}
1499
	}
1490
 
1500
 
1491
	void MainGui::VanillaEvent(System::Object ^Sender, System::EventArgs ^E)
1501
	void MainGui::VanillaEvent(System::Object ^Sender, System::EventArgs ^E)
1492
	{
1502
	{
1493
		if ( m_bDirLocked ) {
1503
		if ( m_bDirLocked ) {
1494
			this->DisplayLocked(false);
1504
			this->DisplayLocked(false);
1495
			return;
1505
			return;
1496
		}
1506
		}
1497
		if ( !m_pPackages->IsVanilla() )
1507
		if ( !m_pPackages->IsVanilla() )
Line 1499... Line 1509...
1499
			this->Enabled = false;
1509
			this->Enabled = false;
1500
			if ( this->DisplayMessageBox(false, "Vanilla Mode", "Switching back to vanilla mode you will no longer be able to use any modifying packages, these will be disabled\nYour current save games will be backed up as modified saves, and any vanilla save games will be restored\n\nDo you wish to go back to Vanilla?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
1510
			if ( this->DisplayMessageBox(false, "Vanilla Mode", "Switching back to vanilla mode you will no longer be able to use any modifying packages, these will be disabled\nYour current save games will be backed up as modified saves, and any vanilla save games will be restored\n\nDo you wish to go back to Vanilla?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
1501
			{
1511
			{
1502
				if ( m_iSaveGameManager == 1 )
1512
				if ( m_iSaveGameManager == 1 )
1503
				{
1513
				{
1504
					m_pPackages->BackupSaves(false);
1514
					m_pPackages->backupSaves(false);
1505
					m_pPackages->RestoreSaves(true);
1515
					m_pPackages->restoreSaves(true);
1506
				}
1516
				}
1507
				m_pPackages->SetVanilla(true);
1517
				m_pPackages->SetVanilla(true);
1508
				m_pMenuBar->Vanilla();
1518
				m_pMenuBar->Vanilla();
1509
				m_pPackages->PrepareDisableForVanilla();
1519
				m_pPackages->PrepareDisableForVanilla();
1510
				this->StartBackground(MGUI_BACKGROUND_DISABLE);
1520
				this->StartBackground(MGUI_BACKGROUND_DISABLE);
Line 1513... Line 1523...
1513
				this->Enabled = true;
1523
				this->Enabled = true;
1514
		}
1524
		}
1515
	}
1525
	}
1516
 
1526
 
1517
	void MainGui::InstallEvent(System::Object ^Sender, System::EventArgs ^E)
1527
	void MainGui::InstallEvent(System::Object ^Sender, System::EventArgs ^E)
1518
	{
1528
	{
1519
		if ( m_bDirLocked ) {
1529
		if ( m_bDirLocked ) {
1520
			this->DisplayLocked(false);
1530
			this->DisplayLocked(false);
1521
			return;
1531
			return;
1522
		}
1532
		}
1523
 
1533
 
1524
		OpenFileDialog ^ofd = gcnew OpenFileDialog();
1534
		OpenFileDialog ^ofd = gcnew OpenFileDialog();
1525
		ofd->Filter = "All (*.spk, *.xsp)|*.spk;*.xsp|Package Files (*.spk)|*.spk|Ship Files (*.xsp)|*.xsp";
1535
		ofd->Filter = "All (*.spk, *.xsp)|*.spk;*.xsp|Package Files (*.spk)|*.spk|Ship Files (*.xsp)|*.xsp";
1526
		ofd->FilterIndex = 1;
1536
		ofd->FilterIndex = 1;
1527
		ofd->RestoreDirectory = true;
1537
		ofd->RestoreDirectory = true;
Line 2067... Line 2077...
2067
				t->sTips->Add("You are about to uninstall a ship, you need to make sure that there are no ships in the sector you was in when you saved, otherwise it could prevent the save from loading\n\nContinue Uninstalling Ship?");
2077
				t->sTips->Add("You are about to uninstall a ship, you need to make sure that there are no ships in the sector you was in when you saved, otherwise it could prevent the save from loading\n\nContinue Uninstalling Ship?");
2068
				t->sTips->Add("You are about to disable a ship, you need to make sure that there are no ships in the sector you was in when you saved, otherwise it could prevent the save from loading\n\nContinue Disabling Ship?");
2078
				t->sTips->Add("You are about to disable a ship, you need to make sure that there are no ships in the sector you was in when you saved, otherwise it could prevent the save from loading\n\nContinue Disabling Ship?");
2069
				break;
2079
				break;
2070
		}
2080
		}
2071
	}
2081
	}
-
 
2082
 
-
 
2083
	void MainGui::SetSaveGameManager(int i) 
-
 
2084
	{ 
-
 
2085
		m_iSaveGameManager = i; 
-
 
2086
		if (m_iSaveGameManager != -1)
-
 
2087
		{
-
 
2088
			if (m_pPackages && m_pPackages->IsLoaded())
-
 
2089
				m_pPackages->setSaveGameManager(m_iSaveGameManager == 1);
-
 
2090
		}
-
 
2091
	}
-
 
2092
 
2072
 
2093
 
2073
	System::Windows::Forms::DialogResult MainGui::DisplayMessageBox(bool inthread, System::String ^title, System::String ^text, MessageBoxButtons buttons, MessageBoxIcon icon)
2094
	System::Windows::Forms::DialogResult MainGui::DisplayMessageBox(bool inthread, System::String ^title, System::String ^text, MessageBoxButtons buttons, MessageBoxIcon icon)
2074
	{
2095
	{
2075
		if ( !inthread )
2096
		if ( !inthread )
2076
			return MessageBox::Show(this, text, title, buttons, icon);
2097
			return MessageBox::Show(this, text, title, buttons, icon);
Line 2082... Line 2103...
2082
			m_messageIcon = icon;
2103
			m_messageIcon = icon;
2083
			m_messageButtons = buttons;
2104
			m_messageButtons = buttons;
2084
 
2105
 
2085
			return System::Windows::Forms::DialogResult::Abort;
2106
			return System::Windows::Forms::DialogResult::Abort;
2086
		}
2107
		}
2087
	}
2108
	}
2088
 
2109
 
2089
	ListViewItem ^MainGui::FindSelectedItem()
2110
	ListViewItem ^MainGui::FindSelectedItem()
2090
	{
2111
	{
2091
		Point ^mousePoint = this->ListPackages->PointToClient(this->contextMenuStrip1->MousePosition);
2112
		Point ^mousePoint = this->ListPackages->PointToClient(this->contextMenuStrip1->MousePosition);
2092
		return  this->ListPackages->GetItemAt(mousePoint->X, mousePoint->Y);
2113
		return  this->ListPackages->GetItemAt(mousePoint->X, mousePoint->Y);
2093
	}
2114
	}
2094
 
2115
 
2095
	CBaseFile *MainGui::GetFileFromItem(ListViewItem ^item)
2116
	CBaseFile *MainGui::GetFileFromItem(ListViewItem ^item)
2096
	{
2117
	{
2097
		int num = System::Convert::ToInt32(item->Tag);
2118
		int num = System::Convert::ToInt32(item->Tag);
2098
		return m_pPackages->GetPackageAt(num);
2119
		return m_pPackages->GetPackageAt(num);
2099
	}
2120
	}
2100
 
2121
 
2101
	System::Void MainGui::OpenContextMenu(System::Object ^Sender, CancelEventArgs ^E)
2122
	System::Void MainGui::OpenContextMenu(System::Object ^Sender, CancelEventArgs ^E)
Line 2129... Line 2150...
2129
				m_pListItem = item;
2150
				m_pListItem = item;
2130
				this->ContextName->Text = item->Text;
2151
				this->ContextName->Text = item->Text;
2131
				if ( item->ImageIndex != -1 )
2152
				if ( item->ImageIndex != -1 )
2132
					this->ContextName->Image = this->ListPackages->LargeImageList->Images[item->ImageIndex];
2153
					this->ContextName->Image = this->ListPackages->LargeImageList->Images[item->ImageIndex];
2133
				else if ( item->ImageKey )
2154
				else if ( item->ImageKey )
2134
				{
2155
				{
2135
					int key = this->ListPackages->LargeImageList->Images->IndexOfKey(item->ImageKey);
2156
					int key = this->ListPackages->LargeImageList->Images->IndexOfKey(item->ImageKey);
2136
					if ( key != -1 )
2157
					if ( key != -1 )
2137
						this->ContextName->Image = this->ListPackages->LargeImageList->Images[key];
2158
						this->ContextName->Image = this->ListPackages->LargeImageList->Images[key];
2138
				}
2159
				}
2139
				else if ( p->GetIcon() )
2160
				else if ( p->GetIcon() )
Line 2271... Line 2292...
2271
				if ( p->IsEnabled() )
2292
				if ( p->IsEnabled() )
2272
					this->ContextDisable->Visible = true;
2293
					this->ContextDisable->Visible = true;
2273
				else
2294
				else
2274
					this->ContextEnable->Visible = true;
2295
					this->ContextEnable->Visible = true;
2275
			}
2296
			}
-
 
2297
 
-
 
2298
			if (p->IsMod())
-
 
2299
			{
-
 
2300
				this->UninstallSelectedContext->Visible = false;
-
 
2301
				this->uninstallToolStripMenuItem->Visible = false;
-
 
2302
				this->viewModSelectedToolStripMenuItem->Visible = true;
-
 
2303
				this->ContextDisable->Visible = false;
-
 
2304
				this->ContextEnable->Visible = false;
-
 
2305
			}
-
 
2306
			else 
-
 
2307
				this->viewModSelectedToolStripMenuItem->Visible = false;
2276
 
2308
 
2277
			this->ContextSeperator->Visible = showSep;
2309
			this->ContextSeperator->Visible = showSep;
2278
			this->ContextSeperator2->Visible = showSep2;
2310
			this->ContextSeperator2->Visible = showSep2;
2279
			E->Cancel = false;
2311
			E->Cancel = false;
2280
		}
2312
		}
2281
	}
2313
	}
2282
 
2314
 
2283
	System::Void MainGui::ListPackages_DragOver(System::Object^  sender, System::Windows::Forms::DragEventArgs^  e)
2315
	System::Void MainGui::ListPackages_DragOver(System::Object^  sender, System::Windows::Forms::DragEventArgs^  e)
2284
	{
2316
	{
2285
		e->Effect = DragDropEffects::None;
2317
		e->Effect = DragDropEffects::None;
2286
 
2318
 
2287
		if (e->Data->GetDataPresent(DataFormats::FileDrop)) 
2319
		if (e->Data->GetDataPresent(DataFormats::FileDrop)) 
2288
		{
2320
		{
2289
			cli::array<String ^> ^a = (cli::array<String ^> ^)e->Data->GetData(DataFormats::FileDrop, false);
2321
			cli::array<String ^> ^a = (cli::array<String ^> ^)e->Data->GetData(DataFormats::FileDrop, false);
2290
			int i;
2322
			int i;
2291
			for(i = 0; i < a->Length; i++)
2323
			for(i = 0; i < a->Length; i++)
2292
			{
2324
			{
2293
				String ^s = a[i];
2325
				String ^s = a[i];
2294
				String ^ext = IO::FileInfo(s).Extension;
2326
				String ^ext = IO::FileInfo(s).Extension;
2295
				if ( String::Compare(IO::FileInfo(s).Extension, ".xsp", true) == 0 || String::Compare(IO::FileInfo(s).Extension, ".spk", true) == 0 )
2327
				if ( String::Compare(IO::FileInfo(s).Extension, ".xsp", true) == 0 || String::Compare(IO::FileInfo(s).Extension, ".spk", true) == 0 )
2296
				{
2328
				{
2297
					e->Effect = DragDropEffects::Copy;
2329
					e->Effect = DragDropEffects::Copy;
Line 2320... Line 2352...
2320
					this->InstallPackage(s, false, false, true);
2352
					this->InstallPackage(s, false, false, true);
2321
				}
2353
				}
2322
			}
2354
			}
2323
 
2355
 
2324
			this->StartInstalling(false, true);
2356
			this->StartInstalling(false, true);
2325
		}
2357
		}
2326
	}
2358
	}
2327
 
2359
 
2328
	bool MainGui::CheckAccessRights(String ^dir)
2360
	bool MainGui::CheckAccessRights(String ^dir)
2329
	{
2361
	{
2330
		/*
2362
		/*
2331
		// check if already exists
2363
		// check if already exists
Line 2397... Line 2429...
2397
		String ^file = Convert::ToString(item->Tag);
2429
		String ^file = Convert::ToString(item->Tag);
2398
		System::Diagnostics::Process::Start(file);
2430
		System::Diagnostics::Process::Start(file);
2399
	}
2431
	}
2400
 
2432
 
2401
	void MainGui::FakePatchControlDialog()
2433
	void MainGui::FakePatchControlDialog()
2402
	{
2434
	{
2403
		FakePatchControl ^fpc = gcnew FakePatchControl(m_pPackages);
2435
		FakePatchControl ^fpc = gcnew FakePatchControl(m_pPackages);
2404
		if ( fpc->ShowDialog(this) == Windows::Forms::DialogResult::OK )
2436
		if ( fpc->ShowDialog(this) == Windows::Forms::DialogResult::OK )
2405
		{
2437
		{
2406
			m_pPackages->ApplyFakePatchOrder(fpc->GetPatchOrder());
2438
			m_pPackages->ApplyFakePatchOrder(fpc->GetPatchOrder());
2407
			m_pPackages->ShuffleFakePatches(0);
2439
			m_pPackages->ShuffleFakePatches(0);
Line 2435... Line 2467...
2435
					{
2467
					{
2436
						errorList.PushBack(str->str + " (" + packageName + ")", str->data + " (" + package2Name + ")");
2468
						errorList.PushBack(str->str + " (" + packageName + ")", str->data + " (" + package2Name + ")");
2437
						++count;
2469
						++count;
2438
					}
2470
					}
2439
					++packageCount;
2471
					++packageCount;
2440
				}
2472
				}
2441
			}
2473
			}
2442
		}
2474
		}
2443
 
2475
 
2444
		if ( count )
2476
		if ( count )
2445
		{
2477
		{
Line 2457... Line 2489...
2457
	void MainGui::EditWaresDialog()
2489
	void MainGui::EditWaresDialog()
2458
	{
2490
	{
2459
		if ( m_bDirLocked ) {
2491
		if ( m_bDirLocked ) {
2460
			this->DisplayLocked(false);
2492
			this->DisplayLocked(false);
2461
			return;
2493
			return;
2462
		}
2494
		}
2463
 
2495
 
2464
		EditWares ^edit = gcnew EditWares(m_pPackages);
2496
		EditWares ^edit = gcnew EditWares(m_pPackages);
2465
 
2497
 
2466
		if ( edit->ShowDialog(this) == Windows::Forms::DialogResult::OK )
2498
		if ( edit->ShowDialog(this) == Windows::Forms::DialogResult::OK )
2467
		{
2499
		{
Line 2471... Line 2503...
2471
	void MainGui::CommandSlotsDialog()
2503
	void MainGui::CommandSlotsDialog()
2472
	{
2504
	{
2473
		CommandSlots ^slots = gcnew CommandSlots(m_pPackages);
2505
		CommandSlots ^slots = gcnew CommandSlots(m_pPackages);
2474
 
2506
 
2475
		slots->ShowDialog(this);
2507
		slots->ShowDialog(this);
2476
	}
2508
	}
2477
 
2509
 
2478
	void MainGui::EditGlobalsDialog()
2510
	void MainGui::EditGlobalsDialog()
2479
	{
2511
	{
2480
		if ( m_pPackages->IsVanilla() ) {
2512
		if ( m_pPackages->IsVanilla() ) {
2481
			this->DisplayMessageBox(false, "Edit Globals", "Currently in Vanilla Mode, Cant change globals without being modified\n\nSwitch to modified mode if you wish to edit globals", MessageBoxButtons::OK, MessageBoxIcon::Question);
2513
			this->DisplayMessageBox(false, "Edit Globals", "Currently in Vanilla Mode, Cant change globals without being modified\n\nSwitch to modified mode if you wish to edit globals", MessageBoxButtons::OK, MessageBoxIcon::Question);
2482
			return;
2514
			return;
2483
		}
2515
		}
2484
		if ( m_bDirLocked ) {
2516
		if ( m_bDirLocked ) {
Line 2742... Line 2774...
2742
		if (m_iSizeX != -1 && m_iSizeY != -1)
2774
		if (m_iSizeX != -1 && m_iSizeY != -1)
2743
			this->Size = System::Drawing::Size(m_iSizeX, m_iSizeY);
2775
			this->Size = System::Drawing::Size(m_iSizeX, m_iSizeY);
2744
 
2776
 
2745
		this->UpdateBuiltInPackages();
2777
		this->UpdateBuiltInPackages();
2746
		this->AutoUpdate();
2778
		this->AutoUpdate();
-
 
2779
	}
-
 
2780
	System::Void MainGui::viewModSelectedToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e)
-
 
2781
	{		
-
 
2782
		this->OpenModSelecter();
2747
	}
2783
	}
2748
}
2784
}