TY Moros
| 7772 | |
| 7773 | //TY Moros |
| 7774 | static EM_BOOL resize_callback(int eventType, const EmscriptenUiEvent *event, void *userData) |
| 7775 | { |
| 7776 | // HACK ALERT! |
| 7777 | // |
| 7778 | // Here we assume any html shell that uses 3 or more instance of the class "emscripten" |
| 7779 | // is using one of the default or minimal emscripten page layouts |
| 7780 | static bool assumeDefaultShell = EM_ASM_INT( return (document.querySelectorAll('.emscripten').length >= 3) ? 1 : 0; ); |
| 7781 | static bool firstTry = false; |
| 7782 | |
| 7783 | // we to apply this style once |
| 7784 | if(!firstTry && assumeDefaultShell) |
| 7785 | { |
| 7786 | EM_ASM({ Module.canvas.parentNode.setAttribute('style', 'width: 100%; height: 70vh; margin-left: auto; margin-right: auto;'); }); |
| 7787 | firstTry = true; |
| 7788 | } |
| 7789 | |
| 7790 | // get and keep the aspect ratio of the canvas |
| 7791 | static double aspect = EM_ASM_DOUBLE( return Module.canvas.clientWidth; ) / EM_ASM_DOUBLE( return Module.canvas.clientHeight; ); |
| 7792 | |
| 7793 | double parentWidth = EM_ASM_DOUBLE( return (!!document.fullscreenElement) ? window.innerWidth : Module.canvas.parentElement.clientWidth; ); |
| 7794 | double parentHeight = EM_ASM_DOUBLE( return (!!document.fullscreenElement) ? window.innerHeight : Module.canvas.parentElement.clientHeight; ); |
| 7795 | |
| 7796 | double width = parentWidth; |
| 7797 | double height = parentWidth / aspect; |
| 7798 | |
| 7799 | if (height > parentHeight) |
| 7800 | { |
| 7801 | height = parentHeight; |
| 7802 | width = height * aspect; |
| 7803 | } |
| 7804 | |
| 7805 | // resize the canvas |
| 7806 | emscripten_set_canvas_element_size("#canvas", static_cast<int>(width), static_cast<int>(height)); |
| 7807 | ptrPGE->olc_UpdateWindowSize(static_cast<int>(width), static_cast<int>(height)); |
| 7808 | return 0; |
| 7809 | } |
| 7810 | |
| 7811 | //TY Moros |
| 7812 | static EM_BOOL keyboard_callback(int eventType, const EmscriptenKeyboardEvent* e, void* userData) |
nothing calls this directly
no test coverage detected