From 0ced81f7e348579203e17097b5b9ab1538ccb614 Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Sat, 25 Jan 2025 00:11:54 +0100 Subject: [PATCH] Improved "Unidentified Pill"-info rendering --- features/eid_api.lua | 5 +++-- main.lua | 30 ++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/features/eid_api.lua b/features/eid_api.lua index 660710eb..03e20103 100644 --- a/features/eid_api.lua +++ b/features/eid_api.lua @@ -1214,13 +1214,14 @@ function EID:filterIconMarkup(text, renderBulletPointIcon) end ---Renders a list of given inline sprite objects returned by the "EID:filterIconMarkup()" function ----@param spriteTable [EID_Icon, integer, fun(spriteObj:Sprite)?][] +---@param spriteTable [EID_Icon, integer?, fun(spriteObj:Sprite)?][] ---@param posX integer ---@param posY integer function EID:renderInlineIcons(spriteTable, posX, posY) for _, sprite in ipairs(spriteTable) do local Xoffset = sprite[1][5] or -1 local Yoffset = sprite[1][6] or 0 + local additionalXOffset = sprite[2] or 0 local spriteObj = (type(sprite[1][7]) == "function" and sprite[1][7]()) or sprite[1][7] or EID.InlineIconSprite if sprite[1][2] >= 0 then spriteObj:SetFrame(sprite[1][1], sprite[1][2]) @@ -1230,7 +1231,7 @@ function EID:renderInlineIcons(spriteTable, posX, posY) spriteObj:Update() end - EID:renderIcon(spriteObj, posX + sprite[2] + Xoffset * EID.Scale, posY + Yoffset * EID.Scale, sprite[3], sprite[1][1], sprite[1][2]) + EID:renderIcon(spriteObj, posX + additionalXOffset + Xoffset * EID.Scale, posY + Yoffset * EID.Scale, sprite[3], sprite[1][1], sprite[1][2]) end end diff --git a/main.lua b/main.lua index 75d79c06..1351dadb 100644 --- a/main.lua +++ b/main.lua @@ -602,7 +602,7 @@ function EID:printDescription(desc, cachedID) EID.lineHeight = EID.Config["LineHeight"] if EID.Config["ShowItemIcon"] and desc.Icon then offsetX = offsetX + 14 - EID:renderInlineIcons({{desc.Icon,0}}, renderPos.X - 3 * EID.Scale, renderPos.Y - 4 * EID.Scale) + EID:renderInlineIcons({{desc.Icon}}, renderPos.X - 3 * EID.Scale, renderPos.Y - 4 * EID.Scale) end --Display ItemType / Charge @@ -683,7 +683,7 @@ function EID:printDescription(desc, cachedID) local transformLineHeight = EID.lineHeight if EID.Config["TransformationIcons"] then transformLineHeight = math.max(EID.lineHeight, transformSprite[4]) - EID:renderInlineIcons({{transformSprite,0}}, renderPos.X, renderPos.Y) + EID:renderInlineIcons({{transformSprite}}, renderPos.X, renderPos.Y) end if EID.Config["TransformationText"] or EID.Config["TransformationProgress"] then local transformationName = "" @@ -832,30 +832,40 @@ function EID:renderUnidentifiedPill(entity) if alwaysUseLocalMode then return false else alwaysUseLocalMode = true end end + EID.isDisplaying = true + local pillColor = entity.SubType if pillColor >= 2049 then pillColor = pillColor - 2048 end - local pos = EID:getTextPosition() + local renderPos = EID:getTextPosition() + local textScale = Vector(EID.Scale, EID.Scale) + local offsetX = 0 if EID.CachingDescription then table.insert(EID.CachedStrings, {}) table.insert(EID.CachedIcons, {}) - table.insert(EID.CachedRenderPoses, Vector(pos.X, pos.Y)) + table.insert(EID.CachedRenderPoses, Vector(renderPos.X, renderPos.Y)) end local descriptionObj = EID:getDescriptionObj(entity.Type, entity.Variant, entity.SubType, entity, false) - descriptionObj.Name = EID:getDescriptionEntry("unidentifiedPill") descriptionObj.Description = "" descriptionObj.ShowWhenUnidentified = false descriptionObj = EID:applyDescriptionModifier(descriptionObj, -999) - if EID.Config["ShowItemIcon"] then - descriptionObj.Name = "{{Pill"..pillColor.."}} "..descriptionObj.Name + if EID.Config["ShowItemIcon"] and descriptionObj.Icon then + offsetX = offsetX + 14 + EID:renderInlineIcons({{descriptionObj.Icon}}, renderPos.X - 3 * EID.Scale, renderPos.Y - 4 * EID.Scale) + EID:renderInlineIcons({{EID.InlineIcons["SecretRoom"]}}, renderPos.X + 1 * EID.Scale, renderPos.Y - 4 * EID.Scale) end - EID:renderString(descriptionObj.Name, pos + Vector(0,-1), Vector(EID.Scale, EID.Scale), EID:getErrorColor()) + EID:renderString( + EID:getDescriptionEntry("unidentifiedPill"), + renderPos + (Vector(offsetX, -3) * EID.Scale), + textScale, + EID:getErrorColor() + ) if EID.Config["ShowItemDescription"] and descriptionObj.ShowWhenUnidentified then - pos.Y = pos.Y + EID.lineHeight * EID.Scale - EID:printBulletPoints(descriptionObj.Description, pos) + renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale + EID:printBulletPoints(descriptionObj.Description, renderPos) end end