Нужно как то сделать, чтобы большие имена и профессии не залазили на другие части худа. Как это починить?
Код Имени
Lua:
local playerName = LocalPlayer():Nick()
local nameIconSize = ScrH() * 0.037
local nameLogo = Material("materials/name.png", "noclamp smooth")
local nameTextWidth = surface.GetTextSize(playerName)
local nameWindowWidth = math.max(nameTextWidth + 10 + nameIconSize, ScrW() * 0.08378)
-- draw black background box
draw.RoundedBox(5, ScrW() * 0.09 - nameWindowWidth/1, ScrH() * 0.7975, nameWindowWidth, nameIconSize, Color(0, 0, 0, 200))
surface.SetMaterial(nameLogo)
surface.SetDrawColor(color_white)
surface.DrawTexturedRect(ScrW() * 0.05 - nameWindowWidth/2 + 5, ScrH() * 0.7975 + 5, nameIconSize - 10, nameIconSize - 10)
-- draw name text
draw.DrawText(playerName, "Font HUD", ScrW() * 0.05 + nameIconSize/2, ScrH() * 0.79890, Color(255, 255, 255), TEXT_ALIGN_CENTER)
Код Работы
local jobIconSize = ScrH() * 0.037
local jobLogo = Material("materials/job.png", "noclamp smooth")
local jobText = LocalPlayer():getDarkRPVar("job")
local jobTextWidth = surface.GetTextSize(jobText)
local jobTextWidthMax = ScrW() * 0.08378 - jobIconSize - 1 -- максимальная ширина текста
local jobWindowWidth = math.min(jobTextWidthMax, jobTextWidth) + jobIconSize + 10 -- ширина окна
-- draw black background box
draw.RoundedBox(5, ScrW() * 0.15 - jobWindowWidth/2, ScrH() * 0.7975, jobWindowWidth, jobIconSize, Color(0, 0, 0, 200))
-- draw job icon
surface.SetMaterial(jobLogo)
surface.SetDrawColor(color_white)
surface.DrawTexturedRect(ScrW() * 0.15 - jobWindowWidth/2 + 5, ScrH() * 0.7975 + 5, jobIconSize - 10, jobIconSize - 10)
-- draw job text
local textX = ScrW() * 0.15 - jobWindowWidth/2 + jobIconSize + 10
local textY = ScrH() * 0.8000
local textColor = Color(255, 255, 255)
local font = "Font HUD"
local alignment = TEXT_ALIGN_LEFT
if jobTextWidth > jobTextWidthMax then
textX = ScrW() * 0.15 + jobIconSize/2
alignment = TEXT_ALIGN_CENTER
end
draw.DrawText(jobText, font, textX, textY, textColor, alignment)