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 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
+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 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,22 +89,18 @@ function EID:BoCSCheckItemName(itemName)
return string.find(string.lower(itemName), string.lower(searchValue)) return string.find(string.lower(itemName), string.lower(searchValue))
end end
--- Handles any input done related to Bag of Crafting search local function handleSearchInput()
function EID:BoCSHandleInput() if (
if Game():IsPaused() then not searchInputEnabled
or (
EID.BoCSLockMode == 0
and
EID:BoCSGetLocked()
)
) then
return return
end 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 newValue = searchValue
local index = 0 local index = 0
local hasLetterInput = false local hasLetterInput = false
@@ -127,7 +157,24 @@ function EID:BoCSHandleInput()
end end
searchValue = newValue searchValue = newValue
end
--- Handles any input done related to Bag of Crafting search
function EID:BoCSHandleInput()
if Game():IsPaused() then
return
end 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 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()