Fixed custom transformation icons

This commit is contained in:
Wofsauge committed 2020-11-01 03:44:47 +01:00
1 parent 250385e0e9
commit b1447e1636
3 files changed
+30 -15

No files matched your search

+14 -2
View File
@@ -135,7 +135,7 @@ function EID:getDescriptionObj(objTable, objID)
local legacyModdedTransformation = nil
if objTable == "collectibles" then
legacyModdedTransformation = EID:getLegacyModDescription("transformation", objID)
legacyModdedTransformation = EID:getLegacyModDescription("transformations", objID)
end
description.Transformation = legacyModdedTransformation or tableEntry[2] or "0"
@@ -146,7 +146,6 @@ end
function EID:getTransformationName(id)
local str = "Custom"
if tonumber(id) == nil then
print("FAIL")
return id
end
return EID:getObjectName(tonumber(id) + 1, "transformations") or str
@@ -238,6 +237,19 @@ function EID:getIcon(str)
end
end
-- Returns the icon for a given transformation name or ID
function EID:getTransformationIcon(str)
if str == nil then return EID.InlineIcons["ERROR"] end
if tonumber(str) ~= nil then
str = EID.descriptions["en_us"].transformations[tonumber(str+1)]
end
local transformSprite = EID:getIcon(str:gsub(" ", ""))
if transformSprite[1] == "ERROR" then
transformSprite = EID:getIcon("CustomTransformation")
end
return transformSprite
end
-- Returns the width of a given string in Pixels
function EID:getStrWidth(str)
return EID.font:GetStringWidthUTF8(str)
+10 -6
View File
@@ -22,25 +22,29 @@ local charsToDebug = {
"End of line",
}
-- Legacy Overriding descriptions
------ Legacy Overriding descriptions ------
__eidItemDescriptions[1] = "\1 Overriden description" -- 5.100.1 = Sad Onion
__eidTrinketDescriptions[1] = "\2 Overriden " -- 5.350.1 = swallowed penny
__eidCardDescriptions[1] = "Overriden Card description" -- 5.300.1 = the fool
__eidPillDescriptions[21] = "Test" -- Pill Effect 20 = Hematemesis
__eidItemTransformations[1] = "Test Transformation" -- add custom transformation Text to Sad Onion
--__eidItemTransformations[2] = "1,2,3,4,5,6,7,8,9,10,11,12,13" -- add all transformations to inner eye
-- Legacy add Description to entity
------ Legacy add Description to entity ------
__eidEntityDescriptions["5.10.1"] = {"Entity Name","Entity description"} -- Adds description to full red hearts
-- test adding custom icons
------ Test: adding custom icons ------
local dummySprite = Sprite()
dummySprite:Load("gfx/eid_inline_icons.anm2", true)
EID.InlineIcons["Test"] = {"hearts", 0, 9, 9, -1, 0, dummySprite}
__eidItemDescriptions[2] = "{{Bomb}} Emote {{Key}} Test {{Test}} description {{SomeInvalidInnerStuff}} cool" -- 5.100.2 = Inner Eye
-- test adding custom transformation icon
__eidItemTransformations[2] = "Test"
------ Test: adding custom transformation icon ------
EID.InlineIcons["SomeTestTransformation"] = {"hearts", 2, 9, 9, -1, 0, dummySprite}
-- the Transformation icon will try to get an icon with the same name as the transformation, but without any spaces. Default Icon otherwise
__eidItemTransformations[2] = "Some Test Transformation"
------ Test: Add all transformations to spoon bender ------
__eidItemTransformations[3] = "1,2,3,4,5,6,7,8,9,10,11,12,13"
local function onDebugRender(t)
for i, v in ipairs(charsToDebug) do
+6 -7
View File
@@ -141,14 +141,12 @@ function printDescription(desc)
if not (desc.Transformation == "0" or desc.Transformation == "" or desc.Transformation == nil) then
for transform in string.gmatch(desc.Transformation, "([^,]+)") do
local transformationName = EID:getTransformationName(transform)
local transformLineHeight = lineHeight
local defaultName = EID.descriptions["en_us"].transformations[tonumber(transform+1)]
local transformSprite = EID:getIcon(defaultName:gsub(" ", ""))
if transformSprite[1] == "ERROR" then
transformSprite = EID:getIcon("CustomTransformation")
end
local transformSprite = EID:getTransformationIcon(transform)
local iconWidth = transformSprite[3] or -1
local iconHeight = transformSprite[4] or -1
local iconOffsetX = transformSprite[5] or -1
local iconOffsetY = transformSprite[6] or -1
local transformLineHeight = lineHeight
if EIDConfig["TransformationIcons"] then
transformLineHeight = math.max(lineHeight, transformSprite[4])
local iconSprite = transformSprite[7] or EID.InlineIconSprite
@@ -161,9 +159,10 @@ function printDescription(desc)
)
end
if EIDConfig["TransformationText"] then
local textOffsetY = math.min(0,(iconHeight-9))/4
EID:renderString(
transformationName,
Vector(EIDConfig["XPosition"] + 17, padding - 1),
Vector(EIDConfig["XPosition"] + iconWidth + 4, padding + textOffsetY),
Vector(EIDConfig["Scale"], EIDConfig["Scale"]),
EID:getTransformationColor()
)