#========================================================================= # # text_extract.pl # # Author: pkg@Climax # Created: # Project: SBSP # Purpose: Extracts text ids from the translation header file and exports # them to an in clude file. This is grabbing the ingame texts and # putting them somewhere that the script compiler can use # Usage: text_extract infile outfile tagprefix # eg: text_extract trans.h scripts\defs\trans.h STR__INGAME__ # # Copyright (c) 2001 Climax Development Ltd # #=========================================================================== local ($inFile,$outFile,$tagPrefix)=@ARGV; #print "inFile: $inFile\n"; #print "outFile: $outFile\n"; #print "tagPrefix: $tagPrefix\n"; # Open files open INFILE, $inFile || die "Can't open input file '$inFile': $!\n"; open OUTFILE, ">$outFile" || die "Can't open output file '$outFile': $!\n"; # Output header print OUTFILE < || die "End of file found while looking while looking for start of enum list!\n"; if($line =~ /^\{/) { $done=1; } } # Grab the ids $done=0; $textId=0; while(!$done) { $line= || die "End of file found before end of enum list!\n"; chomp($line); if($line=~/^\}/) { $done=1; } elsif($line=~/^\s*$/) { } else { $line=~s/^\s*([\w]*).*/$1/; if($line=~/^$tagPrefix/) { print OUTFILE "#define ",$line,"\t\t$textId\n"; } $textId++; } } # Done! :) close INFILE; close OUTFILE;