Skip to content

Commit 0496b3c

Browse files
authored
Merge pull request #2197 from vessellaj/dev
Yush: Added a VerboseKeys setting to enable key display in each macro set.
2 parents fbb2a95 + 5f7fb9a commit 0496b3c

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

addons/Yush/ReadMe.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ The key which resets the current macro set to the previous set.
2929

3030
If true, will display the current macro set you are in. The name it displays is the same name it has in the file it loads.
3131

32+
**VerboseKeys**
33+
34+
If true, will append the list of keybinds for the current macro set (only effective if the *Verbose* setting is `true`).
35+
3236
**VerboseOutput**
3337

3438
Determines where the current macro set will be displayed (only effective if the *Verbose* setting is `true`). The following options are available:

addons/Yush/Yush.lua

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ defaults.ResetKey = '`'
5959
defaults.BackKey = 'backspace'
6060
defaults.Verbose = false
6161
defaults.VerboseOutput = 'Text'
62+
defaults.VerboseKeys = false
6263
defaults.Label = {}
6364

6465
settings = config.load(defaults)
@@ -67,20 +68,32 @@ label = texts.new(settings.Label, settings)
6768

6869
binds = {}
6970
names = {}
71+
key_combos = {}
7072
current = binds
7173
stack = L{binds}
7274
keys = S{}
7375

7476
output = function()
7577
if settings.Verbose then
76-
names[current] = names[current] or 'Unnamed ' .. tostring(current):sub(8)
78+
names[current] = names[current] or 'Unnamed'
79+
80+
local output_text_names = L{}
81+
output_text_names:append(names[current])
82+
if settings.VerboseKeys then
83+
for key, val in pairs(current) do
84+
if type(val) ~= 'string' then
85+
val = names[val] or 'Unnamed'
86+
end
87+
output_text_names:append(key_combos[key] .. ': ' .. val)
88+
end
89+
end
7790

7891
if settings.VerboseOutput == 'Text' then
79-
label:text(names[current])
92+
label:text(output_text_names:concat('\n'))
8093
elseif settings.VerboseOutput == 'Chat' then
81-
log('Changing into macro set %s.':format(names[current]))
94+
log('Changing into macro set %s.':format(output_text_names:concat(' | ')))
8295
elseif settings.VerboseOutput == 'Console' then
83-
print('Changing into macro set %s.':format(names[current]))
96+
print('Changing into macro set %s.':format(output_text_names:concat(' | ')))
8497
end
8598
end
8699
end
@@ -127,12 +140,13 @@ parse_binds = function(fbinds, top)
127140

128141
rawset(names, top, rawget(_innerG._names, fbinds))
129142
for key, val in pairs(fbinds) do
130-
key = S(key:split('+')):map(string.lower)
143+
local split_key = S(key:split('+')):map(string.lower)
144+
rawset(key_combos, split_key, key)
131145
if type(val) == 'string' or type(val) == 'function' then
132-
rawset(top, key, val)
146+
rawset(top, split_key, val)
133147
else
134148
local sub = {}
135-
rawset(top, key, sub)
149+
rawset(top, split_key, sub)
136150
parse_binds(val, sub)
137151
end
138152
end

0 commit comments

Comments
 (0)