This commit is contained in:
xu_yanfeng 2025-01-29 20:53:10 +08:00
parent bc2052e2b7
commit 8e67104ec6
3 changed files with 206 additions and 201 deletions

View File

@ -1,224 +1,227 @@
declare const cc: any; declare const cc: any;
export const enumConfig: Array<{ export function getEnumListConfig() {
type: any; const enumConfig: Array<{
list: Array<{ type: any;
key: string; list: Array<{
values: () => Array<{ name: string; value: number }>; key: string;
}>; values: () => Array<{ name: string; value: number }>;
}> = [ }>;
{ }> = [
type: cc.Widget, {
list: [ type: cc.Widget,
{ list: [
key: "alignMode", {
values: () => { key: "alignMode",
return cc.Widget.AlignMode.__enums__; values: () => {
return cc.Widget.AlignMode.__enums__;
},
}, },
}, ],
], },
}, {
{ type: cc.Button,
type: cc.Button, list: [
list: [ {
{ key: "transition",
key: "transition", values: () => {
values: () => { return cc.Button.Transition.__enums__;
return cc.Button.Transition.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.Sprite,
type: cc.Sprite, list: [
list: [ {
{ key: "sizeMode",
key: "sizeMode", values: () => {
values: () => { return cc.Sprite.SizeMode.__enums__;
return cc.Sprite.SizeMode.__enums__; },
}, },
}, {
{ key: "type",
key: "type", values: () => {
values: () => { return cc.Sprite.Type.__enums__;
return cc.Sprite.Type.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.Mask,
type: cc.Mask, list: [
list: [ {
{ key: "type",
key: "type", values() {
values() { return cc.Mask.Type.__enums__;
return cc.Mask.Type.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.Label,
type: cc.Label, list: [
list: [ {
{ key: "cacheMode",
key: "cacheMode", values() {
values() { return cc.Label.CacheMode.__enums__;
return cc.Label.CacheMode.__enums__; },
}, },
}, {
{ key: "overflow",
key: "overflow", values() {
values() { return cc.Label.Overflow.__enums__;
return cc.Label.Overflow.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.Slider,
type: cc.Slider, list: [
list: [ {
{ key: "direction",
key: "direction", values() {
values() { return cc.Slider.Direction.__enums__;
return cc.Slider.Direction.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.PageView,
type: cc.PageView, list: [
list: [ {
{ key: "direction",
key: "direction", values() {
values() { return cc.PageView.Direction.__enums__;
return cc.PageView.Direction.__enums__; },
}, },
}, {
{ key: "sizeMode",
key: "sizeMode", values() {
values() { return cc.PageView.SizeMode.__enums__;
return cc.PageView.SizeMode.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.PageViewIndicator,
type: cc.PageViewIndicator, list: [
list: [ {
{ key: "direction",
key: "direction", values() {
values() { return cc.PageViewIndicator.Direction.__enums__;
return cc.PageViewIndicator.Direction.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.RichText,
type: cc.RichText, list: [
list: [ {
{ key: "cacheMode",
key: "cacheMode", values() {
values() { return cc.Label.CacheMode.__enums__;
return cc.Label.CacheMode.__enums__; },
}, },
}, {
{ key: "horizontalAlign",
key: "horizontalAlign", values() {
values() { return cc.RichText.HorizontalAlign.__enums__;
return cc.RichText.HorizontalAlign.__enums__; },
}, },
}, {
{ key: "verticalAlign",
key: "verticalAlign", values() {
values() { return cc.RichText.VerticalAlign.__enums__;
return cc.RichText.VerticalAlign.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.ProgressBar,
type: cc.ProgressBar, list: [
list: [ {
{ key: "mode",
key: "mode", values() {
values() { return cc.ProgressBar.Mode.__enums__;
return cc.ProgressBar.Mode.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.Scrollbar,
type: cc.Scrollbar, list: [
list: [ {
{ key: "direction",
key: "direction", values() {
values() { return cc.Scrollbar.Direction.__enums__;
return cc.Scrollbar.Direction.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.EditBox,
type: cc.EditBox, list: [
list: [ {
{ key: "inputMode",
key: "inputMode", values() {
values() { return cc.EditBox.InputMode.__enums__;
return cc.EditBox.InputMode.__enums__; },
}, },
}, {
{ key: "inputFlag",
key: "inputFlag", values() {
values() { return cc.EditBox.InputFlag.__enums__;
return cc.EditBox.InputFlag.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.Layout,
type: cc.Layout, list: [
list: [ {
{ key: "resizeMode",
key: "resizeMode", values() {
values() { return cc.Layout.ResizeMode.__enums__;
return cc.Layout.ResizeMode.__enums__; },
}, },
}, {
{ key: "type",
key: "type", values() {
values() { return cc.Layout.Type.__enums__;
return cc.Layout.Type.__enums__; },
}, },
}, {
{ key: "startAxis",
key: "startAxis", values() {
values() { return cc.Layout.AxisDirection.__enums__;
return cc.Layout.AxisDirection.__enums__; },
}, },
}, {
{ key: "horizontalDirection",
key: "horizontalDirection", values() {
values() { return cc.Layout.HorizontalDirection.__enums__;
return cc.Layout.HorizontalDirection.__enums__; },
}, },
}, {
{ key: "verticalDirection",
key: "verticalDirection", values() {
values() { return cc.Layout.VerticalDirection.__enums__;
return cc.Layout.VerticalDirection.__enums__; },
}, },
}, ],
], },
}, {
{ type: cc.VidePlayer,
type: cc.VidePlayer, list: [
list: [ {
{ key: "resourceType",
key: "resourceType", values() {
values() { return cc.VideoPlayer.ResourceType.__enums__;
return cc.VideoPlayer.ResourceType.__enums__; },
}, },
}, ],
], },
}, ];
]; return enumConfig;
}

View File

@ -2,7 +2,7 @@
import { uniq } from "lodash"; import { uniq } from "lodash";
import { Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestSetPropertyData, ResponseGameInfoData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types"; 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 { 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 { InjectEvent } from "./event";
import { Hint } from "./hint"; import { Hint } from "./hint";
import { injectView } from "./inject-view"; import { injectView } from "./inject-view";
@ -517,8 +517,9 @@ export class Inspector extends InjectEvent {
return false; return false;
} }
private getEnum(node: any, key: string): Array<{ name: string; value: number }> | null { private getEnum(node: any, key: string): Array<{ name: string; value: number }> | null {
for (let i = 0; i < enumConfig.length; i++) { const cfgArray = getEnumListConfig();
const { type, list } = enumConfig[i]; for (let i = 0; i < cfgArray.length; i++) {
const { type, list } = cfgArray[i];
if (type && node instanceof type) { if (type && node instanceof type) {
const ret = list.find((item) => item.key === key); const ret = list.find((item) => item.key === key);
if (ret) { if (ret) {

View File

@ -94,6 +94,7 @@ export function getSimpleProperties(typeName: string): string[] {
config[CompType.RichText] = [ config[CompType.RichText] = [
"string", "string",
"horizontalAlign", "horizontalAlign",
"verticalAlign",
"fontSize", "fontSize",
"font", "font",
"fontFamily", "fontFamily",