-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.html
More file actions
201 lines (170 loc) · 6.07 KB
/
index.html
File metadata and controls
201 lines (170 loc) · 6.07 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#382C2A">
<meta name="viewport"
content="height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
<title>TestPlayer</title>
<script type="text/javascript" src="./js/loader.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
canvas {
outline: none
}
html,
body,
#container {
margin: 0;
overflow: hidden;
width: 100%;
height: 100%;
background-color: white;
}
#splash {
position: absolute;
visibility: hidden;
z-index: 10;
}
#splash__image {
position: absolute;
margin: auto;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
background-image: url("assets/todo.jpg");
visibility: visible;
transition: opacity 0.5s;
z-index: 10;
}
#progress__root {
position: absolute;
}
#progress__line {
width: 0;
height: 100%;
transition: all 0.5s;
}
</style>
</head>
<body>
<div id="splash__image">
<div id="progress__root">
<div id="progress__line"></div>
</div>
</div>
<script>
window.addEventListener("load", () => {
//------------------------------------------------------------------------------//
// default config for this game - can be overwritten for every file-config: //
//------------------------------------------------------------------------------//
config = {
"showFPS": false, // show fps display - always false in prod
"debug": true, // disable JS blobind - always false in prod
"title": "TestPlayer", // disable JS blobind - always false in prod
"filename": "", // filename of game - no extension - must be set for each config
"splash": "assets/todo.jpg", // path to splash-image - with extension
"start": null, // path to start-image - with extension - optional - if present, loader wait for user input to start the game
"width": 900, // width of preloader screen (todo: grab this from splashimage ?)
"height": 540, // height of preloader screen (todo: grab this from splashimage ?)
"x": 0, // x offset of stage (either absolute px value, or string with percentage of window.innerWidth (0-100))
"y": 0, // y offset of stage (either absolute px value, or string with percentage of window.innerHeight (0-100))
"w": "100%", // width of stage (either absolute px value, or string with percentage of window.innerWidth (0-100))
"h": "100%", // height of stage (either absolute px value, or string with percentage of window.innerHeight (0-100))
"stageScaleMode": null, // allowed values: EXACT_FIT noBorder noScale showAll
"stageAlign": null, // allowed values: B BL BR L R T TL TR
"progressParserWeigth": 1, // weight of parser in reporter - can be ommited or set to 0 aswell
// properties for progress bar
"progress": {
"direction": "lr", // lr, td
"back": "#35809e", // #000
"line": "#070bff", // "#00ff00",
"rect": [ // values are percentage of width / height
0.25,
0.65,
0.5,
0.03
]
},
"box2dVersion": "new", // box2d version: none, legacy, new, custom (external implementation)
"skipFramesOfScene": null,
"binary": [ // list of urls to preload (fonts) - relative to project folder
{
"name": "fonts.swf",
"path": "assets/fonts.swf",
"size": 8447
}
],
"runtime": "js/TestPlayer.js"
};
const q = new URLSearchParams(location.search);
for (let key of q.keys()){ config[key] = q.get(key);};
for (let key in config.binary){ config.binary[key].path = config.binary[key].path+'?v='+Math.random();};
function loadJSON(url, callback) {
let xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', url, true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
callback(JSON.parse(xobj.responseText));
}
};
xobj.send(null);
}
const qp = new URLSearchParams(location.search);
if (qp.get("swf")) {
config.binary.push({name: qp.get("swf"),
path: "assets/" + qp.get("swf") + ".swf",
size: 99999,//todo
resourceType: "GAME",
});
}
if (qp.get("swf") && !qp.get("test") && qp.get("port")) {
// record test
// load settings for recording, than start player-loader
let path = `http://localhost:${qp.get("port")}/getSettings?swf=${qp.get("swf")}`;
loadJSON(path, (data) => {
config.testConfig = {};
config.testConfig.settings = data;
config.testConfig.recordtest = true,
config.testConfig.startRecTime = Date.now(),
config.testConfig.port = qp.get("port");
config.testConfig.swfPath = qp.get("swf");
config.testConfig.testPath = qp.get("test");
Loader.init(config);
Loader.runGame((fill) => { }, (instance) => { });
});
}
else if (qp.get("swf") && qp.get("test") && qp.get("port")) {
// run test
// load recordetData (they contain the settigns used for this recording), than start player
let path = `http://localhost:${qp.get("port")}/getSettings?swf=${qp.get("swf")}&test=${qp.get("test")}`;
loadJSON(path, (data) => {
config.testConfig = data;
config.testConfig.startRecTime = Date.now(),
config.testConfig.port = qp.get("port");
config.testConfig.swfPath = qp.get("swf");
config.testConfig.testPath = qp.get("test");
Loader.init(config);
Loader.runGame((fill) => { }, (instance) => { });
});
}
else {
// no test stuff. just start the player
config.binary.push({name: config.filename,
path: "assets/" + config.filename + ".swf",
size: 99999,//todo
resourceType: "GAME",
});
Loader.init(config);
Loader.runGame((fill) => { }, (instance) => { });
}
})
</script>
</body>
</html>