Fixed transparency of text colors and icons

This commit is contained in:
Wofsauge committed 2020-11-01 18:12:06 +01:00
1 parent b1d021648d
commit 240a583066
2 files changed
+22 -8

No files matched your search

+21 -8
View File
@@ -278,6 +278,7 @@ function EID:renderInlineIcons(spriteTable, posX, posY)
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:Render( spriteObj:Render(
Vector((posX + sprite[2] + Xoffset), posY + Yoffset), Vector((posX + sprite[2] + Xoffset), posY + Yoffset),
Vector(0, 0), Vector(0, 0),
@@ -296,17 +297,24 @@ function EID:handleBulletpointIcon(text)
end 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
function EID:getColor(str, baseKColor) function EID:getColor(str, baseKColor)
if str == nil then return baseKColor end 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 #strTrimmed <= #str then
if type(EID.InlineColors[strTrimmed]) =="function" then if type(EID.InlineColors[strTrimmed]) =="function" then
return EID.InlineColors[strTrimmed](baseKColor) color = EID.InlineColors[strTrimmed](color)
end
return EID.InlineColors[strTrimmed] or baseKColor
else else
return baseKColor color = EID.InlineColors[strTrimmed] or color
end end
isColorMarkup = type(EID.InlineColors[strTrimmed]) ~= type(nil)
end
end
color = EID:copyKColor(color)
color.Alpha = math.min(color.Alpha, EIDConfig["Transparency"])
return color, isColorMarkup
end end
-- Filters a given string and looks for Colormarkup. Splits the text into subsections limited by them. -- Filters a given string and looks for Colormarkup. Splits the text into subsections limited by them.
@@ -317,8 +325,8 @@ function EID:filterColorMarkup(text, baseKColor)
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)
local lookup = EID:getColor(word, lastColor) local lookup, isColor = EID:getColor(word, lastColor)
if lookup ~= lastColor 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
@@ -351,7 +359,6 @@ function EID:fitTextToWidth(str, textboxWidth)
text = text .. word .. " " text = text .. word .. " "
curLength = curLength + wordLength curLength = curLength + wordLength
else else
print(text)
table.insert(formatedLines, text) table.insert(formatedLines, text)
text = word .. " " text = word .. " "
curLength = wordLength curLength = wordLength
@@ -393,10 +400,16 @@ function EID:interpolateColors(kColor1, kColor2, fraction)
return t return t
end end
-- 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
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
end
-- Get KColor object of "Entity Name" texts -- Get KColor object of "Entity Name" texts
function EID:getNameColor() function EID:getNameColor()
return KColor( return KColor(
+1
View File
@@ -152,6 +152,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: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),