BoC: Locking query locking possible via result locking combo
This commit is contained in:
1 parent
e3c88aad24
commit
c493675ab7
2 files changed
+129
-67
No files matched your search
@@ -940,7 +940,7 @@ function EID:handleBagOfCraftingUpdating()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Check for Hold Tab key inputs
|
-- Check for Hold Tab key inputs
|
||||||
if displayingRecipeList and Input.IsActionPressed(EID.Config["BagOfCraftingToggleKey"], EID.bagPlayer.ControllerIndex) then
|
if displayingRecipeList and Input.IsActionPressed(EID.Config["BagOfCraftingToggleKey"], EID.bagPlayer.ControllerIndex, true) then
|
||||||
EID.TabDescThisFrame = true
|
EID.TabDescThisFrame = true
|
||||||
EID.bagPlayer.ControlsCooldown = 2
|
EID.bagPlayer.ControlsCooldown = 2
|
||||||
if Input.IsActionTriggered(ButtonAction.ACTION_SHOOTDOWN, EID.bagPlayer.ControllerIndex) then
|
if Input.IsActionTriggered(ButtonAction.ACTION_SHOOTDOWN, EID.bagPlayer.ControllerIndex) then
|
||||||
@@ -950,10 +950,15 @@ function EID:handleBagOfCraftingUpdating()
|
|||||||
bagOfCraftingOffset = math.max(0, bagOfCraftingOffset - EID.Config["BagOfCraftingResults"])
|
bagOfCraftingOffset = math.max(0, bagOfCraftingOffset - EID.Config["BagOfCraftingResults"])
|
||||||
upHeld = Isaac.GetTime()
|
upHeld = Isaac.GetTime()
|
||||||
--lock the current results so you can actually do a recipe that you've scrolled down to without losing it
|
--lock the current results so you can actually do a recipe that you've scrolled down to without losing it
|
||||||
elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTLEFT, EID.bagPlayer.ControllerIndex) then
|
elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTLEFT, EID.bagPlayer.ControllerIndex, true) then
|
||||||
EID.RefreshBagTextbox = true
|
EID.RefreshBagTextbox = true
|
||||||
if (lockedResults == nil) then lockedResults = queryString
|
if (lockedResults == nil) then
|
||||||
else lockedResults = nil end
|
lockedResults = queryString
|
||||||
|
EID:BoCSSetLocked(true)
|
||||||
|
else
|
||||||
|
lockedResults = nil
|
||||||
|
EID:BoCSSetLocked(false)
|
||||||
|
end
|
||||||
--refresh the recipes
|
--refresh the recipes
|
||||||
elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTRIGHT, EID.bagPlayer.ControllerIndex) then
|
elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTRIGHT, EID.bagPlayer.ControllerIndex) then
|
||||||
if (lockedResults == nil) then
|
if (lockedResults == nil) then
|
||||||
|
|||||||
+120
-63
@@ -1,36 +1,70 @@
|
|||||||
|
-- Valid values:
|
||||||
|
-- 0 -> Reset search query after search
|
||||||
|
EID.BoCSLockMode = 0
|
||||||
|
local locked = false
|
||||||
|
|
||||||
local indexCharMapping = " ??????'????,-./0123456789?;?????abcdefghijklmnopqrstuvwxyz"
|
local indexCharMapping = " ??????'????,-./0123456789?;?????abcdefghijklmnopqrstuvwxyz"
|
||||||
local searchValue = ""
|
local searchValue = ""
|
||||||
local searchInputEnabled = false
|
local searchInputEnabled = false
|
||||||
local lastBackspaceTrigger = 0
|
local lastBackspaceTrigger = 0
|
||||||
local backspaceStep = 0
|
local backspaceStep = 0
|
||||||
|
|
||||||
|
|
||||||
--- Returns the current search query
|
--- Returns the current search query
|
||||||
-- @param newValue new search query
|
-- @param newValue new search query
|
||||||
function EID:BoCSSetSearchValue(newValue)
|
function EID:BoCSSetSearchValue(newValue)
|
||||||
if newValue == nil then
|
if newValue == nil then
|
||||||
newValue = ""
|
searchValue = ""
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
searchValue = newValue
|
searchValue = newValue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the current search query
|
--- Returns the current search query
|
||||||
-- @return string
|
-- @return string
|
||||||
function EID:BoCSGetSearchValue()
|
function EID:BoCSGetSearchValue()
|
||||||
return searchValue
|
return searchValue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EID:BoCSGetLocked()
|
||||||
|
return locked
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Locks or unlocks the search query
|
||||||
|
-- @param newState boolean
|
||||||
|
function EID:BoCSSetLocked(newState, force)
|
||||||
|
if EID.BoCSLockMode ~= 0 and force ~= true then
|
||||||
|
locked = false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
locked = newState
|
||||||
|
|
||||||
|
if newState then
|
||||||
|
EID:BoCSSetSearchInputEnabled(false, true)
|
||||||
|
else
|
||||||
|
EID:BoCSSetSearchValue("")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Enables or disables the search input respectively
|
--- Enables or disables the search input respectively
|
||||||
-- @param newState boolean
|
-- @param newState boolean
|
||||||
function EID:BoCSSetSearchInputEnabled(newState)
|
function EID:BoCSSetSearchInputEnabled(newState, force)
|
||||||
searchInputEnabled = newState
|
if EID.BoCSLockMode == 0 and EID:BoCSGetLocked() and force ~= true then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
searchInputEnabled = newState
|
||||||
if newState then
|
if newState then
|
||||||
EID:AddCallback(ModCallbacks.MC_INPUT_ACTION, EID.BoCSBlockInputAction)
|
EID:AddCallback(ModCallbacks.MC_INPUT_ACTION, EID.BoCSBlockInputAction)
|
||||||
else
|
else
|
||||||
EID:RemoveCallback(ModCallbacks.MC_INPUT_ACTION, EID.BoCSBlockInputAction)
|
EID:RemoveCallback(ModCallbacks.MC_INPUT_ACTION, EID.BoCSBlockInputAction)
|
||||||
|
searchInputEnabled = newState
|
||||||
|
|
||||||
|
if EID.BoCSLockMode == 0 and not EID:BoCSGetLocked() then
|
||||||
|
EID:BoCSSetSearchValue("")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -55,6 +89,76 @@ function EID:BoCSCheckItemName(itemName)
|
|||||||
return string.find(string.lower(itemName), string.lower(searchValue))
|
return string.find(string.lower(itemName), string.lower(searchValue))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function handleSearchInput()
|
||||||
|
if (
|
||||||
|
not searchInputEnabled
|
||||||
|
or (
|
||||||
|
EID.BoCSLockMode == 0
|
||||||
|
and
|
||||||
|
EID:BoCSGetLocked()
|
||||||
|
)
|
||||||
|
) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local newValue = searchValue
|
||||||
|
local index = 0
|
||||||
|
local hasLetterInput = false
|
||||||
|
|
||||||
|
-- Keep in mind that this only works because the respective
|
||||||
|
-- enum values are integers
|
||||||
|
for i=Keyboard.KEY_SPACE,Keyboard.KEY_Z do
|
||||||
|
index = index + 1
|
||||||
|
if Input.IsButtonTriggered(i, EID.bagPlayer.ControllerIndex, true) then
|
||||||
|
local toAppend = string.upper(indexCharMapping:sub(index, index))
|
||||||
|
|
||||||
|
newValue = newValue .. toAppend
|
||||||
|
hasLetterInput = true
|
||||||
|
|
||||||
|
-- We only handle one input at a time
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
if hasLetterInput then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if Input.IsButtonTriggered(Keyboard.KEY_BACKSPACE, EID.bagPlayer.ControllerIndex, true) then
|
||||||
|
lastBackspaceTrigger = 0
|
||||||
|
backspaceStep = 0
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local currentFrame = Game():GetFrameCount()
|
||||||
|
-- 30 Frames = 1 second
|
||||||
|
-- 15 = 500ms
|
||||||
|
if Input.IsButtonPressed(Keyboard.KEY_BACKSPACE, EID.bagPlayer.ControllerIndex, true) and (
|
||||||
|
backspaceStep == 0
|
||||||
|
or
|
||||||
|
(backspaceStep == 1 and currentFrame - lastBackspaceTrigger > 15) -- we delay the second deletion a little bit more
|
||||||
|
or
|
||||||
|
(backspaceStep >= 2 and currentFrame - lastBackspaceTrigger > 3)
|
||||||
|
) then
|
||||||
|
local isControlPressed = (
|
||||||
|
Input.IsButtonPressed(Keyboard.KEY_LEFT_CONTROL, EID.bagPlayer.ControllerIndex, true)
|
||||||
|
or
|
||||||
|
Input.IsButtonPressed(Keyboard.KEY_RIGHT_CONTROL, EID.bagPlayer.ControllerIndex, true)
|
||||||
|
)
|
||||||
|
|
||||||
|
if isControlPressed then
|
||||||
|
newValue = ""
|
||||||
|
else
|
||||||
|
newValue = searchValue:sub(1, -2)
|
||||||
|
end
|
||||||
|
|
||||||
|
lastBackspaceTrigger = currentFrame
|
||||||
|
backspaceStep = backspaceStep + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
searchValue = newValue
|
||||||
|
end
|
||||||
|
|
||||||
--- Handles any input done related to Bag of Crafting search
|
--- Handles any input done related to Bag of Crafting search
|
||||||
function EID:BoCSHandleInput()
|
function EID:BoCSHandleInput()
|
||||||
if Game():IsPaused() then
|
if Game():IsPaused() then
|
||||||
@@ -70,64 +174,7 @@ function EID:BoCSHandleInput()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if searchInputEnabled then
|
handleSearchInput()
|
||||||
local newValue = searchValue
|
|
||||||
local index = 0
|
|
||||||
local hasLetterInput = false
|
|
||||||
|
|
||||||
-- Keep in mind that this only works because the respective
|
|
||||||
-- enum values are integers
|
|
||||||
for i=Keyboard.KEY_SPACE,Keyboard.KEY_Z do
|
|
||||||
index = index + 1
|
|
||||||
if Input.IsButtonTriggered(i, EID.bagPlayer.ControllerIndex, true) then
|
|
||||||
local toAppend = string.upper(indexCharMapping:sub(index, index))
|
|
||||||
|
|
||||||
newValue = newValue .. toAppend
|
|
||||||
hasLetterInput = true
|
|
||||||
|
|
||||||
-- We only handle one input at a time
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
if hasLetterInput then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if Input.IsButtonTriggered(Keyboard.KEY_BACKSPACE, EID.bagPlayer.ControllerIndex, true) then
|
|
||||||
lastBackspaceTrigger = 0
|
|
||||||
backspaceStep = 0
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local currentFrame = Game():GetFrameCount()
|
|
||||||
-- 30 Frames = 1 second
|
|
||||||
-- 15 = 500ms
|
|
||||||
if Input.IsButtonPressed(Keyboard.KEY_BACKSPACE, EID.bagPlayer.ControllerIndex, true) and (
|
|
||||||
backspaceStep == 0
|
|
||||||
or
|
|
||||||
(backspaceStep == 1 and currentFrame - lastBackspaceTrigger > 15) -- we delay the second deletion a little bit more
|
|
||||||
or
|
|
||||||
(backspaceStep >= 2 and currentFrame - lastBackspaceTrigger > 3)
|
|
||||||
) then
|
|
||||||
local isControlPressed = (
|
|
||||||
Input.IsButtonPressed(Keyboard.KEY_LEFT_CONTROL, EID.bagPlayer.ControllerIndex, true)
|
|
||||||
or
|
|
||||||
Input.IsButtonPressed(Keyboard.KEY_RIGHT_CONTROL, EID.bagPlayer.ControllerIndex, true)
|
|
||||||
)
|
|
||||||
|
|
||||||
if isControlPressed then
|
|
||||||
newValue = ""
|
|
||||||
else
|
|
||||||
newValue = searchValue:sub(1, -2)
|
|
||||||
end
|
|
||||||
|
|
||||||
lastBackspaceTrigger = currentFrame
|
|
||||||
backspaceStep = backspaceStep + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
searchValue = newValue
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the line that should be displayed inside of the menu
|
--- Returns the line that should be displayed inside of the menu
|
||||||
@@ -142,7 +189,13 @@ function EID:BoCSGetSearchLine()
|
|||||||
result = "{{ColorGreen}}"
|
result = "{{ColorGreen}}"
|
||||||
end
|
end
|
||||||
|
|
||||||
result = result .. "Search: " .. searchValue .. "#"
|
result = result .. "Search: " .. searchValue
|
||||||
|
|
||||||
|
if EID.BoCSLockMode == 0 and EID:BoCSGetLocked() then
|
||||||
|
result = result .. "{{Trinket159}}"
|
||||||
|
end
|
||||||
|
|
||||||
|
result = result .. "#"
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
@@ -294,11 +347,15 @@ end
|
|||||||
--- Resets the search query when entering a new level
|
--- Resets the search query when entering a new level
|
||||||
function EID:BoCSOnNewLevel()
|
function EID:BoCSOnNewLevel()
|
||||||
EID:BoCSSetSearchValue("")
|
EID:BoCSSetSearchValue("")
|
||||||
|
EID:BoCSSetLocked(false)
|
||||||
|
EID:BoCSSetSearchInputEnabled(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Resets the search query when starting and continuing a game
|
--- Resets the search query when starting and continuing a game
|
||||||
function EID:BoCSPostGameStarted()
|
function EID:BoCSPostGameStarted()
|
||||||
EID:BoCSSetSearchValue("")
|
EID:BoCSSetSearchValue("")
|
||||||
|
EID:BoCSSetLocked(false)
|
||||||
|
EID:BoCSSetSearchInputEnabled(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
EID:BoCSHookInput()
|
EID:BoCSHookInput()
|
||||||
|
|||||||
Reference in new issue
Block a user