summaryrefslogtreecommitdiffstats
path: root/tools/buildtheme.pl
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-06-03 13:44:41 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-06-03 13:44:41 +0000
commit30804e5a3f6ab53cff56f11b44c077b5044e0b51 (patch)
treedab9d66b6ccd51133e173a782d1e71aedc2f60a1 /tools/buildtheme.pl
parent6e39dc9e27e852bcf88490ee0c5e267c90f0513b (diff)
downloadrockbox-30804e5a3f6ab53cff56f11b44c077b5044e0b51.tar.gz
rockbox-30804e5a3f6ab53cff56f11b44c077b5044e0b51.tar.bz2
rockbox-30804e5a3f6ab53cff56f11b44c077b5044e0b51.zip
almost finished... copy fonts, backdrops, icon files, skins. last thing to do is copy the images from inside the skins
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26511 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/buildtheme.pl')
-rwxr-xr-xtools/buildtheme.pl140
1 files changed, 134 insertions, 6 deletions
diff --git a/tools/buildtheme.pl b/tools/buildtheme.pl
index 7f135fd121..488a57d0ab 100755
--- a/tools/buildtheme.pl
+++ b/tools/buildtheme.pl
@@ -39,7 +39,7 @@ my $has_remote;
if(!$wpslist) {
- print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
+ print "Usage: buildtheme.pl <WPSLIST> <target>\n",
"Run this script in the root of the target build, and it will put all the\n",
"stuff in $rbdir/wps/\n";
exit;
@@ -101,8 +101,8 @@ STOP
}
# Get the LCD sizes first
-($main_height, $main_width, $main_depth) = (320,240,16);#getlcdsizes();
-($remote_height, $remote_width, $remote_depth) = ();#getlcdsizes(1);
+($main_height, $main_width, $main_depth) = getlcdsizes();
+($remote_height, $remote_width, $remote_depth) = getlcdsizes(1);
#print "LCD: ${main_width}x${main_height}x${main_depth}\n";
$has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
@@ -134,6 +134,8 @@ sub mkdirs
mkdir "$rbdir", 0777;
mkdir "$rbdir/wps", 0777;
mkdir "$rbdir/themes", 0777;
+ mkdir "$rbdir/icons", 0777;
+ mkdir "$rbdir/backdrops", 0777;
if( -d "$rbdir/wps/$themename") {
# print STDERR "wpsbuild warning: directory wps/$themename already exists!\n";
@@ -150,7 +152,7 @@ sub buildcfg {
push @out, <<MOO
\#
-\# generated by wpsbuild.pl
+\# generated by buildtheme.pl
\# $themename is made by $theme{"Author"}
\#
MOO
@@ -175,14 +177,31 @@ MOO
{
# do nothing
}
- elsif ($k =~ "/WPS|RWPS|FMS|RFMF|SBS|RSBS/" && exists($theme{$k}))
+ elsif ($k =~ /WPS|RWPS|FMS|RFMS|SBS|RSBS/ && exists($theme{$k}))
{
push (@out, "$v: $themename.$v\n");
}
+ elsif ($k =~ /backdrop/ )
+ {
+ if (exists($theme{$k}))
+ {
+ my $dst = $theme{$k};
+ $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
+ push (@out, "$v: $theme{$k}\n");
+ }
+ else
+ {
+ push (@out, "$v: -\n");
+ }
+ }
elsif (exists($theme{$k}))
{
push (@out, "$v: $theme{$k}\n");
}
+ else
+ {
+ push (@out, "$v: -\n");
+ }
}
# if(-f "$rbdir/themes/$themename.cfg") {
@@ -195,6 +214,101 @@ MOO
# }
}
+
+sub copythemefont
+{
+ my ($font) = @_;
+ #copy the font specified by the theme
+
+ my $o=$font;
+ $o =~ s/\.fnt/\.bdf/;
+ mkdir "$rbdir/fonts";
+ my $cmd ="$ROOT/tools/convbdf -f -o \"$rbdir/fonts/$font\" \"$ROOT/fonts/$o\" ";
+ # print "$cmd\n";
+ `$cmd`;
+}
+
+sub copyiconset
+{
+ my ($iconset) = @_;
+ #copy the icon specified by the theme
+
+ if ($iconset ne '') {
+ $iconset =~ s/.rockbox/$rbdir/;
+ $iconset =~ /\/(.*icons\/(.*))/i;
+ `cp $ROOT/icons/$2 $1`;
+ }
+}
+
+sub copybackdrop
+{
+ my ($backdrop) = @_;
+ #copy the backdrop file into the build dir
+ if ($backdrop ne '')
+ {
+ my $dst = $backdrop;
+ $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
+ my $cmd = "cp $ROOT/$backdrop $rbdir/$dst";
+ # print "$cmd\n";
+ `$cmd`;
+ }
+}
+
+
+sub copyskin
+{
+ my ($themename, $skin, $ext) = @_;
+ # we assume that we copy the WPS files from the same dir the WPSLIST
+ # file is located in
+ my $dir;
+ my @filelist;
+ my $src;
+ my $dest;
+
+ if($wpslist =~ /(.*)OUT/) {
+ $dir = $1;
+
+ # first try the actual filename given to us
+ # then $skin.widthxheightxdepths.ext
+ # then $skin.ext
+ $src = "${dir}$skin.$ext";
+ if ( -e $src )
+ {
+ my $cmd = "cp $src $rbdir/wps/$themename.$ext";
+ `$cmd`;
+ }
+ else
+ {
+ my $is_remote = ($ext =~ /^r.../i);
+ my $width = $is_remote ? $remote_width : $main_width;
+ my $height = $is_remote ? $remote_height : $main_height;
+ my $depth = $is_remote ? $remote_depth : $main_depth;
+
+ foreach my $d (@depthlist)
+ {
+ next if ($d > $depth);
+ $src = "${dir}$skin.${width}x${height}x${d}.$ext";
+ last if (-e $src);
+ }
+ if (-e $src)
+ {
+ my $cmd = "cp $src $rbdir/wps/$themename.$ext";
+ print "$cmd\n";
+ `$cmd`;
+ }
+ elsif (-e "${dir}$skin.$ext")
+ {
+ my $cmd = "cp ${dir}$skin.$ext $rbdir/wps/$themename.$ext";
+ `$cmd`;
+ }
+ else
+ {
+ #print STDERR "buildtheme warning: No suitable skin file for $ext\n";
+ }
+ }
+ }
+}
+
open(WPS, "<$wpslist");
while(<WPS>) {
my $l = $_;
@@ -222,8 +336,22 @@ while(<WPS>) {
mkdirs($theme{Name});
buildcfg($theme{Name});
+ copyskin($theme{"Name"}, $theme{"WPS"}, "wps") if exists($theme{"WPS"});
+ copyskin($theme{"Name"}, $theme{"RWPS"}, "rwps") if exists($theme{"RWPS"});
+ copyskin($theme{"Name"}, $theme{"FMS"}, "fms") if exists($theme{"FMS"});
+ copyskin($theme{"Name"}, $theme{"RFMS"}, "rfms") if exists($theme{"RFMS"});
+ copyskin($theme{"Name"}, $theme{"SBS"}, "sbs") if exists($theme{"SBS"});
+ copyskin($theme{"Name"}, $theme{"RSBS"}, "rsbs") if exists($theme{"RSBS"});
+
+ copyiconset($theme{"iconset"}) if exists($theme{"iconset"});
+ copyiconset($theme{"remote iconset"}) if exists($theme{"remote iconset"});
+ copyiconset($theme{"viewers iconset"}) if exists($theme{"viewers iconset"});
+ copyiconset($theme{"remote viewers iconset"}) if exists($theme{"remote viewers iconset"});
+ copythemefont($theme{"Font"}) if exists($theme{"Font"});
+ copythemefont($theme{"Remote Font"}) if exists($theme{"Remote Font"});
+ copybackdrop($theme{"backdrop"}) if exists($theme{"backdrop"});
@@ -238,7 +366,7 @@ while(<WPS>) {
($extra && (match($target, $extra) || matchdisplaystring($extra))))
{
$theme{$var} = $value;
- # print "\'$var\': $value\n";
+ #print "\'$var\': $value\n";
}
}
}