Skip to content

Commit

Permalink
Stylua formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber committed Sep 18, 2023
1 parent 17c6c2c commit 3703d5e
Show file tree
Hide file tree
Showing 50 changed files with 592 additions and 550 deletions.
104 changes: 45 additions & 59 deletions plugin/src/ApiContext.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ end
local function rejectWrongProtocolVersion(infoResponseBody)
if infoResponseBody.protocolVersion ~= Config.protocolVersion then
local message = (
"Found a Rojo dev server, but it's using a different protocol version, and is incompatible." ..
"\nMake sure you have matching versions of both the Rojo plugin and server!" ..
"\n\nYour client is version %s, with protocol version %s. It expects server version %s." ..
"\nYour server is version %s, with protocol version %s." ..
"\n\nGo to https://github.com/rojo-rbx/rojo for more details."
"Found a Rojo dev server, but it's using a different protocol version, and is incompatible."
.. "\nMake sure you have matching versions of both the Rojo plugin and server!"
.. "\n\nYour client is version %s, with protocol version %s. It expects server version %s."
.. "\nYour server is version %s, with protocol version %s."
.. "\n\nGo to https://github.com/rojo-rbx/rojo for more details."
):format(
Version.display(Config.version), Config.protocolVersion,
Version.display(Config.version),
Config.protocolVersion,
Config.expectedServerVersionString,
infoResponseBody.serverVersion, infoResponseBody.protocolVersion
infoResponseBody.serverVersion,
infoResponseBody.protocolVersion
)

return Promise.reject(message)
Expand All @@ -59,14 +61,11 @@ local function rejectWrongPlaceId(infoResponseBody)
end

local message = (
"Found a Rojo server, but its project is set to only be used with a specific list of places." ..
"\nYour place ID is %s, but needs to be one of these:" ..
"\n%s" ..
"\n\nTo change this list, edit 'servePlaceIds' in your .project.json file."
):format(
tostring(game.PlaceId),
table.concat(idList, "\n")
)
"Found a Rojo server, but its project is set to only be used with a specific list of places."
.. "\nYour place ID is %s, but needs to be one of these:"
.. "\n%s"
.. "\n\nTo change this list, edit 'servePlaceIds' in your .project.json file."
):format(tostring(game.PlaceId), table.concat(idList, "\n"))

return Promise.reject(message)
end
Expand Down Expand Up @@ -141,18 +140,15 @@ end
function ApiContext:read(ids)
local url = ("%s/api/read/%s"):format(self.__baseUrl, table.concat(ids, ","))

return Http.get(url)
:andThen(rejectFailedRequests)
:andThen(Http.Response.json)
:andThen(function(body)
if body.sessionId ~= self.__sessionId then
return Promise.reject("Server changed ID")
end
return Http.get(url):andThen(rejectFailedRequests):andThen(Http.Response.json):andThen(function(body)
if body.sessionId ~= self.__sessionId then
return Promise.reject("Server changed ID")
end

assert(validateApiRead(body))
assert(validateApiRead(body))

return body
end)
return body
end)
end

function ApiContext:write(patch)
Expand Down Expand Up @@ -189,28 +185,24 @@ function ApiContext:write(patch)

body = Http.jsonEncode(body)

return Http.post(url, body)
:andThen(rejectFailedRequests)
:andThen(Http.Response.json)
:andThen(function(body)
Log.info("Write response: {:?}", body)
return Http.post(url, body):andThen(rejectFailedRequests):andThen(Http.Response.json):andThen(function(body)
Log.info("Write response: {:?}", body)

return body
end)
return body
end)
end

function ApiContext:retrieveMessages()
local url = ("%s/api/subscribe/%s"):format(self.__baseUrl, self.__messageCursor)

local function sendRequest()
local request = Http.get(url)
:catch(function(err)
if err.type == Http.Error.Kind.Timeout and self.__connected then
return sendRequest()
end
local request = Http.get(url):catch(function(err)
if err.type == Http.Error.Kind.Timeout and self.__connected then
return sendRequest()
end

return Promise.reject(err)
end)
return Promise.reject(err)
end)

Log.trace("Tracking request {}", request)
self.__activeRequests[request] = true
Expand All @@ -222,35 +214,29 @@ function ApiContext:retrieveMessages()
end)
end

return sendRequest()
:andThen(rejectFailedRequests)
:andThen(Http.Response.json)
:andThen(function(body)
if body.sessionId ~= self.__sessionId then
return Promise.reject("Server changed ID")
end
return sendRequest():andThen(rejectFailedRequests):andThen(Http.Response.json):andThen(function(body)
if body.sessionId ~= self.__sessionId then
return Promise.reject("Server changed ID")
end

assert(validateApiSubscribe(body))
assert(validateApiSubscribe(body))

self:setMessageCursor(body.messageCursor)
self:setMessageCursor(body.messageCursor)

return body.messages
end)
return body.messages
end)
end

function ApiContext:open(id)
local url = ("%s/api/open/%s"):format(self.__baseUrl, id)

return Http.post(url, "")
:andThen(rejectFailedRequests)
:andThen(Http.Response.json)
:andThen(function(body)
if body.sessionId ~= self.__sessionId then
return Promise.reject("Server changed ID")
end
return Http.post(url, ""):andThen(rejectFailedRequests):andThen(Http.Response.json):andThen(function(body)
if body.sessionId ~= self.__sessionId then
return Promise.reject("Server changed ID")
end

return nil
end)
return nil
end)
end

return ApiContext
21 changes: 11 additions & 10 deletions plugin/src/App/Components/Checkbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ end

function Checkbox:didUpdate(lastProps)
if lastProps.active ~= self.props.active then
self.motor:setGoal(
Flipper.Spring.new(self.props.active and 1 or 0, {
frequency = 6,
dampingRatio = 1.1,
})
)
self.motor:setGoal(Flipper.Spring.new(self.props.active and 1 or 0, {
frequency = 6,
dampingRatio = 1.1,
}))
end
end

Expand All @@ -52,13 +50,14 @@ function Checkbox:render()
BackgroundTransparency = 1,

[Roact.Event.Activated] = function()
if self.props.locked then return end
if self.props.locked then
return
end
self.props.onClick()
end,
}, {
StateTip = e(Tooltip.Trigger, {
text =
(if self.props.locked then "[LOCKED] " else "")
text = (if self.props.locked then "[LOCKED] " else "")
.. (if self.props.active then "Enabled" else "Disabled"),
}),

Expand Down Expand Up @@ -89,7 +88,9 @@ function Checkbox:render()
size = UDim2.new(1, 0, 1, 0),
}, {
Icon = e("ImageLabel", {
Image = if self.props.locked then Assets.Images.Checkbox.Locked else Assets.Images.Checkbox.Inactive,
Image = if self.props.locked
then Assets.Images.Checkbox.Locked
else Assets.Images.Checkbox.Inactive,
ImageColor3 = theme.Inactive.IconColor,
ImageTransparency = self.props.transparency,

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/App/Components/CodeLabel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function CodeLabel:didMount()
end

function CodeLabel:didUpdate()
self:updateHighlights()
self:updateHighlights()
end

function CodeLabel:updateHighlights()
Expand Down
91 changes: 46 additions & 45 deletions plugin/src/App/Components/Dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ function Dropdown:didUpdate(prevProps)
})
end

self.openMotor:setGoal(
Flipper.Spring.new(self.state.open and 1 or 0, {
frequency = 6,
dampingRatio = 1.1,
})
)
self.openMotor:setGoal(Flipper.Spring.new(self.state.open and 1 or 0, {
frequency = 6,
dampingRatio = 1.1,
}))
end

function Dropdown:render()
Expand All @@ -52,10 +50,7 @@ function Dropdown:render()
local width = -1
for i, option in self.props.options do
local text = tostring(option or "")
local textSize = TextService:GetTextSize(
text, 15, Enum.Font.GothamMedium,
Vector2.new(math.huge, 20)
)
local textSize = TextService:GetTextSize(text, 15, Enum.Font.GothamMedium, Vector2.new(math.huge, 20))
if textSize.X > width then
width = textSize.X
end
Expand All @@ -74,7 +69,9 @@ function Dropdown:render()
Font = Enum.Font.GothamMedium,

[Roact.Event.Activated] = function()
if self.props.locked then return end
if self.props.locked then
return
end
self:setState({
open = false,
})
Expand All @@ -88,15 +85,17 @@ function Dropdown:render()
end

return e("ImageButton", {
Size = UDim2.new(0, width+50, 0, 28),
Size = UDim2.new(0, width + 50, 0, 28),
Position = self.props.position,
AnchorPoint = self.props.anchorPoint,
LayoutOrder = self.props.layoutOrder,
ZIndex = self.props.zIndex,
BackgroundTransparency = 1,

[Roact.Event.Activated] = function()
if self.props.locked then return end
if self.props.locked then
return
end
self:setState({
open = not self.state.open,
})
Expand Down Expand Up @@ -136,40 +135,42 @@ function Dropdown:render()
TextTransparency = self.props.transparency,
}),
}),
Options = if self.state.open then e(SlicedImage, {
slice = Assets.Slices.RoundedBackground,
color = theme.BackgroundColor,
position = UDim2.new(1, 0, 1, 3),
size = self.openBinding:map(function(a)
return UDim2.new(1, 0, a*math.min(3, #self.props.options), 0)
end),
anchorPoint = Vector2.new(1, 0),
}, {
Border = e(SlicedImage, {
slice = Assets.Slices.RoundedBorder,
color = theme.BorderColor,
transparency = self.props.transparency,
size = UDim2.new(1, 0, 1, 0),
}),
ScrollingFrame = e(ScrollingFrame, {
size = UDim2.new(1, -4, 1, -4),
position = UDim2.new(0, 2, 0, 2),
transparency = self.props.transparency,
contentSize = self.contentSize,
Options = if self.state.open
then e(SlicedImage, {
slice = Assets.Slices.RoundedBackground,
color = theme.BackgroundColor,
position = UDim2.new(1, 0, 1, 3),
size = self.openBinding:map(function(a)
return UDim2.new(1, 0, a * math.min(3, #self.props.options), 0)
end),
anchorPoint = Vector2.new(1, 0),
}, {
Layout = e("UIListLayout", {
VerticalAlignment = Enum.VerticalAlignment.Top,
FillDirection = Enum.FillDirection.Vertical,
SortOrder = Enum.SortOrder.LayoutOrder,
Padding = UDim.new(0, 0),

[Roact.Change.AbsoluteContentSize] = function(object)
self.setContentSize(object.AbsoluteContentSize)
end,
Border = e(SlicedImage, {
slice = Assets.Slices.RoundedBorder,
color = theme.BorderColor,
transparency = self.props.transparency,
size = UDim2.new(1, 0, 1, 0),
}),
Roact.createFragment(optionButtons),
}),
}) else nil,
ScrollingFrame = e(ScrollingFrame, {
size = UDim2.new(1, -4, 1, -4),
position = UDim2.new(0, 2, 0, 2),
transparency = self.props.transparency,
contentSize = self.contentSize,
}, {
Layout = e("UIListLayout", {
VerticalAlignment = Enum.VerticalAlignment.Top,
FillDirection = Enum.FillDirection.Vertical,
SortOrder = Enum.SortOrder.LayoutOrder,
Padding = UDim.new(0, 0),

[Roact.Change.AbsoluteContentSize] = function(object)
self.setContentSize(object.AbsoluteContentSize)
end,
}),
Roact.createFragment(optionButtons),
}),
})
else nil,
})
end)
end
Expand Down
8 changes: 2 additions & 6 deletions plugin/src/App/Components/IconButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ function IconButton:render()
[Roact.Event.Activated] = self.props.onClick,

[Roact.Event.MouseEnter] = function()
self.motor:setGoal(
Flipper.Spring.new(1, HOVER_SPRING_PROPS)
)
self.motor:setGoal(Flipper.Spring.new(1, HOVER_SPRING_PROPS))
end,

[Roact.Event.MouseLeave] = function()
self.motor:setGoal(
Flipper.Spring.new(0, HOVER_SPRING_PROPS)
)
self.motor:setGoal(Flipper.Spring.new(0, HOVER_SPRING_PROPS))
end,
}, {
Icon = e("ImageLabel", {
Expand Down
5 changes: 2 additions & 3 deletions plugin/src/App/Components/PatchVisualizer/DisplayValue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ local function DisplayValue(props)
Position = UDim2.new(0, 25, 0, 0),
}),
})

elseif t == "table" then
-- Showing a memory address for tables is useless, so we want to show the best we can
local textRepresentation = nil
Expand All @@ -62,10 +61,10 @@ local function DisplayValue(props)

-- Wrap strings in quotes
if type(k) == "string" then
k = "\"" .. k .. "\""
k = '"' .. k .. '"'
end
if type(v) == "string" then
v = "\"" .. v .. "\""
v = '"' .. v .. '"'
end

out[i] = string.format("[%s] = %s", tostring(k), tostring(v))
Expand Down
Loading

0 comments on commit 3703d5e

Please sign in to comment.