Add shell
This commit is contained in:
parent
920168abe0
commit
b7c8011c52
|
@ -461,7 +461,7 @@ SET(EMS_FLAGS " -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_ZLIB=1 -s USE_OGG=1 -s US
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMS_FLAGS} ${ERR_FLAGS}")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMS_FLAGS} ${ERR_FLAGS}")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EMS_FLAGS} ${ERR_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EMS_FLAGS} ${ERR_FLAGS}")
|
||||||
|
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMS_FLAGS} -s TOTAL_MEMORY=1073741824 -lopenal --preload-file game -s DISABLE_EXCEPTION_CATCHING=1 -s ASSERTIONS=0 -s SAFE_HEAP=0 -s MINIFY_HTML=0 -s 'ASYNCIFY_IMPORTS=[\"load_file_async_js\"]'")
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMS_FLAGS} -s TOTAL_MEMORY=1073741824 -lopenal --preload-file game -s DISABLE_EXCEPTION_CATCHING=1 -s ASSERTIONS=0 -s SAFE_HEAP=0 -s MINIFY_HTML=0 -s 'ASYNCIFY_IMPORTS=[\"load_file_async_js\"]' --shell-file shell.html")
|
||||||
|
|
||||||
set_target_properties(
|
set_target_properties(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en-us">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>MKXP</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: black;
|
||||||
|
height: 100vh
|
||||||
|
}
|
||||||
|
|
||||||
|
#canvas {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: block;
|
||||||
|
border: 0px none;
|
||||||
|
background-color: black;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
#spinner {
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 20px;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
}
|
||||||
|
.spinner {
|
||||||
|
height: 50px;
|
||||||
|
width: 50px;
|
||||||
|
margin: 0px auto;
|
||||||
|
-webkit-animation: rotation .8s linear infinite;
|
||||||
|
-moz-animation: rotation .8s linear infinite;
|
||||||
|
-o-animation: rotation .8s linear infinite;
|
||||||
|
animation: rotation 0.8s linear infinite;
|
||||||
|
border-left: 10px solid white;
|
||||||
|
border-right: 10px solid white;
|
||||||
|
border-bottom: 10px solid white;
|
||||||
|
border-top: 10px solid transparent;
|
||||||
|
border-radius: 100%;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes rotation {
|
||||||
|
from {-webkit-transform: rotate(0deg);}
|
||||||
|
to {-webkit-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@-moz-keyframes rotation {
|
||||||
|
from {-moz-transform: rotate(0deg);}
|
||||||
|
to {-moz-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@-o-keyframes rotation {
|
||||||
|
from {-o-transform: rotate(0deg);}
|
||||||
|
to {-o-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@keyframes rotation {
|
||||||
|
from {transform: rotate(0deg);}
|
||||||
|
to {transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="overflow:visible;" id="spinner">
|
||||||
|
<div class="spinner"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1 width="640" height="480"></canvas>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
var Module = {
|
||||||
|
preRun: [],
|
||||||
|
postRun: [],
|
||||||
|
print: (function() {
|
||||||
|
return function(text) {
|
||||||
|
console.log(text);
|
||||||
|
};
|
||||||
|
})(),
|
||||||
|
printErr: function(text) {
|
||||||
|
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
|
console.error(text);
|
||||||
|
},
|
||||||
|
canvas: (function() {
|
||||||
|
var canvas = document.getElementById('canvas');
|
||||||
|
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
})(),
|
||||||
|
setStatus: function(text) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.setBusy = function() {
|
||||||
|
document.getElementById('spinner').style.display = "block";
|
||||||
|
};
|
||||||
|
|
||||||
|
window.setNotBusy = function() {
|
||||||
|
document.getElementById('spinner').style.display = "none";
|
||||||
|
};
|
||||||
|
|
||||||
|
window.onerror = function() {
|
||||||
|
alert("An error occured!")
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{{{ SCRIPT }}}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -197,6 +197,7 @@ void Config::read(int argc, char *argv[])
|
||||||
defScreenW = 640;
|
defScreenW = 640;
|
||||||
defScreenH = 480;
|
defScreenH = 480;
|
||||||
enableBlitting = false;
|
enableBlitting = false;
|
||||||
|
winResizable = false;
|
||||||
|
|
||||||
#undef PO_DESC
|
#undef PO_DESC
|
||||||
#undef PO_DESC_ALL
|
#undef PO_DESC_ALL
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
EM_JS(void, load_file_async_js, (const char* fullPathC), {
|
EM_JS(void, load_file_async_js, (const char* fullPathC), {
|
||||||
Asyncify.handleSleep(function(wakeUp) {
|
Asyncify.handleSleep(function(wakeUp) {
|
||||||
|
// Get argument
|
||||||
const fullPath = UTF8ToString(fullPathC);
|
const fullPath = UTF8ToString(fullPathC);
|
||||||
|
|
||||||
// Make cache object
|
// Make cache object
|
||||||
|
@ -12,6 +13,9 @@ EM_JS(void, load_file_async_js, (const char* fullPathC), {
|
||||||
// Check if already loaded
|
// Check if already loaded
|
||||||
if (window.fileAsyncCache.hasOwnProperty(fullPath)) return wakeUp();
|
if (window.fileAsyncCache.hasOwnProperty(fullPath)) return wakeUp();
|
||||||
|
|
||||||
|
// Show spinner
|
||||||
|
if (window.setBusy) window.setBusy();
|
||||||
|
|
||||||
// Get full destination
|
// Get full destination
|
||||||
const file = "game/" + fullPath;
|
const file = "game/" + fullPath;
|
||||||
|
|
||||||
|
@ -28,6 +32,7 @@ EM_JS(void, load_file_async_js, (const char* fullPathC), {
|
||||||
// Get the new file
|
// Get the new file
|
||||||
FS.createPreloadedFile(path, filename, iurl, true, true, function() {
|
FS.createPreloadedFile(path, filename, iurl, true, true, function() {
|
||||||
window.fileAsyncCache[fullPath] = 1;
|
window.fileAsyncCache[fullPath] = 1;
|
||||||
|
if (window.setNotBusy) window.setNotBusy();
|
||||||
wakeUp();
|
wakeUp();
|
||||||
}, console.error);
|
}, console.error);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue