Skip to content

Commit 7daf299

Browse files
committed
fix: use stopFast and setButton method
1 parent a899f9c commit 7daf299

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

packages/webgal/src/Core/controller/gamePlay/fastSkip.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const setButton = (on: boolean) => {
1919
}
2020
};
2121

22+
export { setButton as setFastButton };
23+
2224
/**
2325
* 停止快进模式
2426
*/

packages/webgal/src/hooks/useHotkey.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { startFast, stopAll, stopFast } from '@/Core/controller/gamePlay/fastSkip';
1+
import { setFastButton, startFast, stopAll, stopFast } from '@/Core/controller/gamePlay/fastSkip';
22
import { nextSentence } from '@/Core/controller/gamePlay/nextSentence';
33
import { fastSaveGame } from '@/Core/controller/storage/fastSaveLoad';
44
import { setStorage } from '@/Core/controller/storage/storageController';
@@ -10,7 +10,6 @@ import { setVisibility } from '@/store/GUIReducer';
1010
import { RootState } from '@/store/store';
1111
import { setOptionData } from '@/store/userDataReducer';
1212
import styles from '@/UI/Backlog/backlog.module.scss';
13-
import bottomControlPanelStyles from '@/UI/BottomControlPanel/bottomControlPanel.module.scss';
1413
import throttle from 'lodash/throttle';
1514
import { useCallback, useEffect, useRef } from 'react';
1615
import { useDispatch } from 'react-redux';
@@ -141,17 +140,13 @@ export function useMouseWheel() {
141140
} else if (isGameActive() && direction === 'down' && !ctrlKey) {
142141
clearTimeout(wheelTimeout);
143142
// 已开启快进模式
144-
if (WebGAL.gameplay.fastInterval !== null) {
145-
clearInterval(WebGAL.gameplay.fastInterval);
146-
WebGAL.gameplay.fastInterval = null;
147-
}
148-
const autoIcon = document.getElementById('Button_ControlPanel_fast');
143+
if (WebGAL.gameplay.isFast) stopFast();
149144
WebGAL.gameplay.isFast = true;
150145
// 滚轮视作快进
151-
if (autoIcon) autoIcon.className = bottomControlPanelStyles.button_on;
146+
setFastButton(true);
152147
setTimeout(() => {
153148
WebGAL.gameplay.isFast = false;
154-
if (autoIcon) autoIcon.className = bottomControlPanelStyles.singleButton;
149+
setFastButton(false);
155150
}, 150);
156151
next();
157152
}

0 commit comments

Comments
 (0)