Skip to content

Commit

Permalink
stats.lua: use fixed naming for single invocation key bindings
Browse files Browse the repository at this point in the history
The names of single invocation key bindings for specific pages will be
changed if defines user key bindings, then original invocation fails.

e.g. : when user defines `key_page_4=F4`, then key binding name
`stats/display-page-4-toggle`
becomes
`stats/display-page-F4-toggle`,
and OSC menu `Help` fails.
  • Loading branch information
SeaHOH authored and kasper93 committed Feb 25, 2025
1 parent 883b948 commit 5459b0f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions player/lua/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1431,12 +1431,12 @@ cache_recorder_timer:kill()
-- Current page and <page key>:<page function> mapping
curr_page = o.key_page_1
pages = {
[o.key_page_1] = { f = default_stats, desc = "Default" },
[o.key_page_2] = { f = vo_stats, desc = "Extended Frame Timings", scroll = true },
[o.key_page_3] = { f = cache_stats, desc = "Cache Statistics" },
[o.key_page_4] = { f = keybinding_info, desc = "Active Key Bindings", scroll = true },
[o.key_page_5] = { f = track_info, desc = "Selected Tracks Info", scroll = true },
[o.key_page_0] = { f = perf_stats, desc = "Internal Performance Info", scroll = true },
[o.key_page_1] = { idx = 1, f = default_stats, desc = "Default" },
[o.key_page_2] = { idx = 2, f = vo_stats, desc = "Extended Frame Timings", scroll = true },
[o.key_page_3] = { idx = 3, f = cache_stats, desc = "Cache Statistics" },
[o.key_page_4] = { idx = 4, f = keybinding_info, desc = "Active Key Bindings", scroll = true },
[o.key_page_5] = { idx = 5, f = track_info, desc = "Selected Tracks Info", scroll = true },
[o.key_page_0] = { idx = 0, f = perf_stats, desc = "Internal Performance Info", scroll = true },
}


Expand Down Expand Up @@ -1720,17 +1720,17 @@ mp.add_key_binding(nil, "display-stats", function() process_key_binding(true) en
mp.add_key_binding(nil, "display-stats-toggle", function() process_key_binding(false) end,
{repeatable=false})

for k, _ in pairs(pages) do
for k, page in pairs(pages) do
-- Single invocation key bindings for specific pages, e.g.:
-- "e script-binding stats/display-page-2"
mp.add_key_binding(nil, "display-page-" .. k, function()
mp.add_key_binding(nil, "display-page-" .. page.idx, function()
curr_page = k
process_key_binding(true)
end, {repeatable=true})

-- Key bindings to toggle a specific page, e.g.:
-- "h script-binding stats/display-page-4-toggle".
mp.add_key_binding(nil, "display-page-" .. k .. "-toggle", function()
mp.add_key_binding(nil, "display-page-" .. page.idx .. "-toggle", function()
curr_page = k
process_key_binding(false)
end, {repeatable=false})
Expand Down

0 comments on commit 5459b0f

Please sign in to comment.