From 9413dc4f1f5472f07e1e41e7098fcacce473f2ac Mon Sep 17 00:00:00 2001 From: dgflash Date: Thu, 11 Aug 2022 15:48:39 +0800 Subject: [PATCH] . --- assets/libs/model-view/VMBase.ts | 2 +- assets/libs/model-view/VMCompsEdit.ts | 56 ++++++++++++++----- assets/libs/model-view/VMCustom.ts | 5 +- assets/libs/model-view/VMEvent.ts | 15 ++++- assets/libs/model-view/VMLabel.ts | 10 +++- assets/libs/model-view/VMModify.ts | 15 ++++- assets/libs/model-view/VMProgress.ts | 11 +++- assets/libs/model-view/VMState.ts | 45 ++++++++++++--- assets/libs/model-view/ui/BhvButtonGroup.ts | 62 +++++++++++++++++---- 9 files changed, 178 insertions(+), 43 deletions(-) diff --git a/assets/libs/model-view/VMBase.ts b/assets/libs/model-view/VMBase.ts index 843a50b..8a4cd68 100644 --- a/assets/libs/model-view/VMBase.ts +++ b/assets/libs/model-view/VMBase.ts @@ -77,7 +77,7 @@ export default class VMBase extends Component { // 打印出所有绑定的路径,方便调试信息 if (DEBUG_WATCH_PATH && DEBUG) { - log('所有路径', this.watchPath ? [this.watchPath] : this.watchPathArr, '<<', this.node.getParent().name + '.' + this.node.name) + log('所有路径', this.watchPath ? [this.watchPath] : this.watchPathArr, '<<', this.node.parent!.name + '.' + this.node.name) } if (this.watchPath == '' && this.watchPathArr.join('') == '') { diff --git a/assets/libs/model-view/VMCompsEdit.ts b/assets/libs/model-view/VMCompsEdit.ts index 5d48d9d..004c7fc 100644 --- a/assets/libs/model-view/VMCompsEdit.ts +++ b/assets/libs/model-view/VMCompsEdit.ts @@ -10,7 +10,6 @@ enum ACTION_MODE { DELETE_COMPONENT } - /** * 用于搜索的MV 组件列表,挂载在父节点后, * 会遍历搜索下面的所有MV组件, 并且显示其观察值的路径 @@ -32,7 +31,10 @@ export default class MVCompsEdit extends Component { @property({ tooltip: '勾选后,会自动查找 find list 中填写的组件', - visible: function () { return this.actionType === ACTION_MODE.SEARCH_COMPONENT } + visible: function () { + // @ts-ignore + return this.actionType === ACTION_MODE.SEARCH_COMPONENT; + } }) public get findTrigger() { return false; @@ -43,7 +45,10 @@ export default class MVCompsEdit extends Component { @property({ tooltip: '勾选后,会批量激活 find list 中填写的组件', - visible: function () { return this.actionType === ACTION_MODE.ENABLE_COMPONENT } + visible: function () { + // @ts-ignore + return this.actionType === ACTION_MODE.ENABLE_COMPONENT; + } }) public get enableTrigger() { return false; @@ -54,7 +59,10 @@ export default class MVCompsEdit extends Component { @property({ tooltip: '勾选后,会批量关闭 find list 中填写的组件', - visible: function () { return this.actionType === ACTION_MODE.ENABLE_COMPONENT } + visible: function () { + // @ts-ignore + return this.actionType === ACTION_MODE.ENABLE_COMPONENT; + } }) public get disableTrigger() { return false; @@ -65,14 +73,20 @@ export default class MVCompsEdit extends Component { @property({ tooltip: '允许删除节点的组件,确定需要移除请勾选,防止误操作', - visible: function () { return this.actionType === ACTION_MODE.DELETE_COMPONENT } + visible: function () { + // @ts-ignore + return this.actionType === ACTION_MODE.DELETE_COMPONENT; + } }) allowDelete: boolean = false; @property({ tooltip: '勾选后,会批量删除 find list 中填写的组件', displayName: '[ X DELETE X ]', - visible: function () { return this.allowDelete && this.actionType === ACTION_MODE.DELETE_COMPONENT } + visible: function () { + // @ts-ignore + return this.allowDelete && this.actionType === ACTION_MODE.DELETE_COMPONENT; + } }) public get deleteTrigger() { return false; @@ -83,7 +97,10 @@ export default class MVCompsEdit extends Component { @property({ tooltip: '勾选后,会批量替换掉指定的路径', - visible: function () { return this.actionType === ACTION_MODE.REPLACE_WATCH_PATH } + visible: function () { + // @ts-ignore + return this.actionType === ACTION_MODE.REPLACE_WATCH_PATH; + } }) public get replaceTrigger() { return false; @@ -94,20 +111,29 @@ export default class MVCompsEdit extends Component { @property({ tooltip: '匹配的路径,匹配规则: 搜索开头为 game的路径', - visible: function () { return this.actionType === ACTION_MODE.REPLACE_WATCH_PATH } + visible: function () { + // @ts-ignore + return this.actionType === ACTION_MODE.REPLACE_WATCH_PATH; + } }) targetPath: string = 'game'; @property({ tooltip: '替换的路径,将匹配到的路径替换', - visible: function () { return this.actionType === ACTION_MODE.REPLACE_WATCH_PATH } + visible: function () { + // @ts-ignore + return this.actionType === ACTION_MODE.REPLACE_WATCH_PATH; + } }) replacePath: string = '*'; @property({ tooltip: '是否搜集绑定VM组件的节点?', - visible: function () { return this.actionType === ACTION_MODE.SEARCH_COMPONENT } + visible: function () { + // @ts-ignore + return this.actionType === ACTION_MODE.SEARCH_COMPONENT; + } }) canCollectNodes: boolean = false; @@ -115,7 +141,10 @@ export default class MVCompsEdit extends Component { type: [Node], readonly: true, tooltip: '收集到绑定了VM组件相关的节点,可以自己跳转过去', - visible: function () { return this.canCollectNodes && this.actionType === ACTION_MODE.SEARCH_COMPONENT } + visible: function () { + // @ts-ignore + return this.canCollectNodes && this.actionType === ACTION_MODE.SEARCH_COMPONENT + } }) collectNodes: Node[] = []; @@ -162,14 +191,15 @@ export default class MVCompsEdit extends Component { let comps = this.node.getComponentsInChildren(className); if (comps == null || comps.length < 1) return; log('[' + className + ']:'); - comps.forEach(v => { + comps.forEach((v: any) => { let ext = ''; if (state <= 3) { //区分模板模式路径 if (v.templateMode === true) { ext = v.watchPathArr ? ':[Path:' + v.watchPathArr.join('|') + ']' : '' - } else { + } + else { ext = v.watchPath ? ':[Path:' + v.watchPath + ']' : '' } } diff --git a/assets/libs/model-view/VMCustom.ts b/assets/libs/model-view/VMCustom.ts index 1b3f171..a110137 100644 --- a/assets/libs/model-view/VMCustom.ts +++ b/assets/libs/model-view/VMCustom.ts @@ -52,7 +52,10 @@ export default class VMCustom extends VMBase { tooltip: '刷新间隔频率(只影响脏检查的频率)', step: 0.01, range: [0, 1], - visible: function () { return this.controller === true } + visible: function () { + // @ts-ignore + return this.controller === true; + } }) refreshRate: number = 0.1; diff --git a/assets/libs/model-view/VMEvent.ts b/assets/libs/model-view/VMEvent.ts index ba36c0e..5be438c 100644 --- a/assets/libs/model-view/VMEvent.ts +++ b/assets/libs/model-view/VMEvent.ts @@ -39,7 +39,10 @@ export default class VMEvent extends VMBase { @property({ tooltip: '监听获取值的路径', - visible: function () { return this.templateMode === false } + visible: function () { + // @ts-ignore + return this.templateMode === false; + } }) watchPath: string = ""; @@ -51,7 +54,10 @@ export default class VMEvent extends VMBase { @property({ tooltip: '监听获取值的多条路径,这些值的改变都会通过这个函数回调,请使用 pathArr 区分获取的值 ', type: [CCString], - visible: function () { return this.templateMode === true } + visible: function () { + // @ts-ignore + return this.templateMode === true; + } }) protected watchPathArr: string[] = []; @@ -62,7 +68,10 @@ export default class VMEvent extends VMBase { public filterMode: FILTER_MODE = FILTER_MODE.none; @property({ - visible: function () { return this.filterMode !== FILTER_MODE.none } + visible: function () { + // @ts-ignore + return this.filterMode !== FILTER_MODE.none + } }) public compareValue: string = ''; diff --git a/assets/libs/model-view/VMLabel.ts b/assets/libs/model-view/VMLabel.ts index 77ec410..353ce0a 100644 --- a/assets/libs/model-view/VMLabel.ts +++ b/assets/libs/model-view/VMLabel.ts @@ -33,14 +33,20 @@ export default class VMLabel extends VMBase { private labelType: string = LABEL_TYPE.CC_LABEL; @property({ - visible: function () { return this.templateMode === false; } + visible: function () { + // @ts-ignore + return this.templateMode === false; + } }) watchPath: string = ""; // 按照匹配参数顺序保存的 path 数组 (固定) @property({ type: [CCString], - visible: function () { return this.templateMode === true } + visible: function () { + // @ts-ignore + return this.templateMode === true; + } }) protected watchPathArr: string[] = []; diff --git a/assets/libs/model-view/VMModify.ts b/assets/libs/model-view/VMModify.ts index fb63bba..d45d7a2 100644 --- a/assets/libs/model-view/VMModify.ts +++ b/assets/libs/model-view/VMModify.ts @@ -31,17 +31,26 @@ export default class VMModify extends VMBase { @property({ type: Enum(CLAMP_MODE), - visible: function () { return this.valueClamp === true } + visible: function () { + // @ts-ignore + return this.valueClamp === true; + } }) valueClampMode: CLAMP_MODE = CLAMP_MODE.MIN_MAX; @property({ - visible: function () { return this.valueClamp === true && this.valueClampMode !== CLAMP_MODE.MAX } + visible: function () { + // @ts-ignore + return this.valueClamp === true && this.valueClampMode !== CLAMP_MODE.MAX; + } }) valueMin: number = 0; @property({ - visible: function () { return this.valueClamp === true && this.valueClampMode !== CLAMP_MODE.MIN } + visible: function () { + // @ts-ignore + return this.valueClamp === true && this.valueClampMode !== CLAMP_MODE.MIN; + } }) valueMax: number = 1; diff --git a/assets/libs/model-view/VMProgress.ts b/assets/libs/model-view/VMProgress.ts index d19fedf..bd6cf5a 100644 --- a/assets/libs/model-view/VMProgress.ts +++ b/assets/libs/model-view/VMProgress.ts @@ -1,3 +1,9 @@ +/* + * @Author: dgflash + * @Date: 2022-08-11 14:45:44 + * @LastEditors: dgflash + * @LastEditTime: 2022-08-11 15:43:34 + */ import { CCString, _decorator } from "cc"; import { EDITOR } from "cc/env"; import { StringFormatFunction } from "./StringFormat"; @@ -24,7 +30,10 @@ export default class VMProgress extends VMCustom { public templateMode: boolean = true; @property({ - visible: function () { return this.componentProperty === 'string' }, + visible: function () { + // @ts-ignore + return this.componentProperty === 'string'; + }, tooltip: '字符串格式化,和 VMLabel 的字段一样,需要填入对应的格式化字符串' }) stringFormat: string = ''; diff --git a/assets/libs/model-view/VMState.ts b/assets/libs/model-view/VMState.ts index 381958b..a02f5c7 100644 --- a/assets/libs/model-view/VMState.ts +++ b/assets/libs/model-view/VMState.ts @@ -54,19 +54,28 @@ export default class VMState extends VMBase { @property({ type: Enum(CHILD_MODE_TYPE), tooltip: '遍历子节点,根据子节点的名字转换为值,判断值满足条件 来激活', - visible: function () { return this.foreachChildMode === true } + visible: function () { + // @ts-ignore + return this.foreachChildMode === true; + } }) foreachChildType: CHILD_MODE_TYPE = CHILD_MODE_TYPE.NODE_INDEX; @property({ displayName: 'Value: a', - visible: function () { return this.foreachChildMode === false } + visible: function () { + // @ts-ignore + return this.foreachChildMode === false; + } }) valueA: number = 0; @property({ displayName: 'Value: b', - visible: function () { return this.foreachChildMode === false && this.condition === CONDITION.range } + visible: function () { + // @ts-ignore + return this.foreachChildMode === false && this.condition === CONDITION.range; + } }) valueB: number = 0; @@ -77,7 +86,10 @@ export default class VMState extends VMBase { valueAction: ACTION = ACTION.NODE_ACTIVE; @property({ - visible: function () { return this.valueAction === ACTION.NODE_OPACITY }, + visible: function () { + // @ts-ignore + return this.valueAction === ACTION.NODE_OPACITY; + }, range: [0, 255], type: CCInteger, displayName: 'Action Opacity' @@ -85,31 +97,46 @@ export default class VMState extends VMBase { valueActionOpacity: number = 0; @property({ - visible: function () { return this.valueAction === ACTION.NODE_COLOR }, + visible: function () { + // @ts-ignore + return this.valueAction === ACTION.NODE_COLOR + }, displayName: 'Action Color' }) valueActionColor: Color = color(155, 155, 155); @property({ - visible: function () { return this.valueAction === ACTION.COMPONENT_CUSTOM }, + visible: function () { + // @ts-ignore + return this.valueAction === ACTION.COMPONENT_CUSTOM + }, displayName: 'Component Name' }) valueComponentName: string = ''; @property({ - visible: function () { return this.valueAction === ACTION.COMPONENT_CUSTOM }, + visible: function () { + // @ts-ignore + return this.valueAction === ACTION.COMPONENT_CUSTOM + }, displayName: 'Component Property' }) valueComponentProperty: string = ''; @property({ - visible: function () { return this.valueAction === ACTION.COMPONENT_CUSTOM }, + visible: function () { + // @ts-ignore + return this.valueAction === ACTION.COMPONENT_CUSTOM + }, displayName: 'Default Value' }) valueComponentDefaultValue: string = ''; @property({ - visible: function () { return this.valueAction === ACTION.COMPONENT_CUSTOM }, + visible: function () { + // @ts-ignore + return this.valueAction === ACTION.COMPONENT_CUSTOM; + }, displayName: 'Action Value' }) valueComponentActionValue: string = ''; diff --git a/assets/libs/model-view/ui/BhvButtonGroup.ts b/assets/libs/model-view/ui/BhvButtonGroup.ts index c076937..040daf1 100644 --- a/assets/libs/model-view/ui/BhvButtonGroup.ts +++ b/assets/libs/model-view/ui/BhvButtonGroup.ts @@ -19,46 +19,88 @@ export default class BhvButtonGroup extends Component { }) transition: number = Button.Transition.NONE; - @property({ visible: function () { return this.transition === Button.Transition.COLOR } }) + @property({ + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.COLOR + } + }) hoverColor: Color = color(255, 255, 255); - @property({ visible: function () { return this.transition === Button.Transition.COLOR } }) + @property({ + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.COLOR + } + }) normalColor: Color = color(214, 214, 214); - @property({ visible: function () { return this.transition === Button.Transition.COLOR } }) + @property({ + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.COLOR; + } + }) pressedColor: Color = color(211, 211, 211); - @property({ visible: function () { return this.transition === Button.Transition.COLOR } }) + @property({ + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.COLOR; + } + }) disabledColor: Color = color(124, 124, 124); @property({ type: SpriteFrame, - visible: function () { return this.transition === Button.Transition.SPRITE } + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.SPRITE; + } }) normalSprite: SpriteFrame | null = null; @property({ type: SpriteFrame, - visible: function () { return this.transition === Button.Transition.SPRITE } + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.SPRITE; + } }) pressedSprite: SpriteFrame | null = null; @property({ type: SpriteFrame, - visible: function () { return this.transition === Button.Transition.SPRITE } + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.SPRITE; + } }) hoverSprite: SpriteFrame | null = null; @property({ type: SpriteFrame, - visible: function () { return this.transition === Button.Transition.SPRITE } + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.SPRITE; + } }) disabledSprite: SpriteFrame | null = null; - @property({ visible: function () { return this.transition === Button.Transition.SCALE || this.transition === Button.Transition.COLOR } }) + @property({ + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.SCALE || this.transition === Button.Transition.COLOR; + } + }) duration: number = 1.0; - @property({ visible: function () { return this.transition === Button.Transition.SCALE } }) + @property({ + visible: function () { + // @ts-ignore + return this.transition === Button.Transition.SCALE; + } + }) zoomScale: number = 1.1; @property({