(engine: VisualNovelEngine, _element: unknown, proportionWidth: number, proportionHeight: number)
| 358 | // ============================================================================ |
| 359 | |
| 360 | export function resize (engine: VisualNovelEngine, _element: unknown, proportionWidth: number, proportionHeight: number): void { |
| 361 | const parentElement = engine.parentElement(); |
| 362 | if (!parentElement) return; |
| 363 | |
| 364 | const mainWidth = parentElement.width(); |
| 365 | const mainHeight = parentElement.height(); |
| 366 | |
| 367 | const h = Math.floor (mainWidth * (proportionHeight / proportionWidth)); |
| 368 | |
| 369 | let widthCss = '100%'; |
| 370 | let heightCss = '100%'; |
| 371 | let marginTopCss: string | number = 0; |
| 372 | |
| 373 | if (h <= mainHeight) { |
| 374 | const marginTop = Math.floor ((mainHeight - h)/2); |
| 375 | marginTopCss = marginTop + 'px'; |
| 376 | heightCss = h + 'px'; |
| 377 | |
| 378 | } else { |
| 379 | const w = Math.floor (mainHeight * (proportionWidth/proportionHeight)); |
| 380 | widthCss = w + 'px'; |
| 381 | } |
| 382 | |
| 383 | $_('.forceAspectRatio').style ({ |
| 384 | 'width': widthCss, |
| 385 | 'height': heightCss, |
| 386 | 'margin-top': marginTopCss |
| 387 | }); |
| 388 | } |
| 389 | |
| 390 | export function goBack (engine: VisualNovelEngine, event: Event, selector: string): void { |
| 391 | if (!$_(`${selector} [data-screen="game"]`).isVisible ()) { |
nothing calls this directly
no test coverage detected