ItemReminder: Added player selection feature and description entry limit
This commit is contained in:
1 parent
96cd905a10
commit
de7668bcba
6 files changed
+114
-52
No files matched your search
+85
-50
@@ -3,10 +3,13 @@ local GLITCH_ITEM_FLAG = 4294967296
|
||||
local currentBlacklist
|
||||
local lastInputTime = 0
|
||||
local lastScrollDirection = 1 -- used for automatic scroll feature, if no description is visible for a category
|
||||
local lastAutoScrollPosition = -1 -- Stores last category before the automatic category skip. This prevents infinite loops, when the player has no items
|
||||
local numAvailableDescriptionSlots = 0
|
||||
|
||||
EID.ItemReminderBlacklist = { ["5.100.714"] = true, ["5.100.715"] = true } -- Dont display these in the Item reminder view
|
||||
EID.ItemReminderTempDescriptions = {} -- Temporary stores descriptions that will be displayed after everythng got evaluated
|
||||
EID.ItemReminderSelectedCategory = 0 -- Currently selected category
|
||||
EID.ItemReminderSelectedPlayer = 0 -- Currently selected player
|
||||
EID.InsideItemReminder = false -- Disable some modifiers, when building the Item Reminder description
|
||||
|
||||
-- TODO:
|
||||
@@ -251,8 +254,16 @@ EID.ItemReminderDescriptionModifier = {
|
||||
|
||||
|
||||
-- Simple function to help with adding properly formatted sections to the reminder description
|
||||
-- returns false, when no further descriptions should be added
|
||||
function EID:ItemReminderAddTempDescriptionEntry(icon, title, newDesc)
|
||||
table.insert(EID.ItemReminderTempDescriptions, { icon or "{{Blank}}", title, newDesc })
|
||||
numAvailableDescriptionSlots = numAvailableDescriptionSlots - 1
|
||||
return EID:ItemReminderCanAddMoreToView()
|
||||
end
|
||||
|
||||
-- returns true, if its possible for the currently evaluated view to have more descriptions added to it
|
||||
function EID:ItemReminderCanAddMoreToView()
|
||||
return numAvailableDescriptionSlots > 0
|
||||
end
|
||||
|
||||
-- Adds a formatted "Result" text to the item name
|
||||
@@ -269,7 +280,7 @@ end
|
||||
-- Add item description for a given entity to the reminder. Also tries to apply special modifiers if present
|
||||
function EID:ItemReminderAddDescription(player, entityType, variant, subType, extraIcon)
|
||||
local objectID = entityType .. "." .. variant .. "." .. subType
|
||||
if currentBlacklist[objectID] then return end
|
||||
if currentBlacklist[objectID] then return true end
|
||||
|
||||
local descObj = EID:getDescriptionObj(entityType, variant, subType)
|
||||
|
||||
@@ -285,21 +296,18 @@ function EID:ItemReminderAddDescription(player, entityType, variant, subType, ex
|
||||
|
||||
currentBlacklist[objectID] = true
|
||||
local iconString = extraIcon or EID:GetIconStringByDescriptionObject(descObj)
|
||||
EID:ItemReminderAddTempDescriptionEntry(iconString, descObj.Name, descObj.Description)
|
||||
return EID:ItemReminderAddTempDescriptionEntry(iconString, descObj.Name, descObj.Description)
|
||||
end
|
||||
|
||||
-- Recently Acquired Item Descriptions
|
||||
function EID:ItemReminderHandleRecentItems(player)
|
||||
if EID.Config["ItemReminderShowRecentItem"] > 0 then
|
||||
local printedItems = 0
|
||||
local playerNum = EID:getPlayerID(player)
|
||||
if EID.RecentlyTouchedItems[playerNum] then
|
||||
for i = #EID.RecentlyTouchedItems[playerNum], 1, -1 do
|
||||
if printedItems >= EID.Config["ItemReminderShowRecentItem"] then break end
|
||||
printedItems = printedItems + 1
|
||||
local recentID = EID.RecentlyTouchedItems[playerNum][i] % GLITCH_ITEM_FLAG
|
||||
EID:ItemReminderAddDescription(player, 5, 100, recentID)
|
||||
end
|
||||
local playerNum = EID:getPlayerID(player)
|
||||
if EID.RecentlyTouchedItems[playerNum] then
|
||||
for i = #EID.RecentlyTouchedItems[playerNum], 1, -1 do
|
||||
if not EID:ItemReminderCanAddMoreToView() then return end
|
||||
|
||||
local recentID = EID.RecentlyTouchedItems[playerNum][i] % GLITCH_ITEM_FLAG
|
||||
EID:ItemReminderAddDescription(player, 5, 100, recentID)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -307,7 +315,8 @@ end
|
||||
-- Active Item Descriptions
|
||||
function EID:ItemReminderHandleActiveItems(player)
|
||||
-- limit number of active item descriptions to 2, since Slot 3 and 4 are handled seperately
|
||||
for i = 0, math.min(EID.Config["ItemReminderShowActiveDesc"], 2) - 1 do
|
||||
for i = 0, 1 do
|
||||
if not EID:ItemReminderCanAddMoreToView() then return end
|
||||
-- the modulo is to convert negative IDs (glitched items) to positive IDs
|
||||
local heldActive = player:GetActiveItem(i) % GLITCH_ITEM_FLAG
|
||||
if heldActive > 0 then
|
||||
@@ -318,8 +327,7 @@ end
|
||||
|
||||
-- pocket active
|
||||
function EID:ItemReminderHandlePocketActive(player)
|
||||
if not EID.isRepentance then return end
|
||||
|
||||
if not EID.isRepentance or not EID:ItemReminderCanAddMoreToView() then return end
|
||||
local pocketActive = player:GetActiveItem(2) or 0
|
||||
if pocketActive > 0 then
|
||||
EID:ItemReminderAddDescription(player, 5, 100, pocketActive)
|
||||
@@ -328,7 +336,7 @@ end
|
||||
|
||||
-- dice bag
|
||||
function EID:ItemReminderHandleDiceBag(player)
|
||||
if not EID.isRepentance then return end
|
||||
if not EID.isRepentance or not EID:ItemReminderCanAddMoreToView() then return end
|
||||
|
||||
local diceBag = player:GetActiveItem(3) or 0
|
||||
if diceBag > 0 then
|
||||
@@ -338,7 +346,8 @@ end
|
||||
|
||||
-- Pocket Item Descriptions
|
||||
function EID:ItemReminderHandlePocketItems(player)
|
||||
for i = 0, EID.Config["ItemReminderShowPocketDesc"] - 1 do
|
||||
for i = 0, 2 do
|
||||
if not EID:ItemReminderCanAddMoreToView() then return end
|
||||
local heldCard = player:GetCard(i)
|
||||
local heldPill = player:GetPill(i)
|
||||
if heldCard > 0 then
|
||||
@@ -358,7 +367,8 @@ end
|
||||
|
||||
-- Trinket Descriptions
|
||||
function EID:ItemReminderHandleTrinkets(player)
|
||||
for t = 0, EID.Config["ItemReminderShowTrinketDesc"] - 1 do
|
||||
for t = 0, 1 do
|
||||
if not EID:ItemReminderCanAddMoreToView() then return end
|
||||
-- account for Golden Trinket IDs
|
||||
local heldTrinketTrue = player:GetTrinket(t)
|
||||
local heldTrinket = heldTrinketTrue
|
||||
@@ -372,16 +382,16 @@ end
|
||||
-- Gulped/unslotted Modeling Clay
|
||||
-- (Hidden information, because Modeling Clay does not visually show its item when gulped)
|
||||
function EID:ItemReminderHandleGulpedModelingClay(player)
|
||||
if EID.isRepentance and EID.Config["ItemReminderShowHiddenInfo"] and player:GetModelingClayEffect() > 0 then
|
||||
if EID.isRepentance and EID.Config["ItemReminderShowHiddenInfo"] and player:GetModelingClayEffect() > 0 and EID:ItemReminderCanAddMoreToView() then
|
||||
EID:ItemReminderAddDescription(player, 5, 350, 166)
|
||||
end
|
||||
end
|
||||
|
||||
-- Tainted ??? Poop Descriptions
|
||||
function EID:ItemReminderHandlePoopSpells(player)
|
||||
if EID.isRepentance and EID.Config["ItemReminderShowPoopDesc"] > 0 and player:GetPlayerType() == 25 then
|
||||
if EID.isRepentance and player:GetPlayerType() == 25 and EID:ItemReminderCanAddMoreToView() then
|
||||
local poopInfo = EID:getDescriptionEntry("poopSpells")
|
||||
for i = 0, EID.Config["ItemReminderShowPoopDesc"] - 1 do
|
||||
for i = 0, 3 do
|
||||
local nextPoop = player:GetPoopSpell(i)
|
||||
EID:ItemReminderAddTempDescriptionEntry("{{PoopSpell" .. nextPoop .. "}}", poopInfo[nextPoop][1],
|
||||
poopInfo[nextPoop][2])
|
||||
@@ -410,6 +420,16 @@ function EID:ItemReminderHandleInputs()
|
||||
EID.ForceRefreshCache = true
|
||||
lastInputTime = Isaac.GetTime()
|
||||
lastScrollDirection = 1
|
||||
elseif Input.IsActionTriggered(EID.Config["ItemReminderNavigateDownButton"], EID.holdTabPlayer.ControllerIndex) and Isaac.GetTime() - lastInputTime > 50 then
|
||||
EID.ItemReminderSelectedPlayer = (EID.ItemReminderSelectedPlayer - 1) % #EID.coopAllPlayers
|
||||
|
||||
EID.ForceRefreshCache = true
|
||||
lastInputTime = Isaac.GetTime()
|
||||
elseif Input.IsActionTriggered(EID.Config["ItemReminderNavigateUpButton"], EID.holdTabPlayer.ControllerIndex) and Isaac.GetTime() - lastInputTime > 50 then
|
||||
EID.ItemReminderSelectedPlayer = (EID.ItemReminderSelectedPlayer + 1) % #EID.coopAllPlayers
|
||||
|
||||
EID.ForceRefreshCache = true
|
||||
lastInputTime = Isaac.GetTime()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -421,68 +441,83 @@ function EID:ItemReminderGetTitle()
|
||||
local translatedTitleEnglish = EID:getDescriptionEntryEnglish("ItemReminder", "CategoryNames")
|
||||
local title = translatedTitle and translatedTitle[category.id] or
|
||||
translatedTitleEnglish and translatedTitleEnglish[category.id] or category.id
|
||||
return "{{ButtonDLeft}}{{ColorText}} " .. title .. " {{CR}}{{ButtonDRight}}"
|
||||
|
||||
local combinedText = EID.ButtonToIconMap[EID.Config["ItemReminderNavigateLeftButton"]] ..
|
||||
"{{ColorText}} " .. title .. " {{CR}}" .. EID.ButtonToIconMap[EID.Config["ItemReminderNavigateRightButton"]]
|
||||
|
||||
-- add player toggle when more than 1 player is present
|
||||
if #EID.coopAllPlayers > 1 then
|
||||
local currentPlayer = EID.coopAllPlayers[EID.ItemReminderSelectedPlayer + 1]
|
||||
local playerIcon = EID:GetPlayerIcon(currentPlayer:GetPlayerType())
|
||||
combinedText = EID.ButtonToIconMap[EID.Config["ItemReminderNavigateDownButton"]] .. " " ..
|
||||
playerIcon .. " " .. EID.ButtonToIconMap[EID.Config["ItemReminderNavigateUpButton"]] .. " " .. combinedText
|
||||
end
|
||||
|
||||
return combinedText
|
||||
end
|
||||
|
||||
function EID:ItemReminderGetDescription(player, checkingTwin)
|
||||
function EID:ItemReminderGetDescription()
|
||||
EID.InsideItemReminder = true
|
||||
EID.ItemReminderTempDescriptions = {}
|
||||
-- empty blacklist and fill with default values
|
||||
currentBlacklist = {}
|
||||
for key, _ in pairs(EID.ItemReminderBlacklist) do currentBlacklist[key] = true end
|
||||
|
||||
local player = EID.coopMainPlayers[EID.ItemReminderSelectedPlayer + 1]
|
||||
|
||||
if EID.Config["ItemReminderShowOverview"] and EID.ItemReminderSelectedCategory == 0 then
|
||||
-- execute all functions defined per category
|
||||
for _, category in ipairs(EID.ItemReminderCategories) do
|
||||
numAvailableDescriptionSlots = 1 -- limit to one description per category in overview mode
|
||||
for _, func in ipairs(category.entryGenerators) do
|
||||
func(player)
|
||||
end
|
||||
end
|
||||
else
|
||||
local category = EID.ItemReminderCategories[EID.ItemReminderSelectedCategory + 1]
|
||||
numAvailableDescriptionSlots = EID.Config["ItemReminderMaxEntriesCount"]
|
||||
for _, func in ipairs(category.entryGenerators) do
|
||||
func(player)
|
||||
end
|
||||
end
|
||||
|
||||
-- Skip category if nothing is in it
|
||||
if #EID.ItemReminderTempDescriptions == 0 and EID.ItemReminderSelectedCategory <= #EID.ItemReminderCategories then
|
||||
if #EID.ItemReminderTempDescriptions == 0 then
|
||||
if lastAutoScrollPosition == -1 then
|
||||
-- auto scroll was started. store last valid category. skip overview if its disabled
|
||||
if not EID.Config["ItemReminderShowOverview"] and EID.ItemReminderSelectedCategory == 0 then
|
||||
lastAutoScrollPosition = lastScrollDirection % #EID.ItemReminderCategories
|
||||
else
|
||||
lastAutoScrollPosition = EID.ItemReminderSelectedCategory
|
||||
end
|
||||
end
|
||||
|
||||
EID.ItemReminderSelectedCategory = (EID.ItemReminderSelectedCategory + lastScrollDirection) %
|
||||
#EID.ItemReminderCategories
|
||||
if not EID.Config["ItemReminderShowOverview"] and EID.ItemReminderSelectedCategory == 0 then
|
||||
EID.ItemReminderSelectedCategory = lastScrollDirection % #EID.ItemReminderCategories
|
||||
EID.ItemReminderSelectedCategory = #EID.ItemReminderCategories
|
||||
end
|
||||
return EID:ItemReminderGetDescription(player, checkingTwin)
|
||||
|
||||
if lastAutoScrollPosition ~= EID.ItemReminderSelectedCategory then
|
||||
-- new category found. try to display text
|
||||
local newCategoryText = EID:ItemReminderGetDescription()
|
||||
if newCategoryText ~= "" then
|
||||
return newCategoryText
|
||||
end
|
||||
end
|
||||
-- auto scroll was stopped. reset scroll value
|
||||
lastAutoScrollPosition = -1
|
||||
|
||||
return "{{Blank}}#{{Blank}} " .. EID:getDescriptionEntry("ItemReminder", "InventoryEmpty")
|
||||
end
|
||||
lastAutoScrollPosition = -1
|
||||
|
||||
-- put descriptions into one long description
|
||||
local finalHoldMapDesc = ""
|
||||
for _, entry in ipairs(EID.ItemReminderTempDescriptions) do
|
||||
finalHoldMapDesc = finalHoldMapDesc .. entry[1] .. " {{ColorEIDObjName}}" .. entry[2] .. "#" .. entry[3] .. "#"
|
||||
end
|
||||
|
||||
-- Finally, check the twin player of this controller
|
||||
-- If both twins have a desc, show their player icon / name to separate the two descs
|
||||
if EID.isRepentance and not checkingTwin then
|
||||
local twin = player:GetOtherTwin()
|
||||
local mainTwinDesc = finalHoldMapDesc
|
||||
local otherTwinDesc = ""
|
||||
if twin then otherTwinDesc = EID:ItemReminderGetDescription(twin, true) end
|
||||
if otherTwinDesc ~= "" then
|
||||
-- Only the other twin had a desc
|
||||
if mainTwinDesc == "" then
|
||||
finalHoldMapDesc = otherTwinDesc
|
||||
else
|
||||
-- Both twins had a desc; merge them with player icon headers
|
||||
finalHoldMapDesc = (EID:getIcon("Player" .. player:GetPlayerType()) ~= EID.InlineIcons["ERROR"] and "{{Player" .. player:GetPlayerType() .. "}}" or "{{CustomTransformation}}") ..
|
||||
" {{ColorGray}}" .. player:GetName() .. "#" .. mainTwinDesc .. "#"
|
||||
finalHoldMapDesc = finalHoldMapDesc ..
|
||||
(EID:getIcon("Player" .. twin:GetPlayerType()) ~= EID.InlineIcons["ERROR"] and "{{Player" .. twin:GetPlayerType() .. "}}" or "{{CustomTransformation}}") ..
|
||||
" {{ColorGray}}" .. twin:GetName() .. "#" .. otherTwinDesc
|
||||
end
|
||||
else
|
||||
-- Only the main twin had a desc
|
||||
finalHoldMapDesc = mainTwinDesc
|
||||
end
|
||||
end
|
||||
finalHoldMapDesc = "{{Blank}}#" .. finalHoldMapDesc
|
||||
|
||||
EID.InsideItemReminder = false
|
||||
|
||||
Reference in new issue
Block a user