Formatted api and main file
This commit is contained in:
1 parent
2a6d330e2c
commit
bfa6addf65
3 files changed
+156
-102
No files matched your search
+119
-55
@@ -68,18 +68,66 @@ EID.TRANSFORMATION = {
|
|||||||
|
|
||||||
-- List of item Types
|
-- List of item Types
|
||||||
EID.ItemTypeAnm2Names = {
|
EID.ItemTypeAnm2Names = {
|
||||||
"null", -- 1
|
"null", -- 1
|
||||||
"passive", -- 2
|
"passive", -- 2
|
||||||
"active", -- 3
|
"active", -- 3
|
||||||
"familiar", -- 4
|
"familiar", -- 4
|
||||||
"trinket" -- 5
|
"trinket" -- 5
|
||||||
}
|
}
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
-------------------------Handle API Functions -----------------------------
|
-------------------------Handle API Functions -----------------------------
|
||||||
|
|
||||||
|
-- Adds a description for a collectible. Optional parameters: itemName, language, transformations
|
||||||
|
function EID:addCollectible(id, description, itemName, language, transformations)
|
||||||
|
itemName = itemName or nil
|
||||||
|
language = language or "en_us"
|
||||||
|
transformations = transformations or "0"
|
||||||
|
EID.descriptions[language].custom["collectible_" .. id] = {id, transformations, itemName, description}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Adds a description for a trinket. Optional parameters: itemName, language, transformations
|
||||||
|
function EID:addTrinket(id, description, itemName, language, transformations)
|
||||||
|
itemName = itemName or nil
|
||||||
|
language = language or "en_us"
|
||||||
|
transformations = transformations or "0"
|
||||||
|
EID.descriptions[language].custom["trinket_" .. id] = {id, transformations, itemName, description}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Adds a description for a card/rune. Optional parameters: itemName, language, transformations
|
||||||
|
function EID:addCard(id, description, itemName, language, transformations)
|
||||||
|
itemName = itemName or nil
|
||||||
|
language = language or "en_us"
|
||||||
|
transformations = transformations or "0"
|
||||||
|
EID.descriptions[language].custom["card_" .. id] = {id, transformations, itemName, description}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Adds a description for a pilleffect id. Optional parameters: itemName, language, transformations
|
||||||
|
function EID:addPill(id, description, itemName, language, transformations)
|
||||||
|
itemName = itemName or nil
|
||||||
|
language = language or "en_us"
|
||||||
|
transformations = transformations or "0"
|
||||||
|
EID.descriptions[language].custom["pill_" .. id] = {id, transformations, itemName, description}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Adds a description for a pilleffect id. Optional parameters: language, transformations
|
||||||
|
-- when subtype is -1 or empty, it will affect all subtypes of that entity
|
||||||
|
function EID:addEntity(id, variant, subtype, entityName, description, language, transformations)
|
||||||
|
subtype = subtype or nil
|
||||||
|
language = language or "en_us"
|
||||||
|
transformations = transformations or "0"
|
||||||
|
EID.descriptions[language].custom[id .. "." .. variant .. "." .. subtype] = {
|
||||||
|
id,
|
||||||
|
variant,
|
||||||
|
subtype,
|
||||||
|
entityName,
|
||||||
|
description,
|
||||||
|
transformations
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns if EID is displaying text right now
|
-- Returns if EID is displaying text right now
|
||||||
function EID:isDisplayingText()
|
function EID:isDisplayingText()
|
||||||
return isDisplayingText
|
return EID.isDisplayingText
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns true, if curse of blind is active
|
-- Returns true, if curse of blind is active
|
||||||
@@ -94,7 +142,7 @@ end
|
|||||||
|
|
||||||
-- returns the entity that is currently described. returns last described entity if currently not displaying text
|
-- returns the entity that is currently described. returns last described entity if currently not displaying text
|
||||||
function EID:getLastDescribedEntity()
|
function EID:getLastDescribedEntity()
|
||||||
return lastDescriptionEntity
|
return EID.lastDescriptionEntity
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns descriptions from the legacy mod descriptions if they exist
|
-- returns descriptions from the legacy mod descriptions if they exist
|
||||||
@@ -114,8 +162,8 @@ function EID:getLegacyModDescription(objTable, id)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns the specified object table in the current language.
|
-- returns the specified object table in the current language.
|
||||||
-- falls back to english if it doesnt exist
|
-- falls back to english if it doesnt exist
|
||||||
function EID:getDescriptionTable(objTable)
|
function EID:getDescriptionTable(objTable)
|
||||||
return EID.descriptions[EIDConfig["Language"]][objTable] or EID.descriptions["en_us"][objTable]
|
return EID.descriptions[EIDConfig["Language"]][objTable] or EID.descriptions["en_us"][objTable]
|
||||||
end
|
end
|
||||||
@@ -123,22 +171,23 @@ end
|
|||||||
-- returns the description object of the specified object table translated with the current language
|
-- returns the description object of the specified object table translated with the current language
|
||||||
-- falls back to english if the objID isnt available
|
-- falls back to english if the objID isnt available
|
||||||
function EID:getDescriptionObj(objTable, objID)
|
function EID:getDescriptionObj(objTable, objID)
|
||||||
local tableEntry = EID.descriptions[EIDConfig["Language"]][objTable][objID] or EID.descriptions["en_us"][objTable][objID] or {}
|
local tableEntry =
|
||||||
|
EID.descriptions[EIDConfig["Language"]][objTable][objID] or EID.descriptions["en_us"][objTable][objID] or {}
|
||||||
|
|
||||||
local description = {}
|
local description = {}
|
||||||
description.ID = objID
|
description.ID = objID
|
||||||
|
|
||||||
description.Name = EID:getObjectName(objID, objTable) or objTable
|
description.Name = EID:getObjectName(objID, objTable) or objTable
|
||||||
|
|
||||||
local legacyModdedDescription = EID:getLegacyModDescription(objTable, objID)
|
local legacyModdedDescription = EID:getLegacyModDescription(objTable, objID)
|
||||||
description.Description = legacyModdedDescription or tableEntry[4] or "MISSING DESCRIPTION"
|
description.Description = legacyModdedDescription or tableEntry[4] or "MISSING DESCRIPTION"
|
||||||
|
|
||||||
local legacyModdedTransformation = nil
|
local legacyModdedTransformation = nil
|
||||||
if objTable == "collectibles" then
|
if objTable == "collectibles" then
|
||||||
legacyModdedTransformation = EID:getLegacyModDescription("transformations", objID)
|
legacyModdedTransformation = EID:getLegacyModDescription("transformations", objID)
|
||||||
end
|
end
|
||||||
description.Transformation = legacyModdedTransformation or tableEntry[2] or "0"
|
description.Transformation = legacyModdedTransformation or tableEntry[2] or "0"
|
||||||
|
|
||||||
return description
|
return description
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -155,28 +204,28 @@ end
|
|||||||
function EID:getObjectName(objID, objType)
|
function EID:getObjectName(objID, objType)
|
||||||
local tableEntry = EID.descriptions[EIDConfig["Language"]][objType][objID] or EID.descriptions["en_us"][objType][objID]
|
local tableEntry = EID.descriptions[EIDConfig["Language"]][objType][objID] or EID.descriptions["en_us"][objType][objID]
|
||||||
if objType == "collectibles" then
|
if objType == "collectibles" then
|
||||||
if EIDConfig["Language"]~="en_us" and #tableEntry==4 then
|
if EIDConfig["Language"] ~= "en_us" and #tableEntry == 4 then
|
||||||
if tableEntry[3] ~= nil and tableEntry[3] ~= "" then
|
if tableEntry[3] ~= nil and tableEntry[3] ~= "" then
|
||||||
return tableEntry[3]
|
return tableEntry[3]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return EID.itemConfig:GetCollectible(objID).Name
|
return EID.itemConfig:GetCollectible(objID).Name
|
||||||
elseif objType == "trinkets" then
|
elseif objType == "trinkets" then
|
||||||
if EIDConfig["Language"]~="en_us" and #tableEntry==3 then
|
if EIDConfig["Language"] ~= "en_us" and #tableEntry == 3 then
|
||||||
if tableEntry[3] ~= nil and tableEntry[3] ~= "" then
|
if tableEntry[3] ~= nil and tableEntry[3] ~= "" then
|
||||||
return tableEntry[3]
|
return tableEntry[3]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return EID.itemConfig:GetTrinket(objID).Name
|
return EID.itemConfig:GetTrinket(objID).Name
|
||||||
elseif objType == "cards" then
|
elseif objType == "cards" then
|
||||||
if EIDConfig["Language"]~="en_us" and #tableEntry==3 then
|
if EIDConfig["Language"] ~= "en_us" and #tableEntry == 3 then
|
||||||
if tableEntry[3] ~= nil and tableEntry[3] ~= "" then
|
if tableEntry[3] ~= nil and tableEntry[3] ~= "" then
|
||||||
return tableEntry[3]
|
return tableEntry[3]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return EID.itemConfig:GetCard(objID).Name
|
return EID.itemConfig:GetCard(objID).Name
|
||||||
elseif objType == "pills" then
|
elseif objType == "pills" then
|
||||||
if EIDConfig["Language"]~="en_us" and #tableEntry==3 then
|
if EIDConfig["Language"] ~= "en_us" and #tableEntry == 3 then
|
||||||
if tableEntry[3] ~= nil and tableEntry[3] ~= "" then
|
if tableEntry[3] ~= nil and tableEntry[3] ~= "" then
|
||||||
return tableEntry[3]
|
return tableEntry[3]
|
||||||
end
|
end
|
||||||
@@ -198,7 +247,7 @@ function EID:hasDescription(entity)
|
|||||||
local isAllowed = false
|
local isAllowed = false
|
||||||
if EIDConfig["EnableEntityDescriptions"] then
|
if EIDConfig["EnableEntityDescriptions"] then
|
||||||
isAllowed = __eidEntityDescriptions[entity.Type .. "." .. entity.Variant .. "." .. entity.SubType] ~= nil
|
isAllowed = __eidEntityDescriptions[entity.Type .. "." .. entity.Variant .. "." .. entity.SubType] ~= nil
|
||||||
--isAllowed = isAllowed or type(entity:GetData()["EID_Description"]) ~= type(nil)
|
--isAllowed = isAllowed or type(entity:GetData()["EID_Description"]) ~= type(nil)
|
||||||
end
|
end
|
||||||
isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_COLLECTIBLE and EIDConfig["DisplayItemInfo"])
|
isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_COLLECTIBLE and EIDConfig["DisplayItemInfo"])
|
||||||
isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_TRINKET and EIDConfig["DisplayTrinketInfo"])
|
isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_TRINKET and EIDConfig["DisplayTrinketInfo"])
|
||||||
@@ -209,7 +258,7 @@ end
|
|||||||
|
|
||||||
-- Replaces shorthand-representations of a character with the internal reference
|
-- Replaces shorthand-representations of a character with the internal reference
|
||||||
function EID:replaceShortMarkupStrings(text)
|
function EID:replaceShortMarkupStrings(text)
|
||||||
for _,pair in ipairs(EID.TextReplacementPairs) do
|
for _, pair in ipairs(EID.TextReplacementPairs) do
|
||||||
text = string.gsub(text, pair[1], pair[2])
|
text = string.gsub(text, pair[1], pair[2])
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
@@ -228,8 +277,17 @@ end
|
|||||||
-- Returns the inlineIcon object of a given Iconstring
|
-- Returns the inlineIcon object of a given Iconstring
|
||||||
-- can be used to validate an iconstring
|
-- can be used to validate an iconstring
|
||||||
function EID:getIcon(str)
|
function EID:getIcon(str)
|
||||||
if str == nil then return EID.InlineIcons["ERROR"] end
|
if str == nil then
|
||||||
local strTrimmed = string.gsub(str, "{{(.-)}}", function(a) return a end)
|
return EID.InlineIcons["ERROR"]
|
||||||
|
end
|
||||||
|
local strTrimmed =
|
||||||
|
string.gsub(
|
||||||
|
str,
|
||||||
|
"{{(.-)}}",
|
||||||
|
function(a)
|
||||||
|
return a
|
||||||
|
end
|
||||||
|
)
|
||||||
if #strTrimmed <= #str then
|
if #strTrimmed <= #str then
|
||||||
return EID.InlineIcons[strTrimmed] or EID.InlineIcons["ERROR"]
|
return EID.InlineIcons[strTrimmed] or EID.InlineIcons["ERROR"]
|
||||||
else
|
else
|
||||||
@@ -239,14 +297,16 @@ end
|
|||||||
|
|
||||||
-- Returns the icon for a given transformation name or ID
|
-- Returns the icon for a given transformation name or ID
|
||||||
function EID:getTransformationIcon(str)
|
function EID:getTransformationIcon(str)
|
||||||
if str == nil then return EID.InlineIcons["ERROR"] end
|
if str == nil then
|
||||||
|
return EID.InlineIcons["ERROR"]
|
||||||
|
end
|
||||||
if tonumber(str) ~= nil then
|
if tonumber(str) ~= nil then
|
||||||
str = EID.descriptions["en_us"].transformations[tonumber(str+1)]
|
str = EID.descriptions["en_us"].transformations[tonumber(str + 1)]
|
||||||
end
|
end
|
||||||
local transformSprite = EID:getIcon(str:gsub(" ", ""))
|
local transformSprite = EID:getIcon(str:gsub(" ", ""))
|
||||||
if transformSprite[1] == "ERROR" then
|
if transformSprite[1] == "ERROR" then
|
||||||
transformSprite = EID:getIcon("CustomTransformation")
|
transformSprite = EID:getIcon("CustomTransformation")
|
||||||
end
|
end
|
||||||
return transformSprite
|
return transformSprite
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -263,7 +323,7 @@ function EID:filterIconMarkup(text, textPosX, textPosY)
|
|||||||
local textposition = string.find(text, word)
|
local textposition = string.find(text, word)
|
||||||
local lookup = EID:getIcon(word)
|
local lookup = EID:getIcon(word)
|
||||||
local preceedingTextWidth = EID:getStrWidth(string.sub(text, 0, textposition - 1)) * EIDConfig["Scale"]
|
local preceedingTextWidth = EID:getStrWidth(string.sub(text, 0, textposition - 1)) * EIDConfig["Scale"]
|
||||||
table.insert(spriteTable,{lookup, preceedingTextWidth})
|
table.insert(spriteTable, {lookup, preceedingTextWidth})
|
||||||
text = string.gsub(text, word, EID:generatePlaceholderString(lookup[3]), 1)
|
text = string.gsub(text, word, EID:generatePlaceholderString(lookup[3]), 1)
|
||||||
end
|
end
|
||||||
return text, spriteTable
|
return text, spriteTable
|
||||||
@@ -272,25 +332,21 @@ end
|
|||||||
--renders a list of given inline sprite objects returned by the "EID:filterIconMarkup()" function
|
--renders a list of given inline sprite objects returned by the "EID:filterIconMarkup()" function
|
||||||
-- Table entry format: {EID.InlineIcons Object, Width of text preceeding the icon}
|
-- Table entry format: {EID.InlineIcons Object, Width of text preceeding the icon}
|
||||||
function EID:renderInlineIcons(spriteTable, posX, posY)
|
function EID:renderInlineIcons(spriteTable, posX, posY)
|
||||||
for _,sprite in ipairs(spriteTable) do
|
for _, sprite in ipairs(spriteTable) do
|
||||||
local Xoffset = sprite[1][5] or -1
|
local Xoffset = sprite[1][5] or -1
|
||||||
local Yoffset = sprite[1][6] or 0
|
local Yoffset = sprite[1][6] or 0
|
||||||
local spriteObj = sprite[1][7] or EID.InlineIconSprite
|
local spriteObj = sprite[1][7] or EID.InlineIconSprite
|
||||||
spriteObj:SetFrame(sprite[1][1], sprite[1][2])
|
spriteObj:SetFrame(sprite[1][1], sprite[1][2])
|
||||||
spriteObj.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
spriteObj.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
||||||
spriteObj.Color = Color(1,1,1,EIDConfig["Transparency"],0,0,0)
|
spriteObj.Color = Color(1, 1, 1, EIDConfig["Transparency"], 0, 0, 0)
|
||||||
spriteObj:Render(
|
spriteObj:Render(Vector((posX + sprite[2] + Xoffset), posY + Yoffset), Vector(0, 0), Vector(0, 0))
|
||||||
Vector((posX + sprite[2] + Xoffset), posY + Yoffset),
|
|
||||||
Vector(0, 0),
|
|
||||||
Vector(0, 0)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the icon used for the bulletpoint. It will look at the first word in the given string.
|
-- Returns the icon used for the bulletpoint. It will look at the first word in the given string.
|
||||||
function EID:handleBulletpointIcon(text)
|
function EID:handleBulletpointIcon(text)
|
||||||
local firstWord = string.match(text, "([^%s]+)")
|
local firstWord = string.match(text, "([^%s]+)")
|
||||||
if EID:getIcon(firstWord) ~= EID.InlineIcons["ERROR"] then
|
if EID:getIcon(firstWord) ~= EID.InlineIcons["ERROR"] then
|
||||||
return firstWord
|
return firstWord
|
||||||
end
|
end
|
||||||
return "\007"
|
return "\007"
|
||||||
@@ -301,10 +357,17 @@ end
|
|||||||
function EID:getColor(str, baseKColor)
|
function EID:getColor(str, baseKColor)
|
||||||
local color = baseKColor
|
local color = baseKColor
|
||||||
local isColorMarkup = false
|
local isColorMarkup = false
|
||||||
if str ~= nil then
|
if str ~= nil then
|
||||||
local strTrimmed = string.gsub(str, "{{(.-)}}", function(a) return a end)
|
local strTrimmed =
|
||||||
|
string.gsub(
|
||||||
|
str,
|
||||||
|
"{{(.-)}}",
|
||||||
|
function(a)
|
||||||
|
return a
|
||||||
|
end
|
||||||
|
)
|
||||||
if #strTrimmed <= #str then
|
if #strTrimmed <= #str then
|
||||||
if type(EID.InlineColors[strTrimmed]) =="function" then
|
if type(EID.InlineColors[strTrimmed]) == "function" then
|
||||||
color = EID.InlineColors[strTrimmed](color)
|
color = EID.InlineColors[strTrimmed](color)
|
||||||
else
|
else
|
||||||
color = EID.InlineColors[strTrimmed] or color
|
color = EID.InlineColors[strTrimmed] or color
|
||||||
@@ -328,15 +391,15 @@ function EID:filterColorMarkup(text, baseKColor)
|
|||||||
local lookup, isColor = EID:getColor(word, lastColor)
|
local lookup, isColor = EID:getColor(word, lastColor)
|
||||||
if isColor then
|
if isColor then
|
||||||
local preceedingText = string.sub(text, lastPosition, textposition - 1)
|
local preceedingText = string.sub(text, lastPosition, textposition - 1)
|
||||||
local preceedingTextWidth = EID:getStrWidth(preceedingText)*EIDConfig["Scale"]
|
local preceedingTextWidth = EID:getStrWidth(preceedingText) * EIDConfig["Scale"]
|
||||||
lastPosition = textposition
|
lastPosition = textposition
|
||||||
table.insert(textPartsTable,{preceedingText, lastColor, preceedingTextWidth})
|
table.insert(textPartsTable, {preceedingText, lastColor, preceedingTextWidth})
|
||||||
lastColor = lookup
|
lastColor = lookup
|
||||||
text = string.gsub(text, word, "", 1)
|
text = string.gsub(text, word, "", 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(textPartsTable,{string.sub(text, lastPosition), lastColor, 0})
|
table.insert(textPartsTable, {string.sub(text, lastPosition), lastColor, 0})
|
||||||
return textPartsTable
|
return textPartsTable
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -349,12 +412,12 @@ function EID:fitTextToWidth(str, textboxWidth)
|
|||||||
for word in string.gmatch(str, "([^%s]+)") do
|
for word in string.gmatch(str, "([^%s]+)") do
|
||||||
local colorFiltered = EID:filterColorMarkup(word, EID:getTextColor())
|
local colorFiltered = EID:filterColorMarkup(word, EID:getTextColor())
|
||||||
local filteredWord = ""
|
local filteredWord = ""
|
||||||
for _,filtered in ipairs(colorFiltered) do
|
for _, filtered in ipairs(colorFiltered) do
|
||||||
filteredWord = filteredWord..filtered[1]
|
filteredWord = filteredWord .. filtered[1]
|
||||||
end
|
end
|
||||||
local strFiltered, spriteTable = EID:filterIconMarkup(filteredWord, 0, 0)
|
local strFiltered, spriteTable = EID:filterIconMarkup(filteredWord, 0, 0)
|
||||||
local wordLength = EID:getStrWidth(strFiltered)
|
local wordLength = EID:getStrWidth(strFiltered)
|
||||||
|
|
||||||
if curLength + wordLength <= textboxWidth or curLength < 12 then
|
if curLength + wordLength <= textboxWidth or curLength < 12 then
|
||||||
text = text .. word .. " "
|
text = text .. word .. " "
|
||||||
curLength = curLength + wordLength
|
curLength = curLength + wordLength
|
||||||
@@ -382,17 +445,18 @@ function EID:renderString(str, position, scale, kcolor)
|
|||||||
EID:renderInlineIcons(spriteTable, position.X, position.Y)
|
EID:renderInlineIcons(spriteTable, position.X, position.Y)
|
||||||
EID.font:DrawStringScaledUTF8(strFiltered, position.X + offsetX, position.Y, scale.X, scale.Y, textPart[2], 0, false)
|
EID.font:DrawStringScaledUTF8(strFiltered, position.X + offsetX, position.Y, scale.X, scale.Y, textPart[2], 0, false)
|
||||||
offsetX = offsetX + textPart[3]
|
offsetX = offsetX + textPart[3]
|
||||||
end
|
end
|
||||||
return textPartsTable[#textPartsTable][2]
|
return textPartsTable[#textPartsTable][2]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Interpolates between 2 KColors with a given fraction.
|
-- Interpolates between 2 KColors with a given fraction.
|
||||||
function EID:interpolateColors(kColor1, kColor2, fraction)
|
function EID:interpolateColors(kColor1, kColor2, fraction)
|
||||||
local t = KColor(
|
local t =
|
||||||
(kColor2.Red-kColor1.Red)*fraction+kColor1.Red,
|
KColor(
|
||||||
(kColor2.Green-kColor1.Green)*fraction+kColor1.Green,
|
(kColor2.Red - kColor1.Red) * fraction + kColor1.Red,
|
||||||
(kColor2.Blue-kColor1.Blue)*fraction+kColor1.Blue,
|
(kColor2.Green - kColor1.Green) * fraction + kColor1.Green,
|
||||||
(kColor2.Alpha-kColor1.Alpha)*fraction+kColor1.Alpha,
|
(kColor2.Blue - kColor1.Blue) * fraction + kColor1.Blue,
|
||||||
|
(kColor2.Alpha - kColor1.Alpha) * fraction + kColor1.Alpha,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
@@ -402,11 +466,11 @@ end
|
|||||||
|
|
||||||
-- Creates a copy of a KColor object. This prevents overwriting existing
|
-- Creates a copy of a KColor object. This prevents overwriting existing
|
||||||
function EID:copyKColor(colorObj)
|
function EID:copyKColor(colorObj)
|
||||||
return KColor(colorObj.Red,colorObj.Green,colorObj.Blue,colorObj.Alpha,0,0,0)
|
return KColor(colorObj.Red, colorObj.Green, colorObj.Blue, colorObj.Alpha, 0, 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Compares two KColors. Returns true if they are equal
|
-- Compares two KColors. Returns true if they are equal
|
||||||
function EID:areColorsEqual(c1,c2)
|
function EID:areColorsEqual(c1, c2)
|
||||||
return c1.Red == c2.Red and c1.Green == c2.Green and c1.Blue == c2.Blue and c1.Alpha == c2.Alpha
|
return c1.Red == c2.Red and c1.Green == c2.Green and c1.Blue == c2.Blue and c1.Alpha == c2.Alpha
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -460,4 +524,4 @@ function EID:getErrorColor()
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
local showDebugChars = false
|
local showDebugChars = true
|
||||||
local charsToDebug = {
|
local charsToDebug = {
|
||||||
"!!! EID DEBUG MODE ACTIVATED !!!", -- Header
|
"!!! EID DEBUG MODE ACTIVATED !!!", -- Header
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890", -- Basic chars
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890", -- Basic chars
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ EID = RegisterMod("External Item Descriptions", 1)
|
|||||||
EID.itemConfig = Isaac.GetItemConfig()
|
EID.itemConfig = Isaac.GetItemConfig()
|
||||||
EID.descriptions = {} -- Table that holds all translation strings
|
EID.descriptions = {} -- Table that holds all translation strings
|
||||||
|
|
||||||
|
EID.isDisplayingText = false
|
||||||
|
EID.lastDescriptionEntity = nil
|
||||||
local lineHeight = 11
|
local lineHeight = 11
|
||||||
local isDisplayingText = false
|
|
||||||
local lastDescriptionEntity = nil
|
|
||||||
local hideDescToggle = false
|
local hideDescToggle = false
|
||||||
EID.sacrificeCounter = 1
|
EID.sacrificeCounter = 1
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ require("mod_config_menu")
|
|||||||
--languages
|
--languages
|
||||||
require("descriptions.ab+.en_us")
|
require("descriptions.ab+.en_us")
|
||||||
require("descriptions.ab+.en_us_detailed")
|
require("descriptions.ab+.en_us_detailed")
|
||||||
require("descriptions.ab+.bul") -- WIP
|
require("descriptions.ab+.bul") -- WIP
|
||||||
require("descriptions.ab+.fr")
|
require("descriptions.ab+.fr")
|
||||||
--require("descriptions.ab+.pl") -- WIP
|
--require("descriptions.ab+.pl") -- WIP
|
||||||
require("descriptions.ab+.pt")
|
require("descriptions.ab+.pt")
|
||||||
@@ -87,7 +87,7 @@ end
|
|||||||
function printDescription(desc)
|
function printDescription(desc)
|
||||||
local padding = posY()
|
local padding = posY()
|
||||||
local itemType = -1
|
local itemType = -1
|
||||||
if tonumber(desc.ID)~=nil then
|
if tonumber(desc.ID) ~= nil then
|
||||||
itemType = EID.itemConfig:GetCollectible(tonumber(desc.ID)).Type or -1
|
itemType = EID.itemConfig:GetCollectible(tonumber(desc.ID)).Type or -1
|
||||||
end
|
end
|
||||||
--Display ItemType / Charge
|
--Display ItemType / Charge
|
||||||
@@ -99,19 +99,11 @@ function printDescription(desc)
|
|||||||
EID.IconSprite:Play(EID.ItemTypeAnm2Names[itemType])
|
EID.IconSprite:Play(EID.ItemTypeAnm2Names[itemType])
|
||||||
EID.IconSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
EID.IconSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
||||||
EID.IconSprite:Update()
|
EID.IconSprite:Update()
|
||||||
EID.IconSprite:Render(
|
EID.IconSprite:Render(Vector(EIDConfig["XPosition"], padding + offsetY), Vector(0, 0), Vector(0, 0))
|
||||||
Vector(EIDConfig["XPosition"], padding + offsetY),
|
|
||||||
Vector(0, 0),
|
|
||||||
Vector(0, 0)
|
|
||||||
)
|
|
||||||
if itemType == 3 then -- Display Charge
|
if itemType == 3 then -- Display Charge
|
||||||
EID.IconSprite:Play(EID.itemConfig:GetCollectible(desc.ID).MaxCharges)
|
EID.IconSprite:Play(EID.itemConfig:GetCollectible(desc.ID).MaxCharges)
|
||||||
EID.IconSprite:Update()
|
EID.IconSprite:Update()
|
||||||
EID.IconSprite:Render(
|
EID.IconSprite:Render(Vector(EIDConfig["XPosition"], padding + offsetY), Vector(0, 0), Vector(0, 0))
|
||||||
Vector(EIDConfig["XPosition"], padding + offsetY),
|
|
||||||
Vector(0, 0),
|
|
||||||
Vector(0, 0)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
if not EIDConfig["ShowItemName"] then
|
if not EIDConfig["ShowItemName"] then
|
||||||
padding = padding + lineHeight * EIDConfig["Scale"]
|
padding = padding + lineHeight * EIDConfig["Scale"]
|
||||||
@@ -152,7 +144,7 @@ function printDescription(desc)
|
|||||||
local iconSprite = transformSprite[7] or EID.InlineIconSprite
|
local iconSprite = transformSprite[7] or EID.InlineIconSprite
|
||||||
iconSprite:Play(transformSprite[1])
|
iconSprite:Play(transformSprite[1])
|
||||||
iconSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
iconSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
||||||
iconSprite.Color = Color(1,1,1,EIDConfig["Transparency"],0,0,0)
|
iconSprite.Color = Color(1, 1, 1, EIDConfig["Transparency"], 0, 0, 0)
|
||||||
iconSprite:Render(
|
iconSprite:Render(
|
||||||
Vector(EIDConfig["XPosition"] + iconOffsetX * EIDConfig["Scale"], padding + iconOffsetY * EIDConfig["Scale"]),
|
Vector(EIDConfig["XPosition"] + iconOffsetX * EIDConfig["Scale"], padding + iconOffsetY * EIDConfig["Scale"]),
|
||||||
Vector(0, 0),
|
Vector(0, 0),
|
||||||
@@ -160,7 +152,7 @@ function printDescription(desc)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
if EIDConfig["TransformationText"] then
|
if EIDConfig["TransformationText"] then
|
||||||
local textOffsetY = math.min(0,(iconHeight-9))/4
|
local textOffsetY = math.min(0, (iconHeight - 9)) / 4
|
||||||
EID:renderString(
|
EID:renderString(
|
||||||
transformationName,
|
transformationName,
|
||||||
Vector(EIDConfig["XPosition"] + iconWidth + 4, padding + textOffsetY),
|
Vector(EIDConfig["XPosition"] + iconWidth + 4, padding + textOffsetY),
|
||||||
@@ -173,10 +165,10 @@ function printDescription(desc)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
printBulletPoints(desc.Description, padding)
|
EID:printBulletPoints(desc.Description, padding)
|
||||||
end
|
end
|
||||||
|
|
||||||
function printBulletPoints(description, padding)
|
function EID:printBulletPoints(description, padding)
|
||||||
local textboxWidth = tonumber(EIDConfig["TextboxWidth"]) * 4
|
local textboxWidth = tonumber(EIDConfig["TextboxWidth"]) * 4
|
||||||
description = EID:replaceShortMarkupStrings(description)
|
description = EID:replaceShortMarkupStrings(description)
|
||||||
for line in string.gmatch(description, "([^#]+)") do
|
for line in string.gmatch(description, "([^#]+)") do
|
||||||
@@ -184,21 +176,18 @@ function printBulletPoints(description, padding)
|
|||||||
local textColor = EID:getTextColor()
|
local textColor = EID:getTextColor()
|
||||||
for i, lineToPrint in ipairs(formatedLines) do
|
for i, lineToPrint in ipairs(formatedLines) do
|
||||||
-- render bulletpoint
|
-- render bulletpoint
|
||||||
local posX = EIDConfig["XPosition"]
|
local posX = EIDConfig["XPosition"]
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
local bpIcon = EID:handleBulletpointIcon(lineToPrint)
|
local bpIcon = EID:handleBulletpointIcon(lineToPrint)
|
||||||
if EID:getIcon(bpIcon) ~= EID.InlineIcons["ERROR"] then
|
if EID:getIcon(bpIcon) ~= EID.InlineIcons["ERROR"] then
|
||||||
lineToPrint = string.gsub(lineToPrint, bpIcon .. " ", "")
|
lineToPrint = string.gsub(lineToPrint, bpIcon .. " ", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
textColor = EID:renderString(bpIcon, Vector(posX, padding), Vector(EIDConfig["Scale"], EIDConfig["Scale"]), textColor)
|
textColor =
|
||||||
|
EID:renderString(bpIcon, Vector(posX, padding), Vector(EIDConfig["Scale"], EIDConfig["Scale"]), textColor)
|
||||||
end
|
end
|
||||||
textColor = EID:renderString(
|
textColor =
|
||||||
lineToPrint,
|
EID:renderString(lineToPrint, Vector(posX + 12, padding), Vector(EIDConfig["Scale"], EIDConfig["Scale"]), textColor)
|
||||||
Vector(posX + 12, padding),
|
|
||||||
Vector(EIDConfig["Scale"], EIDConfig["Scale"]),
|
|
||||||
textColor
|
|
||||||
)
|
|
||||||
padding = padding + lineHeight * EIDConfig["Scale"]
|
padding = padding + lineHeight * EIDConfig["Scale"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -207,7 +196,7 @@ end
|
|||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
---------------------------Handle Rendering--------------------------------
|
---------------------------Handle Rendering--------------------------------
|
||||||
|
|
||||||
function renderQuestionMark()
|
function EID:renderQuestionMark()
|
||||||
IconSprite:Play("CurseOfBlind")
|
IconSprite:Play("CurseOfBlind")
|
||||||
IconSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
IconSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
||||||
IconSprite:Update()
|
IconSprite:Update()
|
||||||
@@ -221,7 +210,7 @@ function renderQuestionMark()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function renderIndicator(entity)
|
function EID:renderIndicator(entity)
|
||||||
if EIDConfig["Indicator"] == "blink" then
|
if EIDConfig["Indicator"] == "blink" then
|
||||||
local c = 255 - math.floor(255 * ((entity.FrameCount % 40) / 40))
|
local c = 255 - math.floor(255 * ((entity.FrameCount % 40) / 40))
|
||||||
entity:SetColor(Color(1, 1, 1, 1, c, c, c), 1, 1, false, false)
|
entity:SetColor(Color(1, 1, 1, 1, c, c, c), 1, 1, false, false)
|
||||||
@@ -258,7 +247,7 @@ end
|
|||||||
---------------------------On Render Function------------------------------
|
---------------------------On Render Function------------------------------
|
||||||
|
|
||||||
local function onRender(t)
|
local function onRender(t)
|
||||||
isDisplayingText = false
|
EID.isDisplayingText = false
|
||||||
local player = Isaac.GetPlayer(0)
|
local player = Isaac.GetPlayer(0)
|
||||||
local closest = nil
|
local closest = nil
|
||||||
local closestDice = nil
|
local closestDice = nil
|
||||||
@@ -292,7 +281,7 @@ local function onRender(t)
|
|||||||
Game():GetRoom():GetType() == RoomType.ROOM_DICE and EIDConfig["DisplayDiceInfo"] and type(closestDice) ~= type(nil)
|
Game():GetRoom():GetType() == RoomType.ROOM_DICE and EIDConfig["DisplayDiceInfo"] and type(closestDice) ~= type(nil)
|
||||||
then
|
then
|
||||||
printDescription(EID:getDescriptionObj("dice", closestDice.SubType + 1))
|
printDescription(EID:getDescriptionObj("dice", closestDice.SubType + 1))
|
||||||
renderIndicator(closestDice)
|
EID:renderIndicator(closestDice)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -300,42 +289,44 @@ local function onRender(t)
|
|||||||
if closest == nil then
|
if closest == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
lastDescriptionEntity = closest
|
EID.lastDescriptionEntity = closest
|
||||||
isDisplayingText = true
|
EID.isDisplayingText = true
|
||||||
|
|
||||||
--Handle Indicators
|
--Handle Indicators
|
||||||
renderIndicator(closest)
|
EID:renderIndicator(closest)
|
||||||
|
--
|
||||||
|
|
||||||
--Handle Entities (specific)
|
--Handle Entities (specific)
|
||||||
--[[ if EIDConfig["EnableEntityDescriptions"] and type(closest:GetData()["EID_Description"]) ~= type(nil) then
|
--[[ if EIDConfig["EnableEntityDescriptions"] and type(closest:GetData()["EID_Description"]) ~= type(nil) then
|
||||||
printTrinketDescription({closest.Type, closest:GetData()["EID_Description"]}, "custom")
|
printTrinketDescription({closest.Type, closest:GetData()["EID_Description"]}, "custom")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
]]--
|
]] --Handle Entities (omni)
|
||||||
--Handle Entities (omni)
|
|
||||||
local objIDString = closest.Type .. "." .. closest.Variant .. "." .. closest.SubType
|
local objIDString = closest.Type .. "." .. closest.Variant .. "." .. closest.SubType
|
||||||
local tableEntry = EID.descriptions[EIDConfig["Language"]]["custom"][objIDString]
|
local tableEntry =
|
||||||
or EID.descriptions["en_us"]["custom"][objIDString] or EID:getLegacyModDescription("custom", objIDString) or nil
|
EID.descriptions[EIDConfig["Language"]]["custom"][objIDString] or EID.descriptions["en_us"]["custom"][objIDString] or
|
||||||
if EIDConfig["EnableEntityDescriptions"] and tableEntry~=nil then
|
EID:getLegacyModDescription("custom", objIDString) or
|
||||||
|
nil
|
||||||
|
if EIDConfig["EnableEntityDescriptions"] and tableEntry ~= nil then
|
||||||
printDescription(EID:getDescriptionObj("custom", objIDString))
|
printDescription(EID:getDescriptionObj("custom", objIDString))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--Handle Trinkets
|
--Handle Trinkets
|
||||||
if closest.Variant == PickupVariant.PICKUP_TRINKET then
|
if closest.Variant == PickupVariant.PICKUP_TRINKET then
|
||||||
printDescription(EID:getDescriptionObj("trinkets", closest.SubType))
|
|
||||||
--Handle Collectibles
|
--Handle Collectibles
|
||||||
|
printDescription(EID:getDescriptionObj("trinkets", closest.SubType))
|
||||||
elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then
|
elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then
|
||||||
|
--Handle Cards & Runes
|
||||||
if EID:hasCurseBlind() and EIDConfig["DisableOnCurse"] then
|
if EID:hasCurseBlind() and EIDConfig["DisableOnCurse"] then
|
||||||
renderQuestionMark()
|
EID:renderQuestionMark()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
printDescription(EID:getDescriptionObj("collectibles", closest.SubType))
|
printDescription(EID:getDescriptionObj("collectibles", closest.SubType))
|
||||||
--Handle Cards & Runes
|
|
||||||
elseif closest.Variant == PickupVariant.PICKUP_TAROTCARD then
|
elseif closest.Variant == PickupVariant.PICKUP_TAROTCARD then
|
||||||
|
--Handle Pills
|
||||||
if closest:ToPickup():IsShopItem() and not EIDConfig["DisplayCardInfoShop"] then
|
if closest:ToPickup():IsShopItem() and not EIDConfig["DisplayCardInfoShop"] then
|
||||||
renderQuestionMark()
|
EID:renderQuestionMark()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
printDescription(EID:getDescriptionObj("cards", closest.SubType))
|
printDescription(EID:getDescriptionObj("cards", closest.SubType))
|
||||||
@@ -353,10 +344,9 @@ local function onRender(t)
|
|||||||
Vector(0, 0)
|
Vector(0, 0)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
--Handle Pills
|
|
||||||
elseif closest.Variant == PickupVariant.PICKUP_PILL then
|
elseif closest.Variant == PickupVariant.PICKUP_PILL then
|
||||||
if closest:ToPickup():IsShopItem() and not EIDConfig["DisplayPillInfoShop"] then
|
if closest:ToPickup():IsShopItem() and not EIDConfig["DisplayPillInfoShop"] then
|
||||||
renderQuestionMark()
|
EID:renderQuestionMark()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user