From 8e67104ec6e3578d45239b11bce1cfb1f00d431c Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Wed, 29 Jan 2025 20:53:10 +0800 Subject: [PATCH] bugfix --- cc-inspector/src/scripts/inject/enumConfig.ts | 399 +++++++++--------- cc-inspector/src/scripts/inject/inspector.ts | 7 +- cc-inspector/src/views/devtools/comp/index.ts | 1 + 3 files changed, 206 insertions(+), 201 deletions(-) diff --git a/cc-inspector/src/scripts/inject/enumConfig.ts b/cc-inspector/src/scripts/inject/enumConfig.ts index 380b63b..71715d3 100644 --- a/cc-inspector/src/scripts/inject/enumConfig.ts +++ b/cc-inspector/src/scripts/inject/enumConfig.ts @@ -1,224 +1,227 @@ declare const cc: any; -export const enumConfig: Array<{ - type: any; - list: Array<{ - key: string; - values: () => Array<{ name: string; value: number }>; - }>; -}> = [ - { - type: cc.Widget, - list: [ - { - key: "alignMode", - values: () => { - return cc.Widget.AlignMode.__enums__; +export function getEnumListConfig() { + const enumConfig: Array<{ + type: any; + list: Array<{ + key: string; + values: () => Array<{ name: string; value: number }>; + }>; + }> = [ + { + type: cc.Widget, + list: [ + { + key: "alignMode", + values: () => { + return cc.Widget.AlignMode.__enums__; + }, }, - }, - ], - }, - { - type: cc.Button, - list: [ - { - key: "transition", - values: () => { - return cc.Button.Transition.__enums__; + ], + }, + { + type: cc.Button, + list: [ + { + key: "transition", + values: () => { + return cc.Button.Transition.__enums__; + }, }, - }, - ], - }, - { - type: cc.Sprite, - list: [ - { - key: "sizeMode", - values: () => { - return cc.Sprite.SizeMode.__enums__; + ], + }, + { + type: cc.Sprite, + list: [ + { + key: "sizeMode", + values: () => { + return cc.Sprite.SizeMode.__enums__; + }, }, - }, - { - key: "type", - values: () => { - return cc.Sprite.Type.__enums__; + { + key: "type", + values: () => { + return cc.Sprite.Type.__enums__; + }, }, - }, - ], - }, - { - type: cc.Mask, - list: [ - { - key: "type", - values() { - return cc.Mask.Type.__enums__; + ], + }, + { + type: cc.Mask, + list: [ + { + key: "type", + values() { + return cc.Mask.Type.__enums__; + }, }, - }, - ], - }, - { - type: cc.Label, - list: [ - { - key: "cacheMode", - values() { - return cc.Label.CacheMode.__enums__; + ], + }, + { + type: cc.Label, + list: [ + { + key: "cacheMode", + values() { + return cc.Label.CacheMode.__enums__; + }, }, - }, - { - key: "overflow", - values() { - return cc.Label.Overflow.__enums__; + { + key: "overflow", + values() { + return cc.Label.Overflow.__enums__; + }, }, - }, - ], - }, - { - type: cc.Slider, - list: [ - { - key: "direction", - values() { - return cc.Slider.Direction.__enums__; + ], + }, + { + type: cc.Slider, + list: [ + { + key: "direction", + values() { + return cc.Slider.Direction.__enums__; + }, }, - }, - ], - }, - { - type: cc.PageView, - list: [ - { - key: "direction", - values() { - return cc.PageView.Direction.__enums__; + ], + }, + { + type: cc.PageView, + list: [ + { + key: "direction", + values() { + return cc.PageView.Direction.__enums__; + }, }, - }, - { - key: "sizeMode", - values() { - return cc.PageView.SizeMode.__enums__; + { + key: "sizeMode", + values() { + return cc.PageView.SizeMode.__enums__; + }, }, - }, - ], - }, - { - type: cc.PageViewIndicator, - list: [ - { - key: "direction", - values() { - return cc.PageViewIndicator.Direction.__enums__; + ], + }, + { + type: cc.PageViewIndicator, + list: [ + { + key: "direction", + values() { + return cc.PageViewIndicator.Direction.__enums__; + }, }, - }, - ], - }, - { - type: cc.RichText, - list: [ - { - key: "cacheMode", - values() { - return cc.Label.CacheMode.__enums__; + ], + }, + { + type: cc.RichText, + list: [ + { + key: "cacheMode", + values() { + return cc.Label.CacheMode.__enums__; + }, }, - }, - { - key: "horizontalAlign", - values() { - return cc.RichText.HorizontalAlign.__enums__; + { + key: "horizontalAlign", + values() { + return cc.RichText.HorizontalAlign.__enums__; + }, }, - }, - { - key: "verticalAlign", - values() { - return cc.RichText.VerticalAlign.__enums__; + { + key: "verticalAlign", + values() { + return cc.RichText.VerticalAlign.__enums__; + }, }, - }, - ], - }, - { - type: cc.ProgressBar, - list: [ - { - key: "mode", - values() { - return cc.ProgressBar.Mode.__enums__; + ], + }, + { + type: cc.ProgressBar, + list: [ + { + key: "mode", + values() { + return cc.ProgressBar.Mode.__enums__; + }, }, - }, - ], - }, - { - type: cc.Scrollbar, - list: [ - { - key: "direction", - values() { - return cc.Scrollbar.Direction.__enums__; + ], + }, + { + type: cc.Scrollbar, + list: [ + { + key: "direction", + values() { + return cc.Scrollbar.Direction.__enums__; + }, }, - }, - ], - }, - { - type: cc.EditBox, - list: [ - { - key: "inputMode", - values() { - return cc.EditBox.InputMode.__enums__; + ], + }, + { + type: cc.EditBox, + list: [ + { + key: "inputMode", + values() { + return cc.EditBox.InputMode.__enums__; + }, }, - }, - { - key: "inputFlag", - values() { - return cc.EditBox.InputFlag.__enums__; + { + key: "inputFlag", + values() { + return cc.EditBox.InputFlag.__enums__; + }, }, - }, - ], - }, - { - type: cc.Layout, - list: [ - { - key: "resizeMode", - values() { - return cc.Layout.ResizeMode.__enums__; + ], + }, + { + type: cc.Layout, + list: [ + { + key: "resizeMode", + values() { + return cc.Layout.ResizeMode.__enums__; + }, }, - }, - { - key: "type", - values() { - return cc.Layout.Type.__enums__; + { + key: "type", + values() { + return cc.Layout.Type.__enums__; + }, }, - }, - { - key: "startAxis", - values() { - return cc.Layout.AxisDirection.__enums__; + { + key: "startAxis", + values() { + return cc.Layout.AxisDirection.__enums__; + }, }, - }, - { - key: "horizontalDirection", - values() { - return cc.Layout.HorizontalDirection.__enums__; + { + key: "horizontalDirection", + values() { + return cc.Layout.HorizontalDirection.__enums__; + }, }, - }, - { - key: "verticalDirection", - values() { - return cc.Layout.VerticalDirection.__enums__; + { + key: "verticalDirection", + values() { + return cc.Layout.VerticalDirection.__enums__; + }, }, - }, - ], - }, - { - type: cc.VidePlayer, - list: [ - { - key: "resourceType", - values() { - return cc.VideoPlayer.ResourceType.__enums__; + ], + }, + { + type: cc.VidePlayer, + list: [ + { + key: "resourceType", + values() { + return cc.VideoPlayer.ResourceType.__enums__; + }, }, - }, - ], - }, -]; + ], + }, + ]; + return enumConfig; +} diff --git a/cc-inspector/src/scripts/inject/inspector.ts b/cc-inspector/src/scripts/inject/inspector.ts index c5f1bc9..ae984e9 100644 --- a/cc-inspector/src/scripts/inject/inspector.ts +++ b/cc-inspector/src/scripts/inject/inspector.ts @@ -2,7 +2,7 @@ import { uniq } from "lodash"; import { Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestSetPropertyData, ResponseGameInfoData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types"; import { ArrayData, BoolData, ColorData, DataType, EngineData, EnumData, Group, ImageData, Info, InvalidData, NodeInfoData, NumberData, ObjectCircleData, ObjectData, Property, StringData, TreeData, Vec2Data, Vec3Data, Vec4Data } from "../../views/devtools/data"; -import { enumConfig } from "./enumConfig"; +import { getEnumListConfig } from "./enumConfig"; import { InjectEvent } from "./event"; import { Hint } from "./hint"; import { injectView } from "./inject-view"; @@ -517,8 +517,9 @@ export class Inspector extends InjectEvent { return false; } private getEnum(node: any, key: string): Array<{ name: string; value: number }> | null { - for (let i = 0; i < enumConfig.length; i++) { - const { type, list } = enumConfig[i]; + const cfgArray = getEnumListConfig(); + for (let i = 0; i < cfgArray.length; i++) { + const { type, list } = cfgArray[i]; if (type && node instanceof type) { const ret = list.find((item) => item.key === key); if (ret) { diff --git a/cc-inspector/src/views/devtools/comp/index.ts b/cc-inspector/src/views/devtools/comp/index.ts index 4632a06..d454fec 100644 --- a/cc-inspector/src/views/devtools/comp/index.ts +++ b/cc-inspector/src/views/devtools/comp/index.ts @@ -94,6 +94,7 @@ export function getSimpleProperties(typeName: string): string[] { config[CompType.RichText] = [ "string", "horizontalAlign", + "verticalAlign", "fontSize", "font", "fontFamily",