# creates PICT resource from a list of names

## Magic resource numbers - this is what Eudora expects.
$firstResNum = 1013;
$curResNum = 1013;

# Static stuff that is the same in each picture
$resHeader = "{ 0, 0, 177, 502},\n	VersionTwo {{ \
	HeaderOp { Version2, 0xFFFF0000, 0xFFFF0000, 0x1F60000, 0xB10000, 0 }, \
	DefHilite {},\n Clip {{ 0, 0, 177, 502 }, \$\"\" }, \
	RGBFgCol { 0, 0, 0, },\nPaintRect {{ 0, 0, 175, 500 }},\nPnSize {{ 0, 0 }}, \
	PaintRect {{ 19, 28, 163, 95 }},\nRGBFgCol { 65535, 65535, 65535, }, \
	FontName { 21, \"Helvetica\" },\nTxFont { 21 },\nTxMode { srcBic },\nTxSize { 9 },\n";

$resFooter = "OpEndPic {}}}};\n\n";

$nameCount = 0;

# OK, we want to put the names in colums. 
# Each column is 13 names long, and there are 5 columns in each picture.

print "#include \"Pict.r\"\n";

while (<>)
{
	chop;
	if (( $nameCount % 65 ) == 0 ) {
		print "resource 'PICT' ( ", $curResNum, ", \"Credits ", 2 + $curResNum - $firstResNum, "\", purgeable) {\n";
		print $resHeader;
		$curResNum++;
		}

	if ( $nameCount % 13 == 0 ) {	# Start a Column
		$newx = 25 + 95 * (( $nameCount % 65 ) / 13 );
		print "LongText {{ 25,", $newx, " }, \"", $_, "\\n\"},\n"
		}
	else {
		print "DVText { 11, \"", $_, "\\n\"},\n";
		}
	
	$nameCount++;

	if ( $nameCount % 65 == 0 ) {
		print $resFooter;
		}
}

# If we didn't finish a resource, close it off
if ( $nameCount % 65 != 0 ) {
	print $resFooter;
	}
