2024-12-09 20:49:02 +08:00
|
|
|
|
import { ITreeData } from '@xuyanfeng/cc-ui/types/cc-tree/const';
|
2024-12-09 16:23:58 +08:00
|
|
|
|
import { v4 } from "uuid";
|
2021-04-04 19:21:17 +08:00
|
|
|
|
export enum DataType {
|
2024-01-09 12:02:47 +08:00
|
|
|
|
Number = 'Number',
|
|
|
|
|
String = 'String',
|
|
|
|
|
Text = 'Text',
|
|
|
|
|
Vec2 = 'Vec2',
|
|
|
|
|
Vec3 = 'Vec3',
|
2024-12-11 14:56:50 +08:00
|
|
|
|
Vec4 = 'Vec4',
|
2024-01-09 12:02:47 +08:00
|
|
|
|
Enum = 'Enum',
|
|
|
|
|
Bool = 'Bool',
|
|
|
|
|
Color = 'Color',
|
|
|
|
|
Invalid = 'Invalid',
|
|
|
|
|
Array = 'Array', // 暂时在控制台打印下
|
|
|
|
|
Object = 'Object',
|
|
|
|
|
ObjectItem = 'ObjectItem',
|
|
|
|
|
Image = 'Image', // 图片
|
|
|
|
|
Engine = 'Engine',// 引擎的类型:cc.Node, cc.Sprite, cc.Label等。。。
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-08 17:52:29 +08:00
|
|
|
|
export class Info {
|
2021-11-06 20:19:21 +08:00
|
|
|
|
public id: string | null = null;
|
2021-04-04 19:21:17 +08:00
|
|
|
|
public type: DataType = DataType.Number;
|
2021-04-05 18:38:44 +08:00
|
|
|
|
public data: any;
|
2021-05-08 20:36:32 +08:00
|
|
|
|
public readonly: boolean = false;
|
2021-04-07 17:26:16 +08:00
|
|
|
|
public path: Array<string> = [];// 属性对应的路径
|
2021-11-06 20:19:21 +08:00
|
|
|
|
constructor() {
|
|
|
|
|
this.id = v4();
|
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isEnum(): boolean { return false; }
|
|
|
|
|
public isVec2(): boolean { return false; }
|
|
|
|
|
public isVec3(): boolean { return false; }
|
2024-12-11 14:56:50 +08:00
|
|
|
|
public isVec4(): boolean { return false; }
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isBool(): boolean { return false; }
|
|
|
|
|
public isText(): boolean { return false; }
|
|
|
|
|
public isString(): boolean { return false; }
|
|
|
|
|
public isColor(): boolean { return false; }
|
|
|
|
|
public isInvalid(): boolean { return false; }
|
|
|
|
|
public isNumber(): boolean { return false; }
|
|
|
|
|
public isArrayOrObject(): boolean { return false; }
|
|
|
|
|
public isArray(): boolean { return false; }
|
|
|
|
|
public isObject(): boolean { return false; }
|
|
|
|
|
public isImage(): boolean { return false; }
|
|
|
|
|
public isEngine(): boolean { return false; }
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TextData extends Info {
|
2024-12-11 14:56:50 +08:00
|
|
|
|
constructor(data: string = "") {
|
2021-04-04 19:21:17 +08:00
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Text;
|
2024-12-11 14:56:50 +08:00
|
|
|
|
this.data = data;
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isText(): boolean { return true; }
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-06 20:19:21 +08:00
|
|
|
|
export interface ObjectItemRequestData {
|
|
|
|
|
id: string | null;
|
2024-12-11 14:56:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 该对象拥有的所有属性
|
|
|
|
|
*/
|
2021-11-06 20:19:21 +08:00
|
|
|
|
data: Property[];
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 23:28:40 +08:00
|
|
|
|
export interface FrameDetails {
|
|
|
|
|
frameID: number;
|
|
|
|
|
url: string;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 14:56:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 组件里面定义了引擎类型的数据,比如 `@property(cc.Label)`
|
|
|
|
|
*/
|
2021-06-19 19:51:05 +08:00
|
|
|
|
export class EngineData extends Info {
|
2021-11-06 20:19:21 +08:00
|
|
|
|
public engineType: string = "";
|
|
|
|
|
public engineUUID: string = "";
|
|
|
|
|
public engineName: string = "";
|
2021-06-19 19:51:05 +08:00
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Engine;
|
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
init(name: string, type: string, uuid: string) {
|
|
|
|
|
this.engineName = name;
|
|
|
|
|
this.engineType = type;
|
|
|
|
|
this.engineUUID = uuid;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isEngine(): boolean { return true; }
|
2021-06-19 19:51:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-05 19:31:34 +08:00
|
|
|
|
export class ArrayData extends Info {
|
2021-06-15 22:19:47 +08:00
|
|
|
|
data: Array<Property> = [];
|
|
|
|
|
|
2021-04-05 19:31:34 +08:00
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Array;
|
|
|
|
|
}
|
2021-06-15 22:19:47 +08:00
|
|
|
|
|
|
|
|
|
add(info: Property) {
|
|
|
|
|
this.data.push(info);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
test() {
|
|
|
|
|
this.add(new Property("item1", new TextData("text")));
|
|
|
|
|
this.add(new Property("item2", new BoolData(true)));
|
2024-12-11 21:05:49 +08:00
|
|
|
|
this.add(new Property("item3", new NumberData(100)));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
testSub() {
|
|
|
|
|
this.add(new Property("item1", new TextData("text")));
|
|
|
|
|
const sub = new ArrayData();
|
|
|
|
|
sub.add(new Property("sub", new StringData("sub")));
|
|
|
|
|
this.add(new Property('arr', sub));
|
2024-12-11 17:52:58 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isArray(): boolean { return true; }
|
2024-12-11 14:56:50 +08:00
|
|
|
|
public isArrayOrObject(): boolean { return true; }
|
2021-04-05 19:31:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-06 20:19:21 +08:00
|
|
|
|
export class ObjectDataItem extends Info {
|
2021-06-17 22:35:37 +08:00
|
|
|
|
|
2021-11-06 20:19:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class ObjectData extends Info {
|
2024-12-11 17:52:58 +08:00
|
|
|
|
/**
|
|
|
|
|
* object的简单描述快照,类似chrome的console,{a:'fff',b:xxx}
|
|
|
|
|
* 主要是为了防止Object的数据过大,无限递归
|
|
|
|
|
*/
|
|
|
|
|
data: string = "";
|
2021-04-05 19:31:34 +08:00
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Object;
|
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
|
|
|
|
|
test() {
|
|
|
|
|
this.data = JSON.stringify({ fack: 'test' });
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
testProperty(): Property[] {
|
|
|
|
|
const obj: Object = JSON.parse(this.data);
|
|
|
|
|
const properties: Property[] = [];
|
|
|
|
|
for (let key in obj) {
|
|
|
|
|
if (typeof obj[key] === 'string') {
|
|
|
|
|
properties.push(new Property(key, new StringData(obj[key])));
|
|
|
|
|
} else if (typeof obj[key] === 'number') {
|
|
|
|
|
properties.push(new Property(key, new NumberData(obj[key])));
|
|
|
|
|
} else if (typeof obj[key] === 'boolean') {
|
|
|
|
|
properties.push(new Property(key, new BoolData(obj[key])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return properties;
|
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isObject(): boolean { return true; }
|
2024-12-11 14:56:50 +08:00
|
|
|
|
public isArrayOrObject(): boolean { return true; }
|
2021-04-05 19:31:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-06 21:42:37 +08:00
|
|
|
|
export class InvalidData extends Info {
|
2021-11-09 15:24:10 +08:00
|
|
|
|
data: "undefined" | "null" | "Infinity" | "NaN" | string;
|
2021-04-05 19:31:34 +08:00
|
|
|
|
|
2021-11-06 21:42:37 +08:00
|
|
|
|
constructor(data: any) {
|
|
|
|
|
super();
|
|
|
|
|
this.data = data;
|
|
|
|
|
this.type = DataType.Invalid;
|
2021-04-05 19:31:34 +08:00
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isInvalid(): boolean { return true; }
|
2021-04-05 19:31:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
|
export class ColorData extends Info {
|
|
|
|
|
constructor(color: string) {
|
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Color;
|
|
|
|
|
this.data = color;
|
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isColor(): boolean { return true; }
|
2021-04-05 18:38:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-04 19:21:17 +08:00
|
|
|
|
export class StringData extends Info {
|
2021-04-05 18:38:44 +08:00
|
|
|
|
constructor(data: string) {
|
2021-04-04 19:21:17 +08:00
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.String;
|
2021-04-05 18:38:44 +08:00
|
|
|
|
this.data = data;
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isString(): boolean { return true; }
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class NumberData extends Info {
|
2021-04-22 19:09:35 +08:00
|
|
|
|
constructor(data: number) {
|
2021-04-04 19:21:17 +08:00
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Number;
|
2021-04-22 19:09:35 +08:00
|
|
|
|
this.data = data;
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isNumber(): boolean { return true; }
|
2021-04-05 18:38:44 +08:00
|
|
|
|
}
|
2021-04-04 19:21:17 +08:00
|
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
|
export class BoolData extends Info {
|
|
|
|
|
constructor(bol: boolean) {
|
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Bool;
|
|
|
|
|
this.data = bol;
|
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isBool(): boolean { return true; }
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class Vec2Data extends Info {
|
2021-06-14 18:46:45 +08:00
|
|
|
|
data: Array<Property> = [];
|
|
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
|
constructor() {
|
2021-04-04 19:21:17 +08:00
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Vec2
|
2021-04-05 18:38:44 +08:00
|
|
|
|
this.data = [];
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add(info: Property) {
|
|
|
|
|
this.data.push(info);
|
|
|
|
|
return this;
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
test() {
|
|
|
|
|
this.add(new Property("x", new NumberData(100)));
|
|
|
|
|
this.add(new Property("y", new NumberData(200)));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isVec2(): boolean {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class Vec3Data extends Info {
|
2021-06-14 18:46:45 +08:00
|
|
|
|
data: Array<Property> = [];
|
2021-04-04 19:21:17 +08:00
|
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
|
constructor() {
|
2021-04-04 19:21:17 +08:00
|
|
|
|
super();
|
2021-04-05 18:38:44 +08:00
|
|
|
|
this.type = DataType.Vec3;
|
|
|
|
|
this.data = [];
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add(info: Property) {
|
|
|
|
|
this.data.push(info);
|
|
|
|
|
return this;
|
2021-06-14 19:41:58 +08:00
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
test() {
|
|
|
|
|
this.add(new Property("x", new NumberData(100)));
|
|
|
|
|
this.add(new Property("y", new NumberData(200)));
|
|
|
|
|
this.add(new Property("z", new NumberData(300)));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isVec3(): boolean {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-06-14 19:41:58 +08:00
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
export class Vec4Data extends Info {
|
2024-12-11 14:56:50 +08:00
|
|
|
|
data: Array<Property> = [];
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Vec4;
|
|
|
|
|
this.data = [];
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2021-06-14 19:41:58 +08:00
|
|
|
|
|
2024-12-11 14:56:50 +08:00
|
|
|
|
add(info: Property) {
|
|
|
|
|
this.data.push(info);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
test() {
|
|
|
|
|
this.add(new Property("x", new NumberData(100)));
|
|
|
|
|
this.add(new Property("y", new NumberData(200)));
|
|
|
|
|
this.add(new Property("z", new NumberData(300)));
|
|
|
|
|
this.add(new Property("w", new NumberData(400)));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2024-12-11 14:56:50 +08:00
|
|
|
|
public isVec4(): boolean {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-14 19:41:58 +08:00
|
|
|
|
export class ImageData extends Info {
|
2024-12-11 21:05:49 +08:00
|
|
|
|
/**
|
|
|
|
|
* 图片的url路径
|
|
|
|
|
*/
|
|
|
|
|
data: string = "";
|
2021-06-14 19:41:58 +08:00
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Image;
|
2024-12-11 21:05:49 +08:00
|
|
|
|
this.data = "";
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
test() {
|
|
|
|
|
const cocos = 'data:image/png;base64,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';
|
|
|
|
|
this.data = cocos;
|
2021-06-14 19:41:58 +08:00
|
|
|
|
return this;
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
2024-01-09 15:33:34 +08:00
|
|
|
|
public isImage(): boolean { return true; }
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class EnumData extends Info {
|
2024-01-09 12:02:47 +08:00
|
|
|
|
public values: Array<{ name: string, value: any }> = [];
|
2021-04-04 19:21:17 +08:00
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
this.type = DataType.Enum;
|
|
|
|
|
}
|
2024-01-09 12:02:47 +08:00
|
|
|
|
public isEnum(): boolean {
|
|
|
|
|
return this.type === DataType.Enum;
|
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
test() {
|
|
|
|
|
this.values.push({ name: "1", value: 1 });
|
|
|
|
|
this.values.push({ name: "2", value: 2 });
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2021-05-08 17:52:29 +08:00
|
|
|
|
}
|
2021-04-04 19:21:17 +08:00
|
|
|
|
|
2024-12-09 20:49:02 +08:00
|
|
|
|
export class TreeData implements ITreeData {
|
|
|
|
|
id: string = "";
|
2021-05-11 22:15:29 +08:00
|
|
|
|
active: boolean = true;
|
2024-12-09 20:49:02 +08:00
|
|
|
|
text: string = "";
|
|
|
|
|
children: TreeData[] = [];
|
2024-12-11 17:52:58 +08:00
|
|
|
|
constructor(id: string = "", text: string = "") {
|
|
|
|
|
this.id = id;
|
|
|
|
|
this.text = text;
|
|
|
|
|
}
|
2021-04-04 19:21:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
|
export class Property {
|
2021-11-06 20:19:21 +08:00
|
|
|
|
public name: string = "property";
|
2021-04-05 18:38:44 +08:00
|
|
|
|
public value: Info = new Info();
|
|
|
|
|
|
|
|
|
|
constructor(name: string, info: Info) {
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.value = info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class Group {
|
2024-12-11 14:56:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 节点的UUID
|
|
|
|
|
*/
|
2021-12-05 18:21:00 +08:00
|
|
|
|
public id: string = "";
|
2021-11-06 20:19:21 +08:00
|
|
|
|
public name: string = "group";
|
2021-04-05 18:38:44 +08:00
|
|
|
|
public data: Array<Property> = [];
|
|
|
|
|
|
2024-01-09 12:02:47 +08:00
|
|
|
|
constructor(name: string, id?: string) {
|
2021-04-05 18:38:44 +08:00
|
|
|
|
this.name = name;
|
2024-01-09 12:02:47 +08:00
|
|
|
|
this.id = id || '';
|
2021-04-05 18:38:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addProperty(property: Property) {
|
|
|
|
|
this.data.push(property)
|
|
|
|
|
}
|
2024-12-11 17:52:58 +08:00
|
|
|
|
buildProperty(name: string, info: Info) {
|
|
|
|
|
const property = new Property(name, info);
|
|
|
|
|
this.addProperty(property);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2021-05-08 18:44:10 +08:00
|
|
|
|
|
|
|
|
|
sort() {
|
2021-11-06 20:19:21 +08:00
|
|
|
|
let order = ["name", "active", "enabled", "uuid", "position", "rotation", "scale", "anchor", "size", "color", "opacity", "skew", "group"];
|
2021-05-08 18:44:10 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
2021-04-05 18:38:44 +08:00
|
|
|
|
}
|
2021-11-20 21:57:54 +08:00
|
|
|
|
|
|
|
|
|
export interface NodeInfoData {
|
2024-12-09 21:37:07 +08:00
|
|
|
|
/**
|
|
|
|
|
* 节点的uuid
|
|
|
|
|
*/
|
|
|
|
|
uuid: string;
|
|
|
|
|
/**
|
|
|
|
|
* 组件数据
|
|
|
|
|
*/
|
2021-11-20 21:57:54 +08:00
|
|
|
|
group: Group[];
|
|
|
|
|
}
|