diff --git a/resources/lang/en.json b/resources/lang/en.json index 5d8ff872d..a092d8695 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -1234,6 +1234,8 @@ }, "preview": { "finish": "Finish preview", + "light_theme": "Light theme", + "dark_theme": "Dark theme", "complete_title": "Preview Complete", "complete_subtitle": "Like what you see? Make it yours.", "exit": "Back to menu", diff --git a/src/client/hud/layers/PreviewFinishButton.ts b/src/client/hud/layers/PreviewFinishButton.ts index 26c1325b1..e5220682a 100644 --- a/src/client/hud/layers/PreviewFinishButton.ts +++ b/src/client/hud/layers/PreviewFinishButton.ts @@ -2,28 +2,38 @@ import { html, LitElement } from "lit"; import { customElement, state } from "lit/decorators.js"; import { EventBus } from "../../../core/EventBus"; import { GameView } from "../../../core/game/GameView"; +import { UserSettings } from "../../../core/game/UserSettings"; import "../../components/baseComponents/Button"; import { Controller } from "../../Controller"; +import { RefreshGraphicsEvent } from "../../InputHandler"; +import { translateText } from "../../Utils"; /** - * Always-on overlay button shown only during a skin preview. Clicking it ends - * the preview by opening . The preview itself never - * auto-ends, so this is the player's way out. + * Top-of-screen toolbar shown only during a skin preview. Lets the player flip + * the map between light/dark themes to see the cosmetic both ways, and finish + * the preview (the preview never auto-ends) — which opens + * . */ @customElement("preview-finish-button") export class PreviewFinishButton extends LitElement implements Controller { public game: GameView; public eventBus: EventBus; + private userSettings = new UserSettings(); + @state() private isPreview = false; + @state() + private isDark = false; + createRenderRoot() { return this; } init() { this.isPreview = this.game?.config().isPreview() ?? false; + this.isDark = this.userSettings.darkMode(); this.requestUpdate(); } @@ -36,10 +46,27 @@ export class PreviewFinishButton extends LitElement implements Controller { modal?.show?.(); } + private toggleTheme() { + // Same path the in-game settings toggle uses: flip the darkMode setting + // (a listener maps it to the renderer's day/night mode) and force a redraw. + this.userSettings.toggleDarkMode(); + this.eventBus.emit(new RefreshGraphicsEvent()); + this.isDark = this.userSettings.darkMode(); + } + render() { if (!this.isPreview) return html``; return html` -
+
+ , and stay visible. */ + the bottom build bar (), , and + stay visible; the Ctrl+click build popup + () is hidden. */ body.preview-mode build-menu, body.preview-mode control-panel, -body.preview-mode unit-display, body.preview-mode attacks-display, body.preview-mode chat-display, body.preview-mode events-display,