-
Notifications
You must be signed in to change notification settings - Fork 967
feat(ui): add mini-hover overlay with in-game toggle #3371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import mouseIcon from "/images/MouseIconWhite.svg?url"; | |
| import ninjaIcon from "/images/NinjaIconWhite.svg?url"; | ||
| import settingsIcon from "/images/SettingIconWhite.svg?url"; | ||
| import sirenIcon from "/images/SirenIconWhite.svg?url"; | ||
| import swordIcon from "/images/SwordIcon.svg?url"; | ||
| import treeIcon from "/images/TreeIconWhite.svg?url"; | ||
| import musicIcon from "/images/music.svg?url"; | ||
|
|
||
|
|
@@ -54,6 +55,7 @@ export class SettingsModal extends LitElement implements Layer { | |
| this.userSettings.backgroundMusicVolume(), | ||
| ); | ||
| SoundManager.setSoundEffectsVolume(this.userSettings.soundEffectsVolume()); | ||
| this.applyMiniHoverOverlayClass(); | ||
| this.eventBus.on(ShowSettingsModalEvent, (event) => { | ||
| this.isVisible = event.isVisible; | ||
| this.shouldPause = event.shouldPause; | ||
|
|
@@ -168,6 +170,19 @@ export class SettingsModal extends LitElement implements Layer { | |
| this.requestUpdate(); | ||
| } | ||
|
|
||
| private applyMiniHoverOverlayClass() { | ||
| document.body.classList.toggle( | ||
| "mini-hover-overlay-disabled", | ||
| !this.userSettings.miniHoverOverlay(), | ||
| ); | ||
| } | ||
|
|
||
| private onToggleMiniHoverOverlayButtonClick() { | ||
| this.userSettings.toggleMiniHoverOverlay(); | ||
| this.applyMiniHoverOverlayClass(); | ||
| this.requestUpdate(); | ||
| } | ||
|
|
||
| private onExitButtonClick() { | ||
| // redirect to the home page | ||
| window.location.href = "/"; | ||
|
|
@@ -498,6 +513,32 @@ export class SettingsModal extends LitElement implements Layer { | |
| </div> | ||
| </button> | ||
|
|
||
| <button | ||
| class="flex gap-3 items-center w-full text-left p-3 hover:bg-slate-700 rounded-sm text-white transition-colors" | ||
| @click="${this.onToggleMiniHoverOverlayButtonClick}" | ||
| > | ||
| <img | ||
| src=${swordIcon} | ||
| alt="miniHoverOverlay" | ||
| width="20" | ||
| height="20" | ||
| style="filter: brightness(0) saturate(100%) invert(72%) sepia(56%) saturate(3204%) hue-rotate(176deg) brightness(99%) contrast(101%)" | ||
| /> | ||
| <div class="flex-1"> | ||
| <div class="font-medium"> | ||
| ${translateText("user_setting.mini_hover_overlay_label")} | ||
| </div> | ||
| <div class="text-sm text-slate-400"> | ||
| ${translateText("user_setting.mini_hover_overlay_desc")} | ||
| </div> | ||
| </div> | ||
| <div class="text-sm text-slate-400"> | ||
| ${this.userSettings.miniHoverOverlay() | ||
| ? translateText("user_setting.on") | ||
| : translateText("user_setting.off")} | ||
| </div> | ||
| </button> | ||
|
Comment on lines
+516
to
+540
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't show a no-op toggle on touch devices. The mini-hover overlay is desktop-only in this PR, but this row renders for every client. On mobile/tablet this becomes a saved setting with no visible effect. Please hide it there, or render it disabled with a short desktop-only hint. 🤖 Prompt for AI Agents |
||
|
|
||
| <div class="border-t border-slate-600 pt-3 mt-4"> | ||
| <button | ||
| class="flex gap-3 items-center w-full text-left p-3 hover:bg-red-600/20 rounded-sm text-red-400 transition-colors" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normalize
attackRatiobefore calculating preview troops.uiState.attackRatiois seeded as20, so this currently predictsmyPlayer.troops() * 20instead of 20% of the army. That makes the new blue-sword preview wildly wrong.Proposed fix
private predictedOutgoingAttackTroops(): number { const myPlayer = this.game.myPlayer(); if (!myPlayer) return 0; - const ratio = this.uiState?.attackRatio ?? 0; + const ratio = (this.uiState?.attackRatio ?? 0) / 100; return Math.max(0, Math.floor(myPlayer.troops() * ratio)); }📝 Committable suggestion
🤖 Prompt for AI Agents