diff --git a/WeakAuras/RegionTypes/Model.lua b/WeakAuras/RegionTypes/Model.lua index ef304ec..e8ced1e 100644 --- a/WeakAuras/RegionTypes/Model.lua +++ b/WeakAuras/RegionTypes/Model.lua @@ -200,9 +200,9 @@ local function modify(parent, region, data) bgFile = SharedMedia:Fetch("background", data.borderBackdrop), insets = { left = data.borderInset, - right = data.borderInset, - top = data.borderInset, - bottom = data.borderInset, + right = data.borderInset, + top = data.borderInset, + bottom = data.borderInset, }, }); border:SetBackdropBorderColor(data.borderColor[1], data.borderColor[2], data.borderColor[3], data.borderColor[4]); @@ -244,18 +244,28 @@ local function modify(parent, region, data) end -- Rotate model - function region:Rotate(degrees) - region.rotation = degrees; + function region:SetAnimRotation(degrees) + region.animRotation = degrees + region:UpdateEffectiveRotation() + end + + function region:SetRotation(degrees) + region.rotation = degrees + region:UpdateEffectiveRotation() + end + + function region:UpdateEffectiveRotation() + region.effectiveRotation = region.animRotation or region.rotation if region.model then - region.model:SetFacing(rad(region.rotation)); + region.model:SetFacing(rad(region.effectiveRotation)) end end - region:Rotate(data.rotation); + region:SetRotation(data.rotation) -- Get model rotation - function region:GetRotation() - return region.rotation; + function region:GetBaseRotation() + return region.rotation end function region:PreShow() diff --git a/WeakAuras/RegionTypes/RegionPrototype.lua b/WeakAuras/RegionTypes/RegionPrototype.lua index ba197a6..8eac24e 100644 --- a/WeakAuras/RegionTypes/RegionPrototype.lua +++ b/WeakAuras/RegionTypes/RegionPrototype.lua @@ -93,6 +93,7 @@ function Private.regionPrototype.AddProperties(properties, defaultsForRegion) isPercent = true } end + if defaultsForRegion and defaultsForRegion.progressSource then properties["progressSource"] = { display = L["Progress Source"], @@ -343,6 +344,7 @@ local function SetProgressSource(self, progressSource) self.progressSource = progressSource self:UpdateProgress() end + local function SetAdjustedMin(self, adjustedMin) local index = adjustedMin:find("%% *$") if index then @@ -355,6 +357,7 @@ local function SetAdjustedMin(self, adjustedMin) end self:UpdateProgress() end + local function SetAdjustedMax(self, adjustedMax) local index = adjustedMax:find("%% *$") if index then @@ -373,6 +376,7 @@ end local function GetMinMaxProgress(self) return self.minProgress or 0, self.maxProgress or 0 end + local function UpdateProgressFromState(self, minMaxConfig, state, progressSource) local progressType = progressSource[2] local property = progressSource[3] @@ -467,6 +471,7 @@ local function UpdateProgressFromState(self, minMaxConfig, state, progressSource else adjustMin = 0 end + local max if minMaxConfig.adjustedMax then max = minMaxConfig.adjustedMax @@ -879,7 +884,7 @@ function Private.regionPrototype.AddExpandFunction(data, region, cloneId, parent if region:IsProtected() then if InCombatLockdown() then Private.AuraWarnings.UpdateWarning(uid, "protected_frame_error", "error", - L["Cannot change secure frame in combat lockdown. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"], + L["Cannot change secure frame in combat lockdown. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"], true) else Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "warning", @@ -910,7 +915,7 @@ function Private.regionPrototype.AddExpandFunction(data, region, cloneId, parent if region:IsProtected() then if InCombatLockdown() then Private.AuraWarnings.UpdateWarning(uid, "protected_frame_error", "error", - L["Cannot change secure frame in combat lockdown. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"], + L["Cannot change secure frame in combat lockdown. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"], true) else Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "warning", diff --git a/WeakAuras/RegionTypes/StopMotion.lua b/WeakAuras/RegionTypes/StopMotion.lua index f2b0684..2bff0f3 100644 --- a/WeakAuras/RegionTypes/StopMotion.lua +++ b/WeakAuras/RegionTypes/StopMotion.lua @@ -18,10 +18,7 @@ local default = { foregroundColor = {1, 1, 1, 1}, backgroundColor = {0.5, 0.5, 0.5, 0.5}, blendMode = "BLEND", - rotation = 0, - discrete_rotation = 0, mirror = false, - rotate = true, selfPoint = "CENTER", anchorPoint = "CENTER", anchorFrameType = "SCREEN", @@ -181,8 +178,7 @@ local function SetProgress(self, progress) if (frame > endFrame) then frame = endFrame - end - + end if (frame < startFrame) then frame = startFrame end @@ -251,8 +247,7 @@ local FrameTickFunctions = { if (frame > endFrame) then frame = endFrame - end - + end if (frame < startFrame) then frame = startFrame end @@ -411,7 +406,8 @@ local function modify(parent, region, data) region.background:SetBaseTexture(backgroundTexture); region.background:SetFrame(backgroundTexture, region.backgroundFrame or 1); region.background:SetDesaturated(data.desaturateBackground) - region.background:SetVertexColor(data.backgroundColor[1], data.backgroundColor[2], data.backgroundColor[3], data.backgroundColor[4]); + region.background:SetVertexColor(data.backgroundColor[1], data.backgroundColor[2], + data.backgroundColor[3], data.backgroundColor[4]) region.background:SetBlendMode(data.blendMode); if (data.hideBackground) then @@ -495,7 +491,6 @@ local function modify(parent, region, data) function region:Update() region:UpdateProgress() end - elseif data.animationType == "progress" then function region:Update() region:UpdateProgress() @@ -525,6 +520,7 @@ local function modify(parent, region, data) self.FrameTick = FrameTickFunctions.progressTimer self.subRegionEvents:AddSubscriber("FrameTick", self) end + self:FrameTick() end diff --git a/WeakAuras/RegionTypes/Texture.lua b/WeakAuras/RegionTypes/Texture.lua index 9285aa4..0e012b6 100644 --- a/WeakAuras/RegionTypes/Texture.lua +++ b/WeakAuras/RegionTypes/Texture.lua @@ -11,9 +11,8 @@ local default = { color = {1, 1, 1, 1}, blendMode = "BLEND", rotation = 0, - discrete_rotation = 0, mirror = false, - rotate = true, + rotate = false, selfPoint = "CENTER", anchorPoint = "CENTER", anchorFrameType = "SCREEN", @@ -64,6 +63,15 @@ local properties = { display = L["Mirror"], setter = "SetMirror", type = "bool" + }, + rotation = { + display = L["Rotation"], + setter = "SetRotation", + type = "number", + min = 0, + max = 360, + bigStep = 1, + default = 0 } } @@ -85,6 +93,16 @@ local function create(parent) return region; end +local SQRT2 = sqrt(2) +local function GetRotatedPoints(degrees, scaleForFullRotate) + local angle = rad(135 - degrees); + local factor = scaleForFullRotate and 1 or SQRT2 + local vx = math.cos(angle) / factor + local vy = math.sin(angle) / factor + + return 0.5+vx,0.5-vy , 0.5-vy,0.5-vx , 0.5+vy,0.5+vx , 0.5-vx,0.5+vy +end + local function modify(parent, region, data) Private.regionPrototype.modify(parent, region, data); region.texture:SetDesaturated(data.desaturate) @@ -95,16 +113,6 @@ local function modify(parent, region, data) region.scalex = 1; region.scaley = 1; region.texture:SetBlendMode(data.blendMode); - --region.texture:SetRotation((data.rotation / 180) * math.pi); - - local function GetRotatedPoints(degrees) - degrees = degrees or 0 - local angle = rad(135 - degrees); - local vx = math.cos(angle); - local vy = math.sin(angle); - - return 0.5+vx,0.5-vy , 0.5-vy,0.5-vx , 0.5+vy,0.5+vx , 0.5-vx,0.5+vy - end region.mirror = data.mirror @@ -113,20 +121,8 @@ local function modify(parent, region, data) if(region.mirror) then mirror_h = not mirror_h; end - local ulx,uly , llx,lly , urx,ury , lrx,lry; - if(data.rotate) then - ulx,uly , llx,lly , urx,ury , lrx,lry = GetRotatedPoints(region.rotation); - else - if(data.discrete_rotation == 0 or data.discrete_rotation == 360) then - ulx,uly , llx,lly , urx,ury , lrx,lry = 0,0 , 0,1 , 1,0 , 1,1; - elseif(data.discrete_rotation == 90) then - ulx,uly , llx,lly , urx,ury , lrx,lry = 1,0 , 0,0 , 1,1 , 0,1; - elseif(data.discrete_rotation == 180) then - ulx,uly , llx,lly , urx,ury , lrx,lry = 1,1 , 1,0 , 0,1 , 0,0; - elseif(data.discrete_rotation == 270) then - ulx,uly , llx,lly , urx,ury , lrx,lry = 0,1 , 1,1 , 0,0 , 1,0; - end - end + local ulx,uly , llx,lly , urx,ury , lrx,lry + = GetRotatedPoints(region.effectiveRotation, data.rotate) if(mirror_h) then if(mirror_v) then region.texture:SetTexCoord(lrx,lry , urx,ury , llx,lly , ulx,uly); @@ -142,8 +138,8 @@ local function modify(parent, region, data) end end - region.rotation = data.rotation; - DoTexCoord(); + region.rotation = data.rotation + region.effectiveRotation = region.rotation function region:Scale(scalex, scaley) region.scalex = scalex; @@ -231,20 +227,26 @@ local function modify(parent, region, data) region.texture:SetDesaturated(b); end - if(data.rotate) then - function region:Rotate(degrees) - region.rotation = degrees; - DoTexCoord(); - end - - function region:GetRotation() - return region.rotation; - end - else - region.Rotate = nil; - region.GetRotation = nil; + function region:SetAnimRotation(degrees) + region.animRotation = degrees + region:UpdateEffectiveRotation() end + function region:SetRotation(degrees) + region.rotation = degrees + region:UpdateEffectiveRotation() + end + + function region:UpdateEffectiveRotation() + region.effectiveRotation = region.animRotation or region.rotation + DoTexCoord() + end + + function region:GetBaseRotation() + return region.rotation + end + region:SetRotation(data.rotation) + Private.regionPrototype.modifyFinish(parent, region, data); end diff --git a/WeakAurasOptions/RegionOptions/Model.lua b/WeakAurasOptions/RegionOptions/Model.lua index 01fe2c7..49c2574 100644 --- a/WeakAurasOptions/RegionOptions/Model.lua +++ b/WeakAurasOptions/RegionOptions/Model.lua @@ -14,9 +14,19 @@ local function createOptions(id, data) order = 0.5, hidden = function() return data.modelDisplayInfo and WeakAuras.BuildInfo > 80100 end }, - -- Option for modelIsDisplayInfo added below - - -- Option for path/id added below + modelDisplayInfo = { + type = "toggle", + width = WeakAuras.normalWidth, + name = L["Use Display Info Id"], + order = 0.6, + hidden = function() return data.modelIsUnit end + }, + model_model_path = { + type = "input", + width = WeakAuras.doubleWidth - 0.15, + name = L["Model"], + order = 1 + }, chooseModel = { type = "execute", width = 0.15, @@ -100,23 +110,6 @@ local function createOptions(id, data) }, }; - if WeakAuras.BuildInfo > 80100 then - options.modelDisplayInfo = { - type = "toggle", - width = WeakAuras.normalWidth, - name = L["Use Display Info Id"], - order = 0.6, - hidden = function() return data.modelIsUnit end - } - else - options.model_path = { - type = "input", - width = WeakAuras.doubleWidth - 0.15, - name = L["Model"], - order = 1 - } - end - for k, v in pairs(OptionsPrivate.commonOptions.BorderOptions(id, data, nil, nil, 70)) do options[k] = v end @@ -199,104 +192,105 @@ local templates = { title = L["Default"], data = { }; - }, - { - title = L["Fire Orb"], - description = "", - data = { - width = 100, - height = 100, - model_path = "spells/6fx_smallfire.m2", - model_x = 0, - model_y = -0.5, - model_z = -1.5 - }, - }, - { - title = L["Blue Sparkle Orb"], - description = "", - data = { - width = 100, - height = 100, - advance = true, - sequence = 1, - model_path = "spells/7fx_druid_halfmoon_missile.m2", - model_x = 0, - model_y = 0.7, - model_z = 1.5 - }, - }, - { - title = L["Arcane Orb"], - description = "", - data = { - width = 100, - height = 100, - advance = true, - sequence = 1, - model_path = "spells/proc_arcane_impact_low.m2", - model_x = 0, - model_y = 0.8, - model_z = 2 - }, - }, - { - title = L["Orange Rune"], - description = "", - data = { - width = 100, - height = 100, - advance = true, - sequence = 1, - model_path = "spells/7fx_godking_orangerune_state.m2", - }, - }, - { - title = L["Blue Rune"], - description = "", - data = { - width = 100, - height = 100, - advance = true, - sequence = 1, - model_path = "spells/7fx_godking_bluerune_state.m2", - } - }, - { - title = L["Yellow Rune"], - description = "", - data = { - width = 100, - height = 100, - advance = true, - sequence = 1, - model_path = "spells/7fx_godking_yellowrune_state.m2", - } - }, - { - title = L["Purple Rune"], - description = "", - data = { - width = 100, - height = 100, - advance = true, - sequence = 1, - model_path = "spells/7fx_godking_purplerune_state.m2", - } - }, - { - title = L["Green Rune"], - description = "", - data = { - width = 100, - height = 100, - advance = true, - sequence = 1, - model_path = "spells/7fx_godking_greenrune_state.m2", - } - }, + } } +tinsert(templates, { + title = L["Fire Orb"], + description = "", + data = { + width = 100, + height = 100, + model_path = "spells/6fx_smallfire.m2", + model_x = 0, + model_y = -0.5, + model_z = -1.5 + }, +}) +tinsert(templates, { + title = L["Blue Sparkle Orb"], + description = "", + data = { + width = 100, + height = 100, + advance = true, + sequence = 1, + model_path = "spells/7fx_druid_halfmoon_missile.m2", + model_x = 0, + model_y = 0.7, + model_z = 1.5 + }, +}) +tinsert(templates, { + title = L["Arcane Orb"], + description = "", + data = { + width = 100, + height = 100, + advance = true, + sequence = 1, + model_path = "spells/proc_arcane_impact_low.m2", + model_x = 0, + model_y = 0.8, + model_z = 2 + }, +}) +tinsert(templates, { + title = L["Orange Rune"], + description = "", + data = { + width = 100, + height = 100, + advance = true, + sequence = 1, + model_path = "spells/7fx_godking_orangerune_state.m2", + }, +}) +tinsert(templates, { + title = L["Blue Rune"], + description = "", + data = { + width = 100, + height = 100, + advance = true, + sequence = 1, + model_path = "spells/7fx_godking_bluerune_state.m2", + } +}) +tinsert(templates, { + title = L["Yellow Rune"], + description = "", + data = { + width = 100, + height = 100, + advance = true, + sequence = 1, + model_path = "spells/7fx_godking_yellowrune_state.m2", + } +}) +tinsert(templates, { + title = L["Purple Rune"], + description = "", + data = { + width = 100, + height = 100, + advance = true, + sequence = 1, + model_path = "spells/7fx_godking_purplerune_state.m2", + } +}) +tinsert(templates, { + title = L["Green Rune"], + description = "", + data = { + width = 100, + height = 100, + advance = true, + sequence = 1, + model_path = "spells/7fx_godking_greenrune_state.m2", + } +}) + OptionsPrivate.registerRegions = OptionsPrivate.registerRegions or {} table.insert(OptionsPrivate.registerRegions, function() OptionsPrivate.Private.RegisterRegionOptions("model", createOptions, createIcon, L["Model"], createThumbnail, modifyThumbnail, diff --git a/WeakAurasOptions/RegionOptions/StopMotion.lua b/WeakAurasOptions/RegionOptions/StopMotion.lua index 9f5a8c4..0504d73 100644 --- a/WeakAurasOptions/RegionOptions/StopMotion.lua +++ b/WeakAurasOptions/RegionOptions/StopMotion.lua @@ -23,7 +23,8 @@ local function setTextureFunc(textureWidget, texturePath, textureName) else local rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight = texturePath:match(pattern2) if rows then - rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight = tonumber(rows), tonumber(columns), tonumber(frames), tonumber(frameWidth), tonumber(frameHeight), tonumber(fileWidth), tonumber(fileHeight) + rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight + = tonumber(rows), tonumber(columns), tonumber(frames), tonumber(frameWidth), tonumber(frameHeight), tonumber(fileWidth), tonumber(fileHeight) local frameScaleW = 1 local frameScaleH = 1 if fileWidth > 0 and frameWidth > 0 then @@ -115,15 +116,14 @@ local function createOptions(id, data) name = L["Choose"], order = 2, func = function() - local path = {} - local paths = {} - for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do - paths[child.id] = path - end - OptionsPrivate.OpenTexturePicker(data, paths, { + local path = {} + local paths = {} + for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do + paths[child.id] = path + end + OptionsPrivate.OpenTexturePicker(data, paths, { texture = "foregroundTexture", color = "foregroundColor", - rotation = "rotation", mirror = "mirror", blendMode = "blendMode" }, texture_types, setTextureFunc); @@ -160,7 +160,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 4, - hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end + hidden = function() + return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) + end }, customForegroundColumns = { type = "input", @@ -176,7 +178,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 5, - hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end + hidden = function() + return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) + end }, customForegroundFrames = { type = "input", @@ -192,7 +196,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 6, - hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end + hidden = function() + return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) + end }, customForegroundFileWidth = { type = "input", @@ -214,7 +220,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 7, - hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end + hidden = function() + return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) + end }, customForegroundFileHeight = { type = "input", @@ -236,7 +244,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 8, - hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end + hidden = function() + return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) + end }, customForegroundFrameWidth = { type = "input", @@ -253,7 +263,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 9, - hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end + hidden = function() + return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) + end }, customForegroundFrameHeight = { type = "input", @@ -270,7 +282,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 10, - hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end + hidden = function() + return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) + end }, blendMode = { type = "select", @@ -293,7 +307,7 @@ local function createOptions(id, data) name = L["Animation Start"], min = 0, max = 1, - bigStep = 0.01, + --bigStep = 0.01, order = 13, isPercent = true }, @@ -304,7 +318,7 @@ local function createOptions(id, data) name = L["Animation End"], min = 0, max = 1, - bigStep = 0.01, + --bigStep = 0.01, order = 14, isPercent = true }, @@ -418,7 +432,11 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 24, - hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end + hidden = function() + return data.sameTexture + or texture_data[data.backgroundTexture] + or textureNameHasData(data.backgroundTexture) + end }, customBackgroundColumns = { type = "input", @@ -434,7 +452,11 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 25, - hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end + hidden = function() + return data.sameTexture + or texture_data[data.backgroundTexture] + or textureNameHasData(data.backgroundTexture) + end }, customBackgroundFrames = { type = "input", @@ -450,7 +472,11 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 26, - hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end + hidden = function() + return data.sameTexture + or texture_data[data.backgroundTexture] + or textureNameHasData(data.backgroundTexture) + end }, customBackgroundFileWidth = { type = "input", @@ -472,7 +498,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 27, - hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end + hidden = function() + return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) + end }, customBackgroundFileHeight = { type = "input", @@ -494,7 +522,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 28, - hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end + hidden = function() + return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) + end }, customBackgroundFrameWidth = { type = "input", @@ -511,7 +541,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 29, - hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end + hidden = function() + return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) + end }, customBackgroundFrameHeight = { type = "input", @@ -528,7 +560,9 @@ local function createOptions(id, data) WeakAuras.UpdateThumbnail(data); end, order = 30, - hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end + hidden = function() + return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) + end }, backgroundPercent = { type = "range", @@ -610,7 +644,8 @@ local function modifyThumbnail(parent, region, data, fullModify, size) region.foreground.frameWidth = 0 region.foreground.frameHeight = 0 else - local rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight = data.foregroundTexture:match(pattern2) + local rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight + = data.foregroundTexture:match(pattern2) if rows then local lastFrame = frames - 1; region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1; @@ -639,17 +674,23 @@ local function modifyThumbnail(parent, region, data, fullModify, size) frame = floor(region.startFrame + (region.endFrame - region.startFrame) * 0.75); end - local texture = data.foregroundTexture or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\stopmotion"; + local texture = data.foregroundTexture or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\StopMotion"; if (region.foreground.rows and region.foreground.columns) then region.texture:SetTexture(texture); local frameScaleW, frameScaleH = 1, 1 - if region.foreground.fileWidth and region.foreground.frameWidth and region.foreground.fileWidth > 0 and region.foreground.frameWidth > 0 then + if region.foreground.fileWidth and region.foreground.frameWidth + and region.foreground.fileWidth > 0 and region.foreground.frameWidth > 0 + then frameScaleW = (region.foreground.frameWidth * region.foreground.columns) / region.foreground.fileWidth end - if region.foreground.fileHeight and region.foreground.frameHeight and region.foreground.fileHeight > 0 and region.foreground.frameHeight > 0 then + + if region.foreground.fileHeight and region.foreground.frameHeight + and region.foreground.fileHeight > 0 and region.foreground.frameHeight > 0 + then frameScaleH = (region.foreground.frameHeight * region.foreground.rows) / region.foreground.fileHeight end + setTile(region.texture, frame, region.foreground.rows, region.foreground.columns, frameScaleW, frameScaleH); region.SetValue = function(self, percent) @@ -666,7 +707,8 @@ local function modifyThumbnail(parent, region, data, fullModify, size) end end - region.texture:SetVertexColor(data.foregroundColor[1], data.foregroundColor[2], data.foregroundColor[3], data.foregroundColor[4]); + region.texture:SetVertexColor(data.foregroundColor[1], data.foregroundColor[2], + data.foregroundColor[3], data.foregroundColor[4]); region.texture:SetBlendMode(data.blendMode); region.elapsed = 0; diff --git a/WeakAurasOptions/RegionOptions/Texture.lua b/WeakAurasOptions/RegionOptions/Texture.lua index 32ef9cb..e235cb1 100644 --- a/WeakAurasOptions/RegionOptions/Texture.lua +++ b/WeakAurasOptions/RegionOptions/Texture.lua @@ -27,9 +27,6 @@ local function createOptions(id, data) OptionsPrivate.OpenTexturePicker(data, paths, { texture = "texture", color = "color", - rotate = "rotate", - discrete_rotation = "discrete_rotation", - rotation = "rotation", mirror = "mirror", blendMode = "blendMode" }, OptionsPrivate.Private.texture_types); @@ -39,55 +36,48 @@ local function createOptions(id, data) control = "WeakAurasIcon", image = "Interface\\AddOns\\WeakAuras\\Media\\Textures\\browse", }, - desaturate = { - type = "toggle", - width = WeakAuras.normalWidth, - name = L["Desaturate"], - order = 2, - }, - space2 = { - type = "execute", - name = "", - width = WeakAuras.normalWidth, - order = 5, - image = function() return "", 0, 0 end, - }, color = { type = "color", width = WeakAuras.normalWidth, name = L["Color"], hasAlpha = true, - order = 10 + order = 2 }, - blendMode = { - type = "select", - width = WeakAuras.normalWidth, - name = L["Blend Mode"], - order = 12, - values = OptionsPrivate.Private.blend_types - }, - mirror = { + desaturate = { type = "toggle", width = WeakAuras.normalWidth, - name = L["Mirror"], - order = 20 + name = L["Desaturate"], + order = 3, }, alpha = { type = "range", control = "WeakAurasSpinBox", width = WeakAuras.normalWidth, name = L["Alpha"], - order = 25, + order = 4, min = 0, max = 1, bigStep = 0.01, isPercent = true }, + blendMode = { + type = "select", + width = WeakAuras.normalWidth, + name = L["Blend Mode"], + order = 5, + values = OptionsPrivate.Private.blend_types + }, + mirror = { + type = "toggle", + width = WeakAuras.normalWidth, + name = L["Mirror"], + order = 6 + }, rotate = { type = "toggle", width = WeakAuras.normalWidth, name = L["Allow Full Rotation"], - order = 30 + order = 8, }, rotation = { type = "range", @@ -98,19 +88,7 @@ local function createOptions(id, data) max = 360, step = 1, bigStep = 3, - order = 35, - hidden = function() return not data.rotate end - }, - discrete_rotation = { - type = "range", - control = "WeakAurasSpinBox", - width = WeakAuras.normalWidth, - name = L["Discrete Rotation"], - min = 0, - max = 360, - step = 90, - order = 35, - hidden = function() return data.rotate end + order = 9, }, endHeader = { type = "header", @@ -142,6 +120,17 @@ local function createThumbnail() return borderframe; end +local SQRT2 = sqrt(2) +local function GetRotatedPoints(degrees, scaleForFullRotate) + degrees = degrees or 0 + local angle = rad(135 - degrees); + local factor = scaleForFullRotate and 1 or SQRT2 + local vx = math.cos(angle) / factor + local vy = math.sin(angle) / factor + + return 0.5+vx,0.5-vy , 0.5-vy,0.5-vx , 0.5+vy,0.5+vx , 0.5-vx,0.5+vy +end + local function modifyThumbnail(parent, region, data, fullModify, size) size = size or 30; local scale; @@ -159,24 +148,7 @@ local function modifyThumbnail(parent, region, data, fullModify, size) region.texture:SetVertexColor(data.color[1], data.color[2], data.color[3], data.color[4]); region.texture:SetBlendMode(data.blendMode); - local ulx,uly , llx,lly , urx,ury , lrx,lry; - if(data.rotate) then - local angle = rad(135 - data.rotation); - local vx = math.cos(angle); - local vy = math.sin(angle); - - ulx,uly , llx,lly , urx,ury , lrx,lry = 0.5+vx,0.5-vy , 0.5-vy,0.5-vx , 0.5+vy,0.5+vx , 0.5-vx,0.5+vy; - else - if(data.discrete_rotation == 0 or data.discrete_rotation == 360) then - ulx,uly , llx,lly , urx,ury , lrx,lry = 0,0 , 0,1 , 1,0 , 1,1; - elseif(data.discrete_rotation == 90) then - ulx,uly , llx,lly , urx,ury , lrx,lry = 1,0 , 0,0 , 1,1 , 0,1; - elseif(data.discrete_rotation == 180) then - ulx,uly , llx,lly , urx,ury , lrx,lry = 1,1 , 1,0 , 0,1 , 0,0; - elseif(data.discrete_rotation == 270) then - ulx,uly , llx,lly , urx,ury , lrx,lry = 0,1 , 1,1 , 0,0 , 1,0; - end - end + local ulx,uly , llx,lly , urx,ury , lrx,lry = GetRotatedPoints(data.rotation, data.rotate) if(data.mirror) then region.texture:SetTexCoord(urx,ury , lrx,lry , ulx,uly , llx,lly); else