diff --git a/src/en/index.html b/src/en/index.html index f29a1074..715bc803 100644 --- a/src/en/index.html +++ b/src/en/index.html @@ -168,6 +168,15 @@
diff --git a/src/ko/index.html b/src/ko/index.html index 74b8374a..b65c6c6d 100644 --- a/src/ko/index.html +++ b/src/ko/index.html @@ -166,6 +166,15 @@
diff --git a/src/resources/js/ui_online.js b/src/resources/js/ui_online.js index b97024ea..8435ee04 100644 --- a/src/resources/js/ui_online.js +++ b/src/resources/js/ui_online.js @@ -67,6 +67,7 @@ const pendingOptions = { }; let pikaVolleyOnline = null; // it is set after loading the game assets +let willSaveReplayAutomatically = null; const chatOpenBtnAndChatDisablingBtnContainer = document.getElementById( 'chat-open-btn-and-chat-disabling-btn-container' @@ -183,6 +184,7 @@ export function setUpUI() { } }); + // For auto-fast-speed-checkbox const autoFastSpeedCheckboxElem = document.getElementById( 'auto-fast-speed-checkbox' ); @@ -214,6 +216,36 @@ export function setUpUI() { } }); + // For auto-save-replay-checkbox + const autoSaveReplayCheckbox = document.getElementById( + 'auto-save-replay-checkbox' + ); + try { + willSaveReplayAutomatically = + 'true' === window.localStorage.getItem('willSaveReplayAutomatically'); + } catch (err) { + console.log(err); + } + if (willSaveReplayAutomatically !== null) { + // @ts-ignore + autoSaveReplayCheckbox.checked = willSaveReplayAutomatically; + } else { + // @ts-ignore + willSaveReplayAutomatically = autoSaveReplayCheckbox.checked; + } + autoSaveReplayCheckbox.addEventListener('change', () => { + // @ts-ignore + willSaveReplayAutomatically = autoSaveReplayCheckbox.checked; + try { + window.localStorage.setItem( + 'willSaveReplayAutomatically', + String(willSaveReplayAutomatically) + ); + } catch (err) { + console.log(err); + } + }); + let bgmSetting = null; try { bgmSetting = window.localStorage.getItem('bgm'); @@ -453,8 +485,12 @@ export function setUpUI() { window.addEventListener('unload', closeConnection); window.addEventListener('beforeunload', function (e) { + // This is for exiting the window by the browser exit button while being connected with quick match server cleanUpFirestoreRelevants(); if (channel.isOpen) { + if (willSaveReplayAutomatically) { + replaySaver.saveAsFile(); + } // Cancel the event e.preventDefault(); // If you prevent default behavior in Mozilla Firefox prompt will always be shown // Chrome requires returnValue to be set @@ -890,6 +926,9 @@ export function askOptionsChangeReceivedFromPeer(options) { } export function noticeDisconnected() { + if (willSaveReplayAutomatically) { + replaySaver.saveAsFile(); + } document.getElementById('notice-disconnected').classList.remove('hidden'); } diff --git a/src/resources/style.css b/src/resources/style.css index 459819cf..e1d44303 100644 --- a/src/resources/style.css +++ b/src/resources/style.css @@ -402,6 +402,9 @@ div.margin-top, p.margin-top { margin-top: calc(2.5 * var(--font-size)); } +div.margin-top-a-little { + margin-top: var(--font-size); +} ul { margin-top: var(--font-size); margin-bottom: var(--font-size);