Permalink
Browse files

Update draw.lua

Fix retvals for draw.SimpleText and add retvals for draw.SimpleTextOutlined
  • Loading branch information...
1 parent 1bd8973 commit 83053f27f65a4a3c05c9d1f64cefd1e952122875 @robotboy655 robotboy655 committed Apr 19, 2014
Showing with 5 additions and 11 deletions.
  1. +5 −11 garrysmod/lua/includes/modules/draw.lua
@@ -68,26 +68,20 @@ function SimpleText(text, font, x, y, colour, xalign, yalign)
y = y or 0
xalign = xalign or TEXT_ALIGN_LEFT
yalign = yalign or TEXT_ALIGN_TOP
- local w, h = 0, 0
- surface.SetFont(font)
+ surface.SetFont(font)
+ local w, h = surface.GetTextSize( text )
+
if (xalign == TEXT_ALIGN_CENTER) then
- w, h = surface.GetTextSize( text )
x = x - w/2
elseif (xalign == TEXT_ALIGN_RIGHT) then
- w, h = surface.GetTextSize( text )
x = x - w
end
if (yalign == TEXT_ALIGN_CENTER) then
- w, h = surface.GetTextSize( text )
y = y - h/2
-
elseif ( yalign == TEXT_ALIGN_BOTTOM ) then
-
- w, h = surface.GetTextSize( text );
- y = y - h;
-
+ y = y - h
end
surface.SetTextPos( math.ceil( x ), math.ceil( y ) );
@@ -123,7 +117,7 @@ function SimpleTextOutlined(text, font, x, y, colour, xalign, yalign, outlinewid
end
end
- SimpleText(text, font, x, y, colour, xalign, yalign)
+ return SimpleText(text, font, x, y, colour, xalign, yalign)
end

0 comments on commit 83053f2

Please sign in to comment.