Skip to content

Commit

Permalink
Fixes ply:IsTyping
Browse files Browse the repository at this point in the history
  • Loading branch information
BadgerCode committed Jul 2, 2019
1 parent d38bd71 commit bd4dc3f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions emojichat/lua/autorun/emoji-chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ if SERVER then
AddCSLuaFile("emojichat/cl_text-component.lua")
AddCSLuaFile("emojichat/cl_util.lua")

AddCSLuaFile("emojichat/sh_chat-overrides.lua")

include("emojichat/sv_chat.lua")
include("emojichat/sh_chat-overrides.lua")
elseif CLIENT then
include("emojichat/cl_echat.lua")

Expand All @@ -25,4 +28,6 @@ elseif CLIENT then
include("emojichat/cl_chat-overrides.lua")
include("emojichat/cl_hooks.lua")
include("emojichat/cl_html-chat-callbacks.lua")

include("emojichat/sh_chat-overrides.lua")
end
3 changes: 2 additions & 1 deletion emojichat/lua/emojichat/cl_chat-overrides.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local oldAddText = chat.AddText

function chat.AddText(...)
eChat.AddLine(TextComponentBuilder.Build(...))
oldAddText(...)
Expand All @@ -7,4 +8,4 @@ end
chat.Open = eChat.showBox
chat.Close = eChat.hideBox
chat.GetChatBoxPos = function() return eChat.frame:GetPos() end
chat.GetChatBoxSize = function() return eChat.frame:GetSize() end
chat.GetChatBoxSize = function() return eChat.frame:GetSize() end
16 changes: 15 additions & 1 deletion emojichat/lua/emojichat/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function eChat.hideBox()
end

eChat.HTMLOutput:SetInactive()
eChat.StopTyping()

local children = eChat.frame:GetChildren()
for _, pnl in pairs( children ) do
Expand Down Expand Up @@ -103,6 +104,7 @@ function eChat.showBox(mode)
end

eChat.HTMLOutput:SetActive(mode)
eChat.StartTyping()

local children = eChat.frame:GetChildren()
for _, pnl in pairs( children ) do
Expand All @@ -115,7 +117,7 @@ function eChat.showBox(mode)
eChat.chatLog:RequestFocus()

eChat.Active = true
hook.Run("StartChat")
hook.Run("StartChat", eChat.ChatMode == CHATMODE_TEAM)
end

function eChat.AddLine(textComponents)
Expand All @@ -137,3 +139,15 @@ function eChat.UpdateFadeTime(durationInSeconds)

eChat.HTMLOutput:UpdateFadeTime(eChat.config.fadeTime)
end

function eChat.StartTyping()
net.Start("SetTypingStatus")
net.WriteBool(true)
net.SendToServer()
end

function eChat.StopTyping()
net.Start("SetTypingStatus")
net.WriteBool(false)
net.SendToServer()
end
5 changes: 5 additions & 0 deletions emojichat/lua/emojichat/sh_chat-overrides.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
local meta = FindMetaTable( "Player" )

function meta:IsTyping()
return self:GetNWBool("IsTyping")
end
8 changes: 7 additions & 1 deletion emojichat/lua/emojichat/sv_chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ hook.Add("PlayerInitialSpawn", "echat_playerinitialspawn", function(ply)
ply:ChatPrint(ply:Nick() .. " has joined the server.")
end)


hook.Remove("PlayerDisconnected", "echat_playerdisconnected")
hook.Add("PlayerDisconnected", "echat_playerdisconnected", function(ply)
PrintMessage(HUD_PRINTTALK, ply:Nick() .. " has left the server.")
end)


util.AddNetworkString("SetTypingStatus")
net.Receive("SetTypingStatus", function(len, ply)
local isTyping = net.ReadBool()
ply:SetNWBool("IsTyping", isTyping)
end)

0 comments on commit bd4dc3f

Please sign in to comment.