我尝试从this教程制作Garry's Mod的聊天框,但我不明白。有人可以教我还是给我榜样?我想制作我的平视显示器包,而我只需要聊天框即可。
这是我的聊天框,它打印从DTextEntry聊天的文本
surface.CreateFont("ch1",{font="Roboto",size=15})
local plyname = LocalPlayer():Name()
chatframe = vgui.Create("DFrame")
chatframe:SetSize(400,250)
chatframe:SetPos(ScrW() - 400,ScrH() - 250)
chatframe:SetDraggable(true)
chatframe:ShowCloseButton(true)
chatframe:SetTitle("")
chatframe.Paint = function(self,w,h)
draw.RoundedBox(0, 0, 0, w, h,Color(70,70,70))
draw.RoundedBox(0, 0, 0, w, 25,Color(66, 179, 245))
draw.RoundedBox(0, 5, 5, 3, 15,color_white)
draw.RoundedBox(0, 10, 5, 3, 15,color_white)
draw.SimpleText(plyname,"ch1" , 15, 5,color_white,TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP)
end
chatframe:MakePopup()
local textbox = vgui.Create("DTextEntry",chatframe)
textbox:SetPos(5,225)
textbox:SetSize(390,20)
textbox:SetText("")
textbox:SetTextColor(color_white)
textbox.Paint = function(self,w,h)
draw.RoundedBox(0, 0, 0, w, h,Color(66, 179, 245))
draw.SimpleText(self:GetValue(),"ch1" , 5, textbox:GetTall() / 2,color_white,TEXT_ALIGN_LEFT,TEXT_ALIGN_CENTER)
end
textbox.OnEnter = function(self)
RunConsoleCommand("say", self:GetValue())
textbox:SetText("")
end
local richtextbox = vgui.Create("RichText",chatframe)
richtextbox:SetPos(0,25)
richtextbox:SetSize(400, 200)