Skip to content

Commit cab538a

Browse files
committed
feat: 增加jackal快捷键
1 parent 5236737 commit cab538a

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

app/src/core/render/canvas2d/renderer.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ export class Renderer {
9393
const viewRectangle = this.getCoverWorldRectangle();
9494
this.renderBackground();
9595
this.renderMainStageElements(viewRectangle);
96+
97+
// 潜行模式 - 只显示鼠标周围的一个圆形区域
98+
if (Settings.isStealthModeEnabled) {
99+
const ctx = this.project.canvas.ctx;
100+
// 设置合成模式为目标输入模式
101+
ctx.globalCompositeOperation = "destination-in";
102+
// 获取鼠标位置
103+
const mouseX = MouseLocation.x;
104+
const mouseY = MouseLocation.y;
105+
// 获取潜行模式半径
106+
const scopeRadius = Settings.stealthModeScopeRadius;
107+
// 绘制圆形区域
108+
ctx.beginPath();
109+
ctx.arc(mouseX, mouseY, scopeRadius, 0, Math.PI * 2);
110+
ctx.fill();
111+
// 恢复合成模式
112+
ctx.globalCompositeOperation = "source-over";
113+
}
114+
96115
this.renderViewElements(viewRectangle);
97116
}
98117

@@ -594,7 +613,7 @@ export class Renderer {
594613
`Stage.warningAssociations: ${this.project.controller.cutting.warningAssociations.length}`,
595614
`ConnectFromNodes: ${this.project.controller.nodeConnection.connectFromEntities}`,
596615
`lastSelectedNode: ${this.project.controller.lastSelectedEntityUUID.size}`,
597-
`粘贴板: ${JSON.stringify(this.project.copyEngine.copyBoardData)}`,
616+
`粘贴板: ${JSON.stringify(this.project.copyEngine?.copyBoardData || "undefined")}`,
598617
`fps: ${this.fps}`,
599618
`delta: ${this.deltaTime.toFixed(2)}`,
600619
`uri: ${this.project.uri}`,

app/src/core/service/Settings.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ export const settingsSchema = z.object({
151151
githubUser: z.string().default(""),
152152
theme: z.string().default("dark-blue"),
153153
telemetry: z.boolean().default(true),
154+
isStealthModeEnabled: z.boolean().default(false),
155+
stealthModeScopeRadius: z.number().min(50).max(500).int().default(150),
154156
});
155157

156158
export type Settings = z.infer<typeof settingsSchema>;

app/src/core/service/SettingsIcons.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,6 @@ export const settingsIcons = {
145145
cameraCycleSpaceSizeY: Scaling,
146146
autoAdjustLineEndpointsByMouseTrack: LineSquiggle,
147147
enableRightClickConnect: MousePointerClick,
148+
isStealthModeEnabled: Crosshair,
149+
stealthModeScopeRadius: ScanEye,
148150
};

app/src/core/service/controlService/shortcutKeysEngine/shortcutKeysRegister.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,15 +927,20 @@ export class KeyBindsRegistrar {
927927
await this.project.keyBinds.create("swapTextAndDetails", "e e e e e", () => {
928928
const selectedTextNodes = this.project.stageManager
929929
.getSelectedEntities()
930-
.filter((node) => node instanceof TextNode);
930+
.filter((node): node is TextNode => node instanceof TextNode);
931931
for (const node of selectedTextNodes) {
932-
const details = node.details;
933-
const text = node.text;
932+
const details: string = node.details;
933+
const text: string = node.text;
934934
node.details = text;
935935
node.text = details;
936936
node.forceAdjustSizeByText();
937937
}
938938
this.project.historyManager.recordStep();
939939
});
940+
941+
await this.project.keyBinds.create("switchStealthMode", "j a c k a l", () => {
942+
Settings.isStealthModeEnabled = !Settings.isStealthModeEnabled;
943+
toast(Settings.isStealthModeEnabled ? "已开启潜行模式" : "已关闭潜行模式");
944+
});
940945
}
941946
}

app/src/sub/SettingsWindow/settings.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ const categories = {
203203
],
204204
debug: ["showDebug", "protectingPrivacy"],
205205
miniWindow: ["windowCollapsingWidth", "windowCollapsingHeight"],
206-
experimental: ["limitCameraInCycleSpace", "cameraCycleSpaceSizeX", "cameraCycleSpaceSizeY"],
206+
experimental: [
207+
"limitCameraInCycleSpace",
208+
"cameraCycleSpaceSizeX",
209+
"cameraCycleSpaceSizeY",
210+
"isStealthModeEnabled",
211+
"stealthModeScopeRadius",
212+
],
207213
},
208214
automation: {
209215
autoNamer: ["autoNamerTemplate", "autoNamerSectionTemplate"],

0 commit comments

Comments
 (0)