1
1
export default async function ( { addon, global, cons, msg } ) {
2
+
2
3
await new Promise ( ( resolve ) => {
3
4
if ( addon . tab . traps . vm . editingTarget ) return resolve ( ) ;
4
5
addon . tab . traps . vm . runtime . once ( "PROJECT_LOADED" , resolve ) ;
@@ -9,6 +10,21 @@ export default async function ({ addon, global, cons, msg }) {
9
10
let fpsCounterElement = document . createElement ( "span" ) ;
10
11
fpsCounterElement . className = "fps-counter" ;
11
12
13
+ function updateVisibility ( ) {
14
+ if ( addon . tab . redux && addon . tab . redux . state . scratchGui . stageSize . stageSize === "small" ) {
15
+ fpsCounterElement . style . display = "none" ;
16
+ } else {
17
+ addon . tab . displayNoneWhileDisabled ( fpsCounterElement , { display : "flex" } ) ;
18
+ }
19
+ }
20
+
21
+ updateVisibility ( ) ;
22
+
23
+ addon . tab . redux . addEventListener ( "statechanged" , ( { detail } ) => {
24
+ if ( detail . action . type !== "scratch-gui/StageSize/SET_STAGE_SIZE" ) return ;
25
+ updateVisibility ( ) ;
26
+ } ) ;
27
+
12
28
const renderTimes = [ ] ;
13
29
var fps = "?" ;
14
30
var lastFps = 0 ;
@@ -23,7 +39,6 @@ export default async function ({ addon, global, cons, msg }) {
23
39
if ( firstTime === - 1 ) firstTime = now ;
24
40
if ( now - firstTime <= 2500 ) fps = "?" ;
25
41
if ( fps !== lastFps ) fpsCounterElement . innerText = msg ( "fpsCounter" , { fps : ( lastFps = fps ) } ) ;
26
- addon . tab . displayNoneWhileDisabled ( fpsCounterElement , { display : "flex" } ) ;
27
42
renderer . ogDraw ( ) ;
28
43
} ;
29
44
@@ -32,6 +47,7 @@ export default async function ({ addon, global, cons, msg }) {
32
47
markAsSeen : true ,
33
48
reduxEvents : [ "scratch-gui/mode/SET_PLAYER" , "fontsLoaded/SET_FONTS_LOADED" , "scratch-gui/locales/SELECT_LOCALE" ] ,
34
49
} ) ;
50
+ console . log ( "Hai :D" ) ;
35
51
addon . tab . appendToSharedSpace ( { space : "afterStopButton" , element : fpsCounterElement , order : 3 } ) ;
36
52
}
37
53
}
0 commit comments