Add text length limit to egp objects (#3269)

This commit is contained in:
thegrb93 2025-02-18 14:52:36 -05:00 committed by GitHub
parent dbed3cf164
commit 03162ba839
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -174,6 +174,7 @@ end
-------------------------------------------------------- --------------------------------------------------------
e2function egpobject wirelink:egpText( number index, string text, vector2 pos ) e2function egpobject wirelink:egpText( number index, string text, vector2 pos )
if (!EGP:IsAllowed( self, this )) then return NULL_EGPOBJECT end if (!EGP:IsAllowed( self, this )) then return NULL_EGPOBJECT end
if #text>256 then text = string.sub(text, 1, 256) end
local bool, obj = egp_create("Text", { index = index, text = text, x = pos[1], y = pos[2] }, this) local bool, obj = egp_create("Text", { index = index, text = text, x = pos[1], y = pos[2] }, this)
if (bool) then EGP:DoAction( this, self, "SendObject", obj ) Update(self,this) end if (bool) then EGP:DoAction( this, self, "SendObject", obj ) Update(self,this) end
return obj return obj
@ -181,6 +182,7 @@ end
e2function egpobject wirelink:egpTextLayout( number index, string text, vector2 pos, vector2 size ) e2function egpobject wirelink:egpTextLayout( number index, string text, vector2 pos, vector2 size )
if (!EGP:IsAllowed( self, this )) then return NULL_EGPOBJECT end if (!EGP:IsAllowed( self, this )) then return NULL_EGPOBJECT end
if #text>256 then text = string.sub(text, 1, 256) end
local bool, obj = egp_create("TextLayout", { index = index, text = text, x = pos[1], y = pos[2], w = size[1], h = size[2] }, this) local bool, obj = egp_create("TextLayout", { index = index, text = text, x = pos[1], y = pos[2], w = size[1], h = size[2] }, this)
if (bool) then EGP:DoAction( this, self, "SendObject", obj ) Update(self,this) end if (bool) then EGP:DoAction( this, self, "SendObject", obj ) Update(self,this) end
return obj return obj
@ -193,6 +195,7 @@ __e2setcost(10)
---------------------------- ----------------------------
e2function void wirelink:egpSetText( number index, string text ) e2function void wirelink:egpSetText( number index, string text )
if (!EGP:IsAllowed( self, this )) then return end if (!EGP:IsAllowed( self, this )) then return end
if #text>256 then text = string.sub(text, 1, 256) end
local bool, k, v = hasObject(this, index) local bool, k, v = hasObject(this, index)
if (bool) then if (bool) then
if v:EditObject({ text = text }) then EGP:DoAction( this, self, "SendObject", v ) Update(self,this) end if v:EditObject({ text = text }) then EGP:DoAction( this, self, "SendObject", v ) Update(self,this) end