From 4b92bd2558d52512eba5c9bd8ac669a09fd63f86 Mon Sep 17 00:00:00 2001 From: jahlib <60108339+jahlib@users.noreply.github.com> Date: Wed, 5 Nov 2025 21:24:05 +0300 Subject: [PATCH] move settings buttons move settings buttons from game desk to setting modal --- client/game.js | 85 +++++++++++++++----------- client/index.html | 77 +++++++++++++++++++----- client/style.css | 148 +++++++++++++++------------------------------- 3 files changed, 163 insertions(+), 147 deletions(-) diff --git a/client/game.js b/client/game.js index eddbb52..8f0c30f 100644 --- a/client/game.js +++ b/client/game.js @@ -89,23 +89,13 @@ class CardGame { } toggleSound() { - this.soundEnabled = !this.soundEnabled; + this.soundEnabled = this.soundToggle.checked; localStorage.setItem('soundEnabled', this.soundEnabled); - this.updateSoundButton(); } - updateSoundButton() { - const btn = document.getElementById('toggle-sound-btn'); - const icon = btn.querySelector('.sound-icon'); - if (this.soundEnabled) { - btn.classList.remove('muted'); - icon.textContent = 'πŸ”Š'; - btn.title = 'Π’Ρ‹ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ Π·Π²ΡƒΠΊ'; - } else { - btn.classList.add('muted'); - icon.textContent = 'πŸ”‡'; - btn.title = 'Π’ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ Π·Π²ΡƒΠΊ'; - } + toggleAnimations() { + this.animationsEnabled = this.animationsToggle.checked; + localStorage.setItem('animationsEnabled', this.animationsEnabled); } showAlert(message) { @@ -223,8 +213,14 @@ class CardGame { this.lobbyRulesContent = document.getElementById('lobby-rules-content'); // Главная страница this.closeRulesBtn = document.getElementById('close-rules-btn'); - // Sound button - this.toggleSoundBtn = document.getElementById('toggle-sound-btn'); + // Settings elements + this.settingsBtn = document.getElementById('settings-btn'); + this.settingsModal = document.getElementById('settings-modal'); + this.closeSettingsBtn = document.getElementById('close-settings-btn'); + this.fullscreenToggle = document.getElementById('fullscreen-toggle'); + this.soundToggle = document.getElementById('sound-toggle'); + this.animationsToggle = document.getElementById('animations-toggle'); + this.logToggle = document.getElementById('log-toggle'); // Leave game button and modal this.leaveGameBtn = document.getElementById('leave-game-btn'); @@ -237,8 +233,9 @@ class CardGame { this.playWith2BotsBtn = document.getElementById('play-with-2-bots-btn'); this.playWith3BotsBtn = document.getElementById('play-with-3-bots-btn'); - // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΡƒΠ΅ΠΌ состояниС ΠΊΠ½ΠΎΠΏΠΊΠΈ Π·Π²ΡƒΠΊΠ° - this.updateSoundButton(); + // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΡƒΠ΅ΠΌ состояниС Π°Π½ΠΈΠΌΠ°Ρ†ΠΈΠΉ + const savedAnimations = localStorage.getItem('animationsEnabled'); + this.animationsEnabled = savedAnimations !== null ? savedAnimations === 'true' : true; } initEventListeners() { @@ -261,26 +258,19 @@ class CardGame { this.drawCardBtn.addEventListener('click', () => this.drawCard()); this.skipTurnBtn.addEventListener('click', () => this.skipTurn()); - // Sound toggle - this.toggleSoundBtn.addEventListener('click', () => this.toggleSound()); + // Settings modal + this.settingsBtn.addEventListener('click', () => this.openSettings()); + this.closeSettingsBtn.addEventListener('click', () => this.closeSettings()); + this.fullscreenToggle.addEventListener('change', () => this.toggleFullscreen()); + this.soundToggle.addEventListener('change', () => this.toggleSound()); + this.animationsToggle.addEventListener('change', () => this.toggleAnimations()); + this.logToggle.addEventListener('change', () => this.toggleLog()); // Leave game button this.leaveGameBtn.addEventListener('click', () => this.showLeaveConfirm()); this.leaveConfirmBtn.addEventListener('click', () => this.confirmLeaveGame()); this.leaveCancelBtn.addEventListener('click', () => this.cancelLeaveGame()); - // Fullscreen button - const fullscreenBtn = document.getElementById('fullscreen-btn'); - if (fullscreenBtn) { - fullscreenBtn.addEventListener('click', () => this.toggleFullscreen()); - } - - // Toggle log button - const toggleLogBtn = document.getElementById('toggle-log-btn'); - if (toggleLogBtn) { - toggleLogBtn.addEventListener('click', () => this.toggleLog()); - } - // Suit selection document.querySelectorAll('.suit-btn').forEach(btn => { btn.addEventListener('click', (e) => { @@ -1207,17 +1197,38 @@ class CardGame { } toggleFullscreen() { - if (!document.fullscreenElement) { + if (this.fullscreenToggle.checked) { // Π’Ρ…ΠΎΠ΄ΠΈΠΌ Π² полноэкранный Ρ€Π΅ΠΆΠΈΠΌ document.documentElement.requestFullscreen().catch(err => { console.log('Error attempting to enable fullscreen:', err); + this.fullscreenToggle.checked = false; }); } else { // Π’Ρ‹Ρ…ΠΎΠ΄ΠΈΠΌ ΠΈΠ· полноэкранного Ρ€Π΅ΠΆΠΈΠΌΠ° - document.exitFullscreen(); + if (document.fullscreenElement) { + document.exitFullscreen(); + } } } + openSettings() { + // Π‘ΠΈΠ½Ρ…Ρ€ΠΎΠ½ΠΈΠ·ΠΈΡ€ΡƒΠ΅ΠΌ состояниС ΠΏΠ΅Ρ€Π΅ΠΊΠ»ΡŽΡ‡Π°Ρ‚Π΅Π»Π΅ΠΉ с Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΌΠΈ настройками + this.soundToggle.checked = this.soundEnabled; + this.animationsToggle.checked = this.animationsEnabled; + this.fullscreenToggle.checked = !!document.fullscreenElement; + + // Π‘ΠΈΠ½Ρ…Ρ€ΠΎΠ½ΠΈΠ·ΠΈΡ€ΡƒΠ΅ΠΌ состояниС Π»ΠΎΠ³Π° (провСряСм Π΅ΡΡ‚ΡŒ Π»ΠΈ класс hidden) + if (this.gameLog) { + this.logToggle.checked = !this.gameLog.classList.contains('hidden'); + } + + this.settingsModal.classList.add('active'); + } + + closeSettings() { + this.settingsModal.classList.remove('active'); + } + toggleLog() { if (!this.gameLog) return; @@ -1491,6 +1502,9 @@ class CardGame { // Анимация ΠΏΠΎΠ»Π΅Ρ‚Π° ΠΊΠ°Ρ€Ρ‚Ρ‹ ΠΎΡ‚ Ρ‚ΠΎΡ‡ΠΊΠΈ A Π΄ΠΎ Ρ‚ΠΎΡ‡ΠΊΠΈ B animateFlyingCard(fromElement, toElement, count = 1, delay = 0) { + // ΠŸΡ€ΠΎΠ²Π΅Ρ€ΡΠ΅ΠΌ Π²ΠΊΠ»ΡŽΡ‡Π΅Π½Ρ‹ Π»ΠΈ Π°Π½ΠΈΠΌΠ°Ρ†ΠΈΠΈ + if (!this.animationsEnabled) return; + setTimeout(() => { for (let i = 0; i < count; i++) { setTimeout(() => { @@ -1585,6 +1599,9 @@ class CardGame { // Анимация ΠΏΠ΅Ρ€Π΅ΠΌΠ΅ΡˆΠΈΠ²Π°Π½ΠΈΡ ΠΊΠΎΠ»ΠΎΠ΄Ρ‹ (ΠΊΠ°Ρ€Ρ‚Ρ‹ лСтят ΠΈΠ· сброса Π² ΠΊΠΎΠ»ΠΎΠ΄Ρƒ) animateDeckShuffle() { + // ΠŸΡ€ΠΎΠ²Π΅Ρ€ΡΠ΅ΠΌ Π²ΠΊΠ»ΡŽΡ‡Π΅Π½Ρ‹ Π»ΠΈ Π°Π½ΠΈΠΌΠ°Ρ†ΠΈΠΈ + if (!this.animationsEnabled) return; + const discardPile = this.discardPile; const deck = document.getElementById('deck'); diff --git a/client/index.html b/client/index.html index e4d04b3..fad45f8 100644 --- a/client/index.html +++ b/client/index.html @@ -116,10 +116,8 @@ πŸšͺ - - + + @@ -127,16 +125,6 @@ - - - - - -
@@ -290,6 +278,67 @@
+ + + diff --git a/client/style.css b/client/style.css index e73bbf4..19a8229 100644 --- a/client/style.css +++ b/client/style.css @@ -601,79 +601,6 @@ input[type="text"]:focus { transform: translateY(100%); } -/* Toggle Log Button (скрыта Π½Π° дСсктопС) */ -.toggle-log-btn { - position: fixed; - top: 20px; - left: 20px; - width: 50px; - height: 50px; - background: #0c3d0ace; - border: 2px solid #767676; - border-radius: 10px; - cursor: pointer; - display: none; - align-items: center; - justify-content: center; - font-size: 24px; - color: #1b6d3e; - transition: all 0.3s; - z-index: 1001; - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); -} - -.toggle-log-btn:hover { - background: #ebebebd7; - color: white; - transform: scale(1.1); -} - -.toggle-log-btn:active { - transform: scale(0.95); -} - -/* Toggle Sound Button */ -.toggle-sound-btn { - position: fixed; - top: 260px; - right: 20px; - width: 50px; - height: 50px; - background: #0c3d0ace; - border: 2px solid #767676; - border-radius: 10px; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 24px; - color: #187114; - transition: all 0.3s; - z-index: 1001; - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); -} - -.toggle-sound-btn:hover { - background: #ebebebd7; - color: white; - transform: scale(1.1); -} - -.toggle-sound-btn:active { - transform: scale(0.95); -} - -.toggle-sound-btn.muted { - background: rgba(136, 28, 28, 0.9); - border-color: #8b8b8b; - color: #e53935; -} - -.toggle-sound-btn.muted:hover { - background: #e53935; - color: white; -} - /* Leave Game Button */ .leave-game-btn { position: fixed; @@ -705,8 +632,8 @@ input[type="text"]:focus { transform: scale(0.95); } -/* Fullscreen Button */ -.fullscreen-btn { +/* Settings Button */ +.settings-btn { position: fixed; top: 80px; right: 20px; @@ -717,7 +644,7 @@ input[type="text"]:focus { border-radius: 10px; cursor: pointer; display: flex; - align-items: flex-end; + align-items: center; justify-content: center; font-size: 24px; color: #ffffff; @@ -726,13 +653,13 @@ input[type="text"]:focus { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); } -.fullscreen-btn:hover { +.settings-btn:hover { background: #ebebebd7; color: white; transform: scale(1.1); } -.fullscreen-btn:active { +.settings-btn:active { transform: scale(0.95); } @@ -1414,6 +1341,43 @@ border: 2px solid #ffd700; margin: 20px 0; } +/* Модалка настроСк */ +.settings-modal-content { + max-width: 500px; + position: relative; +} + +.settings-content { + padding: 20px 0; +} + +.setting-item { + display: flex; + justify-content: space-between; + align-items: center; + padding: 15px 0; + border-bottom: 1px solid rgba(118, 118, 118, 0.2); +} + +.setting-item:last-child { + border-bottom: none; +} + +.setting-label { + font-size: 16px; + font-weight: 500; + color: #4c4c4c; +} + +.setting-item .deck-size-toggle { + margin: 0; +} + +/* ΠŸΠ΅Ρ€Π΅ΠΊΠ»ΡŽΡ‡Π°Ρ‚Π΅Π»ΡŒ Π»ΠΎΠ³Π° - Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… */ +.setting-item.mobile-only { + display: none; +} + .rules-content h1, .rules-content h2, .rules-content h3 { @@ -1792,16 +1756,6 @@ border: 2px solid #ffd700; font-size: 12px; } - /* Toggle log button Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… */ - .toggle-log-btn { - display: flex; - width: 40px; - height: 40px; - font-size: 20px; - top: 10px; - left: 10px; - } - /* Leave game button Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… */ .leave-game-btn { width: 40px; @@ -1811,13 +1765,13 @@ border: 2px solid #ffd700; right: 10px; } - /* Fullscreen button Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… */ - .fullscreen-btn { + /* Settings button Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… - пСрСносим Π²Π»Π΅Π²ΠΎ */ + .settings-btn { width: 40px; height: 40px; font-size: 20px; - top: 60px; - right: 10px; + top: 10px; + left: 10px; } /* Rules button Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… */ @@ -1838,13 +1792,9 @@ border: 2px solid #ffd700; right: 10px; } - /* Toggle sound button Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… */ - .toggle-sound-btn { - width: 40px; - height: 40px; - font-size: 20px; - top: 60px; - left: 10px; + /* ΠŸΠΎΠΊΠ°Π·Ρ‹Π²Π°Π΅ΠΌ ΠΏΠ΅Ρ€Π΅ΠΊΠ»ΡŽΡ‡Π°Ρ‚Π΅Π»ΡŒ Π»ΠΎΠ³Π° Π² настройках Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… */ + .setting-item.mobile-only { + display: flex; } /* Game log Π½Π° ΠΌΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹Ρ… */