… | |
… | |
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 | $file =~ s/\.res$//; |
|
|
398 | $file =~ /\.([^.]+)$/ |
|
|
399 | or next; |
|
|
400 | |
|
|
401 | my $type = $1; |
|
|
402 | |
|
|
403 | substr $dir, 0, 1 + length $PATH, ""; |
|
|
404 | |
|
|
405 | $RESOURCE{"$dir/$file"} = { |
|
|
406 | type => $1, |
|
|
407 | copyright => "", # TODO |
|
|
408 | data => $data, |
|
|
409 | chksum => Digest::MD5::md5 $data, |
|
|
410 | }; |
|
|
411 | } |
|
|
412 | } |
|
|
413 | |
388 | sub find_files; |
414 | sub find_files; |
389 | sub find_files { |
415 | sub find_files { |
390 | my ($path) = @_; |
416 | my ($path) = @_; |
391 | |
417 | |
392 | IO::AIO::aioreq_pri 4; |
418 | IO::AIO::aioreq_pri 4; |
… | |
… | |
401 | push @png, ["$path/$file", 0]; |
427 | push @png, ["$path/$file", 0]; |
402 | } elsif ($file =~ /\.trs$/) { |
428 | } elsif ($file =~ /\.trs$/) { |
403 | push @trs, [$path, $file]; |
429 | push @trs, [$path, $file]; |
404 | } elsif ($file =~ /\.arc$/) { |
430 | } elsif ($file =~ /\.arc$/) { |
405 | push @arc, [$path, $file]; |
431 | push @arc, [$path, $file]; |
|
|
432 | } elsif ($file =~ /\.(ogg|res)$/) { |
|
|
433 | push @res, [$path, $file]; |
406 | } else { |
434 | } else { |
407 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
435 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
408 | } |
436 | } |
409 | } |
437 | } |
410 | }; |
438 | }; |
411 | } |
439 | } |
412 | |
440 | |
413 | sub inst_arch($) { |
441 | sub inst_arch($) { |
414 | my (undef, $path) = @_; |
442 | my (undef, $path) = @_; |
|
|
443 | |
|
|
444 | $PATH = $path; |
415 | |
445 | |
416 | print "\n", |
446 | print "\n", |
417 | "Installing '$path' to '$DATADIR'\n", |
447 | "Installing '$path' to '$DATADIR'\n", |
418 | "\n", |
448 | "\n", |
419 | "This can take a long time if you run this\n", |
449 | "This can take a long time if you run this\n", |
… | |
… | |
434 | $_->join for ( |
464 | $_->join for ( |
435 | # four png crunchers work fine for my 2x smp machine |
465 | # four png crunchers work fine for my 2x smp machine |
436 | (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), |
466 | (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), |
437 | (async \&process_trs), (async \&process_trs), |
467 | (async \&process_trs), (async \&process_trs), |
438 | (async \&process_arc), (async \&process_arc), |
468 | (async \&process_arc), (async \&process_arc), |
|
|
469 | (async \&process_res), (async \&process_res), |
439 | ); |
470 | ); |
440 | |
471 | |
441 | { |
472 | { |
442 | # remove path prefix from editor_folder |
473 | # remove path prefix from editor_folder |
443 | substr $_->{editor_folder}, 0, 1 + length $path, "" |
474 | substr $_->{editor_folder}, 0, 1 + length $path, "" |
… | |
… | |
511 | |
542 | |
512 | print $fh freeze { |
543 | print $fh freeze { |
513 | version => 2, |
544 | version => 2, |
514 | faceinfo => \%FACEINFO, |
545 | faceinfo => \%FACEINFO, |
515 | animinfo => \%ANIMINFO, |
546 | animinfo => \%ANIMINFO, |
|
|
547 | resource => \%RESOURCE, |
516 | }; |
548 | }; |
517 | } |
549 | } |
518 | |
550 | |
519 | for (qw(archetypes facedata treasures)) { |
551 | for (qw(archetypes facedata treasures)) { |
520 | chmod 0644, "$DATADIR/$_~"; |
552 | chmod 0644, "$DATADIR/$_~"; |