|
21 | 21 | <style> |
22 | 22 | html, body { margin: 0; padding: 0; width: 100%; height: 100%; background: #1a1a1a; font-family: Arial, sans-serif; } |
23 | 23 | body { display: flex; justify-content: center; align-items: center; } |
24 | | - .game-container { width: 100%; height: 100%; border-radius: 8px; overflow: hidden; position: relative; } |
| 24 | + .game-container { width: 100%; height: 100%; border-radius: 8px; overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; } |
25 | 25 | #game { width: 100%; height: 100%; } |
26 | 26 |
|
27 | 27 | #loadingOverlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); z-index: 2000; display: none; align-items: center; justify-content: center; } |
|
438 | 438 | source: gameData.romSource, |
439 | 439 | name: gameData.romName.split('.').slice(0, -1).join('.'), |
440 | 440 | core: gameData.core, |
441 | | - biosSource: gameData.biosSource |
| 441 | + biosSource: gameData.biosSource, |
| 442 | + gameHeight: gameData.gameHeight || null |
442 | 443 | }; |
443 | 444 | setState(State.LOADING); |
444 | 445 | initializeEmulator(); |
|
465 | 466 | console.warn('Emulator cleanup error:', e); |
466 | 467 | } |
467 | 468 |
|
468 | | - // Clear game container |
469 | | - document.getElementById('game').innerHTML = ''; |
| 469 | + // Clear game container and reset height |
| 470 | + const container = document.querySelector('.game-container'); |
| 471 | + const gameEl = document.getElementById('game'); |
| 472 | + gameEl.innerHTML = ''; |
| 473 | + gameEl.style.height = ''; |
| 474 | + gameEl.style.width = ''; |
| 475 | + container.style.height = ''; |
| 476 | + container.style.width = ''; |
470 | 477 |
|
471 | 478 | // Reset state |
472 | 479 | pendingROM = null; |
|
519 | 526 | }, { passive: true }); |
520 | 527 | }); |
521 | 528 |
|
| 529 | + function applyGameHeight(heightPercent) { |
| 530 | + const container = document.querySelector('.game-container'); |
| 531 | + const gameEl = document.getElementById('game'); |
| 532 | + if (heightPercent) { |
| 533 | + container.style.height = heightPercent + 'vh'; |
| 534 | + container.style.width = '100%'; |
| 535 | + gameEl.style.height = '100%'; |
| 536 | + gameEl.style.width = '100%'; |
| 537 | + } else { |
| 538 | + container.style.height = '100%'; |
| 539 | + container.style.width = '100%'; |
| 540 | + } |
| 541 | + } |
| 542 | + |
522 | 543 | function initializeEmulator() { |
523 | 544 | window.EJS_player = '#game'; |
524 | 545 | window.EJS_pathtodata = 'EmulatorJS/data/'; |
|
530 | 551 | window.EJS_backgroundBlur = false; |
531 | 552 | window.EJS_backgroundColor = '#1a1a1a'; |
532 | 553 | window.EJS_defaultOptions = { "save-state-location": "browser" }; |
| 554 | + |
| 555 | + // Apply game height if specified |
| 556 | + if (pendingROM?.gameHeight) { |
| 557 | + applyGameHeight(pendingROM.gameHeight); |
| 558 | + } |
533 | 559 | // Disable network-dependent features |
534 | 560 | window.EJS_disableAutoLang = true; // Don't auto-fetch language files |
535 | 561 | window.EJS_language = "en"; // Use English (built-in, no fetch needed) |
|
562 | 588 | window.EJS_onGameStart = function() { |
563 | 589 | console.log('Game started'); |
564 | 590 | setState(State.PLAYING); |
| 591 | + // Reapply game height after EmulatorJS has initialized |
| 592 | + if (pendingROM?.gameHeight) { |
| 593 | + applyGameHeight(pendingROM.gameHeight); |
| 594 | + } |
565 | 595 | setTimeout(() => { |
566 | 596 | const ctx = EJS_emulator?.Module?.AL?.currentCtx?.audioCtx; |
567 | 597 | if (ctx?.state === 'suspended') { |
|
0 commit comments