[Scummvm-cvs-logs] CVS: scummvm/tools credits.pl,1.7,1.8

Max Horn fingolfin at users.sourceforge.net
Tue Mar 22 12:16:37 CET 2005


Update of /cvsroot/scummvm/scummvm/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24439

Modified Files:
	credits.pl 
Log Message:
Add RTF as an output format, allowing the creation of a Credits.rtf file for the OSX version (currently using some Mac/Cocoa specific header stuff, mostly because I am too lazy to do look this up in the RTF specs right now)

Index: credits.pl
===================================================================
RCS file: /cvsroot/scummvm/scummvm/tools/credits.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- credits.pl	3 Jan 2005 23:51:16 -0000	1.7
+++ credits.pl	22 Mar 2005 20:16:02 -0000	1.8
@@ -27,16 +27,17 @@
 my $tab;
 
 if ($#ARGV >= 0) {
-	$mode = "TEXT" if ($ARGV[0] eq "--text");	# AUTHROS
+	$mode = "TEXT" if ($ARGV[0] eq "--text");	# AUTHORS file
 	$mode = "HTML" if ($ARGV[0] eq "--html");	# credits.inc (for use on the website)
 	$mode = "CPP" if ($ARGV[0] eq "--cpp");		# credits.h (for use by about.cpp)
 	$mode = "XML" if ($ARGV[0] eq "--xml");		# credits.xml (DocBook)
+	$mode = "RTF" if ($ARGV[0] eq "--rtf");		# Credits.rtf (Mac OS X About box)
 	#$mode = "TEX" if ($ARGV[0] eq "--tex");		# 10.tex (LaTeX)
 }
 
 if ($mode eq "") {
-	print STDERR "Usage: credits.pl [--text | --html | --cpp | --xml]\n";
-	print STDERR " Just pass --text / --html / --cpp / --xml as parameter, and credits.pl\n";
+	print STDERR "Usage: credits.pl [--text | --html | --cpp | --xml | --rtf]\n";
+	print STDERR " Just pass --text / --html / --cpp / --xml / --rtf as parameter, and credits.pl\n";
 	print STDERR " will print out the corresponding version of the credits to stdout.\n";
 	exit 1;
 }
@@ -52,7 +53,7 @@
 }
 
 # Convert HTML entities to ASCII for the plain text mode
-sub convert_html_entities {
+sub html_entities_to_ascii {
 	my $text = shift;
 	
 	# For now we hardcode these mappings
@@ -76,11 +77,32 @@
 	return $text;
 }
 
+# Convert HTML entities to RTF codes
+sub html_entities_to_rtf {
+	my $text = shift;
+	
+	$text =~ s/á/\\'87/g;
+	$text =~ s/é/\\'8e/g;
+	$text =~ s/ø/\\'bf/g;
+	$text =~ s/ł/\\uc0\\u322 /g;
+	$text =~ s/ö/\\'9a/g;
+
+	$text =~ s/&/&/g;
+	
+	return $text;
+}
+
 sub begin_credits {
 	my $title = shift;
 
 	if ($mode eq "TEXT") {
-		#print convert_html_entities($title)."\n";
+		#print html_entities_to_ascii($title)."\n";
+	} elsif ($mode eq "RTF") {
+		print '{\rtf1\mac\ansicpg10000\cocoartf102' . "\n";
+		print '{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;}' . "\n";
+		print '{\colortbl;\red255\green255\blue255;\red0\green128\blue0;}' . "\n";
+		print '\vieww6920\viewh15480\viewkind0' . "\n";
+		print "\n";
 	} elsif ($mode eq "CPP") {
 		print "// This file was generated by credits.pl. Do not edit by hand!\n";
 		print "static const char *credits[] = {\n";
@@ -103,6 +125,8 @@
 
 sub end_credits {
 	if ($mode eq "TEXT") {
+	} elsif ($mode eq "RTF") {
+		print "}\n";
 	} elsif ($mode eq "CPP") {
 		print "};\n";
 	} elsif ($mode eq "XML") {
@@ -118,10 +142,20 @@
 sub begin_section {
 	my $title = shift;
 	if ($mode eq "TEXT") {
-		$title = convert_html_entities($title);
+		$title = html_entities_to_ascii($title);
 		print $title.":\n";
+	} elsif ($mode eq "RTF") {
+		$title = html_entities_to_rtf($title);
+
+		# Center text
+		print '\pard\qc' . "\n";
+		print '\f0\b\fs28 \cf2 ' . $title . "\n";
+		print '\f1\b0\fs24 \cf0 \\' . "\n";
+#		print '\pard\tx565\li574\fi-574\ql\qnatural' . "\n";
+		# Switch back to base font
+		print '\cf0' . "\n";
 	} elsif ($mode eq "CPP") {
-		$title = convert_html_entities($title);
+		$title = html_entities_to_ascii($title);
 		print '"\\\\C\\\\c1""'.$title.':",' . "\n";
 	} elsif ($mode eq "XML") {
 		print "  <row><entry namest='start' nameend='job'>";
@@ -135,6 +169,8 @@
 sub end_section {
 	if ($mode eq "TEXT") {
 		print "\n";
+	} elsif ($mode eq "RTF") {
+		print "\\\n";
 	} elsif ($mode eq "CPP") {
 		print '"\\\\L\\\\c0""",' . "\n";
 	} elsif ($mode eq "XML") {
@@ -151,8 +187,8 @@
 	
 	if ($mode eq "TEXT") {
 		$name = $nick if $name eq "";
-		$name = convert_html_entities($name);
-		$desc = convert_html_entities($desc);
+		$name = html_entities_to_ascii($name);
+		$desc = html_entities_to_ascii($desc);
 		
 		printf $tab."%-".$max_name_width.".".$max_name_width."s - ", $name;
 		
@@ -160,10 +196,26 @@
 		my $inner_indent = $indent + $max_name_width + 3;
 		my $multitab = " " x $inner_indent;
 		print substr(wrap($multitab, $multitab, $desc), $inner_indent)."\n"
+	} elsif ($mode eq "RTF") {
+		$name = $nick if $name eq "";
+		$name = html_entities_to_rtf($name);
+		$desc = html_entities_to_rtf($desc);
+
+		# Left align name
+		print '\pard\ql\qnatural' . "\n";
+		print $name . "\\\n";
+
+		# Left align description, with a left indention
+		print '\pard\li560\ql\qnatural' . "\n";
+		# Italics
+		print "\\i " . $desc . "\\i0\\\n";
+#		print $name . "\\\n";
+#		print "\\i\t" . $desc . "\\i0\\\n";
+##		print "\t" . $name . "\t- " . $desc . "\\\n";
 	} elsif ($mode eq "CPP") {
 		$name = $nick if $name eq "";
-		$name = convert_html_entities($name);
-		$desc = convert_html_entities($desc);
+		$name = html_entities_to_ascii($name);
+		$desc = html_entities_to_ascii($desc);
 
 		print '"\\\\L\\\\c0""  '.$name.'",' . "\n";
 
@@ -195,8 +247,13 @@
 	my $text = shift;
 	
 	if ($mode eq "TEXT") {
-		print wrap($tab, $tab, convert_html_entities($text))."\n";
+		print wrap($tab, $tab, html_entities_to_ascii($text))."\n";
 		print "\n";
+	} elsif ($mode eq "RTF") {
+		# Left align text
+		print '\pard\ql\qnatural' . "\n";
+		print $text . "\\\n";
+		print "\\\n";
 	} elsif ($mode eq "CPP") {
 		my $line_start = '"\\\\L\\\\c0""';
 		my $line_end = '",';





More information about the Scummvm-git-logs mailing list