Skip to content

Instantly share code, notes, and snippets.

@xyx0no646
Last active August 29, 2021 18:07
Show Gist options
  • Save xyx0no646/787d5f800b262ac0f4297f1950ebef06 to your computer and use it in GitHub Desktop.
Save xyx0no646/787d5f800b262ac0f4297f1950ebef06 to your computer and use it in GitHub Desktop.
Web版 吉里吉里SDL2 フルスクリーン対応
;Licence CC0 / author:@xyx0no646
;ご自由にお使いください
[iscript]
// フルスクリーン対応
if (System.platformName === 'Emscripten') {
KirikiriEmscriptenInterface.evalJS("
if(!window.__onfullschreenchanged) {
document.addEventListener('fullscreenchange',window.__onfullschreenchanged = () => {
window.dispatchEvent(new Event('resize'));
});
}
");
global.kag.onWindowedMenuItemClick = function (){
KirikiriEmscriptenInterface.evalJS("
try {
document.exitFullscreen();
}
catch(e){
console.warn(e);
}
");
} incontextof kag;
global.kag.onFullScreenMenuItemClick = function (){
var isOK = KirikiriEmscriptenInterface.evalJS("document.fullscreenEnabled");
if (isOK) {
KirikiriEmscriptenInterface.evalJS("
try {
document.getElementById('canvas').requestFullscreen();
}
catch(e){
console.warn(e);
};
");
}
} incontextof kag;
{
property _fullScreen{
getter() { return KirikiriEmscriptenInterface.evalJS("!!document.fullscreenElement"); }
setter( value ) {}
};
with(kag) {
&.fullScreen = &_fullScreen;
}
}
}
[endscript]
;コピペ時は重複注意
[return]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment