@@ -2348,30 +2348,62 @@ function init_ui(profile, settings, emulator)
2348
2348
emulator . screen_set_scale ( n , n ) ;
2349
2349
}
2350
2350
2351
- $ ( "toggle_ui" ) . onclick = function ( )
2351
+ /**
2352
+ * @param {boolean } enabled
2353
+ */
2354
+ function enable_theatre_ui ( enabled )
2352
2355
{
2353
- theatre_ui = ! theatre_ui ;
2356
+ theatre_ui = enabled ;
2354
2357
2355
2358
$ ( "runtime_options" ) . style . display = theatre_ui ? "block" : "none" ;
2356
2359
$ ( "runtime_infos" ) . style . display = theatre_ui ? "block" : "none" ;
2357
2360
$ ( "filesystem_panel" ) . style . display = ( filesystem_is_enabled && theatre_ui ) ? "block" : "none" ;
2358
2361
2359
2362
$ ( "toggle_ui" ) . value = ( theatre_ui ? "Hide" : "Show" ) + " UI" ;
2360
- $ ( "toggle_ui" ) . blur ( ) ;
2361
- } ;
2363
+ }
2362
2364
2363
- $ ( "toggle_theatre" ) . onclick = function ( )
2365
+ /**
2366
+ * @param {boolean } enabled
2367
+ */
2368
+ function enable_zoom_to_fit ( enabled )
2364
2369
{
2365
- theatre_mode = ! theatre_mode ;
2370
+ theatre_zoom_to_fit = enabled ;
2371
+ $ ( "scale" ) . disabled = theatre_zoom_to_fit ;
2372
+
2373
+ if ( theatre_zoom_to_fit )
2374
+ {
2375
+ window . addEventListener ( "resize" , zoom_to_fit , true ) ;
2376
+ emulator . add_listener ( "screen-set-size" , zoom_to_fit ) ;
2377
+
2378
+ zoom_to_fit ( ) ;
2379
+ }
2380
+ else
2381
+ {
2382
+ window . removeEventListener ( "resize" , zoom_to_fit , true ) ;
2383
+ emulator . remove_listener ( "screen-set-size" , zoom_to_fit ) ;
2384
+
2385
+ const n = parseFloat ( $ ( "scale" ) . value ) || 1 ;
2386
+ emulator . screen_set_scale ( n , n ) ;
2387
+ }
2388
+
2389
+ $ ( "toggle_zoom_to_fit" ) . value = ( theatre_zoom_to_fit ? "Dis" : "En" ) + "able zoom to fit" ;
2390
+ }
2391
+
2392
+ /**
2393
+ * @param {boolean } enabled
2394
+ */
2395
+ function enable_theatre_mode ( enabled )
2396
+ {
2397
+ theatre_mode = enabled ;
2366
2398
2367
2399
if ( ! theatre_ui )
2368
2400
{
2369
- $ ( "toggle_ui" ) . click ( ) ;
2401
+ enable_theatre_ui ( true ) ;
2370
2402
}
2371
2403
2372
2404
if ( ! theatre_mode && theatre_zoom_to_fit )
2373
2405
{
2374
- $ ( "toggle_zoom_to_fit" ) . click ( ) ;
2406
+ enable_zoom_to_fit ( false ) ;
2375
2407
}
2376
2408
2377
2409
for ( const el of [ "screen_container" , "runtime_options" , "runtime_infos" , "filesystem_panel" ] )
@@ -2387,31 +2419,23 @@ function init_ui(profile, settings, emulator)
2387
2419
document . body . style . overflow = theatre_mode ? "hidden" : "visible" ;
2388
2420
2389
2421
$ ( "toggle_theatre" ) . value = ( theatre_mode ? "Dis" : "En" ) + "able theatre mode" ;
2422
+ }
2423
+
2424
+ $ ( "toggle_ui" ) . onclick = function ( )
2425
+ {
2426
+ enable_theatre_ui ( ! theatre_ui ) ;
2427
+ $ ( "toggle_ui" ) . blur ( ) ;
2428
+ } ;
2429
+
2430
+ $ ( "toggle_theatre" ) . onclick = function ( )
2431
+ {
2432
+ enable_theatre_mode ( ! theatre_mode ) ;
2390
2433
$ ( "toggle_theatre" ) . blur ( ) ;
2391
2434
} ;
2392
2435
2393
2436
$ ( "toggle_zoom_to_fit" ) . onclick = function ( )
2394
2437
{
2395
- theatre_zoom_to_fit = ! theatre_zoom_to_fit ;
2396
- $ ( "scale" ) . disabled = theatre_zoom_to_fit ;
2397
-
2398
- if ( theatre_zoom_to_fit )
2399
- {
2400
- window . addEventListener ( "resize" , zoom_to_fit , true ) ;
2401
- emulator . add_listener ( "screen-set-size" , zoom_to_fit ) ;
2402
-
2403
- zoom_to_fit ( ) ;
2404
- }
2405
- else
2406
- {
2407
- window . removeEventListener ( "resize" , zoom_to_fit , true ) ;
2408
- emulator . remove_listener ( "screen-set-size" , zoom_to_fit ) ;
2409
-
2410
- const n = parseFloat ( $ ( "scale" ) . value ) || 1 ;
2411
- emulator . screen_set_scale ( n , n ) ;
2412
- }
2413
-
2414
- $ ( "toggle_zoom_to_fit" ) . value = ( theatre_zoom_to_fit ? "Dis" : "En" ) + "able zoom to fit" ;
2438
+ enable_zoom_to_fit ( ! theatre_zoom_to_fit ) ;
2415
2439
$ ( "toggle_zoom_to_fit" ) . blur ( ) ;
2416
2440
} ;
2417
2441
0 commit comments