default.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title></title>
  6. <style type="text/css">
  7. body {
  8. margin: 0;
  9. border: 0 none;
  10. padding: 0;
  11. text-align: center;
  12. background-color: #222226;
  13. font-family: 'Noto Sans', Arial, sans-serif;
  14. }
  15. /* Godot Engine default theme style
  16. * ================================ */
  17. .godot {
  18. color: #e0e0e0;
  19. background-color: #3b3943;
  20. background-image: linear-gradient(to bottom, #403e48, #35333c);
  21. border: 1px solid #45434e;
  22. box-shadow: 0 0 1px 1px #2f2d35;
  23. }
  24. button.godot {
  25. font-family: 'Droid Sans', Arial, sans-serif; /* override user agent style */
  26. padding: 1px 5px;
  27. background-color: #37353f;
  28. background-image: linear-gradient(to bottom, #413e49, #3a3842);
  29. border: 1px solid #514f5d;
  30. border-radius: 1px;
  31. box-shadow: 0 0 1px 1px #2a2930;
  32. }
  33. button.godot:hover {
  34. color: #f0f0f0;
  35. background-color: #44414e;
  36. background-image: linear-gradient(to bottom, #494652, #423f4c);
  37. border: 1px solid #5a5667;
  38. box-shadow: 0 0 1px 1px #26252b;
  39. }
  40. button.godot:active {
  41. color: #fff;
  42. background-color: #3e3b46;
  43. background-image: linear-gradient(to bottom, #36343d, #413e49);
  44. border: 1px solid #4f4c59;
  45. box-shadow: 0 0 1px 1px #26252b;
  46. }
  47. button.godot:disabled {
  48. color: rgba(230, 230, 230, 0.2);
  49. background-color: #3d3d3d;
  50. background-image: linear-gradient(to bottom, #434343, #393939);
  51. border: 1px solid #474747;
  52. box-shadow: 0 0 1px 1px #2d2b33;
  53. }
  54. /* Canvas / wrapper
  55. * ================ */
  56. #container {
  57. display: inline-block; /* scale with canvas */
  58. vertical-align: top; /* prevent extra height */
  59. position: relative; /* root for absolutely positioned overlay */
  60. margin: 0;
  61. border: 0 none;
  62. padding: 0;
  63. background-color: #0c0c0c;
  64. }
  65. #canvas {
  66. display: block;
  67. margin: 0 auto;
  68. color: white;
  69. }
  70. #canvas:focus {
  71. outline: none;
  72. }
  73. /* Status display
  74. * ============== */
  75. #status {
  76. position: absolute;
  77. left: 0;
  78. top: 0;
  79. right: 0;
  80. bottom: 0;
  81. display: flex;
  82. justify-content: center;
  83. align-items: center;
  84. /* don't consume click events - make children visible explicitly */
  85. visibility: hidden;
  86. }
  87. #status-progress {
  88. width: 244px;
  89. height: 7px;
  90. background-color: #38363A;
  91. border: 1px solid #444246;
  92. padding: 1px;
  93. box-shadow: 0 0 2px 1px #1B1C22;
  94. border-radius: 2px;
  95. visibility: visible;
  96. }
  97. #status-progress-inner {
  98. height: 100%;
  99. width: 0;
  100. box-sizing: border-box;
  101. transition: width 0.5s linear;
  102. background-color: #202020;
  103. border: 1px solid #222223;
  104. box-shadow: 0 0 1px 1px #27282E;
  105. border-radius: 3px;
  106. }
  107. #status-indeterminate {
  108. visibility: visible;
  109. position: relative;
  110. }
  111. #status-indeterminate > div {
  112. width: 3px;
  113. height: 0;
  114. border-style: solid;
  115. border-width: 6px 2px 0 2px;
  116. border-color: #2b2b2b transparent transparent transparent;
  117. transform-origin: center 14px;
  118. position: absolute;
  119. }
  120. #status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); }
  121. #status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); }
  122. #status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); }
  123. #status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); }
  124. #status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); }
  125. #status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); }
  126. #status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); }
  127. #status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); }
  128. #status-notice {
  129. margin: 0 100px;
  130. line-height: 1.3;
  131. visibility: visible;
  132. padding: 4px 6px;
  133. visibility: visible;
  134. }
  135. /* Debug output
  136. * ============ */
  137. #output-panel {
  138. display: none;
  139. max-width: 700px;
  140. font-size: small;
  141. margin: 6px auto 0;
  142. padding: 0 4px 4px;
  143. text-align: left;
  144. line-height: 2.2;
  145. }
  146. #output-header {
  147. display: flex;
  148. justify-content: space-between;
  149. align-items: center;
  150. }
  151. #output-container {
  152. padding: 6px;
  153. background-color: #2c2a32;
  154. box-shadow: inset 0 0 1px 1px #232127;
  155. color: #bbb;
  156. }
  157. #output-scroll {
  158. line-height: 1;
  159. height: 12em;
  160. overflow-y: scroll;
  161. white-space: pre-wrap;
  162. font-size: small;
  163. font-family: "Lucida Console", Monaco, monospace;
  164. }
  165. </style>
  166. $GODOT_HEAD_INCLUDE
  167. </head>
  168. <body>
  169. <div id="container">
  170. <canvas id="canvas" oncontextmenu="event.preventDefault();" width="640" height="480">
  171. HTML5 canvas appears to be unsupported in the current browser.<br />
  172. Please try updating or use a different browser.
  173. </canvas>
  174. <div id="status">
  175. <div id='status-progress' style='display: none;' oncontextmenu="event.preventDefault();"><div id ='status-progress-inner'></div></div>
  176. <div id='status-indeterminate' style='display: none;' oncontextmenu="event.preventDefault();">
  177. <div></div>
  178. <div></div>
  179. <div></div>
  180. <div></div>
  181. <div></div>
  182. <div></div>
  183. <div></div>
  184. <div></div>
  185. </div>
  186. <div id="status-notice" class="godot" style='display: none;'></div>
  187. </div>
  188. </div>
  189. <div id="output-panel" class="godot">
  190. <div id="output-header">
  191. Output:
  192. <button id='output-clear' class='godot' type='button' autocomplete='off'>Clear</button>
  193. </div>
  194. <div id="output-container"><div id="output-scroll"></div></div>
  195. </div>
  196. <script type="text/javascript" src="$GODOT_BASENAME.js"></script>
  197. <script type="text/javascript">//<![CDATA[
  198. var game = new Engine;
  199. (function() {
  200. const BASENAME = '$GODOT_BASENAME';
  201. const MEMORY_SIZE = $GODOT_TOTAL_MEMORY;
  202. const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED;
  203. const INDETERMINATE_STATUS_STEP_MS = 100;
  204. var container = document.getElementById('container');
  205. var canvas = document.getElementById('canvas');
  206. var statusProgress = document.getElementById('status-progress');
  207. var statusProgressInner = document.getElementById('status-progress-inner');
  208. var statusIndeterminate = document.getElementById('status-indeterminate');
  209. var statusNotice = document.getElementById('status-notice');
  210. var initializing = true;
  211. var statusMode = 'hidden';
  212. var indeterminiateStatusAnimationId = 0;
  213. setStatusMode('indeterminate');
  214. game.setCanvas(canvas);
  215. game.setAsmjsMemorySize(MEMORY_SIZE);
  216. function setStatusMode(mode) {
  217. if (statusMode === mode || !initializing)
  218. return;
  219. [statusProgress, statusIndeterminate, statusNotice].forEach(elem => {
  220. elem.style.display = 'none';
  221. });
  222. if (indeterminiateStatusAnimationId !== 0) {
  223. cancelAnimationFrame(indeterminiateStatusAnimationId);
  224. indeterminiateStatusAnimationId = 0;
  225. }
  226. switch (mode) {
  227. case 'progress':
  228. statusProgress.style.display = 'block';
  229. break;
  230. case 'indeterminate':
  231. statusIndeterminate.style.display = 'block';
  232. indeterminiateStatusAnimationId = requestAnimationFrame(animateStatusIndeterminate);
  233. break;
  234. case 'notice':
  235. statusNotice.style.display = 'block';
  236. break;
  237. case 'hidden':
  238. break;
  239. default:
  240. throw new Error("Invalid status mode");
  241. }
  242. statusMode = mode;
  243. }
  244. function animateStatusIndeterminate(ms) {
  245. var i = Math.floor(ms / INDETERMINATE_STATUS_STEP_MS % 8);
  246. if (statusIndeterminate.children[i].style.borderTopColor == '') {
  247. Array.prototype.slice.call(statusIndeterminate.children).forEach(child => {
  248. child.style.borderTopColor = '';
  249. });
  250. statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf';
  251. }
  252. requestAnimationFrame(animateStatusIndeterminate);
  253. }
  254. function setStatusNotice(text) {
  255. while (statusNotice.lastChild) {
  256. statusNotice.removeChild(statusNotice.lastChild);
  257. }
  258. var lines = text.split('\n');
  259. lines.forEach((line, index) => {
  260. statusNotice.appendChild(document.createTextNode(line));
  261. statusNotice.appendChild(document.createElement('br'));
  262. });
  263. };
  264. game.setProgressFunc((current, total) => {
  265. if (total > 0) {
  266. statusProgressInner.style.width = current/total * 100 + '%';
  267. setStatusMode('progress');
  268. if (current === total) {
  269. // wait for progress bar animation
  270. setTimeout(() => {
  271. setStatusMode('indeterminate');
  272. }, 500);
  273. }
  274. } else {
  275. setStatusMode('indeterminate');
  276. }
  277. });
  278. if (DEBUG_ENABLED) {
  279. var outputRoot = document.getElementById("output-panel");
  280. var outputScroll = document.getElementById("output-scroll");
  281. var OUTPUT_MSG_COUNT_MAX = 400;
  282. document.getElementById('output-clear').addEventListener('click', () => {
  283. while (outputScroll.firstChild) {
  284. outputScroll.firstChild.remove();
  285. }
  286. });
  287. outputRoot.style.display = 'block';
  288. function print(text) {
  289. if (arguments.length > 1) {
  290. text = Array.prototype.slice.call(arguments).join(" ");
  291. }
  292. if (text.length <= 0) return;
  293. while (outputScroll.childElementCount >= OUTPUT_MSG_COUNT_MAX) {
  294. outputScroll.firstChild.remove();
  295. }
  296. var msg = document.createElement("div");
  297. if (String.prototype.trim.call(text).startsWith("**ERROR**")) {
  298. msg.style.color = "#d44";
  299. } else if (String.prototype.trim.call(text).startsWith("**WARNING**")) {
  300. msg.style.color = "#ccc000";
  301. } else if (String.prototype.trim.call(text).startsWith("**SCRIPT ERROR**")) {
  302. msg.style.color = "#c6d";
  303. }
  304. msg.textContent = text;
  305. var scrollToBottom = outputScroll.scrollHeight - (outputScroll.clientHeight + outputScroll.scrollTop) < 10;
  306. outputScroll.appendChild(msg);
  307. if (scrollToBottom) {
  308. outputScroll.scrollTop = outputScroll.scrollHeight;
  309. }
  310. };
  311. function printError(text) {
  312. print('**ERROR**' + ":", text);
  313. }
  314. game.setStdoutFunc(text => {
  315. print(text);
  316. console.log(text);
  317. });
  318. game.setStderrFunc(text => {
  319. printError(text);
  320. console.warn(text);
  321. });
  322. }
  323. game.start(BASENAME + '.pck').then(() => {
  324. setStatusMode('hidden');
  325. initializing = false;
  326. }, err => {
  327. if (DEBUG_ENABLED)
  328. printError(err.message);
  329. setStatusNotice(err.message);
  330. setStatusMode('notice');
  331. initializing = false;
  332. });
  333. })();
  334. //]]></script>
  335. </body>
  336. </html>