diff options
author | Franklin Wei <frankhwei536@gmail.com> | 2016-11-20 15:16:41 -0500 |
---|---|---|
committer | Franklin Wei <me@fwei.tk> | 2016-12-18 18:13:22 +0100 |
commit | 1a6a8b52f7aa4e2da6f4c34a0c743c760b8cfd99 (patch) | |
tree | 8e7f2d6b0cbdb5d15c13457b2c3e1de69f598440 /apps/plugins/puzzles/html/jspage.pl | |
parent | 3ee79724f6fb033d50e26ef37b33d3f8cedf0c5b (diff) | |
download | rockbox-1a6a8b52f7aa4e2da6f4c34a0c743c760b8cfd99.tar.gz rockbox-1a6a8b52f7aa4e2da6f4c34a0c743c760b8cfd99.zip |
Port of Simon Tatham's Puzzle Collection
Original revision: 5123b1bf68777ffa86e651f178046b26a87cf2d9
MIT Licensed. Some games still crash and others are unplayable due to
issues with controls. Still need a "real" polygon filling algorithm.
Currently builds one plugin per puzzle (about 40 in total, around 100K
each on ARM), but can easily be made to build a single monolithic
overlay (800K or so on ARM).
The following games are at least partially broken for various reasons,
and have been disabled on this commit:
Cube: failed assertion with "Icosahedron" setting
Keen: input issues
Mines: weird stuff happens on target
Palisade: input issues
Solo: input issues, occasional crash on target
Towers: input issues
Undead: input issues
Unequal: input and drawing issues (concave polys)
Untangle: input issues
Features left to do:
- In-game help system
- Figure out the weird bugs
Change-Id: I7c69b6860ab115f973c8d76799502e9bb3d52368
Diffstat (limited to 'apps/plugins/puzzles/html/jspage.pl')
-rwxr-xr-x | apps/plugins/puzzles/html/jspage.pl | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/apps/plugins/puzzles/html/jspage.pl b/apps/plugins/puzzles/html/jspage.pl new file mode 100755 index 0000000000..19868bd948 --- /dev/null +++ b/apps/plugins/puzzles/html/jspage.pl | |||
@@ -0,0 +1,120 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use strict; | ||
4 | use warnings; | ||
5 | |||
6 | open my $footerfile, "<", shift @ARGV or die "footer: open: $!\n"; | ||
7 | my $footer = ""; | ||
8 | $footer .= $_ while <$footerfile>; | ||
9 | close $footerfile; | ||
10 | |||
11 | for my $arg (@ARGV) { | ||
12 | $arg =~ /(.*\/)?([^\/]+)\.html$/ or die; | ||
13 | my $filename = $2; | ||
14 | open my $gamefile, "<", $arg or die "$arg: open: $!\n"; | ||
15 | my $unfinished = 0; | ||
16 | my $docname = $filename; | ||
17 | chomp(my $puzzlename = <$gamefile>); | ||
18 | while ($puzzlename =~ s/^([^:=]+)(=([^:]+))?://) { | ||
19 | if ($1 eq "unfinished") { | ||
20 | $unfinished = 1; | ||
21 | } elsif ($1 eq "docname") { | ||
22 | $docname = $3; | ||
23 | } else { | ||
24 | die "$arg: unknown keyword '$1'\n"; | ||
25 | } | ||
26 | } | ||
27 | my $instructions = ""; | ||
28 | $instructions .= $_ while <$gamefile>; | ||
29 | close $gamefile; | ||
30 | |||
31 | open my $outpage, ">", "${filename}.html"; | ||
32 | |||
33 | my $unfinishedtitlefragment = $unfinished ? "an unfinished puzzle " : ""; | ||
34 | my $unfinishedheading = $unfinished ? "<h2 align=center>an unfinished puzzle</h2>\n" : ""; | ||
35 | my $unfinishedpara; | ||
36 | my $links; | ||
37 | if ($unfinished) { | ||
38 | $unfinishedpara = <<EOF; | ||
39 | <p> | ||
40 | You have found your way to a page containing an <em>unfinished</em> | ||
41 | puzzle in my collection, not linked from the <a href="../">main | ||
42 | puzzles page</a>. Don't be surprised if things are hard to understand | ||
43 | or don't work as you expect. | ||
44 | EOF | ||
45 | $links = <<EOF; | ||
46 | <p align="center"> | ||
47 | <a href="../">Back to main puzzles page</a> (which does not link to this) | ||
48 | EOF | ||
49 | } else { | ||
50 | $unfinishedpara = ""; | ||
51 | $links = <<EOF; | ||
52 | <p align="center"> | ||
53 | <a href="../doc/${docname}.html#${docname}">Full instructions</a> | ||
54 | | | ||
55 | <a href="../">Back to main puzzles page</a> | ||
56 | EOF | ||
57 | } | ||
58 | |||
59 | print $outpage <<EOF; | ||
60 | <!DOCTYPE html> | ||
61 | <html> | ||
62 | <head> | ||
63 | <meta http-equiv="Content-Type" content="text/html; charset=ASCII" /> | ||
64 | <title>${puzzlename}, ${unfinishedtitlefragment}from Simon Tatham's Portable Puzzle Collection</title> | ||
65 | <script type="text/javascript" src="${filename}.js"></script> | ||
66 | </head> | ||
67 | <body onLoad="initPuzzle();"> | ||
68 | <h1 align=center>${puzzlename}</h1> | ||
69 | ${unfinishedheading} | ||
70 | <h2 align=center>from Simon Tatham's Portable Puzzle Collection</h2> | ||
71 | |||
72 | ${unfinishedpara} | ||
73 | |||
74 | <hr> | ||
75 | <div id="puzzle" style="display: none"> | ||
76 | <p align=center> | ||
77 | <input type="button" id="new" value="New game"> | ||
78 | <input type="button" id="restart" value="Restart game"> | ||
79 | <input type="button" id="undo" value="Undo move"> | ||
80 | <input type="button" id="redo" value="Redo move"> | ||
81 | <input type="button" id="solve" value="Solve game"> | ||
82 | <input type="button" id="specific" value="Enter game ID"> | ||
83 | <input type="button" id="random" value="Enter random seed"> | ||
84 | <select id="gametype"></select> | ||
85 | </p> | ||
86 | <div align=center> | ||
87 | <div id="resizable" style="position:relative; left:0; top:0"> | ||
88 | <canvas style="display: block" id="puzzlecanvas" width="1px" height="1px" tabindex="1"> | ||
89 | </canvas> | ||
90 | <div id="statusbarholder" style="display: block"> | ||
91 | </div> | ||
92 | </div> | ||
93 | <p> | ||
94 | Link to this puzzle: | ||
95 | <a id="permalink-desc">by game ID</a> | ||
96 | <a id="permalink-seed">by random seed</a> | ||
97 | </p> | ||
98 | </div> | ||
99 | </div> | ||
100 | <div id="apology"> | ||
101 | Sorry, this Javascript puzzle doesn't seem to work in your web | ||
102 | browser. Perhaps you have Javascript disabled, or perhaps your browser | ||
103 | doesn't provide a feature that the puzzle code requires (such as | ||
104 | <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Typed_arrays">typed arrays</a>). | ||
105 | These puzzles have been successfully run in Firefox 19, Chrome 26, | ||
106 | Internet Explorer 10 and Safari 6. | ||
107 | </div> | ||
108 | <hr> | ||
109 | |||
110 | ${instructions} | ||
111 | |||
112 | ${links} | ||
113 | |||
114 | ${footer} | ||
115 | </body> | ||
116 | </html> | ||
117 | EOF | ||
118 | |||
119 | close $outpage; | ||
120 | } | ||