-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix animation sound loss during undo/redo (#718)
* fix warning * fix animation sound during export & load
- Loading branch information
Showing
11 changed files
with
62 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import { Sprite } from '../sprite' | ||
import { Animation } from '../animation' | ||
import { Sound } from '../sound' | ||
import { Costume } from '../costume' | ||
import { fromText } from '../common/file' | ||
import { Project } from '.' | ||
|
||
function mockFile(name = 'mocked') { | ||
return fromText(name, Math.random() + '') | ||
} | ||
|
||
function makeProject() { | ||
const project = new Project() | ||
const sprite = new Sprite('Sprite') | ||
const costume = new Costume('default', mockFile()) | ||
sprite.addCostume(costume) | ||
const animationCostumes = Array.from({ length: 3 }, (_, i) => new Costume(`a${i}`, mockFile())) | ||
const animation = Animation.create('default', animationCostumes) | ||
sprite.addAnimation(animation) | ||
const sound = new Sound('sound', mockFile()) | ||
project.addSprite(sprite) | ||
project.addSound(sound) | ||
return project | ||
} | ||
|
||
describe('Project', () => { | ||
it('should preserve animation sound with exportGameFiles & loadGameFiles', async () => { | ||
const project = makeProject() | ||
const sprite = project.sprites[0] | ||
const animation = sprite.animations[0] | ||
animation.setSound(project.sounds[0].name) | ||
|
||
const files = project.exportGameFiles() | ||
await project.loadGameFiles(files) | ||
expect(project.sprites[0].animations[0].sound).toBe(project.sounds[0].name) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters