mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Scenes: an import counts appended packs as built in, as drafts do
This commit is contained in:
1 parent
c8b440dded
commit
de0be208da
2 files changed
+31
-7
No files matched your search
@@ -80,6 +80,11 @@ import { sceneSaveFailureReason } from './sceneSaveError.js';
|
||||
import { STORY_TAG_LIMIT, STORY_TAGS } from './storyTags.js';
|
||||
import { captureStoryThumb } from './storyThumb.js';
|
||||
|
||||
/** Scenes GEV ships (recipes and appended packs), as opposed to a person's own. */
|
||||
const BUILT_IN_SCENE_IDS = new Set(
|
||||
[...SCENE_RECIPES, ...SCENE_APPEND_RECIPES].map(({ id }) => id),
|
||||
);
|
||||
|
||||
/** @constant {string} localStorage key for the serialized project */
|
||||
const STORAGE_KEY = 'godsEyeView.sceneProject.v2';
|
||||
const STORAGE_CHECKPOINT_KEY = 'godsEyeView.sceneProject.checkpoint.v1';
|
||||
@@ -2078,15 +2083,12 @@ export class SceneDirector {
|
||||
* @returns {Array<{id: string, title: string, camera: object, shotCount: number, thumb: string, tags: string[]}>}
|
||||
*/
|
||||
draftScenes() {
|
||||
const builtIn = new Set(
|
||||
[...SCENE_RECIPES, ...SCENE_APPEND_RECIPES].map(({ id }) => id),
|
||||
);
|
||||
return this._project.scenes
|
||||
.filter(
|
||||
(scene) =>
|
||||
scene.stories !== true &&
|
||||
scene.shots.length > 0 &&
|
||||
!builtIn.has(scene.id),
|
||||
!BUILT_IN_SCENE_IDS.has(scene.id),
|
||||
)
|
||||
.map((scene) => ({
|
||||
id: scene.id,
|
||||
@@ -2535,11 +2537,10 @@ export class SceneDirector {
|
||||
this._storageReadError = null;
|
||||
// Keep authoring on the named or current scene, else the first scene
|
||||
// that is not a built-in one, else the first scene.
|
||||
const builtIn = new Set(SCENE_RECIPES.map(({ id }) => id));
|
||||
const selected =
|
||||
project.scenes.find(({ id }) => id === selection?.sceneId) ||
|
||||
project.scenes.find(({ id }) => id === this._selectedSceneId) ||
|
||||
project.scenes.find(({ id }) => !builtIn.has(id)) ||
|
||||
project.scenes.find(({ id }) => !BUILT_IN_SCENE_IDS.has(id)) ||
|
||||
project.scenes[0] ||
|
||||
null;
|
||||
this._selectedSceneId = selected?.id ?? null;
|
||||
|
||||
@@ -22,7 +22,11 @@ import { LayerLifecycle } from '../data/lifecycle.js';
|
||||
import { SceneDirector } from './director.js';
|
||||
import { stringifySceneDocument } from '../director/document.js';
|
||||
import { SCENE_TRACKING_PARAM_KEYS } from './scenePolicy.js';
|
||||
import { SCENE_RECIPES, getSceneAppendRecipeById } from './recipes.js';
|
||||
import {
|
||||
SCENE_APPEND_RECIPES,
|
||||
SCENE_RECIPES,
|
||||
getSceneAppendRecipeById,
|
||||
} from './recipes.js';
|
||||
import { STORY_TAGS } from './storyTags.js';
|
||||
|
||||
const NEPAL_ORIGINAL_SHOT_TITLES = [
|
||||
@@ -2534,6 +2538,25 @@ test('an import keeps the current scene, else picks a non-built-in scene, else t
|
||||
SCENE_RECIPES[0].id,
|
||||
'a built-in scene only when there is nothing else',
|
||||
);
|
||||
// An appended pack's scene is built in too, as Stories' drafts count it.
|
||||
const [pack] = SCENE_APPEND_RECIPES;
|
||||
const withPack = JSON.stringify({
|
||||
version: 6,
|
||||
scenes: [
|
||||
{ ...structuredClone(PROJECT_FIXTURE.scenes[0]), id: pack.id },
|
||||
{ ...structuredClone(PROJECT_FIXTURE.scenes[0]), id: 'mine' },
|
||||
],
|
||||
});
|
||||
director._selectedSceneId = null;
|
||||
assert.equal(
|
||||
await director.importProjectFile({
|
||||
name: 'c.json',
|
||||
text: async () => withPack,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(director._selectedSceneId, 'mine');
|
||||
assert.deepEqual(director.draftScenes().map(({ id }) => id), ['mine']);
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user