|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, minimal-ui, shrink-to-fit=no"> |
| 7 | + <meta name="apple-mobile-web-app-capable" content="yes"> |
| 8 | + <!-- The above 4 meta tags *must* come first in the head; any other head content must come *after* these tags --> |
| 9 | + |
| 10 | + <title>{{project.title}} {{project.version}}</title> |
| 11 | + <style type='text/css'> |
| 12 | + /* Disable user selection to avoid strange bug in Chrome on Windows: |
| 13 | + * Selecting a text outside the canvas, then clicking+draging would |
| 14 | + * drag the selected text but block mouse down/up events to the engine. |
| 15 | + */ |
| 16 | + body { |
| 17 | + {{^DEFOLD_SCALE_MODE_IS_NO_SCALE}} |
| 18 | + position: fixed; /* Prevent overscroll */ |
| 19 | + {{/DEFOLD_SCALE_MODE_IS_NO_SCALE}} |
| 20 | + margin:0; |
| 21 | + padding:0; |
| 22 | + } |
| 23 | + |
| 24 | + .canvas-app-container { |
| 25 | + width: 100%; |
| 26 | + height: 100%; |
| 27 | + position: absolute; |
| 28 | + align-items: center; |
| 29 | + justify-content: center; |
| 30 | + overflow: hidden; |
| 31 | + } |
| 32 | + |
| 33 | + .canvas-app-container:-webkit-full-screen { |
| 34 | + /* Auto width and height in Safari/Chrome fullscreen. */ |
| 35 | + width: auto; |
| 36 | + height: auto; |
| 37 | + } |
| 38 | + |
| 39 | + #canvas { |
| 40 | + outline: none; |
| 41 | + border: 0; |
| 42 | + width: 100%; |
| 43 | + vertical-align: bottom; |
| 44 | + } |
| 45 | + |
| 46 | + #canvas-container { |
| 47 | + position: relative; |
| 48 | + } |
| 49 | + |
| 50 | + canvas:focus, canvas:active { |
| 51 | + outline: none; |
| 52 | + border: 0; |
| 53 | + ie-dummy: expression(this.hideFocus=true); |
| 54 | + -moz-outline-style: none; |
| 55 | + } |
| 56 | + |
| 57 | + div { |
| 58 | + -webkit-tap-highlight-color: rgba(0,0,0,0); |
| 59 | + -webkit-touch-callout: none; |
| 60 | + -webkit-user-select: none; |
| 61 | + -khtml-user-select: none; |
| 62 | + -moz-user-select: none; |
| 63 | + -ms-user-select: none; |
| 64 | + user-select: none; |
| 65 | + } |
| 66 | + |
| 67 | + {{{DEFOLD_CUSTOM_CSS_INLINE}}} |
| 68 | + </style> |
| 69 | +</head> |
| 70 | + |
| 71 | +<body> |
| 72 | + <div id="app-container" class="canvas-app-container"> |
| 73 | + <div id="canvas-container" class="canvas-app-canvas-container"> |
| 74 | + <canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="{{display.width}}" height="{{display.height}}"></canvas> |
| 75 | + <div style="position: absolute; bottom: 0px; left: 50%;"> |
| 76 | + <div id="canvas-ad" style="width: 728px; height:90px; margin-left: -50%;"/> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + <!-- --> |
| 81 | + <script id='engine-loader' type='text/javascript' src="dmloader.js"></script> |
| 82 | + <!-- --> |
| 83 | + <script id='engine-setup' type='text/javascript'> |
| 84 | + var extra_params = { |
| 85 | + archive_location_filter: function( path ) { |
| 86 | + return ("{{DEFOLD_ARCHIVE_LOCATION_PREFIX}}" + path + "{{DEFOLD_ARCHIVE_LOCATION_SUFFIX}}"); |
| 87 | + }, |
| 88 | + engine_arguments: [{{#DEFOLD_ENGINE_ARGUMENTS}}"{{.}}",{{/DEFOLD_ENGINE_ARGUMENTS}}], |
| 89 | + custom_heap_size: {{DEFOLD_HEAP_SIZE}}, |
| 90 | + full_screen_container: "#canvas-container", |
| 91 | + disable_context_menu: true |
| 92 | + } |
| 93 | + |
| 94 | + Module['onRuntimeInitialized'] = function() { |
| 95 | + Module.runApp("canvas", extra_params); |
| 96 | + }; |
| 97 | + |
| 98 | + Module["locateFile"] = function(path, scriptDirectory) |
| 99 | + { |
| 100 | + // dmengine*.wasm is hardcoded in the built JS loader for WASM, |
| 101 | + // we need to replace it here with the correct project name. |
| 102 | + if (path == "dmengine.wasm" || path == "dmengine_release.wasm" || path == "dmengine_headless.wasm") { |
| 103 | + path = "{{exe-name}}.wasm"; |
| 104 | + } |
| 105 | + return scriptDirectory + path; |
| 106 | + }; |
| 107 | + |
| 108 | + var is_iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; |
| 109 | + var buttonHeight = 0; |
| 110 | +{{#html5.show_made_with_defold}} |
| 111 | + buttonHeight = 42; |
| 112 | +{{/html5.show_made_with_defold}} |
| 113 | +{{#html5.show_fullscreen_button}} |
| 114 | + buttonHeight = 42; |
| 115 | +{{/html5.show_fullscreen_button}} |
| 116 | + // Resize on init, screen resize and orientation change |
| 117 | + function resize_game_canvas() { |
| 118 | + // Hack for iOS when exit from Fullscreen mode |
| 119 | + if (is_iOS) { |
| 120 | + window.scrollTo(0, 0); |
| 121 | + } |
| 122 | + |
| 123 | + var app_container = document.getElementById('app-container'); |
| 124 | + var game_canvas = document.getElementById('canvas'); |
| 125 | + var innerWidth = window.innerWidth; |
| 126 | + var innerHeight = window.innerHeight - buttonHeight; |
| 127 | + var width = {{display.width}}; |
| 128 | + var height = {{display.height}}; |
| 129 | + var targetRatio = width / height; |
| 130 | + var actualRatio = innerWidth / innerHeight; |
| 131 | + {{#DEFOLD_SCALE_MODE_IS_DOWNSCALE_FIT}} |
| 132 | + //Downscale fit |
| 133 | + if (innerWidth < width || innerHeight < height) { |
| 134 | + if (actualRatio > targetRatio) { |
| 135 | + width = innerHeight * targetRatio; |
| 136 | + height = innerHeight; |
| 137 | + app_container.style.marginLeft = ((innerWidth - width) / 2) + "px"; |
| 138 | + app_container.style.marginTop = "0px"; |
| 139 | + } |
| 140 | + else { |
| 141 | + width = innerWidth; |
| 142 | + height = innerWidth / targetRatio; |
| 143 | + app_container.style.marginLeft = "0px"; |
| 144 | + app_container.style.marginTop = ((innerHeight - height) / 2) + "px"; |
| 145 | + } |
| 146 | + } |
| 147 | + else { |
| 148 | + app_container.style.marginLeft = ((innerWidth - width) / 2) + "px"; |
| 149 | + app_container.style.marginTop = ((innerHeight - height) / 2) + "px"; |
| 150 | + } |
| 151 | + {{/DEFOLD_SCALE_MODE_IS_DOWNSCALE_FIT}} |
| 152 | + {{#DEFOLD_SCALE_MODE_IS_STRETCH}} |
| 153 | + //Stretch |
| 154 | + width = innerWidth; |
| 155 | + height = innerHeight; |
| 156 | + {{/DEFOLD_SCALE_MODE_IS_STRETCH}} |
| 157 | + {{#DEFOLD_SCALE_MODE_IS_FIT}} |
| 158 | + //Fit |
| 159 | + if (actualRatio > targetRatio) { |
| 160 | + width = innerHeight * targetRatio; |
| 161 | + height = innerHeight; |
| 162 | + app_container.style.marginLeft = ((innerWidth - width) / 2) + "px"; |
| 163 | + app_container.style.marginTop = "0px"; |
| 164 | + } |
| 165 | + else { |
| 166 | + width = innerWidth; |
| 167 | + height = innerWidth / targetRatio; |
| 168 | + app_container.style.marginLeft = "0px"; |
| 169 | + app_container.style.marginTop = ((innerHeight - height) / 2) + "px"; |
| 170 | + } |
| 171 | + {{/DEFOLD_SCALE_MODE_IS_FIT}} |
| 172 | + {{#DEFOLD_SCALE_MODE_IS_NO_SCALE}} |
| 173 | + //No scale |
| 174 | + var margin_left = ((innerWidth - width) / 2); |
| 175 | + margin_left = margin_left > 0 ? margin_left : 0; |
| 176 | + var margin_top = ((innerHeight - height) / 2); |
| 177 | + margin_top = margin_top > 0 ? margin_top : 0; |
| 178 | + app_container.style.marginLeft = margin_left + "px"; |
| 179 | + app_container.style.marginTop = margin_top + "px"; |
| 180 | + {{/DEFOLD_SCALE_MODE_IS_NO_SCALE}} |
| 181 | + app_container.style.width = width + "px"; |
| 182 | + app_container.style.height = height + buttonHeight + "px"; |
| 183 | + game_canvas.width = width; |
| 184 | + game_canvas.height = height; |
| 185 | + } |
| 186 | + resize_game_canvas(); |
| 187 | + window.addEventListener('resize', resize_game_canvas, false); |
| 188 | + window.addEventListener('orientationchange', resize_game_canvas, false); |
| 189 | + </script> |
| 190 | + |
| 191 | + <script id='engine-start' type='text/javascript'> |
| 192 | + EngineLoader.load("canvas", "{{exe-name}}"); |
| 193 | + </script> |
| 194 | +</body> |
| 195 | +</html> |
0 commit comments