From fbf4cfeba0e3d5ee79ae3327d9a464f50ef00898 Mon Sep 17 00:00:00 2001 From: Denneisk <20892685+Denneisk@users.noreply.github.com> Date: Fri, 17 Nov 2023 22:27:17 -0500 Subject: [PATCH] Naive fix for TextLayout TopLeft --- lua/entities/gmod_wire_egp/lib/objects/textlayout.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/entities/gmod_wire_egp/lib/objects/textlayout.lua b/lua/entities/gmod_wire_egp/lib/objects/textlayout.lua index 82b694c6af..e0216a5edd 100644 --- a/lua/entities/gmod_wire_egp/lib/objects/textlayout.lua +++ b/lua/entities/gmod_wire_egp/lib/objects/textlayout.lua @@ -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