from retail

This commit is contained in:
Bunny67
2020-07-11 00:19:17 +03:00
parent bbb4ac1c37
commit 6a7003b535
27 changed files with 2317 additions and 647 deletions
+124 -13
View File
@@ -51,6 +51,9 @@ function WeakAuras.AddActionOption(id, data)
pcall(PlaySound, v, "Master");
end
WeakAuras.Add(data);
if(value == "message") then
WeakAuras.ReloadOptions(data.id)
end
end,
args = {
init_header = {
@@ -112,7 +115,7 @@ function WeakAuras.AddActionOption(id, data)
type = "input",
width = WeakAuras.normalWidth,
name = L["Send To"],
order = 4,
order = 3.1,
disabled = function() return not data.actions.start.do_message end,
hidden = function() return data.actions.start.message_type ~= "WHISPER" end
},
@@ -120,7 +123,7 @@ function WeakAuras.AddActionOption(id, data)
type = "input",
width = WeakAuras.doubleWidth,
name = L["Message"],
order = 5,
order = 4,
disabled = function() return not data.actions.start.do_message end,
desc = function()
return L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(data)
@@ -131,27 +134,27 @@ function WeakAuras.AddActionOption(id, data)
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Play Sound"],
order = 7
order = 8
},
start_do_loop = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Loop"],
order = 7.1,
order = 8.1,
disabled = function() return not data.actions.start.do_sound end,
},
start_sound_repeat = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Repeat After"],
order = 7.2,
order = 8.2,
hidden = function() return not data.actions.start.do_loop end,
disabled = function() return not data.actions.start.do_sound end,
},
start_sound_repeat_space = {
type = "description",
width = WeakAuras.normalWidth,
order = 7.3,
order = 8.3,
name = "",
hidden = function() return not data.actions.start.do_loop end,
},
@@ -159,7 +162,7 @@ function WeakAuras.AddActionOption(id, data)
type = "select",
width = WeakAuras.normalWidth,
name = L["Sound"],
order = 8,
order = 8.4,
values = sound_types,
disabled = function() return not data.actions.start.do_sound end,
control = "WeakAurasSortedDropdown"
@@ -484,7 +487,7 @@ function WeakAuras.AddActionOption(id, data)
type = "input",
width = WeakAuras.normalWidth,
name = L["Send To"],
order = 24,
order = 23.1,
disabled = function() return not data.actions.finish.do_message end,
hidden = function() return data.actions.finish.message_type ~= "WHISPER" end
},
@@ -492,7 +495,7 @@ function WeakAuras.AddActionOption(id, data)
type = "input",
width = WeakAuras.doubleWidth,
name = L["Message"],
order = 25,
order = 24,
disabled = function() return not data.actions.finish.do_message end,
desc = function()
return L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(data)
@@ -503,13 +506,13 @@ function WeakAuras.AddActionOption(id, data)
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Play Sound"],
order = 27
order = 28
},
finish_sound = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Sound"],
order = 28,
order = 28.1,
values = sound_types,
disabled = function() return not data.actions.finish.do_sound end,
control = "WeakAurasSortedDropdown"
@@ -796,17 +799,125 @@ function WeakAuras.AddActionOption(id, data)
},
}
-- Text format option helpers
WeakAuras.AddCodeOption(action.args, data, L["Custom Code"], "init", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-init",
0.011, function() return not data.actions.init.do_custom end, {"actions", "init", "custom"}, true);
WeakAuras.AddCodeOption(action.args, data, L["Custom Code"], "start_message", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#chat-message---custom-code",
5.1, function() return not (data.actions.start.do_message and WeakAuras.ContainsCustomPlaceHolder(data.actions.start.message)) end, {"actions", "start", "message_custom"}, false);
5, function() return not (data.actions.start.do_message and WeakAuras.ContainsCustomPlaceHolder(data.actions.start.message)) end, {"actions", "start", "message_custom"}, false);
local startHidden = function()
return WeakAuras.IsCollapsed("format_option", "actions", "start_message", true)
end
local startSetHidden = function(hidden)
WeakAuras.SetCollapsed("format_option", "actions", "start_message", hidden)
end
local startGet = function(key)
return data.actions.start["message_format_" .. key]
end
local order = 6
local usedKeys = {}
local function startAddOption(key, option)
if usedKeys[key] then
return
end
usedKeys[key] = true
option.order = order
order = order + 0.01
local reload = option.reloadOptions
option.reloadOptions = nil
option.set = function(info, v)
data.actions.start["message_format_" .. key] = v
WeakAuras.Add(data)
if reload then
WeakAuras.ReloadOptions2(data.id, data)
end
end
if option.hidden then
local hidden = option.hidden
option.hidden = function() return not data.actions.start.do_message or hidden() end
else
option.hidden = function() return not data.actions.start.do_message end
end
action.args["start_message_format_" .. key] = option
end
if data.controlledChildren then
for _, childId in pairs(data.controlledChildren) do
local childData = WeakAuras.GetData(childId)
local startGet = function(key)
return childData.actions.start["message_format_" .. key]
end
WeakAuras.AddTextFormatOption(childData.actions and childData.actions.start.message, true, startGet, startAddOption, startHidden, startSetHidden)
end
else
WeakAuras.AddTextFormatOption(data.actions and data.actions.start.message, true, startGet, startAddOption, startHidden, startSetHidden)
end
WeakAuras.AddCodeOption(action.args, data, L["Custom Code"], "start", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-show",
13, function() return not data.actions.start.do_custom end, {"actions", "start", "custom"}, true);
WeakAuras.AddCodeOption(action.args, data, L["Custom Code"], "finish_message", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#chat-message---custom-code",
26, function() return not (data.actions.finish.do_message and WeakAuras.ContainsCustomPlaceHolder(data.actions.finish.message)) end, {"actions", "finish", "message_custom"}, false);
25, function() return not (data.actions.finish.do_message and WeakAuras.ContainsCustomPlaceHolder(data.actions.finish.message)) end, {"actions", "finish", "message_custom"}, false);
local finishHidden = function()
return WeakAuras.IsCollapsed("format_option", "actions", "finish_message", true)
end
local finishSetHidden = function(hidden)
WeakAuras.SetCollapsed("format_option", "actions", "finish_message", hidden)
end
local finishGet = function(key)
return data.actions.finish["message_format_" .. key]
end
order = 25
usedKeys = {}
local function finishAddOption(key, option)
if usedKeys[key] then
return
end
option.order = order
order = order + 0.01
local reload = option.reloadOptions
option.reloadOptions = nil
option.set = function(info, v)
data.actions.finish["message_format_" .. key] = v
WeakAuras.Add(data)
if reload then
WeakAuras.ReloadOptions2(data.id, data)
end
end
if option.hidden then
local hidden = option.hidden
option.hidden = function() return not data.actions.finish.do_message or hidden() end
else
option.hidden = function() return not data.actions.finish.do_message end
end
action.args["finish_message_format_" .. key] = option
end
if data.controlledChildren then
for _, childId in pairs(data.controlledChildren) do
local childData = WeakAuras.GetData(childId)
local finishGet = function(key)
return childData.actions.finish["message_format_" .. key]
end
WeakAuras.AddTextFormatOption(childData.actions and childData.actions.finish.message, true, finishGet, finishAddOption, finishHidden, finishSetHidden)
end
else
WeakAuras.AddTextFormatOption(data.actions and data.actions.finish.message, true, finishGet, finishAddOption, finishHidden, finishSetHidden)
end
WeakAuras.AddCodeOption(action.args, data, L["Custom Code"], "finish", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-hide",
32, function() return not data.actions.finish.do_custom end, {"actions", "finish", "custom"}, true);
+2 -4
View File
@@ -11,8 +11,7 @@ local group_aura_name_info_types = WeakAuras.group_aura_name_info_types;
local group_aura_stack_info_types = WeakAuras.group_aura_stack_info_types;
local function getAuraMatchesLabel(name)
local iconCache = WeakAuras.spellCache.Get();
local ids = iconCache[name]
local ids = WeakAuras.spellCache.GetSpellsMatching(name)
if(ids) then
local descText = "";
local numMatches = 0;
@@ -37,8 +36,7 @@ local function spellId_tremove(tbl, pos)
end
local function getAuraMatchesList(name)
local iconCache = WeakAuras.spellCache.Get();
local ids = iconCache[name]
local ids = WeakAuras.spellCache.GetSpellsMatching(name)
if(ids) then
local descText = "";
for id, _ in pairs(ids) do
+45 -8
View File
@@ -6,8 +6,7 @@ local operator_types = WeakAuras.operator_types
local debuff_types = WeakAuras.debuff_types
local function getAuraMatchesLabel(name)
local iconCache = WeakAuras.spellCache.Get()
local ids = iconCache[name]
local ids = WeakAuras.spellCache.GetSpellsMatching(name)
if ids then
local descText = ""
local numMatches = 0
@@ -21,8 +20,7 @@ local function getAuraMatchesLabel(name)
end
local function getAuraMatchesList(name)
local iconCache = WeakAuras.spellCache.Get()
local ids = iconCache[name]
local ids = WeakAuras.spellCache.GetSpellsMatching(name)
if ids then
local descText = ""
for id, _ in pairs(ids) do
@@ -695,18 +693,57 @@ local function GetBuffTriggerOptions(data, optionTriggerChoices)
width = WeakAuras.doubleWidth,
hidden = function() return not (trigger.type == "aura2" and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party")) end
},
ignoreInvisible = {
type = "toggle",
name = WeakAuras.newFeatureString .. L["Ignore out of checking range."],
desc = L["Uses UnitIsVisible() to check if in range. This is polled every second."],
order = 68.9,
width = WeakAuras.doubleWidth,
hidden = function() return not (trigger.type == "aura2" and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party")) end
},
useUnitName = {
type = "toggle",
width = "WeakAuras.normalWidth",
name = L["UnitName Filter"],
order = 69.1,
hidden = function() return
not (trigger.type == "aura2" and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"))
end
},
unitName = {
type = "input",
width = WeakAuras.normalWidth,
name = L["Unit Name Filter"],
desc = L["Filter formats: 'Name', 'Name-Realm', '-Realm'.\n\nSupports multiple entries, separated by commas\n"],
order = 69.2,
hidden = function()
return not (trigger.type == "aura2"
and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party") and trigger.useUnitName)
end
},
unitNameSpace = {
type = "description",
name = "",
order = 69.3,
width = WeakAuras.normalWidth,
hidden = function()
return not (trigger.type == "aura2"
and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party") and not trigger.useUnitName)
end
},
useGroup_count = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Unit Count"],
hidden = function() return not (trigger.type == "aura2" and IsGroupTrigger(trigger)) end,
order = 69
order = 70
},
useGroup_countSpace = {
type = "description",
name = "",
order = 69.1,
order = 70.1,
width = WeakAuras.normalWidth,
hidden = function() return not (trigger.type == "aura2" and IsGroupTrigger(trigger) and not trigger.useGroup_count) end
},
@@ -721,7 +758,7 @@ local function GetBuffTriggerOptions(data, optionTriggerChoices)
return L["Group aura count description"]:format(groupType, groupType, groupType, groupType, groupType, groupType, groupType)
end
end,
order = 69.2,
order = 70.2,
width = WeakAuras.halfWidth,
values = operator_types,
hidden = function() return not (trigger.type == "aura2" and IsGroupTrigger(trigger) and trigger.useGroup_count) end,
@@ -738,7 +775,7 @@ local function GetBuffTriggerOptions(data, optionTriggerChoices)
return L["Group aura count description"]:format(groupType, groupType, groupType, groupType, groupType, groupType, groupType)
end
end,
order = 69.3,
order = 70.3,
width = WeakAuras.halfWidth,
hidden = function() return not (trigger.type == "aura2" and IsGroupTrigger(trigger) and trigger.useGroup_count) end,
},
+91 -36
View File
@@ -12,42 +12,70 @@ local spellCache = {}
WeakAuras.spellCache = spellCache
local cache
local metaData
local bestIcon = {}
local dynFrame = WeakAuras.dynFrame
-- Builds a cache of name/icon pairs from existing spell data
-- This is a rather slow operation, so it's only done once, and the result is subsequently saved
function spellCache.Build(callback)
if cache then
local co = coroutine.create(function()
local id = 0
local misses = 0
while misses < 400 do
id = id + 1
local name, _, icon = GetSpellInfo(id)
if(icon == 136243) then -- 136243 is the a gear icon, we can ignore those spells
misses = 0;
elseif name and name ~= "" then
cache[name] = cache[name] or {}
cache[name][id] = icon
misses = 0
else
misses = misses + 1
end
coroutine.yield()
end
if callback then
callback()
end
end)
dynFrame:AddAction(callback, co)
else
function spellCache.Build()
if not cache then
error("spellCache has not been loaded. Call WeakAuras.spellCache.Load(...) first.")
end
if not metaData.needsRebuild then
return
end
wipe(cache)
local co = coroutine.create(function()
local id = 0
local misses = 0
while misses < 400 do
id = id + 1
local name, _, icon = GetSpellInfo(id)
if(icon == 136243) then -- 136243 is the a gear icon, we can ignore those spells
misses = 0;
elseif name and name ~= "" then
cache[name] = cache[name] or {}
cache[name].spells = cache[name].spells or {}
cache[name].spells[id] = icon
misses = 0
else
misses = misses + 1
end
coroutine.yield()
end
for _, category in pairs(GetCategoryList()) do
local total = GetCategoryNumAchievements(category, true)
for i = 1, total do
local id,name,_,_,_,_,_,_,_,iconID = GetAchievementInfo(category, i)
if name and iconID then
cache[name] = cache[name] or {}
cache[name].achievements = cache[name].achievements or {}
cache[name].achievements[id] = iconID
end
end
coroutine.yield()
end
-- Updates the icon cache with whatever icons WeakAuras core has actually used.
-- This helps keep name<->icon matches relevant.
for name, icons in pairs(WeakAurasSaved.dynamicIconCache) do
if WeakAurasSaved.dynamicIconCache[name] then
for spellId, icon in pairs(WeakAurasSaved.dynamicIconCache[name]) do
spellCache.AddIcon(name, spellId, icon)
end
end
end
metaData.needsRebuild = false
end)
dynFrame:AddAction("spellCache", co)
end
function spellCache.GetIcon(name)
@@ -62,22 +90,30 @@ function spellCache.GetIcon(name)
local icons = cache[name]
local bestMatch = nil
if (icons) then
for spellId, icon in pairs(icons) do
if (not bestMatch) then
bestMatch = spellId
elseif(type(spellId) == "number" and IsSpellKnown(spellId)) then
bestMatch = spellId
if (icons.spells) then
for spellId, icon in pairs(icons.spells) do
if (not bestMatch) then
bestMatch = spellId
elseif(type(spellId) == "number" and IsSpellKnown(spellId)) then
bestMatch = spellId
end
end
end
end
bestIcon[name] = bestMatch and icons[bestMatch];
bestIcon[name] = bestMatch and icons.spells[bestMatch];
return bestIcon[name];
else
error("spellCache has not been loaded. Call WeakAuras.spellCache.Load(...) first.")
end
end
function spellCache.GetSpellsMatching(name)
if cache[name] then
return cache[name].spells
end
end
function spellCache.AddIcon(name, id, icon)
if cache then
if name then
@@ -100,7 +136,26 @@ function spellCache.Get()
end
function spellCache.Load(data)
cache = cache or data
metaData = data
cache = metaData.spellCache
local _, build = GetBuildInfo();
local locale = GetLocale();
local version = WeakAuras.versionString
local num = 0;
for i,v in pairs(cache) do
num = num + 1;
end
if(num < 39000 or metaData.locale ~= locale or metaData.build ~= build or metaData.version ~= version or not metaData.spellCacheAchivements) then
metaData.build = build;
metaData.locale = locale;
metaData.version = version;
metaData.spellCacheAchivements = true
metaData.needsRebuild = true
wipe(cache)
end
end
-- This function computes the Levenshtein distance between two strings
+106 -37
View File
@@ -331,7 +331,7 @@ local function addControlsForChange(args, order, data, conditionVariable, condit
WeakAuras.ReloadTriggerOptions(data);
end
setValueComplex = function(property)
setValueComplex = function(property, reloadOptions)
return function(info, v)
for id, reference in pairs(conditions[i].changes[j].references) do
local auraData = WeakAuras.GetData(id);
@@ -346,7 +346,11 @@ local function addControlsForChange(args, order, data, conditionVariable, condit
conditions[i].changes[j].value = {};
end
conditions[i].changes[j].value[property] = v;
WeakAuras.ReloadTriggerOptions(data);
if reloadOptions then
WeakAuras.ReloadOptions2(data.id, data)
else
WeakAuras.ReloadTriggerOptions(data);
end
end
end
@@ -394,13 +398,16 @@ local function addControlsForChange(args, order, data, conditionVariable, condit
WeakAuras.Add(data);
end
setValueComplex = function(property)
setValueComplex = function(property, reloadOptions)
return function(info, v)
if (type (conditions[i].changes[j].value) ~= "table") then
conditions[i].changes[j].value = {};
end
conditions[i].changes[j].value[property] = v;
WeakAuras.Add(data);
if reloadOptions then
WeakAuras.ReloadOptions2(data.id, data)
end
end
end
@@ -671,6 +678,10 @@ local function addControlsForChange(args, order, data, conditionVariable, condit
descMessage = L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(data)
end
local message_getter = function()
return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.message;
end
args["condition" .. i .. "value" .. j .. "message"] = {
type = "input",
width = WeakAuras.doubleWidth,
@@ -680,10 +691,47 @@ local function addControlsForChange(args, order, data, conditionVariable, condit
get = function()
return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.message;
end,
set = setValueComplex("message")
get = message_getter,
set = setValueComplex("message", true)
}
order = order + 1;
local formatGet = function(key)
return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value["message_format_" .. key]
end
local usedKeys = {}
local function addOption(key, option)
if usedKeys[key] then
return
end
usedKeys[key] = true
option.order = order
order = order + 0.01
local fullKey = "condition" .. i .. "value" .. j .. "message_format_" .. key
option.get = function()
return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value["message_format_" .. key];
end
local originalName = option.name
option.name = blueIfNoValue2(data, conditions[i].changes[j], "value", "message_format_" .. key, originalName, originalName)
option.desc = descIfNoValue2(data, conditions[i].changes[j], "value", "message_format_" .. key, nil, option.values)
option.set = setValueComplex("message_format_" .. key, option.reloadOptions)
option.reloadOptions = nil
args[fullKey] = option
end
if data.controlledChildren then
for id, reference in pairs(conditions[i].changes[j].references) do
local input = reference.value and reference.value.message
WeakAuras.AddTextFormatOption(input, false, formatGet, addOption)
end
else
local input = type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value["message"]
WeakAuras.AddTextFormatOption(input, false, formatGet, addOption)
end
local function customHidden()
local message = type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.message;
if (not message) then return true; end
@@ -1434,9 +1482,9 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit
if (currentConditionTemplate.type == "number" or currentConditionTemplate.type == "timer") then
local opTypes = WeakAuras.operator_types
if currentConditionTemplate.operator_types_without_equal then
if currentConditionTemplate.operator_types == "without_equal" then
opTypes = WeakAuras.operator_types_without_equal
elseif currentConditionTemplate.operator_types_only_equal then
elseif currentConditionTemplate.operator_types == "only_equal" then
opTypes = WeakAuras.equality_operator_types
end
@@ -1546,21 +1594,22 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit
}
order = order + 1;
elseif (currentConditionTemplate.type == "string") then
args["condition" .. i .. tostring(path) .. "_op"] = {
name = blueIfNoValue(data, conditions[i].check, "op", L["Differences"]),
desc = descIfNoValue(data, conditions[i].check, "op", currentConditionTemplate.type),
type = "select",
width = WeakAuras.normalWidth,
order = order,
values = WeakAuras.string_operator_types,
get = function()
return check and check.op;
end,
set = setOp
}
order = order + 1;
order = addSpace(args, order);
if currentConditionTemplate.operator_types ~= "none" then
args["condition" .. i .. tostring(path) .. "_op"] = {
name = blueIfNoValue(data, conditions[i].check, "op", L["Differences"]),
desc = descIfNoValue(data, conditions[i].check, "op", currentConditionTemplate.type),
type = "select",
width = WeakAuras.normalWidth,
order = order,
values = WeakAuras.string_operator_types,
get = function()
return check and check.op;
end,
set = setOp
}
order = order + 1;
order = addSpace(args, order);
end
args["condition" .. i .. tostring(path) .. "_value"] = {
type = "input",
@@ -2085,18 +2134,34 @@ local function findMatchingProperty(all, change, id)
return nil;
end
local propertyTypeToSubProperty = {
chat = { "message_type", "message_dest", "message_channel", "message", "custom" },
sound = { "sound", "sound_channel", "sound_path", "sound_kit_id", "sound_repeat", "sound_type"},
customcode = { "custom" },
glowexternal = {
"glow_action", "glow_frame_type", "glow_type",
"glow_frame", "choose_glow_frame",
"use_glow_color", "glow_color",
"glow_lines", "glow_frequency", "glow_length", "glow_thickness", "glow_XOffset", "glow_YOffset",
"glow_scale", "glow_border"
}
};
local noop = function() end
local function SubPropertiesForChange(change)
if change.property == "sound" then
return { "sound", "sound_channel", "sound_path", "sound_kit_id", "sound_repeat", "sound_type"}
elseif change.property == "customcode" then
return { "custom" }
elseif change.property == "glowexternal" then
return {
"glow_action", "glow_frame_type", "glow_type",
"glow_frame", "choose_glow_frame",
"use_glow_color", "glow_color",
"glow_lines", "glow_frequency", "glow_length", "glow_thickness", "glow_XOffset", "glow_YOffset",
"glow_scale", "glow_border"
}
elseif change.property == "chat" then
local result = { "message_type", "message_dest", "message_channel", "message", "custom" }
local input = change.value and change.value.message
if input then
local getter = function(key)
return change.value["message_format_" .. key]
end
WeakAuras.AddTextFormatOption(input, false, getter, function(key)
tinsert(result, "message_format_" .. key)
end)
end
return result
end
end
local subPropertyToType = {
glow_color = "color"
@@ -2115,8 +2180,12 @@ local function mergeConditionChange(all, change, id, changeIndex, allProperties)
all.samevalue = false;
end
else
for _, propertyName in ipairs(propertyTypeToSubProperty[propertyType]) do
if not compareValues(all.value[propertyName], change.value[propertyName], subPropertyToType[propertyName]) then
for _, propertyName in ipairs(SubPropertiesForChange(change)) do
if all.samevalue[propertyName] == nil then
-- NEW not yet seen property
all.value[propertyName] = change.value[propertyName]
all.samevalue[propertyName] = true
elseif not compareValues(all.value[propertyName], change.value[propertyName], subPropertyToType[propertyName]) then
all.value[propertyName] = nil;
if all.samevalue then
all.samevalue[propertyName] = false;
@@ -2172,7 +2241,7 @@ local function mergeCondition(all, aura, id, conditionIndex, allProperties)
local propertyType = change.property and allProperties.propertyMap[change.property] and allProperties.propertyMap[change.property].type;
if (propertyType == "chat" or propertyType == "sound" or propertyType == "customcode" or propertyType == "glowexternal") then
copy.samevalue = {};
for _, propertyName in ipairs(propertyTypeToSubProperty[propertyType]) do
for _, propertyName in ipairs(SubPropertiesForChange(change)) do
copy.samevalue[propertyName] = true;
end
else
@@ -2220,7 +2289,7 @@ local function mergeConditions(all, aura, id, allConditionTemplates, propertyTyp
local propertyType = change.property and propertyTypes.propertyMap[change.property] and propertyTypes.propertyMap[change.property].type;
if (propertyType == "chat" or propertyType == "sound" or propertyType == "customcode" or propertyType == "glowexternal") then
change.samevalue = {};
for _, propertyName in ipairs(propertyTypeToSubProperty[propertyType]) do
for _, propertyName in ipairs(SubPropertiesForChange(change)) do
change.samevalue[propertyName] = true;
end
else
+31 -20
View File
@@ -22,7 +22,7 @@ local function ConstructIconPicker(frame)
group.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -17, 30); -- 12
group.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 17, -50);
group.frame:Hide();
group:SetLayout("flow");
group:SetLayout("fill");
local scroll = AceGUI:Create("ScrollFrame");
scroll:SetLayout("flow");
@@ -48,27 +48,40 @@ local function ConstructIconPicker(frame)
end
local usedIcons = {};
local AddButton = function(name, icon)
local button = AceGUI:Create("WeakAurasIconButton");
button:SetName(name);
button:SetTexture(icon);
button:SetClick(function()
group:Pick(icon);
end);
scroll:AddChild(button);
usedIcons[icon] = true;
end
local num = 0;
if(subname and subname ~= "") then
for name, icons in pairs(spellCache.Get()) do
local bestDistance = math.huge;
local bestName;
if(name:lower():find(subname, 1, true)) then
for spellId, icon in pairs(icons) do
if (not usedIcons[icon]) then
local button = AceGUI:Create("WeakAurasIconButton");
button:SetName(name);
button:SetTexture(icon);
button:SetClick(function()
group:Pick(icon);
end);
scroll:AddChild(button);
usedIcons[icon] = true;
num = num + 1;
if(num >= 500) then
break;
if icons.spells then
for spellId, icon in pairs(icons.spells) do
if (not usedIcons[icon]) then
AddButton(name, icon)
num = num + 1;
if(num >= 500) then
break;
end
end
end
elseif icons.achievements then
for _, icon in pairs(icons.achievements) do
if (not usedIcons[icon]) then
AddButton(name, icon)
num = num + 1;
if(num >= 500) then
break;
end
end
end
end
@@ -88,7 +101,6 @@ local function ConstructIconPicker(frame)
input:SetWidth(170);
input:SetHeight(15);
input:SetPoint("BOTTOMRIGHT", group.frame, "TOPRIGHT", -12, -5);
WeakAuras.input = input;
local inputLabel = input:CreateFontString(nil, "OVERLAY", "GameFontNormal");
inputLabel:SetText(L["Search"]);
@@ -189,7 +201,6 @@ local function ConstructIconPicker(frame)
close:SetWidth(100);
close:SetText(L["Okay"]);
scroll.frame:SetPoint("BOTTOM", close, "TOP", 0, 10);
return group
end
@@ -748,7 +748,7 @@ function WeakAuras.CreateFrame()
tremove(tempGroup.controlledChildren, index)
displayButtons[id]:ClearPick()
WeakAuras.ReloadTriggerOptions(tempGroup)
WeakAuras.AddOption(tempGroup.id, tempGroup)
self:FillOptions(displayOptions[tempGroup.id])
end
@@ -962,7 +962,7 @@ function WeakAuras.CreateFrame()
end
end
WeakAuras.ReloadTriggerOptions(data)
WeakAuras.AddOption(data.id, data)
self:FillOptions(displayOptions[id], tab) -- TODO: remove tab parametter once legacy aura trigger is removed
WeakAuras.SetMoverSizer(id)
@@ -1041,7 +1041,7 @@ function WeakAuras.CreateFrame()
WeakAuras.EnsureOptions(id)
displayButtons[id]:Pick()
tinsert(tempGroup.controlledChildren, id)
WeakAuras.ReloadTriggerOptions(tempGroup)
WeakAuras.AddOption(tempGroup.id, tempGroup)
self:FillOptions(displayOptions[tempGroup.id])
end
end
@@ -1062,7 +1062,7 @@ function WeakAuras.CreateFrame()
tinsert(tempGroup.controlledChildren, id)
end
end
WeakAuras.ReloadTriggerOptions(tempGroup)
WeakAuras.AddOption(tempGroup.id, tempGroup)
self:FillOptions(displayOptions[tempGroup.id])
self.pickedDisplay = tempGroup
end
@@ -146,39 +146,6 @@ function(allstates, event, ...)
index = ,
}
return true
end]=]
},
{
name = "Text: Decimals (percentage)",
snippet = [=[
function()
-- Change percentpower as needed
-- Change [1] to other your trigger number
-- The 0 in `"%.0f"` controls how many decimal places it will round to
if aura_env.states[1] and aura_env.states[1].percentpower then
return string.format("%.0f", aura_env.states[1].percentpower)
end
end]=]
},
{
name = "Text: Abbreviate numbers",
snippet = [=[
function()
-- Change tooltip1 to your value
-- Change [1] to other your trigger number
-- If using a tooltip value, be sure to tick Use Tooltip Values in the trigger
if aura_env.states[1] and aura_env.states[1].tooltip1 then
return AbbreviateNumbers(aura_env.states[1].tooltip1)
end
end]=]
},
{
name = "Text: Colored Name",
snippet = [=[
function()
if aura_env.states[1] and aura_env.states[1].unit then
return WA_ClassColorName(aura_env.states[1].unit)
end
end]=]
},
}
+39 -29
View File
@@ -29,10 +29,11 @@ local function createOptions(id, data)
set = function(info, v)
data.displayText = WeakAuras.ReplaceLocalizedRaidMarkers(v);
WeakAuras.Add(data);
WeakAuras.ReloadOptions2(data.id, data)
WeakAuras.UpdateThumbnail(data);
WeakAuras.SetIconNames(data);
WeakAuras.ResetMoverSizer();
end
end,
},
customTextUpdate = {
type = "select",
@@ -43,33 +44,6 @@ local function createOptions(id, data)
order = 36
},
-- code editor added below
progressPrecision = {
type = "select",
width = WeakAuras.normalWidth,
order = 39,
name = L["Remaining Time Precision"],
values = WeakAuras.precision_types,
get = function() return data.progressPrecision or 1 end,
hidden = function() return not (WeakAuras.ContainsPlaceHolders(data.displayText, "pt"));
end,
disabled = function()
return not WeakAuras.ContainsPlaceHolders(data.displayText, "p");
end
},
totalPrecision = {
type = "select",
width = WeakAuras.normalWidth,
order = 39.5,
name = L["Total Time Precision"],
values = WeakAuras.precision_types,
get = function() return data.totalPrecision or 1 end,
hidden = function()
return not (WeakAuras.ContainsPlaceHolders(data.displayText, "pt"));
end,
disabled = function()
return not WeakAuras.ContainsPlaceHolders(data.displayText, "t");
end
},
font = {
type = "select",
@@ -269,6 +243,43 @@ local function createOptions(id, data)
WeakAuras.AddCodeOption(options, data, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-text",
37, function() return not WeakAuras.ContainsCustomPlaceHolder(data.displayText) end, {"customText"}, false);
-- Add Text Format Options
local input = data.displayText
local hidden = function()
return WeakAuras.IsCollapsed("format_option", "text", "displayText", true)
end
local setHidden = function(hidden)
WeakAuras.SetCollapsed("format_option", "text", "displayText", hidden)
end
local get = function(key)
return data["displayText_format_" .. key]
end
local order = 12
local function addOption(key, option)
option.order = order
order = order + 0.01
if option.reloadOptions then
option.reloadOptions = nil
option.set = function(info, v)
data["displayText_format_" .. key] = v
WeakAuras.Add(data)
WeakAuras.ReloadOptions2(data.id, data)
end
end
options["displayText_format_" .. key] = option
end
WeakAuras.AddTextFormatOption(input, true, get, addOption, hidden, setHidden)
addOption("footer", {
type = "description",
name = "",
width = WeakAuras.doubleWidth,
hidden = hidden
})
return {
text = options;
position = WeakAuras.PositionOptions(id, data, nil, true);
@@ -341,7 +352,6 @@ local function modifyThumbnail(parent, borderframe, data, fullModify, size)
local function UpdateText()
local textStr = data.displayText;
textStr = WeakAuras.ReplacePlaceHolders(textStr, borderframe);
text:SetText(textStr);
rescroll();
end
+1 -1
View File
@@ -134,7 +134,7 @@ local function modifyThumbnail(parent, region, data, fullModify, size)
region.texture:SetHeight(scale * data.height);
end
WeakAuras.SetTexture(region.texture, data.texture);
region.texture:SetTexture(data.texture);
region.texture:SetVertexColor(data.color[1], data.color[2], data.color[3], data.color[4]);
region.texture:SetBlendMode(data.blendMode);
+40 -36
View File
@@ -82,14 +82,14 @@ local function createOptions(parentData, data, index, subIndex)
width = WeakAuras.normalWidth,
dialogControl = "LSM30_Font",
name = L["Font"],
order = 12,
order = 13,
values = AceGUIWidgetLSMlists.font,
},
text_fontSize = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Size"],
order = 13,
order = 14,
min = 6,
softMax = 72,
step = 1,
@@ -423,11 +423,9 @@ local function createOptions(parentData, data, index, subIndex)
end
end
local CheckForTimePlaceHolders = CheckTextOptions("pt")
local commonTextOptions = {
__title = L["Common Text"],
__hidden = function() return hideCustomTextOption() and CheckForTimePlaceHolders() end,
__hidden = function() return hideCustomTextOption() end,
text_customTextUpdate = {
type = "select",
width = WeakAuras.doubleWidth,
@@ -442,42 +440,48 @@ local function createOptions(parentData, data, index, subIndex)
WeakAuras.ReloadOptions2(parentData.id, parentData)
end
},
-- Code Editor added below
text_progressPrecision = {
type = "select",
width = WeakAuras.normalWidth,
hidden = CheckForTimePlaceHolders,
disabled = CheckTextOptions("p"),
order = 5,
name = L["Remaining Time Precision"],
values = WeakAuras.precision_types,
get = function() return parentData.progressPrecision or 1 end,
set = function(info, v)
parentData.progressPrecision = v
WeakAuras.Add(parentData)
WeakAuras.ReloadOptions2(parentData.id, parentData)
end,
},
text_totalPrecision = {
type = "select",
width = WeakAuras.normalWidth,
hidden = CheckForTimePlaceHolders,
disabled = CheckTextOptions("t"),
order = 6,
name = L["Total Time Precision"],
values = WeakAuras.precision_types,
get = function() return parentData.totalPrecision or 1 end,
set = function(info, v)
parentData.totalPrecision = v
WeakAuras.Add(parentData)
WeakAuras.ReloadOptions2(parentData.id, parentData)
end,
},
}
WeakAuras.AddCodeOption(commonTextOptions, parentData, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-text",
4, hideCustomTextOption, {"customText"}, false)
-- Add Text Format Options
local input = data["text_text"]
local hidden = function()
return WeakAuras.IsCollapsed("format_option", "text", "text_text", true)
end
local setHidden = function(hidden)
WeakAuras.SetCollapsed("format_option", "text", "text_text", hidden)
end
local get = function(key)
return data["text_text_format_" .. key]
end
local order = 12
local function addOption(key, option)
option.order = order
order = order + 0.01
if option.reloadOptions then
option.reloadOptions = nil
option.set = function(info, v)
data["text_text_format_" .. key] = v
WeakAuras.Add(parentData)
WeakAuras.ReloadOptions2(parentData.id, parentData)
end
end
options["text_text_format_" .. key] = option
end
WeakAuras.AddTextFormatOption(input, true, get, addOption, hidden, setHidden)
addOption("footer", {
type = "description",
name = "",
width = WeakAuras.doubleWidth,
hidden = hidden
})
return options, commonTextOptions
end
+77 -30
View File
@@ -1064,35 +1064,7 @@ loadedFrame:SetScript("OnEvent", function(self, event, addon)
odb.idCache = nil;
end
odb.spellCache = odb.spellCache or {};
spellCache.Load(odb.spellCache);
local _, build = GetBuildInfo();
local locale = GetLocale();
local version = WeakAuras.versionString
local num = 0;
for i,v in pairs(odb.spellCache) do
num = num + 1;
end
if(num < 39000 or odb.locale ~= locale or odb.build ~= build or odb.version ~= version) then
spellCache.Build();
odb.build = build;
odb.locale = locale;
odb.version = version;
end
-- Updates the icon cache with whatever icons WeakAuras core has actually used.
-- This helps keep name<->icon matches relevant.
for name, icons in pairs(db.dynamicIconCache) do
if db.dynamicIconCache[name] then
for spellId, icon in pairs(db.dynamicIconCache[name]) do
spellCache.AddIcon(name, spellId, icon)
end
end
end
spellCache.Load(odb);
if odb.magnetAlign == nil then
odb.magnetAlign = true
@@ -1392,6 +1364,8 @@ function WeakAuras.ShowOptions(msg)
WeakAuras.Pause();
WeakAuras.SetFakeStates()
WeakAuras.spellCache.Build()
if (firstLoad) then
frame = WeakAuras.CreateFrame();
frame.buttonsScroll.frame:Show();
@@ -2551,7 +2525,7 @@ local function flattenRegionOptions(allOptions, isGroupTab)
end
local function parsePrefix(input, data, create)
local subRegionIndex, property = string.match(input, "^sub%.(%d+)%..+%.(.+)")
local subRegionIndex, property = string.match(input, "^sub%.(%d+)%..-%.(.+)")
subRegionIndex = tonumber(subRegionIndex)
if subRegionIndex then
if create then
@@ -4837,3 +4811,76 @@ end
function WeakAuras.DeleteCollapsedData(id)
collapsedOptions[id] = nil
end
function WeakAuras.AddTextFormatOption(input, withHeader, get, addOption, hidden, setHidden)
local headerOption
if withHeader then
headerOption = {
type = "execute",
control = "WeakAurasExpandSmall",
name = function()
return L["|cFFffcc00Format Options|r"]
end,
width = WeakAuras.doubleWidth,
func = function()
setHidden(not hidden())
end,
image = function()
return hidden() and "Interface\\AddOns\\WeakAuras\\Media\\Textures\\edit" or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\editdown"
end,
imageWidth = 24,
imageHeight = 24
}
addOption("header", headerOption)
else
hidden = false
end
local seenSymbols = {}
WeakAuras.ParseTextStr(input, function(symbol)
if not seenSymbols[symbol] then
local triggerNum, sym = string.match(symbol, "(.+)%.(.+)")
sym = sym or symbol
addOption(symbol .. "desc", {
type = "description",
name = L["Format for %s"]:format("%" .. symbol),
width = WeakAuras.normalWidth,
hidden = hidden
})
if sym == "c" or sym == "i" then
-- No special options for these
else
addOption(symbol .. "_format", {
type = "select",
name = L["Format"],
width = WeakAuras.normalWidth,
values = WeakAuras.format_types_display,
hidden = hidden,
reloadOptions = true
})
local selectedFormat = get(symbol .. "_format")
if (WeakAuras.format_types[selectedFormat]) then
WeakAuras.format_types[selectedFormat].AddOptions(symbol, hidden, addOption, get)
end
end
end
seenSymbols[symbol] = true
end)
if next(seenSymbols) then
local footerOption = {
type = "header",
name = "",
}
addOption("footer", footerOption)
end
if not next(seenSymbols) and withHeader then
headerOption.hidden = true
end
end