Skip to content

Commit

Permalink
Go back to non-random screen image filename, but do two scene updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcglincy committed Dec 22, 2021
1 parent 7e0def8 commit 0a5a512
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/dungeondraw-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/dungeondraw-bundle.min.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/dungeon.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ export class Dungeon extends PlaceableObject {
// uncomment for jpg+compression
//const filename = `${canvas.scene.name}-dungeon.jpg`;
//const base64 = await canvas.app.renderer.extract.base64(this, "image/jpeg", 0.5);
const randString =
Math.random().toString(36).substring(2, 6) +
Math.random().toString(36).substring(2, 6);
const filename = `${canvas.scene.name}-dungeon-${randString}.png`;
const filename = `${canvas.scene.name}-dungeon.png`;
const base64 = await canvas.app.renderer.extract.base64(tempContainer);
const res = await fetch(base64);
const blob = await res.blob();
Expand All @@ -106,8 +103,11 @@ export class Dungeon extends PlaceableObject {
await FilePicker.upload("data", folder, file, {});
const path = folder ? folder + "/" + filename : filename;
// make sure we don't keep using a cached copy
// TODO: we only need to do this is we're keeping a fixed filename
// TextureLoader.loader.cache.delete(path);
TextureLoader.loader.cache.delete(path);
if (canvas.scene.data.img === path) {
// cheat to force a scene update when we're re-saving to the same filename
await canvas.scene.update({ img: null }, { render: false });
}
await canvas.scene.update({ img: path });

// remove our mask
Expand Down

0 comments on commit 0a5a512

Please sign in to comment.