diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 6712960..7a838fe 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -4635,6 +4635,7 @@ WeakAuras.event_prototypes = { { name = "aggro", display = L["Aggro"], + type = "tristate", store = true, conditionType = "bool", }, diff --git a/WeakAuras/RegionTypes/AuraBar.lua b/WeakAuras/RegionTypes/AuraBar.lua index 36b8d5b..1e15548 100644 --- a/WeakAuras/RegionTypes/AuraBar.lua +++ b/WeakAuras/RegionTypes/AuraBar.lua @@ -1101,18 +1101,17 @@ local function modify(parent, region, data) region.tooltipFrame:EnableMouse(false); end - function region:Update() + function region:UpdateMinMax() local state = region.state + local min local max if state.progressType == "timed" then - local expirationTime = state.expirationTime and state.expirationTime > 0 and state.expirationTime or math.huge; local duration = state.duration or 0 - if region.adjustedMinRelPercent then region.adjustedMinRel = region.adjustedMinRelPercent * duration end - local adjustMin = region.adjustedMin or region.adjustedMinRel or 0; + min = region.adjustedMin or region.adjustedMinRel or 0; if duration == 0 then max = 0 @@ -1124,20 +1123,13 @@ local function modify(parent, region, data) else max = duration end - - region:SetTime(max - adjustMin, expirationTime - adjustMin, state.inverse); - if not region.TimerTick then - region.TimerTick = TimerTick - region:UpdateRegionHasTimerTick() - end elseif state.progressType == "static" then - local value = state.value or 0; local total = state.total or 0; - if region.adjustedMinRelPercent then region.adjustedMinRel = region.adjustedMinRelPercent * total end - local adjustMin = region.adjustedMin or region.adjustedMinRel or 0; + min = region.adjustedMin or region.adjustedMinRel or 0; + if region.adjustedMax then max = region.adjustedMax elseif region.adjustedMaxRelPercent then @@ -1146,7 +1138,31 @@ local function modify(parent, region, data) else max = total end - region:SetValue(value - adjustMin, max - adjustMin); + end + region.currentMin, region.currentMax = min, max + end + + function region:GetMinMax() + return region.currentMin or 0, region.currentMax or 0 + end + + function region:Update() + local state = region.state + region:UpdateMinMax() + if state.progressType == "timed" then + local expirationTime = state.expirationTime and state.expirationTime > 0 and state.expirationTime or math.huge; + local duration = state.duration or 0 + + region:SetTime(region.currentMax - region.currentMin, expirationTime - region.currentMin, state.inverse); + if not region.TimerTick then + region.TimerTick = TimerTick + region:UpdateRegionHasTimerTick() + end + elseif state.progressType == "static" then + local value = state.value or 0; + local total = state.total or 0; + + region:SetValue(value - region.currentMin, region.currentMax - region.currentMin); if region.TimerTick then region.TimerTick = nil region:UpdateRegionHasTimerTick() @@ -1173,9 +1189,8 @@ local function modify(parent, region, data) icon:SetDesaturated(data.desaturate); local duration = state.duration or 0 - local min = region.adjustMin or 0 local effectiveInverse = (state.inverse and not region.inverseDirection) or (not state.inverse and region.inverseDirection); - region.bar:SetAdditionalBars(state.additionalProgress, region.overlays, min, max, effectiveInverse, region.overlayclip); + region.bar:SetAdditionalBars(state.additionalProgress, region.overlays, region.currentMin, region.currentMax, effectiveInverse, region.overlayclip); end -- Scale update function diff --git a/WeakAuras/RegionTypes/RegionPrototype.lua b/WeakAuras/RegionTypes/RegionPrototype.lua index 6079d61..84632ae 100644 --- a/WeakAuras/RegionTypes/RegionPrototype.lua +++ b/WeakAuras/RegionTypes/RegionPrototype.lua @@ -525,10 +525,18 @@ function WeakAuras.regionPrototype.modify(parent, region, data) end if not parent or parent.regionType ~= "dynamicgroup" then - if not ( - data.anchorFrameType == "CUSTOM" - or data.anchorFrameType == "UNITFRAME" - ) then + if + -- Don't anchor single Auras that with custom anchoring, + -- these will be anchored in expand + not ( + data.anchorFrameType == "CUSTOM" + or data.anchorFrameType == "UNITFRAME" + ) + -- Group Auras that will never be expanded, so those need + -- to be always anchored here + or data.regionType == "dynamicgroup" + or data.regionType == "group" + then WeakAuras.AnchorFrame(data, region, parent); end end diff --git a/WeakAuras/SubRegionTypes/SubText.lua b/WeakAuras/SubRegionTypes/SubText.lua index 8775855..ff016ad 100644 --- a/WeakAuras/SubRegionTypes/SubText.lua +++ b/WeakAuras/SubRegionTypes/SubText.lua @@ -3,6 +3,8 @@ if not WeakAuras.IsCorrectVersion() then return end local SharedMedia = LibStub("LibSharedMedia-3.0"); local L = WeakAuras.L; +local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ceil(GetScreenHeight() / 20) * 20 + local defaultFont = WeakAuras.defaultFont local defaultFontSize = WeakAuras.defaultFontSize @@ -80,7 +82,23 @@ local properties = { softMax = 72, step = 1, default = 12 - } + }, + text_anchorXOffset = { + display = L["X-Offset"], + setter = "SetXOffset", + type = "number", + softMin = (-1 * screenWidth), + softMax = screenWidth, + bigStep = 10, + }, + text_anchorYOffset = { + display = L["Y-Offset"], + setter = "SetYOffset", + type = "number", + softMin = (-1 * screenHeight), + softMax = screenHeight, + bigStep = 10, + }, } @@ -258,7 +276,7 @@ local function modify(parent, region, parentData, data, first) if text:GetFont() then text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr)) end - region:UpdateAnchor() + region:UpdateAnchorOnTextChange() end end @@ -342,7 +360,7 @@ local function modify(parent, region, parentData, data, first) local fontPath = SharedMedia:Fetch("font", data.text_font); region.text:SetFont(fontPath, size, data.text_fontType); region.text:SetTextHeight(size) - region:UpdateAnchor(); + region:UpdateAnchorOnTextChange(); end function region:SetVisible(visible) @@ -380,18 +398,39 @@ local function modify(parent, region, parentData, data, first) end end + region.text_anchorXOffset = data.text_anchorXOffset + region.text_anchorYOffset = data.text_anchorYOffset + local textDegrees = data.rotateText == "LEFT" and 90 or data.rotateText == "RIGHT" and -90 or 0; - local xo, yo = getRotateOffset(text, textDegrees, selfPoint) - parent:AnchorSubRegion(text, "point", selfPoint, data.text_anchorPoint, (data.text_anchorXOffset or 0) + xo, (data.text_anchorYOffset or 0) + yo) + + region.UpdateAnchor = function(self) + local xo, yo = getRotateOffset(text, textDegrees, selfPoint) + parent:AnchorSubRegion(text, "point", selfPoint, data.text_anchorPoint, (self.text_anchorXOffset or 0) + xo, (self.text_anchorYOffset or 0) + yo) + end + + region:UpdateAnchor() animRotate(text, textDegrees, selfPoint) if textDegrees == 0 then - region.UpdateAnchor = function() end + region.UpdateAnchorOnTextChange = function() end else - region.UpdateAnchor = function(self) - local xo, yo = getRotateOffset(self.text, textDegrees, selfPoint) - parent:AnchorSubRegion(self.text, "point", selfPoint, data.text_anchorPoint, (data.text_anchorXOffset or 0) + xo, (data.text_anchorYOffset or 0) + yo) + region.UpdateAnchorOnTextChange = region.UpdateAnchor + end + + region.SetXOffset = function(self, xOffset) + if self.text_anchorXOffset == xOffset then + return end + self.text_anchorXOffset = xOffset + self:UpdateAnchor() + end + + region.SetYOffset = function(self, yOffset) + if self.text_anchorYOffset == yOffset then + return + end + self.text_anchorYOffset = yOffset + self:UpdateAnchor() end end diff --git a/WeakAuras/SubRegionTypes/Tick.lua b/WeakAuras/SubRegionTypes/Tick.lua index cdd5d83..8cd237d 100644 --- a/WeakAuras/SubRegionTypes/Tick.lua +++ b/WeakAuras/SubRegionTypes/Tick.lua @@ -181,61 +181,37 @@ local funcs = { 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 + local minValue, maxValue = self.parent:GetMinMax() + local valueRange = maxValue - minValue - if not self.trigger_total or percent and percent < 0 or percent > 1 then - hide = true - offset = 0 - else - offset = percent * width - end + local tick_placement + if self.tick_placement_mode == "AtValue" then + tick_placement = self.tick_placement elseif self.tick_placement_mode == "AtMissingValue" then - local percent = self.trigger_total and self.trigger_total ~= 0 and 1 - (self.tick_placement / self.trigger_total) - if not self.trigger_total or percent and percent < 0 or percent > 1 then - hide = true - offset = 0 - else - offset = percent * width - end + tick_placement = self.trigger_total and self.trigger_total - self.tick_placement 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 + if self.tick_placement >= 0 and self.tick_placement <= 100 and self.trigger_total then + tick_placement = self.tick_placement * self.trigger_total / 100 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 + tick_placement = self.state.expirationTime - GetTime() + self.tick_placement else - atValue = self.state.value + self.tick_placement + tick_placement = 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 + local percent = valueRange ~= 0 and tick_placement and (tick_placement - minValue) / valueRange + if not percent or (percent and percent < 0 or percent > 1) then self.texture:Hide() + offset = 0 else self.texture:Show() + offset = percent * width end - - local inverse = self.inverse if self.trigger_inverse then inverse = not inverse diff --git a/WeakAurasOptions/CommonOptions.lua b/WeakAurasOptions/CommonOptions.lua index b640953..dd37831 100644 --- a/WeakAurasOptions/CommonOptions.lua +++ b/WeakAurasOptions/CommonOptions.lua @@ -262,7 +262,7 @@ local function removeFuncs(intable, removeFunc) intable[i] = nil; elseif (i == "func" and removeFunc) then intable[i] = nil - elseif(type(v) == "table" and i ~= "values") then + elseif(type(v) == "table" and i ~= "values" and i ~= "extraFunctions") then removeFuncs(v, removeFunc) end end @@ -1233,8 +1233,8 @@ local function AddCodeOption(args, data, name, prefix, url, order, hiddenFunc, p extraFunctions = extraFunctions or {}; tinsert(extraFunctions, 1, { buttonLabel = L["Expand"], - func = function() - WeakAuras.OpenTextEditor(data, path, encloseInFunction, multipath, reloadOptions, setOnParent, url) + func = function(info) + WeakAuras.OpenTextEditor(WeakAuras.GetPickedDisplay(), path, encloseInFunction, multipath, reloadOptions, setOnParent, url) end }); diff --git a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua index 50038e3..1f18ed8 100644 --- a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua +++ b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua @@ -760,7 +760,7 @@ function WeakAuras.CreateFrame() end end if (type(self.pickedDisplay) == "string" and self.pickedDisplay == id) - or (type(self.pickedDisplay == "table") and id == tempGroup.id) + or (type(self.pickedDisplay) == "table" and id == tempGroup.id) then frame:UpdateOptions() end @@ -1184,6 +1184,13 @@ function WeakAuras.CreateFrame() self:FillOptions() end + frame.GetPickedDisplay = function(self) + if type(self.pickedDisplay) == "string" then + return WeakAuras.GetData(self.pickedDisplay) + end + return self.pickedDisplay + end + frame:SetClampedToScreen(true) local w, h = frame:GetSize() local left, right, top, bottom = w/2,-w/2, 0, h-25 diff --git a/WeakAurasOptions/WeakAurasOptions.lua b/WeakAurasOptions/WeakAurasOptions.lua index 2c419d7..18c8f66 100644 --- a/WeakAurasOptions/WeakAurasOptions.lua +++ b/WeakAurasOptions/WeakAurasOptions.lua @@ -727,6 +727,10 @@ function WeakAuras.EnsureOptions(data, subOption) return frame:EnsureOptions(data, subOption) end +function WeakAuras.GetPickedDisplay() + return frame:GetPickedDisplay() +end + function WeakAuras.GetSpellTooltipText(id) local tooltip = WeakAuras.GetHiddenTooltip(); tooltip:SetSpellByID(id);