fix: defaults

This commit is contained in:
cha0s 2021-04-01 21:30:51 -05:00
parent 3db9eefcc5
commit 7f4a80a767

View File

@ -156,10 +156,16 @@ export default (latus) => class Pictured extends decorate(Trait) {
async load(json = {}) {
await super.load(json);
const {images} = this.params;
const images = {
...this.params.images,
default: {
...(this.params.images.default || {}),
uri: this.entity.uri && !this.params.images.default.uri
? this.entity.uri.replace('.entity.json', '.png')
: this.params.images.default.uri,
},
};
this.#currentImage = this.state.currentImage;
images.default = images.default || {};
images.default.uri = images.default.uri || this.entity.uri.replace('.entity.json', '.png');
const {Image} = latus.get('%resources');
this.#images = await mapValuesAsync(images, ({uri}) => Image.load(uri));
this.#sprites = await mapValuesAsync(this.#images, async (image) => new Sprite(image));