full-size.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <!DOCTYPE html>
  2. <html xmlns='http://www.w3.org/1999/xhtml' lang='' xml:lang=''>
  3. <head>
  4. <meta charset='utf-8' />
  5. <meta name='viewport' content='width=device-width, user-scalable=no' />
  6. <title>$GODOT_PROJECT_NAME</title>
  7. <style type='text/css'>
  8. body {
  9. touch-action: none;
  10. margin: 0;
  11. border: 0 none;
  12. padding: 0;
  13. text-align: center;
  14. background-color: black;
  15. }
  16. #canvas {
  17. display: block;
  18. margin: 0;
  19. color: white;
  20. }
  21. #canvas:focus {
  22. outline: none;
  23. }
  24. .godot {
  25. font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;
  26. color: #e0e0e0;
  27. background-color: #3b3943;
  28. background-image: linear-gradient(to bottom, #403e48, #35333c);
  29. border: 1px solid #45434e;
  30. box-shadow: 0 0 1px 1px #2f2d35;
  31. }
  32. /* Status display
  33. * ============== */
  34. #status {
  35. position: absolute;
  36. left: 0;
  37. top: 0;
  38. right: 0;
  39. bottom: 0;
  40. display: flex;
  41. justify-content: center;
  42. align-items: center;
  43. /* don't consume click events - make children visible explicitly */
  44. visibility: hidden;
  45. }
  46. #status-progress {
  47. width: 366px;
  48. height: 7px;
  49. background-color: #38363A;
  50. border: 1px solid #444246;
  51. padding: 1px;
  52. box-shadow: 0 0 2px 1px #1B1C22;
  53. border-radius: 2px;
  54. visibility: visible;
  55. }
  56. @media only screen and (orientation:portrait) {
  57. #status-progress {
  58. width: 61.8%;
  59. }
  60. }
  61. #status-progress-inner {
  62. height: 100%;
  63. width: 0;
  64. box-sizing: border-box;
  65. transition: width 0.5s linear;
  66. background-color: #202020;
  67. border: 1px solid #222223;
  68. box-shadow: 0 0 1px 1px #27282E;
  69. border-radius: 3px;
  70. }
  71. #status-indeterminate {
  72. height: 42px;
  73. visibility: visible;
  74. position: relative;
  75. }
  76. #status-indeterminate > div {
  77. width: 4.5px;
  78. height: 0;
  79. border-style: solid;
  80. border-width: 9px 3px 0 3px;
  81. border-color: #2b2b2b transparent transparent transparent;
  82. transform-origin: center 21px;
  83. position: absolute;
  84. }
  85. #status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); }
  86. #status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); }
  87. #status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); }
  88. #status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); }
  89. #status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); }
  90. #status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); }
  91. #status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); }
  92. #status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); }
  93. #status-notice {
  94. margin: 0 100px;
  95. line-height: 1.3;
  96. visibility: visible;
  97. padding: 4px 6px;
  98. visibility: visible;
  99. }
  100. </style>
  101. $GODOT_HEAD_INCLUDE
  102. </head>
  103. <body>
  104. <canvas id='canvas'>
  105. HTML5 canvas appears to be unsupported in the current browser.<br />
  106. Please try updating or use a different browser.
  107. </canvas>
  108. <div id='status'>
  109. <div id='status-progress' style='display: none;' oncontextmenu='event.preventDefault();'><div id ='status-progress-inner'></div></div>
  110. <div id='status-indeterminate' style='display: none;' oncontextmenu='event.preventDefault();'>
  111. <div></div>
  112. <div></div>
  113. <div></div>
  114. <div></div>
  115. <div></div>
  116. <div></div>
  117. <div></div>
  118. <div></div>
  119. </div>
  120. <div id='status-notice' class='godot' style='display: none;'></div>
  121. </div>
  122. <script type='text/javascript' src='$GODOT_URL'></script>
  123. <script type='text/javascript'>//<![CDATA[
  124. const GODOT_CONFIG = $GODOT_CONFIG;
  125. var engine = new Engine(GODOT_CONFIG);
  126. (function() {
  127. const INDETERMINATE_STATUS_STEP_MS = 100;
  128. var statusProgress = document.getElementById('status-progress');
  129. var statusProgressInner = document.getElementById('status-progress-inner');
  130. var statusIndeterminate = document.getElementById('status-indeterminate');
  131. var statusNotice = document.getElementById('status-notice');
  132. var initializing = true;
  133. var statusMode = 'hidden';
  134. var animationCallbacks = [];
  135. function animate(time) {
  136. animationCallbacks.forEach(callback => callback(time));
  137. requestAnimationFrame(animate);
  138. }
  139. requestAnimationFrame(animate);
  140. function setStatusMode(mode) {
  141. if (statusMode === mode || !initializing)
  142. return;
  143. [statusProgress, statusIndeterminate, statusNotice].forEach(elem => {
  144. elem.style.display = 'none';
  145. });
  146. animationCallbacks = animationCallbacks.filter(function(value) {
  147. return (value != animateStatusIndeterminate);
  148. });
  149. switch (mode) {
  150. case 'progress':
  151. statusProgress.style.display = 'block';
  152. break;
  153. case 'indeterminate':
  154. statusIndeterminate.style.display = 'block';
  155. animationCallbacks.push(animateStatusIndeterminate);
  156. break;
  157. case 'notice':
  158. statusNotice.style.display = 'block';
  159. break;
  160. case 'hidden':
  161. break;
  162. default:
  163. throw new Error('Invalid status mode');
  164. }
  165. statusMode = mode;
  166. }
  167. function animateStatusIndeterminate(ms) {
  168. var i = Math.floor(ms / INDETERMINATE_STATUS_STEP_MS % 8);
  169. if (statusIndeterminate.children[i].style.borderTopColor == '') {
  170. Array.prototype.slice.call(statusIndeterminate.children).forEach(child => {
  171. child.style.borderTopColor = '';
  172. });
  173. statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf';
  174. }
  175. }
  176. function setStatusNotice(text) {
  177. while (statusNotice.lastChild) {
  178. statusNotice.removeChild(statusNotice.lastChild);
  179. }
  180. var lines = text.split('\n');
  181. lines.forEach((line) => {
  182. statusNotice.appendChild(document.createTextNode(line));
  183. statusNotice.appendChild(document.createElement('br'));
  184. });
  185. };
  186. function displayFailureNotice(err) {
  187. var msg = err.message || err;
  188. console.error(msg);
  189. setStatusNotice(msg);
  190. setStatusMode('notice');
  191. initializing = false;
  192. };
  193. if (!Engine.isWebGLAvailable()) {
  194. displayFailureNotice('WebGL not available');
  195. } else {
  196. setStatusMode('indeterminate');
  197. engine.startGame({
  198. 'onProgress': function (current, total) {
  199. if (total > 0) {
  200. statusProgressInner.style.width = current/total * 100 + '%';
  201. setStatusMode('progress');
  202. if (current === total) {
  203. // wait for progress bar animation
  204. setTimeout(() => {
  205. setStatusMode('indeterminate');
  206. }, 500);
  207. }
  208. } else {
  209. setStatusMode('indeterminate');
  210. }
  211. },
  212. }).then(() => {
  213. setStatusMode('hidden');
  214. initializing = false;
  215. }, displayFailureNotice);
  216. }
  217. })();
  218. //]]></script>
  219. </body>
  220. </html>