Skip to content
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 addons/Yush/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ The key which resets the current macro set to the previous set.

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.

**VerboseKeys**

If true, will append the list of keybinds for the current macro set (only effective if the *Verbose* setting is `true`).

**VerboseOutput**

Determines where the current macro set will be displayed (only effective if the *Verbose* setting is `true`). The following options are available:
Expand Down
28 changes: 21 additions & 7 deletions addons/Yush/Yush.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ defaults.ResetKey = '`'
defaults.BackKey = 'backspace'
defaults.Verbose = false
defaults.VerboseOutput = 'Text'
defaults.VerboseKeys = false
defaults.Label = {}

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

binds = {}
names = {}
key_combos = {}
current = binds
stack = L{binds}
keys = S{}

output = function()
if settings.Verbose then
names[current] = names[current] or 'Unnamed ' .. tostring(current):sub(8)
names[current] = names[current] or 'Unnamed'

local output_text_names = L{}
output_text_names:append(names[current])
if settings.VerboseKeys then
for key, val in pairs(current) do
if type(val) ~= 'string' then
val = names[val] or 'Unnamed'
end
output_text_names:append(key_combos[key] .. ': ' .. val)
end
end

if settings.VerboseOutput == 'Text' then
label:text(names[current])
label:text(output_text_names:concat('\n'))
elseif settings.VerboseOutput == 'Chat' then
log('Changing into macro set %s.':format(names[current]))
log('Changing into macro set %s.':format(output_text_names:concat(' | ')))
elseif settings.VerboseOutput == 'Console' then
print('Changing into macro set %s.':format(names[current]))
print('Changing into macro set %s.':format(output_text_names:concat(' | ')))
end
end
end
Expand Down Expand Up @@ -127,12 +140,13 @@ parse_binds = function(fbinds, top)

rawset(names, top, rawget(_innerG._names, fbinds))
for key, val in pairs(fbinds) do
key = S(key:split('+')):map(string.lower)
local split_key = S(key:split('+')):map(string.lower)
rawset(key_combos, split_key, key)
if type(val) == 'string' or type(val) == 'function' then
rawset(top, key, val)
rawset(top, split_key, val)
else
local sub = {}
rawset(top, key, sub)
rawset(top, split_key, sub)
parse_binds(val, sub)
end
end
Expand Down