Change HTML5 start-up API
Rename engine.start() to startGame(), new start() takes string arguments handed directly to main(). Rename Engine.loadEngine() to load(). Add setLocale(), setResizeCanvasOnStart(), setExecutableName() and preloadFile().
This commit is contained in:
25
misc/dist/html/default.html
vendored
25
misc/dist/html/default.html
vendored
@ -225,7 +225,7 @@ $GODOT_HEAD_INCLUDE
|
||||
<script type="text/javascript" src="$GODOT_BASENAME.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
var game = new Engine;
|
||||
var engine = new Engine;
|
||||
|
||||
(function() {
|
||||
|
||||
@ -245,7 +245,7 @@ $GODOT_HEAD_INCLUDE
|
||||
var indeterminiateStatusAnimationId = 0;
|
||||
|
||||
setStatusMode('indeterminate');
|
||||
game.setCanvas(canvas);
|
||||
engine.setCanvas(canvas);
|
||||
|
||||
function setStatusMode(mode) {
|
||||
|
||||
@ -300,7 +300,7 @@ $GODOT_HEAD_INCLUDE
|
||||
});
|
||||
};
|
||||
|
||||
game.setProgressFunc((current, total) => {
|
||||
engine.setProgressFunc((current, total) => {
|
||||
|
||||
if (total > 0) {
|
||||
statusProgressInner.style.width = current/total * 100 + '%';
|
||||
@ -330,10 +330,6 @@ $GODOT_HEAD_INCLUDE
|
||||
outputRoot.style.display = 'block';
|
||||
|
||||
function print(text) {
|
||||
if (arguments.length > 1) {
|
||||
text = Array.prototype.slice.call(arguments).join(" ");
|
||||
}
|
||||
if (text.length <= 0) return;
|
||||
while (outputScroll.childElementCount >= OUTPUT_MSG_COUNT_MAX) {
|
||||
outputScroll.firstChild.remove();
|
||||
}
|
||||
@ -354,26 +350,31 @@ $GODOT_HEAD_INCLUDE
|
||||
};
|
||||
|
||||
function printError(text) {
|
||||
print('**ERROR**' + ":", text);
|
||||
if (!text.startsWith('**ERROR**: ')) {
|
||||
text = '**ERROR**: ' + text;
|
||||
}
|
||||
print(text);
|
||||
}
|
||||
|
||||
game.setStdoutFunc(text => {
|
||||
engine.setStdoutFunc(text => {
|
||||
print(text);
|
||||
console.log(text);
|
||||
});
|
||||
|
||||
game.setStderrFunc(text => {
|
||||
engine.setStderrFunc(text => {
|
||||
printError(text);
|
||||
console.warn(text);
|
||||
});
|
||||
}
|
||||
|
||||
game.start(BASENAME + '.pck').then(() => {
|
||||
engine.startGame(BASENAME + '.pck').then(() => {
|
||||
setStatusMode('hidden');
|
||||
initializing = false;
|
||||
}, err => {
|
||||
if (DEBUG_ENABLED)
|
||||
if (DEBUG_ENABLED) {
|
||||
printError(err.message);
|
||||
console.warn(err);
|
||||
}
|
||||
setStatusNotice(err.message);
|
||||
setStatusMode('notice');
|
||||
initializing = false;
|
||||
|
||||
Reference in New Issue
Block a user