BoC: Locking query locking possible via result locking combo

This commit is contained in:
Eric authored and wofsauge committed 2024-05-31 21:42:03 +02:00
1 parent e3c88aad24
commit c493675ab7
2 files changed
+84 -22

No files matched your search

+9 -4
View File
@@ -940,7 +940,7 @@ function EID:handleBagOfCraftingUpdating()
end
-- 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.bagPlayer.ControlsCooldown = 2
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"])
upHeld = Isaac.GetTime()
--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
if (lockedResults == nil) then lockedResults = queryString
else lockedResults = nil end
if (lockedResults == nil) then
lockedResults = queryString
EID:BoCSSetLocked(true)
else
lockedResults = nil
EID:BoCSSetLocked(false)
end
--refresh the recipes
elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTRIGHT, EID.bagPlayer.ControllerIndex) then
if (lockedResults == nil) then
+75 -18
View File
@@ -1,36 +1,70 @@
-- Valid values:
-- 0 -> Reset search query after search
EID.BoCSLockMode = 0
local locked = false
local indexCharMapping = " ??????'????,-./0123456789?;?????abcdefghijklmnopqrstuvwxyz"
local searchValue = ""
local searchInputEnabled = false
local lastBackspaceTrigger = 0
local backspaceStep = 0
--- Returns the current search query
-- @param newValue new search query
function EID:BoCSSetSearchValue(newValue)
if newValue == nil then
newValue = ""
searchValue = ""
return
end
searchValue = newValue
end
--- Returns the current search query
-- @return string
function EID:BoCSGetSearchValue()
return searchValue
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
-- @param newState boolean
function EID:BoCSSetSearchInputEnabled(newState)
searchInputEnabled = newState
function EID:BoCSSetSearchInputEnabled(newState, force)
if EID.BoCSLockMode == 0 and EID:BoCSGetLocked() and force ~= true then
return
end
searchInputEnabled = newState
if newState then
EID:AddCallback(ModCallbacks.MC_INPUT_ACTION, EID.BoCSBlockInputAction)
else
EID:RemoveCallback(ModCallbacks.MC_INPUT_ACTION, EID.BoCSBlockInputAction)
searchInputEnabled = newState
if EID.BoCSLockMode == 0 and not EID:BoCSGetLocked() then
EID:BoCSSetSearchValue("")
end
end
end
@@ -55,22 +89,18 @@ function EID:BoCSCheckItemName(itemName)
return string.find(string.lower(itemName), string.lower(searchValue))
end
--- Handles any input done related to Bag of Crafting search
function EID:BoCSHandleInput()
if Game():IsPaused() then
local function handleSearchInput()
if (
not searchInputEnabled
or (
EID.BoCSLockMode == 0
and
EID:BoCSGetLocked()
)
) then
return
end
if EID.bagPlayer == nil then
return
end
if Input.IsButtonTriggered(Keyboard.KEY_ENTER, EID.bagPlayer.ControllerIndex, true) then
EID:BoCSSetSearchInputEnabled(not searchInputEnabled)
return
end
if searchInputEnabled then
local newValue = searchValue
local index = 0
local hasLetterInput = false
@@ -127,7 +157,24 @@ function EID:BoCSHandleInput()
end
searchValue = newValue
end
--- Handles any input done related to Bag of Crafting search
function EID:BoCSHandleInput()
if Game():IsPaused() then
return
end
if EID.bagPlayer == nil then
return
end
if Input.IsButtonTriggered(Keyboard.KEY_ENTER, EID.bagPlayer.ControllerIndex, true) then
EID:BoCSSetSearchInputEnabled(not searchInputEnabled)
return
end
handleSearchInput()
end
--- Returns the line that should be displayed inside of the menu
@@ -142,7 +189,13 @@ function EID:BoCSGetSearchLine()
result = "{{ColorGreen}}"
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
end
@@ -294,11 +347,15 @@ end
--- Resets the search query when entering a new level
function EID:BoCSOnNewLevel()
EID:BoCSSetSearchValue("")
EID:BoCSSetLocked(false)
EID:BoCSSetSearchInputEnabled(false)
end
--- Resets the search query when starting and continuing a game
function EID:BoCSPostGameStarted()
EID:BoCSSetSearchValue("")
EID:BoCSSetLocked(false)
EID:BoCSSetSearchInputEnabled(false)
end
EID:BoCSHookInput()