Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Entry patch #2724

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions lua/entities/gmod_wire_textentry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if CLIENT then
end,
"Enter","Cancel"
)
panel:SetBackgroundBlur(false)
stepa2 marked this conversation as resolved.
Show resolved Hide resolved
end)

net.Receive( "wire_textentry_kick", function()
Expand Down Expand Up @@ -77,10 +78,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()
Expand Down Expand Up @@ -164,23 +171,36 @@ 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)

local ENTERED_DISABLE_DELAY = 0.1

function ENT:OnTextEntered(text)
WireLib.TriggerOutput( self, "Text", text )
WireLib.TriggerOutput( self, "Entered", 1 )

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()
stepa2 marked this conversation as resolved.
Show resolved Hide resolved
if IsValid( self ) then
stepa2 marked this conversation as resolved.
Show resolved Hide resolved
WireLib.TriggerOutput( self, "User", nil )
WireLib.TriggerOutput( self, "Text", "" )
end
end)
end

timer.Create(timername.."_disable_entered", ENTERED_DISABLE_DELAY, 1, function()
WireLib.TriggerOutput( self, "Entered", 0 )
end)
stepa2 marked this conversation as resolved.
Show resolved Hide resolved
end

----------------------------------------------------
-- Prompt
-- Sends prompt to user etc
Expand Down