mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 09:14:09 +00:00
fix preview stuff
This commit is contained in:
@@ -1234,6 +1234,8 @@
|
|||||||
},
|
},
|
||||||
"preview": {
|
"preview": {
|
||||||
"finish": "Finish preview",
|
"finish": "Finish preview",
|
||||||
|
"light_theme": "Light theme",
|
||||||
|
"dark_theme": "Dark theme",
|
||||||
"complete_title": "Preview Complete",
|
"complete_title": "Preview Complete",
|
||||||
"complete_subtitle": "Like what you see? Make it yours.",
|
"complete_subtitle": "Like what you see? Make it yours.",
|
||||||
"exit": "Back to menu",
|
"exit": "Back to menu",
|
||||||
|
|||||||
@@ -2,28 +2,38 @@ import { html, LitElement } from "lit";
|
|||||||
import { customElement, state } from "lit/decorators.js";
|
import { customElement, state } from "lit/decorators.js";
|
||||||
import { EventBus } from "../../../core/EventBus";
|
import { EventBus } from "../../../core/EventBus";
|
||||||
import { GameView } from "../../../core/game/GameView";
|
import { GameView } from "../../../core/game/GameView";
|
||||||
|
import { UserSettings } from "../../../core/game/UserSettings";
|
||||||
import "../../components/baseComponents/Button";
|
import "../../components/baseComponents/Button";
|
||||||
import { Controller } from "../../Controller";
|
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
|
* Top-of-screen toolbar shown only during a skin preview. Lets the player flip
|
||||||
* the preview by opening <preview-complete-modal>. The preview itself never
|
* the map between light/dark themes to see the cosmetic both ways, and finish
|
||||||
* auto-ends, so this is the player's way out.
|
* the preview (the preview never auto-ends) — which opens
|
||||||
|
* <preview-complete-modal>.
|
||||||
*/
|
*/
|
||||||
@customElement("preview-finish-button")
|
@customElement("preview-finish-button")
|
||||||
export class PreviewFinishButton extends LitElement implements Controller {
|
export class PreviewFinishButton extends LitElement implements Controller {
|
||||||
public game: GameView;
|
public game: GameView;
|
||||||
public eventBus: EventBus;
|
public eventBus: EventBus;
|
||||||
|
|
||||||
|
private userSettings = new UserSettings();
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
private isPreview = false;
|
private isPreview = false;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
private isDark = false;
|
||||||
|
|
||||||
createRenderRoot() {
|
createRenderRoot() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.isPreview = this.game?.config().isPreview() ?? false;
|
this.isPreview = this.game?.config().isPreview() ?? false;
|
||||||
|
this.isDark = this.userSettings.darkMode();
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,10 +46,27 @@ export class PreviewFinishButton extends LitElement implements Controller {
|
|||||||
modal?.show?.();
|
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() {
|
render() {
|
||||||
if (!this.isPreview) return html``;
|
if (!this.isPreview) return html``;
|
||||||
return html`
|
return html`
|
||||||
<div class="fixed bottom-6 left-1/2 -translate-x-1/2 z-[10005]">
|
<div
|
||||||
|
class="fixed top-6 left-1/2 -translate-x-1/2 z-[10005] flex items-center gap-2"
|
||||||
|
>
|
||||||
|
<o-button
|
||||||
|
variant="secondary"
|
||||||
|
.title=${this.isDark
|
||||||
|
? translateText("preview.light_theme")
|
||||||
|
: translateText("preview.dark_theme")}
|
||||||
|
@click=${this.toggleTheme}
|
||||||
|
></o-button>
|
||||||
<o-button
|
<o-button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
translationKey="preview.finish"
|
translationKey="preview.finish"
|
||||||
|
|||||||
@@ -667,10 +667,11 @@ news-button .active button::after {
|
|||||||
|
|
||||||
/* Cinematic skin-preview mode: hide the normal in-game HUD so the player can
|
/* Cinematic skin-preview mode: hide the normal in-game HUD so the player can
|
||||||
just watch their previewed cosmetic spread across the map. The game canvas,
|
just watch their previewed cosmetic spread across the map. The game canvas,
|
||||||
<preview-finish-button>, and <preview-complete-modal> stay visible. */
|
the bottom build bar (<unit-display>), <preview-finish-button>, and
|
||||||
|
<preview-complete-modal> stay visible; the Ctrl+click build popup
|
||||||
|
(<build-menu>) is hidden. */
|
||||||
body.preview-mode build-menu,
|
body.preview-mode build-menu,
|
||||||
body.preview-mode control-panel,
|
body.preview-mode control-panel,
|
||||||
body.preview-mode unit-display,
|
|
||||||
body.preview-mode attacks-display,
|
body.preview-mode attacks-display,
|
||||||
body.preview-mode chat-display,
|
body.preview-mode chat-display,
|
||||||
body.preview-mode events-display,
|
body.preview-mode events-display,
|
||||||
|
|||||||
Reference in New Issue
Block a user