Skip to content

Commit

Permalink
again
Browse files Browse the repository at this point in the history
  • Loading branch information
patapancakes committed Jan 8, 2024
1 parent c729436 commit 09fda1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
12 changes: 0 additions & 12 deletions gamecanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ const canvas = document.getElementById('canvas');
const gameContainer = document.getElementById('gameContainer');
let lastTouchedId;

// Launch the Player and configure it
window.addEventListener('load', (event) => {
createEasyRpgPlayer(easyrpgPlayer)
.then(function(Module) {
// Module is ready
easyrpgPlayer = Module;
easyrpgPlayer.initApi();

canvas.focus();
});
});

// Make EasyRPG player embeddable
canvas.addEventListener('mouseenter', () => canvas.focus());
canvas.addEventListener('click', () => canvas.focus());
Expand Down
21 changes: 17 additions & 4 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ let easyrpgPlayer = {
initialized: false,
game: ynoGameId,
saveFs: undefined,
wsUrl: 'wss://connect.ynoproject.net/' + ynoGameId + '/',
postRun: []
wsUrl: 'wss://connect.ynoproject.net/' + ynoGameId + '/'
};

const sessionIdKey = 'ynoproject_sessionId';
Expand Down Expand Up @@ -79,8 +78,10 @@ async function injectScripts() {
}
if (globalConfig.preloads)
initPreloads();

let easyrpgPlayerLoadFuncs = [];

easyrpgPlayer.postRun.push(() => {
easyrpgPlayerLoadFuncs.push(() => {
easyrpgPlayer.initialized = true;
easyrpgPlayer._SetNametagMode(config.nametagMode);
easyrpgPlayer._SetSoundVolume(globalConfig.soundVolume);
Expand All @@ -100,7 +101,19 @@ async function injectScripts() {
};
});
if (typeof onResize !== 'undefined')
easyrpgPlayer.postRun.push(onResize);
easyrpgPlayerLoadFuncs.push(onResize);

createEasyRpgPlayer(easyrpgPlayer)
.then(function(Module) {
// Module is ready
easyrpgPlayer = Module;
easyrpgPlayer.initApi();

for (let func of easyrpgPlayerLoadFuncs)
func();

canvas.focus();
});
};

const scriptTag = document.createElement('script');
Expand Down

0 comments on commit 09fda1a

Please sign in to comment.