Subversion Repositories spk

Rev

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

Rev 126 Rev 127
Line 26... Line 26...
26
 
26
 
27
/*
27
/*
28
	Func:	GetInput
28
	Func:	GetInput
29
	Desc:	Gets an input from the user, ie, any settings required to be typed in
29
	Desc:	Gets an input from the user, ie, any settings required to be typed in
30
*/
30
*/
31
CyString GetInput ()
31
Utils::String GetInput ()
32
{
32
{
33
	g_read = true;
33
	g_read = true;
34
 
34
 
35
	CyString line;
35
	Utils::String line;
36
	char c = getchar();
36
	char c = getchar();
37
 
37
 
38
	while ( (c != '\n') && (c != '\0') )
38
	while ( (c != '\n') && (c != '\0') )
39
	{
39
	{
40
		line += c;
40
		line += c;
Line 311... Line 311...
311
		printf("\t- Bodies:\t %d\n", ship.GetBodies()->Count());
311
		printf("\t- Bodies:\t %d\n", ship.GetBodies()->Count());
312
		printf("\t- Cockpits:\t %d\n", ship.GetCockpits()->size());
312
		printf("\t- Cockpits:\t %d\n", ship.GetCockpits()->size());
313
		printf("\t- Text Entries:\t %d\n", ship.GetTexts()->size());
313
		printf("\t- Text Entries:\t %d\n", ship.GetTexts()->size());
314
 
314
 
315
		printf("\nEnter the name for the ship: ");
315
		printf("\nEnter the name for the ship: ");
316
		ship.setName(GetInput().ToString());
316
		ship.setName(GetInput());
317
		printf("Enter the author for the ship: ");
317
		printf("Enter the author for the ship: ");
318
		ship.setAuthor(GetInput().ToString());
318
		ship.setAuthor(GetInput());
319
		printf("Enter the version for the ship: V");
319
		printf("Enter the version for the ship: V");
320
		ship.setVersion(GetInput().ToString());
320
		ship.setVersion(GetInput());
321
		printf("Enter the description for the ship: ");
321
		printf("Enter the description for the ship: ");
322
		ship.setDescription(GetInput().ToString());
322
		ship.setDescription(GetInput());
323
 
323
 
324
		struct tm   *currDate;
324
		struct tm   *currDate;
325
		char    dateString[100];
325
		char    dateString[100];
326
		time_t now = time(NULL);
326
		time_t now = time(NULL);
327
		currDate = localtime( &now );
327
		currDate = localtime( &now );
Line 352... Line 352...
352
			return "X3: Terran Conflict";
352
			return "X3: Terran Conflict";
353
		case GAME_X3AP:
353
		case GAME_X3AP:
354
			return "X3: Albion Prelude";
354
			return "X3: Albion Prelude";
355
		case GAME_X3FL:
355
		case GAME_X3FL:
356
			return "X3: Farnham's Legacy";
356
			return "X3: Farnham's Legacy";
357
		case GAME_XREBIRTH:
-
 
358
			return "X: Rebirth";
-
 
359
	}
357
	}
360
	return "Unknown";
358
	return "Unknown";
361
}
359
}
362
void DisplayVersion ( CyString filename )
360
void DisplayVersion ( CyString filename )
363
{
361
{
Line 859... Line 857...
859
	remove ( filename.c_str() );
857
	remove ( filename.c_str() );
860
 
858
 
861
	CSpkFile spkfile;
859
	CSpkFile spkfile;
862
 
860
 
863
	printf ( "Enter Script Name: " );
861
	printf ( "Enter Script Name: " );
864
	spkfile.setName ( GetInput().ToString() );
862
	spkfile.setName(GetInput());
865
 
863
 
866
	printf ( "Enter Script Author: " );
864
	printf ( "Enter Script Author: " );
867
	spkfile.setAuthor ( GetInput().ToString() );
865
	spkfile.setAuthor(GetInput());
868
 
866
 
869
	printf ( "Enter Script Version: " );
867
	printf ( "Enter Script Version: " );
870
	spkfile.setVersion ( GetInput().ToString() );
868
	spkfile.setVersion(GetInput());
871
 
869
 
872
	printf ( "Enter Script Description: " );
870
	printf ( "Enter Script Description: " );
873
	spkfile.setDescription ( GetInput().ToString() );
871
	spkfile.setDescription(GetInput());
874
 
872
 
875
	struct tm   *currDate;
873
	struct tm   *currDate;
876
	char    dateString[100];
874
	char    dateString[100];
877
	time_t now = time(NULL);
875
	time_t now = time(NULL);
878
 
876
 
Line 1145... Line 1143...
1145
	}
1143
	}
1146
 
1144
 
1147
	printf ( "(Done)\n" );
1145
	printf ( "(Done)\n" );
1148
}
1146
}
1149
 
1147
 
1150
CyString GetAsk(CyString command)
1148
Utils::String GetAsk(const Utils::String &command)
1151
{
1149
{
1152
	printf("(ASK) Enter the value for, %s: ", command.c_str());
1150
	printf("(ASK) Enter the value for, %s: ", command.c_str());
1153
	return GetInput();
1151
	return GetInput();
1154
}
1152
}
1155
 
1153
 
Line 1330... Line 1328...
1330
		printf("Error: %s doesn't appear to be a spk file\n", spkfile.c_str());
1328
		printf("Error: %s doesn't appear to be a spk file\n", spkfile.c_str());
1331
		return;
1329
		return;
1332
	}
1330
	}
1333
 
1331
 
1334
	CPackages p;
1332
	CPackages p;
-
 
1333
	p.startup(".", ".", ".");
1335
	int error;
1334
	int error;
1336
	CBaseFile *package = p.OpenPackage(spkfile, &error, 0, SPKREAD_NODATA);
1335
	CBaseFile *package = p.OpenPackage(spkfile, &error, 0, SPKREAD_NODATA);
1337
	if ( !package )
1336
	if ( !package )
1338
	{
1337
	{
1339
		printf("Error: unable to open package files, %s, Error=%d\n", spkfile.c_str(), error);
1338
		printf("Error: unable to open package files, %s, Error=%d\n", spkfile.c_str(), error);
1340
		return;
1339
		return;
1341
	}
1340
	}
1342
 
1341
 
1343
	Utils::CStringList list;
1342
	Utils::CStringList list;
1344
	if ( !package->GeneratePackagerScript(true, &list, game) )
1343
	if ( !p.generatePackagerScript(package, true, &list, game) )
1345
	{
1344
	{
1346
		printf("Error: Unable to generate packager script\n");
1345
		printf("Error: Unable to generate packager script\n");
1347
		return;
1346
		return;
1348
	}
1347
	}
1349
 
1348