Skip to content

Commit

Permalink
🐞 fix: 修复一按右键就会开关背包的问题
Browse files Browse the repository at this point in the history
这个问题导致在背包页面右键物品交互时,准星会瞬移到中心位置,并且字打开地图标记时会立刻关闭地图。
  • Loading branch information
kiccer committed Feb 12, 2023
1 parent 988e7d5 commit 152929e
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Soldier76-lite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ RunningCache = {
-- 累计偏差像素
deviationCounterPX = 0,
-- 上一次的 Y 轴位置
lastY = 0
lastY = 0,
-- 按下右键时的时间戳
rightMouseDownTimestamp = 0
}

-- 是否启动
Expand Down Expand Up @@ -120,13 +122,6 @@ function Main (event, arg, family)
-- 重置缓存
RunningCache.deviationPX = 0
RunningCache.deviationCounterPX = 0

elseif event == "MOUSE_BUTTON_RELEASED" and arg == 3 and family == "mouse" then
-- -- 重置鼠标位置
if (not IsPressed(1) and not IsPressed(3)) then
PressAndReleaseKey('tab')
PressAndReleaseKey('tab')
end
end
end

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

-- 进入压枪循环
Main(event, arg, family)
-- 右键长按 300ms 以上,认定为开镜了,放开右键后,按下 tab 两次,重置鼠标位置
if event == "MOUSE_BUTTON_PRESSED" and arg == 3 and family == "mouse" then
RunningCache.rightMouseDownTimestamp = GetRunningTime()
end

if event == "MOUSE_BUTTON_RELEASED" and arg == 3 and family == "mouse" then
-- 右键按下时长
local rightMouseDownDuration = GetRunningTime() - RunningCache.rightMouseDownTimestamp
-- ConsoleLog({ "右键按下时长: ", rightMouseDownDuration, "ms" })

-- 重置鼠标位置
if (rightMouseDownDuration >= 300 and not IsPressed(1)) then
PressAndReleaseKey('tab')
PressAndReleaseKey('tab')
end
end

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

0 comments on commit 152929e

Please sign in to comment.