-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.html
More file actions
228 lines (222 loc) · 8.33 KB
/
Copy pathindex.html
File metadata and controls
228 lines (222 loc) · 8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dune II - The Building of A Dynasty</title>
<meta charset="UTF-8"/>
<meta name="description" content="Dune II reimplementation written in HTML5 / JavaScript"/>
<meta name="viewport"
content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0.0, viewport-fit=cover"/>
<meta name="mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="apple-mobile-web-app-title" content="Dune2"/>
<link rel="icon" type="image/png" href="img/favicon.png"/>
<link rel="shortcut icon" type="image/png" href="img/touch-icon-152.png"/>
<link rel="apple-touch-icon" href="img/touch-icon-152.png"/>
<link rel="apple-touch-icon" sizes="152x152" href="img/touch-icon-152.png"/>
<link rel="apple-touch-icon" sizes="180x180" href="img/touch-icon-180.png"/>
<link rel="manifest" href="site.webmanifest"/>
<link type="text/css" rel="stylesheet" href="css/game.css"/>
<link type="text/css" rel="stylesheet" media="all" href="css/aristo.css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript">
var Epicport = {}; // Namespace
Epicport.i18n = {
html_login_success_title: "You successfully logged in",
html_can_save_desc: "Now you can save games",
html_can_load_desc: "Now you can load game saves",
html_success: "Success",
html_info: "Info",
html_error: "Error",
html_game_saved: "Game successfully saved",
html_game_protected: "Protected game file cannot be overwritten.",
html_game_load_error: "Game could not be loaded",
html_autosave: "Autosave.dat",
html_ok: "Ok",
html_cancel: "Cancel",
};
var query = new URLSearchParams(window.location.search);
Epicport.profile = {
identity: query.get("profile") || "public"
};
</script>
<script type="text/javascript" src="js/async.js"></script>
<script type="text/javascript" src="js/dialog.js"></script>
<script type="text/javascript" src="js/canvas.js"></script>
<script type="text/javascript" src="js/dune2.js"></script>
<script type="text/javascript" src="js/api.js"></script>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.17.1/firebase-app.js";
import { getAuth, signInAnonymously } from "https://www.gstatic.com/firebasejs/9.17.1/firebase-auth.js";
import { getAnalytics, logEvent } from "https://www.gstatic.com/firebasejs/9.17.1/firebase-analytics.js";
import { getDatabase, serverTimestamp, ref, query, get, set, push, orderByChild, limitToLast } from "https://www.gstatic.com/firebasejs/9.17.1/firebase-database.js";
const firebaseConfig = {
apiKey: "AIzaSyDmXth60JN9eiAh-vHVCLEPy66P3SOk7OY",
authDomain: "dune2-1ee3b.firebaseapp.com",
projectId: "dune2-1ee3b",
storageBucket: "dune2-1ee3b.appspot.com",
messagingSenderId: "627922875052",
appId: "1:627922875052:web:987774bcd0985c133e6509",
measurementId: "G-RK068C4YP1",
databaseURL: "https://dune2-1ee3b-default-rtdb.europe-west1.firebasedatabase.app",
};
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
signInAnonymously(getAuth());
window.firebase = {
app,
analytics,
logEvent,
db: getDatabase(app),
ts: serverTimestamp,
ref,
query,
get,
set,
push,
orderByChild,
limitToLast,
};
</script>
</head>
<body oncontextmenu="return false;">
<div class="game">
<div class="dune2-select-house-dialog dialog" title="Choose your side">
<div class="opendune-house-container">
<p class="opendune-select-house">Choose your side</p>
<p class="opendune-house opendune-a-house" title="House Atreides"></p>
<p class="opendune-house opendune-o-house" title="House Ordos"></p>
<p class="opendune-house opendune-h-house" title="House Harkonnen"></p>
</div>
</div>
<div class="game_container opendune">
<canvas id="canvas"></canvas>
<div id="output" class="canvas_overlay">
<div class="click_to_start">
<span class="huge">Press to Start</span>
</div>
<div class="loader">
<div class="info">
<div id="status" class="status">Loading...</div>
</div>
</div>
</div>
</div>
<div class="select-file-dialog dialog" title="Select file">
<p class="label">
Select file
</p>
<ul class="select-file-dialog-saves">
<span>No saved games found</span>
</ul>
<p></p>
<p class="select-file-input">
<label for="select-file-dialog-file">Enter file name</label>
<input id="select-file-dialog-file" type="text" value="">
</p>
</div>
</div>
<script type="text/javascript">
Epicport.API = new Epicport.API({
game: "opendune",
arguments: ["-a"],
preRun: function () {
},
start:
function () {
var preventUpDown = function (e) {
if (e.keyCode === 38 || e.keyCode === 40) {
e.preventDefault();
}
}
document.addEventListener("keydown", preventUpDown);
document.addEventListener("keyup", preventUpDown);
document.addEventListener("keypress", preventUpDown);
var dune2 = new Epicport.Dune2();
dune2.start('js/opendune.js');
},
js: '/js/opendune.js'
});
var Module = Epicport.API.module();
var canvas = document.getElementById("canvas");
var canvasPreventDefault = function (e) {
if (e.target === canvas) {
e.preventDefault();
}
}
document.body.addEventListener("touchstart", canvasPreventDefault, false);
document.body.addEventListener("touchend", canvasPreventDefault, false);
document.body.addEventListener("touchmove", canvasPreventDefault, false);
function setSize() {
var ratio = 640 / 400;
var gameContainer = jQuery(".game_container");
var width = window.innerWidth;
var height = window.innerHeight;
if (width >= height * ratio) {
gameContainer.width(height * ratio);
gameContainer.height(height);
gameContainer.css("margin-top", "");
gameContainer.css("margin-left", (width - height * ratio) / 2);
gameContainer.parent().removeClass("small");
} else {
gameContainer.width(width);
gameContainer.height(width / ratio);
gameContainer.css("margin-top", (height - width / ratio) / 2);
gameContainer.css("margin-left", "");
gameContainer.parent().addClass("small");
}
}
jQuery(document).ready(function () {
setSize();
});
$(window).on("resize orientationchange", function () {
setSize();
});
if (window.ontouchstart === null) {
function touchHandler(event) {
if (event.touches.length > 1) {
event.preventDefault();
return;
}
var touch = event.changedTouches[0];
event = new MouseEvent({
touchstart: "mousedown",
touchmove: "mousemove",
touchend: "mouseup"
}[event.type], {
bubbles: true,
cancelable: true,
view: window,
detail: 0,
screenX: touch.screenX,
screenY: touch.screenY,
clientX: touch.clientX,
clientY: touch.clientY,
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false,
button: 0,
relatedTarget: null,
});
event.touching = true;
touch.target.dispatchEvent(event);
}
window.addEventListener("touchstart", touchHandler, true);
window.addEventListener("touchmove", touchHandler, true);
window.addEventListener("touchend", touchHandler, true);
}
setInterval(function () {
if (document.visibilityState === "visible") {
Epicport.API.autoSave();
}
}, 5 * 60 * 1000);
document.addEventListener("visibilitychange", function () {
if (document.visibilityState !== "visible") {
Epicport.API.autoSave();
}
});
</script>
</body>
</html>