Subversion Repositories spk

Rev

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

Rev 200 Rev 203
Line 132... Line 132...
132
	g_indent = indent;
132
	g_indent = indent;
133
 
133
 
134
	if ( !p->IsEnabled() )
134
	if ( !p->IsEnabled() )
135
		printf("[D] ");
135
		printf("[D] ");
136
 
136
 
137
	printf ( "%s %s by %s\n", p->name(language).c_str(), version.c_str(), p->author().c_str() );
137
	wprintf(L"%s %hs by %s\n", p->name(language).c_str(), version.c_str(), p->author().c_str() );
138
}
138
}
139
 
139
 
140
void DoAllChildren(CPackages *packages, CBaseFile *p, CLinkList<CBaseFile> *doneList, int indent)
140
void DoAllChildren(CPackages *packages, CBaseFile *p, CLinkList<CBaseFile> *doneList, int indent)
141
{
141
{
142
	CLinkList<CBaseFile> children;
142
	CLinkList<CBaseFile> children;
Line 187... Line 187...
187
	}
187
	}
188
 
188
 
189
	return argList->Count();
189
	return argList->Count();
190
}
190
}
191
 
191
 
192
CyString InstallPackage(CyStringList *lArguments, Utils::WStringList *errors, CPackages *packages, bool disabled)
192
Utils::WString InstallPackage(CyStringList *lArguments, Utils::WStringList *errors, CPackages *packages, bool disabled)
193
{
193
{
194
	CProgressConsole progress;
194
	CProgressConsole progress;
195
 
195
 
196
	int error;
196
	int error;
197
 
197
 
198
	if ( !lArguments || !lArguments->Count() )
198
	if ( !lArguments || !lArguments->Count() )
199
		return NullString;
199
		return Utils::WString::Null();
200
 
200
 
201
	// append spk on the end
201
	// append spk on the end
202
	for ( SStringList *node = lArguments->Head(); node; node = node->next )
202
	for ( SStringList *node = lArguments->Head(); node; node = node->next )
203
	{
203
	{
204
		if (!CFileIO::Exists(node->str.ToString()))
204
		if (!CFileIO::Exists(node->str.ToString()))
Line 268... Line 268...
268
		for ( CListNode<CBaseFile> *pNode = lPackageList.Front(); pNode; pNode = pNode->next() )
268
		for ( CListNode<CBaseFile> *pNode = lPackageList.Front(); pNode; pNode = pNode->next() )
269
		{
269
		{
270
			CBaseFile *package = pNode->Data();
270
			CBaseFile *package = pNode->Data();
271
 
271
 
272
			// compare versions
272
			// compare versions
273
			Utils::String packageName = package->getFullPackageName(packages->GetLanguage());
273
			Utils::WString packageName = package->getFullPackageName(packages->GetLanguage());
274
 
274
 
275
			int checkFlags = IC_ALL;
275
			int checkFlags = IC_ALL;
276
			int check = packages->PrepareInstallPackage(package, (disabled) ? true : !package->IsEnabled(), false, checkFlags);
276
			int check = packages->PrepareInstallPackage(package, (disabled) ? true : !package->IsEnabled(), false, checkFlags);
277
 
277
 
278
			switch (check)
278
			switch (check)
279
			{
279
			{
280
				case INSTALLCHECK_OLDVERSION:
280
				case INSTALLCHECK_OLDVERSION:
281
					printf ( "Newer version of \"%s\" already installed", packageName.c_str() );
281
					wprintf(L"Newer version of \"%s\" already installed", packageName.c_str() );
282
					if ( !g_force )
282
					if ( !g_force )
283
					{
283
					{
284
						printf ( ", Unable to install older, use -o to force installation\n" );
284
						printf ( ", Unable to install older, use -o to force installation\n" );
285
						continue;
285
						continue;
286
					}
286
					}
Line 292... Line 292...
292
						break;
292
						break;
293
					}
293
					}
294
					break;
294
					break;
295
					// wait for the rest to be added
295
					// wait for the rest to be added
296
				case INSTALLCHECK_WRONGGAME:
296
				case INSTALLCHECK_WRONGGAME:
297
					wprintf ( L"ERROR! \"%hs\" Wrong Game (Requires: %s)", packageName.c_str(), packages->getGameTypesString(package, false).c_str() );
297
					wprintf ( L"ERROR! \"%s\" Wrong Game (Requires: %s)", packageName.c_str(), packages->getGameTypesString(package, false).c_str() );
298
					if ( g_force )
298
					if ( g_force )
299
					{
299
					{
300
						printf ( " [FORCED]\n" );
300
						printf ( " [FORCED]\n" );
301
						if ( packages->PrepareInstallPackage(package, disabled, true) != INSTALLCHECK_OK )
301
						if ( packages->PrepareInstallPackage(package, disabled, true) != INSTALLCHECK_OK )
302
							continue;
302
							continue;
Line 307... Line 307...
307
						continue;
307
						continue;
308
					}
308
					}
309
					break;
309
					break;
310
 
310
 
311
				case INSTALLCHECK_WRONGVERSION:
311
				case INSTALLCHECK_WRONGVERSION:
312
					wprintf ( L"ERROR! \"%hs\" Wrong Game Version (Requires: %s)\n", packageName.c_str(), packages->getGameVersionString(package).c_str() );
312
					wprintf ( L"ERROR! \"%s\" Wrong Game Version (Requires: %s)\n", packageName.c_str(), packages->getGameVersionString(package).c_str() );
313
					if ( g_force )
313
					if ( g_force )
314
					{
314
					{
315
						printf ( " [FORCED]\n" );
315
						printf ( " [FORCED]\n" );
316
						if ( packages->PrepareInstallPackage(package, disabled, true) != INSTALLCHECK_OK )
316
						if ( packages->PrepareInstallPackage(package, disabled, true) != INSTALLCHECK_OK )
317
							continue;
317
							continue;
Line 328... Line 328...
328
			{
328
			{
329
				Utils::String installtext = packages->getInstallBeforeText(package);
329
				Utils::String installtext = packages->getInstallBeforeText(package);
330
				if ( !installtext.empty() )
330
				if ( !installtext.empty() )
331
				{
331
				{
332
					installtext = installtext.stripHtml();
332
					installtext = installtext.stripHtml();
333
					printf ( "Installing %s: %s\n", packageName.c_str(), installtext.c_str() );
333
					wprintf(L"Installing %s: %hs\n", packageName.c_str(), installtext.c_str() );
334
					printf ( "Do you want to continue with the install? " );
334
					printf ( "Do you want to continue with the install? " );
335
 
335
 
336
					if ( g_force )
336
					if ( g_force )
337
						printf ( "(FORCED)\n" );
337
						printf ( "(FORCED)\n" );
338
					else
338
					else
Line 359... Line 359...
359
	{
359
	{
360
		printf ( "\nError! Some packages are missing dependacies:\n" );
360
		printf ( "\nError! Some packages are missing dependacies:\n" );
361
		for ( CListNode<CBaseFile> *pNode = lCheckPackages.Front(); pNode; pNode = pNode->next() )
361
		for ( CListNode<CBaseFile> *pNode = lCheckPackages.Front(); pNode; pNode = pNode->next() )
362
		{
362
		{
363
			CSpkFile *spk = (CSpkFile *)pNode->Data();
363
			CSpkFile *spk = (CSpkFile *)pNode->Data();
364
			printf ( "\t%s V%s by %s (Requires: %s by %s)\n", spk->name(packages->GetLanguage()).c_str(), spk->version().c_str(), spk->author().c_str(), spk->GetOtherName().c_str(), spk->GetOtherAuthor().c_str());
364
			wprintf(L"\t%s V%hs by %s (Requires: %hs by %hs)\n", spk->name(packages->GetLanguage()).c_str(), spk->version().c_str(), spk->author().c_str(), spk->GetOtherName().c_str(), spk->GetOtherAuthor().c_str());
365
		}
365
		}
366
	}
366
	}
367
 
367
 
368
	// no packages will be installed
368
	// no packages will be installed
369
	if ( packages->GetNumPackagesInQueue() < 1 )
369
	if ( packages->GetNumPackagesInQueue() < 1 )
370
		return NullString;
370
		return Utils::WString::Null();
371
 
371
 
372
	// install the package file
372
	// install the package file
373
	printf ( "  - Installing                     " );
373
	printf ( "  - Installing                     " );
374
	CLinkList<CBaseFile> erroredPackages;
374
	CLinkList<CBaseFile> erroredPackages;
375
	if ( packages->installPreparedPackages(errors, &progress, &erroredPackages) )
375
	if ( packages->installPreparedPackages(errors, &progress, &erroredPackages) )
376
		progress.Finish();
376
		progress.Finish();
377
	else
377
	else
378
	{
378
	{
379
		printf ( "ERROR!\n" );
379
		printf ( "ERROR!\n" );
380
		return NullString;
380
		return Utils::WString::Null();
381
	}
381
	}
382
 
382
 
383
	// delete any errored packages
383
	// delete any errored packages
384
	for ( CListNode<CBaseFile> *pNode = erroredPackages.Front(); pNode; pNode = pNode->next() )
384
	for ( CListNode<CBaseFile> *pNode = erroredPackages.Front(); pNode; pNode = pNode->next() )
385
	{
385
	{
386
		lPackages.remove(pNode->Data());
386
		lPackages.remove(pNode->Data());
387
		pNode->DeleteData();
387
		pNode->DeleteData();
388
	}
388
	}
389
 
389
 
390
	// now display the packages
390
	// now display the packages
391
	CyString retStr = "Packages Installed:\n";
391
	Utils::WString retStr = L"Packages Installed:\n";
392
	for ( CListNode<CBaseFile> *pNode = lPackages.Front(); pNode; pNode = pNode->next() )
392
	for ( CListNode<CBaseFile> *pNode = lPackages.Front(); pNode; pNode = pNode->next() )
393
	{
393
	{
394
		CBaseFile *package = pNode->Data();
394
		CBaseFile *package = pNode->Data();
395
 
395
 
396
		retStr += "  <> ";
396
		retStr += L"  <> ";
397
		retStr += package->getFullPackageName(packages->GetLanguage());
397
		retStr += package->getFullPackageName(packages->GetLanguage());
398
		retStr += "\n";
398
		retStr += L"\n";
399
 
399
 
400
		if ( !packages->getInstallAfterText(package).empty() )
400
		if ( !packages->getInstallAfterText(package).empty() )
401
		{
401
		{
402
			Utils::String afterText = packages->getInstallAfterText(package).stripHtml();
402
			Utils::String afterText = packages->getInstallAfterText(package).stripHtml();
403
			afterText = afterText.findReplace("\n", "\n\t");
403
			afterText = afterText.findReplace("\n", "\n\t");
404
			retStr += "\t";
404
			retStr += L"\t";
405
			retStr += afterText;
405
			retStr += afterText.toWString();
406
			retStr += "\n";
406
			retStr += L"\n";
407
		}
407
		}
408
	}
408
	}
409
 
409
 
410
	return retStr;
410
	return retStr;
411
}
411
}
Line 446... Line 446...
446
		}
446
		}
447
	}
447
	}
448
 
448
 
449
	CProgressConsole progress;
449
	CProgressConsole progress;
450
 
450
 
451
	endMessage = "Uninstalled: " + p->getFullPackageName(packages->GetLanguage());
451
	endMessage = "Uninstalled: " + p->getFullPackageName(packages->GetLanguage()).toString();
452
	// add the uninstall after text
452
	// add the uninstall after text
453
	uText = packages->getUninstallAfterText(p).stripHtml();
453
	uText = packages->getUninstallAfterText(p).stripHtml();
454
	if (!uText.empty())
454
	if (!uText.empty())
455
	{
455
	{
456
		endMessage += "\n\n";
456
		endMessage += "\n\n";
Line 481... Line 481...
481
	if ( !p )
481
	if ( !p )
482
		return false;
482
		return false;
483
 
483
 
484
	CProgressConsole progress;
484
	CProgressConsole progress;
485
 
485
 
486
	endMessage = "Enabled: " + p->getFullPackageName(packages->GetLanguage());
486
	endMessage = "Enabled: " + p->getFullPackageName(packages->GetLanguage()).toString();
487
 
487
 
488
	printf ( "  - Enabling                       " );
488
	printf ( "  - Enabling                       " );
489
	if ( packages->enablePackage(p, errors, &progress) )
489
	if ( packages->enablePackage(p, errors, &progress) )
490
	{
490
	{
491
		progress.Finish();
491
		progress.Finish();
Line 509... Line 509...
509
	if ( !p )
509
	if ( !p )
510
		return false;
510
		return false;
511
 
511
 
512
	CProgressConsole progress;
512
	CProgressConsole progress;
513
 
513
 
514
	endMessage = "Disabled: " + p->getFullPackageName(packages->GetLanguage());
514
	endMessage = "Disabled: " + p->getFullPackageName(packages->GetLanguage()).toString();
515
 
515
 
516
	printf ( "  - Disabling                      " );
516
	printf ( "  - Disabling                      " );
517
	if ( packages->disablePackage(p, errors, &progress) )
517
	if ( packages->disablePackage(p, errors, &progress) )
518
	{
518
	{
519
		progress.Finish();
519
		progress.Finish();
Line 794... Line 794...
794
				case 'i':
794
				case 'i':
795
					if ( argc <= start )
795
					if ( argc <= start )
796
						printf ( "Syntax: %s [flags] /i <file>\n\tInstalls a package to the destination\n", cmd.c_str() );
796
						printf ( "Syntax: %s [flags] /i <file>\n\tInstalls a package to the destination\n", cmd.c_str() );
797
					else
797
					else
798
					{
798
					{
799
						Utils::String aftertext = InstallPackage(&lArguments, &lErrors, &packages, disabled).ToString();
799
						Utils::WString aftertext = InstallPackage(&lArguments, &lErrors, &packages, disabled);
800
						if(!aftertext.empty())
800
						if(!aftertext.empty())
801
						{
801
						{
802
							prepare = true;
802
							prepare = true;
803
							endMessage = aftertext;
803
							endMessage = aftertext.toString();
804
						}
804
						}
805
						PrintDebug(&errors);
805
						PrintDebug(&errors);
806
					}
806
					}
807
					break;
807
					break;
808
 
808