Skip to content

Commit e873092

Browse files
committed
✨ 增加键盘调整摄像机缩放倍率的自定义设置项
1 parent c508392 commit e873092

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

app/src/core/service/Settings.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export namespace Settings {
5555
allowMoveCameraByWSAD: boolean;
5656
cameraKeyboardMoveReverse: boolean;
5757
scaleCameraByMouseLocation: boolean;
58+
cameraKeyboardScaleRate: number;
5859
allowAddCycleEdge: boolean;
5960
moveAmplitude: number;
6061
moveFriction: number;
@@ -120,6 +121,7 @@ export namespace Settings {
120121
allowMoveCameraByWSAD: false,
121122
cameraKeyboardMoveReverse: false,
122123
scaleCameraByMouseLocation: true,
124+
cameraKeyboardScaleRate: 0.2,
123125
allowAddCycleEdge: false,
124126
moveAmplitude: 2,
125127
moveFriction: 0.1,

app/src/core/stage/Camera.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export namespace Camera {
8484
export let limitCameraInCycleSpace = false;
8585
export let cameraCycleSpaceSizeX = 1000;
8686
export let cameraCycleSpaceSizeY = 1000;
87+
let cameraKeyboardScaleRate = 0.2;
8788

8889
// IDEA: 突然有一个好点子
8990
// 把wsad移动的逻辑改成瞬间爆炸的冲刺一小段距离,而不是改成直接赋予永久的作用力方向然后再撤销
@@ -164,12 +165,12 @@ export namespace Camera {
164165
let tickNumberUpper = 0;
165166

166167
export function zoomInByKeyboard() {
167-
Camera.targetScale *= 1.2;
168+
Camera.targetScale *= 1 + cameraKeyboardScaleRate;
168169
tickNumberUpper = tickNumber + 5 * 60;
169170
}
170171

171172
export function zoomOutByKeyboard() {
172-
Camera.targetScale *= 0.8;
173+
Camera.targetScale *= 1 - cameraKeyboardScaleRate;
173174
tickNumberUpper = tickNumber + 5 * 60;
174175
}
175176

@@ -244,6 +245,9 @@ export namespace Camera {
244245
Settings.watch("cameraCycleSpaceSizeY", (value) => {
245246
cameraCycleSpaceSizeY = value;
246247
});
248+
Settings.watch("cameraKeyboardScaleRate", (value) => {
249+
cameraKeyboardScaleRate = value;
250+
});
247251
}
248252

249253
/**

app/src/locales/en.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ settings:
265265
When the approximation is close enough (less than 0.0001), the scaling will stop automatically.
266266
A value of 1 means the scaling will be completed immediately without any intermediate transition effect.
267267
A value of 0 means the scaling will never be completed, which can simulate a locked effect.
268+
cameraKeyboardScaleRate:
269+
title: Viewport Zoom Keyboard Rate
270+
description: |
271+
The zoom scale factor of the viewport each time it is zoomed in or out using a keyboard press.
272+
A value of 0.2 means that each zoom in will increase the scale to 1.2 times the original, and each zoom out will decrease the scale to 0.8 times the original.
273+
A value of 0 means keyboard zooming is disabled.
274+
268275
scaleCameraByMouseLocation:
269276
title: Scale Camera by Mouse Location
270277
description: |

app/src/locales/zh_CN.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ settings:
248248
当逼近的足够近时(小于0.0001),会自动停止缩放
249249
值为1代表缩放会立刻完成,没有中间的过渡效果
250250
值为0代表缩放永远都不会完成,可模拟锁死效果
251+
cameraKeyboardScaleRate:
252+
title: 视角缩放键盘速率
253+
description: |
254+
每次通过一次按键来缩放视野时,视野的缩放倍率
255+
值为0.2代表每次放大会变为原来的1.2倍,缩小为原来的0.8倍
256+
值为0代表禁止通过键盘缩放
251257
scaleCameraByMouseLocation:
252258
title: 视角缩放根据鼠标位置
253259
description: |

app/src/locales/zh_TW.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ settings:
236236
當逼近的足夠近時(小於0.0001),會自動停止縮放
237237
值为1代表縮放會立刻完成,没有中间的过渡效果
238238
值为0代表縮放永遠都不会完成,可模拟锁死效果
239+
cameraKeyboardScaleRate:
240+
title: 视角缩放键盘速率
241+
description: |
242+
每次通过一次按键来缩放视野时,视野的缩放倍率
243+
值为0.2代表每次放大会变为原来的1.2倍,缩小为原来的0.8倍
244+
值为0代表禁止通过键盘缩放
239245
scaleCameraByMouseLocation:
240246
title: 视角缩放根据鼠标位置
241247
description: |

app/src/pages/settings/control.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ export default function Control() {
4343

4444
<FieldGroup title="Camera 摄像机/视野/相关" icon={<Fullscreen />}>
4545
<SettingField icon={<ScanEye />} settingKey="scaleExponent" type="slider" min={0} max={1} step={0.01} />
46+
<SettingField
47+
icon={<ScanEye />}
48+
settingKey="cameraKeyboardScaleRate"
49+
type="slider"
50+
min={0}
51+
max={3}
52+
step={0.1}
53+
/>
4654
<SettingField icon={<ScanEye />} settingKey="scaleCameraByMouseLocation" type="switch" />
4755
<SettingField icon={<Keyboard />} settingKey="allowMoveCameraByWSAD" type="switch" />
4856
<SettingField icon={<Keyboard />} settingKey="cameraKeyboardMoveReverse" type="switch" />

0 commit comments

Comments
 (0)