Fixed BoC search feature blocking controller inputs; Added configurable key for search feature toggle
This commit is contained in:
1 parent
f358080666
commit
cf27dfea20
3 files changed
+22
-16
No files matched your search
@@ -126,7 +126,7 @@ local function handleSearchInput()
|
||||
return
|
||||
end
|
||||
|
||||
if Input.IsButtonTriggered(Keyboard.KEY_ESCAPE, EID.bagPlayer.ControllerIndex, true) then
|
||||
if Input.IsButtonTriggered(Keyboard.KEY_ESCAPE, 0, true) then
|
||||
EID:BoCSSetSearchInputEnabled(false)
|
||||
EID:BoCSSetSearchValue("")
|
||||
return
|
||||
@@ -140,9 +140,9 @@ local function handleSearchInput()
|
||||
-- enum values are integers
|
||||
for i=Keyboard.KEY_SPACE,Keyboard.KEY_RIGHT_BRACKET do
|
||||
index = index + 1
|
||||
if Input.IsButtonTriggered(i, EID.bagPlayer.ControllerIndex, true) then
|
||||
if Input.IsButtonTriggered(i, 0, true) then
|
||||
local toAppend = indexCharMapping:sub(index, index)
|
||||
local isShiftPressed = (Input.IsButtonPressed(Keyboard.KEY_LEFT_SHIFT, EID.bagPlayer.ControllerIndex, true) or Input.IsButtonPressed(Keyboard.KEY_RIGHT_SHIFT, EID.bagPlayer.ControllerIndex, true))
|
||||
local isShiftPressed = (Input.IsButtonPressed(Keyboard.KEY_LEFT_SHIFT, 0, true) or Input.IsButtonPressed(Keyboard.KEY_RIGHT_SHIFT, 0, true))
|
||||
if isShiftPressed then toAppend = shiftCharMapping:sub(index, index) end
|
||||
|
||||
newValue = newValue .. toAppend
|
||||
@@ -157,7 +157,7 @@ local function handleSearchInput()
|
||||
end
|
||||
end
|
||||
|
||||
if Input.IsButtonTriggered(Keyboard.KEY_BACKSPACE, EID.bagPlayer.ControllerIndex, true) then
|
||||
if Input.IsButtonTriggered(Keyboard.KEY_BACKSPACE, 0, true) then
|
||||
lastBackspaceTrigger = 0
|
||||
backspaceStep = 0
|
||||
return
|
||||
@@ -166,7 +166,7 @@ local function handleSearchInput()
|
||||
local currentFrame = game:GetFrameCount()
|
||||
-- 30 Frames = 1 second
|
||||
-- 15 = 500ms
|
||||
if Input.IsButtonPressed(Keyboard.KEY_BACKSPACE, EID.bagPlayer.ControllerIndex, true) and (
|
||||
if Input.IsButtonPressed(Keyboard.KEY_BACKSPACE, 0, true) and (
|
||||
backspaceStep == 0
|
||||
or
|
||||
(backspaceStep == 1 and currentFrame - lastBackspaceTrigger >= 15) -- we delay the second deletion a little bit more
|
||||
@@ -174,9 +174,9 @@ local function handleSearchInput()
|
||||
(backspaceStep >= 2 and currentFrame - lastBackspaceTrigger >= 1)
|
||||
) then
|
||||
local isControlPressed = (
|
||||
Input.IsButtonPressed(Keyboard.KEY_LEFT_CONTROL, EID.bagPlayer.ControllerIndex, true)
|
||||
Input.IsButtonPressed(Keyboard.KEY_LEFT_CONTROL, 0, true)
|
||||
or
|
||||
Input.IsButtonPressed(Keyboard.KEY_RIGHT_CONTROL, EID.bagPlayer.ControllerIndex, true)
|
||||
Input.IsButtonPressed(Keyboard.KEY_RIGHT_CONTROL, 0, true)
|
||||
)
|
||||
|
||||
if isControlPressed then
|
||||
@@ -207,15 +207,13 @@ function EID:BoCSHandleInput()
|
||||
end
|
||||
|
||||
-- Clear the previous search when Enter is pressed
|
||||
-- TODO: make this a modifiable hotkey
|
||||
if Input.IsButtonTriggered(Keyboard.KEY_ENTER, EID.bagPlayer.ControllerIndex, true) then
|
||||
if Input.IsButtonTriggered(EID.Config["CraftingSearchKey"], 0, true) then
|
||||
if not searchInputEnabled then EID:BoCSSetSearchValue("") end
|
||||
end
|
||||
|
||||
-- Start a new search when Enter is pressed
|
||||
-- TODO: make this a modifiable hotkey
|
||||
-- by default, both are Enter, but for instance clearing could be Backspace and then you could modify a search term with Enter
|
||||
if Input.IsButtonTriggered(Keyboard.KEY_ENTER, EID.bagPlayer.ControllerIndex, true) then
|
||||
if Input.IsButtonTriggered(EID.Config["CraftingSearchKey"], 0, true) then
|
||||
EID:BoCSSetSearchInputEnabled(not searchInputEnabled)
|
||||
return
|
||||
end
|
||||
@@ -262,7 +260,7 @@ function EID:BoCSHookInputIsButtonTriggered()
|
||||
end
|
||||
end
|
||||
|
||||
if bagPlayer == nil or controller ~= bagPlayer.ControllerIndex then
|
||||
if bagPlayer == nil or controller ~= 0 then -- only execute for keyboard
|
||||
return oldInputIsButtonTriggered(key, controller)
|
||||
end
|
||||
|
||||
@@ -286,7 +284,7 @@ function EID:BoCSHookInputIsButtonPressed()
|
||||
end
|
||||
end
|
||||
|
||||
if bagPlayer == nil or controller ~= bagPlayer.ControllerIndex then
|
||||
if bagPlayer == nil or controller ~= 0 then -- only execute for keyboard
|
||||
return oldInputIsButtonPressed(key, controller)
|
||||
end
|
||||
|
||||
@@ -310,7 +308,7 @@ function EID:BoCSHookInputIsActionPressed()
|
||||
end
|
||||
end
|
||||
|
||||
if bagPlayer == nil or controller ~= bagPlayer.ControllerIndex then
|
||||
if bagPlayer == nil or controller ~= 0 then -- only execute for keyboard
|
||||
return oldInputIsActionPressed(key, controller)
|
||||
end
|
||||
|
||||
@@ -334,8 +332,8 @@ function EID:BoCSHookInputIsActionTriggered()
|
||||
end
|
||||
end
|
||||
|
||||
if bagPlayer == nil or controller ~= bagPlayer.ControllerIndex then
|
||||
return oldInputIsActionTriggered(key, controller)
|
||||
if bagPlayer == nil or controller ~= 0 then
|
||||
return oldInputIsActionTriggered(key, controller) -- only execute for keyboard
|
||||
end
|
||||
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user