?? rsc2savefile.pl
字號:
#!/usr/bin/perl
use BuildRscCFile;
## NOTE: all file name must be within 6 chars.
#const
my $IMG_BIN_FILE = "image.cdd"; #compact dir data
my $IMG_DIR_FILE = "image.dir";
my $PAL_DIR_FILE = "Pal.dir";
#font's bin is file *.fbn, * is desided by idstr.
my $FNT_DIR_FILE = "font.dir";
#string's bin is file *.sbn, * is desided by idstr.
my $STR_DIR_FILE = "string.dir";
#logo's data bin is file *.lbn, * is desided by idstr.
my $LOGO_DIR_FILE = "logo.dir";
#dsp code's data bin is file *.dbn, * is desided by idstr.
my $DSP_DIR_FILE = "dspcod.dir";
#resource configure files dir
my $RSC_CFG_DIR_FILE = "rsccfg.dir";
my $JPEG_DIR_FILE = "jpeg.dir";
#### remove old output files
my @proglist = ("rm","-f","$IMG_BIN_FILE");
system(@proglist);
my @proglist = ("rm","-f","$IMG_DIR_FILE");
system(@proglist);
my @proglist = ("rm","-f","$PAL_DIR_FILE");
system(@proglist);
my @proglist = ("rm","-f","$FNT_DIR_FILE");
system(@proglist);
my @proglist = ("rm","-f","$STR_DIR_FILE");
system(@proglist);
my @proglist = ("rm","-f","$LOGO_DIR_FILE");
system(@proglist);
my @proglist = ("rm","-f","$DSP_DIR_FILE");
system(@proglist);
my @proglist = ("rm","-f","$RSC_CFG_DIR_FILE");
system(@proglist);
my @proglist = ("rm","-f","$JPEG_DIR_FILE");
system(@proglist);
# const
my $PARSE_ERR_SECTION = "error_section";
my $PARSE_GENERAL = "general";
my $PARSE_RSC_IMAGE = "image";
my $PARSE_RSC_FONT = "font";
my $PARSE_RSC_STRING = "string";
my $PARSE_RSC_LOGO = "logo";
my $PARSE_RSC_DSP = "dspcod";
my $PARSE_RSC_CONFIG = "rsccfg";
my $PARSE_JPEG_CODE = "jpeg_code";
#my $PARSE_RSC_OVER = "over";
# ver
my $line;
my $linenum = 0;
my $parse_type;
my $resource_path;
my $resource_file;
my $string_id_file = "StringID.def"; #default
if (@ARGV != 0)
{
open (H_SCRIPT, "$ARGV[0]") || die ("Can not open file \"$ARGV[0]\"\n");
}
else
{
open (H_SCRIPT, "RscScript") || die ("Can not open file \"RscScript\"\n");
}
foreach $line(<H_SCRIPT>)
{
$linenum ++;
$line =~ s/(\;.*)//; #remove lines marked by ;
$line =~ s/(\s*)//g; #remove all space for all of them can be ignord in format
$line =~ tr/A-Z/a-z/; #lower case only;
if ($line =~ /^\[(.+)\]$/) # [] line
{
if (($1 eq $PARSE_GENERAL) || ($1 eq $PARSE_RSC_IMAGE) || ($1 eq $PARSE_RSC_FONT) || ($1 eq $PARSE_RSC_STRING) || ($1 eq $PARSE_RSC_LOGO) || ($1 eq $PARSE_RSC_DSP) || ($1 eq $PARSE_RSC_CONFIG) || ($1 eq $PARSE_JPEG_CODE))
{
$parse_type = $1;
# print "\nOK: find section [$parse_type] at line $linenum.\n";
}
else
{
print "Warning: unknown resource type \"$1\" at line $linenum, this section be ignored.\n";
$parse_type = $PARSE_ERR_SECTION;
}
next;
}
elsif ($line =~ /^$/) #empty line
{
# print "OK: find an empty line at line $linenum.\n";
next;
}
if ($parse_type eq $PARSE_GENERAL)
{
if ($line =~ /^resource_path=([a-zA-Z\.\\][a-zA-Z0-9_\.\\]*)$/)
{
# print "OK: find resource file path :\"$1\" at line $linenum\n";
$resource_path = $1;
}
}
elsif ($parse_type eq $PARSE_RSC_IMAGE)
{
if ($line =~ /^file=([a-zA-Z][a-zA-Z0-9_\.]*),iszip=(\d)+$/)
{
# print "OK: find image file \"$1\" at line $linenum, iszip = $2.\n";
$resource_file = $1;
&BuildImg("$resource_path"."$resource_file","$IMG_BIN_FILE","$IMG_DIR_FILE",$2,"$PAL_DIR_FILE");
}
else
{
print "Warning: format mismatch for image resource, line $linenum has been ignored.\n";
}
}
elsif ($parse_type eq $PARSE_RSC_FONT)
{
if ($line =~ /^file=([a-zA-Z][a-zA-Z0-9_\.]*),idstr=([a-zA-Z0-9_]+),iszip=(\d)+$/)
{
# print "OK: find font file \"$1\" at line $linenum, idstr = $2, iszip = $3\n";
$resource_file = $1;
&BuildFnt("$resource_path"."$resource_file",$2,"$FNT_DIR_FILE",$3);
}
else
{
print "Warning: format mismatch for font resource, line $linenum has been ignored.\n";
}
}
elsif ($parse_type eq $PARSE_RSC_STRING)
{
if ($line =~ /^stringidfile=([a-zA-Z][a-zA-Z0-9_\.]*)$/)
{
$string_id_file = $1;
# print "OK: find string id file \"$1\" at line $linenum\n"
}
elsif ($line =~ /^file=([a-zA-Z][a-zA-Z0-9_\.]*),idstr=([a-zA-Z0-9_]+),iszip=(\d)+$/)
{
# print "OK: find string file \"$1\" at line $linenum, idstr = $2, iszip = $3\n";
$resource_file = $1;
&BuildStr("$resource_path"."$resource_file","$resource_path"."$string_id_file",$2,"$STR_DIR_FILE",$3);
}
else
{
print "Warning: format mismatch for string resource, line $linenum has been ignored.\n";
}
}
elsif ($parse_type eq $PARSE_RSC_LOGO)
{
if ($line =~ /^file=([a-zA-Z0-9_][a-zA-Z0-9_\.]*),idstr=([a-zA-Z0-9_]+),iszip=(\d)+$/)
{
# print "OK: find Logo file \"$1\" at line $linenum, idstr = $2, iszip = $3\n";
$resource_file = $1;
&BuildInc("$resource_path"."$resource_file",$2,"$LOGO_DIR_FILE",$3);
}
else
{
print "Warning: format mismatch for logo resource, line $linenum has been ignored.\n";
}
}
elsif ($parse_type eq $PARSE_JPEG_CODE)
{
if ($line =~ /^file=([a-zA-Z0-9_][a-zA-Z0-9_\.]*),idstr=([a-zA-Z0-9_]+),iszip=(\d)+$/)
{
# print "OK: find Logo file \"$1\" at line $linenum, idstr = $2, iszip = $3\n";
$resource_file = $1;
&CopyAndSave("$resource_path"."$resource_file",$2,"$JPEG_DIR_FILE",$3);
}
else
{
print "Warning: format mismatch for logo resource, line $linenum has been ignored.\n";
}
}
elsif ($parse_type eq $PARSE_RSC_DSP)
{
if ($line =~ /^file=([a-zA-Z][a-zA-Z0-9_\.]*),idstr=([a-zA-Z0-9_]+),iszip=(\d)+$/)
{
# print "OK: find DSP CODE file \"$1\" at line $linenum, idstr = $2, iszip = $3\n";
$resource_file = $1;
&BuildDataFile("$resource_path"."$resource_file",$2,"$DSP_DIR_FILE", $3, 32);
}
else
{
print "Warning: format mismatch for DSP CODE resource, line $linenum has been ignored.\n";
}
}
elsif ($parse_type eq $PARSE_RSC_CONFIG)
{
if ($line =~ /^file=([a-zA-Z][a-zA-Z0-9_\.]*),idstr=([a-zA-Z0-9_]+),iszip=(\d)+$/)
{
# print "OK: find Direct file \"$1\" at line $linenum, idstr = $2, iszip = $3\n";
$resource_file = $1;
&CopyAndSave("$resource_path"."$resource_file",$2,"$RSC_CFG_DIR_FILE", $3);
}
else
{
print "Warning: format mismatch for DSP CODE resource, line $linenum has been ignored.\n";
}
}
elsif ($parse_type eq $PARSE_ERR_SECTION)
{
print "Warning: Line $linenum be ignored for in unknown section \n";
#do nothing for $PARSE_ERR_SECTION and just ignore this section.
}
else
{
die("Error: how can I run to here !!!\n");
}
}
close (H_SCRIPT);
##############################################################
# copy $IMG_BIN_FILE to "$IMG_BIN_FILE".".wrk"
# append the resource dir's
my $FM_SCRIPT = "FileMapConfig";
my $FM_SCRIPT2 = "$FM_SCRIPT".".wrk";
if (-e "$FM_SCRIPT")
{
my @proglist = ("cp","-f","$FM_SCRIPT","$FM_SCRIPT2");
system(@proglist);
chmod (6,"$FM_SCRIPT2"); # remove the "READ ONLY" attribute
open (H_FM_SCRIPT2,">>$FM_SCRIPT2") || die("Error: can not open \"$FM_SCRIPT2\" !\n");
print H_FM_SCRIPT2 "\n";
print H_FM_SCRIPT2 "[dir]\n";
print H_FM_SCRIPT2 "DirFileName = .\\$FNT_DIR_FILE\n" if (-e $FNT_DIR_FILE);
print H_FM_SCRIPT2 "DirFileName = .\\$STR_DIR_FILE\n" if (-e $STR_DIR_FILE);
print H_FM_SCRIPT2 "DirFileName = .\\$PAL_DIR_FILE\n" if (-e $PAL_DIR_FILE);
print H_FM_SCRIPT2 "DirFileName = .\\$LOGO_DIR_FILE\n" if (-e $LOGO_DIR_FILE);
print H_FM_SCRIPT2 "DirFileName = .\\$DSP_DIR_FILE\n" if (-e $DSP_DIR_FILE);
print H_FM_SCRIPT2 "DirFileName = .\\$JPEG_DIR_FILE\n" if (-e $JPEG_DIR_FILE);
print H_FM_SCRIPT2 "DirFileName = .\\$RSC_CFG_DIR_FILE\n" if (-e $RSC_CFG_DIR_FILE);
print H_FM_SCRIPT2 "\n";
print H_FM_SCRIPT2 "[compactdir]\n";
print H_FM_SCRIPT2 "DirFileName = .\\$IMG_DIR_FILE\n" if (-e $IMG_DIR_FILE);
print H_FM_SCRIPT2 "\n";
close (H_FM_SCRIPT2);
}
else
{
die("Error: can not find File Map Script file : \"$FM_SCRIPT\" !\n");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -