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

Sort systems by duration in Debugger (v0.8) #150

Merged
merged 1 commit into from
Dec 9, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog][kac], and this project adheres to

## [Unreleased]

### Added

- Added a button to the Debugger's system list to sort by run time.

### Fixed

- The debugger now gracefully handles cyclic tables.
Expand Down
17 changes: 16 additions & 1 deletion lib/debugger/ui.luau
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,17 @@ local function ui(debugger, loop)
end
end

local sortByDuration, setSortByDuration = plasma.useState(false)

plasma.space(15)
plasma.heading("SYSTEMS")
plasma.row({ verticalAlignment = Enum.VerticalAlignment.Center }, function()
plasma.heading("SYSTEMS")

if plasma.button(`sort by: {sortByDuration and "duration" or "order"}`):clicked() then
setSortByDuration(not sortByDuration)
end
end)

plasma.space(10)

local durations = {}
Expand Down Expand Up @@ -198,6 +207,12 @@ local function ui(debugger, loop)
})
end

if sortByDuration then
table.sort(listOfSystems, function(a, b)
return (durations[a.system] or 0) > (durations[b.system] or 0)
end)
end

local systemList = custom.selectionList(listOfSystems, custom)
local selected = systemList:selected()
local rightClicked = systemList:rightClicked()
Expand Down
3 changes: 2 additions & 1 deletion lib/debugger/widgets/selectionList.luau
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ return function(Plasma)

Plasma.useEffect(function()
refs.mainText.Text = text
refs.index.Text = index or ""
refs.button.container.Icon.Text = icon or ""
refs.button.container.Icon.Visible = icon ~= nil
end, text, icon)
end, text, icon, index)

refs.button.container.sideText.Visible = sideText ~= nil
refs.button.container.sideText.Text = if sideText ~= nil then sideText else ""
Expand Down
Loading