Skip to content

Commit

Permalink
add migration, fix cast trigger, bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuds committed Aug 14, 2023
1 parent 5f258b1 commit 4d14662
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 11 deletions.
65 changes: 65 additions & 0 deletions WeakAuras/Modernize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1734,5 +1734,70 @@ function Private.Modernize(data)
end
end

if data.internalVersion < 67 then
local function migrateToTable(tab, field)
local value = tab[field]
if value ~= nil and type(value) ~= "table" then
tab[field] = { value }
end
end
do
local trigger_migration = {}
for triggerName, proto in pairs(Private.event_prototypes) do
for _, field in ipairs(proto.args) do
if field.multiEntry then
trigger_migration[triggerName] = trigger_migration[triggerName] or {}
tinsert(trigger_migration[triggerName], field.name)
if field.type == "number" then
tinsert(trigger_migration[triggerName], field.name.."_operator")
end
end
end
end
for _, triggerData in ipairs(data.triggers) do
local t = triggerData.trigger
local fieldsToMigrate = trigger_migration[t.event]
if fieldsToMigrate then
for _, field in ipairs(fieldsToMigrate) do
migrateToTable(t, field)
end
end
-- cast trigger move data from 'spell' & 'spellId' to 'spellIds' & 'spellNames'
if t.event == "Cast" and t.type == "unit" then
if t.spellId then
if t.useExactSpellId then
t.use_spellIds = t.use_spellId
t.spellIds = t.spellIds or {}
tinsert(t.spellIds, t.spellId)
else
t.use_spellNames = t.use_spellId
t.spellNames = t.spellNames or {}
tinsert(t.spellNames, t.spellId)
end
end
if t.use_spell and t.spell then
t.use_spellNames = true
t.spellNames = t.spellNames or {}
tinsert(t.spellNames, t.spell)
end
t.use_spellId = nil
t.spellId = nil
t.use_spell = nil
t.spell = nil
end
end
end
do
for _, field in ipairs(Private.load_prototype.args) do
if field.multiEntry then
migrateToTable(data.load, field.name)
if field.type == "number" then
migrateToTable(data.load, field.name.."_operator")
end
end
end
end
end

data.internalVersion = max(data.internalVersion or 0, WeakAuras.InternalVersion())
end
18 changes: 9 additions & 9 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4948,7 +4948,7 @@ Private.event_prototypes = {
type = "spell",
init = "arg",
showExactOption = true,
test = "Private.ExecEnv.CompareSpellIds(spellName, %s, %s)",
test = "Private.ExecEnv.CompareSpellIds(spellName, %q, %s)",
}
},
nameFunc = function(trigger)
Expand Down Expand Up @@ -5009,7 +5009,7 @@ Private.event_prototypes = {
type = "spell",
init = "arg",
showExactOption = true,
test = "Private.ExecEnv.CompareSpellIds(spellName, %s, %s)",
test = "Private.ExecEnv.CompareSpellIds(spellName, %q, %s)",
},
{
name = "direction",
Expand Down Expand Up @@ -8205,7 +8205,7 @@ Private.event_prototypes = {
display = L["Name(s)"],
type = "spell",
enable = function(trigger) return not trigger.use_inverse end,
test = "Private.ExecEnv.CompareSpellIds(spellId, %s, false)",
test = "Private.ExecEnv.CompareSpellIds(spellId, %q, false)",
multiEntry = {
operator = "or",
},
Expand All @@ -8216,28 +8216,28 @@ Private.event_prototypes = {
display = L["Exact Spell ID(s)"],
type = "spell",
enable = function(trigger) return not trigger.use_inverse end,
test = "Private.ExecEnv.CompareSpellIds(spellId, %s, true)",
test = "Private.ExecEnv.CompareSpellIds(spellId, %q, true)",
multiEntry = {
operator = "or",
},
},
{ -- TODO migrate into spellIds
{
name = "spellId",
display = L["Spell ID"],
conditionType = "number",
store = true,
test = "true",
hidden = true
},
--[[ TODO migrate into spellNames
{
name = "spell",
display = L["Legacy Spellname"],
display = L["Spellname"],
type = "string",
enable = function(trigger) return not trigger.use_inverse end,
conditionType = "string",
store = true,
test = "true",
hidden = true
},
]]
{
name = "castType",
display = L["Cast Type"],
Expand Down
2 changes: 1 addition & 1 deletion WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- @type string, Private
local AddonName, Private = ...

local internalVersion = 66
local internalVersion = 67

-- Lua APIs
local insert = table.insert
Expand Down
2 changes: 1 addition & 1 deletion WeakAurasOptions/LoadOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ function OptionsPrivate.ConstructOptions(prototype, data, startorder, triggernum
order = order + 1;
options[name..suffix] = {
type = "input",
width = (arg.showExactOption and (WeakAuras.doubleWidth - WeakAuras.halfWidth) or WeakAuras.normalWidth) - (arg.showExactOption and 0.2 or 0),
width = (arg.showExactOption and WeakAuras.doubleWidth or WeakAuras.normalWidth) - (arg.showExactOption and 0.2 or 0),
name = arg.display,
order = order,
hidden = hidden,
Expand Down

0 comments on commit 4d14662

Please sign in to comment.