mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-24 08:26:01 +00:00
add url parameter for saving to the local file system &mock-save
This commit is contained in:
@@ -39,6 +39,7 @@ import "./anim-editor.element";
|
||||
import "./help.element";
|
||||
|
||||
import "./app.element.scss";
|
||||
import { mock_save_load } from "./util";
|
||||
|
||||
@customElement("app-root")
|
||||
@provide({
|
||||
@@ -72,13 +73,36 @@ export class AppElement extends LitElement {
|
||||
async onSceneSaved({ detail: scene }: SceneSavedEvent): Promise<void> {
|
||||
try {
|
||||
const file = new File([scene], "scene.scn.ron", { type: "text/ron" });
|
||||
const token = await this.api.createScene(file);
|
||||
if (mock_save_load()) {
|
||||
let handle = await window.showSaveFilePicker({
|
||||
suggestedName: "scene",
|
||||
types: [{
|
||||
description: "Scene Files",
|
||||
accept: {
|
||||
"text/ron": [".scn.ron"]
|
||||
}
|
||||
}]
|
||||
});
|
||||
let writable = await handle.createWritable();
|
||||
await writable.write(file);
|
||||
await writable.close();
|
||||
let token = handle.name;
|
||||
|
||||
this.dispatchEvent(new CustomEvent("scene-uploaded", {
|
||||
detail: token,
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
}));
|
||||
this.dispatchEvent(new CustomEvent("scene-uploaded", {
|
||||
detail: token,
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
}));
|
||||
|
||||
} else {
|
||||
const token = await this.api.createScene(file);
|
||||
|
||||
this.dispatchEvent(new CustomEvent("scene-uploaded", {
|
||||
detail: token,
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
}));
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
|
||||
@@ -3,3 +3,7 @@ export function isDevEnvironment(): boolean {
|
||||
|| window.location.hostname === "127.0.0.1"
|
||||
|| window.location.hostname.includes("deploy-preview");
|
||||
}
|
||||
|
||||
export function mock_save_load(): boolean {
|
||||
return window.location.search.includes("mock-saves");
|
||||
}
|
||||
Reference in New Issue
Block a user