Skip to content

Commit

Permalink
Naive fix for TextLayout TopLeft
Browse files Browse the repository at this point in the history
  • Loading branch information
Denneisk committed Nov 18, 2023
1 parent 872272c commit fbf4cfe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/entities/gmod_wire_egp/lib/objects/textlayout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,21 @@ function Obj:Draw(ent, drawMat)

if (not self.layouter) then self.layouter = MakeTextScreenLayouter() end

local w, h = self.w, self.h
local x, y = self.x - w / 2, self.y - h / 2

if self.angle == 0 then
self.layouter:DrawText(self.text, self.x, self.y, self.w, self.h, self.halign, self.valign)
self.layouter:DrawText(self.text, x, y, w, h, self.halign, self.valign)
else
mat:Set(drawMat)

mat:Translate(Vector(self.x, self.y, 0))
mat:Translate(Vector(x, y, 0))

matAng.y = -self.angle
mat:Rotate(matAng)

cam_PushModelMatrix(mat, true)
self.layouter:DrawText(self.text, 0, 0, self.w, self.h, self.halign, self.valign)
self.layouter:DrawText(self.text, 0, 0, w, h, self.halign, self.valign)
cam_PopModelMatrix()
end

Expand Down

0 comments on commit fbf4cfe

Please sign in to comment.