diff --git a/tools/buildzip.pl b/tools/buildzip.pl
index 6d25a01..51df2f8 100755
--- a/tools/buildzip.pl
+++ b/tools/buildzip.pl
@@ -625,9 +625,11 @@ STOP
# Now do the WPS dance
if(-d "$ROOT/wps") {
- my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl ";
- $wps_build_cmd=$wps_build_cmd."-v " if $verbose;
- $wps_build_cmd=$wps_build_cmd." --tempdir=$temp_dir --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target";
+# my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl ";
+ my $wps_build_cmd="perl $ROOT/wps/wpsbuild2.pl";
+ $wps_build_cmd=$wps_build_cmd." -v" if $verbose;
+# $wps_build_cmd=$wps_build_cmd." --tempdir=$temp_dir --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target";
+ $wps_build_cmd=$wps_build_cmd." --tempdir=$temp_dir --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST.xml";
print "wpsbuild: $wps_build_cmd\n" if $verbose;
system("$wps_build_cmd");
print "wps_build_cmd: done\n" if $verbose;
diff --git a/wps/WPSLIST.xml b/wps/WPSLIST.xml
new file mode 100644
index 0000000..5fd8d8a
--- /dev/null
+++ b/wps/WPSLIST.xml
@@ -0,0 +1,300 @@
+
+
+ ipodVOL
+ xameius
+ 12-Nimbus.fnt
+ 08-Schumacher-Clean.fnt
+ top
+ top
+
+
+
+ bar (inverse)
+
+ ipodVOL.wps
+ rockbox_default.rwps
+
+
+
+ boxes
+ Christi Scarborough (after Magnus Westerlund)
+ 08-Schumacher-Clean.fnt
+ 08-Schumacher-Clean.fnt
+ top
+ top
+ 000000
+ B6C6E5
+
+
+
+ bar (inverse)
+
+
+
+ boxes.wps
+ boxes.rwps
+
+
+
+ engineeer2
+ Magnus Westerlund
+ 08-Nedore.fnt
+ 08-Nedore.fnt
+ top
+ top
+
+
+
+ bar (inverse)
+
+
+
+ engineeer2.wps
+ engineeer2.rwps
+
+
+
+ iAmp
+ Raymond Hoh
+ 12-Nimbus.fnt
+ 12-Nimbus.fnt
+
+
+
+ bar (inverse)
+ top
+ top
+
+
+
+ iAmp.wps
+ iAmp.rwps
+
+
+
+ zezayer
+ Jake Owen, Dominik Riebeling
+ 08-Nedore.fnt
+ 08-Nedore.fnt
+ top
+ top
+
+
+
+ bar (inverse)
+
+
+
+ zezayer.wps
+ zezayer.rwps
+
+
+
+ DancePuffDuo
+ Chris Oxtoby
+ 13-Nimbus.fnt
+ 13-Nimbus.fnt
+ top
+ top
+ 000000
+ B6C6E5
+
+
+
+ bar (inverse)
+
+
+
+ DancePuffDuo.wps
+ DancePuffDuo.rwps
+
+
+
+ iCatcher
+ Ioannis Koutoulakis
+ 08-Rockfont.fnt
+ 08-Rockfont.fnt
+ 09-Nedore.fnt
+ 09-Nedore.fnt
+ 08-Nedore.fnt
+ 09-Nedore.fnt
+ 09-Nedore.fnt
+ 09-Nedore.fnt
+ 12-Nimbus.fnt
+ 14-Nimbus.fnt
+ 19-Nimbus.fnt
+ 19-Nimbus.fnt
+ 19-Nimbus.fnt
+ 09-Nedore.fnt
+ 14-Nimbus.fnt
+ 000000
+ FFFFFF
+ top
+ top
+
+
+ bar (inverse)
+
+
+
+ iCatcher.wps
+ iCatcher.rwps
+
+
+
+ UniCatcher
+ Ioannis Koutoulakis
+ 16-GNU-Unifont.fnt
+ 16-GNU-Unifont.fnt
+ 000000
+ FFFFFF
+ top
+ top
+
+
+ bar (inverse)
+
+
+
+ UniCatcher.wps
+ UniCatcher.rwps
+
+
+
+ Rockboxed
+ Roan Horning
+ 08-Schumacher-Clean.fnt
+ 08-Schumacher-Clean.fnt
+ 12-Nimbus.fnt
+ 10-Nimbus.fnt
+ 12-Nimbus.fnt
+ 12-Nimbus.fnt
+ 12-Nimbus.fnt
+ 12-Nimbus.fnt
+ 12-Nimbus.fnt
+ 14-Nimbus.fnt
+ 19-Nimbus.fnt
+ 19-Nimbus.fnt
+ 19-Nimbus.fnt
+ 000000
+ FFC000
+ top
+
+
+
+ bar (inverse)
+
+
+
+ Rockboxed.wps
+ rockbox_default.rwps
+
+
+
+ progressive
+ Jens Arnold
+
+ progressive.wps
+
+
+
+ cabbiev2
+ Johannes Voggenthaler, Apoo Maha, Marc Guay, Alex Vanderpol, Jerry Lange, Keith Perri, Mark Fawcus, and Marianne Arnold with support from Rockbox developers and forums. Based on Cabbie by Yohann Misquitta.
+ 35-Adobe-Helvetica.fnt
+ 27-Adobe-Helvetica.fnt
+ 15-Adobe-Helvetica.fnt
+ 16-Adobe-Helvetica.fnt
+ 15-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 12-Adobe-Helvetica.fnt
+ 11-Sazanami-Mincho.fnt
+ 08-Rockfont.fnt
+ 08-Rockfont.fnt
+
+ 08-Rockfont.fnt
+ 12-Adobe-Helvetica.fnt
+
+ CCCCCC
+ 000000
+ fde89e
+ b58c00
+ 000000
+
+
+ backdrops/cabbiev2.480x800x16.bmp
+ backdrops/cabbiev2.320x480x16.bmp
+ backdrops/cabbiev2.320x240x16.bmp
+ backdrops/cabbiev2.128x128x16.bmp
+ backdrops/cabbiev2.128x160x16.bmp
+ backdrops/cabbiev2.132x80x16.bmp
+ backdrops/cabbiev2.138x110x2.bmp
+ backdrops/cabbiev2.160x128x16.bmp
+ backdrops/cabbiev2.160x128x2.bmp
+ backdrops/cabbiev2.176x132x16.bmp
+ backdrops/cabbiev2.176x220x16.bmp
+ backdrops/cabbiev2.220x176x16.bmp
+ backdrops/cabbiev2.240x320x16.bmp
+ backdrops/cabbiev2.240x400x16.bmp
+
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (gradient)
+ bar (inverse)
+ bar (inverse)
+
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+ icons/tango_small_mono.bmp
+ icons/tango_small.bmp
+ icons/tango_small_mono.bmp
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+ icons/tango_small.bmp
+
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers_mono.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers_mono.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+ icons/tango_small_viewers.bmp
+
+ top
+ top
+
+
+
+ cabbiev2.wps
+ cabbiev2.rwps
+
+
diff --git a/wps/wpsbuild2.pl b/wps/wpsbuild2.pl
new file mode 100755
index 0000000..dd0588f
--- /dev/null
+++ b/wps/wpsbuild2.pl
@@ -0,0 +1,716 @@
+#!/usr/bin/perl
+#
+# __________ __ ___.
+# Open \______ \ ____ ____ | | _\_ |__ _______ ___
+# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+# \/ \/ \/ \/ \/
+# $Id$
+#
+# Copyright (C) 2011 Marcin Bukat
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+
+use strict;
+use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
+use File::Basename;
+use XML::Simple qw(:strict);
+
+# boolean constants
+use constant TRUE => 1;
+use constant FALSE => 0;
+
+# global variables
+my $ROOT = "..";
+my $verbose = FALSE;
+my $rbdir = ".rockbox";
+my $tempdir = ".rockbox";
+my $wpslist;
+my $modelname;
+
+# Get options
+GetOptions ( 'r|root=s' => \$ROOT,
+ 'm|modelname=s' => \$modelname,
+ 'v|verbose' => \$verbose,
+ 'rbdir=s' => \$rbdir, # If we want to put in a different directory
+ 'tempdir=s' => \$tempdir, # override .rockbox temporary dir
+ );
+
+my ($wpslist, @foo) = @ARGV;
+
+# list of the valid lcd depth
+my @depthlist = ( 16, 8, 4, 2, 1 );
+
+# list of the valid skin files
+my @skintags = ('wps','sbs','fms','rwps','rsbs','rfms');
+
+# LCD sizes
+my ($main_height, $main_width, $main_depth);
+my ($remote_height, $remote_width, $remote_depth);
+my $has_remote;
+
+
+if(!$wpslist) {
+ print "Usage: wpsbuild2.pl [options] WPSLIST.xml\n",
+ "-r|--root Root dir of the rockbox sources (.. if ommited)\n",
+ "-m|--modelname Target name *MANDATORY* (e.g mpiohd300)\n",
+ "--rbdir Base dir used in config (.rockbox if ommited)\n",
+ "--tempdir Temporary output dir (.rockbox if ommited)\n",
+ "-v|--verbose Verbose output\n",
+ "\n",
+ "Run this script in the root of the target build, and it will put all the\n",
+ "stuff in tempdir/wps/ and build the cfg according to rbdir\n";
+ exit;
+}
+
+# this function returns LCD dimensions and depth
+# for modelname target
+# params:
+# 1) main = false; remote = true;
+sub getlcdsizes
+{
+ my $remote = $_[0];
+ my @sizes;
+
+ open (CONFIG, "$ROOT/firmware/export/config/$modelname" . ".h");
+ while()
+ {
+ if ($remote)
+ {
+ if ($_ =~ /^\s*#define\s+LCD_REMOTE_HEIGHT\s+([0-9]+)\s*.*$/)
+ {
+ $sizes[0] = $1;
+ }
+ elsif ($_ =~ /^\s*#define\s+LCD_REMOTE_WIDTH\s+([0-9]+)\s*.*$/)
+ {
+ $sizes[1] = $1;
+ }
+
+ elsif ($_ =~ /^\s*#define\s+LCD_REMOTE_DEPTH\s+([0-9]+)\s*.*$/)
+ {
+ $sizes[2] = $1;
+ }
+ }
+ else
+ {
+ if ($_ =~ /^\s*#define\s+LCD_HEIGHT\s+([0-9]+)\s*.*$/)
+ {
+ $sizes[0] = $1;
+ }
+ elsif ($_ =~ /^\s*#define\s*LCD_WIDTH\s+([0-9]+)\s*.*$/)
+ {
+ $sizes[1] = $1;
+ }
+ elsif ($_ =~ /^\s*#define\s+LCD_DEPTH\s+([0-9]+)\s*.*$/)
+ {
+ $sizes[2] = $1;
+ }
+ }
+ }
+ close(CONFIG);
+
+ return @sizes;
+}
+
+# helper function which checks if passed key exists and
+# is not empty in theme parse tree
+# params:
+# 1) reference to parse tree node
+# 2) tag name to check
+sub tag_empty
+{
+ my ($ref, $tag) = @_;
+
+ # check if such element is present
+ if (exists $$ref->{$tag})
+ {
+ # check if referenced element is ARRAY
+ if (ref($$ref->{$tag}) ne 'ARRAY' && $$ref->{$tag} eq '')
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+# this helper function takes WIDTHxHEIGHTxDEPTH as its argument and reference
+# to parse tree object
+# then it returns value of the object corresponding to the desired
+# resolution and depth
+sub filter_resolution_depth
+{
+ # get parameters
+ my ($resolution_depth, $tag_ref) = @_;
+ my $element;
+
+ # check if referenced element is an array
+ if (ref($$tag_ref) eq 'ARRAY')
+ {
+ # loop though all array elements
+ foreach $element (@{$$tag_ref})
+ {
+ # check if element is a hash
+ # (it has screen constraints set)
+ if (ref($element) eq 'HASH')
+ {
+ # compare with given resolution
+ if (exists $element->{screen})
+ {
+ if ($element->{screen} eq $resolution_depth)
+ {
+ return $element->{content};
+ }
+ }
+ }
+ else
+ {
+ return $element;
+ }
+ }
+ }
+ else # single element
+ {
+ # check if this is hash (aka element specifies resolution)
+ if (ref($$tag_ref) eq 'HASH')
+ {
+ $element = $$tag_ref;
+ if (exists $element->{screen})
+ {
+ if ($element->{screen} eq $resolution_depth)
+ {
+ return $element->{content};
+ }
+ }
+ }
+ else
+ {
+ # no resolution constraints - return the content of tag
+ return $$tag_ref;
+ }
+ }
+}
+
+# helper function which returns the list of graphic files
+# used in skin file passed as argument
+sub scan_skin_graphics
+{
+ my $path = $_[0];
+ my @filelist;
+ open(SKINFILE, "$path");
+ while ()
+ {
+ push @filelist, $1 if (/[\(,]([^,]*?.bmp)[\),]/);
+ }
+ close(SKINFILE);
+
+ return @filelist;
+}
+
+# copies suitable wps/rwps/sbs/rsbs/fms/rfms
+# params:
+# 1) main screen WIDTHxHEIGHTxDEPTH
+# 2) remote screen WIDTHxHEIGHTxDEPTH
+# 3) reference (aka pointer) to theme parse tree
+sub copy_skin_files
+{
+ my ($main_screen, $remote_screen, $theme_ref) = @_;
+ my $file;
+ my $tag;
+ my $dir;
+ my @g_filelist;
+ my $screen;
+ my $ret = FALSE;
+
+ # we assume that we copy the WPS files from the same dir the WPSLIST
+ # file is located in
+
+ # split full path into path and filename itself
+ my ($filename, $dir) = fileparse($wpslist);
+
+ # loop through all skins sections
+ foreach $tag (@skintags)
+ {
+ #destinguish between remote and main tags
+ if ($tag =~ /^r.*/)
+ {
+ $screen = $remote_screen;
+ }
+ else
+ {
+ $screen = $main_screen;
+ }
+
+ if (exists $$theme_ref->{$tag})
+ {
+ # split filename into base and extension
+ my ($name, $ext) = split(/\./, $$theme_ref->{$tag});
+
+ # check for someskinfile.txt.wps
+ $file = $name . ".txt" . "." . $ext;
+ if (!-e "$dir/$file")
+ {
+ # check for generic someskinfile.wps
+ $file = $$theme_ref->{$tag};
+ if (!-e "$dir/$file")
+ {
+ # check for the model specific one
+ $file = $name . "." . $screen . "." . $modelname . "." . $ext;
+ if (!-e "$dir/$file")
+ {
+ # resolution depth specific
+ $file = $name . "." . $screen . "." . $ext;
+ }
+ }
+ }
+
+ if (-e "$dir/$file")
+ {
+ # copy skin file if present
+ system("install -D $dir/$file $tempdir/wps/$name.$ext");
+
+ if ($verbose)
+ {
+ print "install -D $dir/$file $tempdir/wps/$name.$ext\n";
+ }
+
+ $ret = TRUE;
+
+ # scan skin file for graphics
+ @g_filelist = &scan_skin_graphics("$dir" . "$file");
+
+ if ($#g_filelist >= 0)
+ {
+ if (-e "$dir/$name/$screen")
+ {
+ foreach $file (@g_filelist)
+ {
+ system("install -D $dir/$name/$screen/$file $tempdir/wps/$name/$file");
+
+ if ($verbose)
+ {
+ print "install -D $dir/$name/$screen/$file $tempdir/wps/$name/$file\n";
+ }
+ }
+ }
+ elsif (-e "$dir/$name")
+ {
+ foreach $file (@g_filelist)
+ {
+ system("install -D $dir/$name/$file $tempdir/wps/$name/$file");
+
+ if ($verbose)
+ {
+ print "install -D $dir/$name/$file $tempdir/wps/$name/$file\n";
+ }
+ }
+ }
+ else
+ {
+ print STDERR "beep, no dir to copy graphics from!\n";
+ }
+ }
+ }
+ }
+ }
+# give the hint if this function pass copied some files or not
+return $ret;
+}
+
+# copy backdrop
+# params:
+# 1) main screen WIDTHxHEIGHTxDEPTH (remote seems to be not handled at all)
+# 2) reference (aka pointer) to theme parse tree
+sub copy_backdrop
+{
+ my ($screen, $theme_ref) = @_;
+ if (exists $$theme_ref->{backdrop})
+ {
+ my $backdrop = &filter_resolution_depth($screen, \$$theme_ref->{backdrop});
+ if ($backdrop ne '')
+ {
+ # clip resolution from filename
+ my $dst = $backdrop;
+ $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
+ system("install -D $ROOT/$backdrop $tempdir/$dst");
+
+ if ($verbose)
+ {
+ print("install -D $ROOT/$backdrop $tempdir/$dst\n");
+ }
+ }
+ }
+}
+
+# copy font, remote font
+# params:
+# 1) main screen WIDTHxHEIGHTxDEPTH
+# 2) remote screen WIDTHxHEIGHTxDEPTH
+# 3) reference (aka pointer) to theme parse tree
+sub copy_fonts
+{
+ my ($screen, $remote_screen, $theme_ref) = @_;
+ my $tag;
+ my $font;
+
+ foreach $tag ('font', 'remote_font')
+ {
+ if (exists $$theme_ref->{$tag})
+ {
+ if ($tag eq 'font')
+ {
+ $font = &filter_resolution_depth($screen, \$$theme_ref->{$tag});
+ }
+ else
+ {
+ $font = &filter_resolution_depth($remote_screen, \$$theme_ref->{$tag});
+ }
+
+ if ($font ne '')
+ {
+ my $src = $font;
+ $src =~ s/\.fnt/\.bdf/;
+
+ mkdir "$tempdir/fonts";
+ system("$ROOT/tools/convbdf -f -o \"$tempdir/fonts/$font\" \"$ROOT/fonts/$src\" ");
+
+ if ($verbose)
+ {
+ print "mkdir $tempdir/fonts\n";
+ print "$ROOT/tools/convbdf -f -o \"$tempdir/fonts/$font\" \"$ROOT/fonts/$src\" \n";
+ }
+ }
+ }
+ }
+}
+
+# copy icons, viewers icons and its remote variants
+# params:
+# 1) main screen WIDTHxHEIGHTxDEPTH
+# 2) remote screen WIDTHxHEIGHTxDEPTH
+# 3) reference (aka pointer) to theme parse tree
+sub copy_icons
+{
+ my ($screen, $remote_screen, $theme_ref) = @_;
+ my $tag;
+ my $icons;
+
+ foreach $tag ('iconset', 'remote_iconset',
+ 'viewers_iconset', 'remote_viewers_iconset')
+ {
+ if (exists $$theme_ref->{$tag})
+ {
+ if ($tag =~ m/^remote.*/)
+ {
+ $icons = &filter_resolution_depth($remote_screen, \$$theme_ref->{$tag});
+ }
+ else
+ {
+ $icons = &filter_resolution_depth($screen, \$$theme_ref->{$tag});
+ }
+
+ if ($icons ne '')
+ {
+ my $dst = $tempdir . "/" . $icons;
+ $dst =~ /\/.*icons\/(.*)/i;
+ system("install -D $ROOT/$icons $dst");
+
+ if ($verbose)
+ {
+ print "install -D $ROOT/$icons $dst\n";
+ }
+ }
+ }
+ }
+}
+
+# Builds theme config file
+# params:
+# 1) main screen WIDTHxHEIGHTxDEPTH
+# 2) remote screen WIDTHxHEIGHTxDEPTH (xx if missing)
+# 3) reference (aka pointer) to theme parse tree
+sub build_config
+{
+ my ($screen, $remote_screen, $theme_ref) = @_;
+ my @out;
+ my $tag;
+ my $resource;
+ my $element;
+ my $cfg_element;
+ my $cfg = $$theme_ref->{name} . ".cfg";
+
+ # config header
+ push @out, "#\n";
+ push @out, "# $cfg generated by wpsbuild2.pl\n";
+ push @out, "# " . $$theme_ref->{name} . " is made by " . $$theme_ref->{author} . "\n";
+ push @out, "#\n";
+
+ foreach $element ('wps','sbs','fms')
+ {
+ # wps, sbs, fms config
+ if (!tag_empty($theme_ref, $element))
+ {
+ push @out, "$element: $rbdir/wps/$$theme_ref->{$element}\n";
+ }
+ else
+ {
+ push @out, "$element: -\n";
+ }
+ }
+
+ foreach $element ('rwps','rsbs','rfms')
+ {
+ # rwps, rsbs, rfms config
+ if (!tag_empty($theme_ref, $element) && $has_remote)
+ {
+ push @out, "$element: $rbdir/wps/$$theme_ref->{$element}\n";
+ }
+ else
+ {
+ push @out, "$element: -\n";
+ }
+ }
+
+ # font config
+ if (!tag_empty($theme_ref, 'font'))
+ {
+ $resource = filter_resolution_depth($screen, \$$theme_ref->{font});
+ if ($resource eq '')
+ {
+ push @out, "font: -\n";
+ }
+ else
+ {
+ push @out, "font: $rbdir/fonts/$resource\n";
+ }
+ }
+
+ # remote font config
+ if (!tag_empty($theme_ref, 'remote_font') && $has_remote)
+ {
+ $resource = filter_resolution_depth($remote_screen, \$$theme_ref->{remote_font});
+ if ($resource eq '')
+ {
+ push @out, "remote font: -\n";
+ }
+ else
+ {
+ push @out, "remote font: $rbdir/fonts/$resource\n";
+ }
+ }
+
+ # foreground, background color
+ foreach $element ('foreground_color','background_color')
+ {
+ if (!tag_empty($theme_ref, $element) && $main_depth > 2)
+ {
+ $cfg_element = $element;
+ $cfg_element =~ s/_/\ /g;
+ push @out, "$cfg_element: $$theme_ref->{$element}\n";
+ }
+ }
+
+ # statusbar
+ if (!tag_empty($theme_ref, 'statusbar'))
+ {
+ push @out, "statusbar: $$theme_ref->{statusbar}\n";
+ }
+
+ # remote statusbar
+ if (!tag_empty($theme_ref, 'remote_statusbar') && $has_remote)
+ {
+ push @out, "remote statusbar: $$theme_ref->{remote_statusbar}\n";
+ }
+
+ # backdrop
+ if (!tag_empty($theme_ref,'backdrop'))
+ {
+ $resource = filter_resolution_depth($screen, \$$theme_ref->{backdrop});
+ if ($resource eq '')
+ {
+ push @out, "backdrop: -\n";
+ }
+ else
+ {
+ # clip resolution from filename
+ $resource =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
+ push @out, "backdrop: $rbdir/$resource\n";
+ }
+ }
+
+ # line selector start color
+ # line selector end color
+ # line selector text color
+ foreach $element ('line_selector_start_color',
+ 'line_selector_end_color',
+ 'line_selector_text_color')
+ {
+ if (!tag_empty($theme_ref, $element) && $main_depth > 2)
+ {
+ $cfg_element = $element;
+ $cfg_element =~ s/_/\ /g;
+ push @out, "$cfg_element: $$theme_ref->{$element}\n";
+ }
+ }
+
+ # selector type
+ if (!tag_empty($theme_ref, 'selector'))
+ {
+ $resource = filter_resolution_depth($screen, \$$theme_ref->{selector});
+ if ($resource ne '')
+ {
+ push @out, "selector type: $resource\n";
+ }
+ }
+
+ # iconset, viewers iconset
+ foreach $element ('iconset', 'viewers_iconset')
+ {
+ # iconset, viewers iconset
+ if (!tag_empty($theme_ref, $element))
+ {
+ $resource = filter_resolution_depth($screen, \$$theme_ref->{$element});
+ $cfg_element = $element;
+ $cfg_element =~ s/_/\ /g;
+ if ($resource eq '')
+ {
+ push @out, "$cfg_element: -\n";
+ }
+ else
+ {
+ push @out, "$cfg_element: $rbdir/$resource\n";
+ }
+ }
+ }
+
+ # remote iconset, remote viewers iconset
+ foreach $element ('remote_iconset', 'remote_viewers_iconset')
+ {
+ if (!tag_empty($theme_ref, $element) && $has_remote)
+ {
+ $resource = filter_resolution_depth($remote_screen, \$$theme_ref->{$element});
+ $cfg_element = $element;
+ $cfg_element =~ s/_/\ /g;
+ if ($resource eq '')
+ {
+ push @out, "$cfg_element: -\n";
+ }
+ else
+ {
+ push @out, "$cfg_element: $rbdir/$resource\n";
+ }
+ }
+ }
+
+ # filetype colours
+ if (!tag_empty($theme_ref, 'filetype_colours') && $main_depth > 2)
+ {
+ push @out, "filetype colours: $$theme_ref->{filetype_colours}\n";
+ }
+
+ # ui viewport
+ if (!tag_empty($theme_ref, 'ui_viewport'))
+ {
+ push @out, "ui viewport: $$theme_ref->{ui_viewport}\n";
+ }
+ else
+ {
+ push @out, "ui viewport: -\n";
+ }
+
+ # remote ui vieport
+ if (!tag_empty($theme_ref, 'remote_ui_viewport') && $has_remote)
+ {
+
+ push @out, "remote ui viewport: $$theme_ref->{remote_ui_viewport}\n";
+ }
+ else
+ {
+ push @out, "remote ui viewport: -\n";
+ }
+
+ # dump config to file
+ if(-f "$tempdir/wps/$cfg")
+ {
+ print STDERR "wpsbuild warning: wps/$cfg already exists!\n";
+ }
+ else
+ {
+ open(CFG, ">$tempdir/themes/$cfg");
+ print CFG @out;
+ close(CFG);
+ }
+}
+
+# Get the LCD sizes first
+($main_height, $main_width, $main_depth) = getlcdsizes(FALSE);
+($remote_height, $remote_width, $remote_depth) = getlcdsizes(TRUE);
+
+#print "LCD: ${main_width}x${main_height}x${main_depth}\n";
+if ($remote_height && $remote_width && $remote_depth)
+{
+ $has_remote = TRUE;
+}
+
+# prefix $rbdir with / if needed (needed for the theme.cfg)
+unless ($rbdir =~ m/^\/.*/)
+{
+ $rbdir = "/" . $rbdir;
+}
+
+my $main_screen = $main_width . "x" . $main_height . "x" . $main_depth;
+my $remote_screen = $remote_width . "x" . $remote_height . "x" . $remote_depth;
+my $xml = new XML::Simple (KeyAttr=>[], ForceArray=>0, SuppressEmpty=>1);
+
+ # parse input file
+my $data = $xml->XMLin("$wpslist");
+my $theme;
+my $depth;
+
+# process all themes found in input file
+foreach $theme (@{$data->{theme}})
+{
+ foreach $depth (@depthlist)
+ {
+ # consider only valid depths
+ $main_screen = $remote_screen = 'xx';
+ if ($main_depth >= $depth)
+ {
+ $main_screen = $main_width . "x" . $main_height . "x" . $depth;
+ }
+
+ if ($remote_depth >= $depth)
+ {
+ $remote_screen = $remote_width . "x" . $remote_height . "x" . $depth;
+ }
+
+ # process the skin with the highes depth satisfying all constraints
+ if (copy_skin_files($main_screen, $remote_screen, \$theme))
+ {
+ # copy backdrop
+ copy_backdrop($main_screen, \$theme);
+
+ # copy fonts
+ copy_fonts($main_screen, $remote_screen, \$theme);
+
+ # copy icons (iconset and viewers icons)
+ copy_icons($main_screen, $remote_screen, \$theme);
+
+ # build .cfg file finally
+ build_config($main_screen, $remote_screen, \$theme);
+ last;
+ }
+ }
+}