default.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>$GODOT_HEAD_TITLE</title>
  6. $GODOT_HEAD_INCLUDE
  7. <style type="text/css">
  8. body {
  9. margin: 0;
  10. border: 0 none;
  11. padding: 0;
  12. text-align: center;
  13. background-color: black;
  14. font-family: $GODOT_STYLE_FONT_FAMILY;
  15. }
  16. /* Godot Engine default theme style
  17. * ================================ */
  18. .godot {
  19. color: #e0e0e0;
  20. background-color: #3b3943;
  21. background-image: linear-gradient(to bottom, #403e48, #35333c);
  22. border: 1px solid #45434e;
  23. box-shadow: 0 0 1px 1px #2f2d35;
  24. }
  25. button.godot {
  26. font-family: $GODOT_STYLE_FONT_FAMILY; /* override user agent style */
  27. padding: 1px 5px;
  28. background-color: #37353f;
  29. background-image: linear-gradient(to bottom, #413e49, #3a3842);
  30. border: 1px solid #514f5d;
  31. border-radius: 1px;
  32. box-shadow: 0 0 1px 1px #2a2930;
  33. }
  34. button.godot:hover {
  35. color: #f0f0f0;
  36. background-color: #44414e;
  37. background-image: linear-gradient(to bottom, #494652, #423f4c);
  38. border: 1px solid #5a5667;
  39. box-shadow: 0 0 1px 1px #26252b;
  40. }
  41. button.godot:active {
  42. color: #fff;
  43. background-color: #3e3b46;
  44. background-image: linear-gradient(to bottom, #36343d, #413e49);
  45. border: 1px solid #4f4c59;
  46. box-shadow: 0 0 1px 1px #26252b;
  47. }
  48. button.godot:disabled {
  49. color: rgba(230, 230, 230, 0.2);
  50. background-color: #3d3d3d;
  51. background-image: linear-gradient(to bottom, #434343, #393939);
  52. border: 1px solid #474747;
  53. box-shadow: 0 0 1px 1px #2d2b33;
  54. }
  55. /* Canvas / wrapper
  56. * ================ */
  57. #container {
  58. display: inline-block; /* scale with canvas */
  59. vertical-align: top; /* prevent extra height */
  60. position: relative; /* root for absolutely positioned overlay */
  61. margin: 0;
  62. border: 0 none;
  63. padding: 0;
  64. background-color: #111;
  65. }
  66. #canvas {
  67. display: block;
  68. margin: 0 auto;
  69. /* canvas must have border and padding set to zero to
  70. * calculate cursor coordinates correctly */
  71. border: 0 none;
  72. padding: 0;
  73. color: white;
  74. }
  75. /* Status display
  76. * ============== */
  77. #status-container {
  78. position: absolute;
  79. left: 0;
  80. top: 0;
  81. right: 0;
  82. bottom: 0;
  83. display: flex;
  84. justify-content: center;
  85. align-items: center;
  86. /* don't consume click events - make children visible explicitly */
  87. visibility: hidden;
  88. }
  89. #status {
  90. cursor: pointer;
  91. visibility: visible;
  92. padding: 4px 6px;
  93. }
  94. /* On-hover controls
  95. * ================= */
  96. #controls {
  97. visibility: hidden;
  98. opacity: 0.0;
  99. transition: opacity 500ms ease-in-out 200ms;
  100. position: absolute;
  101. right: 16px;
  102. top: 16px;
  103. padding: 3px 5px;
  104. font-size: small;
  105. -moz-user-select: none;
  106. -webkit-user-select: none;
  107. -ms-user-select: none;
  108. }
  109. #container:hover > #controls {
  110. opacity: 1.0;
  111. transition: opacity 60ms ease-in-out;
  112. }
  113. #controls > button,
  114. #controls > label {
  115. vertical-align: middle;
  116. margin-left: 2px;
  117. margin-right: 2px;
  118. }
  119. #controls > label > input[type="checkbox"] {
  120. /* override user agent style */
  121. margin-left: 0;
  122. }
  123. label > input {
  124. vertical-align: middle;
  125. }
  126. #display-output { display: none; }
  127. /* Debug output
  128. * ============ */
  129. #output {
  130. display: none;
  131. margin: 6px auto;
  132. border: 2px groove grey;
  133. padding: 4px;
  134. outline: none;
  135. text-align: left;
  136. white-space: pre-wrap;
  137. font-size: small;
  138. color: #eee;
  139. background-color: black;
  140. font-family: "Lucida Console", Monaco, monospace;
  141. }
  142. /* Export style include
  143. * ==================== */
  144. $GODOT_STYLE_INCLUDE
  145. </style>
  146. </head>
  147. <body>
  148. <div id="container">
  149. <canvas id="canvas" width="$GODOT_CANVAS_WIDTH" height="$GODOT_CANVAS_HEIGHT" onclick="canvas.ownerDocument.defaultView.focus();" oncontextmenu="event.preventDefault();">
  150. HTML5 canvas appears to be unsupported in the current browser.<br />Please try updating or use a different browser.
  151. </canvas>
  152. <div id="status-container">
  153. <span id="status" class="godot" onclick="this.style.visibility='hidden';">Loading page...</span>
  154. </div>
  155. <div id="controls" class="godot">
  156. <label id="display-output"><input id="output-toggle" type="checkbox" autocomplete="off" onchange="Presentation.setOutputVisible(this.checked);" />display output</label>
  157. <!-- hidden until implemented
  158. <label><input id="lock-cursor" type="checkbox" autocomplete="off" />lock cursor</label>
  159. <label><input id="resize-canvas" type="checkbox" autocomplete="off" />resize canvas</label>
  160. -->
  161. <button id="fullscreen" class="godot" type="button" disabled="disabled" autocomplete="off" onclick="Presentation.goFullscreen();">fullscreen</button>
  162. </div>
  163. </div>
  164. <!-- Firefox adds extra space to textarea, but shouldn't matter too much https://bugzilla.mozilla.org/show_bug.cgi?id=33654 -->
  165. <textarea id="output" rows="10" cols="100" readonly="readonly" style="resize:none"></textarea>
  166. <script type="text/javascript">//<![CDATA[
  167. var Presentation = (function() {
  168. var statusElement = document.getElementById("status");
  169. var outputElement = document.getElementById("output");
  170. var doneLoading = false;
  171. function onLoaded() {
  172. doneLoading = true;
  173. var fullscreenButtonElement = document.getElementById("fullscreen");
  174. fullscreenButtonElement.disabled = false;
  175. }
  176. var presentation = {
  177. statusElement: statusElement,
  178. outputElement: outputElement,
  179. postRun: [],
  180. setOutputVisible: function setOutputVisible(visible) {
  181. outputElement.style.display = (visible?"block":"none");
  182. },
  183. setStatusVisible: function setStatusVisible(visible) {
  184. statusElement.style.visibility = (visible?"visible":"hidden");
  185. },
  186. setStatus: function setStatus(text) {
  187. if (!text) {
  188. // emscripten sets empty string as status after "Running..."
  189. // per timeout, but another status may have been set by then
  190. if (Presentation.setStatus.lastText === "Running...") {
  191. Presentation.setStatusVisible(false);
  192. onLoaded();
  193. }
  194. } else {
  195. Presentation.setStatus.lastText = text;
  196. statusElement.innerHTML = text;
  197. Presentation.setStatusVisible(true);
  198. }
  199. },
  200. goFullscreen: function goFullscreen() {
  201. if (doneLoading) Module.requestFullScreen(false, false);
  202. }
  203. };
  204. window.onerror = function(event) { presentation.setStatus("Failure during start-up, see JavaScript console") };
  205. if ($GODOT_CONTROLS_ENABLED) { // controls enabled
  206. (function() {
  207. var controlsElement = document.getElementById("controls");
  208. controlsElement.style.visibility="visible";
  209. })();
  210. }
  211. if ($GODOT_DEBUG_ENABLED) { // debugging enabled
  212. (function() {
  213. var outputToggleLabel = document.getElementById("display-output");
  214. var outputToggle = document.getElementById("output-toggle");
  215. outputElement.value = ""; // clear browser cache
  216. outputElement.style.display = "block";
  217. outputToggle.checked = true;
  218. outputToggleLabel.style.display = "inline";
  219. presentation.print = function print(text) {
  220. if (outputElement.value.length !== 0)
  221. outputElement.value += "\n";
  222. outputElement.value += text;
  223. outputElement.scrollTop = outputElement.scrollHeight; // focus on bottom
  224. };
  225. })();
  226. presentation.postRun.push(function() {
  227. window.onerror = function(event) { presentation.print("**EXCEPTION**:", event) };
  228. });
  229. } else {
  230. presentation.postRun.push(function() { window.onerror = null; });
  231. }
  232. return presentation;
  233. })();
  234. // Emscripten interface
  235. var Module = (function() {
  236. var print = (function() {
  237. if (typeof Presentation.print === "function") {
  238. return function print(text) {
  239. if (arguments.length > 1)
  240. text = Array.prototype.slice.call(arguments).join(" ");
  241. console.log(text);
  242. Presentation.print(text);
  243. };
  244. } else {
  245. return function print(text) {
  246. if (arguments.length > 1)
  247. text = Array.prototype.slice.call(arguments).join(" ");
  248. console.log(text);
  249. };
  250. }
  251. })();
  252. var postRun = [];
  253. if (typeof Presentation !== "undefined" && Presentation.postRun instanceof Array) {
  254. postRun = Presentation.postRun;
  255. }
  256. var canvas = (function() {
  257. var canvasElement = document.getElementById("canvas");
  258. // As a default initial behavior, pop up an alert when WebGL context is lost. To make your
  259. // application robust, you may want to override this behavior before shipping!
  260. // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
  261. canvasElement.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false);
  262. return canvasElement;
  263. })();
  264. var setStatus = (function() {
  265. if (typeof Presentation.setStatus === "function")
  266. return function setStatus(text) {
  267. if (!Module.setStatus.last)
  268. Module.setStatus.last = { time: Date.now(), text: "" };
  269. if (text === Module.setStatus.text)
  270. return;
  271. var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
  272. var now = Date.now();
  273. if (m) {
  274. if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
  275. return;
  276. text = m[1];
  277. }
  278. Presentation.setStatus(text);
  279. };
  280. else
  281. return function setStatus(text) {
  282. if (!Module.setStatus.last)
  283. Module.setStatus.last = { time: Date.now(), text: "" };
  284. if (text === Module.setStatus.text)
  285. return;
  286. var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
  287. var now = Date.now();
  288. if (m) {
  289. if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
  290. return;
  291. text = m[1];
  292. }
  293. };
  294. })();
  295. return {
  296. TOTAL_MEMORY: $GODOT_TMEM,
  297. preRun: [],
  298. postRun: postRun,
  299. print: print,
  300. printErr: function printErr(text) {
  301. if (arguments.length > 1)
  302. text = Array.prototype.slice.call(arguments).join(" ");
  303. if (0) { // XXX disabled for safety `if (typeof dump == "function")`
  304. dump(text + "\n"); // fast, straight to the real console
  305. } else {
  306. console.error(text);
  307. }
  308. },
  309. canvas: canvas,
  310. setStatus: setStatus,
  311. totalDependencies: 0,
  312. monitorRunDependencies: function monitorRunDependencies(left) {
  313. this.totalDependencies = Math.max(this.totalDependencies, left);
  314. Module.setStatus(left ? "Preparing... (" + (this.totalDependencies-left) + "/" + this.totalDependencies + ")" : "All downloads complete.");
  315. }
  316. };
  317. })();
  318. Presentation.setStatus("Downloading...");
  319. (function() {
  320. var script = document.createElement('script');
  321. script.src = "$GODOT_ASM";
  322. script.onload = function() {
  323. setTimeout(function() {
  324. var memoryInitializer = '$GODOT_MEM';
  325. if (typeof Module.locateFile === 'function') {
  326. memoryInitializer = Module.locateFile(memoryInitializer);
  327. } else if (Module.memoryInitializerPrefixURL) {
  328. memoryInitializer = Module.memoryInitializerPrefixURL + memoryInitializer;
  329. }
  330. var xhr = Module.memoryInitializerRequest = new XMLHttpRequest();
  331. xhr.open('GET', memoryInitializer, true);
  332. xhr.responseType = 'arraybuffer';
  333. xhr.send(null);
  334. var script = document.createElement('script');
  335. script.src = "$GODOT_JS";
  336. script.onload = function() {
  337. Module.FS.createPreloadedFile('/data.pck', null, 'data.pck', true, true, null, null, false, true);
  338. };
  339. document.body.appendChild(script);
  340. }, 1); // delaying even 1ms is enough to allow compilation memory to be reclaimed
  341. };
  342. document.body.appendChild(script);
  343. })();
  344. //]]></script>
  345. </body>
  346. </html>