From b9f217eae36d2e015b9a7048e50fdde8713b577f Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Thu, 8 May 2025 22:13:31 +0200 Subject: [PATCH] Added feature to allow icon backgrounds. Added VirtuesCollectibleX icons --- features/eid_api.lua | 22 ++++++++++++++++------ features/eid_data.lua | 6 ++++++ resources/gfx/eid_inline_icons.anm2 | 6 ++++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/features/eid_api.lua b/features/eid_api.lua index 1fa48875..18eeb282 100644 --- a/features/eid_api.lua +++ b/features/eid_api.lua @@ -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 diff --git a/features/eid_data.lua b/features/eid_data.lua index 40b9d170..23a3cc5d 100644 --- a/features/eid_data.lua +++ b/features/eid_data.lua @@ -975,6 +975,12 @@ EID.RoomShapeToMarkup = { "{{Room}}", "{{RoomSmallHorizontal}}", "{{RoomSmallVer EID.RoomTypeToMarkup = { "{{Room}}", "{{Shop}}", "{{ErrorRoom}}", "{{TreasureRoom}}", "{{BossRoom}}", "{{MiniBoss}}", "{{SecretRoom}}", "{{SuperSecretRoom}}", "{{ArcadeRoom}}", "{{CursedRoom}}", "{{ChallengeRoom}}", "{{Library}}", "{{SacrificeRoom}}", "{{DevilRoom}}", "{{AngelRoom}}", "{{LadderRoom}}", "{{Room}}" --[[boss rush]], "{{IsaacsRoom}}", "{{BarrenRoom}}", "{{ChestRoom}}", "{{DiceRoom}}", "{{Shop}}", "{{Room}}", --[[Black Market / Greed Exit]] "{{Planetarium}}", "{{Teleporter}}","{{Teleporter}}", "{{Room}}", "{{Room}}" --[[Blue Key rooms]], "{{UltraSecretRoom}}" } EID.ItemPoolTypeToMarkup = { [0] = "{{ItemPoolTreasure}}", "{{ItemPoolShop}}", "{{ItemPoolBoss}}", "{{ItemPoolDevil}}", "{{ItemPoolAngel}}", "{{ItemPoolSecret}}", "{{ItemPoolLibrary}}", "{{ItemPoolShellGame}}", "{{ItemPoolGoldenChest}}", "{{ItemPoolRedChest}}", "{{ItemPoolBeggar}}", "{{ItemPoolDemonBeggar}}", "{{ItemPoolCurse}}", "{{ItemPoolKeyMaster}}", "{{ItemPoolBombBum}}", "{{ItemPoolMomsChest}}", "{{ItemPoolGreedTreasure}}", "{{ItemPoolGreedShop}}", "{{ItemPoolGreedBoss}}", "{{ItemPoolGreedDevil}}", "{{ItemPoolGreedAngel}}", "{{ItemPoolGreedCurse}}", "{{ItemPoolGreedSecret}}", "{{ItemPoolCraneGame}}", "{{ItemPoolUltraSecret}}", "{{ItemPoolBatteryBum}}", "{{ItemPoolPlanetarium}}", "{{ItemPoolOldChest}}", "{{ItemPoolBabyShop}}", "{{ItemPoolWoodenChest}}", "{{ItemPoolRottenBeggar}}"} +-- Background icon markup substrings +EID.MarkupBackgroundKeywords = { + ["Virtues"] = "gfx/ui/hud_bookofvirtues.png", +} + + -- additional offset of the textbox to the entity position. Only applies in local description mode. -- If a function returns a value, it will be used as the offset EID.LocalModePositionOffset = { diff --git a/resources/gfx/eid_inline_icons.anm2 b/resources/gfx/eid_inline_icons.anm2 index 40f42f75..555148d5 100644 --- a/resources/gfx/eid_inline_icons.anm2 +++ b/resources/gfx/eid_inline_icons.anm2 @@ -1,5 +1,5 @@ - + @@ -276,7 +276,9 @@ - + + +