fixed-size.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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" 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 engine = new Engine;
  199. (function() {
  200. const MAIN_PACK = '$GODOT_BASENAME.pck';
  201. const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED;
  202. const INDETERMINATE_STATUS_STEP_MS = 100;
  203. var container = document.getElementById('container');
  204. var canvas = document.getElementById('canvas');
  205. var statusProgress = document.getElementById('status-progress');
  206. var statusProgressInner = document.getElementById('status-progress-inner');
  207. var statusIndeterminate = document.getElementById('status-indeterminate');
  208. var statusNotice = document.getElementById('status-notice');
  209. var initializing = true;
  210. var statusMode = 'hidden';
  211. var indeterminiateStatusAnimationId = 0;
  212. function setStatusMode(mode) {
  213. if (statusMode === mode || !initializing)
  214. return;
  215. [statusProgress, statusIndeterminate, statusNotice].forEach(elem => {
  216. elem.style.display = 'none';
  217. });
  218. if (indeterminiateStatusAnimationId !== 0) {
  219. cancelAnimationFrame(indeterminiateStatusAnimationId);
  220. indeterminiateStatusAnimationId = 0;
  221. }
  222. switch (mode) {
  223. case 'progress':
  224. statusProgress.style.display = 'block';
  225. break;
  226. case 'indeterminate':
  227. statusIndeterminate.style.display = 'block';
  228. indeterminiateStatusAnimationId = requestAnimationFrame(animateStatusIndeterminate);
  229. break;
  230. case 'notice':
  231. statusNotice.style.display = 'block';
  232. break;
  233. case 'hidden':
  234. break;
  235. default:
  236. throw new Error("Invalid status mode");
  237. }
  238. statusMode = mode;
  239. }
  240. function animateStatusIndeterminate(ms) {
  241. var i = Math.floor(ms / INDETERMINATE_STATUS_STEP_MS % 8);
  242. if (statusIndeterminate.children[i].style.borderTopColor == '') {
  243. Array.prototype.slice.call(statusIndeterminate.children).forEach(child => {
  244. child.style.borderTopColor = '';
  245. });
  246. statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf';
  247. }
  248. requestAnimationFrame(animateStatusIndeterminate);
  249. }
  250. function setStatusNotice(text) {
  251. while (statusNotice.lastChild) {
  252. statusNotice.removeChild(statusNotice.lastChild);
  253. }
  254. var lines = text.split('\n');
  255. lines.forEach((line, index) => {
  256. statusNotice.appendChild(document.createTextNode(line));
  257. statusNotice.appendChild(document.createElement('br'));
  258. });
  259. };
  260. engine.setProgressFunc((current, total) => {
  261. if (total > 0) {
  262. statusProgressInner.style.width = current/total * 100 + '%';
  263. setStatusMode('progress');
  264. if (current === total) {
  265. // wait for progress bar animation
  266. setTimeout(() => {
  267. setStatusMode('indeterminate');
  268. }, 500);
  269. }
  270. } else {
  271. setStatusMode('indeterminate');
  272. }
  273. });
  274. if (DEBUG_ENABLED) {
  275. var outputRoot = document.getElementById("output-panel");
  276. var outputScroll = document.getElementById("output-scroll");
  277. var OUTPUT_MSG_COUNT_MAX = 400;
  278. document.getElementById('output-clear').addEventListener('click', () => {
  279. while (outputScroll.firstChild) {
  280. outputScroll.firstChild.remove();
  281. }
  282. });
  283. outputRoot.style.display = 'block';
  284. function print(text) {
  285. while (outputScroll.childElementCount >= OUTPUT_MSG_COUNT_MAX) {
  286. outputScroll.firstChild.remove();
  287. }
  288. var msg = document.createElement("div");
  289. if (String.prototype.trim.call(text).startsWith("**ERROR**")) {
  290. msg.style.color = "#d44";
  291. } else if (String.prototype.trim.call(text).startsWith("**WARNING**")) {
  292. msg.style.color = "#ccc000";
  293. } else if (String.prototype.trim.call(text).startsWith("**SCRIPT ERROR**")) {
  294. msg.style.color = "#c6d";
  295. }
  296. msg.textContent = text;
  297. var scrollToBottom = outputScroll.scrollHeight - (outputScroll.clientHeight + outputScroll.scrollTop) < 10;
  298. outputScroll.appendChild(msg);
  299. if (scrollToBottom) {
  300. outputScroll.scrollTop = outputScroll.scrollHeight;
  301. }
  302. };
  303. function printError(text) {
  304. if (!String.prototype.trim.call(text).startsWith('**ERROR**: ')) {
  305. text = '**ERROR**: ' + text;
  306. }
  307. print(text);
  308. }
  309. engine.setStdoutFunc(text => {
  310. print(text);
  311. console.log(text);
  312. });
  313. engine.setStderrFunc(text => {
  314. printError(text);
  315. console.warn(text);
  316. });
  317. }
  318. function displayFailureNotice(err) {
  319. var msg = err.message || err;
  320. if (DEBUG_ENABLED) {
  321. printError(msg);
  322. }
  323. console.error(msg);
  324. setStatusNotice(msg);
  325. setStatusMode('notice');
  326. initializing = false;
  327. };
  328. if (!Engine.isWebGLAvailable()) {
  329. displayFailureNotice("WebGL not available");
  330. } else {
  331. setStatusMode('indeterminate');
  332. engine.setCanvas(canvas);
  333. engine.startGame(MAIN_PACK).then(() => {
  334. setStatusMode('hidden');
  335. initializing = false;
  336. }, displayFailureNotice);
  337. }
  338. })();
  339. //]]></script>
  340. </body>
  341. </html>