digraphs: add proposals for rare latin smallcaps forms
[sheet.git] / nethack.plp
1 <:
2 use utf8;
3 use strict;
4 use warnings;
5 no  warnings 'qw';  # you know what you doing
6 no  warnings 'uninitialized';  # save some useless checks for more legible code
7
8 our $VERSION = '1.0';
9
10 our $ascii = 0;
11 if (exists $get{ascii}) {
12         $ascii = $get{ascii} ne '0';  # manual override
13 } elsif (defined $ENV{HTTP_ACCEPT_CHARSET}) {
14         $ascii = 1;
15         for (split q{,}, $ENV{HTTP_ACCEPT_CHARSET}) {
16                 $ascii = 0, last if $_ eq '*' or m{utf-?8}i;
17         }
18 }
19
20 my $charset = $ascii ? 'us-ascii' : 'utf-8';
21 my $ctype = "text/html; charset=$charset";
22 $header{content_type} = $ctype;
23
24 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
25  "http://www.w3.org/TR/html4/loose.dtd">
26 <html>
27
28 <head>
29 <title>nethack cheat sheet</title>
30 <meta http-equiv="content-type" content="<:= $ctype :>">
31 <link rel="stylesheet" type="text/css" media="all" href="base.css">
32 <!--[if lte IE 6]><style> .help dl.legend dt {margin:0 0 1px} </style><![endif]-->
33 <!--[if lte IE 7]><style> .help dl.legend dd {float:none} </style><![endif]--><:
34         my %styles = map {$_ => $_} qw(dark circus mono red terse);
35         our $style = exists $get{style} && $styles{$get{style}} || 'light';
36         printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
37                 $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_
38         ) for keys %styles;
39
40         our $showkeys = exists $get{keys} && $get{keys} ne '0';
41         print "\n<style> .no {visibility:hidden} </style>" unless $showkeys;
42         print "\n<style> .no, .alias {opacity:.5} </style>"
43                 if $showkeys and $get{keys} eq 'ghost';
44 :>
45
46 <script><!--
47 function setmode(classname) {
48         // set style for each #rows>li>ul>li to display:none unless it matches classname
49         var showclass = classname ? ' '+classname+'(?!\\w)' : '^$';
50         var parentskip = /^keys/;
51         var row = document.getElementById('rows').firstChild;
52         do {
53                 if (row.tagName == 'LI' && row.firstChild.tagName == 'UL'
54                 && !row.firstChild.className.match(parentskip)) {
55                         var el = row.firstChild.firstChild;
56                         if (el) do {
57                                 if (el.tagName == 'LI') {
58                                         el.style.display = el.className.match(showclass) ? 'block' : 'none';
59                                 }
60                         } while (el = el.nextSibling);
61                 }
62         } while (row = row.nextSibling);
63
64         // update H2 to reflect the first part of a currently active (but hidden) H3
65         var h3s = document.getElementsByTagName('H3');
66         for (var i = 0; i < h3s.length; i++) {
67                 if (h3s[i].parentNode.style.display != 'block') continue;
68                 document.getElementsByTagName('H2')[0].innerHTML = h3s[i].firstChild.data;
69         }
70 } // setmode
71 //--></script>
72
73 <body id="nethack">
74
75 <h1>NetHack cheat sheet</h1>
76
77 <h2>normal gameplay</h2>
78
79 <ul id="rows">
80
81 <li class="row">
82         <ul class="keys omni">
83         <li class="me" onclick="setmode()"><b>Esc</b>
84                 <!-- not as static anymore, but never bothered; just see ^[ -->
85         </ul>
86 </li>
87
88 <:
89 our %sign = (
90         arg    => $ascii ? '.' : '·',  # described as 'dot'
91         args   => $ascii ? ':' : '⁚',
92         argi   => $ascii ? "'" : '′',
93         argm   => $ascii ? '|' : '↕',
94         motion => $ascii ? '|' : '↕',
95         alias  => $ascii ? 'see: ' : '»',
96         up     => $ascii ? 'up'    : '▲',
97         right  => $ascii ? 'right' : '▶',
98         down   => $ascii ? 'down'  : '▼',
99         left   => $ascii ? 'left'  : '◀',
100         sep    => $ascii ? '*'     : '•',
101         _      => exists $get{ascii} && !$ascii ? "\x{200b}" : '<wbr>',
102                 # use the correct ZWNJ only when unicode is forced on
103                 # default to use unofficial html for best support
104 );
105
106 use Shiar_Sheet::Keyboard;
107 my $keys = Shiar_Sheet::Keyboard->new({do 'nethack.inc.pl'});
108 $keys->map($get{map}) or undef $get{map};
109 $keys->print_rows($get{static});
110 :>
111 </ul>
112
113 <hr>
114
115 <div class="help">
116         <div class="left">
117                 <dl class="legend legend-types">
118                 <dt class="ci">
119                         <dd>
120                 <dt class="pm">direction
121                         <dd>Direction to move to or target a command (<:= $sign{motion} :>).
122                 <dt class="po">move
123                         <dd>Other character movement.
124                 <dt class="co">act
125                         <dd>Direct action command: takes a turn.
126                 <dt class="mi">info
127                         <dd>Informational command: shows/does something without ending the turn.
128                 <dt class="mo">invertory
129                         <dd>Display invertory menu.
130                 <dt class="mv">menu
131                         <dd>Enters some other menu.
132                 <dt class="me">
133                         <dd>
134                 </dl>
135         </div>
136
137         <div class="right">
138                 <dl class="legend legend-options">
139                 <dt>key<:= $sign{arg} :>
140                         <dd>Commands with a dot need at least one argument afterwards.
141                 <dt>key<:= $sign{argi} :>
142                         <dd>Asks for an inventory item.
143                 <dt>key<:= $sign{argm} :>
144                         <dd>Thing
145                 <dt>key<:= $sign{motion} :>
146                         <dd>Requires a direction afterwards.
147                 </dl>
148
149                 <ul class="legend legend-set">
150                 <li>keyboard <strong>map</strong> is
151                         <:= $get{map} ? 'set to ' : '' :><em><:= $keys->{map} :></em>
152                 <li><strong>ascii</strong> mode is
153                         <:= exists $get{ascii} && 'forced ' :><em><:=
154                                 $ascii ? 'on' : 'off' :></em>
155                 <li><strong>keys</strong> are
156                         <em><:= $showkeys ? 'always shown' : 'hidden if unassigned' :></em><:=
157                                 !exists $get{keys} && ' by default' :>
158                 <li>default <strong>style</strong> is
159                         <:= defined $get{style} && 'set to ' :><em><:= $style :></em>
160                 </ul>
161         </div>
162 </div>
163
164 <p class="footer">
165         <a href="http://sheet.shiar.nl/nethack">sheet.shiar.nl<strong>/nethack</strong></a>
166         <a href="git://dev.shiar.net/vi-cheat"><:= "v$VERSION" :></a>
167         created by Shiar <:= $sign{sep} :>
168         <a title="Licensed under the GNU Affero General Public License, version 3"
169            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> <:= $sign{sep} :>
170         last update <:
171                 use Time::Format qw(time_format);
172                 print time_format('yyyy-mm-dd', (stat 'nethack.inc.pl')[9]);
173         :>
174 </p>
175
176 </html>