Skip to content

Commit d53c22e

Browse files
committed
imp: support file field shortcuts
instead of needing to do `{ type: ‘file’, kind: ‘emote’ }` you can now use the shorthand `{ type: ‘emote’ }`
1 parent d6cf7c8 commit d53c22e

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/core/systems/Apps.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,11 @@ export class Apps extends System {
331331
if (!isArray(entity.fields)) {
332332
entity.fields = []
333333
}
334-
// apply any initial values
335334
const props = entity.blueprint.props
336335
for (const field of entity.fields) {
336+
// apply file shortcuts
337+
fileRemaps[field.type]?.(field)
338+
// apply any initial values
337339
if (field.initial !== undefined && props[field.key] === undefined) {
338340
props[field.key] = field.initial
339341
}
@@ -378,3 +380,38 @@ export class Apps extends System {
378380
}
379381
}
380382
}
383+
384+
export const fileRemaps = {
385+
avatar: field => {
386+
field.type = 'file'
387+
field.kind = 'avatar'
388+
},
389+
emote: field => {
390+
field.type = 'file'
391+
field.kind = 'emote'
392+
},
393+
model: field => {
394+
field.type = 'file'
395+
field.kind = 'model'
396+
},
397+
texture: field => {
398+
field.type = 'file'
399+
field.kind = 'texture'
400+
},
401+
image: field => {
402+
field.type = 'file'
403+
field.kind = 'image'
404+
},
405+
video: field => {
406+
field.type = 'file'
407+
field.kind = 'video'
408+
},
409+
hdr: field => {
410+
field.type = 'file'
411+
field.kind = 'hdr'
412+
},
413+
audio: field => {
414+
field.type = 'file'
415+
field.kind = 'audio'
416+
},
417+
}

0 commit comments

Comments
 (0)