Web版 吉里吉里SDL2 フルスクリーン対応
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;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