History

stats.lua: allow keybindings to toggle the display of a specific page

This lets you define bindings like h script-binding stats/display-page-4-toggle. Requested in #14966.

Guido Cella committed 2 years ago

Commit 493cab71 parent be814e33 files · +15 −8Browse files

Showing the changes to player/lua/stats.lua (1 of 3 files). Show all

Unified · Split

player/lua/stats.lua+13−7
@@ -1750,14 +1750,20 @@ mp.add_key_binding(nil, "display-stats", function() process_key_binding(true) en · 1749 unmodified lines
1750mp.add_key_binding(nil, "display-stats-toggle", function() process_key_binding(false) end,1750mp.add_key_binding(nil, "display-stats-toggle", function() process_key_binding(false) end,
1751 {repeatable=false})1751 {repeatable=false})
1752 1752
1753-- Single invocation bindings without key, can be used in input.conf to create
1754-- bindings for a specific page: "e script-binding stats/display-page-2"
1755for k, _ in pairs(pages) do1753for k, _ in pairs(pages) do
1756 mp.add_key_binding(nil, "display-page-" .. k,1754 -- Single invocation key bindings for specific pages, e.g.:
1757 function()1755 -- "e script-binding stats/display-page-2"
1758 curr_page = k1756 mp.add_key_binding(nil, "display-page-" .. k, function()
1759 process_key_binding(true)1757 curr_page = k
1760 end, {repeatable=true})1758 process_key_binding(true)
1759 end, {repeatable=true})
1760
1761 -- Key bindings to toggle a specific page, e.g.:
1762 -- "h script-binding stats/display-page-4-toggle".
1763 mp.add_key_binding(nil, "display-page-" .. k .. "-toggle", function()
1764 curr_page = k
1765 process_key_binding(false)
1766 end, {repeatable=true})
1761end1767end
1762 1768
1763-- Reprint stats immediately when VO was reconfigured, only when toggled1769-- Reprint stats immediately when VO was reconfigured, only when toggled

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t