Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make debugger more compact #32

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/debugger/formatTable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local function formatTable(object, mode, _padLength, _depth)
end)

local count = 0
local size = #values
for _, entry in values do
local key = entry.key
local value = entry.value
Expand All @@ -40,7 +41,8 @@ local function formatTable(object, mode, _padLength, _depth)
end

if mode == FormatMode.Long then
part ..= "\n" .. string.rep(" ", _depth - 1)
local spaces = string.rep(" ", _depth - 1)
part ..= if count == 0 then spaces else "\n" .. spaces
end

count += 1
Expand Down Expand Up @@ -94,7 +96,8 @@ local function formatTable(object, mode, _padLength, _depth)
end

if mode == FormatMode.Long then
str ..= "\n" .. string.rep(" ", _depth - 2)
local spaces = string.rep(" ", _depth - 1)
str ..= if count == size then spaces else "\n" .. spaces
end

if mode == FormatMode.Short or _depth > 1 then
Expand Down
11 changes: 4 additions & 7 deletions lib/debugger/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ local function ui(debugger, loop)
end
end

plasma.space(30)

plasma.space(15)
plasma.heading("STATE")
plasma.space(10)

Expand Down Expand Up @@ -117,7 +116,7 @@ local function ui(debugger, loop)
end
end

plasma.space(30)
plasma.space(15)
plasma.heading("SYSTEMS")
plasma.space(10)

Expand All @@ -131,7 +130,7 @@ local function ui(debugger, loop)
plasma.heading(eventName, {
font = Enum.Font.Gotham,
})
plasma.space(10)
plasma.space(5)
local items = {}

for _, system in systems do
Expand Down Expand Up @@ -174,7 +173,7 @@ local function ui(debugger, loop)
end
end

plasma.space(20)
plasma.space(10)
end
end)

Expand Down Expand Up @@ -213,8 +212,6 @@ local function ui(debugger, loop)
closable = true,
}, function()
plasma.useKey(name)
plasma.heading(name)
plasma.space(0)

plasma.row(function()
if plasma.button(string.format("View queries (%d)", #debugger._queries)):clicked() then
Expand Down
2 changes: 1 addition & 1 deletion lib/debugger/widgets/codeText.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ return function(Plasma)
Text = "",
AutomaticSize = Enum.AutomaticSize.Y,
Font = Enum.Font.Code,
TextSize = 22,
TextSize = 18,
TextStrokeTransparency = 0.5,
TextXAlignment = Enum.TextXAlignment.Left,
TextYAlignment = Enum.TextYAlignment.Top,
Expand Down
2 changes: 1 addition & 1 deletion lib/debugger/widgets/container.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ return function(Plasma)
return Plasma.widget(function(fn, options)
options = options or {}

local padding = options.padding or 10
local padding = options.padding or 5

local refs = Plasma.useInstance(function(ref)
return create("Frame", {
Expand Down
6 changes: 5 additions & 1 deletion lib/debugger/widgets/entityInspect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ local FormatMode = formatTableModule.FormatMode

return function(plasma)
return plasma.widget(function(debugger)
local style = plasma.useStyle()

local closed = plasma
.window({
title = string.format("Entity %d", debugger.debugEntity),
Expand All @@ -18,7 +20,9 @@ return function(plasma)
local model = debugger.findInstanceFromEntity(debugger.debugEntity)

if model then
plasma.highlight(model)
plasma.highlight(model, {
fillColor = style.primaryColor,
})
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/debugger/widgets/errorInspect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ return function(plasma)
local selected = plasma
.table(items, {
selectable = true,
font = Enum.Font.Code,
})
:selected()

Expand Down
9 changes: 4 additions & 5 deletions lib/debugger/widgets/frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ return function(Plasma)
UICorner.Parent = Frame

local UIPadding = Instance.new("UIPadding")
UIPadding.PaddingBottom = UDim.new(0, 20)
UIPadding.PaddingLeft = UDim.new(0, 20)
UIPadding.PaddingRight = UDim.new(0, 20)
UIPadding.PaddingTop = UDim.new(0, 20)
UIPadding.PaddingBottom = UDim.new(0, 10)
UIPadding.PaddingLeft = UDim.new(0, 10)
UIPadding.PaddingRight = UDim.new(0, 10)
UIPadding.PaddingTop = UDim.new(0, 10)
UIPadding.Parent = Frame

local UIStroke = Instance.new("UIStroke")
UIStroke.Parent = Frame

local UIListLayout = Instance.new("UIListLayout")
UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
UIListLayout.Padding = UDim.new(0, 10)
UIListLayout.Parent = Frame

local numChildren = #Frame:GetChildren()
Expand Down
3 changes: 1 addition & 2 deletions lib/debugger/widgets/hoverInspect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ return function(plasma)
if next(componentData) == nil then
str ..= "{ }"
else
str ..= formatTable(componentData, FormatMode.Long, 0, 2)
str ..= (formatTable(componentData, FormatMode.Long, 0, 2) .. "\n")
end
str ..= "\n"
end

custom.tooltip(str)
Expand Down
6 changes: 3 additions & 3 deletions lib/debugger/widgets/link.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ return function(Plasma)
local button = create("TextButton", {
[ref] = "button",
BackgroundTransparency = 1,
AutomaticSize = Enum.AutomaticSize.XY,
Text = "",
Size = UDim2.new(0, 0, 0, 40),

create("UIPadding", {
PaddingBottom = UDim.new(0, 0),
Expand All @@ -37,7 +37,7 @@ return function(Plasma)
Size = UDim2.new(0, 30, 1, 0),
Text = options.icon,
TextXAlignment = Enum.TextXAlignment.Left,
TextSize = 23,
TextSize = 16,
TextColor3 = style.textColor,
Font = Enum.Font.GothamBold,
}),
Expand All @@ -50,7 +50,7 @@ return function(Plasma)
Text = text,
TextXAlignment = Enum.TextXAlignment.Left,
TextColor3 = color,
TextSize = 19,
TextSize = 16,
}),

Activated = function()
Expand Down
8 changes: 5 additions & 3 deletions lib/debugger/widgets/realmSwitch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ return function(Plasma)
create("TextButton", {
[ref] = "button",
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 0, 30),
Size = UDim2.new(1, 0, 0, 25),
Text = "",

create("UICorner"),
Expand All @@ -34,19 +34,21 @@ return function(Plasma)
Text = left,
Size = UDim2.new(0.5, 0, 1, 0),
BackgroundColor3 = style.primaryColor,
BorderSizePixel = 0,
TextColor3 = style.textColor,
Font = Enum.Font.GothamMedium,
TextSize = 15,
TextSize = 14,
}),

create("TextLabel", {
[ref] = "right",
Text = right,
Size = UDim2.new(0.5, 0, 1, 0),
BackgroundColor3 = style.bg1,
BorderSizePixel = 0,
TextColor3 = style.textColor,
Font = Enum.Font.GothamMedium,
TextSize = 15,
TextSize = 14,
}),

MouseEnter = function()
Expand Down
8 changes: 4 additions & 4 deletions lib/debugger/widgets/selectionList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ return function(Plasma)
local refs = Plasma.useInstance(function(ref)
local button = create("TextButton", {
[ref] = "button",
Size = UDim2.new(1, 0, 0, 40),
Size = UDim2.new(1, 0, 0, 25),
Text = "",

create("UICorner", {
Expand All @@ -34,7 +34,7 @@ return function(Plasma)
Size = UDim2.new(0, 22, 1, 0),
Text = icon,
TextXAlignment = Enum.TextXAlignment.Left,
TextSize = 23,
TextSize = 16,
TextColor3 = style.textColor,
Font = Enum.Font.GothamBold,
}),
Expand All @@ -45,7 +45,7 @@ return function(Plasma)
Size = UDim2.new(0, 0, 1, 0),
Text = text,
TextXAlignment = Enum.TextXAlignment.Left,
TextSize = 19,
TextSize = 16,
TextColor3 = style.textColor,
Font = Enum.Font.SourceSans,
TextTruncate = Enum.TextTruncate.AtEnd,
Expand All @@ -62,7 +62,7 @@ return function(Plasma)
Size = UDim2.new(0, 0, 1, 0),
Text = "",
TextXAlignment = Enum.TextXAlignment.Left,
TextSize = 15,
TextSize = 14,
TextColor3 = style.mutedTextColor,
Font = Enum.Font.SourceSans,
}),
Expand Down
10 changes: 5 additions & 5 deletions lib/debugger/widgets/tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ return function(plasma)
[ref] = "label",
TextXAlignment = Enum.TextXAlignment.Left,
TextYAlignment = Enum.TextYAlignment.Top,
TextSize = 20,
TextSize = 15,
BorderSizePixel = 0,
Font = Enum.Font.Code,
TextStrokeTransparency = 0.5,
Expand All @@ -20,10 +20,10 @@ return function(plasma)
AutomaticSize = Enum.AutomaticSize.XY,

create("UIPadding", {
PaddingBottom = UDim.new(0, 8),
PaddingLeft = UDim.new(0, 8),
PaddingRight = UDim.new(0, 8),
PaddingTop = UDim.new(0, 8),
PaddingBottom = UDim.new(0, 4),
PaddingLeft = UDim.new(0, 4),
PaddingRight = UDim.new(0, 4),
PaddingTop = UDim.new(0, 4),
}),

create("UICorner"),
Expand Down
4 changes: 3 additions & 1 deletion lib/debugger/widgets/valueInspect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ return function(plasma)
return plasma.label("(empty table)")
end

plasma.table(items)
plasma.table(items, {
font = Enum.Font.Code,
})
return nil
end)
:closed()
Expand Down
7 changes: 5 additions & 2 deletions lib/debugger/widgets/worldInspect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ return function(plasma)
end
end

plasma.row(function()
plasma.heading("Size")
plasma.row({
verticalAlignment = Enum.VerticalAlignment.Center,
}, function()
plasma.heading("SIZE:")
plasma.label(
`{world:size()} {if cache.emptyEntities > 0 then `({cache.emptyEntities} empty)` else ""}`
)
Expand Down Expand Up @@ -86,6 +88,7 @@ return function(plasma)
width = 200,
headings = true,
selectable = true,
font = Enum.Font.Code,
})
:selected()

Expand Down
Loading