Fixed transparency of text colors and icons
This commit is contained in:
1 parent
b1d021648d
commit
240a583066
2 files changed
+26
-12
No files matched your search
+25
-12
@@ -262,7 +262,7 @@ function EID:filterIconMarkup(text, textPosX, textPosY)
|
|||||||
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: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
|
||||||
@@ -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 strTrimmed = string.gsub(str, "{{(.-)}}", function(a) return a end)
|
local isColorMarkup = false
|
||||||
if #strTrimmed <= #str then
|
if str ~= nil then
|
||||||
if type(EID.InlineColors[strTrimmed]) =="function" then
|
local strTrimmed = string.gsub(str, "{{(.-)}}", function(a) return a end)
|
||||||
return EID.InlineColors[strTrimmed](baseKColor)
|
if #strTrimmed <= #str then
|
||||||
|
if type(EID.InlineColors[strTrimmed]) =="function" then
|
||||||
|
color = EID.InlineColors[strTrimmed](color)
|
||||||
|
else
|
||||||
|
color = EID.InlineColors[strTrimmed] or color
|
||||||
|
end
|
||||||
|
isColorMarkup = type(EID.InlineColors[strTrimmed]) ~= type(nil)
|
||||||
end
|
end
|
||||||
return EID.InlineColors[strTrimmed] or baseKColor
|
|
||||||
else
|
|
||||||
return baseKColor
|
|
||||||
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(
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
Reference in new issue
Block a user