Skip to content

Commit 79aec53

Browse files
committed
- update emscripten shell
1 parent ce2d941 commit 79aec53

File tree

2 files changed

+91
-97
lines changed

2 files changed

+91
-97
lines changed

src_rebuild/platform/Emscripten/shell.html

Lines changed: 84 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@
8686
<div class="emscripten_border">
8787
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
8888
</div>
89-
9089
<div class="container">
91-
<figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>emscripten</strong></center></figure>
90+
<div class="spinner" id='spinner'></div>
9291
<div class="emscripten" id="status">Downloading...</div>
9392
<div class="emscripten">
9493
<progress value="0" max="100" id="progress" hidden=1></progress>
@@ -107,97 +106,88 @@
107106

108107
</section>
109108

110-
<script type='text/javascript'>
111-
var statusElement = document.getElementById('status');
112-
var progressElement = document.getElementById('progress');
113-
var spinnerElement = document.getElementById('spinner');
114-
115-
var Module = {
116-
preRun: [],
117-
postRun: [],
118-
print: (function () {
119-
var element = document.getElementById('output');
120-
121-
if (element) element.value = ''; // clear browser cache
122-
return function (text) {
123-
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
124-
// These replacements are necessary if you render to raw HTML
125-
//text = text.replace(/&/g, "&amp;");
126-
//text = text.replace(/</g, "&lt;");
127-
//text = text.replace(/>/g, "&gt;");
128-
//text = text.replace('\n', '<br>', 'g');
129-
console.log(text);
130-
if (element) {
131-
element.value += text + "\n";
132-
element.scrollTop = element.scrollHeight; // focus on bottom
133-
}
134-
};
135-
})(),
136-
printErr: function (text) {
137-
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
138-
console.error(text);
139-
},
140-
canvas: (function () {
141-
var canvas = document.getElementById('canvas');
142-
canvas.style.display = "none";
143-
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
144-
// application robust, you may want to override this behavior before shipping!
145-
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
146-
canvas.addEventListener("webglcontextlost", function (e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
147-
148-
return canvas;
149-
})(),
150-
setStatus: function (text) {
151-
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
152-
if (text === Module.setStatus.last.text) return;
153-
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
154-
var now = Date.now();
155-
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
156-
Module.setStatus.last.time = now;
157-
Module.setStatus.last.text = text;
158-
if (m) {
159-
text = m[1];
160-
progressElement.value = parseInt(m[2]) * 100;
161-
progressElement.max = parseInt(m[4]) * 100;
162-
progressElement.hidden = false;
163-
spinnerElement.hidden = false;
164-
} else {
165-
progressElement.value = null;
166-
progressElement.max = null;
167-
progressElement.hidden = true;
168-
if (!text) spinnerElement.hidden = true;
169-
}
170-
statusElement.innerHTML = text;
171-
},
172-
totalDependencies: 0,
173-
monitorRunDependencies: function (left) {
174-
this.totalDependencies = Math.max(this.totalDependencies, left);
175-
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies - left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
176-
}
177-
};
178-
179-
Module.setStatus('Downloading...');
180-
181-
// don't immediately run the game
182-
Module['noInitialRun'] = true
183-
184-
// for save config/data
185-
Module.preRun.push(function() {
186-
ENV.HOME = "/userstorage";
109+
<script type='text/javascript'>
110+
var statusElement = document.getElementById('status');
111+
var progressElement = document.getElementById('progress');
112+
var spinnerElement = document.getElementById('spinner');
113+
114+
var Module = {
115+
print: (function() {
116+
var element = document.getElementById('output');
117+
if (element) element.value = ''; // clear browser cache
118+
return function(text) {
119+
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
120+
// These replacements are necessary if you render to raw HTML
121+
//text = text.replace(/&/g, "&amp;");
122+
//text = text.replace(/</g, "&lt;");
123+
//text = text.replace(/>/g, "&gt;");
124+
//text = text.replace('\n', '<br>', 'g');
125+
console.log(text);
126+
if (element) {
127+
element.value += text + "\n";
128+
element.scrollTop = element.scrollHeight; // focus on bottom
129+
}
130+
};
131+
})(),
132+
canvas: (() => {
133+
var canvas = document.getElementById('canvas');
187134

188-
// create LSFS and mount 'data' local storage item into '/data' directory
189-
FS.mkdir('/userstorage'); // for old versions use: FS.createFolder(FS.root, 'data', true, true);
190-
FS.mount(LSFS(), { key: 'userstorage' }, '/userstorage');
191-
})
192-
193-
window.onerror = function () {
194-
Module.setStatus('Exception thrown, see JavaScript console');
195-
spinnerElement.style.display = 'none';
196-
Module.setStatus = function (text) {
197-
if (text) Module.printErr('[post-exception status] ' + text);
198-
};
199-
};
200-
135+
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
136+
// application robust, you may want to override this behavior before shipping!
137+
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
138+
canvas.addEventListener("webglcontextlost", (e) => { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
139+
140+
return canvas;
141+
})(),
142+
setStatus: (text) => {
143+
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
144+
if (text === Module.setStatus.last.text) return;
145+
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
146+
var now = Date.now();
147+
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
148+
Module.setStatus.last.time = now;
149+
Module.setStatus.last.text = text;
150+
if (m) {
151+
text = m[1];
152+
progressElement.value = parseInt(m[2])*100;
153+
progressElement.max = parseInt(m[4])*100;
154+
progressElement.hidden = false;
155+
spinnerElement.hidden = false;
156+
} else {
157+
progressElement.value = null;
158+
progressElement.max = null;
159+
progressElement.hidden = true;
160+
if (!text) spinnerElement.style.display = 'none';
161+
}
162+
statusElement.innerHTML = text;
163+
},
164+
totalDependencies: 0,
165+
monitorRunDependencies: (left) => {
166+
this.totalDependencies = Math.max(this.totalDependencies, left);
167+
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
168+
},
169+
// don't immediately run the game
170+
noInitialRun: true,
171+
preRun: [
172+
// for save config/data
173+
() => {
174+
ENV.HOME = "/userstorage";
175+
176+
// create LSFS and mount 'data' local storage item into '/data' directory
177+
FS.mkdir('/userstorage'); // for old versions use: FS.createFolder(FS.root, 'data', true, true);
178+
FS.mount(LSFS(), { key: 'userstorage' }, '/userstorage');
179+
}
180+
]
181+
};
182+
Module.setStatus('Downloading...');
183+
window.onerror = (event) => {
184+
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus
185+
Module.setStatus('Exception thrown, see JavaScript console');
186+
spinnerElement.style.display = 'none';
187+
Module.setStatus = (text) => {
188+
if (text) console.error('[post-exception status] ' + text);
189+
};
190+
};
201191
function readCDImage(event) {
202192
var reader = new FileReader();
203193
reader.onload = function(){
@@ -226,8 +216,8 @@
226216
var canvas = document.getElementById('canvas');
227217
canvas.style.display = null;
228218
}
229-
</script>
219+
</script>
230220
<script src="lsfs.js"></script>
231-
{{{ SCRIPT }}}
221+
{{{ SCRIPT }}}
232222
</body>
233223
</html>

src_rebuild/premake5.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ SDL2_DIR = os.getenv("SDL2_DIR") or "dependencies/SDL2"
2121
OPENAL_DIR = os.getenv("OPENAL_DIR") or "dependencies/openal-soft"
2222
JPEG_DIR = os.getenv("JPEG_DIR") or "dependencies/jpeg"
2323

24-
WEBDEMO_DIR = os.getenv("WEBDEMO_DIR") or "../../../content/web_demo@/" -- FIXME: make it better
24+
WEBDEMO_DIR = os.getenv("WEBDEMO_DIR") or "../../../../content/web_demo@/" -- FIXME: make it better
2525
RED2_DIR = os.getenv("RED2_DIR") or "../../data@/"
2626
WEBSHELL_PATH = "../platform/Emscripten" -- must be relative to makefile path (SADLY)
2727

@@ -182,11 +182,15 @@ if os.target() == "windows" or os.target() == "emscripten" then
182182
include "premake_libjpeg.lua"
183183
end
184184

185+
-- font tool
186+
if os.target() ~= "emscripten" then
187+
include "premake5_font_tool.lua"
188+
end
189+
185190
-- Psy-Cross layer
186191
include "premake5_psycross.lua"
187192

188-
-- font tool
189-
include "premake5_font_tool.lua"
193+
190194

191195
-- game iteslf
192196
project "REDRIVER2"

0 commit comments

Comments
 (0)