diff options
Diffstat (limited to 'wps/wpsbuild.pl')
-rwxr-xr-x | wps/wpsbuild.pl | 724 |
1 files changed, 345 insertions, 379 deletions
diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl index e516c3d444..873331318a 100755 --- a/wps/wpsbuild.pl +++ b/wps/wpsbuild.pl | |||
@@ -12,6 +12,7 @@ use strict; | |||
12 | use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF | 12 | use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF |
13 | 13 | ||
14 | my $ROOT=".."; | 14 | my $ROOT=".."; |
15 | my $wpsdir; | ||
15 | my $verbose; | 16 | my $verbose; |
16 | my $rbdir=".rockbox"; | 17 | my $rbdir=".rockbox"; |
17 | my $tempdir=".rockbox"; | 18 | my $tempdir=".rockbox"; |
@@ -31,21 +32,22 @@ GetOptions ( 'r|root=s' => \$ROOT, | |||
31 | 32 | ||
32 | my $firmdir="$ROOT/firmware"; | 33 | my $firmdir="$ROOT/firmware"; |
33 | my $cppdef = $target; | 34 | my $cppdef = $target; |
34 | my @depthlist = ( 16, 8, 4, 2, 1 ); | ||
35 | 35 | ||
36 | # These parameters are filled in as we parse wpslist | 36 | # These parameters are filled in as we parse wpslist |
37 | my $req_size; | ||
38 | my $req_g_wps; | ||
39 | my $req_t; | 37 | my $req_t; |
40 | my $req_t_wps; | 38 | my $theme; |
39 | my $has_wps; | ||
41 | my $wps; | 40 | my $wps; |
42 | my $wps_prefix; | 41 | my $has_rwps; |
43 | my $sbs_prefix; | ||
44 | my $rwps; | 42 | my $rwps; |
43 | my $has_sbs; | ||
45 | my $sbs; | 44 | my $sbs; |
46 | my $sbs_w_size; | 45 | my $has_rsbs; |
47 | my $rsbs; | 46 | my $rsbs; |
48 | my $rsbs_w_size; | 47 | my $has_fms; |
48 | my $fms; | ||
49 | my $has_rfms; | ||
50 | my $rfms; | ||
49 | my $width; | 51 | my $width; |
50 | my $height; | 52 | my $height; |
51 | my $font; | 53 | my $font; |
@@ -53,13 +55,16 @@ my $remotefont; | |||
53 | my $fgcolor; | 55 | my $fgcolor; |
54 | my $bgcolor; | 56 | my $bgcolor; |
55 | my $statusbar; | 57 | my $statusbar; |
58 | my $remotestatusbar; | ||
56 | my $author; | 59 | my $author; |
57 | my $backdrop; | 60 | my $backdrop; |
58 | my $lineselectstart; | 61 | my $lineselectstart; |
59 | my $lineselectend; | 62 | my $lineselectend; |
60 | my $selecttype; | 63 | my $selecttype; |
61 | my $iconset; | 64 | my $iconset; |
65 | my $remoteiconset; | ||
62 | my $viewericon; | 66 | my $viewericon; |
67 | my $remoteviewericon; | ||
63 | my $lineselecttextcolor; | 68 | my $lineselecttextcolor; |
64 | my $filetylecolor; | 69 | my $filetylecolor; |
65 | my $listviewport; | 70 | my $listviewport; |
@@ -135,28 +140,33 @@ STOP | |||
135 | 140 | ||
136 | sub mkdirs | 141 | sub mkdirs |
137 | { | 142 | { |
138 | my $wpsdir = $wps; | ||
139 | $wpsdir =~ s/\.(r|)wps//; | ||
140 | mkdir "$tempdir/wps", 0777; | 143 | mkdir "$tempdir/wps", 0777; |
141 | mkdir "$tempdir/themes", 0777; | 144 | mkdir "$tempdir/themes", 0777; |
145 | mkdir "$tempdir/icons", 0777; | ||
142 | 146 | ||
143 | if( -d "$tempdir/wps/$wpsdir") { | 147 | if( -d "$tempdir/wps/$theme") { |
144 | #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n"; | 148 | #print STDERR "wpsbuild warning: directory wps/$theme already exists!\n"; |
145 | } | 149 | } |
146 | else | 150 | else |
147 | { | 151 | { |
148 | mkdir "$tempdir/wps/$wpsdir", 0777; | 152 | mkdir "$tempdir/wps/$theme", 0777; |
149 | } | 153 | } |
150 | } | 154 | } |
151 | 155 | ||
156 | sub normalize | ||
157 | { | ||
158 | my $in = $_[0]; | ||
159 | # strip resolution | ||
160 | $in =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//; | ||
161 | return $in; | ||
162 | } | ||
163 | |||
152 | sub copybackdrop | 164 | sub copybackdrop |
153 | { | 165 | { |
154 | #copy the backdrop file into the build dir | 166 | #copy the backdrop file into the build dir |
155 | if ($backdrop ne '') { | 167 | if ($backdrop ne '') { |
156 | my $dst = $backdrop; | 168 | my $dst = normalize($backdrop); |
157 | $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//; | 169 | system("cp $ROOT/$backdrop $tempdir/$dst"); |
158 | my $cmd = "cp $ROOT/$backdrop $tempdir/$dst"; | ||
159 | `$cmd`; | ||
160 | } | 170 | } |
161 | } | 171 | } |
162 | 172 | ||
@@ -167,31 +177,30 @@ sub copythemefont | |||
167 | 177 | ||
168 | $o =~ s/\.fnt/\.bdf/; | 178 | $o =~ s/\.fnt/\.bdf/; |
169 | mkdir "$tempdir/fonts"; | 179 | mkdir "$tempdir/fonts"; |
170 | my $cmd ="$ROOT/tools/convbdf -f -o \"$tempdir/fonts/$_[0]\" \"$ROOT/fonts/$o\" "; | 180 | system("$ROOT/tools/convbdf -f -o \"$tempdir/fonts/$_[0]\" \"$ROOT/fonts/$o\" "); |
171 | `$cmd`; | ||
172 | } | 181 | } |
173 | 182 | ||
174 | sub copythemeicon | 183 | sub copythemeicon |
175 | { | 184 | { |
185 | my $i = $_[0]; | ||
176 | #copy the icon specified by the theme | 186 | #copy the icon specified by the theme |
177 | if ($iconset ne '') { | 187 | if ($i ne "-") { |
178 | my $tempicon = $tempdir . "/" . $iconset; | 188 | my $tempicon = $tempdir . "/" . $i; |
179 | $iconset = $rbdir . "/" . $iconset; | ||
180 | $tempicon =~ /\/.*icons\/(.*)/i; | 189 | $tempicon =~ /\/.*icons\/(.*)/i; |
181 | `cp $ROOT/icons/$1 $tempicon`; | 190 | system("cp $ROOT/icons/$1 $tempicon"); |
182 | } | 191 | } |
183 | } | 192 | } |
184 | 193 | ||
185 | sub copythemeviewericon | 194 | sub uniq { |
186 | { | 195 | my %seen = (); |
187 | #copy the viewer icon specified by the theme | 196 | my @r = (); |
188 | 197 | foreach my $a (@_) { | |
189 | if ($viewericon ne '') { | 198 | unless ($seen{$a}) { |
190 | my $tempviewericon = $tempdir . "/" . $viewericon; | 199 | push @r, $a; |
191 | $viewericon = $rbdir . "/" . $viewericon; | 200 | $seen{$a} = 1; |
192 | $tempviewericon =~ /\/.*icons\/(.*)/i; | 201 | } |
193 | `cp $ROOT/icons/$1 $tempviewericon`; | ||
194 | } | 202 | } |
203 | return @r; | ||
195 | } | 204 | } |
196 | 205 | ||
197 | sub copywps | 206 | sub copywps |
@@ -199,181 +208,104 @@ sub copywps | |||
199 | # we assume that we copy the WPS files from the same dir the WPSLIST | 208 | # we assume that we copy the WPS files from the same dir the WPSLIST |
200 | # file is located in | 209 | # file is located in |
201 | my $dir; | 210 | my $dir; |
211 | my %skinfiles = ("wps", $wps, | ||
212 | "sbs", $sbs, | ||
213 | "fms", $fms, | ||
214 | "rwps", $rwps, | ||
215 | "rsbs", $rsbs, | ||
216 | "rfms", $rfms); | ||
202 | my @filelist; | 217 | my @filelist; |
203 | my $file; | 218 | my $file; |
204 | my $__sb; | ||
205 | 219 | ||
206 | if($wpslist =~ /(.*)WPSLIST/) { | 220 | if($wpslist =~ /(.*)\/WPSLIST/) { |
207 | $dir = $1; | 221 | $dir = $1; |
208 | $__sb = $sbs_prefix . "." . $req_size . ".sbs"; | 222 | |
209 | #print "$req_t_wps $req_g_wps $sbs_prefix\n"; | 223 | # copy fully-fledged wps, sbs, etc. including graphics |
210 | #print "$dir/$__sb\n"; | 224 | foreach my $ext (keys %skinfiles) { |
211 | 225 | next unless ($skinfiles{$ext}); | |
212 | # system("cp $dir/$wps .rockbox/wps/"); | 226 | $file = $skinfiles{$ext}; |
213 | # check for <name>.WIDTHxHEIGHTxDEPTH.sbs | 227 | system("cp $dir/$file $tempdir/wps/$theme.$ext"); |
214 | if (-e "$dir/$__sb") { | 228 | open(SKIN, "$dir/$file"); |
215 | system("cp $dir/$__sb $tempdir/wps/$sbs"); | 229 | while (<SKIN>) { |
230 | $filelist[$#filelist + 1] = $1 if (/[\(,]([^,]*?.bmp)[\),]/); | ||
231 | } | ||
232 | close(SKIN); | ||
216 | } | 233 | } |
217 | # check for <name>.WIDTHxHEIGHTxDEPTH.<model>.sbs and overwrite the | 234 | |
218 | # previous sb if needed | 235 | if ($#filelist >= 0) { |
219 | $__sb = $sbs_prefix . "." . $req_size . "." . $modelname . ".sbs"; | 236 | if (-e "$dir/$theme") { |
220 | if (-e "$dir/$__sb") { | 237 | foreach $file (uniq(@filelist)) { |
221 | system("cp $dir/$__sb $tempdir/wps/$sbs"); | 238 | system("cp $dir/$theme/$file $tempdir/wps/$theme/"); |
239 | } | ||
240 | } | ||
241 | else { | ||
242 | print STDERR "beep, no dir to copy WPS from!\n"; | ||
243 | } | ||
222 | } | 244 | } |
223 | |||
224 | if (-e "$dir/$req_t_wps" ) { | ||
225 | system("cp $dir/$req_t_wps $tempdir/wps/$wps"); | ||
226 | |||
227 | } elsif (-e "$dir/$req_g_wps") { | ||
228 | system("cp $dir/$req_g_wps $tempdir/wps/$wps"); | ||
229 | |||
230 | open(WPSFILE, "$dir/$req_g_wps"); | ||
231 | while (<WPSFILE>) { | ||
232 | $filelist[$#filelist + 1] = $1 if (/[\(,]([^,]*?.bmp)[\),]/); | ||
233 | } | ||
234 | close(WPSFILE); | ||
235 | |||
236 | if ($#filelist >= 0) { | ||
237 | if (-e "$dir/$wps_prefix/$req_size") { | ||
238 | foreach $file (@filelist) { | ||
239 | system("cp $dir/$wps_prefix/$req_size/$file $tempdir/wps/$wps_prefix/"); | ||
240 | } | ||
241 | } | ||
242 | elsif (-e "$dir/$wps_prefix") { | ||
243 | foreach $file (@filelist) { | ||
244 | system("cp $dir/$wps_prefix/$file $tempdir/wps/$wps_prefix/"); | ||
245 | } | ||
246 | } | ||
247 | else { | ||
248 | print STDERR "beep, no dir to copy WPS from!\n"; | ||
249 | } | ||
250 | } | ||
251 | |||
252 | } else { | ||
253 | print STDERR "Skipping $wps - no matching resolution.\n"; | ||
254 | } | ||
255 | } else { | 245 | } else { |
256 | print STDERR "No source directory!\n"; | 246 | print STDERR "No source directory!\n"; |
257 | } | 247 | } |
258 | } | 248 | } |
259 | 249 | ||
260 | sub buildcfg { | 250 | sub buildcfg { |
261 | my $cfg = $wps; | 251 | my $cfg = $theme . ".cfg"; |
262 | my @out; | 252 | my @out; |
263 | |||
264 | $cfg =~ s/\.(r|)wps/.cfg/; | ||
265 | 253 | ||
266 | push @out, <<MOO | 254 | push @out, <<MOO |
267 | \# | 255 | \# |
268 | \# $cfg generated by wpsbuild.pl | 256 | \# $cfg generated by wpsbuild.pl |
269 | \# $wps is made by $author | 257 | \# $wps is made by $author |
270 | \# | 258 | \# |
271 | wps: $rbdir/wps/$wps | ||
272 | MOO | 259 | MOO |
273 | ; | 260 | ; |
274 | if(defined($sbs)) { | 261 | |
275 | if ($sbs eq '') { | 262 | my %skinfiles = ("wps" => $wps, |
276 | push @out, "sbs: -\n"; | 263 | "sbs" => $sbs, |
277 | } else { | 264 | "fms" => $fms, |
278 | push @out, "sbs: $rbdir/wps/$sbs\n"; | 265 | "rwps" => $rwps, |
279 | } | 266 | "rsbs" => $rsbs, |
280 | } | 267 | "rfms" => $rfms); |
281 | if(defined($rsbs) && $has_remote) { | 268 | for my $skin (keys %skinfiles) { |
282 | if ($rsbs eq '') { | 269 | my $val = $skinfiles{$skin}; |
283 | push @out, "rsbs: -\n"; | 270 | print "$skin: $val\n"; |
284 | } else { | 271 | if (!defined($val)) { |
285 | push @out, "rsbs: $rbdir/wps/$rsbs\n"; | 272 | # dont put value if not defined (e.g. rwps when there's no remote) |
286 | } | 273 | next; |
287 | } | 274 | } elsif ($val eq '') { |
288 | if($font) { | 275 | # empty resets to built-in |
289 | if ($font eq '') { | 276 | push @out, "$skin: -\n"; |
290 | push @out, "font: -\n"; | ||
291 | } else { | ||
292 | push @out, "font: $rbdir/fonts/$font\n"; | ||
293 | } | ||
294 | } | ||
295 | if(defined($remotefont) && $has_remote) { | ||
296 | if ($remotefont eq '') { | ||
297 | push @out, "remote font: -\n"; | ||
298 | } else { | ||
299 | push @out, "remote font: $rbdir/fonts/$remotefont\n"; | ||
300 | } | ||
301 | } | ||
302 | if($fgcolor && $main_depth > 2) { | ||
303 | push @out, "foreground color: $fgcolor\n"; | ||
304 | } | ||
305 | if($bgcolor && $main_depth > 2) { | ||
306 | push @out, "background color: $bgcolor\n"; | ||
307 | } | ||
308 | if($statusbar) { | ||
309 | if($rwps && $has_remote ) { | ||
310 | push @out, "remote statusbar: $statusbar\n"; | ||
311 | } | ||
312 | push @out, "statusbar: $statusbar\n"; | ||
313 | } | ||
314 | if(defined($backdrop)) { | ||
315 | if ($backdrop eq '') { | ||
316 | push @out, "backdrop: -\n"; | ||
317 | } else { | ||
318 | # clip resolution from filename | ||
319 | $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//; | ||
320 | push @out, "backdrop: $rbdir/$backdrop\n"; | ||
321 | } | ||
322 | } | ||
323 | if($lineselectstart && $main_depth > 2) { | ||
324 | push @out, "line selector start color: $lineselectstart\n"; | ||
325 | } | ||
326 | if($lineselectend && $main_depth > 2) { | ||
327 | push @out, "line selector end color: $lineselectend\n"; | ||
328 | } | ||
329 | if($selecttype) { | ||
330 | push @out, "selector type: $selecttype\n"; | ||
331 | } | ||
332 | if(defined($iconset)) { | ||
333 | if ($iconset eq '') { | ||
334 | push @out, "iconset: -\n"; | ||
335 | } else { | ||
336 | push @out, "iconset: $iconset\n"; | ||
337 | } | ||
338 | } | ||
339 | if(defined($viewericon)) { | ||
340 | if ($viewericon eq '') { | ||
341 | push @out, "viewers iconset: -\n"; | ||
342 | } else { | ||
343 | push @out, "viewers iconset: $viewericon\n"; | ||
344 | } | ||
345 | } | ||
346 | if($lineselecttextcolor && $main_depth > 2 ) { | ||
347 | push @out, "line selector text color: $lineselecttextcolor\n"; | ||
348 | } | ||
349 | if($filetylecolor && $main_depth > 2) { | ||
350 | if ($filetylecolor eq '') { | ||
351 | push @out, "filetype colours: -\n"; | ||
352 | } else { | ||
353 | push @out, "filetype colours: $filetylecolor\n"; | ||
354 | } | ||
355 | } | ||
356 | if($rwps && $has_remote ) { | ||
357 | if ($rwps eq '') { | ||
358 | push @out, "rwps: -\n"; | ||
359 | } else { | 277 | } else { |
360 | push @out, "rwps: $rbdir/wps/$rwps\n"; | 278 | # file name is always <theme>.{wps,rwps,...} (see copywps()) |
279 | push @out, "$skin: $rbdir/wps/$theme.$skin\n"; | ||
361 | } | 280 | } |
362 | } | 281 | } |
363 | if(defined($listviewport)) { | 282 | |
364 | if ($listviewport eq '') { | 283 | push @out, "selector type: $selecttype\n" if (defined($selecttype)); |
365 | push @out, "ui viewport: -\n"; | 284 | push @out, "backdrop: $backdrop\n" if (defined($backdrop)); |
366 | } else { | 285 | push @out, "filetype colours: $filetylecolor\n" if (defined($filetylecolor)); |
367 | push @out, "ui viewport: $listviewport\n"; | 286 | |
368 | } | 287 | if ($main_depth > 2) { |
288 | push @out, "foreground color: $fgcolor\n" if($fgcolor); | ||
289 | push @out, "background color: $bgcolor\n" if($bgcolor); | ||
290 | push @out, "line selector start color: $lineselectstart\n" if($lineselectstart); | ||
291 | push @out, "line selector end color: $lineselectend\n" if($lineselectend);; | ||
292 | push @out, "line selector text color: $lineselecttextcolor\n" if($lineselecttextcolor); | ||
369 | } | 293 | } |
370 | if(defined($remotelistviewport) && $has_remote) { | 294 | |
371 | if ($remotelistviewport eq '') { | 295 | push @out, "font: $font\n" if (defined($font)); |
372 | push @out, "remote ui viewport: -\n"; | 296 | push @out, "statusbar: $statusbar\n" if (defined($statusbar)); |
373 | } else { | 297 | push @out, "iconset: $iconset\n" if (defined($iconset)); |
374 | push @out, "remote ui viewport: $listviewport\n"; | 298 | push @out, "viewers iconset: $viewericon\n" if (defined($viewericon)); |
375 | } | 299 | push @out, "ui viewport: $listviewport\n" if (defined($listviewport)); |
300 | |||
301 | if ($has_remote) { | ||
302 | push @out, "remote font: $remotefont\n" if (defined($remotefont)); | ||
303 | push @out, "remote statusbar: $remotestatusbar\n" if (defined($remotestatusbar)); | ||
304 | push @out, "remote iconset: $remoteiconset\n" if (defined($remoteiconset)); | ||
305 | push @out, "remote viewers iconset: $remoteviewericon\n" if (defined($remoteviewericon)); | ||
306 | push @out, "remote ui viewport: $remotelistviewport\n" if (defined($remotelistviewport)); | ||
376 | } | 307 | } |
308 | |||
377 | if(-f "$tempdir/wps/$cfg") { | 309 | if(-f "$tempdir/wps/$cfg") { |
378 | print STDERR "wpsbuild warning: wps/$cfg already exists!\n"; | 310 | print STDERR "wpsbuild warning: wps/$cfg already exists!\n"; |
379 | } | 311 | } |
@@ -391,8 +323,47 @@ MOO | |||
391 | #print "LCD: ${main_width}x${main_height}x${main_depth}\n"; | 323 | #print "LCD: ${main_width}x${main_height}x${main_depth}\n"; |
392 | $has_remote = 1 if ($remote_height && $remote_width && $remote_depth); | 324 | $has_remote = 1 if ($remote_height && $remote_width && $remote_depth); |
393 | 325 | ||
394 | my $isrwps; | 326 | |
395 | my $within; | 327 | # check if line matches the setting string or if it contains a regex |
328 | # that contains the targets resolution | ||
329 | sub check_res { | ||
330 | my ($line, $string, $remote) = @_; | ||
331 | if ($line =~ /^${string}: *(.*)/i) { | ||
332 | return $1; | ||
333 | } | ||
334 | elsif($line =~ /^${string}.(.*): *(.*)/i) { | ||
335 | # $1 is a resolution regex, $2 the filename incl. resolution | ||
336 | my $fn = $2; | ||
337 | my $size_str = "${main_width}x${main_height}x${main_depth}"; | ||
338 | if ($remote) { | ||
339 | $size_str = "${remote_width}x${remote_height}x${remote_depth}"; | ||
340 | } | ||
341 | if ($size_str =~ /$1$/) { | ||
342 | return $fn; | ||
343 | } | ||
344 | } | ||
345 | return ""; | ||
346 | } | ||
347 | |||
348 | # check if <theme>.<model>.<ext> exists. If not, check if <theme>.<ext> exists | ||
349 | sub check_skinfile { | ||
350 | my $ext = $_[0]; | ||
351 | my $req_skin = $theme . "." . $modelname . ".$ext"; | ||
352 | if (-e "$wpsdir/$req_skin") { | ||
353 | return $req_skin; | ||
354 | } else { | ||
355 | $req_skin = $theme . ".$ext"; | ||
356 | if (-e "$wpsdir/$req_skin") { | ||
357 | return $req_skin; | ||
358 | } | ||
359 | } | ||
360 | return ''; | ||
361 | } | ||
362 | |||
363 | |||
364 | # Infer WPS (etc.) filename from the the if it wasnt given | ||
365 | $wpslist =~ /(.*)WPSLIST/; | ||
366 | $wpsdir = $1; | ||
396 | 367 | ||
397 | open(WPS, "<$wpslist"); | 368 | open(WPS, "<$wpslist"); |
398 | while(<WPS>) { | 369 | while(<WPS>) { |
@@ -410,15 +381,21 @@ while(<WPS>) { | |||
410 | $rbdir = "/" . $rbdir; | 381 | $rbdir = "/" . $rbdir; |
411 | } | 382 | } |
412 | 383 | ||
413 | if($l =~ /^ *<(r|)wps>/i) { | 384 | if($l =~ /^ *<theme>/i) { |
414 | $isrwps = $1; | ||
415 | $within = 1; | ||
416 | # undef is a unary operator (!) | 385 | # undef is a unary operator (!) |
386 | undef $theme; | ||
387 | undef $has_wps; | ||
388 | undef $has_rwps; | ||
389 | undef $has_sbs; | ||
390 | undef $has_rsbs; | ||
391 | undef $has_fms; | ||
392 | undef $has_rfms; | ||
417 | undef $wps; | 393 | undef $wps; |
418 | undef $wps_prefix; | ||
419 | undef $rwps; | 394 | undef $rwps; |
420 | undef $sbs; | 395 | undef $sbs; |
421 | undef $rsbs; | 396 | undef $rsbs; |
397 | undef $fms; | ||
398 | undef $rfms; | ||
422 | undef $width; | 399 | undef $width; |
423 | undef $height; | 400 | undef $height; |
424 | undef $font; | 401 | undef $font; |
@@ -426,224 +403,213 @@ while(<WPS>) { | |||
426 | undef $fgcolor; | 403 | undef $fgcolor; |
427 | undef $bgcolor; | 404 | undef $bgcolor; |
428 | undef $statusbar; | 405 | undef $statusbar; |
406 | undef $remotestatusbar; | ||
429 | undef $author; | 407 | undef $author; |
430 | undef $req_g_wps; | ||
431 | undef $req_t_wps; | ||
432 | undef $backdrop; | 408 | undef $backdrop; |
433 | undef $lineselectstart; | 409 | undef $lineselectstart; |
434 | undef $lineselectend; | 410 | undef $lineselectend; |
435 | undef $selecttype; | 411 | undef $selecttype; |
436 | undef $iconset; | 412 | undef $iconset; |
413 | undef $remoteiconset; | ||
437 | undef $viewericon; | 414 | undef $viewericon; |
415 | undef $remoteviewericon; | ||
438 | undef $lineselecttextcolor; | 416 | undef $lineselecttextcolor; |
439 | undef $filetylecolor; | 417 | undef $filetylecolor; |
440 | undef $listviewport; | 418 | undef $listviewport; |
441 | undef $remotelistviewport; | 419 | undef $remotelistviewport; |
442 | |||
443 | next; | ||
444 | } | 420 | } |
445 | if($within) { | 421 | elsif($l =~ /^Name: *(.*)/i) { |
446 | if($l =~ /^ *<\/${isrwps}wps>/i) { | 422 | $theme = $1; |
447 | # Get the required width and height | 423 | } |
448 | my ($rheight, $rwidth, $rdepth); | 424 | elsif($l =~ /^Authors: *(.*)/i) { |
449 | if($isrwps) { | 425 | $author = $1; |
450 | ($rheight, $rwidth, $rdepth) = | 426 | } |
451 | ($remote_height, $remote_width, $remote_depth); | 427 | elsif ($l =~ /^WPS: *(yes|no)/i) { |
428 | $has_wps = $1; | ||
429 | } | ||
430 | elsif ($l =~ /^RWPS: *(yes|no)/i) { | ||
431 | $has_rwps = $1; | ||
432 | } | ||
433 | elsif ($l =~ /^SBS: *(yes|no)/i) { | ||
434 | $has_sbs = $1; | ||
435 | } | ||
436 | elsif ($l =~ /^RSBS: *(yes|no)/i) { | ||
437 | $has_rsbs = $1; | ||
438 | } | ||
439 | elsif ($l =~ /^FMS: *(yes|no)/i) { | ||
440 | $has_fms = $1; | ||
441 | } | ||
442 | elsif ($l =~ /^RFMS: *(yes|no)/i) { | ||
443 | $has_rfms = $1; | ||
444 | } | ||
445 | elsif($l =~ /^ *<main>/i) { | ||
446 | # parse main unit settings | ||
447 | while(<WPS>) { | ||
448 | my $l = $_; | ||
449 | if ($l =~ /^ *<\/main>/i) { | ||
450 | last; | ||
452 | } | 451 | } |
453 | else { | 452 | elsif($_ = check_res($l, "wps")) { |
454 | ($rheight, $rwidth, $rdepth) = | 453 | $wps = $_; |
455 | ($main_height, $main_width, $main_depth); | ||
456 | } | 454 | } |
457 | 455 | elsif($_ = check_res($l, "sbs")) { | |
458 | if(!$rheight || !$rwidth) { | 456 | $sbs = $_; |
459 | #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n", | ||
460 | #$isrwps?"remote ":""; | ||
461 | $within = 0; | ||
462 | next; | ||
463 | } | 457 | } |
464 | $wpslist =~ /(.*)WPSLIST/; | 458 | elsif($_ = check_res($l, "fms")) { |
465 | my $wpsdir = $1; | 459 | $fms = $_; |
466 | # If this WPS installable on this platform, one of the following | ||
467 | # two files will be present | ||
468 | foreach my $d (@depthlist) { | ||
469 | next if ($d > $rdepth); | ||
470 | |||
471 | $req_size = $rwidth . "x" . $rheight . "x" . $d; | ||
472 | |||
473 | # check for model specific wps | ||
474 | $req_g_wps = $wps_prefix . "." . $req_size . "." . $modelname . ".wps"; | ||
475 | last if (-e "$wpsdir/$req_g_wps"); | ||
476 | |||
477 | # check for normal wps (with WIDTHxHEIGHTxDEPTH) | ||
478 | $req_g_wps = $wps_prefix . "." . $req_size . ".wps"; | ||
479 | last if (-e "$wpsdir/$req_g_wps"); | ||
480 | |||
481 | if ($isrwps) { | ||
482 | $req_size = $req_size . "." . $main_width . "x" . $main_height . "x" . "$main_depth"; | ||
483 | |||
484 | $req_g_wps = $wps_prefix . "." . $req_size . ".wps"; | ||
485 | last if (-e "$wpsdir/$req_g_wps"); | ||
486 | } | ||
487 | } | 460 | } |
488 | $req_t_wps = $wps_prefix . ".txt" . ".wps"; | 461 | elsif($_ = check_res($l, "Font")) { |
489 | 462 | $font = $_; | |
490 | #print "LCD: $wps wants $width x $height\n"; | ||
491 | #print "LCD: is $rwidth x $rheight\n"; | ||
492 | |||
493 | #print "gwps: $wpsdir/$req_g_wps" . "\n"; | ||
494 | if (-e "$wpsdir/$req_g_wps" || -e "$wpsdir/$req_t_wps" ) { | ||
495 | # | ||
496 | # The target model has an LCD that is suitable for this | ||
497 | # WPS | ||
498 | # | ||
499 | #print "Size requirement is fine!\n"; | ||
500 | mkdirs() if (-e "$wpsdir/$req_g_wps"); | ||
501 | # Do the copying before building the .cfg - buildcfg() | ||
502 | # mangles some filenames | ||
503 | if ($backdrop) { | ||
504 | copybackdrop(); | ||
505 | } | ||
506 | if ($iconset) { | ||
507 | copythemeicon(); | ||
508 | } | ||
509 | if ($viewericon) { | ||
510 | copythemeviewericon(); | ||
511 | } | ||
512 | if ($font) { | ||
513 | copythemefont($font); | ||
514 | } | ||
515 | if ($remotefont) { | ||
516 | copythemefont($remotefont); | ||
517 | } | ||
518 | if(!$isrwps) { | ||
519 | # We only make .cfg files for <wps> sections: | ||
520 | buildcfg(); | ||
521 | } | ||
522 | copywps(); | ||
523 | } | 463 | } |
524 | else { | 464 | elsif($_ = check_res($l, "Statusbar")) { |
525 | #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) "; | 465 | $statusbar = $_; |
526 | #print "Skip $wps due to size restraints\n"; | 466 | } |
467 | elsif($_ = check_res($l, "Backdrop")) { | ||
468 | $backdrop = $_; | ||
469 | } | ||
470 | elsif($l =~ /^Foreground Color: *(.*)/i) { | ||
471 | $fgcolor = $1; | ||
472 | } | ||
473 | elsif($l =~ /^Background Color: *(.*)/i) { | ||
474 | $bgcolor = $1; | ||
475 | } | ||
476 | elsif($l =~ /^line selector start color: *(.*)/i) { | ||
477 | $lineselectstart = $1; | ||
478 | } | ||
479 | elsif($l =~ /^line selector end color: *(.*)/i) { | ||
480 | $lineselectend = $1; | ||
481 | } | ||
482 | elsif($_ = check_res($l, "selector type")) { | ||
483 | $selecttype = $_; | ||
484 | } | ||
485 | elsif($_ = check_res($l, "iconset")) { | ||
486 | $iconset = $_; | ||
487 | } | ||
488 | elsif($_ = check_res($l, "viewers iconset")) { | ||
489 | $viewericon = $_; | ||
490 | } | ||
491 | elsif($l =~ /^line selector text color: *(.*)/i) { | ||
492 | $lineselecttextcolor = $1; | ||
493 | } | ||
494 | elsif($l =~ /^filetype colours: *(.*)/i) { | ||
495 | $filetylecolor = $1; | ||
496 | } | ||
497 | elsif($_ = check_res($l, "ui viewport")) { | ||
498 | $listviewport = $_; | ||
527 | } | 499 | } |
528 | $within = 0; | ||
529 | } | ||
530 | elsif($l =~ /^Name: *(.*)/i) { | ||
531 | # Note that in the case this is within <rwps>, $wps will contain the | ||
532 | # name of the rwps. Use $isrwps to figure out what type it is. | ||
533 | $wps = $wps_prefix = $1; | ||
534 | $wps_prefix =~ s/\.(r|)wps//; | ||
535 | #print $wps_prefix . "\n"; | ||
536 | } | ||
537 | elsif($l =~ /^RWPS: *(.*)/i) { | ||
538 | $rwps = $1; | ||
539 | } | ||
540 | elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
541 | $rwps = $1; | ||
542 | } | ||
543 | elsif($l =~ /^SBS: *(.*)/i) { | ||
544 | $sbs = $sbs_prefix = $1; | ||
545 | $sbs_prefix =~ s/\.(r|)sbs//; | ||
546 | } | ||
547 | elsif($l =~ /^SBS\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
548 | $sbs = $sbs_prefix = $1; | ||
549 | $sbs_prefix =~ s/\.(r|)sbs//; | ||
550 | } | ||
551 | elsif($l =~ /^RSBS: *(.*)/i) { | ||
552 | $rsbs = $1; | ||
553 | } | ||
554 | elsif($l =~ /^RSBS\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
555 | $rsbs = $1; | ||
556 | } | ||
557 | elsif($l =~ /^Author: *(.*)/i) { | ||
558 | $author = $1; | ||
559 | } | ||
560 | elsif($l =~ /^Width: *(.*)/i) { | ||
561 | $width = $1; | ||
562 | } | ||
563 | elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
564 | $width = $1; | ||
565 | } | ||
566 | elsif($l =~ /^Height: *(.*)/i) { | ||
567 | $height = $1; | ||
568 | } | ||
569 | elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
570 | $height = $1; | ||
571 | } | ||
572 | elsif($l =~ /^Font: *(.*)/i) { | ||
573 | $font = $1; | ||
574 | } | ||
575 | elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
576 | $font = $1; | ||
577 | } | ||
578 | elsif($l =~ /^Remote Font\.${remote_width}x${remote_height}x$remote_depth: *(.*)/i) { | ||
579 | $remotefont = $1; | ||
580 | } | ||
581 | elsif($l =~ /^Remote Font: *(.*)/i) { | ||
582 | $remotefont = $1; | ||
583 | } | ||
584 | elsif($l =~ /^Foreground Color: *(.*)/i) { | ||
585 | $fgcolor = $1; | ||
586 | } | ||
587 | elsif($l =~ /^Background Color: *(.*)/i) { | ||
588 | $bgcolor = $1; | ||
589 | } | ||
590 | elsif($l =~ /^Statusbar: *(.*)/i) { | ||
591 | $statusbar = $1; | ||
592 | } | ||
593 | elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
594 | $statusbar = $1; | ||
595 | } | ||
596 | elsif($l =~ /^Backdrop: *(.*)/i) { | ||
597 | $backdrop = $1; | ||
598 | } | ||
599 | elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
600 | $backdrop = $1; | ||
601 | } | ||
602 | elsif($l =~ /^line selector start color: *(.*)/i) { | ||
603 | $lineselectstart = $1; | ||
604 | } | ||
605 | elsif($l =~ /^line selector end color: *(.*)/i) { | ||
606 | $lineselectend = $1; | ||
607 | } | ||
608 | elsif($l =~ /^selector type: *(.*)/i) { | ||
609 | $selecttype = $1; | ||
610 | } | ||
611 | elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
612 | $selecttype = $1; | ||
613 | } | ||
614 | elsif($l =~ /^iconset: *(.*)/i) { | ||
615 | $iconset = $1; | ||
616 | } | ||
617 | elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | ||
618 | $iconset = $1; | ||
619 | } | ||
620 | elsif($l =~ /^viewers iconset: *(.*)/i) { | ||
621 | $viewericon = $1; | ||
622 | } | 500 | } |
623 | elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | 501 | } |
624 | $viewericon = $1; | 502 | elsif($l =~ /^ *<remote>/i) { |
503 | while(<WPS>) { | ||
504 | # parse remote settings | ||
505 | my $l = $_; | ||
506 | if ($l =~ /^ *<\/remote>/i) { | ||
507 | last; | ||
508 | } | ||
509 | elsif(!$has_remote) { | ||
510 | next; # dont parse <remote> section | ||
511 | } | ||
512 | elsif($_ = check_res($l, "rwps", 1)) { | ||
513 | $rwps = $_; | ||
514 | } | ||
515 | elsif($_ = check_res($l, "rsbs", 1)) { | ||
516 | $rsbs = $_; | ||
517 | } | ||
518 | elsif($_ = check_res($l, "rfms", 1)) { | ||
519 | $rfms = $_; | ||
520 | } | ||
521 | elsif($_ = check_res($l, "Font", 1)) { | ||
522 | $remotefont = $_; | ||
523 | } | ||
524 | elsif($_ = check_res($l, "iconset", 1)) { | ||
525 | $remoteiconset = $_; | ||
526 | } | ||
527 | elsif($_ = check_res($l, "viewers iconset", 1)) { | ||
528 | $remoteviewericon = $_; | ||
529 | } | ||
530 | elsif($_ = check_res($l, "statusbar", 1)) { | ||
531 | $remotestatusbar = $_; | ||
532 | } | ||
533 | elsif($_ = check_res($l, "ui viewport", 1)) { | ||
534 | $remotelistviewport = $_; | ||
535 | } | ||
625 | } | 536 | } |
626 | elsif($l =~ /^line selector text color: *(.*)/i) { | 537 | } |
627 | $lineselecttextcolor = $1; | 538 | elsif($l =~ /^ *<\/theme>/i) { |
539 | # for each wps,sbs,fms (+ remote variants) check if <theme>[.<model>].wps | ||
540 | # exists if no filename was specified in WPSLIST | ||
541 | my $req_skin; | ||
542 | |||
543 | if ($has_wps eq "yes" && !$wps) { | ||
544 | $wps = check_skinfile("wps"); | ||
545 | } elsif ($has_wps eq "no") { | ||
546 | $wps = ''; | ||
628 | } | 547 | } |
629 | elsif($l =~ /^filetype colours: *(.*)/i) { | 548 | |
630 | $filetylecolor = $1; | 549 | if ($has_sbs eq "yes" && !$sbs) { |
550 | $sbs = check_skinfile("sbs"); | ||
551 | } elsif ($has_sbs eq "no") { | ||
552 | $sbs = ''; | ||
631 | } | 553 | } |
632 | elsif($l =~ /^ui viewport: *(.*)/i) { | 554 | |
633 | $listviewport = $1; | 555 | if ($has_fms eq "yes" && !$fms) { |
556 | $fms = check_skinfile("fms"); | ||
557 | } elsif ($has_fms eq "no") { | ||
558 | $fms = ''; | ||
634 | } | 559 | } |
635 | elsif($l =~ /^ui viewport\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | 560 | |
636 | $listviewport = $1; | 561 | # now check for remote skin files (use main screen's extension) |
562 | if ($has_remote) { | ||
563 | if ($has_rwps eq "yes" && !$rwps) { | ||
564 | $rwps = check_skinfile("wps"); | ||
565 | } elsif ($has_rwps eq "no") { | ||
566 | $rwps = ''; | ||
567 | } | ||
568 | |||
569 | if ($has_rsbs eq "yes" && !$rsbs) { | ||
570 | $rsbs = check_skinfile("sbs"); | ||
571 | } elsif ($has_rsbs eq "no") { | ||
572 | $rsbs = ''; | ||
573 | } | ||
574 | |||
575 | if ($has_rfms eq "yes" && !$rfms) { | ||
576 | $rfms = check_skinfile("fms"); | ||
577 | } elsif ($has_rfms eq "no") { | ||
578 | $rfms = ''; | ||
579 | } | ||
637 | } | 580 | } |
638 | elsif($l =~ /^remote ui viewport: *(.*)/i) { | 581 | #print "LCD: $wps wants $width x $height\n"; |
639 | $remotelistviewport = $1; | 582 | |
583 | # | ||
584 | # The target model has an LCD that is suitable for this | ||
585 | # WPS | ||
586 | # | ||
587 | #print "Size requirement is fine!\n"; | ||
588 | mkdirs() if (-e "$wpsdir/$theme"); | ||
589 | # Do the copying before building the .cfg - buildcfg() | ||
590 | # mangles some filenames | ||
591 | if (defined($backdrop) && $backdrop ne "-") { | ||
592 | copybackdrop(); | ||
593 | $backdrop = normalize($backdrop); | ||
594 | } | ||
595 | foreach my $i ($iconset, $viewericon, $remoteiconset, $remoteviewericon) { | ||
596 | if (defined($i) && $i ne "-") { | ||
597 | copythemeicon($i); | ||
598 | } | ||
640 | } | 599 | } |
641 | elsif($l =~ /^remote ui viewport\.${main_width}x${main_height}x$main_depth: *(.*)/i) { | 600 | if (defined($font) && $font ne "-") { |
642 | $remotelistviewport = $1; | 601 | copythemefont($font); |
602 | $font = "$rbdir/fonts/$font"; | ||
643 | } | 603 | } |
644 | else{ | 604 | if (defined($remotefont) && $remotefont ne "-") { |
645 | #print "Unknown line: $l!\n"; | 605 | copythemefont($remotefont); |
606 | $remotefont = "$rbdir/fonts/$remotefont"; | ||
646 | } | 607 | } |
608 | buildcfg(); | ||
609 | copywps(); | ||
610 | } | ||
611 | else{ | ||
612 | #print "Unknown line: $l!\n"; | ||
647 | } | 613 | } |
648 | } | 614 | } |
649 | 615 | ||