mirror of
https://github.com/wiremod/wire.git
synced 2025-03-04 03:03:04 -05:00
Text Entry patch (#2724)
* Added 'Entered' boolean output to Text Entry * Disabled background blur on Text Entry * Text Entry fix * More patches * Hold timer will be removed on text entry entity removal
This commit is contained in:
parent
47682de595
commit
269b3b942c
@ -20,7 +20,7 @@ if CLIENT then
|
||||
net.Receive("wire_textentry_show",function()
|
||||
local self=net.ReadEntity()
|
||||
if not IsValid(self) then return end
|
||||
panel = Derma_StringRequest(
|
||||
panel = Derma_StringRequestNoBlur(
|
||||
"Wire Text Entry",
|
||||
"Enter text below",
|
||||
"",
|
||||
@ -50,11 +50,23 @@ if CLIENT then
|
||||
return
|
||||
end
|
||||
|
||||
function ENT:GetHoldClamped()
|
||||
return math.max(self:GetHold(), 0)
|
||||
end
|
||||
|
||||
function ENT:GetHoldTimerName()
|
||||
return "wire_textentry_" .. self:EntIndex()
|
||||
end
|
||||
|
||||
function ENT:RemoveHoldTimer()
|
||||
timer.Remove(self:GetHoldTimerName())
|
||||
end
|
||||
|
||||
----------------------------------------------------
|
||||
-- UpdateOverlay
|
||||
----------------------------------------------------
|
||||
function ENT:UpdateOverlay()
|
||||
local hold = math.Round(math.max(self:GetHold(),0),1)
|
||||
local hold = math.Round(self:GetHoldClamped(),1)
|
||||
local txt = "Hold Length: " .. (hold > 0 and hold or "Forever")
|
||||
|
||||
if self.BlockInput then
|
||||
@ -77,10 +89,16 @@ function ENT:Initialize()
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
|
||||
self.Inputs=WireLib.CreateInputs(self,{"Block Input (When set to a non-zero value, blocks any further inputs.)","Prompt (When set to a non-zero value, opens the prompt popup for the driver of the linked vehicle.\nIf no vehicle is linked, opens the prompt for the owner of this entity instead.)"})
|
||||
self.Outputs=WireLib.CreateOutputs(self,{"In Use","Text [STRING]","User [ENTITY]"})
|
||||
self.Inputs=WireLib.CreateInputs(self,{
|
||||
"Block Input (When set to a non-zero value, blocks any further inputs.)",
|
||||
"Prompt (When set to a non-zero value, opens the prompt popup for the driver of the linked vehicle.\n"
|
||||
.."If no vehicle is linked, opens the prompt for the owner of this entity instead.)"})
|
||||
self.Outputs=WireLib.CreateOutputs(self,{
|
||||
"In Use","Text [STRING]","User [ENTITY]",
|
||||
"Entered (Set to 1 for a bit when text is successfully entered)"
|
||||
})
|
||||
|
||||
self.BlockInput=false
|
||||
self.BlockInput = false
|
||||
self.NextPrompt = 0
|
||||
|
||||
self:UpdateOverlay()
|
||||
@ -146,6 +164,8 @@ function ENT:OnRemove()
|
||||
self.Vehicle.WireTextEntry = nil
|
||||
end
|
||||
|
||||
self:RemoveHoldTimer()
|
||||
|
||||
self:Unprompt( true )
|
||||
end
|
||||
|
||||
@ -164,23 +184,31 @@ net.Receive("wire_textentry_action",function(len,ply)
|
||||
self:Unprompt() -- in all cases, make text entry available for use again
|
||||
|
||||
if ok and not self.BlockInput then
|
||||
WireLib.TriggerOutput( self, "Text", text )
|
||||
self:OnTextEntered(text)
|
||||
|
||||
local timername = "wire_textentry_" .. self:EntIndex()
|
||||
timer.Remove( timername )
|
||||
if math.max(self:GetHold(),0) > 0 then
|
||||
timer.Create( timername, math.max(self:GetHold(),0), 1, function()
|
||||
if IsValid( self ) then
|
||||
WireLib.TriggerOutput( self, "User", nil )
|
||||
WireLib.TriggerOutput( self, "Text", "" )
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self:UpdateOverlay()
|
||||
end)
|
||||
|
||||
function ENT:OnTextEntered(text)
|
||||
WireLib.TriggerOutput( self, "Text", text )
|
||||
WireLib.TriggerOutput( self, "Entered", 1 )
|
||||
WireLib.TriggerOutput( self, "Entered", 0 )
|
||||
|
||||
local timername = self:GetHoldTimerName()
|
||||
timer.Remove( timername )
|
||||
if self:GetHoldClamped() > 0 then
|
||||
timer.Create( timername, self:GetHoldClamped(), 1, function()
|
||||
if not self:IsValid() then return end
|
||||
|
||||
WireLib.TriggerOutput( self, "User", nil )
|
||||
WireLib.TriggerOutput( self, "Text", "" )
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------
|
||||
-- Prompt
|
||||
-- Sends prompt to user etc
|
||||
@ -201,8 +229,7 @@ function ENT:Prompt( ply )
|
||||
WireLib.TriggerOutput( self, "User", ply )
|
||||
WireLib.TriggerOutput( self, "In Use", 1 )
|
||||
|
||||
local timername = "wire_textentry_" .. self:EntIndex()
|
||||
timer.Remove( timername )
|
||||
self:RemoveHoldTimer()
|
||||
|
||||
net.Start( "wire_textentry_show" )
|
||||
net.WriteEntity( self )
|
||||
@ -226,8 +253,7 @@ function ENT:Unprompt( kickuser )
|
||||
net.Start( "wire_textentry_kick" ) net.Send( self.User )
|
||||
end
|
||||
|
||||
local timername = "wire_textentry_" .. self:EntIndex()
|
||||
timer.Remove( timername )
|
||||
self:RemoveHoldTimer()
|
||||
|
||||
self.User = nil
|
||||
WireLib.TriggerOutput( self, "In Use", 0 )
|
||||
|
Loading…
Reference in New Issue
Block a user