Skip to content

Commit 09fda1a

Browse files
committed
again
1 parent c729436 commit 09fda1a

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

gamecanvas.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@ const canvas = document.getElementById('canvas');
55
const gameContainer = document.getElementById('gameContainer');
66
let lastTouchedId;
77

8-
// Launch the Player and configure it
9-
window.addEventListener('load', (event) => {
10-
createEasyRpgPlayer(easyrpgPlayer)
11-
.then(function(Module) {
12-
// Module is ready
13-
easyrpgPlayer = Module;
14-
easyrpgPlayer.initApi();
15-
16-
canvas.focus();
17-
});
18-
});
19-
208
// Make EasyRPG player embeddable
219
canvas.addEventListener('mouseenter', () => canvas.focus());
2210
canvas.addEventListener('click', () => canvas.focus());

init.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ let easyrpgPlayer = {
3838
initialized: false,
3939
game: ynoGameId,
4040
saveFs: undefined,
41-
wsUrl: 'wss://connect.ynoproject.net/' + ynoGameId + '/',
42-
postRun: []
41+
wsUrl: 'wss://connect.ynoproject.net/' + ynoGameId + '/'
4342
};
4443

4544
const sessionIdKey = 'ynoproject_sessionId';
@@ -79,8 +78,10 @@ async function injectScripts() {
7978
}
8079
if (globalConfig.preloads)
8180
initPreloads();
81+
82+
let easyrpgPlayerLoadFuncs = [];
8283

83-
easyrpgPlayer.postRun.push(() => {
84+
easyrpgPlayerLoadFuncs.push(() => {
8485
easyrpgPlayer.initialized = true;
8586
easyrpgPlayer._SetNametagMode(config.nametagMode);
8687
easyrpgPlayer._SetSoundVolume(globalConfig.soundVolume);
@@ -100,7 +101,19 @@ async function injectScripts() {
100101
};
101102
});
102103
if (typeof onResize !== 'undefined')
103-
easyrpgPlayer.postRun.push(onResize);
104+
easyrpgPlayerLoadFuncs.push(onResize);
105+
106+
createEasyRpgPlayer(easyrpgPlayer)
107+
.then(function(Module) {
108+
// Module is ready
109+
easyrpgPlayer = Module;
110+
easyrpgPlayer.initApi();
111+
112+
for (let func of easyrpgPlayerLoadFuncs)
113+
func();
114+
115+
canvas.focus();
116+
});
104117
};
105118

106119
const scriptTag = document.createElement('script');

0 commit comments

Comments
 (0)