diff --git a/WeakAuras/BuffTrigger2.lua b/WeakAuras/BuffTrigger2.lua index 94c9dfc..2cebaf4 100644 --- a/WeakAuras/BuffTrigger2.lua +++ b/WeakAuras/BuffTrigger2.lua @@ -342,12 +342,12 @@ local function UpdateMatchData(time, matchDataChanged, unit, index, filter, name return changed or data.lastChanged == time end -local function calculateNextCheck(triggerInfoRemaing, auraDataRemaing, auraDataExpirationTime, nextCheck) - if auraDataRemaing > 0 and auraDataRemaing >= triggerInfoRemaing then +local function calculateNextCheck(triggerInfoRemaining, auraDataRemaining, auraDataExpirationTime, nextCheck) + if auraDataRemaining > 0 and auraDataRemaining >= triggerInfoRemaining then if not nextCheck then - return auraDataExpirationTime - triggerInfoRemaing + return auraDataExpirationTime - triggerInfoRemaining else - return min(auraDataExpirationTime - triggerInfoRemaing, nextCheck) + return min(auraDataExpirationTime - triggerInfoRemaining, nextCheck) end end return nextCheck @@ -815,7 +815,7 @@ local function GetAllUnits(unit, allUnits) local i = 1 local max if unit == "boss" then - max = 4 + max = MAX_BOSS_FRAMES elseif unit == "arena" then max = 5 else @@ -873,7 +873,7 @@ local function TriggerInfoApplies(triggerInfo, unit) if triggerInfo.unit == "group" and triggerInfo.groupSubType == "party" then if IsInRaid() then -- Filter our player/party# while in raid and keep only raid units that are correct - if unit:sub(1,4) ~= "raid" or not UnitIsUnit("player", unit) then + if not WeakAuras.multiUnitUnits.raid[unit] or not UnitIsUnit("player", unit) then return false end else @@ -884,11 +884,11 @@ local function TriggerInfoApplies(triggerInfo, unit) end -- Filter our player/party# while in raid - if (triggerInfo.unit == "group" and triggerInfo.groupSubType == "group" and IsInRaid() and unit:sub(1,4) ~= "raid") then + if (triggerInfo.unit == "group" and triggerInfo.groupSubType == "group" and IsInRaid() and not WeakAuras.multiUnitUnits.raid[unit]) then return false end - if triggerInfo.unit == "group" and triggerInfo.groupSubType == "raid" and unit:sub(1,4) ~= "raid" then + if triggerInfo.unit == "group" and triggerInfo.groupSubType == "raid" and not WeakAuras.multiUnitUnits.raid[unit] then return false end @@ -1356,13 +1356,13 @@ end local function ScanUnit(time, arg1) if not arg1 then return end - if (arg1:sub(1,4) == "raid" and IsInRaid()) then + if (WeakAuras.multiUnitUnits.raid[arg1] and IsInRaid()) then ScanGroupUnit(time, matchDataChanged, "group", arg1) - elseif ((arg1:sub(1,5) == "party" or arg1 == "player") and not IsInRaid()) then + elseif (WeakAuras.multiUnitUnits.party[arg1] and not IsInRaid()) then ScanGroupUnit(time, matchDataChanged, "group", arg1) - elseif arg1:sub(1,4) == "boss" then + elseif WeakAuras.multiUnitUnits.boss[arg1] then ScanGroupUnit(time, matchDataChanged, "boss", arg1) - elseif arg1:sub(1,5) == "arena" then + elseif WeakAuras.multiUnitUnits.arena[arg1] then ScanGroupUnit(time, matchDataChanged, "arena", arg1) else ScanGroupUnit(time, matchDataChanged, nil, arg1) @@ -1506,7 +1506,7 @@ local function EventHandler(frame, event, arg1, arg2, ...) tinsert(unitsToRemove, unit) end end - elseif event == "PARTY_MEMBERS_CHANGED" or event == "RAID_ROSTER_UPDATE" then + elseif event == "PARTY_MEMBERS_CHANGED" or event == "RAID_ROSTER_UPDATE" then local unitsToCheck = {} for unit in GetAllUnits("group", true) do RecheckActiveForUnitType("group", unit, deactivatedTriggerInfos) @@ -1515,11 +1515,11 @@ local function EventHandler(frame, event, arg1, arg2, ...) end end elseif event == "UNIT_FLAGS" then - if arg1:sub(1,4) == "raid" or arg1:sub(1, 5) == "party" or arg1 == "player" then + if WeakAuras.multiUnitUnits.group[arg1] then RecheckActiveForUnitType("group", arg1, deactivatedTriggerInfos) end elseif event == "PLAYER_FLAGS_CHANGED" then - if arg1:sub(1,4) == "raid" or arg1:sub(1, 5) == "party" or arg1 == "player" then + if WeakAuras.multiUnitUnits.group[arg1] then RecheckActiveForUnitType("group", arg1, deactivatedTriggerInfos) end elseif event == "UNIT_ENTERED_VEHICLE" or event == "UNIT_EXITED_VEHICLE" then diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index b3ecd83..102b015 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -938,7 +938,7 @@ end local function MultiUnitLoop(Func, unit, ...) unit = string.lower(unit) if unit == "boss" or unit == "arena" then - for i = 1, 5 do + for i = 1, MAX_BOSS_FRAMES do Func(unit..i, ...) end elseif unit == "group" then @@ -2503,6 +2503,7 @@ function WeakAuras.WatchUnitChange(unit) watchUnitChange:RegisterEvent("PLAYER_TARGET_CHANGED") watchUnitChange:RegisterEvent("PLAYER_FOCUS_CHANGED"); watchUnitChange:RegisterEvent("UNIT_TARGET"); + watchUnitChange:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT"); watchUnitChange:RegisterEvent("PARTY_MEMBERS_CHANGED"); watchUnitChange:RegisterEvent("RAID_ROSTER_UPDATE"); watchUnitChange:RegisterEvent("PLAYER_ENTERING_WORLD") @@ -3036,10 +3037,9 @@ do if(v:GetObjectType() == "FontString") then local text = v:GetText(); if(text) then - local _, _, name = text:find("^(.+) %(%d+ [^%)]+%)$"); + local _, _, name, shortenedName = text:find("^((.-) ?+?[VI%d]*) %(%d+ .+%)$"); if(name) then - local _, _, shortenedName = name:find("^(.+) [VI%d]+$") - return name, shortenedName or name; + return name, shortenedName; end end end diff --git a/WeakAuras/RegionTypes/AuraBar.lua b/WeakAuras/RegionTypes/AuraBar.lua index ef89e0b..d78b19d 100644 --- a/WeakAuras/RegionTypes/AuraBar.lua +++ b/WeakAuras/RegionTypes/AuraBar.lua @@ -552,68 +552,143 @@ local barPrototype = { ["orientation"] = "HORIZONTAL", } -local function AnchorSubRegion(self, subRegion, anchorType, selfPoint, anchorPoint, anchorXOffset, anchorYOffset) - if anchorType == "area" then - local anchor = self - if selfPoint == "bar" then - anchor = self - elseif selfPoint == "icon" then - anchor = self.icon - elseif selfPoint == "fg" then - anchor = self.bar.fgFrame - elseif selfPoint == "bg" then - anchor = self.bar.bg - end - - anchorXOffset = anchorXOffset or 0 - anchorYOffset = anchorYOffset or 0 - subRegion:ClearAllPoints() - subRegion:SetPoint("bottomleft", anchor, "bottomleft", -anchorXOffset, -anchorYOffset) - subRegion:SetPoint("topright", anchor, "topright", anchorXOffset, anchorYOffset) - else - subRegion:ClearAllPoints() - anchorPoint = anchorPoint or "CENTER" - - local anchorRegion = self.bar - - anchorXOffset = anchorXOffset or 0 - anchorYOffset = anchorYOffset or 0 - - if anchorPoint:sub(1, 5) == "ICON_" then - anchorRegion = self.icon - anchorPoint = anchorPoint:sub(6) - elseif anchorPoint:sub(1, 6) == "INNER_" then - anchorPoint = anchorPoint:sub(7) - - if anchorPoint:find("LEFT", 1, true) then - anchorXOffset = anchorXOffset + 2 - elseif anchorPoint:find("RIGHT", 1, true) then - anchorXOffset = anchorXOffset - 2 +local funcs = { + AnchorSubRegion = function(self, subRegion, anchorType, selfPoint, anchorPoint, anchorXOffset, anchorYOffset) + if anchorType == "area" then + local anchor = self + if selfPoint == "bar" then + anchor = self + elseif selfPoint == "icon" then + anchor = self.icon + elseif selfPoint == "fg" then + anchor = self.bar.fgFrame + elseif selfPoint == "bg" then + anchor = self.bar.bg end - if anchorPoint:find("TOP", 1, true) then - anchorYOffset = anchorYOffset - 2 - elseif anchorPoint:find("BOTTOM", 1, true) then - anchorYOffset = anchorYOffset + 2 + anchorXOffset = anchorXOffset or 0 + anchorYOffset = anchorYOffset or 0 + subRegion:ClearAllPoints() + subRegion:SetPoint("bottomleft", anchor, "bottomleft", -anchorXOffset, -anchorYOffset) + subRegion:SetPoint("topright", anchor, "topright", anchorXOffset, anchorYOffset) + else + subRegion:ClearAllPoints() + anchorPoint = anchorPoint or "CENTER" + + local anchorRegion = self.bar + + anchorXOffset = anchorXOffset or 0 + anchorYOffset = anchorYOffset or 0 + + if anchorPoint:sub(1, 5) == "ICON_" then + anchorRegion = self.icon + anchorPoint = anchorPoint:sub(6) + elseif anchorPoint:sub(1, 6) == "INNER_" then + anchorPoint = anchorPoint:sub(7) + + if anchorPoint:find("LEFT", 1, true) then + anchorXOffset = anchorXOffset + 2 + elseif anchorPoint:find("RIGHT", 1, true) then + anchorXOffset = anchorXOffset - 2 + end + + if anchorPoint:find("TOP", 1, true) then + anchorYOffset = anchorYOffset - 2 + elseif anchorPoint:find("BOTTOM", 1, true) then + anchorYOffset = anchorYOffset + 2 + end + elseif anchorPoint == "SPARK" then + anchorRegion = self.bar.spark + anchorPoint = "CENTER" end - elseif anchorPoint == "SPARK" then - anchorRegion = self.bar.spark - anchorPoint = "CENTER" + + selfPoint = selfPoint or "CENTER" + + if not WeakAuras.point_types[selfPoint] then + selfPoint = "CENTER" + end + + if not WeakAuras.point_types[anchorPoint] then + anchorPoint = "CENTER" + end + + subRegion:SetPoint(selfPoint, anchorRegion, anchorPoint, anchorXOffset, anchorYOffset) + end + end, + SetIconColor = function(self, r, g, b, a) + self.icon:SetVertexColor(r, g, b, a); + end, + SetIconDesaturated = function(self, b) + self.icon:SetDesaturated(b); + end, + SetBackgroundColor = function (self, r, g, b, a) + self.bar:SetBackgroundColor(r, g, b, a); + end, + SetSparkColor = function(self, r, g, b, a) + self.bar.spark:SetVertexColor(r, g, b, a); + end, + SetSparkHeight = function(self, height) + self.bar.spark:SetHeight(height); + end, + SetSparkWidth = function(self, width) + self.bar.spark:SetWidth(width); + end, + SetRegionWidth = function(self, width) + self.width = width; + self:Scale(self.scalex, self.scaley); + end, + SetRegionHeight = function(self, height) + self.height = height; + self:Scale(self.scalex, self.scaley); + end, + SetValue = function(self, value, total) + local progress = 0; + if (total ~= 0) then + progress = value / total; end - selfPoint = selfPoint or "CENTER" - - if not WeakAuras.point_types[selfPoint] then - selfPoint = "CENTER" + if self.inverseDirection then + progress = 1 - progress; end - if not WeakAuras.point_types[anchorPoint] then - anchorPoint = "CENTER" + self.bar:SetValue(progress); + end, + SetTime = function(self, duration, expirationTime, inverse) + local remaining = expirationTime - GetTime(); + local progress = duration ~= 0 and remaining / duration or 0; + -- Need to invert? + if ( + (self.inverseDirection and not inverse) + or (inverse and not self.inverseDirection) + ) + then + progress = 1 - progress; end - - subRegion:SetPoint(selfPoint, anchorRegion, anchorPoint, anchorXOffset, anchorYOffset) + self.bar:SetValue(progress); + end, + SetInverse = function(self, inverse) + if (self.inverseDirection == inverse) then + return; + end + self.inverseDirection = inverse; + self.bar:SetValue(1 - self.bar:GetValue()); + self.subRegionEvents:Notify("InverseChanged") + end, + SetOrientation = function(self, orientation) + self.orientation = orientation + self:UpdateEffectiveOrientation() + self.bar:SetValue(self.bar:GetValue()); + end, + SetOverlayColor = function(self, id, r, g, b, a) + self.bar:SetAdditionalBarColor(id, { r, g, b, a}); + end, + GetEffectiveOrientation = function(self) + return self.effectiveOrientation + end, + GetInverse = function(self) + return self.inverseDirection end -end +} -- Called when first creating a new region/display local function create(parent) @@ -625,7 +700,6 @@ local function create(parent) -- Create statusbar (inherit prototype) local bar = CreateFrame("FRAME", nil, region); - WeakAuras:Mixin(bar, SmoothStatusBarMixin); local fg = bar:CreateTexture(nil, "BORDER"); local bg = bar:CreateTexture(nil, "BACKGROUND"); bg:SetAllPoints(); @@ -664,7 +738,9 @@ local function create(parent) WeakAuras.regionPrototype.create(region); - region.AnchorSubRegion = AnchorSubRegion + for k, f in pairs(funcs) do + region[k] = f + end -- Return new display/region return region; @@ -810,12 +886,6 @@ local function orientVertical(region, data) bar:SetOrientation("VERTICAL"); end -local function orient(region, data, orientation) - -- Apply correct orientation - region.orientation = orientation; - region:UpdateEffectiveOrientation() -end - local function GetTexCoordZoom(texWidth) local texCoord = {texWidth, texWidth, texWidth, 1 - texWidth, 1 - texWidth, texWidth, 1 - texWidth, 1 - texWidth} return unpack(texCoord) @@ -959,6 +1029,8 @@ local function modify(parent, region, data) orientVertical(region, data); end end + + region.subRegionEvents:Notify("OrientationChanged") end -- Apply orientation alignment @@ -1090,123 +1162,16 @@ local function modify(parent, region, data) region.flipY = false end - region:UpdateEffectiveOrientation() - -- Update height self.bar.totalHeight = region.height * scaley self.bar.iconHeight = iconsize * scaley self:SetHeight(self.bar.totalHeight); icon:SetHeight(self.bar.iconHeight); + + region:UpdateEffectiveOrientation() end -- region:Scale(1.0, 1.0); - if data.smoothProgress then - region.PreShow = function() - region.bar:ResetSmoothedValue(); - end - else - region.PreShow = nil - end - function region:SetValue(value, total) - local progress = 0; - if (total ~= 0) then - progress = value / total; - end - - if region.inverseDirection then - progress = 1 - progress; - end - - if (data.smoothProgress) then - region.bar.targetValue = progress - region.bar:SetSmoothedValue(progress); - else - region.bar:SetValue(progress); - end - end - - function region:SetTime(duration, expirationTime, inverse) - local remaining = expirationTime - GetTime(); - local progress = duration ~= 0 and remaining / duration or 0; - -- Need to invert? - if ( - (region.inverseDirection and not inverse) - or (inverse and not region.inverseDirection) - ) - then - progress = 1 - progress; - end - if (data.smoothProgress) then - region.bar.targetValue = progress - region.bar:SetSmoothedValue(progress); - else - region.bar:SetValue(progress); - end - end - - function region:SetIconColor(r, g, b, a) - self.icon:SetVertexColor(r, g, b, a); - end - - function region:SetIconDesaturated(b) - self.icon:SetDesaturated(b); - end - - function region:SetBackgroundColor(r, g, b, a) - self.bar:SetBackgroundColor(r, g, b, a); - end - - function region:SetSparkColor(r, g, b, a) - self.bar.spark:SetVertexColor(r, g, b, a); - end - - function region:SetSparkHeight(height) - self.bar.spark:SetHeight(height); - end - - function region:SetSparkWidth(width) - self.bar.spark:SetWidth(width); - end - - function region:SetRegionWidth(width) - self.width = width; - self:Scale(self.scalex, self.scaley); - end - - function region:SetRegionHeight(height) - self.height = height; - self:Scale(self.scalex, self.scaley); - end - - function region:SetInverse(inverse) - if (region.inverseDirection == inverse) then - return; - end - region.inverseDirection = inverse; - if (data.smoothProgress) then - if (region.bar.targetValue) then - region.bar.targetValue = 1 - region.bar.targetValue - region.bar:SetSmoothedValue(region.bar.targetValue); - end - else - region.bar:SetValue(1 - region.bar:GetValue()); - end - end - - function region:SetOrientation(orientation) - orient(region, data, orientation); - if (data.smoothProgress) then - if region.bar.targetValue then - region.bar:SetSmoothedValue(region.bar.targetValue); - end - else - region.bar:SetValue(region.bar:GetValue()); - end - end - - function region:SetOverlayColor(id, r, g, b, a) - region.bar:SetAdditionalBarColor(id, { r, g, b, a}); - end -- Update internal bar alignment region.bar:Update(); diff --git a/WeakAuras/RegionTypes/RegionPrototype.lua b/WeakAuras/RegionTypes/RegionPrototype.lua index d77b041..bcd0273 100644 --- a/WeakAuras/RegionTypes/RegionPrototype.lua +++ b/WeakAuras/RegionTypes/RegionPrototype.lua @@ -23,7 +23,7 @@ local SubRegionEventSystem = end, RemoveSubscriber = function(self, event, subRegion) - tremove(self.events[event], subRegion) + tremove(self.events[event], tIndexOf(self.events[event], subRegion)) end, Notify = function(self, event, ...) diff --git a/WeakAuras/SubRegionTypes/Tick.lua b/WeakAuras/SubRegionTypes/Tick.lua new file mode 100644 index 0000000..e88b9a3 --- /dev/null +++ b/WeakAuras/SubRegionTypes/Tick.lua @@ -0,0 +1,340 @@ +if not WeakAuras.IsCorrectVersion() then return end + +local SharedMedia = LibStub("LibSharedMedia-3.0"); +local L = WeakAuras.L; + +local default = function(parentType) + return { + tick_visible = true, + tick_color = {1, 1, 1, 1}, + tick_placement_mode = "AtValue", + tick_placement = "50", + automatic_length = true, + tick_thickness = 2, + tick_length = 30, + } +end + +local properties = { + tick_visible = { + display = L["Visibility"], + setter = "SetVisible", + type = "bool", + defaultProperty = true, + }, + tick_color = { + display = L["Color"], + setter = "SetTickColor", + type = "color", + }, + tick_placement_mode = { + display = L["Placement Mode"], + setter = "SetTickPlacementMode", + type = "list", + values = WeakAuras.tick_placement_modes, + }, + tick_placement = { + display = L["Placement"], + setter = "SetTickPlacement", + type = "number", + validate = WeakAuras.ValidateNumeric, + }, + automatic_length = { + display = L["Automatic Length"], + setter = "SetAutomaticLength", + type = "bool", + defaultProperty = true, + }, + tick_thickness = { + display = L["Thickness"], + setter = "SetTickThickness", + type = "number", + min = 0, + bigStep = 1, + default = 2, + }, + tick_length = { + display = L["Length"], + setter = "SetTickLength", + type = "number", + min = 0, + bigStep = 1, + default = 30, + }, +} + +local auraBarAnchor = { + ["HORIZONTAL"] = "LEFT", + ["HORIZONTAL_INVERSE"] = "RIGHT", + ["VERTICAL"] = "TOP", + ["VERTICAL_INVERSE"] = "BOTTOM", +} + +local auraBarAnchorInverse = { + ["HORIZONTAL"] = "RIGHT", + ["HORIZONTAL_INVERSE"] = "LEFT", + ["VERTICAL"] = "BOTTOM", + ["VERTICAL_INVERSE"] = "TOP", +} + +local function create() + local subRegion = CreateFrame("FRAME", nil, UIParent) + subRegion.texture = subRegion:CreateTexture() + subRegion.texture:SetDrawLayer("ARTWORK", 3) + subRegion.texture:SetAllPoints(subRegion) + return subRegion +end + +local function onAcquire(subRegion) + subRegion:Show() +end + +local function onRelease(subRegion) + subRegion:Hide() +end + +local funcs = { + Update = function(self, state) + self.trigger_inverse = state.inverse + self.state = state + if state.progressType == "timed" then + self.trigger_total = state.duration + elseif state.progressType == "static" then + self.trigger_total = state.total + else + self.trigger_total = nil + end + self:UpdateVisible() + self:UpdateTickPlacement(); + self:UpdateTimerTick() + end, + OrientationChanged = function(self) + self.orientation = self.parent:GetEffectiveOrientation() + self.vertical = (self.orientation == "VERTICAL") or (self.orientation == "VERTICAL_INVERSE") + + self:UpdateTickPlacement() + self:UpdateTickSize() + end, + OnSizeChanged = function(self) + if self.vertical then + self.parentMinorSize, self.parentMajorSize = self.parent.bar:GetRealSize() + else + self.parentMajorSize, self.parentMinorSize = self.parent.bar:GetRealSize() + end + + self:UpdateTickPlacement() + self:UpdateTickSize() + end, + InverseChanged = function(self) + self.inverse = self.parent:GetInverse() + self:UpdateTickPlacement() + end, + SetVisible = function(self, visible) + if self.tick_visible ~= visible then + self.tick_visible = visible + self:UpdateVisible() + end + end, + UpdateVisible = function(self) + local missingProgress = self.tick_placement_mode == "AtValue" and not self.trigger_total + if self.tick_visible and not missingProgress then + self:Show() + else + self:Hide() + end + end, + SetTickColor = function(self, r, g, b, a) + self.tick_color[1], self.tick_color[2], self.tick_color[3], self.tick_color[4] = r, g, b, a or 1 + self.texture:SetTexture(r, g, b, a or 1) + end, + SetTickPlacementMode = function(self, placement_mode) + if self.tick_placement_mode ~= placement_mode then + self.tick_placement_mode = placement_mode + self:UpdateTickPlacement() + self:UpdateVisible() + self:UpdateTimerTick() + end + end, + UpdateTimerTick = function(self) + if self.tick_placement_mode == "ValueOffset" and self.state and self.state.progressType == "timed" then + if not self.TimerTick then + self.TimerTick = self.UpdateTickPlacement + self.parent:UpdateRegionHasTimerTick() + self.parent.subRegionEvents:AddSubscriber("TimerTick", self) + end + else + if self.TimerTick then + self.TimerTick = nil + self.parent:UpdateRegionHasTimerTick() + self.parent.subRegionEvents:RemoveSubscriber("TimerTick", self) + end + end + end, + SetTickPlacement = function(self, placement) + placement = tonumber(placement) + if self.tick_placement ~= placement then + self.tick_placement = placement + self:UpdateTickPlacement() + end + end, + UpdateTickPlacement = function(self) + local offset, offsetx, offsety = self.tick_placement, 0, 0 + local width = self.parentMajorSize + + local hide = false + if self.tick_placement_mode == "AtValue" then + local percent = self.trigger_total and self.trigger_total ~= 0 and self.tick_placement / self.trigger_total + + if not self.trigger_total or percent < 0 or percent > 1 then + hide = true + offset = 0 + else + offset = percent * width + end + elseif self.tick_placement_mode == "AtMissingValue" then + local percent = self.trigger_total and self.trigger_total ~= 0 and self.tick_placement / self.trigger_total + percent = 1 - percent + if not self.trigger_total or percent < 0 or percent > 1 then + hide = true + offset = 0 + else + offset = percent * width + end + elseif self.tick_placement_mode == "AtPercent" then + if self.tick_placement >= 0 and self.tick_placement <= 100 then + offset = (self.tick_placement / 100) * width + else + hide = true + offset = 0 + end + elseif self.tick_placement_mode == "ValueOffset" then + if self.trigger_total and self.trigger_total ~= 0 then + local atValue + if self.state.progressType == "timed" then + atValue = self.state.expirationTime - GetTime() + self.tick_placement + else + atValue = self.state.value + self.tick_placement + end + + local percent = atValue / self.trigger_total + if not self.trigger_total or percent < 0 or percent > 1 then + hide = true + offset = 0 + else + offset = percent * width + end + else + hide = true + offset = 0 + end + end + + if hide then + self.texture:Hide() + else + self.texture:Show() + end + + + + local inverse = self.inverse + if self.trigger_inverse then + inverse = not inverse + end + + if (self.orientation == "HORIZONTAL_INVERSE") or (self.orientation == "VERTICAL") then + offset = -offset + end + + if inverse then + offset = -offset + end + + if (self.vertical) then + offsety = offset + else + offsetx = offset + end + local side = inverse and auraBarAnchorInverse or auraBarAnchor + self:ClearAllPoints() + self:SetPoint("CENTER", self.parent.bar, side[self.orientation], offsetx, offsety) + end, + SetAutomaticLength = function(self, automatic_length) + if self.automatic_length ~= automatic_length then + self.automatic_length = automatic_length + self:UpdateTickSize() + end + end, + SetTickThickness = function(self, thickness, forced) + if self.tick_thickness ~= thickness then + self.tick_thickness = thickness + self:UpdateTickSize() + end + end, + SetTickLength = function(self, length, forced) + if self.length ~= length then + self.tick_length = length + self:UpdateTickSize() + end + end, + UpdateTickSize = function(self) + if self.vertical then + self:SetHeight(self.tick_thickness) + else + self:SetWidth(self.tick_thickness) + end + + local length = self.automatic_length and self.parentMinorSize or self.tick_length + if self.vertical then + self:SetWidth(length) + else + self:SetHeight(length) + end + end +} + +local function modify(parent, region, parentData, data, first) + + region:SetParent(parent) + region.orientation = parent.effectiveOrientation + region.inverse = parentData.inverse + region.trigger_inverse = false + region.vertical = region.orientation == "VERTICAL" or region.orientation == "VERTICAL_INVERSE" + if (region.vertical) then + region.parentMinorSize, region.parentMajorSize = parent.bar:GetRealSize() + else + region.parentMajorSize, region.parentMinorSize = parent.bar:GetRealSize() + end + + region.parent = parent + region.parentData = parentData + region.tick_visible = data.tick_visible + region.tick_color = data.tick_color + region.tick_placement_mode = data.tick_placement_mode + region.tick_placement = tonumber(data.tick_placement) + region.automatic_length = data.automatic_length + region.tick_thickness = data.tick_thickness + region.tick_length = data.tick_length + + for k, v in pairs(funcs) do + region[k] = v + end + + region:SetVisible(data.tick_visible) + region:SetTickColor(unpack(data.tick_color)) + + region:UpdateTickSize() + + parent.subRegionEvents:AddSubscriber("Update", region) + parent.subRegionEvents:AddSubscriber("OrientationChanged", region) + parent.subRegionEvents:AddSubscriber("InverseChanged", region) + parent:SetScript("OnSizeChanged", function() region:OnSizeChanged() end) + + region.TimerTick = nil +end + +local function supports(regionType) + return regionType == "aurabar" +end + +WeakAuras.RegisterSubRegionType("subtick", L["Tick"], supports, create, modify, onAcquire, onRelease, default, nil, properties); diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index ff641d3..e2ca16e 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -330,6 +330,13 @@ WeakAuras.spark_hide_types = { BOTH = L["Full/Empty"] } +WeakAuras.tick_placement_modes = { + AtValue = L["At Value"], + AtMissingValue = L["At missing Value"], + AtPercent = L["At Percent"], + ValueOffset = L["Offset from progress"] +} + WeakAuras.containment_types = { OUTSIDE = L["Outside"], INSIDE = L["Inside"] diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index 590b1ff..10d3fed 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -1917,7 +1917,7 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...) local _, class = UnitClass("player"); - local incombat = UnitAffectingCombat("player") -- or UnitAffectingCombat("pet"); + local inCombat = UnitAffectingCombat("player") -- or UnitAffectingCombat("pet"); local vehicle = UnitInVehicle("player") or UnitOnTaxi("player") local vehicleUi = UnitHasVehicleUI("player") @@ -1936,8 +1936,8 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...) if (data and not data.controlledChildren) then local loadFunc = loadFuncs[id]; local loadOpt = loadFuncsForOptions[id]; - shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", incombat, vehicle, vehicleUi, group, player, realm, class, faction, playerLevel, zone, size, difficulty); - couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", incombat, vehicle, vehicleUi, group, player, realm, class, faction, playerLevel, zone, size, difficulty); + shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, vehicle, vehicleUi, group, player, realm, class, faction, playerLevel, zone, size, difficulty); + couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, vehicle, vehicleUi, group, player, realm, class, faction, playerLevel, zone, size, difficulty); if(shouldBeLoaded and not loaded[id]) then changed = changed + 1; @@ -2032,18 +2032,6 @@ function WeakAuras.RegisterLoadEvents() WeakAuras.StopProfileSystem("load"); end); ---[[ - C_Timer.NewTicker(0.5, function() - WeakAuras.StartProfileSystem("load"); - local zoneId = C_Map.GetBestMapForUnit("player"); - if loadFrame.zoneId ~= zoneId then - WeakAuras.ScanForLoads(nil, "ZONE_CHANGED") - loadFrame.zoneId = zoneId; - end - WeakAuras.StopProfileSystem("load"); - end) -]] - unitLoadFrame:SetScript("OnEvent", function(frame, e, arg1, ...) WeakAuras.StartProfileSystem("load"); if (arg1 == "player") then @@ -5758,7 +5746,7 @@ end local function ApplyStateToRegion(id, cloneId, region, parent) region:Update(); - region.subRegionEvents:Notify("Update") + region.subRegionEvents:Notify("Update", region.state, region.states) WeakAuras.UpdateMouseoverTooltip(region); region:Expand(); @@ -6232,7 +6220,7 @@ function WeakAuras.ReplacePlaceHolders(textStr, region, customFunc, useHiddenSta result = result .. string.sub(textStr, start, currentPos - 1) elseif state == 2 and currentPos > start then local symbol = string.sub(textStr, start, currentPos - 1) - result = result .. ValueForSymbol(symbol, region, customFunc, regionState, regionStates) + result = result .. ValueForSymbol(symbol, region, customFunc, regionState, regionStates, useHiddenStates) elseif state == 1 then result = result .. "%" end @@ -6692,11 +6680,14 @@ for i = 1, 5 do end for i = 1, 4 do - trackableUnits["boss" .. i] = true trackableUnits["party" .. i] = true trackableUnits["partypet" .. i] = true end +for i = 1, MAX_BOSS_FRAMES do + trackableUnits["boss" .. i] = true +end + for i = 1, 40 do trackableUnits["raid" .. i] = true trackableUnits["raidpet" .. i] = true diff --git a/WeakAuras/WeakAuras.toc b/WeakAuras/WeakAuras.toc index b42c415..3d89def 100644 --- a/WeakAuras/WeakAuras.toc +++ b/WeakAuras/WeakAuras.toc @@ -57,3 +57,4 @@ SubRegionTypes\SubText.lua SubRegionTypes\Border.lua SubRegionTypes\Glow.lua SubRegionTypes\BarModel.lua +SubRegionTypes\Tick.lua diff --git a/WeakAurasOptions/RegionOptions/AuraBar.lua b/WeakAurasOptions/RegionOptions/AuraBar.lua index 66d9a39..e70d0ca 100644 --- a/WeakAurasOptions/RegionOptions/AuraBar.lua +++ b/WeakAurasOptions/RegionOptions/AuraBar.lua @@ -73,13 +73,6 @@ local function createOptions(id, data) name = L["Inverse"], order = 35 }, - smoothProgress = { - type = "toggle", - width = WeakAuras.normalWidth, - name = L["Smooth Progress"], - desc = L["Animates progress changes"], - order = 37 - }, useTooltip = { type = "toggle", width = WeakAuras.normalWidth, @@ -603,7 +596,6 @@ local templates = { height = 30, barColor = { 0, 1, 0, 1}, inverse = true, - smoothProgress = true, } }, { @@ -615,7 +607,6 @@ local templates = { rotateText = "LEFT", orientation = "VERTICAL_INVERSE", inverse = true, - smoothProgress = true, } }, } diff --git a/WeakAurasOptions/RegionOptions/ProgressTexture.lua b/WeakAurasOptions/RegionOptions/ProgressTexture.lua index 5016db5..3be29d4 100644 --- a/WeakAurasOptions/RegionOptions/ProgressTexture.lua +++ b/WeakAurasOptions/RegionOptions/ProgressTexture.lua @@ -221,13 +221,6 @@ local function createOptions(id, data) bigStep = 0.01, isPercent = true }, - smoothProgress = { - type = "toggle", - width = WeakAuras.normalWidth, - name = L["Smooth Progress"], - desc = L["Animates progress changes"], - order = 55.1 - }, textureWrapMode = { type = "select", width = WeakAuras.normalWidth, diff --git a/WeakAurasOptions/SubRegionOptions/Tick.lua b/WeakAurasOptions/SubRegionOptions/Tick.lua new file mode 100644 index 0000000..2ce19cc --- /dev/null +++ b/WeakAurasOptions/SubRegionOptions/Tick.lua @@ -0,0 +1,97 @@ +if not WeakAuras.IsCorrectVersion() then return end + +local SharedMedia = LibStub("LibSharedMedia-3.0"); +local L = WeakAuras.L; + +local indentWidth = WeakAuras.normalWidth * 0.06 + +local function createOptions(parentData, data, index, subIndex) + local options = { + __title = L["Tick %s"]:format(subIndex), + __order = 1, + __up = function() + if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionUp, index, "subtick")) then + WeakAuras.ReloadOptions2(parentData.id, parentData) + end + end, + __down = function() + if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionDown, index, "subtick")) then + WeakAuras.ReloadOptions2(parentData.id, parentData) + end + end, + __duplicate = function() + if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DuplicateSubRegion, index, "subtick")) then + WeakAuras.ReloadOptions2(parentData.id, parentData) + end + end, + __delete = function() + if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subtick")) then + WeakAuras.ReloadOptions2(parentData.id, parentData) + end + end, + tick_visible = { + type = "toggle", + width = WeakAuras.normalWidth, + name = L["Show Tick"], + order = 1, + }, + tick_color = { + type = "color", + width = WeakAuras.normalWidth, + name = L["Color"], + order = 2, + hasAlpha = true, + }, + tick_placement_mode = { + type = "select", + width = WeakAuras.normalWidth, + name = L["Tick Mode"], + order = 3, + values = WeakAuras.tick_placement_modes, + desc = L["Relative mode positions the tick at the position relative to the total width of the progress bar.\nAbsolute mode positions the tick at a fixed value."], + }, + tick_placement = { + type = "input", + width = WeakAuras.normalWidth, + name = L["Tick Placement"], + order = 4, + validate = WeakAuras.ValidateNumeric, + desc = L["Enter in a value for the tick's placement."], + }, + tick_space1 = { + type = "description", + width = WeakAuras.normalWidth, + name = "", + order = 5, + }, + automatic_length = { + type = "toggle", + width = WeakAuras.normalWidth, + name = L["Automatic length"], + order = 6, + desc = L["Matches the height setting of a horizontal bar or width for a vertical bar."], + }, + tick_thickness = { + type = "range", + width = WeakAuras.normalWidth, + name = L["Thickness"], + order = 7, + min = 0, + softMax = 20, + step = 1, + }, + tick_length = { + type = "range", + width = WeakAuras.normalWidth, + name = L["Length"], + order = 8, + min = 0, + softMax = 50, + step = 1, + disabled = function() return data.automatic_length end, + }, + } + return options +end + +WeakAuras.RegisterSubRegionOptions("subtick", createOptions, L["Places a tick on the bar"]); diff --git a/WeakAurasOptions/WeakAurasOptions.toc b/WeakAurasOptions/WeakAurasOptions.toc index 8493060..261f087 100644 --- a/WeakAurasOptions/WeakAurasOptions.toc +++ b/WeakAurasOptions/WeakAurasOptions.toc @@ -32,6 +32,7 @@ SubRegionOptions\SubText.lua SubRegionOptions\Border.lua SubRegionOptions\Glow.lua SubRegionOptions\BarModel.lua +SubRegionOptions\Tick.lua Cache.lua