Skip to content

Commit

Permalink
fix for 1.2.178
Browse files Browse the repository at this point in the history
  • Loading branch information
AGulev committed Dec 27, 2020
1 parent a96f680 commit 8de7cde
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
23 changes: 10 additions & 13 deletions example/engine_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
vertical-align: bottom;
}

#canvas-container {
position: relative;
}

canvas:focus, canvas:active {
outline: none;
border: 0;
Expand All @@ -66,7 +70,9 @@

<body>
<div id="app-container" class="canvas-app-container">
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="{{display.width}}" height="{{display.height}}"></canvas>
<div id="canvas-container" class="canvas-app-canvas-container">
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="{{display.width}}" height="{{display.height}}"></canvas>
</div>
<div class="buttons-background">
{{#html5.show_fullscreen_button}}
<div class="button" onclick="Module.toggleFullscreen();">Fullscreen</div>
Expand All @@ -86,6 +92,7 @@
},
engine_arguments: [{{#DEFOLD_ENGINE_ARGUMENTS}}"{{.}}",{{/DEFOLD_ENGINE_ARGUMENTS}}],
custom_heap_size: {{DEFOLD_HEAP_SIZE}},
full_screen_container: "#canvas-container",
disable_context_menu: true
}

Expand Down Expand Up @@ -184,20 +191,10 @@
resize_game_canvas();
window.addEventListener('resize', resize_game_canvas, false);
window.addEventListener('orientationchange', resize_game_canvas, false);

function load_engine() {
var engineJS = document.createElement('script');
engineJS.type = 'text/javascript';
if (Module['isWASMSupported']) {
engineJS.src = '{{exe-name}}_wasm.js';
} else {
engineJS.src = '{{exe-name}}_asmjs.js';
}
document.head.appendChild(engineJS);
}
</script>

<script id='engine-start' type='text/javascript'>
load_engine();
EngineLoader.load("canvas", "{{exe-name}}");
</script>
<!-- JsToDef example -->
<script type='text/javascript'>
Expand Down
2 changes: 1 addition & 1 deletion example/example.script
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ function final(self)
if jstodef then
jstodef.remove_listener(example_1_listener)
end
end
end
2 changes: 2 additions & 0 deletions game.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ title = jstodef

[html5]
htmlfile = /example/engine_template.html
heap_size = 32

[library]
include_dirs = jstodef

10 changes: 5 additions & 5 deletions jstodef/lib/web/lib_jstodef.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ var LibJsToDef = {
var msg_id = allocate(intArrayFromString(message_id), "i8", ALLOC_NORMAL);
switch (typeof message) {
case 'undefined':
dynCall("vi", JsToDef._callback_empty, [msg_id]);
{{{ makeDynCall("vi", "JsToDef._callback_empty")}}}(msg_id);
break;
case 'number':
dynCall("vif", JsToDef._callback_number, [msg_id, message]);
{{{ makeDynCall("vif", "JsToDef._callback_number")}}}(msg_id, message);
break;
case 'string':
var msg = allocate(intArrayFromString(message), "i8", ALLOC_NORMAL);
dynCall("vii", JsToDef._callback_string, [msg_id, msg]);
{{{ makeDynCall("vii", "JsToDef._callback_string")}}}(msg_id, msg);
Module._free(msg);
break;
case 'object':
var msg = JSON.stringify(message);
msg = allocate(intArrayFromString(msg), "i8", ALLOC_NORMAL);
dynCall("vii", JsToDef._callback_object, [msg_id, msg]);
{{{ makeDynCall("vii"," JsToDef._callback_object")}}}(msg_id, msg);
Module._free(msg);
break;
case 'boolean':
var msg = message ? 1 : 0;
dynCall("vii", JsToDef._callback_bool, [msg_id, msg]);
{{{ makeDynCall("vii", "JsToDef._callback_bool")}}}(msg_id, msg);
break;
default:
console.warn("Unsupported message format: " + (typeof message));
Expand Down

0 comments on commit 8de7cde

Please sign in to comment.