diff --git a/chat.js b/chat.js index 129b4524..afb41d49 100644 --- a/chat.js +++ b/chat.js @@ -456,7 +456,9 @@ function updateGameChatMessageVisibility() { } } -function chatInputActionFired() { +async function chatInputActionFired() { + if (!await ensurePlayerConfirmedChatAgeWarning()) return; + const chatInput = document.getElementById("chatInput"); if (!chatInput?.value.trim().length) return; @@ -563,7 +565,7 @@ function initChat() { document.getSelection().collapseToEnd(); }; gameChatInput.onblur = () => gameChatContainer.classList.remove('focused'); - gameChatInput.onkeydown = function (e) { + gameChatInput.onkeydown = async function (e) { if (e.key === 'Tab') { e.preventDefault(); cycleGameChatMode(); @@ -576,6 +578,7 @@ function initChat() { e.preventDefault(); if (!playerName) return; + if (!await ensurePlayerConfirmedChatAgeWarning()) return; switch (gameChatModeIndex) { case 0: if (!trySendMapMessage(chatMessageContent)) @@ -654,6 +657,18 @@ function trySendGlobalMessage(content) { return false; } +async function ensurePlayerConfirmedChatAgeWarning() { + if (globalConfig.chatAgeWarningConfirmed) return true; + + return new Promise(resolve => { + showConfirmLikeModal('chatAgeWarningModal', () => { + resolve(true); + globalConfig.chatAgeWarningConfirmed = true; + updateConfig(globalConfig, true); + }, () => resolve(false)); + }) +} + function addChatTip() { const tips = localizedMessages.chatTips.tips; if (++globalConfig.chatTipIndex >= Object.keys(tips).length) diff --git a/index.php b/index.php index e37bc727..fce75fcd 100644 --- a/index.php +++ b/index.php @@ -1755,6 +1755,7 @@ class="joystickBase" /> ✖