local Roact = require(game:GetService("ReplicatedStorage"):WaitForChild("Roact"))
local RobloxChatGui = Roact.Component:extend("RobloxChatGui")
function RobloxChatGui:init()
self.props.Signals = {
TextBoxFocusLost = Instance.new("BindableEvent"),
OnAnyHover = Instance.new("BindableEvent")
}
self.state = {
EntireChatVisible = true,
ChatBarVisible = true,
GlobalTransparency = 0.6
}
end
function RobloxChatGui:render()
local ScreenGui = Roact.createElement("ScreenGui", {
Enabled = self.state.EntireChatVisible,
ResetOnSpawn = false,
DisplayOrder = 6 --actual display order used by lua chat system
}, {
MasterFrame = Roact.createElement("Frame", {
Name = "MasterFrame",
BackgroundTransparency = 1,
Size = UDim2.new(0.3, 0, 0.292, 0),
Visible = true,
[Roact.Event.MouseEnter] = function ()
self.props.Signals.OnAnyHover:Fire()
end,
[Roact.Event.MouseMoved] = function ()
self.props.Signals.OnAnyHover:Fire()
end
}, {
ChatBarFrame = Roact.createElement("Frame", {
BackgroundColor3 = Color3.fromRGB(0, 0, 0),
BackgroundTransparency = self.state.GlobalTransparency,
Visible = self.state.ChatbarVisible,
Position = UDim2.new(0, 0, 1, -42),
Size = UDim2.new(1, 0, 0, 42),
BorderSizePixel = 0,
[Roact.Event.MouseEnter] = function ()
self.props.Signals.OnAnyHover:Fire()
end,
[Roact.Event.MouseMoved] = function ()
self.props.Signals.OnAnyHover:Fire()
end
}, {
BoxFrame = Roact.createElement("Frame", {
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
Visible = true,
Position = UDim2.new(0, 7, 0, 7),
Size = UDim2.new(1, -14, 1, -14),
BackgroundTransparency = self.state.GlobalTransparency,
BorderSizePixel = 0,
[Roact.Event.MouseEnter] = function ()
self.props.Signals.OnAnyHover:Fire()
end,
[Roact.Event.MouseMoved] = function ()
self.props.Signals.OnAnyHover:Fire()
end
}, {
ChatBar = Roact.createElement("TextBox", {
BackgroundTransparency = 1,
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.new(0.5, 0, 0.5, 0),
Size = UDim2.new(1, -10, 1, -10),
SelectionStart = -1,
Visible = true,
PlaceholderColor3 = Color3.new(0, 0, 0),
PlaceholderText = "To chat click here or press '/' key",
FontFace = Font.fromEnum(Enum.Font.SourceSansBold),
LineHeight = 1,
TextSize = 18,
TextTransparency = 0.4,
TextXAlignment = Enum.TextXAlignment.Left,
TextYAlignment = Enum.TextYAlignment.Top,
TextEditable = true,
ClearTextOnFocus = false,
Text = "",
TextColor3 = Color3.fromRGB(27, 42, 53),
TextWrapped = true,
[Roact.Event.FocusLost] = function (...)
self.props.Signals.TextBoxFocusLost:Fire(...)
end,
[Roact.Event.MouseEnter] = function ()
self.props.Signals.OnAnyHover:Fire()
end,
[Roact.Event.MouseMoved] = function ()
self.props.Signals.OnAnyHover:Fire()
end
})
})
}),
ChatChannel = Roact.createElement("Frame", {
BackgroundColor3 = Color3.fromRGB(0, 0, 0),
BackgroundTransparency = self.state.GlobalTransparency,
BorderColor3 = Color3.fromRGB(27, 42, 53),
Position = UDim2.new(0, 0, 0, 2),
Size = UDim2.new(1, 0, 1, -46),
Visible = true,
BorderSizePixel = 0,
[Roact.Event.MouseEnter] = function ()
self.props.Signals.OnAnyHover:Fire()
end,
[Roact.Event.MouseMoved] = function ()
self.props.Signals.OnAnyHover:Fire()
end
}, {
Scroller = Roact.createElement("ScrollingFrame", {
Position = UDim2.new(0, 0, 0, 3),
Size = UDim2.new(1, -4, 1, -6),
Visible = true,
CanvasSize = UDim2.new(0, 0, 0, 18),
BorderSizePixel = 0,
BackgroundTransparency = 1,
[Roact.Event.MouseEnter] = function ()
self.props.Signals.OnAnyHover:Fire()
end,
[Roact.Event.MouseMoved] = function ()
self.props.Signals.OnAnyHover:Fire()
end
}, {
UIListLayout = Roact.createElement("UIListLayout", {
Padding = UDim.new(0, 0),
Name = "UIListLayout",
FillDirection = Enum.FillDirection.Vertical,
SortOrder = Enum.SortOrder.LayoutOrder,
VerticalAlignment = Enum.VerticalAlignment.Top
})
})
})
})
})
return ScreenGui
end
return function(PlayerToMountTo:Player)
local Element = Roact.createElement(RobloxChatGui)
local Handle = Roact.mount(Element, PlayerToMountTo.PlayerGui, "RobloxChatGui")
return {Element = Element, Handle = Handle}
end