-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikhail Sorokin
committed
Jun 28, 2024
1 parent
50e0b42
commit 81db5ee
Showing
11 changed files
with
712 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!doctype html> | ||
<html lang="en-us"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<!-- <meta name="gamefile" content="game.zip"> --> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<title>INSTEAD-EM</title> | ||
<style> | ||
body { font-family: 'Segoe UI', Roboto, Arial, sans-serif; } | ||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } | ||
div.emscripten { text-align: center; } | ||
div.emscripten_border { border: 0px solid black; } | ||
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ | ||
canvas.emscripten { border: 0px none; background-color: black; } | ||
#controls { margin-top: 20px; } | ||
.ldBar-label { | ||
padding: 5px; | ||
font-weight: bold; | ||
background-color: rgba(255, 255, 255, 0.5); | ||
border-radius: 5px; | ||
} | ||
#emProgress .ldBar-label { | ||
display: none; | ||
} | ||
</style> | ||
<link rel="stylesheet" type="text/css" href="loading-bar.css"/> | ||
</head> | ||
<body> | ||
<div id="preloader"> | ||
<div id="emPreloader" data-type="fill" data-img="sdl_instead.svg" class="ldBar label-center" style="width:200px; height: 200px; margin-left: auto; margin-right: auto" data-value="0"></div> | ||
<div class="emscripten" id="emscripten-status">Downloading...</div> | ||
<div style="margin: 5px;"> </div> | ||
<div id="emProgress" data-preset="line" class="ldBar no-label" style="width:400px; margin-left: auto; margin-right: auto;" data-value="0"></div> | ||
</div> | ||
<div id="emscripten-app" style="display:none"> | ||
<div id="controls" class="emscripten"> | ||
<!-- <input type="checkbox" id="resize">Resize canvas | ||
<input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer --> | ||
<input type="button" value="Fullscreen" onclick='document.getElementById("canvas").requestFullscreen()'> | ||
</div> | ||
<div class="emscripten_border"> | ||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas> | ||
</div> | ||
</div> | ||
<script type="text/javascript" src="loading-bar.min.js"></script> | ||
<script type="text/javascript" src="loader-em.js"></script> | ||
</body> | ||
</html> |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
var memFileSize = 1111191; | ||
|
||
var appElement = document.getElementById('emscripten-app'); | ||
var statusElement = document.getElementById('emscripten-status'); | ||
var preloaderElement = document.getElementById('preloader'); | ||
|
||
var barPreloader = new ldBar("#emPreloader"); | ||
var barProgress = new ldBar("#emProgress", {"stroke-width": 5, "stroke": '#666666'}); | ||
|
||
var Module = { | ||
preRun: [], | ||
postRun: [], | ||
dataFileDownloads: { | ||
}, | ||
print: (function() { | ||
return function(text) { | ||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); | ||
console.log(text); | ||
}; | ||
})(), | ||
printErr: function(text) { | ||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); | ||
if (0) { // XXX disabled for safety typeof dump == 'function') { | ||
dump(text + '\n'); // fast, straight to the real console | ||
} else { | ||
console.error(text); | ||
} | ||
}, | ||
canvas: (function() { | ||
var canvas = document.getElementById('canvas'); | ||
|
||
// As a default initial behavior, pop up an alert when webgl context is lost. To make your | ||
// application robust, you may want to override this behavior before shipping! | ||
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 | ||
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false); | ||
|
||
return canvas; | ||
})(), | ||
setStatus: function(text) { | ||
if (text === 'Running') { | ||
preloaderElement.style.display = 'none'; | ||
appElement.style.display = 'block'; | ||
} else if (text.indexOf('Launching game') === 0) { | ||
barPreloader.set(100); | ||
} else if (this.dataFileDownloads.hasOwnProperty('game') && text.indexOf('Loading game') === 0) { | ||
var stInfo = this.dataFileDownloads['game']; | ||
barPreloader.set(66 + stInfo.loaded / stInfo.total * 34); | ||
barProgress.set(stInfo.loaded / stInfo.total * 100); | ||
} else if (this.dataFileDownloads.hasOwnProperty('instead-em.data')) { | ||
var stInfo = this.dataFileDownloads['instead-em.data']; | ||
barPreloader.set(33 + stInfo.loaded / stInfo.total * 33); | ||
barProgress.set(stInfo.loaded / stInfo.total * 100); | ||
} | ||
statusElement.innerHTML = text; | ||
} | ||
}; | ||
|
||
Module.setStatus('Downloading...'); | ||
window.onerror = function(event) { | ||
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus | ||
Module.setStatus('Exception thrown, see JavaScript console'); | ||
// spinnerElement.style.display = 'none'; | ||
Module.setStatus = function(text) { | ||
if (text) Module.printErr('[post-exception status] ' + text); | ||
}; | ||
}; | ||
|
||
// helper functions | ||
function requestFullscreen () { | ||
Module.requestFullscreen( | ||
document.getElementById('pointerLock').checked, | ||
document.getElementById('resize').checked | ||
); | ||
} | ||
|
||
// Memory loader | ||
(function() { | ||
var memoryInitializer = 'instead-em.html.mem'; | ||
if (typeof Module['locateFile'] === 'function') { | ||
memoryInitializer = Module['locateFile'](memoryInitializer); | ||
} else if (Module['memoryInitializerPrefixURL']) { | ||
memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer; | ||
} | ||
var meminitXHR = Module['memoryInitializerRequest'] = new XMLHttpRequest(); | ||
meminitXHR.open('GET', memoryInitializer, true); | ||
meminitXHR.responseType = 'arraybuffer'; | ||
meminitXHR.send(null); | ||
statusElement.innerHTML = 'Downloading memory snapshot'; | ||
meminitXHR.onprogress = function(ev) { | ||
barPreloader.set(ev.loaded/memFileSize * 33); | ||
barProgress.set(ev.loaded/memFileSize * 100); | ||
} | ||
})(); | ||
|
||
// Main script loader | ||
var emScript = document.createElement('script'); | ||
emScript.src = "instead-em.js"; | ||
document.body.appendChild(emScript); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.