diff --git a/src/core/Settings.tsx b/src/core/Settings.tsx
index 98557878..d46299e7 100644
--- a/src/core/Settings.tsx
+++ b/src/core/Settings.tsx
@@ -41,6 +41,9 @@ export namespace Settings {
// 音效相关
soundEnabled: boolean;
cuttingLineStartSoundFile: string;
+ connectLineStartSoundFile: string;
+ connectFindTargetSoundFile: string;
+ cuttingLineReleaseSoundFile: string;
// github 相关
githubToken: string;
githubUser: string;
@@ -78,7 +81,9 @@ export namespace Settings {
// 音效相关
soundEnabled: true,
cuttingLineStartSoundFile: "",
-
+ connectLineStartSoundFile: "",
+ connectFindTargetSoundFile: "",
+ cuttingLineReleaseSoundFile: "",
// github 相关
githubToken: "",
githubUser: "",
diff --git a/src/core/SoundService.tsx b/src/core/SoundService.tsx
index e54a41c7..c146bcbf 100644
--- a/src/core/SoundService.tsx
+++ b/src/core/SoundService.tsx
@@ -13,11 +13,23 @@ import { Settings } from "./Settings";
export namespace SoundService {
let cuttingLineStartSoundFile = "";
+ let connectLineStartSoundFile = "";
+ let connectFindTargetSoundFile = "";
+ let cuttingLineReleaseSoundFile = "";
export function init() {
Settings.watch("cuttingLineStartSoundFile", (value) => {
cuttingLineStartSoundFile = value;
});
+ Settings.watch("connectLineStartSoundFile", (value) => {
+ connectLineStartSoundFile = value;
+ });
+ Settings.watch("connectFindTargetSoundFile", (value) => {
+ connectFindTargetSoundFile = value;
+ });
+ Settings.watch("cuttingLineReleaseSoundFile", (value) => {
+ cuttingLineReleaseSoundFile = value;
+ });
}
export namespace play {
@@ -27,7 +39,14 @@ export namespace SoundService {
}
// 开始连接
+ export function connectLineStart() {
+ loadAndPlaySound(connectLineStartSoundFile);
+ }
+
// 连接吸附到目标点
+ export function connectFindTarget() {
+ loadAndPlaySound(connectFindTargetSoundFile);
+ }
// 自动保存执行特效
// 自动备份执行特效
@@ -35,6 +54,9 @@ export namespace SoundService {
// 框选增加物体音效
// 切断特效声音
+ export function cuttingLineRelease() {
+ loadAndPlaySound(cuttingLineReleaseSoundFile);
+ }
// 连接成功
}
diff --git a/src/core/controller/concrete/ControllerCutting.tsx b/src/core/controller/concrete/ControllerCutting.tsx
index f7e83020..b1765342 100644
--- a/src/core/controller/concrete/ControllerCutting.tsx
+++ b/src/core/controller/concrete/ControllerCutting.tsx
@@ -147,4 +147,5 @@ ControllerCutting.mouseup = (event: MouseEvent) => {
cuttingStartLocation.distance(ControllerCutting.lastMoveLocation) / 10,
),
);
+ SoundService.play.cuttingLineRelease();
};
diff --git a/src/core/controller/concrete/ControllerNodeConnection.tsx b/src/core/controller/concrete/ControllerNodeConnection.tsx
index bf7ffc05..12b3ed5c 100644
--- a/src/core/controller/concrete/ControllerNodeConnection.tsx
+++ b/src/core/controller/concrete/ControllerNodeConnection.tsx
@@ -12,6 +12,7 @@ import { EdgeRenderer } from "../../render/canvas2d/entityRenderer/edge/EdgeRend
import { ConnectableEntity } from "../../stageObject/StageObject";
import { ConnectPoint } from "../../stageObject/entity/ConnectPoint";
import { v4 } from "uuid";
+import { SoundService } from "../../SoundService";
/**
* 右键连线功能 的控制器
@@ -109,6 +110,8 @@ ControllerNodeConnection.mousedown = (event: MouseEvent) => {
),
);
}
+ // 播放音效
+ SoundService.play.connectLineStart();
}
};
@@ -126,9 +129,10 @@ ControllerNodeConnection.mousemove = (event: MouseEvent) => {
let isFindConnectToNode = false;
for (const entity of StageManager.getConnectableEntity()) {
if (entity.collisionBox.isPointInCollisionBox(worldLocation)) {
+ // 找到了连接的节点,吸附上去
Stage.connectToEntity = entity;
isFindConnectToNode = true;
-
+ SoundService.play.connectFindTarget();
break;
}
}
diff --git a/src/pages/settings/sounds.tsx b/src/pages/settings/sounds.tsx
index 492467c3..c64816be 100644
--- a/src/pages/settings/sounds.tsx
+++ b/src/pages/settings/sounds.tsx
@@ -11,6 +11,27 @@ export default function Sounds() {
details={"右键按下时刚开始创建切割线准备切割东西时播放的音效文件。"}
type="text"
/>
+ }
+ settingKey="connectLineStartSoundFile"
+ title={"连接线开始音效"}
+ details={"右键按下时刚开始创建连接时播放的音效文件。"}
+ type="text"
+ />
+ }
+ settingKey="connectFindTargetSoundFile"
+ title={"连接线查找目标音效"}
+ details={"当"}
+ type="text"
+ />
+ }
+ settingKey="cuttingLineReleaseSoundFile"
+ title={"切断线释放特效"}
+ details={"纯粹解压用的"}
+ type="text"
+ />
>
);
}