plugin: Title bar in session window, clean up Config

This commit is contained in:
Lucien Greathouse
2019-01-04 18:23:07 -08:00
parent 1888c83b6e
commit c57989a790
2 changed files with 175 additions and 148 deletions

View File

@@ -1,5 +1,7 @@
local Roact = require(script:FindFirstAncestor("Rojo").Roact) local Roact = require(script:FindFirstAncestor("Rojo").Roact)
local Config = require(script.Parent.Parent.Config)
local FitList = require(script.Parent.FitList) local FitList = require(script.Parent.FitList)
local FitText = require(script.Parent.FitText) local FitText = require(script.Parent.FitText)
@@ -14,8 +16,8 @@ function ConnectPanel:init()
self.labelSize, self.setLabelSize = Roact.createBinding(Vector2.new()) self.labelSize, self.setLabelSize = Roact.createBinding(Vector2.new())
self:setState({ self:setState({
address = "localhost", address = Config.defaultHost,
port = "34872", port = Config.defaultPort,
}) })
end end
@@ -44,175 +46,199 @@ function ConnectPanel:render()
Position = UDim2.new(0.5, 0, 0, 0), Position = UDim2.new(0.5, 0, 0, 0),
AnchorPoint = Vector2.new(0.5, 0), AnchorPoint = Vector2.new(0.5, 0),
}, },
layoutProps = {
Padding = UDim.new(0, 8),
},
paddingProps = {
PaddingTop = UDim.new(0, 8),
PaddingBottom = UDim.new(0, 8),
PaddingLeft = UDim.new(0, 8),
PaddingRight = UDim.new(0, 8),
},
}, { }, {
Address = e(FitList, { Title = e("TextLabel", {
containerProps = { LayoutOrder = 1,
LayoutOrder = 1, Font = Enum.Font.SourceSans,
BackgroundTransparency = 1, TextSize = 22,
}, Text = "Start Rojo Session",
layoutProps = { Size = UDim2.new(1, 0, 0, 28),
FillDirection = Enum.FillDirection.Horizontal, BackgroundTransparency = 1,
Padding = UDim.new(0, 8), TextColor3 = Color3.new(1, 1, 1),
},
}, { }, {
Label = e(FitText, { BottomBorder = e("Frame", {
MinSize = Vector2.new(0, 24), BorderSizePixel = 0,
Kind = "TextLabel", BackgroundColor3 = Color3.fromRGB(48, 48, 48),
LayoutOrder = 1, Size = UDim2.new(1, 0, 0, 1),
BackgroundTransparency = 1, Position = UDim2.new(0, 0, 1, -1),
TextXAlignment = Enum.TextXAlignment.Left,
Font = Enum.Font.SourceSans,
TextSize = FORM_TEXT_SIZE,
Text = "Address",
TextColor3 = Color3.fromRGB(245, 245, 245),
[Roact.Change.AbsoluteSize] = function(rbx)
self:updateLabelSize("address", rbx.AbsoluteSize)
end,
}, {
Sizing = e("UISizeConstraint", {
MinSize = self.labelSize,
}),
}),
InputOuter = e("Frame", {
LayoutOrder = 2,
Size = UDim2.new(0, 300, 0, 24),
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
BorderColor3 = Color3.fromRGB(64, 64, 64),
}, {
InputInner = e("TextBox", {
BackgroundTransparency = 1,
Size = UDim2.new(1, -8, 1, -8),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
Font = Enum.Font.SourceSans,
ClearTextOnFocus = false,
TextXAlignment = Enum.TextXAlignment.Left,
TextSize = FORM_TEXT_SIZE,
Text = self.state.address,
TextColor3 = Color3.fromRGB(245, 245, 245),
[Roact.Change.Text] = function(rbx)
self:setState({
address = rbx.Text,
})
end,
}),
}), }),
}), }),
Port = e(FitList, { Body = e(FitList, {
containerProps = { containerProps = {
LayoutOrder = 2,
BackgroundTransparency = 1, BackgroundTransparency = 1,
LayoutOrder = 2,
}, },
layoutProps = { layoutProps = {
FillDirection = Enum.FillDirection.Horizontal,
Padding = UDim.new(0, 8), Padding = UDim.new(0, 8),
}, },
paddingProps = {
PaddingTop = UDim.new(0, 8),
PaddingBottom = UDim.new(0, 8),
PaddingLeft = UDim.new(0, 8),
PaddingRight = UDim.new(0, 8),
},
}, { }, {
Label = e(FitText, { Address = e(FitList, {
MinSize = Vector2.new(0, 24), containerProps = {
Kind = "TextLabel", LayoutOrder = 1,
LayoutOrder = 1, BackgroundTransparency = 1,
BackgroundTransparency = 1, },
TextXAlignment = Enum.TextXAlignment.Left, layoutProps = {
Font = Enum.Font.SourceSans, FillDirection = Enum.FillDirection.Horizontal,
TextSize = FORM_TEXT_SIZE, Padding = UDim.new(0, 8),
Text = "Port", },
TextColor3 = Color3.fromRGB(245, 245, 245), }, {
Label = e(FitText, {
[Roact.Change.AbsoluteSize] = function(rbx) MinSize = Vector2.new(0, 24),
self:updateLabelSize("port", rbx.AbsoluteSize) Kind = "TextLabel",
end, LayoutOrder = 1,
}, {
Sizing = e("UISizeConstraint", {
MinSize = self.labelSize,
}),
}),
InputOuter = e("Frame", {
LayoutOrder = 2,
Size = UDim2.new(0, 300, 0, 24),
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
BorderColor3 = Color3.fromRGB(64, 64, 64),
}, {
InputInner = e("TextBox", {
BackgroundTransparency = 1, BackgroundTransparency = 1,
Size = UDim2.new(1, -8, 1, -8),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
Font = Enum.Font.SourceSans,
ClearTextOnFocus = false,
TextXAlignment = Enum.TextXAlignment.Left, TextXAlignment = Enum.TextXAlignment.Left,
Font = Enum.Font.SourceSans,
TextSize = FORM_TEXT_SIZE, TextSize = FORM_TEXT_SIZE,
Text = self.state.port, Text = "Address",
TextColor3 = Color3.fromRGB(245, 245, 245), TextColor3 = Color3.fromRGB(245, 245, 245),
[Roact.Change.Text] = function(rbx) [Roact.Change.AbsoluteSize] = function(rbx)
self:setState({ self:updateLabelSize("address", rbx.AbsoluteSize)
port = rbx.Text,
})
end, end,
}, {
Sizing = e("UISizeConstraint", {
MinSize = self.labelSize,
}),
}),
InputOuter = e("Frame", {
LayoutOrder = 2,
Size = UDim2.new(0, 300, 0, 24),
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
BorderColor3 = Color3.fromRGB(64, 64, 64),
}, {
InputInner = e("TextBox", {
BackgroundTransparency = 1,
Size = UDim2.new(1, -8, 1, -8),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
Font = Enum.Font.SourceSans,
ClearTextOnFocus = false,
TextXAlignment = Enum.TextXAlignment.Left,
TextSize = FORM_TEXT_SIZE,
Text = self.state.address,
TextColor3 = Color3.fromRGB(245, 245, 245),
[Roact.Change.Text] = function(rbx)
self:setState({
address = rbx.Text,
})
end,
}),
}), }),
}), }),
}),
Buttons = e(FitList, { Port = e(FitList, {
containerProps = { containerProps = {
LayoutOrder = 3, LayoutOrder = 2,
BackgroundTransparency = 1, BackgroundTransparency = 1,
}, },
layoutProps = { layoutProps = {
FillDirection = Enum.FillDirection.Horizontal, FillDirection = Enum.FillDirection.Horizontal,
Padding = UDim.new(0, 8), Padding = UDim.new(0, 8),
}, },
}, { }, {
e(FitText, { Label = e(FitText, {
Kind = "TextButton", MinSize = Vector2.new(0, 24),
LayoutOrder = 1, Kind = "TextLabel",
BackgroundColor3 = Color3.fromRGB(32, 32, 32), LayoutOrder = 1,
BorderColor3 = Color3.fromRGB(64, 64, 64), BackgroundTransparency = 1,
TextColor3 = Color3.fromRGB(245, 245, 245), TextXAlignment = Enum.TextXAlignment.Left,
Text = "Start", Font = Enum.Font.SourceSans,
Font = Enum.Font.SourceSans, TextSize = FORM_TEXT_SIZE,
TextSize = FORM_TEXT_SIZE, Text = "Port",
Padding = Vector2.new(12, 3), TextColor3 = Color3.fromRGB(245, 245, 245),
[Roact.Event.Activated] = function() [Roact.Change.AbsoluteSize] = function(rbx)
if startSession ~= nil then self:updateLabelSize("port", rbx.AbsoluteSize)
startSession(self.state.address, self.state.port) end,
end }, {
end, Sizing = e("UISizeConstraint", {
MinSize = self.labelSize,
}),
}),
InputOuter = e("Frame", {
LayoutOrder = 2,
Size = UDim2.new(0, 300, 0, 24),
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
BorderColor3 = Color3.fromRGB(64, 64, 64),
}, {
InputInner = e("TextBox", {
BackgroundTransparency = 1,
Size = UDim2.new(1, -8, 1, -8),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
Font = Enum.Font.SourceSans,
ClearTextOnFocus = false,
TextXAlignment = Enum.TextXAlignment.Left,
TextSize = FORM_TEXT_SIZE,
Text = self.state.port,
TextColor3 = Color3.fromRGB(245, 245, 245),
[Roact.Change.Text] = function(rbx)
self:setState({
port = rbx.Text,
})
end,
}),
}),
}), }),
e(FitText, { Buttons = e(FitList, {
Kind = "TextButton", containerProps = {
LayoutOrder = 2, LayoutOrder = 3,
BackgroundColor3 = Color3.fromRGB(32, 32, 32), BackgroundTransparency = 1,
BorderColor3 = Color3.fromRGB(64, 64, 64), },
TextColor3 = Color3.fromRGB(245, 245, 245), layoutProps = {
Text = "Cancel", FillDirection = Enum.FillDirection.Horizontal,
Font = Enum.Font.SourceSans, Padding = UDim.new(0, 8),
TextSize = FORM_TEXT_SIZE, },
Padding = Vector2.new(12, 3), }, {
e(FitText, {
Kind = "TextButton",
LayoutOrder = 1,
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
BorderColor3 = Color3.fromRGB(64, 64, 64),
TextColor3 = Color3.fromRGB(245, 245, 245),
Text = "Start",
Font = Enum.Font.SourceSans,
TextSize = FORM_TEXT_SIZE,
Padding = Vector2.new(12, 3),
[Roact.Event.Activated] = function() [Roact.Event.Activated] = function()
if cancel ~= nil then if startSession ~= nil then
cancel() startSession(self.state.address, self.state.port)
end end
end, end,
}), }),
e(FitText, {
Kind = "TextButton",
LayoutOrder = 2,
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
BorderColor3 = Color3.fromRGB(64, 64, 64),
TextColor3 = Color3.fromRGB(245, 245, 245),
Text = "Cancel",
Font = Enum.Font.SourceSans,
TextSize = FORM_TEXT_SIZE,
Padding = Vector2.new(12, 3),
[Roact.Event.Activated] = function()
if cancel ~= nil then
cancel()
end
end,
}),
})
}) })
}) })
end end

View File

@@ -3,5 +3,6 @@ return {
version = {0, 5, 0}, version = {0, 5, 0},
expectedServerVersionString = "0.5.0 or newer", expectedServerVersionString = "0.5.0 or newer",
protocolVersion = 2, protocolVersion = 2,
port = 34872, defaultHost = "localhost",
defaultPort = 34872,
} }