• How to make HUD scale to text?
    6 replies, posted
I am sorry for posting so many question lately, but I am really trying to learn this, so my questions is: How do you make it so when you are making a HUD and for example you have a RPNAME, I want the HUD to scale with the Name so if It is a big name then the HUD will just scale to it, and will not look bad when a name is long. Thanks for Reading
Actually I now have something like this:     -- Bars for all Desc.     local message1 = LocalPlayer():getDarkRPVar("rpname")     draw.RoundedBox(0, 613, 5,surface.GetTextSize(message1) + 16, 25,Color(255,255,255,255))     draw.SimpleText(LocalPlayer():getDarkRPVar( "rpname" ),"CloseCaption_Bold",620, 4, Color(0,0,0,255))     local message = LocalPlayer():getDarkRPVar("job")     draw.RoundedBox(0, 748, 5, surface.GetTextSize(message) + 13, 25,Color(255,255,255,255))     draw.SimpleText(LocalPlayer():getDarkRPVar( "job" ),"CloseCaption_Bold",755, 4, Color(0,0,0,255)) which does what I want it to, but in result when the text is to big the HUD scales to big, so now the question is how do I make a statement saying that if there is a certain amount of width then stop drawing the HUD?
Sorry a lot of posts but just to make sure you get what is trying to happen: Screenshot That is what it looks like and what is need to happen is that the rpname on the HUD, if it is too big everything should shift over to the right in order to keep it neat.
surface.GetTextSize returns 2 arguments, width & height. Make sure to use surface.SetFont if you aren't already local width, height = surface.GetTextSize( "string" )
Where do I put that, with this code:     draw.RoundedBox(0,0,0,ScrW(), 35, Color(20,20,20,250))     draw.RoundedBox(0,0,35,ScrW(), 3, Color(255,0,0,250))     draw.SimpleText(OGL.ServerNameOnHud,"CloseCaption_Bold",ScrW() - 180, 5, OGL.ServerNameColor)     surface.SetDrawColor(255,255,255)     surface.SetMaterial(NameMaterial)     surface.DrawTexturedRect(-2,-4,45,45)     draw.SimpleText(LocalPlayer():getDarkRPVar("rpname"),"TheDefaultSettings",surface.GetTextSize(message) - 30,7,Color(255,255,255,255))     surface.SetDrawColor(255,255,255)     surface.SetMaterial(JobMaterial)     surface.DrawTexturedRect(155,-4,45,45)     draw.SimpleText(LocalPlayer():getDarkRPVar("job"),"TheDefaultSettings",200,7,Color(255,255,255,255))
please does someone know?
Tip : if you want to spend more time designing a nice hud instead of trying to scale it, just make sure it fits in an 800x600 display. Simply use ScrW & ScrH to always keep the hud a certain amount of pixels away from the end.
Sorry, you need to Log In to post a reply to this thread.