Skip to content

Commit 152929e

Browse files
committed
🐞 fix: 修复一按右键就会开关背包的问题
这个问题导致在背包页面右键物品交互时,准星会瞬移到中心位置,并且字打开地图标记时会立刻关闭地图。
1 parent 988e7d5 commit 152929e

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

Soldier76-lite.lua

+19-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ RunningCache = {
2323
-- 累计偏差像素
2424
deviationCounterPX = 0,
2525
-- 上一次的 Y 轴位置
26-
lastY = 0
26+
lastY = 0,
27+
-- 按下右键时的时间戳
28+
rightMouseDownTimestamp = 0
2729
}
2830

2931
-- 是否启动
@@ -120,13 +122,6 @@ function Main (event, arg, family)
120122
-- 重置缓存
121123
RunningCache.deviationPX = 0
122124
RunningCache.deviationCounterPX = 0
123-
124-
elseif event == "MOUSE_BUTTON_RELEASED" and arg == 3 and family == "mouse" then
125-
-- -- 重置鼠标位置
126-
if (not IsPressed(1) and not IsPressed(3)) then
127-
PressAndReleaseKey('tab')
128-
PressAndReleaseKey('tab')
129-
end
130125
end
131126
end
132127

@@ -140,6 +135,22 @@ function OnEvent (event, arg, family)
140135

141136
-- 进入压枪循环
142137
Main(event, arg, family)
138+
-- 右键长按 300ms 以上,认定为开镜了,放开右键后,按下 tab 两次,重置鼠标位置
139+
if event == "MOUSE_BUTTON_PRESSED" and arg == 3 and family == "mouse" then
140+
RunningCache.rightMouseDownTimestamp = GetRunningTime()
141+
end
142+
143+
if event == "MOUSE_BUTTON_RELEASED" and arg == 3 and family == "mouse" then
144+
-- 右键按下时长
145+
local rightMouseDownDuration = GetRunningTime() - RunningCache.rightMouseDownTimestamp
146+
-- ConsoleLog({ "右键按下时长: ", rightMouseDownDuration, "ms" })
147+
148+
-- 重置鼠标位置
149+
if (rightMouseDownDuration >= 300 and not IsPressed(1)) then
150+
PressAndReleaseKey('tab')
151+
PressAndReleaseKey('tab')
152+
end
153+
end
143154

144155
-- 释放所有占用的按键
145156
if event == "PROFILE_DEACTIVATED" then

0 commit comments

Comments
 (0)