… | |
… | |
9 | |
9 | |
10 | my $arch; |
10 | my $arch; |
11 | |
11 | |
12 | umask 022; |
12 | umask 022; |
13 | |
13 | |
|
|
14 | our $VERSION = '1.0'; |
|
|
15 | |
14 | sub escape_html($) { |
16 | sub escape_html($) { |
15 | local $_ = shift; |
17 | local $_ = shift; |
16 | s/([<>&])/sprintf "&#%d;", ord $1/ge; |
18 | s/([<>&])/sprintf "&#%d;", ord $1/ge; |
17 | $_ |
19 | $_ |
18 | } |
20 | } |
19 | |
21 | |
20 | for my $path (@ARGV) { |
22 | for my $path (@ARGV) { |
21 | print "$path\n"; |
23 | # print STDERR "$path\n"; |
22 | |
24 | |
23 | if (!-e "$path.png" |
25 | if (!-e "$path.png" |
24 | || !-e "$path.pst" |
26 | || !-e "$path.pst" |
25 | || -M "$path.pst" > -M $path |
27 | || -M "$path.pst" > -M $path |
26 | || -M "$path.png" > -M $path) { |
28 | || -M "$path.png" > -M $path) { |
… | |
… | |
73 | "-->\n</style>", |
75 | "-->\n</style>", |
74 | "</head>", |
76 | "</head>", |
75 | "<body>"; |
77 | "<body>"; |
76 | |
78 | |
77 | print "<table id='nav'>", |
79 | print "<table id='nav'>", |
78 | "<tr><td rowspan='3'><h1>"; |
80 | "<tr valign='center'><td rowspan='3' style='padding-right: 3em'><h1>"; |
79 | print "<a href='/'>/</a> "; |
81 | print "<a href='/'>/</a> "; |
80 | for (0 .. $#path - 1) { |
82 | for (0 .. $#path - 1) { |
81 | print "<a href='/", (join "/", @path[0..$_]), "/'>$path[$_]</a> / "; |
83 | print "<a href='/", (join "/", @path[0..$_]), "/'>$path[$_]</a> / "; |
82 | } |
84 | } |
83 | |
85 | |
84 | my @tile = map { |
86 | my @tile = map { |
85 | $meta->{info}{"tile_path_$_"} |
87 | $meta->{info}{"tile_path_$_"} |
86 | ? "<a href='$meta->{info}{\"tile_path_$_\"}.html'><img style='border: 2px solid blue;' src='$meta->{info}{\"tile_path_$_\"}.jpg'/></a>" |
88 | ? "<a href='$meta->{info}{\"tile_path_$_\"}.html'><img style='border: 2px solid blue;' src='$meta->{info}{\"tile_path_$_\"}.jpg'/></a>" |
87 | : "" |
89 | : "" |
88 | } 1..4; |
90 | } 1..4; |
|
|
91 | #"}"# vim misparses without this comment |
89 | |
92 | |
90 | print "$path[-1] "; |
93 | print "$path[-1]", |
91 | print "</h1></td>", |
94 | "</h1>", |
|
|
95 | "<p style='font-size: 8pt;'><a href='/about.txt'>[more about cfmaps.schmorp.de]</a></p>", |
|
|
96 | "</td>", |
92 | "<td/><td>$tile[0]</td><td/></tr>", |
97 | "<td/><td>$tile[0]</td><td/></tr>", |
93 | "<tr><td>$tile[3]</td>"; |
98 | "<tr><td>$tile[3]</td>", |
94 | print "<td><img id='thumb' src='@path[-1].jpg'/></td>", |
99 | "<td><img id='thumb' src='@path[-1].jpg'/></td>", |
95 | "<td>$tile[1]</td>", |
100 | "<td>$tile[1]</td>", |
96 | "<tr><td/><td>$tile[2]</td><td/></tr>"; |
101 | "<tr><td/><td>$tile[2]</td><td/></tr>", |
97 | print "</table>"; |
102 | "</table>"; |
98 | |
103 | |
99 | my $W1 = $W + 600; |
104 | my $W1 = $W + 600; |
100 | |
105 | |
101 | print "<p style='width: ${W1}px'><a href='/about.txt'>[about cfmaps.schmorp.de]</a></p>"; |
|
|
102 | print "<p class='m' style='white-space: pre; width=auto; '>", |
106 | print "<p class='m' style='white-space: pre; width=auto; '>", |
103 | escape_html $meta->{info}{msg}, |
107 | escape_html $meta->{info}{msg}, |
104 | "</p>"; |
108 | "</p>"; |
105 | |
109 | |
106 | print "<table id='map'>"; |
110 | print "<table id='map'>"; |
… | |
… | |
110 | for my $y (0.. $meta->{height} - 1) { |
114 | for my $y (0.. $meta->{height} - 1) { |
111 | print "<tr>"; |
115 | print "<tr>"; |
112 | for my $x (0.. $meta->{width} - 1) { |
116 | for my $x (0.. $meta->{width} - 1) { |
113 | print "<td>"; |
117 | print "<td>"; |
114 | if (my $as = $meta->{map}[$x][$y]) { |
118 | if (my $as = $meta->{map}[$x][$y]) { |
115 | print "<span><div>($x|$y)<ul>"; |
119 | print "<span><div>($x|$y)"; |
116 | for my $a (@$as) { |
|
|
117 | my $o = $arch->{$a->{_name}}; |
|
|
118 | print "<li>\"$o->{name}\" ($a->{_name})\n"; |
|
|
119 | for (sort keys %$a) { |
|
|
120 | next if $ignore{$_}; |
|
|
121 | my $v = escape_html $a->{$_}; |
|
|
122 | |
120 | |
123 | if (($o->{type} == 66 || $o->{type} == 41) && $_ eq "slaying") { # door, teleporter |
121 | sub print_archs { |
124 | $a->{msg} =~ /^final_map\s*(\S+)\s*$/m, $v = $1 |
122 | print "<ul>"; |
125 | if $v eq "/!"; # random map |
123 | for my $a (@{$_[0]}) { |
|
|
124 | my $o = $arch->{$a->{_name}}; |
|
|
125 | print "<li><a href='/archetypes.html#", (lc $a->{_name}), "'>\"$o->{name}\" ($a->{_name})</a>\n"; |
|
|
126 | for (sort keys %$a) { |
|
|
127 | next if $ignore{$_}; |
|
|
128 | my $v = escape_html $a->{$_}; |
126 | |
129 | |
|
|
130 | if (($o->{type} == 66 || $o->{type} == 41) && $_ eq "slaying") { # door, teleporter |
|
|
131 | $a->{msg} =~ /^final_map\s*(\S+)\s*$/m, $v = $1 |
|
|
132 | if $v eq "/!"; # random map |
|
|
133 | |
127 | print "slaying => <a href='$v.html'>$v</a>\n"; |
134 | print "slaying => <a href='$v.html'>$v</a>\n"; |
|
|
135 | } elsif ($_ eq "other_arch") { |
|
|
136 | print "$_ => <a href='/archetypes.html#", (lc $a->{$_}), "'>$v</a>\n"; |
|
|
137 | } elsif ($_ eq "inventory") { |
|
|
138 | print "inventory =>\n"; |
|
|
139 | print_archs ($a->{$_}); |
128 | } elsif ($_ eq "msg") { |
140 | } elsif ($_ eq "msg") { |
129 | print "<p class='m'>$v</p>"; |
141 | print "<p class='m'>$v</p>"; |
130 | } else { |
142 | } else { |
131 | print "$_ => $v\n"; |
143 | print "$_ => $v\n"; |
|
|
144 | } |
132 | } |
145 | } |
133 | } |
146 | } |
|
|
147 | print "</ul>"; |
134 | } |
148 | } |
|
|
149 | |
|
|
150 | print_archs $as; |
135 | print "</ul></div></span>"; |
151 | print "</div></span>"; |
136 | } |
152 | } |
137 | print "</td>"; |
153 | print "</td>"; |
138 | } |
154 | } |
139 | print "</tr>"; |
155 | print "</tr>"; |
140 | } |
156 | } |
141 | |
157 | |
|
|
158 | print "</table></p><hr/><p style='font-size: 6pt'>created by <b>cfmap2html</b> version $VERSION</p>", |
142 | print "</table></p><p style='height: 600px;'/></body></html>"; |
159 | "<p style='height: 600px;'/></body></html>"; |
143 | |
160 | |
144 | close $fh; |
161 | close $fh; |
145 | |
162 | |
146 | system "gzip", "-7f", "$path.html"; |
163 | system "gzip", "-7f", "$path.html"; |
147 | } |
164 | } |