Files
UnrealEngineUWP/Engine/Build/HTML5/Game.html.template
Peter Sauerbrei 446972d460 [INTEGRATE] Chage 2082198
final changes to make Tappy Chicken for HTML5
#ue4
#html5
#tappy chicken

[CL 2082256 by Peter Sauerbrei in Main branch]
2014-05-22 15:14:51 -04:00

220 lines
6.1 KiB
Plaintext

<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>%GAME%</title>
<style type="text/css">
body {
background: black;
color: gray;
font-family: Helvetica, sans-serif;
}
.emscripten {
padding-right: 0;
margin-left: auto;
margin-right: auto;
display: block;
}
div#status {
font-size: 70%;
}
textarea.emscripten {
font-family: consolas, "lucida sans console", monospace;
background: gray;
font-size: 80%;
width: 80%;
display: none;
}
div.emscripten {
text-align: center;
}
div#display_wrapper {
position: relative;
margin: 1em auto 10px auto;
text-align: center;
min-width: 640px;
max-width: 95%;
/*border: 1px solid red;*/
}
canvas.main {
border: none;
background: #444;
display: block;
}
canvas.main:not([fullscreen]) {
padding-right: 0;
margin-left: auto;
margin-right: auto;
width: 100%;
}
input[type=button] {
background: #444;
border: 2px solid #444;
border-radius: 2px;
}
input[type=button]:hover {
background: #777;
border-color: #777;
}
</style>
</head>
<body>
<div class="emscripten" id="status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
<!-- Canvas resolution needs to be divisible by 8; default to 904x1600 for in-page resolution -->
<div id="display_wrapper">
<canvas class="main" id="canvas" oncontextmenu="event.preventDefault()" height="904" width="1600"></canvas>
</div>
<div class="emscripten">
<input type="button" value="Fullscreen" onclick="Module.requestFullScreen(false)">
<input type="button" value="Pause" onclick="Module['pauseMainLoop']();">
<input type="button" value="Resume" onclick="Module['resumeMainLoop']();">
<input type="button" value="Quit" onclick="__exit(0)">
<input type="button" value="ClearStoredGame" onclick="$.jStorage.flush()">
</div>
<textarea class="emscripten" id="output" rows="8"></textarea>
<script type="text/javascript">
var UE4 = {
get console_command() {
var fn = Module.cwrap('execute_console_command', null, ['string']);
delete UE4["console_command"];
UE4.console_command = fn;
return fn;
}
};
function resizeListener(width, height) {
console.log("resizeListener:", width, height);
UE4.console_command("r.SetRes " + width + "x" + height);
}
var gWasFullScreen = false;
var gOldWidth, gOldHeight;
function fullScreenChange() {
var fsElem = document['fullScreenElement'] ||
document['mozFullScreenElement'] ||
document['webkitFullScreenElement'] ||
document['msFullScreenElement'] ||
document['webkitCurrentFullScreenElement'];
var canvas = document.getElementById("canvas");
if (fsElem == canvas || fsElem == canvas.parentNode) {
// we just went full screen
gWasFullScreen = true;
// update the canvas size
gOldWidth = canvas.width;
gOldHeight = canvas.height;
var width = window.screen.width;
var height = window.screen.height;
canvas.width = width;
canvas.height = height;
canvas.setAttribute("fullscreen", "true");
console.log("r.SetRes", canvas.width, canvas.height);
UE4.console_command("r.SetRes " + canvas.width + "x" + canvas.height);
} else if (gWasFullScreen) {
// we just left full screen
gWasFullScreen = false;
canvas.width = gOldWidth;
canvas.height = gOldHeight;
canvas.removeAttribute("fullscreen");
console.log("r.SetRes", canvas.width, canvas.height);
UE4.console_command("r.SetRes " + canvas.width + "x" + canvas.height);
}
}
function preRunHandler() {
document.addEventListener('fullscreenchange', fullScreenChange, false);
document.addEventListener('mozfullscreenchange', fullScreenChange, false);
document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
document.addEventListener('MSFullscreenChange', fullScreenChange, false);
// this needs to die
Browser.updateCanvasDimensions = function() { };
}
var Module = {
preRun: [preRunHandler],
postRun: [],
noImageDecoding: true,
noAudioDecoding: true,
arguments: [%UE4CMDLINE%],
print: (function() {
var element = document.getElementById('output');
element.value = ''; // clear browser cache
return function(text) {
// show it if it's hidden first
element.style.display = "block";
element.value += text + "\n";
element.scrollTop = 99999; // focus on bottom
};
})(),
printErr: function(text) {
console.log(text);
},
canvas: document.getElementById('canvas'),
setStatus: function(text) {
if (Module.setStatus.interval) clearInterval(Module.setStatus.interval);
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
</script>
<script type="text/javascript">
var tmid = Date.now();
</script>
<script src="json2.js"></script>
<script src="moz_binarystring.js"></script>
<script src="jStorage.js"></script>
<script src="%GAME%.data.js"></script>
<script async src="%CONFIG%.js"></script>
<script type="text/javascript">
var tend = Date.now();
console.log("Script load time: Data[js]: " + (tmid-tstart).toFixed(2) + "ms, code[js]: " + (tend-tmid).toFixed(2));
</script>
</body>
</html>