mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-20 08:58:41 +00:00
属性排序
This commit is contained in:
parent
3e0dd01b14
commit
807e0c83ef
@ -142,6 +142,24 @@ export class Group {
|
|||||||
addProperty(property: Property) {
|
addProperty(property: Property) {
|
||||||
this.data.push(property)
|
this.data.push(property)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort() {
|
||||||
|
let order = ['name', 'uuid', 'position', 'rotation', 'scale', 'anchor', 'size', 'color', 'opacity', 'skew', 'group'];
|
||||||
|
let orderKeys: Array<Property> = [];
|
||||||
|
let otherKeys: Array<Property> = [];
|
||||||
|
this.data.forEach(property => {
|
||||||
|
if (order.find(el => el === property.name)) {
|
||||||
|
orderKeys.push(property)
|
||||||
|
} else {
|
||||||
|
otherKeys.push(property);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
orderKeys.sort((a, b) => {
|
||||||
|
return order.indexOf(a.name) - order.indexOf(b.name);
|
||||||
|
})
|
||||||
|
otherKeys.sort();
|
||||||
|
this.data = orderKeys.concat(otherKeys);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testData = [
|
export const testData = [
|
||||||
|
@ -176,6 +176,7 @@ class CCInspector {
|
|||||||
rotation: ["rotationX", "rotationY"],
|
rotation: ["rotationX", "rotationY"],
|
||||||
anchor: ["anchorX", "anchorY"],
|
anchor: ["anchorX", "anchorY"],
|
||||||
size: ["width", "height"],
|
size: ["width", "height"],
|
||||||
|
skew: ['skewX', 'skewY'],
|
||||||
position: ["x", "y", "z"],
|
position: ["x", "y", "z"],
|
||||||
scale: ["scaleX", "scaleY", "scaleZ"],
|
scale: ["scaleX", "scaleY", "scaleZ"],
|
||||||
designResolution: ["width", "height"], // 这个比较特殊,在key下边,其他的都不是在key下
|
designResolution: ["width", "height"], // 这个比较特殊,在key下边,其他的都不是在key下
|
||||||
@ -230,16 +231,18 @@ class CCInspector {
|
|||||||
_getGroupData(node: any) {
|
_getGroupData(node: any) {
|
||||||
let nodeGroup = new Group(node.constructor.name);
|
let nodeGroup = new Group(node.constructor.name);
|
||||||
let keys = this._getNodeKeys(node);
|
let keys = this._getNodeKeys(node);
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length;) {
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
let propertyValue = node[key];
|
let propertyValue = node[key];
|
||||||
let pair = this._getPairProperty(key);
|
let pair = this._getPairProperty(key);
|
||||||
if (pair) {
|
if (pair) {
|
||||||
|
let bSplice = false;
|
||||||
// 把这个成对的属性剔除掉
|
// 把这个成对的属性剔除掉
|
||||||
pair.values.forEach((item: string) => {
|
pair.values.forEach((item: string) => {
|
||||||
let index = keys.findIndex(el => el === item);
|
let index = keys.findIndex(el => el === item);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
keys.splice(index, 1);
|
keys.splice(index, 1);
|
||||||
|
bSplice = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 序列化成对的属性
|
// 序列化成对的属性
|
||||||
@ -265,14 +268,19 @@ class CCInspector {
|
|||||||
let property = new Property(pair.key, info);
|
let property = new Property(pair.key, info);
|
||||||
nodeGroup.addProperty(property);
|
nodeGroup.addProperty(property);
|
||||||
}
|
}
|
||||||
|
if (!bSplice) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let propertyPath = [node.uuid, key];
|
let propertyPath = [node.uuid, key];
|
||||||
let info = this._genInfoData(propertyValue, propertyPath);
|
let info = this._genInfoData(propertyValue, propertyPath);
|
||||||
if (info) {
|
if (info) {
|
||||||
nodeGroup.addProperty(new Property(key, info));
|
nodeGroup.addProperty(new Property(key, info));
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nodeGroup.sort();
|
||||||
return nodeGroup;
|
return nodeGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,6 +318,7 @@ class CCInspector {
|
|||||||
let nodeOrComp = this.inspectorGameMemoryStorage[uuid];
|
let nodeOrComp = this.inspectorGameMemoryStorage[uuid];
|
||||||
if (nodeOrComp && key in nodeOrComp) {
|
if (nodeOrComp && key in nodeOrComp) {
|
||||||
debugger
|
debugger
|
||||||
|
|
||||||
function circleFind(base: Object): boolean {
|
function circleFind(base: Object): boolean {
|
||||||
let obj = Object.getPrototypeOf(base);
|
let obj = Object.getPrototypeOf(base);
|
||||||
let ret = Object.getOwnPropertyDescriptor(obj, key)
|
let ret = Object.getOwnPropertyDescriptor(obj, key)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user