Formatted api and main file
This commit is contained in:
1 parent
2a6d330e2c
commit
bfa6addf65
3 files changed
+107
-53
No files matched your search
+77
-13
@@ -77,9 +77,57 @@ EID.ItemTypeAnm2Names = {
|
||||
---------------------------------------------------------------------------
|
||||
-------------------------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
|
||||
function EID:isDisplayingText()
|
||||
return isDisplayingText
|
||||
return EID.isDisplayingText
|
||||
end
|
||||
|
||||
-- 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
|
||||
function EID:getLastDescribedEntity()
|
||||
return lastDescriptionEntity
|
||||
return EID.lastDescriptionEntity
|
||||
end
|
||||
|
||||
-- returns descriptions from the legacy mod descriptions if they exist
|
||||
@@ -123,7 +171,8 @@ end
|
||||
-- returns the description object of the specified object table translated with the current language
|
||||
-- falls back to english if the objID isnt available
|
||||
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 = {}
|
||||
description.ID = objID
|
||||
@@ -228,8 +277,17 @@ end
|
||||
-- Returns the inlineIcon object of a given Iconstring
|
||||
-- can be used to validate an iconstring
|
||||
function EID:getIcon(str)
|
||||
if str == nil then return EID.InlineIcons["ERROR"] end
|
||||
local strTrimmed = string.gsub(str, "{{(.-)}}", function(a) return a end)
|
||||
if str == nil then
|
||||
return EID.InlineIcons["ERROR"]
|
||||
end
|
||||
local strTrimmed =
|
||||
string.gsub(
|
||||
str,
|
||||
"{{(.-)}}",
|
||||
function(a)
|
||||
return a
|
||||
end
|
||||
)
|
||||
if #strTrimmed <= #str then
|
||||
return EID.InlineIcons[strTrimmed] or EID.InlineIcons["ERROR"]
|
||||
else
|
||||
@@ -239,7 +297,9 @@ 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 str == nil then
|
||||
return EID.InlineIcons["ERROR"]
|
||||
end
|
||||
if tonumber(str) ~= nil then
|
||||
str = EID.descriptions["en_us"].transformations[tonumber(str + 1)]
|
||||
end
|
||||
@@ -279,11 +339,7 @@ function EID:renderInlineIcons(spriteTable, posX, posY)
|
||||
spriteObj:SetFrame(sprite[1][1], sprite[1][2])
|
||||
spriteObj.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
||||
spriteObj.Color = Color(1, 1, 1, EIDConfig["Transparency"], 0, 0, 0)
|
||||
spriteObj:Render(
|
||||
Vector((posX + sprite[2] + Xoffset), posY + Yoffset),
|
||||
Vector(0, 0),
|
||||
Vector(0, 0)
|
||||
)
|
||||
spriteObj:Render(Vector((posX + sprite[2] + Xoffset), posY + Yoffset), Vector(0, 0), Vector(0, 0))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -302,7 +358,14 @@ function EID:getColor(str, baseKColor)
|
||||
local color = baseKColor
|
||||
local isColorMarkup = false
|
||||
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 type(EID.InlineColors[strTrimmed]) == "function" then
|
||||
color = EID.InlineColors[strTrimmed](color)
|
||||
@@ -388,7 +451,8 @@ end
|
||||
|
||||
-- Interpolates between 2 KColors with a given fraction.
|
||||
function EID:interpolateColors(kColor1, kColor2, fraction)
|
||||
local t = KColor(
|
||||
local t =
|
||||
KColor(
|
||||
(kColor2.Red - kColor1.Red) * fraction + kColor1.Red,
|
||||
(kColor2.Green - kColor1.Green) * fraction + kColor1.Green,
|
||||
(kColor2.Blue - kColor1.Blue) * fraction + kColor1.Blue,
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
local showDebugChars = false
|
||||
local showDebugChars = true
|
||||
local charsToDebug = {
|
||||
"!!! EID DEBUG MODE ACTIVATED !!!", -- Header
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890", -- Basic chars
|
||||
|
||||
@@ -2,9 +2,9 @@ EID = RegisterMod("External Item Descriptions", 1)
|
||||
EID.itemConfig = Isaac.GetItemConfig()
|
||||
EID.descriptions = {} -- Table that holds all translation strings
|
||||
|
||||
EID.isDisplayingText = false
|
||||
EID.lastDescriptionEntity = nil
|
||||
local lineHeight = 11
|
||||
local isDisplayingText = false
|
||||
local lastDescriptionEntity = nil
|
||||
local hideDescToggle = false
|
||||
EID.sacrificeCounter = 1
|
||||
|
||||
@@ -99,19 +99,11 @@ function printDescription(desc)
|
||||
EID.IconSprite:Play(EID.ItemTypeAnm2Names[itemType])
|
||||
EID.IconSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
||||
EID.IconSprite:Update()
|
||||
EID.IconSprite:Render(
|
||||
Vector(EIDConfig["XPosition"], padding + offsetY),
|
||||
Vector(0, 0),
|
||||
Vector(0, 0)
|
||||
)
|
||||
EID.IconSprite:Render(Vector(EIDConfig["XPosition"], padding + offsetY), Vector(0, 0), Vector(0, 0))
|
||||
if itemType == 3 then -- Display Charge
|
||||
EID.IconSprite:Play(EID.itemConfig:GetCollectible(desc.ID).MaxCharges)
|
||||
EID.IconSprite:Update()
|
||||
EID.IconSprite:Render(
|
||||
Vector(EIDConfig["XPosition"], padding + offsetY),
|
||||
Vector(0, 0),
|
||||
Vector(0, 0)
|
||||
)
|
||||
EID.IconSprite:Render(Vector(EIDConfig["XPosition"], padding + offsetY), Vector(0, 0), Vector(0, 0))
|
||||
end
|
||||
if not EIDConfig["ShowItemName"] then
|
||||
padding = padding + lineHeight * EIDConfig["Scale"]
|
||||
@@ -173,10 +165,10 @@ function printDescription(desc)
|
||||
end
|
||||
end
|
||||
end
|
||||
printBulletPoints(desc.Description, padding)
|
||||
EID:printBulletPoints(desc.Description, padding)
|
||||
end
|
||||
|
||||
function printBulletPoints(description, padding)
|
||||
function EID:printBulletPoints(description, padding)
|
||||
local textboxWidth = tonumber(EIDConfig["TextboxWidth"]) * 4
|
||||
description = EID:replaceShortMarkupStrings(description)
|
||||
for line in string.gmatch(description, "([^#]+)") do
|
||||
@@ -191,14 +183,11 @@ function printBulletPoints(description, padding)
|
||||
lineToPrint = string.gsub(lineToPrint, bpIcon .. " ", "")
|
||||
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
|
||||
textColor = EID:renderString(
|
||||
lineToPrint,
|
||||
Vector(posX + 12, padding),
|
||||
Vector(EIDConfig["Scale"], EIDConfig["Scale"]),
|
||||
textColor
|
||||
)
|
||||
textColor =
|
||||
EID:renderString(lineToPrint, Vector(posX + 12, padding), Vector(EIDConfig["Scale"], EIDConfig["Scale"]), textColor)
|
||||
padding = padding + lineHeight * EIDConfig["Scale"]
|
||||
end
|
||||
end
|
||||
@@ -207,7 +196,7 @@ end
|
||||
---------------------------------------------------------------------------
|
||||
---------------------------Handle Rendering--------------------------------
|
||||
|
||||
function renderQuestionMark()
|
||||
function EID:renderQuestionMark()
|
||||
IconSprite:Play("CurseOfBlind")
|
||||
IconSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
|
||||
IconSprite:Update()
|
||||
@@ -221,7 +210,7 @@ function renderQuestionMark()
|
||||
end
|
||||
end
|
||||
|
||||
function renderIndicator(entity)
|
||||
function EID:renderIndicator(entity)
|
||||
if EIDConfig["Indicator"] == "blink" then
|
||||
local c = 255 - math.floor(255 * ((entity.FrameCount % 40) / 40))
|
||||
entity:SetColor(Color(1, 1, 1, 1, c, c, c), 1, 1, false, false)
|
||||
@@ -258,7 +247,7 @@ end
|
||||
---------------------------On Render Function------------------------------
|
||||
|
||||
local function onRender(t)
|
||||
isDisplayingText = false
|
||||
EID.isDisplayingText = false
|
||||
local player = Isaac.GetPlayer(0)
|
||||
local closest = 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)
|
||||
then
|
||||
printDescription(EID:getDescriptionObj("dice", closestDice.SubType + 1))
|
||||
renderIndicator(closestDice)
|
||||
EID:renderIndicator(closestDice)
|
||||
end
|
||||
return
|
||||
end
|
||||
@@ -300,42 +289,44 @@ local function onRender(t)
|
||||
if closest == nil then
|
||||
return
|
||||
end
|
||||
lastDescriptionEntity = closest
|
||||
isDisplayingText = true
|
||||
EID.lastDescriptionEntity = closest
|
||||
EID.isDisplayingText = true
|
||||
|
||||
--Handle Indicators
|
||||
renderIndicator(closest)
|
||||
EID:renderIndicator(closest)
|
||||
--
|
||||
|
||||
--Handle Entities (specific)
|
||||
--[[ if EIDConfig["EnableEntityDescriptions"] and type(closest:GetData()["EID_Description"]) ~= type(nil) then
|
||||
printTrinketDescription({closest.Type, closest:GetData()["EID_Description"]}, "custom")
|
||||
return
|
||||
end
|
||||
]]--
|
||||
--Handle Entities (omni)
|
||||
]] --Handle Entities (omni)
|
||||
local objIDString = closest.Type .. "." .. closest.Variant .. "." .. closest.SubType
|
||||
local tableEntry = EID.descriptions[EIDConfig["Language"]]["custom"][objIDString]
|
||||
or EID.descriptions["en_us"]["custom"][objIDString] or EID:getLegacyModDescription("custom", objIDString) or nil
|
||||
local tableEntry =
|
||||
EID.descriptions[EIDConfig["Language"]]["custom"][objIDString] or EID.descriptions["en_us"]["custom"][objIDString] or
|
||||
EID:getLegacyModDescription("custom", objIDString) or
|
||||
nil
|
||||
if EIDConfig["EnableEntityDescriptions"] and tableEntry ~= nil then
|
||||
printDescription(EID:getDescriptionObj("custom", objIDString))
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--Handle Trinkets
|
||||
if closest.Variant == PickupVariant.PICKUP_TRINKET then
|
||||
printDescription(EID:getDescriptionObj("trinkets", closest.SubType))
|
||||
--Handle Collectibles
|
||||
printDescription(EID:getDescriptionObj("trinkets", closest.SubType))
|
||||
elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then
|
||||
--Handle Cards & Runes
|
||||
if EID:hasCurseBlind() and EIDConfig["DisableOnCurse"] then
|
||||
renderQuestionMark()
|
||||
EID:renderQuestionMark()
|
||||
return
|
||||
end
|
||||
printDescription(EID:getDescriptionObj("collectibles", closest.SubType))
|
||||
--Handle Cards & Runes
|
||||
elseif closest.Variant == PickupVariant.PICKUP_TAROTCARD then
|
||||
--Handle Pills
|
||||
if closest:ToPickup():IsShopItem() and not EIDConfig["DisplayCardInfoShop"] then
|
||||
renderQuestionMark()
|
||||
EID:renderQuestionMark()
|
||||
return
|
||||
end
|
||||
printDescription(EID:getDescriptionObj("cards", closest.SubType))
|
||||
@@ -353,10 +344,9 @@ local function onRender(t)
|
||||
Vector(0, 0)
|
||||
)
|
||||
end
|
||||
--Handle Pills
|
||||
elseif closest.Variant == PickupVariant.PICKUP_PILL then
|
||||
if closest:ToPickup():IsShopItem() and not EIDConfig["DisplayPillInfoShop"] then
|
||||
renderQuestionMark()
|
||||
EID:renderQuestionMark()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user