ItemReminder: Added custom scrollbar support
This commit is contained in:
1 parent
13c25fc8de
commit
038d50ae68
1 file changed
+70
-32
+70
-32
@@ -20,21 +20,30 @@ EID.InsideItemReminder = false -- Disable some modifiers, when building the Item
|
|||||||
|
|
||||||
-- Data Tables --
|
-- Data Tables --
|
||||||
|
|
||||||
-- Format : Table of { id = "Category Name", entryGenerators = table of functions to generate descriptions }
|
-- Format : Table of { id = "Category Name", entryGenerators = table of functions to generate descriptions, isScrollable = only shows one entry at a time but is scrollable }
|
||||||
-- Execution order is handles by the order of the table entries.
|
-- Execution order is handles by the order of the table entries.
|
||||||
-- Category name is interpreted as a lookup for the "EID.descriptions.ItemReminder.CategoryNames" table. If no translation is found, use english or the lookup value
|
-- Category name is interpreted as a lookup for the "EID.descriptions.ItemReminder.CategoryNames" table. If no translation is found, use english or the lookup value
|
||||||
EID.ItemReminderCategories = {
|
EID.ItemReminderCategories = {
|
||||||
{ id = "Overview", entryGenerators = {} }, -- special handling for Overview category
|
{ id = "Overview", entryGenerators = {} }, -- special handling for Overview category
|
||||||
{ id = "Special", entryGenerators = { function(player) EID:ItemReminderHandlePoopSpells(player) end, } },
|
{ id = "Special", entryGenerators = { function(player) EID:ItemReminderHandlePoopSpells(player) end, } },
|
||||||
{ id = "Actives", entryGenerators = { function(player) EID:ItemReminderHandleActiveItems(player) end, } },
|
{ id = "Actives", entryGenerators = { function(player) EID:ItemReminderHandleActiveItems(player) end, } },
|
||||||
{ id = "Pockets", entryGenerators = {
|
{
|
||||||
|
id = "Pockets",
|
||||||
|
entryGenerators = {
|
||||||
function(player) EID:ItemReminderHandleDiceBag(player) end,
|
function(player) EID:ItemReminderHandleDiceBag(player) end,
|
||||||
function(player) EID:ItemReminderHandlePocketActive(player) end,
|
function(player) EID:ItemReminderHandlePocketActive(player) end,
|
||||||
function(player) EID:ItemReminderHandlePocketItems(player) end } },
|
function(player) EID:ItemReminderHandlePocketItems(player) end }
|
||||||
{ id = "Trinkets", entryGenerators = {
|
},
|
||||||
|
{
|
||||||
|
id = "Trinkets",
|
||||||
|
entryGenerators = {
|
||||||
function(player) EID:ItemReminderHandleTrinkets(player) end,
|
function(player) EID:ItemReminderHandleTrinkets(player) end,
|
||||||
function(player) EID:ItemReminderHandleGulpedModelingClay(player) end } },
|
function(player) EID:ItemReminderHandleGulpedModelingClay(player) end }
|
||||||
{ id = "Passives", entryGenerators = {
|
},
|
||||||
|
{
|
||||||
|
id = "Passives",
|
||||||
|
isScrollable = true,
|
||||||
|
entryGenerators = {
|
||||||
function(player) -- Passive item: Zodiac
|
function(player) -- Passive item: Zodiac
|
||||||
if EID.isRepentance and player:HasCollectible(392) and not EID:IsCategorySelected("Passives") then
|
if EID.isRepentance and player:HasCollectible(392) and not EID:IsCategorySelected("Passives") then
|
||||||
EID:ItemReminderAddDescription(player, 5, 100, 392)
|
EID:ItemReminderAddDescription(player, 5, 100, 392)
|
||||||
@@ -45,9 +54,15 @@ EID.ItemReminderCategories = {
|
|||||||
EID:ItemReminderAddDescription(player, 5, 100, 700)
|
EID:ItemReminderAddDescription(player, 5, 100, 700)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
function(player) EID:ItemReminderHandleSelectedPassiveItem(player) end } },
|
function(player) EID:ItemReminderHandleSelectedPassiveItem(player) end },
|
||||||
|
scrollbarGenerator = function(player)
|
||||||
|
local playerNum = EID:getPlayerID(player)
|
||||||
|
local numPassives = EID.RecentlyTouchedItems[playerNum] and #EID.RecentlyTouchedItems[playerNum] or 0
|
||||||
|
if numPassives < 2 then return nil end -- dont display scrollbar if less than 2 items are in the table
|
||||||
|
return EID:ItemReminderHandleItemScrollbarFeature(EID.RecentlyTouchedItems[playerNum], 100, true)
|
||||||
|
end
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Format: ItemID = table
|
-- Format: ItemID = table
|
||||||
-- modifierFunction = function that modifies the original description object of the item
|
-- modifierFunction = function that modifies the original description object of the item
|
||||||
-- isCheat = Only evaluate, if the "ItemReminderShowRNGCheats" config option is enabled
|
-- isCheat = Only evaluate, if the "ItemReminderShowRNGCheats" config option is enabled
|
||||||
@@ -508,6 +523,48 @@ function EID:ItemReminderTrimBulletPoints(description)
|
|||||||
return trimmedDescription
|
return trimmedDescription
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- takes a list of item ids and an item variant to automatically generate a scrollable list of item icons.
|
||||||
|
function EID:ItemReminderHandleItemScrollbarFeature(entryTable, itemVariant, descending)
|
||||||
|
-- handle Scrollable passives list
|
||||||
|
local newDescription = "{{Blank}} " .. EID.ButtonToIconMap[EID.Config["ItemReminderNavigateUpButton"]]
|
||||||
|
|
||||||
|
EID.ItemReminderSelectedItem = EID.ItemReminderSelectedItem % #entryTable -- clamp selection
|
||||||
|
|
||||||
|
-- render icons
|
||||||
|
if descending then
|
||||||
|
local startIndex = #entryTable - EID.ItemReminderSelectedItem -- start from end of list
|
||||||
|
local stopIndex = startIndex - 3
|
||||||
|
|
||||||
|
for i = startIndex, stopIndex, -1 do
|
||||||
|
local index = ((i - 1) % #entryTable) + 1
|
||||||
|
local recentID = entryTable[index] % GLITCH_ITEM_FLAG
|
||||||
|
|
||||||
|
if i < 1 and index == startIndex then
|
||||||
|
-- prevent display of copies of the same icon, when less than 4 items were collected
|
||||||
|
break
|
||||||
|
end
|
||||||
|
newDescription = newDescription .. "{{" .. EID:GetIconNameByVariant(itemVariant) .. recentID .. "}} "
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local startIndex = EID.ItemReminderSelectedItem -- start from end of list
|
||||||
|
local stopIndex = startIndex + 3
|
||||||
|
for i = startIndex, stopIndex do
|
||||||
|
local index = (i % #entryTable) + 1
|
||||||
|
local recentID = entryTable[index] % GLITCH_ITEM_FLAG
|
||||||
|
|
||||||
|
if i >= #entryTable and index == startIndex + 1 then
|
||||||
|
-- prevent display of copies of the same icon, when less than 4 items were collected
|
||||||
|
break
|
||||||
|
end
|
||||||
|
newDescription = newDescription .. "{{" .. EID:GetIconNameByVariant(itemVariant) .. recentID .. "}} "
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- add counter
|
||||||
|
newDescription = newDescription .. "(" .. (EID.ItemReminderSelectedItem + 1) .. "/" .. #entryTable .. ") "
|
||||||
|
|
||||||
|
return newDescription .. EID.ButtonToIconMap[EID.Config["ItemReminderNavigateDownButton"]] .. "#"
|
||||||
|
end
|
||||||
|
|
||||||
function EID:ItemReminderGetDescription()
|
function EID:ItemReminderGetDescription()
|
||||||
EID.InsideItemReminder = true
|
EID.InsideItemReminder = true
|
||||||
EID.ItemReminderTempDescriptions = {}
|
EID.ItemReminderTempDescriptions = {}
|
||||||
@@ -566,31 +623,12 @@ function EID:ItemReminderGetDescription()
|
|||||||
|
|
||||||
local finalHoldMapDesc = "{{Blank}}#"
|
local finalHoldMapDesc = "{{Blank}}#"
|
||||||
|
|
||||||
local playerNum = EID:getPlayerID(player)
|
local category = EID.ItemReminderCategories[EID.ItemReminderSelectedCategory + 1]
|
||||||
local numPassives = EID.RecentlyTouchedItems[playerNum] and #EID.RecentlyTouchedItems[playerNum] or 0
|
if EID:IsScrollableCategorySelected() then
|
||||||
|
local scrollbar = category.scrollbarGenerator(player)
|
||||||
if EID:IsCategorySelected("Passives") and numPassives > 1 then
|
if scrollbar then
|
||||||
-- handle Scrollable passives list
|
finalHoldMapDesc = scrollbar
|
||||||
finalHoldMapDesc = "{{Blank}} " .. EID.ButtonToIconMap[EID.Config["ItemReminderNavigateDownButton"]]
|
|
||||||
|
|
||||||
EID.ItemReminderSelectedItem = EID.ItemReminderSelectedItem % numPassives -- clamp selection
|
|
||||||
-- render icons
|
|
||||||
local startIndex = numPassives - EID.ItemReminderSelectedItem -- start from end of list
|
|
||||||
local stopIndex = startIndex - 3
|
|
||||||
|
|
||||||
for i = startIndex, stopIndex, -1 do
|
|
||||||
local index = ((i - 1) % numPassives) + 1
|
|
||||||
local recentID = EID.RecentlyTouchedItems[playerNum][index] % GLITCH_ITEM_FLAG
|
|
||||||
|
|
||||||
if i < 1 and index == startIndex then
|
|
||||||
-- prevent display of copies of the same icon, when less than 4 passive items were collected
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
finalHoldMapDesc = finalHoldMapDesc .. "{{Collectible" .. recentID .. "}} "
|
|
||||||
end
|
|
||||||
finalHoldMapDesc = finalHoldMapDesc .. "(" .. (EID.ItemReminderSelectedItem + 1) .. "/" .. numPassives .. ") "
|
|
||||||
|
|
||||||
finalHoldMapDesc = finalHoldMapDesc .. EID.ButtonToIconMap[EID.Config["ItemReminderNavigateUpButton"]] .. "#"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Default: put all descriptions into one long description
|
-- Default: put all descriptions into one long description
|
||||||
|
|||||||
Reference in new issue
Block a user