mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
plugin: Add setting for opening scripts externally
This commit is contained in:
@@ -107,12 +107,13 @@ function App:init()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function App:startSession(address, port)
|
function App:startSession(address, port, sessionOptions)
|
||||||
Log.trace("Starting new session")
|
Log.trace("Starting new session")
|
||||||
|
|
||||||
local baseUrl = ("http://%s:%s"):format(address, port)
|
local baseUrl = ("http://%s:%s"):format(address, port)
|
||||||
self.serveSession = ServeSession.new({
|
self.serveSession = ServeSession.new({
|
||||||
apiContext = ApiContext.new(baseUrl),
|
apiContext = ApiContext.new(baseUrl),
|
||||||
|
openScriptsExternally = sessionOptions.openScriptsExternally,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.serveSession:onStatusChanged(function(status, details)
|
self.serveSession:onStatusChanged(function(status, details)
|
||||||
@@ -153,8 +154,8 @@ function App:render()
|
|||||||
if self.state.appStatus == AppStatus.NotStarted then
|
if self.state.appStatus == AppStatus.NotStarted then
|
||||||
children = {
|
children = {
|
||||||
ConnectPanel = e(ConnectPanel, {
|
ConnectPanel = e(ConnectPanel, {
|
||||||
startSession = function(address, port)
|
startSession = function(address, port, settings)
|
||||||
self:startSession(address, port)
|
self:startSession(address, port, settings)
|
||||||
end,
|
end,
|
||||||
openSettings = function()
|
openSettings = function()
|
||||||
self:setState({
|
self:setState({
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ local FitList = require(Plugin.Components.FitList)
|
|||||||
local FitText = require(Plugin.Components.FitText)
|
local FitText = require(Plugin.Components.FitText)
|
||||||
local FormButton = require(Plugin.Components.FormButton)
|
local FormButton = require(Plugin.Components.FormButton)
|
||||||
local FormTextInput = require(Plugin.Components.FormTextInput)
|
local FormTextInput = require(Plugin.Components.FormTextInput)
|
||||||
|
local PluginSettings = require(Plugin.Components.PluginSettings)
|
||||||
|
|
||||||
local e = Roact.createElement
|
local e = Roact.createElement
|
||||||
|
|
||||||
@@ -28,147 +29,153 @@ function ConnectPanel:render()
|
|||||||
local openSettings = self.props.openSettings
|
local openSettings = self.props.openSettings
|
||||||
|
|
||||||
return Theme.with(function(theme)
|
return Theme.with(function(theme)
|
||||||
return e(Panel, nil, {
|
return PluginSettings.with(function(settings)
|
||||||
Layout = e("UIListLayout", {
|
return e(Panel, nil, {
|
||||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
Layout = e("UIListLayout", {
|
||||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||||
VerticalAlignment = Enum.VerticalAlignment.Center,
|
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||||
}),
|
VerticalAlignment = Enum.VerticalAlignment.Center,
|
||||||
|
}),
|
||||||
|
|
||||||
Inputs = e(FitList, {
|
Inputs = e(FitList, {
|
||||||
containerProps = {
|
|
||||||
BackgroundTransparency = 1,
|
|
||||||
LayoutOrder = 1,
|
|
||||||
},
|
|
||||||
layoutProps = {
|
|
||||||
FillDirection = Enum.FillDirection.Horizontal,
|
|
||||||
Padding = UDim.new(0, 8),
|
|
||||||
},
|
|
||||||
paddingProps = {
|
|
||||||
PaddingTop = UDim.new(0, 20),
|
|
||||||
PaddingBottom = UDim.new(0, 10),
|
|
||||||
PaddingLeft = UDim.new(0, 24),
|
|
||||||
PaddingRight = UDim.new(0, 24),
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
Address = e(FitList, {
|
|
||||||
containerProps = {
|
containerProps = {
|
||||||
LayoutOrder = 1,
|
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
|
LayoutOrder = 1,
|
||||||
},
|
},
|
||||||
layoutProps = {
|
layoutProps = {
|
||||||
Padding = UDim.new(0, 4),
|
FillDirection = Enum.FillDirection.Horizontal,
|
||||||
|
Padding = UDim.new(0, 8),
|
||||||
|
},
|
||||||
|
paddingProps = {
|
||||||
|
PaddingTop = UDim.new(0, 20),
|
||||||
|
PaddingBottom = UDim.new(0, 10),
|
||||||
|
PaddingLeft = UDim.new(0, 24),
|
||||||
|
PaddingRight = UDim.new(0, 24),
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
Label = e(FitText, {
|
Address = e(FitList, {
|
||||||
Kind = "TextLabel",
|
containerProps = {
|
||||||
LayoutOrder = 1,
|
LayoutOrder = 1,
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
},
|
||||||
Font = theme.TitleFont,
|
layoutProps = {
|
||||||
TextSize = 20,
|
Padding = UDim.new(0, 4),
|
||||||
Text = "Address",
|
},
|
||||||
TextColor3 = theme.Text1,
|
}, {
|
||||||
|
Label = e(FitText, {
|
||||||
|
Kind = "TextLabel",
|
||||||
|
LayoutOrder = 1,
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
Font = theme.TitleFont,
|
||||||
|
TextSize = 20,
|
||||||
|
Text = "Address",
|
||||||
|
TextColor3 = theme.Text1,
|
||||||
|
}),
|
||||||
|
|
||||||
|
Input = e(FormTextInput, {
|
||||||
|
layoutOrder = 2,
|
||||||
|
width = UDim.new(0, 220),
|
||||||
|
value = self.state.address,
|
||||||
|
placeholderValue = Config.defaultHost,
|
||||||
|
onValueChange = function(newValue)
|
||||||
|
self:setState({
|
||||||
|
address = newValue,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Input = e(FormTextInput, {
|
Port = e(FitList, {
|
||||||
layoutOrder = 2,
|
containerProps = {
|
||||||
width = UDim.new(0, 220),
|
LayoutOrder = 2,
|
||||||
value = self.state.address,
|
BackgroundTransparency = 1,
|
||||||
placeholderValue = Config.defaultHost,
|
},
|
||||||
onValueChange = function(newValue)
|
layoutProps = {
|
||||||
self:setState({
|
Padding = UDim.new(0, 4),
|
||||||
address = newValue,
|
},
|
||||||
})
|
}, {
|
||||||
end,
|
Label = e(FitText, {
|
||||||
|
Kind = "TextLabel",
|
||||||
|
LayoutOrder = 1,
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
Font = theme.TitleFont,
|
||||||
|
TextSize = 20,
|
||||||
|
Text = "Port",
|
||||||
|
TextColor3 = theme.Text1,
|
||||||
|
}),
|
||||||
|
|
||||||
|
Input = e(FormTextInput, {
|
||||||
|
layoutOrder = 2,
|
||||||
|
width = UDim.new(0, 80),
|
||||||
|
value = self.state.port,
|
||||||
|
placeholderValue = Config.defaultPort,
|
||||||
|
onValueChange = function(newValue)
|
||||||
|
self:setState({
|
||||||
|
port = newValue,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Port = e(FitList, {
|
Buttons = e(FitList, {
|
||||||
|
fitAxes = "Y",
|
||||||
containerProps = {
|
containerProps = {
|
||||||
|
BackgroundTransparency = 1,
|
||||||
LayoutOrder = 2,
|
LayoutOrder = 2,
|
||||||
BackgroundTransparency = 1,
|
Size = UDim2.new(1, 0, 0, 0),
|
||||||
},
|
},
|
||||||
layoutProps = {
|
layoutProps = {
|
||||||
Padding = UDim.new(0, 4),
|
FillDirection = Enum.FillDirection.Horizontal,
|
||||||
|
HorizontalAlignment = Enum.HorizontalAlignment.Right,
|
||||||
|
Padding = UDim.new(0, 8),
|
||||||
|
},
|
||||||
|
paddingProps = {
|
||||||
|
PaddingTop = UDim.new(0, 0),
|
||||||
|
PaddingBottom = UDim.new(0, 20),
|
||||||
|
PaddingLeft = UDim.new(0, 24),
|
||||||
|
PaddingRight = UDim.new(0, 24),
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
Label = e(FitText, {
|
e(FormButton, {
|
||||||
Kind = "TextLabel",
|
layoutOrder = 1,
|
||||||
LayoutOrder = 1,
|
text = "Settings",
|
||||||
BackgroundTransparency = 1,
|
secondary = true,
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
onClick = function()
|
||||||
Font = theme.TitleFont,
|
if openSettings ~= nil then
|
||||||
TextSize = 20,
|
openSettings()
|
||||||
Text = "Port",
|
end
|
||||||
TextColor3 = theme.Text1,
|
end,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Input = e(FormTextInput, {
|
e(FormButton, {
|
||||||
layoutOrder = 2,
|
layoutOrder = 2,
|
||||||
width = UDim.new(0, 80),
|
text = "Connect",
|
||||||
value = self.state.port,
|
onClick = function()
|
||||||
placeholderValue = Config.defaultPort,
|
if startSession ~= nil then
|
||||||
onValueChange = function(newValue)
|
local address = self.state.address
|
||||||
self:setState({
|
if address:len() == 0 then
|
||||||
port = newValue,
|
address = Config.defaultHost
|
||||||
})
|
end
|
||||||
|
|
||||||
|
local port = self.state.port
|
||||||
|
if port:len() == 0 then
|
||||||
|
port = Config.defaultPort
|
||||||
|
end
|
||||||
|
|
||||||
|
local sessionOptions = {
|
||||||
|
openScriptsExternally = settings:get("openScriptsExternally"),
|
||||||
|
}
|
||||||
|
|
||||||
|
startSession(address, port, sessionOptions)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
}),
|
})
|
||||||
|
end)
|
||||||
Buttons = e(FitList, {
|
|
||||||
fitAxes = "Y",
|
|
||||||
containerProps = {
|
|
||||||
BackgroundTransparency = 1,
|
|
||||||
LayoutOrder = 2,
|
|
||||||
Size = UDim2.new(1, 0, 0, 0),
|
|
||||||
},
|
|
||||||
layoutProps = {
|
|
||||||
FillDirection = Enum.FillDirection.Horizontal,
|
|
||||||
HorizontalAlignment = Enum.HorizontalAlignment.Right,
|
|
||||||
Padding = UDim.new(0, 8),
|
|
||||||
},
|
|
||||||
paddingProps = {
|
|
||||||
PaddingTop = UDim.new(0, 0),
|
|
||||||
PaddingBottom = UDim.new(0, 20),
|
|
||||||
PaddingLeft = UDim.new(0, 24),
|
|
||||||
PaddingRight = UDim.new(0, 24),
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
e(FormButton, {
|
|
||||||
layoutOrder = 1,
|
|
||||||
text = "Settings",
|
|
||||||
secondary = true,
|
|
||||||
onClick = function()
|
|
||||||
if openSettings ~= nil then
|
|
||||||
openSettings()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}),
|
|
||||||
|
|
||||||
e(FormButton, {
|
|
||||||
layoutOrder = 2,
|
|
||||||
text = "Connect",
|
|
||||||
onClick = function()
|
|
||||||
if startSession ~= nil then
|
|
||||||
local address = self.state.address
|
|
||||||
if address:len() == 0 then
|
|
||||||
address = Config.defaultHost
|
|
||||||
end
|
|
||||||
|
|
||||||
local port = self.state.port
|
|
||||||
if port:len() == 0 then
|
|
||||||
port = Config.defaultPort
|
|
||||||
end
|
|
||||||
|
|
||||||
startSession(address, port)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -33,14 +33,6 @@ local VALUES = {
|
|||||||
[Environment.Test] = false,
|
[Environment.Test] = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UnstableOpenScriptsExternally = {
|
|
||||||
type = "BoolValue",
|
|
||||||
values = {
|
|
||||||
[Environment.User] = false,
|
|
||||||
[Environment.Dev] = false,
|
|
||||||
[Environment.Test] = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local CONTAINER_NAME = "RojoDevSettings" .. Config.codename
|
local CONTAINER_NAME = "RojoDevSettings" .. Config.codename
|
||||||
@@ -152,10 +144,6 @@ function DevSettings:twoWaySyncEnabled()
|
|||||||
return getValue("UnstableTwoWaySync")
|
return getValue("UnstableTwoWaySync")
|
||||||
end
|
end
|
||||||
|
|
||||||
function DevSettings:alwaysOpenScriptsExternally()
|
|
||||||
return getValue("UnstableOpenScriptsExternally")
|
|
||||||
end
|
|
||||||
|
|
||||||
function _G.ROJO_DEV_CREATE()
|
function _G.ROJO_DEV_CREATE()
|
||||||
DevSettings:createDevSettings()
|
DevSettings:createDevSettings()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ ServeSession.Status = Status
|
|||||||
|
|
||||||
local validateServeOptions = t.strictInterface({
|
local validateServeOptions = t.strictInterface({
|
||||||
apiContext = t.table,
|
apiContext = t.table,
|
||||||
|
openScriptsExternally = t.boolean,
|
||||||
})
|
})
|
||||||
|
|
||||||
function ServeSession.new(options)
|
function ServeSession.new(options)
|
||||||
@@ -75,6 +76,7 @@ function ServeSession.new(options)
|
|||||||
self = {
|
self = {
|
||||||
__status = Status.NotStarted,
|
__status = Status.NotStarted,
|
||||||
__apiContext = options.apiContext,
|
__apiContext = options.apiContext,
|
||||||
|
__openScriptsExternally = options.openScriptsExternally,
|
||||||
__reconciler = reconciler,
|
__reconciler = reconciler,
|
||||||
__instanceMap = instanceMap,
|
__instanceMap = instanceMap,
|
||||||
__statusChangedCallback = nil,
|
__statusChangedCallback = nil,
|
||||||
@@ -125,7 +127,7 @@ function ServeSession:stop()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ServeSession:__onActiveScriptChanged(activeScript)
|
function ServeSession:__onActiveScriptChanged(activeScript)
|
||||||
if not DevSettings:alwaysOpenScriptsExternally() then
|
if not self.__openScriptsExternally then
|
||||||
Log.trace("Not opening script {} because feature not enabled.", activeScript)
|
Log.trace("Not opening script {} because feature not enabled.", activeScript)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user