MCPcopy Create free account
hub / github.com/Crain99/cc-reverse / processSpriteFrameSingle

Function processSpriteFrameSingle

src/core/resourceProcessor.js:505–561  ·  view source on GitHub ↗
(spriteData, name, key)

Source from the content-addressed store, hash-verified

503 },
504
505 isCompressedFormat(data) {
506 if (!Array.isArray(data) || data.length < 2) return false;
507 const header = data[0];
508 return Array.isArray(header) && header.length > 0 && typeof header[0] === 'string';
509 },
510
511 restoreCompressedData(data) {
512 if (!this.isCompressedFormat(data)) {
513 this.resolveReferences(data);
514 this.decodeUuids(data);
515 return data;
516 }
517
518 const { typeDefinitions } = require('./typeDefinitions');
519 const typeList = data[0];
520 const result = [typeList];
521
522 for (let i = 1; i < data.length; i++) {
523 const item = data[i];
524 if (Array.isArray(item) && item.length > 0 && typeof item[0] === 'number') {
525 const typeIndex = item[0];
526 const typeName = typeList[typeIndex];
527 if (typeName) {
528 const obj = this.arrayToObject(typeName, item.slice(1), typeDefinitions);
529 result.push(obj);
530 } else {
531 result.push(item);
532 }
533 } else if (typeof item === 'object' && item !== null) {
534 result.push(item);
535 } else {
536 result.push(item);
537 }
538 }
539
540 this.resolveReferences(result);
541 this.decodeUuids(result);
542 return result;
543 },
544
545 arrayToObject(typeName, values, typeDefinitions) {
546 const settings = this.getCCSettings();
547 let properties = null;
548
549 if (settings && settings.types && settings.types[typeName]) {
550 properties = settings.types[typeName];
551 }
552 if (!properties) {
553 properties = typeDefinitions.getProperties(typeName);
554 }
555 if (!properties) {
556 return { __type__: typeName, _values: values };
557 }
558
559 const obj = { __type__: typeName };
560 for (let i = 0; i < values.length && i < properties.length; i++) {
561 obj[properties[i]] = values[i];
562 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected