More clean up
This commit is contained in:
parent
c94ffcc506
commit
f03da42b5e
43 changed files with 818 additions and 1076 deletions
|
|
@ -29,7 +29,7 @@ export default class GameLoop {
|
|||
private readonly agentPopulation: AgentPopulation;
|
||||
private readonly exportSnapshotRenderer: ExportSnapshotRenderer;
|
||||
private readonly framePerformance = new FramePerformance();
|
||||
private readonly devStatsOverlay: DevStatsOverlay | null;
|
||||
private devStatsOverlay: DevStatsOverlay | null = null;
|
||||
private readonly toolbarContrastMonitor: ToolbarContrastMonitor;
|
||||
private readonly seedValue = Math.floor(Math.random() * 0xffffffff);
|
||||
private readonly seed = this.seedValue.toString(16);
|
||||
|
|
@ -47,9 +47,6 @@ export default class GameLoop {
|
|||
ui: GardenUi
|
||||
) {
|
||||
this.resize();
|
||||
this.devStatsOverlay = import.meta.env.DEV
|
||||
? new DevStatsOverlay(canvas.parentElement ?? document.body)
|
||||
: null;
|
||||
this.resources = new GameLoopResources(
|
||||
canvas,
|
||||
device,
|
||||
|
|
@ -103,8 +100,12 @@ export default class GameLoop {
|
|||
});
|
||||
|
||||
window.addEventListener('resize', this.resizeListener);
|
||||
this.pointerInput.attach();
|
||||
this.eraserPreviewController.attach();
|
||||
this.syncDevStatsOverlay();
|
||||
}
|
||||
|
||||
public attachPointerInput(): void {
|
||||
this.pointerInput.attach();
|
||||
}
|
||||
|
||||
public setEraseMode(isErasing: boolean): void {
|
||||
|
|
@ -118,6 +119,7 @@ export default class GameLoop {
|
|||
|
||||
public onVibeChanged(): void {
|
||||
this.agentPopulation.onVibeChanged();
|
||||
this.syncDevStatsOverlay();
|
||||
}
|
||||
|
||||
public setAudioMuted(isMuted: boolean): void {
|
||||
|
|
@ -153,6 +155,7 @@ export default class GameLoop {
|
|||
this.pointerInput.detach();
|
||||
this.eraserPreviewController.detach();
|
||||
this.devStatsOverlay?.destroy();
|
||||
this.devStatsOverlay = null;
|
||||
this.toolbarContrastMonitor.destroy();
|
||||
this.introPrompt.destroy();
|
||||
await this.agentPopulation.waitForCompaction();
|
||||
|
|
@ -220,6 +223,18 @@ export default class GameLoop {
|
|||
requestAnimationFrame(this.render);
|
||||
};
|
||||
|
||||
private syncDevStatsOverlay(): void {
|
||||
if (appConfig.tuningPane.showFpsOverlay) {
|
||||
this.devStatsOverlay ??= new DevStatsOverlay(
|
||||
this.canvas.parentElement ?? document.body
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.devStatsOverlay?.destroy();
|
||||
this.devStatsOverlay = null;
|
||||
}
|
||||
|
||||
private updateAccentColor(color: RgbColor): void {
|
||||
const accentColor = rgbColorToCss(color);
|
||||
if (this.previousAccentColor === accentColor) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue