Skip to content

Commit

Permalink
Fix color formatting issues with combining multiple similar condition…
Browse files Browse the repository at this point in the history
…s in 1 condition (fixes #18)
  • Loading branch information
Numynum committed May 7, 2023
1 parent 9011391 commit d46e515
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions MacroToolkit/modules/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ local function validateCondition(condition, optionArguments, parameters)
elseif name:lower() ~= parameters:lower() and optionArguments[1]:lower() ~= parameters:lower() then
local spellID = select(7, GetSpellInfo(parameters))
msg = format(
"Known spell mismatch: [%s%s|r:%s (%s)]\n %s%s",
"Known spell mismatch: [%s%s%s|r:%s (%s)]\n %s%s",
conditionColor,
no and "no" or "",
condition,
optionArguments[1],
name,
Expand Down Expand Up @@ -779,24 +780,28 @@ function MT:ParseMacro(macrotext)
end
for _, c in ipairs(conditions) do
local cps = {strsplit(",", c.c)}
local offset = c.p;
for _, condition_phrase in ipairs(cps) do
spos = string.find(condition_phrase, ":")
wipe(option_arguments)
if spos then
option_arguments = {strsplit("/", string.sub(condition_phrase, spos + 1))}
condition = string.sub(condition_phrase, 1, spos - 1)
else condition = condition_phrase end
else
condition = condition_phrase
end
local colorArguments
color, err, colorArguments = validateCondition(condition, option_arguments, parameters)
if err then table.insert(errors, err) end
pos = string.find(macrotext, escape(condition), c.p)
pos = string.find(macrotext, escape(condition), offset)
table.insert(parsed_text, { t = condition, c = color, s = pos})
if colorArguments then
for _, argument in ipairs(option_arguments) do
pos = string.find(macrotext, escape(argument), pos)
table.insert(parsed_text, { t = argument, c = colorArguments, s = pos})
end
end
offset = offset + string.len(condition_phrase) + 1 -- +1 for the comma
end
end
end
Expand Down

0 comments on commit d46e515

Please sign in to comment.