ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfmap2html
(Generate patch)

Comparing cfmaps/cfmap2html (file contents):
Revision 1.12 by root, Sun Nov 20 05:02:58 2005 UTC vs.
Revision 1.19 by root, Tue Nov 22 17:54:41 2005 UTC

15# 15#
16# You should have received a copy of the GNU General Public License 16# You should have received a copy of the GNU General Public License
17# along with gvpe; if not, write to the Free Software 17# along with gvpe; if not, write to the Free Software
18# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 19
20our $VERSION = '1.12'; 20our $VERSION = '1.2';
21 21
22use Storable; 22use Storable;
23 23
24my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} 24my $LIBDIR = $ENV{CROSSFIRE_LIBDIR}
25 or die "\$CROSSFIRE_LIBDIR must be set\n"; 25 or die "\$CROSSFIRE_LIBDIR must be set\n";
60 my $W2 = $W + 600; 60 my $W2 = $W + 600;
61 61
62 my (@path) = split /\//, $path; 62 my (@path) = split /\//, $path;
63 63
64 print "<?xml version='1.0' encoding='utf-8'?>", 64 print "<?xml version='1.0' encoding='utf-8'?>",
65 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">", 65 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
66 "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>", 66 "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>",
67 "<head>", 67 "<head>",
68 "<title>Crossfire Map \"$path\"</title>", 68 "<title>Crossfire Map \"$path\"</title>",
69 "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>\n", 69 "<link rel='stylesheet' type='text/css' media='all' href='/common.css'/>\n",
70 "<link rel='stylesheet' type='text/css' media='all' href='/overlay.css' title='Show Overlays'/>\n",
71 "<link rel='alternate stylesheet' type='text/css' media='all' href='/plain.css' title='Hide Overlays'/>\n",
70 "<style type='text/css'>\n", 72 "<style type='text/css'>\n",
71 ".map { width: ${W}px; height: ${H}px; background-image: url($path[-1].png); }\n", 73 ".map { width: ${W}px; height: ${H}px; background-image: url($path[-1].png); }\n",
72 ".enlarge { width: ${W2}px; height: 600px; }\n", 74 ".enlarge { width: ${W2}px; height: 600px; }\n",
73 "</style>", 75 "</style>",
74 "</head>", 76 "</head>",
109 "</p>"; 111 "</p>";
110 112
111 print "<table class='map'>"; 113 print "<table class='map'>";
112 114
113 my %ignore = map +($_ => 1), qw(name _name x y); 115 my %ignore = map +($_ => 1), qw(name _name x y);
116 my %is_exit = map +($_ => 1), 41, 57, 66;
114 117
115 for my $y (0.. $meta->{height} - 1) { 118 for my $y (0.. $meta->{height} - 1) {
116 print "<tr>"; 119 print "<tr>";
117 for my $x (0.. $meta->{width} - 1) { 120 for my $x (0.. $meta->{width} - 1) {
118 print "<td>";
119 if (my $as = $meta->{map}[$x][$y]) { 121 if (my $as = $meta->{map}[$x][$y]) {
122 my @class;
123
124 push @class, "fishy" if grep $_->{invisible} || $_->{face} || exists $_->{no_pass}, @$as;
125 push @class, "exit" if grep $is_exit{$arch->{$_->{_name}}{type}} && $_->{slaying}, @$as;
126 push @class, "dialog" if grep $_->{msg} =~ /^\@match/m, @$as;
127
128 print "<td", (@class ? " class='" . (join " ", @class) . "'" : ""), ">";
129 print "<div>";
130
131 print join "\n", map "<span class='c'>$_</span>",
132 reverse sort { (length $a) <=> (length $b) or $b <=> $a }
133 grep $_, map $_->{connected}, @$as;
134
120 print "<div><div>($x|$y)"; 135 print "<div>($x|$y)";
121 136
122 sub print_archs { 137 sub print_archs {
123 print "<ul>"; 138 print "<ul>";
124 for my $a (@{$_[0]}) { 139 for my $a (@{$_[0]}) {
125 my $o = $arch->{$a->{_name}}; 140 my $o = $arch->{$a->{_name}};
130 print "<li><a href='/arc.xhtml#", (lc $a->{_name}), "'>$aname \"$name\"</a>\n"; 145 print "<li><a href='/arc.xhtml#", (lc $a->{_name}), "'>$aname \"$name\"</a>\n";
131 for (sort keys %$a) { 146 for (sort keys %$a) {
132 next if $ignore{$_}; 147 next if $ignore{$_};
133 my $v = escape_html $a->{$_}; 148 my $v = escape_html $a->{$_};
134 149
135 if ($_ eq "slaying" && ($type == 41 || $type == 57 || $type == 66)) { # door, teleporter, player_changer 150 if ($_ eq "slaying" && $is_exit{$type}) { # door, teleporter, player_changer
136 $a->{msg} =~ /^final_map\s*(\S+)\s*$/m, $v = $1 151 $a->{msg} =~ /^final_map\s*(\S+)\s*$/m, $v = $1
137 if $v eq "/!"; # random map 152 if $v eq "/!"; # random map
138 153
139 print "slaying => <a href='$v.xhtml'>$v</a>\n"; 154 print "slaying => <a href='$v.xhtml'>$v</a>\n";
140 } elsif ($_ eq "other_arch") { 155 } elsif ($_ eq "other_arch") {
152 } 167 }
153 print "</ul>"; 168 print "</ul>";
154 } 169 }
155 170
156 print_archs $as; 171 print_archs $as;
157 print "</div></div>"; 172 print "</div></div></td>";
173 } else {
174 print "<td/>";
158 } 175 }
159 print "</td>";
160 } 176 }
161 print "</tr>"; 177 print "</tr>";
162 } 178 }
163 179
164 print "</table><p class='footer'>created by <a href='http://software.schmorp.de/#crossfire'>cfmap2html</a> version $VERSION</p>", 180 print "</table><p class='footer'>created by <a href='http://software.schmorp.de/#crossfire'>cfmap2html</a> version $VERSION</p>",
165 "<p class='enlarge'/></body></html>"; 181 "<p class='enlarge'/></body></html>";
166 182
167 close $fh; 183 close $fh;
168 184
169 system "gzip", "-7f", "$path.xhtml"; 185 #system "gzip", "-7f", "$path.xhtml";
170} 186}
171 187

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines