Start maybe working on a native app
This commit is contained in:
@@ -10,6 +10,7 @@ import { RENDER_LAYERS } from "@/common/everything_registry.ts";
|
||||
import { atlas_png } from "@/client/atlas.ts";
|
||||
import { RenderBenchmark } from "@/client/benchmark/benchmark.ts";
|
||||
import { format_report } from "@/client/benchmark/report.ts";
|
||||
import { platform } from "@/client/platform.ts";
|
||||
|
||||
// how often the totals that go through every chunk are worked out again, so the overlay doesn't slow the frames it's
|
||||
// measuring
|
||||
@@ -113,7 +114,7 @@ export class DebugOverlay {
|
||||
if (copy) {
|
||||
const switches = { ...render_debug, ...level_renderer.draw };
|
||||
lines.push(Object.entries(switches).map(([key, on]) => ` ${key}: ${on}`).join("\n"));
|
||||
copy_text(lines.join("\n")).catch(() => {});
|
||||
platform.write_clipboard(lines.join("\n")).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +138,7 @@ export class DebugOverlay {
|
||||
|
||||
// right after the benchmark, firefox and safari only let the page copy from a click
|
||||
#copy_benchmark() {
|
||||
copy_text(this.#benchmark_report!).then(
|
||||
platform.write_clipboard(this.#benchmark_report!).then(
|
||||
() => this.#benchmark_status = "The benchmark's results are on the clipboard",
|
||||
() => this.#benchmark_status = "Click above to copy the benchmark's results",
|
||||
);
|
||||
@@ -187,16 +188,3 @@ export class DebugOverlay {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pages that aren't https or localhost have no clipboard api, like a server on another computer, but the old way
|
||||
// still copies from a click
|
||||
function copy_text(text: string): Promise<void> {
|
||||
if (navigator.clipboard) return navigator.clipboard.writeText(text);
|
||||
const area = document.createElement("textarea");
|
||||
area.value = text;
|
||||
document.body.append(area);
|
||||
area.select();
|
||||
const copied = document.execCommand("copy");
|
||||
area.remove();
|
||||
return copied ? Promise.resolve() : Promise.reject(new Error("Couldn't copy"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user