1
1
import { GameLaunchInfo } from 'flashpoint-launcher' ;
2
- import React from 'react' ;
2
+ import React , { useState } from 'react' ;
3
3
4
4
export default function LauncherEmbedPage ( props : GameLaunchInfo ) {
5
+ const [ rufflePlayer , setRufflePlayer ] = useState < any | undefined > ( ) ;
5
6
const containerRef = React . useRef < HTMLDivElement | null > ( null ) ;
6
7
const navigate = window . ext . hooks . useNavigate ( ) ;
7
8
const ruffleJsUrl = React . useMemo ( ( ) => `${ window . ext . utils . getFileServerURL ( ) } /ruffle/webhosted/latest/ruffle.js` , [ ] ) ;
@@ -32,9 +33,10 @@ export default function LauncherEmbedPage(props: GameLaunchInfo) {
32
33
try {
33
34
const ruffle = ( window as any ) . RufflePlayer . newest ( ) ;
34
35
const player = ruffle . createPlayer ( ) ;
36
+ player . id = 'ruffle-player' ;
35
37
containerRef . current . appendChild ( player ) ;
36
-
37
38
player . load ( lc ) ;
39
+ setRufflePlayer ( player ) ;
38
40
console . log ( 'Ruffle player created and loaded with:' , lc ) ;
39
41
} catch ( err ) {
40
42
console . error ( 'Failed to create Ruffle player:' , err ) ;
@@ -52,14 +54,16 @@ export default function LauncherEmbedPage(props: GameLaunchInfo) {
52
54
53
55
const ruffle = ( window as any ) . RufflePlayer . newest ( ) ;
54
56
const player = ruffle . createPlayer ( ) ;
57
+ player . id = 'ruffle-player' ;
55
58
containerRef . current . appendChild ( player ) ;
56
59
player . load ( lc ) ;
60
+ setRufflePlayer ( player ) ;
57
61
console . log ( 'Ruffle player created and loaded with:' , lc ) ;
58
62
} catch ( err ) {
59
63
console . error ( 'Failed to create Ruffle player:' , err ) ;
60
64
}
61
65
}
62
- } ) ;
66
+ } , [ ] ) ;
63
67
64
68
const onBack = ( ) => {
65
69
navigate ( - 1 ) ;
@@ -70,6 +74,6 @@ export default function LauncherEmbedPage(props: GameLaunchInfo) {
70
74
< div className = 'ruffle-title' > { props . game . title } </ div >
71
75
< div className = 'ruffle-container' style = { { width, height } } ref = { containerRef } > </ div >
72
76
</ div >
73
- < button className = 'simple-button' onClick = { onBack } > Back</ button >
77
+ < button className = 'simple-button ruffle-back-button ' onClick = { onBack } > Back</ button >
74
78
</ div > ;
75
79
}
0 commit comments