2021-04-21 00:42:32 +00:00
|
|
|
import { VideoModes } from '../videomodes';
|
2022-05-10 13:52:06 +00:00
|
|
|
import { BOOLEAN_OPTION, OptionHandler } from '../options';
|
2021-04-21 00:42:32 +00:00
|
|
|
|
2021-12-25 15:24:59 +00:00
|
|
|
export const SCREEN_MONO = 'mono_screen';
|
|
|
|
export const SCREEN_FULL_PAGE = 'full_page';
|
|
|
|
export const SCREEN_SCANLINE = 'show_scanlines';
|
|
|
|
export const SCREEN_GL = 'gl_canvas';
|
2021-04-21 00:42:32 +00:00
|
|
|
|
|
|
|
declare global {
|
|
|
|
interface Document {
|
|
|
|
webkitCancelFullScreen: () => void;
|
|
|
|
webkitIsFullScreen: boolean;
|
|
|
|
}
|
|
|
|
interface Element {
|
|
|
|
webkitRequestFullScreen: (options?: any) => void;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export class Screen implements OptionHandler {
|
|
|
|
constructor(private vm: VideoModes) {}
|
|
|
|
|
2021-12-25 15:24:59 +00:00
|
|
|
enterFullScreen = () => {
|
2021-04-21 00:42:32 +00:00
|
|
|
const elem = document.getElementById('screen')!;
|
2021-12-25 15:24:59 +00:00
|
|
|
if (document.fullscreenEnabled) {
|
|
|
|
if (document.fullscreenElement) {
|
|
|
|
void document.exitFullscreen();
|
2021-04-21 00:42:32 +00:00
|
|
|
} else {
|
2021-12-25 15:24:59 +00:00
|
|
|
void elem.requestFullscreen();
|
2021-04-21 00:42:32 +00:00
|
|
|
}
|
2021-12-25 15:24:59 +00:00
|
|
|
} else if (elem.webkitRequestFullScreen) {
|
|
|
|
if (document.webkitIsFullScreen) {
|
|
|
|
document.webkitCancelFullScreen();
|
2021-04-21 00:42:32 +00:00
|
|
|
} else {
|
2021-12-25 15:24:59 +00:00
|
|
|
elem.webkitRequestFullScreen();
|
2021-04-21 00:42:32 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-29 00:20:25 +00:00
|
|
|
};
|
2021-04-21 00:42:32 +00:00
|
|
|
|
|
|
|
getOptions() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
name: 'Screen',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: SCREEN_MONO,
|
|
|
|
label: 'Mono Screen',
|
|
|
|
type: BOOLEAN_OPTION,
|
|
|
|
defaultVal: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: SCREEN_SCANLINE,
|
|
|
|
label: 'Show Scanlines',
|
|
|
|
type: BOOLEAN_OPTION,
|
|
|
|
defaultVal: false,
|
|
|
|
},
|
2021-12-25 15:24:59 +00:00
|
|
|
{
|
|
|
|
name: SCREEN_FULL_PAGE,
|
|
|
|
label: 'Full Page',
|
|
|
|
type: BOOLEAN_OPTION,
|
|
|
|
defaultVal: false,
|
|
|
|
},
|
2021-04-21 00:42:32 +00:00
|
|
|
{
|
|
|
|
name: SCREEN_GL,
|
|
|
|
label: 'GL Renderer *',
|
|
|
|
type: BOOLEAN_OPTION,
|
|
|
|
defaultVal: true,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
setOption(name: string, value: boolean) {
|
|
|
|
switch (name) {
|
|
|
|
case SCREEN_MONO:
|
|
|
|
this.vm.mono(value);
|
|
|
|
break;
|
2021-12-25 15:24:59 +00:00
|
|
|
case SCREEN_FULL_PAGE:
|
|
|
|
this.setFullPage(value);
|
|
|
|
break;
|
2021-04-21 00:42:32 +00:00
|
|
|
case SCREEN_SCANLINE:
|
|
|
|
this.vm.scanlines(value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-12-25 15:24:59 +00:00
|
|
|
|
|
|
|
private setFullPage(on: boolean) {
|
|
|
|
if (on) {
|
|
|
|
document.body.classList.add('full-page');
|
|
|
|
} else {
|
|
|
|
document.body.classList.remove('full-page');
|
|
|
|
}
|
|
|
|
}
|
2021-04-21 00:42:32 +00:00
|
|
|
}
|