-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
113 lines (100 loc) · 3.88 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
<!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>
<!-- -->
<script type='text/javascript' src="dmloader.js"></script>
<script type='text/javascript' src="{{DEFOLD_ENGINE}}" async onload="{{DEFOLD_DEV_INIT}}"></script>
<script type='text/javascript'>
var extra_params = {
archive_location_filter: function( path ) {
return ("{{DEFOLD_ARCHIVE_LOCATION_PREFIX}}" + path + "{{DEFOLD_ARCHIVE_LOCATION_SUFFIX}}");
},
engine_arguments: ["--verify-graphics-calls=false"],
splash_image: "{{DEFOLD_SPLASH_IMAGE}}",
custom_heap_size: {{DEFOLD_HEAP_SIZE}}
}
Module.runApp("canvas", extra_params);
// 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);
</script>
</body>
</html>