mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 15:16:07 +00:00
plugin: UI pretty much done
This commit is contained in:
@@ -1,15 +1,154 @@
|
|||||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||||
|
|
||||||
|
local Session = require(script.Parent.Parent.Session)
|
||||||
|
local Config = require(script.Parent.Parent.Config)
|
||||||
|
local Version = require(script.Parent.Parent.Version)
|
||||||
|
local Logging = require(script.Parent.Parent.Logging)
|
||||||
|
local DevSettings = require(script.Parent.Parent.DevSettings)
|
||||||
|
|
||||||
local ConnectPanel = require(script.Parent.ConnectPanel)
|
local ConnectPanel = require(script.Parent.ConnectPanel)
|
||||||
|
local ConnectionActivePanel = require(script.Parent.ConnectionActivePanel)
|
||||||
|
|
||||||
local e = Roact.createElement
|
local e = Roact.createElement
|
||||||
|
|
||||||
|
local function showUpgradeMessage(lastVersion)
|
||||||
|
local message = (
|
||||||
|
"Rojo detected an upgrade from version %s to version %s." ..
|
||||||
|
"\nMake sure you have also upgraded your server!" ..
|
||||||
|
"\n\nRojo plugin version %s is intended for use with server version %s."
|
||||||
|
):format(
|
||||||
|
Version.display(lastVersion), Version.display(Config.version),
|
||||||
|
Version.display(Config.version), Config.expectedServerVersionString
|
||||||
|
)
|
||||||
|
|
||||||
|
Logging.info(message)
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Check if the user is using a newer version of Rojo than last time. If they
|
||||||
|
are, show them a reminder to make sure they check their server version.
|
||||||
|
]]
|
||||||
|
local function checkUpgrade(plugin)
|
||||||
|
-- When developing Rojo, there's no use in doing version checks
|
||||||
|
if DevSettings:isEnabled() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local lastVersion = plugin:GetSetting("LastRojoVersion")
|
||||||
|
|
||||||
|
if lastVersion then
|
||||||
|
local wasUpgraded = Version.compare(Config.version, lastVersion) == 1
|
||||||
|
|
||||||
|
if wasUpgraded then
|
||||||
|
showUpgradeMessage(lastVersion)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
plugin:SetSetting("LastRojoVersion", Config.version)
|
||||||
|
end
|
||||||
|
|
||||||
|
local SessionStatus = {
|
||||||
|
Disconnected = "Disconnected",
|
||||||
|
Connected = "Connected",
|
||||||
|
Configuring = "Configuring",
|
||||||
|
-- TODO: Error?
|
||||||
|
}
|
||||||
|
|
||||||
|
setmetatable(SessionStatus, {
|
||||||
|
__index = function(_, key)
|
||||||
|
error(("%q is not a valid member of SessionStatus"):format(tostring(key)), 2)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
local App = Roact.Component:extend("App")
|
local App = Roact.Component:extend("App")
|
||||||
|
|
||||||
function App:render()
|
function App:init()
|
||||||
return e("ScreenGui", nil, {
|
self:setState({
|
||||||
ConnectPanel = e(ConnectPanel),
|
sessionStatus = SessionStatus.Disconnected,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
self.currentSession = nil
|
||||||
|
|
||||||
|
self.displayedVersion = DevSettings:isEnabled()
|
||||||
|
and Config.codename
|
||||||
|
or Version.display(Config.version)
|
||||||
|
end
|
||||||
|
|
||||||
|
function App:render()
|
||||||
|
local children
|
||||||
|
|
||||||
|
if self.state.sessionStatus == SessionStatus.Connected then
|
||||||
|
children = {
|
||||||
|
ConnectionActivePanel = e(ConnectionActivePanel),
|
||||||
|
}
|
||||||
|
elseif self.state.sessionStatus == SessionStatus.Configuring then
|
||||||
|
children = {
|
||||||
|
ConnectPanel = e(ConnectPanel, {
|
||||||
|
startSession = function(address, port)
|
||||||
|
Logging.info("Starting new session")
|
||||||
|
|
||||||
|
self.currentSession = Session.new({
|
||||||
|
address = address,
|
||||||
|
port = port,
|
||||||
|
onError = function()
|
||||||
|
Logging.info("Session terminated")
|
||||||
|
self.currentSession = nil
|
||||||
|
|
||||||
|
self:setState({
|
||||||
|
sessionStatus = SessionStatus.Disconnected,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
self:setState({
|
||||||
|
sessionStatus = SessionStatus.Connected,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
cancel = function()
|
||||||
|
Logging.info("Canceling session configuration")
|
||||||
|
|
||||||
|
self:setState({
|
||||||
|
sessionStatus = SessionStatus.Disconnected,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return e("ScreenGui", nil, children)
|
||||||
|
end
|
||||||
|
|
||||||
|
function App:didMount()
|
||||||
|
Logging.trace("Rojo %s initializing", self.displayedVersion)
|
||||||
|
|
||||||
|
local toolbar = self.props.plugin:CreateToolbar("Rojo " .. self.displayedVersion)
|
||||||
|
|
||||||
|
-- TODO: Icon!
|
||||||
|
local connectButton = toolbar:CreateButton("Connect", "Connect to Rojo Session", "")
|
||||||
|
connectButton.ClickableWhenViewportHidden = true
|
||||||
|
|
||||||
|
connectButton.Click:Connect(function()
|
||||||
|
connectButton:SetActive(false)
|
||||||
|
checkUpgrade(self.props.plugin)
|
||||||
|
|
||||||
|
if self.state.sessionStatus == SessionStatus.Connected then
|
||||||
|
Logging.info("Disconnecting session")
|
||||||
|
|
||||||
|
error("NYI")
|
||||||
|
elseif self.state.sessionStatus == SessionStatus.Disconnected then
|
||||||
|
Logging.info("Starting session configuration")
|
||||||
|
|
||||||
|
self:setState({
|
||||||
|
sessionStatus = SessionStatus.Configuring,
|
||||||
|
})
|
||||||
|
elseif self.state.sessionStatus == SessionStatus.Configuring then
|
||||||
|
Logging.info("Canceling session configuration")
|
||||||
|
|
||||||
|
self:setState({
|
||||||
|
sessionStatus = SessionStatus.Disconnected,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return App
|
return App
|
||||||
@@ -5,6 +5,8 @@ local FitText = require(script.Parent.FitText)
|
|||||||
|
|
||||||
local e = Roact.createElement
|
local e = Roact.createElement
|
||||||
|
|
||||||
|
local FORM_TEXT_SIZE = 20
|
||||||
|
|
||||||
local ConnectPanel = Roact.Component:extend("ConnectPanel")
|
local ConnectPanel = Roact.Component:extend("ConnectPanel")
|
||||||
|
|
||||||
function ConnectPanel:init()
|
function ConnectPanel:init()
|
||||||
@@ -37,7 +39,7 @@ function ConnectPanel:render()
|
|||||||
|
|
||||||
return e(FitList, {
|
return e(FitList, {
|
||||||
containerProps = {
|
containerProps = {
|
||||||
BackgroundColor3 = Color3.fromRGB(8, 8, 8),
|
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
|
||||||
BorderColor3 = Color3.fromRGB(64, 64, 64),
|
BorderColor3 = Color3.fromRGB(64, 64, 64),
|
||||||
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),
|
||||||
@@ -63,12 +65,13 @@ function ConnectPanel:render()
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
Label = e(FitText, {
|
Label = e(FitText, {
|
||||||
|
MinSize = Vector2.new(0, 24),
|
||||||
Kind = "TextLabel",
|
Kind = "TextLabel",
|
||||||
LayoutOrder = 1,
|
LayoutOrder = 1,
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
Font = Enum.Font.SourceSans,
|
Font = Enum.Font.SourceSans,
|
||||||
TextSize = 16,
|
TextSize = FORM_TEXT_SIZE,
|
||||||
Text = "Address",
|
Text = "Address",
|
||||||
TextColor3 = Color3.fromRGB(245, 245, 245),
|
TextColor3 = Color3.fromRGB(245, 245, 245),
|
||||||
|
|
||||||
@@ -81,17 +84,23 @@ function ConnectPanel:render()
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Input = e("TextBox", {
|
InputOuter = e("Frame", {
|
||||||
LayoutOrder = 2,
|
LayoutOrder = 2,
|
||||||
Size = UDim2.new(0, 300, 0, 20),
|
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,
|
Font = Enum.Font.SourceSans,
|
||||||
ClearTextOnFocus = false,
|
ClearTextOnFocus = false,
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
TextSize = 16,
|
TextSize = FORM_TEXT_SIZE,
|
||||||
Text = self.state.address,
|
Text = self.state.address,
|
||||||
TextColor3 = Color3.fromRGB(245, 245, 245),
|
TextColor3 = Color3.fromRGB(245, 245, 245),
|
||||||
BackgroundColor3 = Color3.fromRGB(8, 8, 8),
|
|
||||||
BorderColor3 = Color3.fromRGB(64, 64, 64),
|
|
||||||
|
|
||||||
[Roact.Change.Text] = function(rbx)
|
[Roact.Change.Text] = function(rbx)
|
||||||
self:setState({
|
self:setState({
|
||||||
@@ -100,6 +109,7 @@ function ConnectPanel:render()
|
|||||||
end,
|
end,
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
}),
|
||||||
|
|
||||||
Port = e(FitList, {
|
Port = e(FitList, {
|
||||||
containerProps = {
|
containerProps = {
|
||||||
@@ -112,12 +122,13 @@ function ConnectPanel:render()
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
Label = e(FitText, {
|
Label = e(FitText, {
|
||||||
|
MinSize = Vector2.new(0, 24),
|
||||||
Kind = "TextLabel",
|
Kind = "TextLabel",
|
||||||
LayoutOrder = 1,
|
LayoutOrder = 1,
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
Font = Enum.Font.SourceSans,
|
Font = Enum.Font.SourceSans,
|
||||||
TextSize = 16,
|
TextSize = FORM_TEXT_SIZE,
|
||||||
Text = "Port",
|
Text = "Port",
|
||||||
TextColor3 = Color3.fromRGB(245, 245, 245),
|
TextColor3 = Color3.fromRGB(245, 245, 245),
|
||||||
|
|
||||||
@@ -130,17 +141,23 @@ function ConnectPanel:render()
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Input = e("TextBox", {
|
InputOuter = e("Frame", {
|
||||||
LayoutOrder = 2,
|
LayoutOrder = 2,
|
||||||
Size = UDim2.new(0, 300, 0, 20),
|
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,
|
Font = Enum.Font.SourceSans,
|
||||||
ClearTextOnFocus = false,
|
ClearTextOnFocus = false,
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
TextSize = 16,
|
TextSize = FORM_TEXT_SIZE,
|
||||||
Text = self.state.port,
|
Text = self.state.port,
|
||||||
TextColor3 = Color3.fromRGB(245, 245, 245),
|
TextColor3 = Color3.fromRGB(245, 245, 245),
|
||||||
BackgroundColor3 = Color3.fromRGB(8, 8, 8),
|
|
||||||
BorderColor3 = Color3.fromRGB(64, 64, 64),
|
|
||||||
|
|
||||||
[Roact.Change.Text] = function(rbx)
|
[Roact.Change.Text] = function(rbx)
|
||||||
self:setState({
|
self:setState({
|
||||||
@@ -149,6 +166,7 @@ function ConnectPanel:render()
|
|||||||
end,
|
end,
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
}),
|
||||||
|
|
||||||
Buttons = e(FitList, {
|
Buttons = e(FitList, {
|
||||||
containerProps = {
|
containerProps = {
|
||||||
@@ -163,10 +181,13 @@ function ConnectPanel:render()
|
|||||||
e(FitText, {
|
e(FitText, {
|
||||||
Kind = "TextButton",
|
Kind = "TextButton",
|
||||||
LayoutOrder = 1,
|
LayoutOrder = 1,
|
||||||
BackgroundColor3 = Color3.fromRGB(16, 16, 16),
|
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
|
||||||
BorderColor3 = Color3.fromRGB(64, 64, 64),
|
BorderColor3 = Color3.fromRGB(64, 64, 64),
|
||||||
TextColor3 = Color3.fromRGB(245, 245, 245),
|
TextColor3 = Color3.fromRGB(245, 245, 245),
|
||||||
Text = "Start",
|
Text = "Start",
|
||||||
|
Font = Enum.Font.SourceSans,
|
||||||
|
TextSize = FORM_TEXT_SIZE,
|
||||||
|
Padding = Vector2.new(12, 3),
|
||||||
|
|
||||||
[Roact.Event.Activated] = function()
|
[Roact.Event.Activated] = function()
|
||||||
if startSession ~= nil then
|
if startSession ~= nil then
|
||||||
@@ -178,10 +199,13 @@ function ConnectPanel:render()
|
|||||||
e(FitText, {
|
e(FitText, {
|
||||||
Kind = "TextButton",
|
Kind = "TextButton",
|
||||||
LayoutOrder = 2,
|
LayoutOrder = 2,
|
||||||
BackgroundColor3 = Color3.fromRGB(16, 16, 16),
|
BackgroundColor3 = Color3.fromRGB(32, 32, 32),
|
||||||
BorderColor3 = Color3.fromRGB(64, 64, 64),
|
BorderColor3 = Color3.fromRGB(64, 64, 64),
|
||||||
TextColor3 = Color3.fromRGB(245, 245, 245),
|
TextColor3 = Color3.fromRGB(245, 245, 245),
|
||||||
Text = "Cancel",
|
Text = "Cancel",
|
||||||
|
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 cancel ~= nil then
|
||||||
|
|||||||
25
plugin/src/Components/ConnectionActivePanel.lua
Normal file
25
plugin/src/Components/ConnectionActivePanel.lua
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||||
|
|
||||||
|
local FitText = require(script.Parent.FitText)
|
||||||
|
|
||||||
|
local e = Roact.createElement
|
||||||
|
|
||||||
|
local ConnectionActivePanel = Roact.Component:extend("ConnectionActivePanel")
|
||||||
|
|
||||||
|
function ConnectionActivePanel:render()
|
||||||
|
return e(FitText, {
|
||||||
|
Kind = "TextLabel",
|
||||||
|
Padding = Vector2.new(4, 4),
|
||||||
|
Font = Enum.Font.SourceSans,
|
||||||
|
TextSize = 16,
|
||||||
|
Text = "Rojo Connected",
|
||||||
|
TextColor3 = Color3.new(1, 1, 1),
|
||||||
|
BackgroundColor3 = Color3.new(0, 0, 0),
|
||||||
|
BorderSizePixel = 0,
|
||||||
|
BackgroundTransparency = 0.6,
|
||||||
|
Position = UDim2.new(0.5, 0, 0, 0),
|
||||||
|
AnchorPoint = Vector2.new(0.5, 0),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return ConnectionActivePanel
|
||||||
@@ -18,6 +18,7 @@ function FitText:render()
|
|||||||
local containerProps = Dictionary.merge(self.props, {
|
local containerProps = Dictionary.merge(self.props, {
|
||||||
Kind = Dictionary.None,
|
Kind = Dictionary.None,
|
||||||
Padding = Dictionary.None,
|
Padding = Dictionary.None,
|
||||||
|
MinSize = Dictionary.None,
|
||||||
Size = self.sizeBinding
|
Size = self.sizeBinding
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ function FitText:didUpdate()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function FitText:updateTextMeasurements()
|
function FitText:updateTextMeasurements()
|
||||||
|
local minSize = self.props.MinSize or Vector2.new(0, 0)
|
||||||
local padding = self.props.Padding or Vector2.new(0, 0)
|
local padding = self.props.Padding or Vector2.new(0, 0)
|
||||||
|
|
||||||
local text = self.props.Text or ""
|
local text = self.props.Text or ""
|
||||||
@@ -41,8 +43,8 @@ function FitText:updateTextMeasurements()
|
|||||||
|
|
||||||
local measuredText = TextService:GetTextSize(text, textSize, font, Vector2.new(9e6, 9e6))
|
local measuredText = TextService:GetTextSize(text, textSize, font, Vector2.new(9e6, 9e6))
|
||||||
local totalSize = UDim2.new(
|
local totalSize = UDim2.new(
|
||||||
0, padding.X * 2 + measuredText.X,
|
0, math.max(minSize.X, padding.X * 2 + measuredText.X),
|
||||||
0, padding.Y * 2 + measuredText.Y)
|
0, math.max(minSize.Y, padding.Y * 2 + measuredText.Y))
|
||||||
|
|
||||||
self.setSize(totalSize)
|
self.setSize(totalSize)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ local ApiContext = require(script.Parent.ApiContext)
|
|||||||
local Config = require(script.Parent.Config)
|
local Config = require(script.Parent.Config)
|
||||||
local Logging = require(script.Parent.Logging)
|
local Logging = require(script.Parent.Logging)
|
||||||
|
|
||||||
local REMOTE_URL = ("http://localhost:%d"):format(Config.port)
|
|
||||||
|
|
||||||
local function makeInstanceMap()
|
local function makeInstanceMap()
|
||||||
local self = {
|
local self = {
|
||||||
fromIds = {},
|
fromIds = {},
|
||||||
@@ -249,12 +247,16 @@ end
|
|||||||
local Session = {}
|
local Session = {}
|
||||||
Session.__index = Session
|
Session.__index = Session
|
||||||
|
|
||||||
function Session.new(onError)
|
function Session.new(config)
|
||||||
local self = {}
|
local self = {}
|
||||||
|
|
||||||
|
self.onError = config.onError
|
||||||
|
|
||||||
local instanceMap = makeInstanceMap()
|
local instanceMap = makeInstanceMap()
|
||||||
|
|
||||||
local api = ApiContext.new(REMOTE_URL)
|
local remoteUrl = ("http://%s:%s"):format(config.address, config.port)
|
||||||
|
|
||||||
|
local api = ApiContext.new(remoteUrl)
|
||||||
|
|
||||||
ApiContext:onMessage(function(message)
|
ApiContext:onMessage(function(message)
|
||||||
local requestedIds = {}
|
local requestedIds = {}
|
||||||
@@ -277,7 +279,7 @@ function Session.new(onError)
|
|||||||
end)
|
end)
|
||||||
:catch(function(message)
|
:catch(function(message)
|
||||||
Logging.warn("%s", tostring(message))
|
Logging.warn("%s", tostring(message))
|
||||||
onError()
|
self.onError()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -292,7 +294,7 @@ function Session.new(onError)
|
|||||||
end)
|
end)
|
||||||
:catch(function(message)
|
:catch(function(message)
|
||||||
Logging.warn("%s", tostring(message))
|
Logging.warn("%s", tostring(message))
|
||||||
onError()
|
self.onError()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return setmetatable(self, Session)
|
return setmetatable(self, Session)
|
||||||
|
|||||||
@@ -8,81 +8,12 @@ Roact.setGlobalConfig({
|
|||||||
elementTracing = true,
|
elementTracing = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
local Session = require(script.Session)
|
|
||||||
local Config = require(script.Config)
|
|
||||||
local Version = require(script.Version)
|
|
||||||
local Logging = require(script.Logging)
|
|
||||||
local DevSettings = require(script.DevSettings)
|
|
||||||
local App = require(script.Components.App)
|
local App = require(script.Components.App)
|
||||||
|
|
||||||
local function showUpgradeMessage(lastVersion)
|
local app = Roact.createElement(App, {
|
||||||
local message = (
|
plugin = plugin,
|
||||||
"Rojo detected an upgrade from version %s to version %s." ..
|
})
|
||||||
"\nMake sure you have also upgraded your server!" ..
|
|
||||||
"\n\nRojo plugin version %s is intended for use with server version %s."
|
|
||||||
):format(
|
|
||||||
Version.display(lastVersion), Version.display(Config.version),
|
|
||||||
Version.display(Config.version), Config.expectedServerVersionString
|
|
||||||
)
|
|
||||||
|
|
||||||
Logging.info(message)
|
Roact.mount(app, game:GetService("CoreGui"), "Rojo UI")
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
-- TODO: Detect another instance of Rojo coming online and shut down this one.
|
||||||
Check if the user is using a newer version of Rojo than last time. If they
|
|
||||||
are, show them a reminder to make sure they check their server version.
|
|
||||||
]]
|
|
||||||
local function checkUpgrade()
|
|
||||||
-- When developing Rojo, there's no use in doing version checks
|
|
||||||
if DevSettings:isEnabled() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local lastVersion = plugin:GetSetting("LastRojoVersion")
|
|
||||||
|
|
||||||
if lastVersion then
|
|
||||||
local wasUpgraded = Version.compare(Config.version, lastVersion) == 1
|
|
||||||
|
|
||||||
if wasUpgraded then
|
|
||||||
showUpgradeMessage(lastVersion)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
plugin:SetSetting("LastRojoVersion", Config.version)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function main()
|
|
||||||
local displayedVersion = DevSettings:isEnabled()
|
|
||||||
and Config.codename
|
|
||||||
or Version.display(Config.version)
|
|
||||||
|
|
||||||
Logging.trace("Rojo %s initialized", displayedVersion)
|
|
||||||
|
|
||||||
local toolbar = plugin:CreateToolbar("Rojo " .. displayedVersion)
|
|
||||||
|
|
||||||
Roact.mount(Roact.createElement(App), game:GetService("CoreGui"), "Rojo UI")
|
|
||||||
|
|
||||||
local currentSession
|
|
||||||
|
|
||||||
-- TODO: Icon!
|
|
||||||
local connectButton = toolbar:CreateButton("Connect", "Connect to Rojo Session", "")
|
|
||||||
connectButton.ClickableWhenViewportHidden = true
|
|
||||||
|
|
||||||
connectButton.Click:Connect(function()
|
|
||||||
connectButton:SetActive(false)
|
|
||||||
checkUpgrade()
|
|
||||||
|
|
||||||
if currentSession ~= nil then
|
|
||||||
Logging.warn("A session is already running!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
Logging.info("Started new session.")
|
|
||||||
currentSession = Session.new(function()
|
|
||||||
Logging.info("Session terminated.")
|
|
||||||
currentSession = nil
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user