File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,18 +5,6 @@ const canvas = document.getElementById('canvas');
55const gameContainer = document . getElementById ( 'gameContainer' ) ;
66let 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
219canvas . addEventListener ( 'mouseenter' , ( ) => canvas . focus ( ) ) ;
2210canvas . addEventListener ( 'click' , ( ) => canvas . focus ( ) ) ;
Original file line number Diff line number Diff 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
4544const 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' ) ;
You can’t perform that action at this time.
0 commit comments