summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/html/javapage.pl
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2016-11-20 15:16:41 -0500
committerFranklin Wei <me@fwei.tk>2016-12-18 18:13:22 +0100
commit1a6a8b52f7aa4e2da6f4c34a0c743c760b8cfd99 (patch)
tree8e7f2d6b0cbdb5d15c13457b2c3e1de69f598440 /apps/plugins/puzzles/html/javapage.pl
parent3ee79724f6fb033d50e26ef37b33d3f8cedf0c5b (diff)
downloadrockbox-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/javapage.pl')
-rwxr-xr-xapps/plugins/puzzles/html/javapage.pl104
1 files changed, 104 insertions, 0 deletions
diff --git a/apps/plugins/puzzles/html/javapage.pl b/apps/plugins/puzzles/html/javapage.pl
new file mode 100755
index 0000000000..cd5e6a1669
--- /dev/null
+++ b/apps/plugins/puzzles/html/javapage.pl
@@ -0,0 +1,104 @@
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6open my $footerfile, "<", shift @ARGV or die "footer: open: $!\n";
7my $footer = "";
8$footer .= $_ while <$footerfile>;
9close $footerfile;
10
11for 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>
40You have found your way to a page containing an <em>unfinished</em>
41puzzle in my collection, not linked from the <a href="../">main
42puzzles page</a>. Don't be surprised if things are hard to understand
43or don't work as you expect.
44EOF
45 $links = <<EOF;
46<p align="center">
47<a href="../">Back to main puzzles page</a> (which does not link to this)
48EOF
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>
56EOF
57 }
58
59 print $outpage <<EOF;
60<html>
61<head>
62<title>${puzzlename}, ${unfinishedtitlefragment}from Simon Tatham's Portable Puzzle Collection</title>
63<link rel="stylesheet" type="text/css" href="../../sitestyle.css" name="Simon Tatham's Home Page Style">
64<script type="text/javascript" src="resize-puzzle-applet.js"></script>
65</head>
66<body onLoad="initResizablePuzzleApplet();">
67<h1 align=center>${puzzlename}</h1>
68${unfinishedheading}
69<h2 align=center>from Simon Tatham's Portable Puzzle Collection</h2>
70
71${unfinishedpara}
72
73<p align="center">
74<table cellpadding="0">
75<tr>
76<td>
77<applet id="applet" archive="${filename}.jar" code="PuzzleApplet"
78 width="700" height="500">
79</applet>
80</td>
81<td>
82<div id="eresize" style="width:5px;height:500px;cursor:e-resize;"></div>
83</td>
84</tr>
85<td>
86<div id="sresize" style="width:700px;height:5px;cursor:s-resize;"></div>
87</td>
88<td>
89<div id="seresize" style="width:5px;height:5px;cursor:se-resize;"></div>
90</td>
91</tr>
92</table>
93
94${instructions}
95
96${links}
97
98${footer}
99</body>
100</html>
101EOF
102
103 close $outpage;
104}