… | |
… | |
6 | my $exec_prefix = "@exec_prefix@"; |
6 | my $exec_prefix = "@exec_prefix@"; |
7 | my $datarootdir = "@datarootdir@"; |
7 | my $datarootdir = "@datarootdir@"; |
8 | my $DATADIR = "@datadir@/@PACKAGE@"; |
8 | my $DATADIR = "@datadir@/@PACKAGE@"; |
9 | |
9 | |
10 | my $CONVERT = "@CONVERT@"; |
10 | my $CONVERT = "@CONVERT@"; |
11 | my $IDENTIFY = "@IDENTIFY@"; |
11 | #my $IDENTIFY = "@IDENTIFY@"; |
12 | my $OPTIPNG = "@OPTIPNG@"; |
12 | my $OPTIPNG = "@OPTIPNG@"; |
13 | my $RSYNC = "@RSYNC@"; |
13 | my $RSYNC = "@RSYNC@"; |
14 | my $PNGNQ = "@PNGNQ@"; |
14 | my $PNGNQ = "@PNGNQ@"; |
15 | |
15 | |
16 | use Getopt::Long; |
16 | use Getopt::Long; |
… | |
… | |
101 | } |
101 | } |
102 | |
102 | |
103 | { |
103 | { |
104 | our %ANIMINFO; |
104 | our %ANIMINFO; |
105 | our %FACEINFO; |
105 | our %FACEINFO; |
|
|
106 | our %RESOURCE; |
106 | our @ARC; |
107 | our @ARC; |
107 | our %ARC; |
108 | our %ARC; |
108 | our $TRS; |
109 | our $TRS; |
109 | our $NFILE; |
110 | our $NFILE; |
|
|
111 | our $PATH; |
110 | |
112 | |
111 | our $QUANTIZE = "+dither -colorspace RGB -colors 256"; |
113 | our $QUANTIZE = "+dither -colorspace RGB -colors 256"; |
112 | |
114 | |
113 | our (@png, @trs, @arc); # files we are interested in |
115 | our (@png, @trs, @arc, @res); # files we are interested in |
114 | |
116 | |
115 | sub commit_png($$$) { |
117 | sub commit_png($$$) { |
116 | my ($name, $data, $T) = @_; |
118 | my ($name, $data, $T) = @_; |
117 | |
119 | |
118 | $FACEINFO{$name}{"data$T"} = $data; |
120 | $FACEINFO{$name}{"data$T"} = $data; |
… | |
… | |
383 | |
385 | |
384 | $TRS .= $trs; |
386 | $TRS .= $trs; |
385 | } |
387 | } |
386 | } |
388 | } |
387 | |
389 | |
|
|
390 | sub process_res { |
|
|
391 | while (@res) { |
|
|
392 | my ($dir, $file) = @{pop @res}; |
|
|
393 | |
|
|
394 | my $data; |
|
|
395 | aio_load "$dir/$file", $data; |
|
|
396 | |
|
|
397 | my $copyright; |
|
|
398 | aio_load "$dir/copyright", $copyright; |
|
|
399 | |
|
|
400 | $file =~ s/\.res$//; |
|
|
401 | $file =~ /\.([^.]+)$/ |
|
|
402 | or next; |
|
|
403 | |
|
|
404 | my $type = $1; |
|
|
405 | |
|
|
406 | substr $dir, 0, 1 + length $PATH, ""; |
|
|
407 | |
|
|
408 | $RESOURCE{"$dir/$file"} = { |
|
|
409 | type => $1, |
|
|
410 | copyright => $copyright, |
|
|
411 | data => $data, |
|
|
412 | chksum => Digest::MD5::md5 $data, |
|
|
413 | }; |
|
|
414 | } |
|
|
415 | } |
|
|
416 | |
388 | sub find_files; |
417 | sub find_files; |
389 | sub find_files { |
418 | sub find_files { |
390 | my ($path) = @_; |
419 | my ($path) = @_; |
391 | |
420 | |
392 | IO::AIO::aioreq_pri 4; |
421 | IO::AIO::aioreq_pri 4; |
… | |
… | |
401 | push @png, ["$path/$file", 0]; |
430 | push @png, ["$path/$file", 0]; |
402 | } elsif ($file =~ /\.trs$/) { |
431 | } elsif ($file =~ /\.trs$/) { |
403 | push @trs, [$path, $file]; |
432 | push @trs, [$path, $file]; |
404 | } elsif ($file =~ /\.arc$/) { |
433 | } elsif ($file =~ /\.arc$/) { |
405 | push @arc, [$path, $file]; |
434 | push @arc, [$path, $file]; |
|
|
435 | } elsif ($file =~ /\.(ogg|res)$/) { |
|
|
436 | push @res, [$path, $file]; |
406 | } else { |
437 | } else { |
407 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
438 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
408 | } |
439 | } |
409 | } |
440 | } |
410 | }; |
441 | }; |
411 | } |
442 | } |
412 | |
443 | |
413 | sub inst_arch($) { |
444 | sub inst_arch($) { |
414 | my (undef, $path) = @_; |
445 | my (undef, $path) = @_; |
|
|
446 | |
|
|
447 | $PATH = $path; |
415 | |
448 | |
416 | print "\n", |
449 | print "\n", |
417 | "Installing '$path' to '$DATADIR'\n", |
450 | "Installing '$path' to '$DATADIR'\n", |
418 | "\n", |
451 | "\n", |
419 | "This can take a long time if you run this\n", |
452 | "This can take a long time if you run this\n", |
… | |
… | |
434 | $_->join for ( |
467 | $_->join for ( |
435 | # four png crunchers work fine for my 2x smp machine |
468 | # four png crunchers work fine for my 2x smp machine |
436 | (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), |
469 | (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), |
437 | (async \&process_trs), (async \&process_trs), |
470 | (async \&process_trs), (async \&process_trs), |
438 | (async \&process_arc), (async \&process_arc), |
471 | (async \&process_arc), (async \&process_arc), |
|
|
472 | (async \&process_res), (async \&process_res), |
439 | ); |
473 | ); |
440 | |
474 | |
441 | { |
475 | { |
442 | # remove path prefix from editor_folder |
476 | # remove path prefix from editor_folder |
443 | substr $_->{editor_folder}, 0, 1 + length $path, "" |
477 | substr $_->{editor_folder}, 0, 1 + length $path, "" |
… | |
… | |
511 | |
545 | |
512 | print $fh freeze { |
546 | print $fh freeze { |
513 | version => 2, |
547 | version => 2, |
514 | faceinfo => \%FACEINFO, |
548 | faceinfo => \%FACEINFO, |
515 | animinfo => \%ANIMINFO, |
549 | animinfo => \%ANIMINFO, |
|
|
550 | resource => \%RESOURCE, |
516 | }; |
551 | }; |
517 | } |
552 | } |
518 | |
553 | |
519 | for (qw(archetypes facedata treasures)) { |
554 | for (qw(archetypes facedata treasures)) { |
520 | chmod 0644, "$DATADIR/$_~"; |
555 | chmod 0644, "$DATADIR/$_~"; |