From 5459b0ff191b88215848f23750900aca0c0c248a Mon Sep 17 00:00:00 2001 From: SeaHOH Date: Tue, 25 Feb 2025 14:19:48 +0800 Subject: stats.lua: use fixed naming for single invocation key bindings 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. --- player/lua/stats.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'player') diff --git a/player/lua/stats.lua b/player/lua/stats.lua index 2179b2f070..63e87d0eab 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -1431,12 +1431,12 @@ cache_recorder_timer:kill() -- Current page and : 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 }, } @@ -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}) -- cgit v1.2.3