-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
152 lines (134 loc) · 5.25 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no,width=device-width,minimal-ui" />
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>{{DEFOLD_APP_TITLE}}</title>
<style>
canvas {
vertical-align: middle;
}
.canvas-app-container {
/* A positioned parent for loading visuals */
width: 100%;
height: 100%;
position: absolute;
align-items: center;
justify-content: center;
overflow: hidden;
background: #0e1618;
}
.canvas-app-progress {
visibility: hidden;
}
.canvas-app-progress-bar {
visibility: hidden;
}
* { margin:0; padding:0; }
#canvas {
outline: none;
border: 0;
width: 100%;
}
canvas:focus, canvas:active {
outline: none;
border: 0;
ie-dummy: expression(this.hideFocus=true);
-moz-outline-style: none;
}
div {
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
body {
position: fixed; /* Prevent overscroll */
background-color: rgb(0, 0, 0);
}
</style>
</head>
<body oncontextmenu="return false;">
<div id="fb-root"></div>
<div id="app-container" class="canvas-app-container">
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="{{DEFOLD_DISPLAY_WIDTH}}" height="{{DEFOLD_DISPLAY_HEIGHT}}"></canvas>
</div>
<!-- -->
{{{DEFOLD_DEV_INLINE}}}
<script type='text/javascript' src="dmloader.js"></script>
<script type='text/javascript'>
var extra_params = {
archive_location_filter: function( path ) {
return ("{{DEFOLD_ARCHIVE_LOCATION_PREFIX}}" + path + "{{DEFOLD_ARCHIVE_LOCATION_SUFFIX}}");
},
{{#HAS_DEFOLD_ENGINE_ARGUMENTS}}
engine_arguments: ["{{DEFOLD_ENGINE_ARGUMENTS}}"],
{{/HAS_DEFOLD_ENGINE_ARGUMENTS}}
//engine_arguments: ["--verify-graphics-calls=false"],
splash_image: "{{DEFOLD_SPLASH_IMAGE}}",
custom_heap_size: {{DEFOLD_HEAP_SIZE}}
}
Module['onRuntimeInitialized'] = function() {
Module.runApp("canvas", extra_params);
};
Module["locateFile"] = function(path, scriptDirectory)
{
// dmengine*.wasm is hardcoded in the built JS loader for WASM,
// we need to replace it here with the correct project name.
if (path == "dmengine.wasm" || path == "dmengine_release.wasm" || path == "dmengine_headless.wasm") {
path = "{{DEFOLD_BINARY_PREFIX}}.wasm";
}
return scriptDirectory + path;
};
function load_engine() {
var engineJS = document.createElement('script');
engineJS.type = 'text/javascript';
if (Module['isWASMSupported']) {
engineJS.src = '{{DEFOLD_BINARY_PREFIX}}_wasm.js';
} else {
engineJS.src = '{{DEFOLD_BINARY_PREFIX}}_asmjs.js';
}
document.head.appendChild(engineJS);
}
// Make sure to resize the canvas to cover entire available area
// Resize on init, screen resize and orientation change
function resize_game_canvas() {
var app_container = document.getElementById('app-container');
var game_canvas = document.getElementById('canvas');
var dpi=window.devicePixelRatio || 1
var width=window.innerWidth;
var height=window.innerHeight;
var targetRatio = {{DEFOLD_DISPLAY_WIDTH}}/{{DEFOLD_DISPLAY_HEIGHT}};
var actualRatio = width/height;
if (actualRatio > targetRatio) {
width = height * targetRatio;
app_container.style.marginLeft = ((window.innerWidth - width) / 2) + "px"
app_container.style.marginTop = "0px"
}
else {
height = width / targetRatio;
app_container.style.marginLeft = "0px"
app_container.style.marginTop = ((window.innerHeight - height) / 2) + "px"
}
app_container.style.width = width+"px";
app_container.style.height = height+"px";
game_canvas.width = width*dpi;
game_canvas.height = height*dpi;
window.console.log("width: " + game_canvas.width + " > "+ game_canvas.style.width)
window.console.log("height:" + game_canvas.height + " > "+ game_canvas.style.height)
}
resize_game_canvas();
window.addEventListener('resize', resize_game_canvas, false);
window.addEventListener('orientationchange', resize_game_canvas, false);
if ({{DEFOLD_HAS_FACEBOOK_APP_ID}}) {
// Load Facebook API
var fb = document.createElement('script');
fb.type = 'text/javascript';
fb.src = '//connect.facebook.net/en_US/sdk.js';
fb.onload = load_engine;
document.head.appendChild(fb);
} else {
load_engine();
}
</script>
</body>
</html>