Added feature to allow icon backgrounds.

Added VirtuesCollectibleX icons
This commit is contained in:
Wofsauge committed 2025-05-08 22:13:31 +02:00
1 parent 3a6b675280
commit b9f217eae3
3 files changed
+26 -8

No files matched your search

+16 -6
View File
@@ -1169,6 +1169,7 @@ end
---@return EID_Icon?
function EID:createItemIconObject(str)
local item = nil
local backgroundImage = ""
local subTypeIdentifier = 0
-- Check for {{Item#.##.###}} markup; easiest way to handle it is to just call this function again
@@ -1183,7 +1184,16 @@ function EID:createItemIconObject(str)
end
end
end
-- Add background image to Icon, if the keyword can be found in the markup string
for keyword, imagePath in pairs(EID.MarkupBackgroundKeywords) do
if string.find(str, keyword) then
str = string.gsub(str, keyword, "")
backgroundImage = imagePath
break
end
end
---@diagnostic disable
local collID,numReplace = string.gsub(str, "Collectible", "")
if numReplace > 0 and collID ~= "" and tonumber(collID) ~= nil then
@@ -1206,19 +1216,19 @@ function EID:createItemIconObject(str)
return {"Pills", tonumber(pillID % 2048)-1, 9, 8, 0, 1, EID.CardPillSprite}
end
---@diagnostic enable
if item == nil then
return nil
end
if dynamicSpriteCache[str] then
return dynamicSpriteCache[str]
if dynamicSpriteCache[backgroundImage .. str] then
return dynamicSpriteCache[backgroundImage .. str]
else
local spriteDummy = Sprite()
spriteDummy:Load("gfx/eid_inline_icons.anm2", true)
spriteDummy:ReplaceSpritesheet(0, backgroundImage)
spriteDummy:ReplaceSpritesheet(1, item.GfxFileName)
spriteDummy:LoadGraphics()
local newDynamicSprite = {"ItemIcon", subTypeIdentifier, 11, 8, -2, -2, spriteDummy}
dynamicSpriteCache[str] = newDynamicSprite
local newDynamicSprite = { "ItemIcon", subTypeIdentifier, 11, 8, -2, -2, spriteDummy }
dynamicSpriteCache[backgroundImage .. str] = newDynamicSprite
return newDynamicSprite
end
end