mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-06-01 13:54:05 +00:00
增加break的快捷操作
This commit is contained in:
parent
78b50a72b0
commit
cdb676c582
@ -81,6 +81,7 @@ export type RequestOpenScriptData = {
|
|||||||
script: string;
|
script: string;
|
||||||
};
|
};
|
||||||
export type ResponseErrorData = string;
|
export type ResponseErrorData = string;
|
||||||
|
export type RequestBreakOnData = { uuid: string; type: BreakOnType };
|
||||||
export enum Msg {
|
export enum Msg {
|
||||||
None = "None",
|
None = "None",
|
||||||
/**
|
/**
|
||||||
@ -154,8 +155,23 @@ export enum Msg {
|
|||||||
*/
|
*/
|
||||||
RequestOpenNodeTouchFuntion = "request-open-node-touch-funtion",
|
RequestOpenNodeTouchFuntion = "request-open-node-touch-funtion",
|
||||||
RequestOpenScript = "request-open-script",
|
RequestOpenScript = "request-open-script",
|
||||||
|
RequestBreakOn = "request-break-on",
|
||||||
|
RequestBreakClean = "request-break-clean",
|
||||||
|
}
|
||||||
|
export enum BreakOnType {
|
||||||
|
SizeChanged = "size changed",
|
||||||
|
TransformChanged = "transform changed",
|
||||||
|
ColorChanged = "color changed",
|
||||||
|
LayerChanged = "layer changed",
|
||||||
|
SiblingOrderChanged = "sibling order changed",
|
||||||
|
ActiveChanged = "active changed",
|
||||||
|
Destroyed = "destroyed",
|
||||||
|
ParentChanged = "parent changed",
|
||||||
|
ChildAdded = "child added",
|
||||||
|
ChildRemoved = "child removed",
|
||||||
|
CompAdded = "component added",
|
||||||
|
CompRemoved = "component removed",
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PluginEvent {
|
export class PluginEvent {
|
||||||
public static FLAG = "cc-inspector";
|
public static FLAG = "cc-inspector";
|
||||||
/**
|
/**
|
||||||
|
13
src/scripts/inject/break.ts
Normal file
13
src/scripts/inject/break.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export const breakArray: Array<{ node: any; key: string; fn: Function }> = [];
|
||||||
|
|
||||||
|
export function addBreak(node: any, key: string, fn: Function) {
|
||||||
|
breakArray.push({ node, key, fn });
|
||||||
|
}
|
||||||
|
export function cleanBreak() {
|
||||||
|
breakArray.forEach((el) => {
|
||||||
|
const { node, key, fn } = el;
|
||||||
|
if (node && node.isValid) {
|
||||||
|
node.off(key, fn);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@ -131,7 +131,7 @@ export class Hint {
|
|||||||
},
|
},
|
||||||
} as IUiMenuItem;
|
} as IUiMenuItem;
|
||||||
});
|
});
|
||||||
ccui.menu.showMenuByMouseEvent(event, menu, 0.8);
|
ccui.menu.showMenuByMouseEvent(event, menu, { opacity: 0.8 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private sendInspectNodeMsg(node: any) {
|
private sendInspectNodeMsg(node: any) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// eval 注入脚本的代码,变量尽量使用var,后来发现在import之后,let会自动变为var
|
// eval 注入脚本的代码,变量尽量使用var,后来发现在import之后,let会自动变为var
|
||||||
import { uniq } from "lodash";
|
import { uniq } from "lodash";
|
||||||
import { Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestOpenNodeTouchFuntionData, RequestOpenScriptData, RequestSetPropertyData, ResponseGameInfoData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
import { BreakOnType, Msg, PluginEvent, RequestBreakOnData, RequestLogData, RequestNodeInfoData, RequestOpenNodeTouchFuntionData, RequestOpenScriptData, RequestSetPropertyData, ResponseGameInfoData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
||||||
import { CompType, getNodeIcon } from "../../views/devtools/comp";
|
import { CompType, getNodeIcon } from "../../views/devtools/comp";
|
||||||
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 { calcCodeHint, getCallbacks } from "./code-hint";
|
import { calcCodeHint, getCallbacks } from "./code-hint";
|
||||||
@ -12,6 +12,7 @@ import { inspectTarget } from "./inspect-list";
|
|||||||
import { getValue, trySetValueWithConfig } from "./setValue";
|
import { getValue, trySetValueWithConfig } from "./setValue";
|
||||||
import { BuildArrayOptions, BuildImageOptions, BuildObjectOptions, BuildVecOptions } from "./types";
|
import { BuildArrayOptions, BuildImageOptions, BuildObjectOptions, BuildVecOptions } from "./types";
|
||||||
import { isHasProperty } from "./util";
|
import { isHasProperty } from "./util";
|
||||||
|
import { addBreak, cleanBreak } from "./break";
|
||||||
|
|
||||||
declare const cc: any;
|
declare const cc: any;
|
||||||
export class Inspector extends InjectEvent {
|
export class Inspector extends InjectEvent {
|
||||||
@ -224,6 +225,39 @@ export class Inspector extends InjectEvent {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Msg.RequestBreakClean: {
|
||||||
|
cleanBreak();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Msg.RequestBreakOn: {
|
||||||
|
const data: RequestBreakOnData = pluginEvent.data;
|
||||||
|
const node = this.inspectorGameMemoryStorage[data.uuid];
|
||||||
|
if (node && node.isValid && node instanceof cc.Node) {
|
||||||
|
const map = {};
|
||||||
|
map[BreakOnType.ActiveChanged] = cc.Node?.EventType?.ACTIVE_CHANGED;
|
||||||
|
map[BreakOnType.SizeChanged] = cc.Node?.EventType?.SIZE_CHANGED;
|
||||||
|
map[BreakOnType.TransformChanged] = cc.Node?.EventType?.TRANSFORM_CHANGED;
|
||||||
|
map[BreakOnType.ColorChanged] = cc.Node?.EventType?.COLOR_CHANGED;
|
||||||
|
map[BreakOnType.LayerChanged] = cc.Node?.EventType?.LAYER_CHANGED;
|
||||||
|
map[BreakOnType.SiblingOrderChanged] = cc.Node?.EventType?.SIBLING_ORDER_CHANGED || cc.Node?.EventType?.CHILDREN_ORDER_CHANGED;
|
||||||
|
map[BreakOnType.Destroyed] = cc.Node?.EventType?.NODE_DESTROYED;
|
||||||
|
map[BreakOnType.ParentChanged] = cc.Node?.EventType?.PARENT_CHANGED;
|
||||||
|
map[BreakOnType.ChildAdded] = cc.Node?.EventType?.CHILD_ADDED;
|
||||||
|
map[BreakOnType.ChildRemoved] = cc.Node?.EventType?.CHILD_REMOVED;
|
||||||
|
map[BreakOnType.CompAdded] = cc.Node?.EventType?.COMPONENT_ADDED;
|
||||||
|
map[BreakOnType.CompRemoved] = cc.Node?.EventType?.COMPONENT_REMOVED;
|
||||||
|
const key = map[data.type];
|
||||||
|
if (key) {
|
||||||
|
const fn = () => {
|
||||||
|
eval("console.log(key);debugger;");
|
||||||
|
};
|
||||||
|
node.on(key, fn);
|
||||||
|
addBreak(node, key, fn);
|
||||||
|
} else {
|
||||||
|
console.log(`not adapt event: ${data.type}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
init() {
|
init() {
|
||||||
|
@ -22,7 +22,7 @@ import { HandExpandOptions } from "@xuyanfeng/cc-ui/types/cc-tree/const";
|
|||||||
import Mousetrap, { MousetrapInstance } from "mousetrap";
|
import Mousetrap, { MousetrapInstance } from "mousetrap";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { defineComponent, nextTick, onMounted, onUnmounted, ref, toRaw, watch } from "vue";
|
import { defineComponent, nextTick, onMounted, onUnmounted, ref, toRaw, watch } from "vue";
|
||||||
import { Msg, PluginEvent, RequestOpenNodeTouchFuntionData, RequestOpenScriptData, RequestTreeInfoData, RequestUseFrameData, ResponseSetPropertyData, ResponseSupportData } from "../../core/types";
|
import { BreakOnType, Msg, PluginEvent, RequestBreakOnData, RequestOpenNodeTouchFuntionData, RequestOpenScriptData, RequestTreeInfoData, RequestUseFrameData, ResponseSetPropertyData, ResponseSupportData } from "../../core/types";
|
||||||
import { ga } from "../../ga";
|
import { ga } from "../../ga";
|
||||||
import { GA_EventName } from "../../ga/type";
|
import { GA_EventName } from "../../ga/type";
|
||||||
import { ShowCode } from "../../scripts/inject/types";
|
import { ShowCode } from "../../scripts/inject/types";
|
||||||
@ -484,6 +484,35 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 断点功能
|
||||||
|
menus.push({ type: ccui.menu.MenuType.Separator });
|
||||||
|
if (data) {
|
||||||
|
const breakMenus: IUiMenuItem[] = [];
|
||||||
|
for (let key in BreakOnType) {
|
||||||
|
const v = BreakOnType[key];
|
||||||
|
breakMenus.push({
|
||||||
|
name: `${v}`,
|
||||||
|
enabled: true,
|
||||||
|
callback: (item) => {
|
||||||
|
ga.fireEventWithParam(GA_EventName.MouseMenu, item.name);
|
||||||
|
bridge.send(Msg.RequestBreakOn, { uuid: data.id, type: v } as RequestBreakOnData);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
menus.push({
|
||||||
|
name: "break on",
|
||||||
|
enabled: true,
|
||||||
|
items: breakMenus,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
menus.push({
|
||||||
|
name: "break clean",
|
||||||
|
enabled: true,
|
||||||
|
callback: (item) => {
|
||||||
|
ga.fireEventWithParam(GA_EventName.MouseMenu, item.name);
|
||||||
|
bridge.send(Msg.RequestBreakClean);
|
||||||
|
},
|
||||||
|
});
|
||||||
ccui.menu.showMenuByMouseEvent(event, menus);
|
ccui.menu.showMenuByMouseEvent(event, menus);
|
||||||
},
|
},
|
||||||
onChangeCase() {
|
onChangeCase() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user