Skip to content

Update textlib.lua #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions [gamemodes]/[race]/[addons]/race_delay_indicator/textlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local visibleText = {}
------
defaults = {
fX = 0.5,
fY = 0.5,
fY = 0.9,
bRelativePosition = true,
strText = "",
bVerticalAlign = "center",
Expand All @@ -20,6 +20,7 @@ defaults = {
bClip = false,
bWordWrap = true,
bVisible = false,
bColorCode = true,
tBoundingBox = false, --If a bounding box is not set, it will not be used.
bRelativeBoundingBox = true,
}
Expand Down Expand Up @@ -150,6 +151,12 @@ function dxText:wordWrap(bool)
return true
end

function dxText:colorCode(bool)
if type(bool) ~= "boolean" then return self.bColorCode end
self.bColorCode = bool
return true
end

function dxText:type(type,...)
if not validTypes[type] then return self.strType, unpack(self.tAttributes) end
self.strType = type
Expand Down Expand Up @@ -184,7 +191,7 @@ function dxText:boundingBox(left,top,right,bottom,relative)
return true
end

addEventHandler ( "onClientRender", root,
addEventHandler ( "onClientRender", getRootElement(),
function()
for self,_ in pairs(visibleText) do
while true do
Expand Down Expand Up @@ -247,7 +254,7 @@ addEventHandler ( "onClientRender", root,
for offsetX=-outlinesize,outlinesize,outlinesize do
for offsetY=-outlinesize,outlinesize,outlinesize do
if not (offsetX == 0 and offsetY == 0) then
dxDrawText(self.strText, l + offsetX, t + offsetY, r + offsetX, b + offsetY, tocolor(att2, att3, att4, att5), self.fScale, self.strFont, self.bHorizontalAlign, self.bVerticalAlign, self.bClip, self.bWordWrap, self.bPostGUI )
dxDrawText(string.gsub(self.strText, "#%x%x%x%x%x%x", ""), l + offsetX, t + offsetY, r + offsetX, b + offsetY, tocolor(att2, att3, att4, att5), self.fScale, self.strFont, self.bHorizontalAlign, self.bVerticalAlign, self.bClip, self.bWordWrap, self.bPostGUI )
end
end
end
Expand All @@ -258,17 +265,17 @@ addEventHandler ( "onClientRender", root,
att3 = att3 or 0
att4 = att4 or 0
att5 = att5 or self.tColor[4]
dxDrawText(self.strText, l + shadowDist, t + shadowDist, r + shadowDist, b + shadowDist, tocolor(att2, att3, att4, att5), self.fScale, self.strFont, self.bHorizontalAlign, self.bVerticalAlign, self.bClip, self.bWordWrap, self.bPostGUI )
dxDrawText(string.gsub(self.strText, "#%x%x%x%x%x%x", ""), l + shadowDist, t + shadowDist, r + shadowDist, b + shadowDist, tocolor(att2, att3, att4, att5), self.fScale, self.strFont, self.bHorizontalAlign, self.bVerticalAlign, self.bClip, self.bWordWrap, self.bPostGUI )
end
dxDrawText ( self.strText, l, t, r, b, tocolor(unpack(self.tColor)), self.fScale, self.strFont, self.bHorizontalAlign, self.bVerticalAlign, self.bClip, self.bWordWrap, self.bPostGUI )
dxDrawText ( self.strText, l, t, r, b, tocolor(unpack(self.tColor)), self.fScale, self.strFont, self.bHorizontalAlign, self.bVerticalAlign, self.bClip, self.bWordWrap, self.bPostGUI, self.bColorCode )
break
end
end
end
)

if addEvent ( "updateDisplays", true ) then
addEventHandler ( "updateDisplays", root,
addEventHandler ( "updateDisplays", getRootElement(),
function(self)
setmetatable( self, dxText_mt )
--Remove any old ones with the same id
Expand Down