mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-10 21:54:15 +00:00
fix close
This commit is contained in:
@@ -52,6 +52,7 @@ export class WebGPUDebugOverlay extends LitElement implements Layer {
|
|||||||
private tickComputeMs: number = 0;
|
private tickComputeMs: number = 0;
|
||||||
|
|
||||||
private frameTimes: number[] = [];
|
private frameTimes: number[] = [];
|
||||||
|
private lastDebugEnabled: boolean | null = null;
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
.overlay {
|
.overlay {
|
||||||
@@ -83,6 +84,30 @@ export class WebGPUDebugOverlay extends LitElement implements Layer {
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.titleLeft {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.closeButton {
|
||||||
|
appearance: none;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: rgba(255, 255, 255, 0.75);
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 16px;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.closeButton:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
}
|
||||||
|
|
||||||
.metrics {
|
.metrics {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
@@ -158,6 +183,7 @@ export class WebGPUDebugOverlay extends LitElement implements Layer {
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.eventBus.on(WebGPUComputeMetricsEvent, (e) => {
|
this.eventBus.on(WebGPUComputeMetricsEvent, (e) => {
|
||||||
|
this.syncDebugVisibility();
|
||||||
if (typeof e.computeMs === "number" && Number.isFinite(e.computeMs)) {
|
if (typeof e.computeMs === "number" && Number.isFinite(e.computeMs)) {
|
||||||
this.tickComputeMs = e.computeMs;
|
this.tickComputeMs = e.computeMs;
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
@@ -166,8 +192,17 @@ export class WebGPUDebugOverlay extends LitElement implements Layer {
|
|||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private syncDebugVisibility(): boolean {
|
||||||
|
const enabled = !!this.userSettings?.webgpuDebug();
|
||||||
|
if (this.lastDebugEnabled !== enabled) {
|
||||||
|
this.lastDebugEnabled = enabled;
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
updateFrameMetrics(frameDurationMs: number): void {
|
updateFrameMetrics(frameDurationMs: number): void {
|
||||||
if (!this.userSettings || !this.userSettings.webgpuDebug()) {
|
if (!this.syncDebugVisibility()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,6 +221,14 @@ export class WebGPUDebugOverlay extends LitElement implements Layer {
|
|||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private close(): void {
|
||||||
|
if (!this.userSettings) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.userSettings.set("settings.webgpuDebug", false);
|
||||||
|
this.syncDebugVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
private selectedShaderId() {
|
private selectedShaderId() {
|
||||||
const selected = this.userSettings.getInt(TERRITORY_SHADER_KEY, 0);
|
const selected = this.userSettings.getInt(TERRITORY_SHADER_KEY, 0);
|
||||||
return territoryShaderIdFromInt(selected);
|
return territoryShaderIdFromInt(selected);
|
||||||
@@ -330,7 +373,15 @@ export class WebGPUDebugOverlay extends LitElement implements Layer {
|
|||||||
return html`
|
return html`
|
||||||
<div class="overlay">
|
<div class="overlay">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div>WebGPU Debug</div>
|
<div class="titleLeft">WebGPU Debug</div>
|
||||||
|
<button
|
||||||
|
class="closeButton"
|
||||||
|
title="Close"
|
||||||
|
aria-label="Close WebGPU Debug overlay"
|
||||||
|
@click=${() => this.close()}
|
||||||
|
>
|
||||||
|
×
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sectionTitle">Renderer</div>
|
<div class="sectionTitle">Renderer</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user