Fix animated icons/text
This commit is contained in:
1 parent
8c85313edb
commit
c0a6128ea7
1 file changed
+15
-9
+15
-9
@@ -653,23 +653,23 @@ function EID:renderInlineIcons(spriteTable, posX, posY)
|
|||||||
spriteObj:Update()
|
spriteObj:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
EID:renderIcon(spriteObj, posX + sprite[2] + Xoffset * EID.Scale, posY + Yoffset * EID.Scale, sprite[3])
|
EID:renderIcon(spriteObj, posX + sprite[2] + Xoffset * EID.Scale, posY + Yoffset * EID.Scale, sprite[3], sprite[1][1], sprite[1][2])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- helper function to render Icons in specific EID settins
|
-- helper function to render Icons in specific EID settins
|
||||||
function EID:renderIcon(spriteObj, posX, posY, callback)
|
function EID:renderIcon(spriteObj, posX, posY, callback, animName, animFrame)
|
||||||
spriteObj.Scale = Vector(EID.Scale, EID.Scale)
|
spriteObj.Scale = Vector(EID.Scale, EID.Scale)
|
||||||
spriteObj.Color = Color(1, 1, 1, EID.Config["Transparency"], 0, 0, 0)
|
spriteObj.Color = Color(1, 1, 1, EID.Config["Transparency"], 0, 0, 0)
|
||||||
if callback then
|
if callback then
|
||||||
callback(spriteObj)
|
callback(spriteObj)
|
||||||
end
|
end
|
||||||
|
|
||||||
spriteObj:Render(Vector(posX, posY), nullVector, nullVector)
|
|
||||||
|
|
||||||
if EID.CachingDescription then
|
if EID.CachingDescription then
|
||||||
table.insert(EID.CachedIcons, {spriteObj, posX, posY, callback, spriteObj:GetAnimation(), spriteObj:GetFrame()})
|
table.insert(EID.CachedIcons, {spriteObj, posX, posY, callback, animName or spriteObj:GetAnimation(), animFrame or spriteObj:GetFrame()})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
spriteObj:Render(Vector(posX, posY), nullVector, nullVector)
|
||||||
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.
|
||||||
@@ -683,6 +683,7 @@ end
|
|||||||
|
|
||||||
-- Gets a KColor from a Markup-string (example Input: "{{ColorText}}")
|
-- Gets a KColor from a Markup-string (example Input: "{{ColorText}}")
|
||||||
-- Returns the KColor object and a boolean value indicating if the given string was a color markup or not
|
-- Returns the KColor object and a boolean value indicating if the given string was a color markup or not
|
||||||
|
local colorFunc = nil
|
||||||
function EID:getColor(str, baseKColor)
|
function EID:getColor(str, baseKColor)
|
||||||
local color = baseKColor
|
local color = baseKColor
|
||||||
local isColorMarkup = false
|
local isColorMarkup = false
|
||||||
@@ -690,8 +691,10 @@ function EID:getColor(str, baseKColor)
|
|||||||
local strTrimmed = string.gsub(str,"{{(.-)}}",function(a) return a end, 1)
|
local strTrimmed = string.gsub(str,"{{(.-)}}",function(a) return a end, 1)
|
||||||
if #strTrimmed <= #str then
|
if #strTrimmed <= #str then
|
||||||
if type(EID.InlineColors[strTrimmed]) == "function" then
|
if type(EID.InlineColors[strTrimmed]) == "function" then
|
||||||
|
colorFunc = EID.InlineColors[strTrimmed]
|
||||||
color = EID.InlineColors[strTrimmed](color)
|
color = EID.InlineColors[strTrimmed](color)
|
||||||
else
|
else
|
||||||
|
if EID.InlineColors[strTrimmed] then colorFunc = nil end
|
||||||
color = EID.InlineColors[strTrimmed] or color
|
color = EID.InlineColors[strTrimmed] or color
|
||||||
end
|
end
|
||||||
isColorMarkup = type(EID.InlineColors[strTrimmed]) ~= type(nil)
|
isColorMarkup = type(EID.InlineColors[strTrimmed]) ~= type(nil)
|
||||||
@@ -699,6 +702,7 @@ function EID:getColor(str, baseKColor)
|
|||||||
end
|
end
|
||||||
color = EID:copyKColor(color)
|
color = EID:copyKColor(color)
|
||||||
color.Alpha = math.min(color.Alpha, EID.Config["Transparency"])
|
color.Alpha = math.min(color.Alpha, EID.Config["Transparency"])
|
||||||
|
|
||||||
return color, isColorMarkup
|
return color, isColorMarkup
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -707,6 +711,7 @@ end
|
|||||||
function EID:filterColorMarkup(text, baseKColor)
|
function EID:filterColorMarkup(text, baseKColor)
|
||||||
local textPartsTable = {}
|
local textPartsTable = {}
|
||||||
local lastColor = baseKColor
|
local lastColor = baseKColor
|
||||||
|
local lastFunc = colorFunc
|
||||||
local lastPosition = 0
|
local lastPosition = 0
|
||||||
for word in string.gmatch(text, "{{.-}}") do
|
for word in string.gmatch(text, "{{.-}}") do
|
||||||
local textposition = string.find(text, word)
|
local textposition = string.find(text, word)
|
||||||
@@ -715,13 +720,14 @@ function EID:filterColorMarkup(text, baseKColor)
|
|||||||
local preceedingText = string.sub(text, lastPosition, textposition - 1)
|
local preceedingText = string.sub(text, lastPosition, textposition - 1)
|
||||||
local preceedingTextWidth = EID:getStrWidth(preceedingText) * EID.Scale
|
local preceedingTextWidth = EID:getStrWidth(preceedingText) * EID.Scale
|
||||||
lastPosition = textposition
|
lastPosition = textposition
|
||||||
table.insert(textPartsTable, {preceedingText, lastColor, preceedingTextWidth})
|
table.insert(textPartsTable, {preceedingText, lastColor, preceedingTextWidth, lastFunc})
|
||||||
lastColor = lookup
|
lastColor = lookup
|
||||||
|
lastFunc = colorFunc
|
||||||
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, lastFunc})
|
||||||
return textPartsTable
|
return textPartsTable
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -839,7 +845,7 @@ function EID:renderString(str, position, scale, kcolor)
|
|||||||
EID:renderInlineIcons(spriteTable, position.X + offsetX, position.Y)
|
EID:renderInlineIcons(spriteTable, position.X + offsetX, 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)
|
||||||
if EID.CachingDescription then
|
if EID.CachingDescription then
|
||||||
table.insert(EID.CachedStrings, {strFiltered, position.X + offsetX, position.Y, textPart[2]})
|
table.insert(EID.CachedStrings, {strFiltered, position.X + offsetX, position.Y, textPart[2], textPart[4], EID.Config["Transparency"]})
|
||||||
end
|
end
|
||||||
offsetX = offsetX + EID:getStrWidth(strFiltered) * scale.X
|
offsetX = offsetX + EID:getStrWidth(strFiltered) * scale.X
|
||||||
end
|
end
|
||||||
@@ -1278,4 +1284,4 @@ function EID:checkPlayersForMissingItems()
|
|||||||
EID.SaveGame[EID.Config["SaveGameNumber"]].ItemNeedsPickup[player.QueuedItem.Item.ID] = nil
|
EID.SaveGame[EID.Config["SaveGameNumber"]].ItemNeedsPickup[player.QueuedItem.Item.ID] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user