1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
2 | |
2 | |
3 | # cfarch2png - convert crossfire maps to png+metadata |
3 | # cfarch2png - convert deliantra maps to png+metadata |
4 | # Copyright (C) 2005,2007 Marc Lehmann <cfmaps@schmorp.de> |
4 | # Copyright (C) 2005,2007,2008 Marc Lehmann <cfmaps@schmorp.de> |
5 | # |
5 | # |
6 | # CFARCH2PNG is free software; you can redistribute it and/or modify |
6 | # CFARCH2PNG is free software; you can redistribute it and/or modify |
7 | # it under the terms of the GNU General Public License as published by |
7 | # it under the terms of the GNU General Public License as published by |
8 | # the Free Software Foundation; either version 2 of the License, or |
8 | # the Free Software Foundation; either version 2 of the License, or |
9 | # (at your option) any later version. |
9 | # (at your option) any later version. |
… | |
… | |
28 | # Bottom object: the highest object that is a floor type object. |
28 | # Bottom object: the highest object that is a floor type object. |
29 | # |
29 | # |
30 | # ... I believe that anytime, but it still doesn't mention the smoothlevel |
30 | # ... I believe that anytime, but it still doesn't mention the smoothlevel |
31 | # interaction :( |
31 | # interaction :( |
32 | |
32 | |
33 | our $VERSION = '2.001'; |
33 | our $VERSION = '2.002'; |
34 | |
34 | |
35 | use strict; |
35 | use strict; |
36 | |
36 | |
37 | use Crossfire 1.0; |
37 | use Deliantra; |
38 | use List::Util qw(max); |
38 | use List::Util qw(max); |
39 | |
39 | |
40 | use Gtk2; |
40 | use Gtk2; |
41 | |
41 | |
42 | sub T (){ 32 } |
42 | sub T (){ 32 } |
43 | |
43 | |
44 | Crossfire::load_archetypes; |
44 | Deliantra::load_archetypes; |
45 | Crossfire::load_tilecache; |
45 | Deliantra::load_tilecache; |
46 | |
46 | |
47 | sub cfmap_render($;$) { |
47 | sub cfmap_render($;$) { |
48 | my ($mapa, $mapname) = @_; |
48 | my ($mapa, $mapname) = @_; |
49 | |
49 | |
50 | my %meta; |
50 | my %meta; |
… | |
… | |
217 | |
217 | |
218 | ($map_pb, \%meta) |
218 | ($map_pb, \%meta) |
219 | } |
219 | } |
220 | |
220 | |
221 | for my $file (@ARGV) { |
221 | for my $file (@ARGV) { |
222 | my $mapa = read_arch $file; |
|
|
223 | $file =~ s/\.map$//; |
222 | $file =~ s/\.map$//; |
|
|
223 | my $mapa = read_arch "$file.map"; |
224 | my ($pb, $meta) = cfmap_render $mapa, $file; |
224 | my ($pb, $meta) = cfmap_render $mapa, $file; |
225 | $pb->save ("$file.png~~", "png"); |
225 | $pb->save ("$file.png~~", "png"); |
226 | system "gm", "convert", "$file.png~~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; |
226 | system "gm", "convert", "$file.png~~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; |
227 | #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency |
227 | #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency |
228 | system "optipng", "-q", "-out", "$file.png~", "$file.png~~"; |
228 | system "optipng", "-q", "-out", "$file.png~", "$file.png~~"; |
229 | # system "pngnq <\Q$file.png~\E >\Q$file.png\E"; |
229 | # system "pngnq <\Q$file.png~\E >\Q$file.png\E"; |
230 | unlink "$file.png~~"; |
230 | unlink "$file.png~~"; |
231 | Storable::nstore $meta, "$file.pst"; |
231 | utime +(stat "$file.map")[8,9], "$file.jpg" or die "$file.jpg: $!"; |
232 | utime +(stat $file)[8,9], "$file.pst"; |
232 | utime +(stat "$file.map")[8,9], "$file.png~" or die "$file.png~: $!"; |
233 | utime +(stat $file)[8,9], "$file.jpg"; |
|
|
234 | utime +(stat $file)[8,9], "$file.png~"; |
|
|
235 | rename "$file.png~", "$file.png"; |
233 | rename "$file.png~", "$file.png"; |
236 | } |
234 | } |
237 | |
235 | |
238 | |
236 | |
239 | |
237 | |