common keyboard javascript include
[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 <script type="text/javascript" src="/keys.js"></script>
46
47 <body id="nethack">
48
49 <h1>NetHack cheat sheet</h1>
50
51 <h2>normal gameplay</h2>
52
53 <ul id="rows">
54
55 <li class="row">
56         <ul class="keys omni">
57         <li class="me" onclick="setmode()"><b>Esc</b>
58                 <!-- not as static anymore, but never bothered; just see ^[ -->
59         </ul>
60 </li>
61
62 <:
63 our %sign = (
64         arg    => $ascii ? '.' : '·',  # described as 'dot'
65         args   => $ascii ? ':' : '⁚',
66         argi   => $ascii ? "'" : '′',
67         argm   => $ascii ? '|' : '↕',
68         motion => $ascii ? '|' : '↕',
69         alias  => $ascii ? 'see: ' : '»',
70         up     => $ascii ? 'up'    : '▲',
71         right  => $ascii ? 'right' : '▶',
72         down   => $ascii ? 'down'  : '▼',
73         left   => $ascii ? 'left'  : '◀',
74         sep    => $ascii ? '*'     : '•',
75         _      => exists $get{ascii} && !$ascii ? "\x{200b}" : '<wbr>',
76                 # use the correct ZWNJ only when unicode is forced on
77                 # default to use unofficial html for best support
78 );
79
80 use Shiar_Sheet::Keyboard;
81 my $keys = Shiar_Sheet::Keyboard->new({do 'nethack.inc.pl'});
82 $keys->map($get{map}) or undef $get{map};
83 $keys->print_rows($get{static});
84 :>
85 </ul>
86
87 <hr>
88
89 <div class="help">
90         <div class="left">
91                 <dl class="legend legend-types">
92                 <dt class="ci">
93                         <dd>
94                 <dt class="pm">direction
95                         <dd>Direction to move to or target a command (<:= $sign{motion} :>).
96                 <dt class="po">move
97                         <dd>Other character movement.
98                 <dt class="co">act
99                         <dd>Direct action command: takes a turn.
100                 <dt class="mi">info
101                         <dd>Informational command: shows/does something without ending the turn.
102                 <dt class="mo">invertory
103                         <dd>Display invertory menu.
104                 <dt class="mv">menu
105                         <dd>Enters some other menu.
106                 <dt class="me">
107                         <dd>
108                 </dl>
109         </div>
110
111         <div class="right">
112                 <dl class="legend legend-options">
113                 <dt>key<:= $sign{arg} :>
114                         <dd>Commands with a dot need at least one argument afterwards.
115                 <dt>key<:= $sign{argi} :>
116                         <dd>Asks for an inventory item.
117                 <dt>key<:= $sign{argm} :>
118                         <dd>Thing
119                 <dt>key<:= $sign{motion} :>
120                         <dd>Requires a direction afterwards.
121                 </dl>
122
123                 <ul class="legend legend-set">
124                 <li>keyboard <strong>map</strong> is
125                         <:= $get{map} ? 'set to ' : '' :><em><:= $keys->{map} :></em>
126                 <li><strong>ascii</strong> mode is
127                         <:= exists $get{ascii} && 'forced ' :><em><:=
128                                 $ascii ? 'on' : 'off' :></em>
129                 <li><strong>keys</strong> are
130                         <em><:= $showkeys ? 'always shown' : 'hidden if unassigned' :></em><:=
131                                 !exists $get{keys} && ' by default' :>
132                 <li>default <strong>style</strong> is
133                         <:= defined $get{style} && 'set to ' :><em><:= $style :></em>
134                 </ul>
135         </div>
136 </div>
137
138 <p class="footer">
139         <a href="http://sheet.shiar.nl/nethack">sheet.shiar.nl<strong>/nethack</strong></a>
140         <a href="git://dev.shiar.net/vi-cheat"><:= "v$VERSION" :></a>
141         created by Shiar <:= $sign{sep} :>
142         <a title="Licensed under the GNU Affero General Public License, version 3"
143            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> <:= $sign{sep} :>
144         last update <:
145                 use Time::Format qw(time_format);
146                 print time_format('yyyy-mm-dd', (stat 'nethack.inc.pl')[9]);
147         :>
148 </p>
149
150 </html>