diff --git a/Core/Defaults.lua b/Core/Defaults.lua index 8365bb7..04eb644 100755 --- a/Core/Defaults.lua +++ b/Core/Defaults.lua @@ -105,7 +105,8 @@ local Defaults = { }, }, Essential = { - IconSize = 42, + IconWidth = 42, + IconHeight = 42, Layout = {"CENTER", "CENTER", 0, -275.1}, Text = { FontSize = 15, @@ -114,7 +115,8 @@ local Defaults = { }, }, Utility = { - IconSize = 36, + IconWidth = 36, + IconHeight = 36, Layout = {"TOP", "EssentialCooldownViewer", "BOTTOM", 0, -1.1}, Text = { FontSize = 15, @@ -123,7 +125,8 @@ local Defaults = { }, }, Buffs = { - IconSize = 32, + IconWidth = 32, + IconHeight = 32, CenterBuffs = false, Layout = {"BOTTOM", "BCDM_SecondaryPowerBar", "TOP", 0, 1.1}, Text = { @@ -162,7 +165,8 @@ local Defaults = { } }, Custom = { - IconSize = 38, + IconWidth = 38, + IconHeight = 38, FrameStrata = "LOW", Layout = {"CENTER", "NONE", "CENTER", 0, 0}, Spacing = 1, @@ -255,7 +259,8 @@ local Defaults = { }, }, AdditionalCustom = { - IconSize = 38, + IconWidth = 38, + IconHeight = 38, FrameStrata = "LOW", Layout = {"CENTER", "NONE", "CENTER", 0, 0}, Spacing = 1, @@ -348,7 +353,8 @@ local Defaults = { }, }, Item = { - IconSize = 38, + IconWidth = 38, + IconHeight = 38, FrameStrata = "LOW", Layout = {"CENTER", "NONE", "CENTER", 0, 0}, Spacing = 1, @@ -363,7 +369,8 @@ local Defaults = { }, Trinket = { Enabled = true, - IconSize = 38, + IconWidth = 38, + IconHeight = 38, FrameStrata = "LOW", Layout = {"CENTER", "NONE", "CENTER", 0, 0}, Spacing = 1, @@ -377,7 +384,8 @@ local Defaults = { Trinkets = {}, }, ItemSpell = { - IconSize = 38, + IconWidth = 38, + IconHeight = 38, FrameStrata = "LOW", Layout = {"CENTER", "NONE", "CENTER", 0, 0}, Spacing = 1, diff --git a/Core/GUI.lua b/Core/GUI.lua index 6f7e643..58cc153 100755 --- a/Core/GUI.lua +++ b/Core/GUI.lua @@ -1253,7 +1253,7 @@ local function CreateCooldownViewerSettings(parentContainer, viewerType) xOffsetSlider:SetValue(BCDM.db.profile.CooldownManager[viewerType].Layout[hasAnchorParent and 4 or 3]) xOffsetSlider:SetSliderValues(-3000, 3000, 0.1) xOffsetSlider:SetCallback("OnValueChanged", function(self, _, value) BCDM.db.profile.CooldownManager[viewerType].Layout[hasAnchorParent and 4 or 3] = value BCDM:UpdateCooldownViewer(viewerType) end) - xOffsetSlider:SetRelativeWidth(isCustomViewer and 0.25 or 0.33) + xOffsetSlider:SetRelativeWidth(0.25) layoutContainer:AddChild(xOffsetSlider) local yOffsetSlider = AG:Create("Slider") @@ -1261,16 +1261,24 @@ local function CreateCooldownViewerSettings(parentContainer, viewerType) yOffsetSlider:SetValue(BCDM.db.profile.CooldownManager[viewerType].Layout[hasAnchorParent and 5 or 4]) yOffsetSlider:SetSliderValues(-3000, 3000, 0.1) yOffsetSlider:SetCallback("OnValueChanged", function(self, _, value) BCDM.db.profile.CooldownManager[viewerType].Layout[hasAnchorParent and 5 or 4] = value BCDM:UpdateCooldownViewer(viewerType) end) - yOffsetSlider:SetRelativeWidth(isCustomViewer and 0.25 or 0.33) + yOffsetSlider:SetRelativeWidth(0.25) layoutContainer:AddChild(yOffsetSlider) - local iconSizeSlider = AG:Create("Slider") - iconSizeSlider:SetLabel("Icon Size") - iconSizeSlider:SetValue(BCDM.db.profile.CooldownManager[viewerType].IconSize) - iconSizeSlider:SetSliderValues(16, 128, 0.1) - iconSizeSlider:SetCallback("OnValueChanged", function(self, _, value) BCDM.db.profile.CooldownManager[viewerType].IconSize = value BCDM:UpdateCooldownViewer(viewerType) end) - iconSizeSlider:SetRelativeWidth(isCustomViewer and 0.25 or 0.33) - layoutContainer:AddChild(iconSizeSlider) + local iconWidthSlider = AG:Create("Slider") + iconWidthSlider:SetLabel("Icon Width") + iconWidthSlider:SetValue(BCDM.db.profile.CooldownManager[viewerType].IconWidth) + iconWidthSlider:SetSliderValues(16, 128, 0.1) + iconWidthSlider:SetCallback("OnValueChanged", function(self, _, value) BCDM.db.profile.CooldownManager[viewerType].IconWidth = value BCDM:UpdateCooldownViewer(viewerType) end) + iconWidthSlider:SetRelativeWidth(0.25) + layoutContainer:AddChild(iconWidthSlider) + + local iconHeightSlider = AG:Create("Slider") + iconHeightSlider:SetLabel("Icon Height") + iconHeightSlider:SetValue(BCDM.db.profile.CooldownManager[viewerType].IconHeight) + iconHeightSlider:SetSliderValues(16, 128, 0.1) + iconHeightSlider:SetCallback("OnValueChanged", function(self, _, value) BCDM.db.profile.CooldownManager[viewerType].IconHeight = value BCDM:UpdateCooldownViewer(viewerType) end) + iconHeightSlider:SetRelativeWidth(0.25) + layoutContainer:AddChild(iconHeightSlider) if viewerType == "Essential" or viewerType == "Utility" or viewerType == "Buffs" then local infoTag = CreateInformationTag(layoutContainer, "Updates To Sizes will be applied on closing the |cFF8080FFBetter|rCooldownManager Configuration Window.") diff --git a/Modules/AdditionalCustomCooldownViewer.lua b/Modules/AdditionalCustomCooldownViewer.lua index 2ec90c5..1618f9c 100755 --- a/Modules/AdditionalCustomCooldownViewer.lua +++ b/Modules/AdditionalCustomCooldownViewer.lua @@ -66,7 +66,7 @@ local function CreateCustomIcon(spellId) else customIcon:SetBackdropBorderColor(0, 0, 0, 1) end - customIcon:SetSize(CustomDB.IconSize, CustomDB.IconSize) + customIcon:SetSize(CustomDB.IconWidth, CustomDB.IconHeight) local anchorParent = CustomDB.Layout[2] == "NONE" and UIParent or _G[CustomDB.Layout[2]] customIcon:SetPoint(CustomDB.Layout[1], anchorParent, CustomDB.Layout[3], CustomDB.Layout[4], CustomDB.Layout[5]) customIcon:RegisterEvent("SPELL_UPDATE_COOLDOWN") @@ -117,8 +117,8 @@ local function CreateCustomIcon(spellId) local borderSize = BCDM.db.profile.CooldownManager.General.BorderSize customIcon.Icon:SetPoint("TOPLEFT", customIcon, "TOPLEFT", borderSize, -borderSize) customIcon.Icon:SetPoint("BOTTOMRIGHT", customIcon, "BOTTOMRIGHT", -borderSize, borderSize) - local iconZoom = BCDM.db.profile.CooldownManager.General.IconZoom * 0.5 - customIcon.Icon:SetTexCoord(iconZoom, 1 - iconZoom, iconZoom, 1 - iconZoom) + local zoom = BCDM.db.profile.CooldownManager.General.IconZoom + customIcon.Icon:SetTexCoord(BCDM:CalculateTexCoords(zoom, CustomDB.IconWidth, CustomDB.IconHeight)) customIcon.Icon:SetTexture(C_Spell.GetSpellInfo(spellId).iconID) return customIcon @@ -186,7 +186,8 @@ local function LayoutAdditionalCustomCooldownViewer() CreateCustomIcons(AdditionalCustomCooldownViewerIcons) - local iconSize = CustomDB.IconSize + local iconWidth = CustomDB.IconWidth + local iconHeight = CustomDB.IconHeight local iconSpacing = CustomDB.Spacing -- Calculate and set container size first @@ -198,11 +199,11 @@ local function LayoutAdditionalCustomCooldownViewer() local totalWidth, totalHeight = 0, 0 if useCenteredLayout or growthDirection == "RIGHT" or growthDirection == "LEFT" then - totalWidth = (#AdditionalCustomCooldownViewerIcons * iconSize) + ((#AdditionalCustomCooldownViewerIcons - 1) * iconSpacing) - totalHeight = iconSize + totalWidth = (#AdditionalCustomCooldownViewerIcons * iconWidth) + ((#AdditionalCustomCooldownViewerIcons - 1) * iconSpacing) + totalHeight = iconHeight elseif growthDirection == "UP" or growthDirection == "DOWN" then - totalWidth = iconSize - totalHeight = (#AdditionalCustomCooldownViewerIcons * iconSize) + ((#AdditionalCustomCooldownViewerIcons - 1) * iconSpacing) + totalWidth = iconWidth + totalHeight = (#AdditionalCustomCooldownViewerIcons * iconHeight) + ((#AdditionalCustomCooldownViewerIcons - 1) * iconSpacing) end BCDM.AdditionalCustomCooldownViewerContainer:SetSize(totalWidth, totalHeight) end @@ -223,15 +224,15 @@ local function LayoutAdditionalCustomCooldownViewer() local useCenteredLayout = (point == "TOP" or point == "BOTTOM") and (growthDirection == "LEFT" or growthDirection == "RIGHT") if useCenteredLayout and #AdditionalCustomCooldownViewerIcons > 0 then - local totalWidth = (#AdditionalCustomCooldownViewerIcons * iconSize) + ((#AdditionalCustomCooldownViewerIcons - 1) * iconSpacing) - local startOffset = -(totalWidth / 2) + (iconSize / 2) + local totalWidth = (#AdditionalCustomCooldownViewerIcons * iconWidth) + ((#AdditionalCustomCooldownViewerIcons - 1) * iconSpacing) + local startOffset = -(totalWidth / 2) + (iconWidth / 2) for i, spellIcon in ipairs(AdditionalCustomCooldownViewerIcons) do spellIcon:SetParent(BCDM.AdditionalCustomCooldownViewerContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() - local xOffset = startOffset + ((i - 1) * (iconSize + iconSpacing)) + local xOffset = startOffset + ((i - 1) * (iconWidth + iconSpacing)) spellIcon:SetPoint("CENTER", BCDM.AdditionalCustomCooldownViewerContainer, "CENTER", xOffset, 0) ApplyCooldownText() spellIcon:Show() @@ -239,7 +240,7 @@ local function LayoutAdditionalCustomCooldownViewer() else for i, spellIcon in ipairs(AdditionalCustomCooldownViewerIcons) do spellIcon:SetParent(BCDM.AdditionalCustomCooldownViewerContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() if i == 1 then diff --git a/Modules/CooldownManager.lua b/Modules/CooldownManager.lua index f001e37..ee30d0e 100755 --- a/Modules/CooldownManager.lua +++ b/Modules/CooldownManager.lua @@ -24,6 +24,17 @@ local function FetchCooldownTextRegion(cooldown) end end +function BCDM:CalculateTexCoords(zoom, iconWidth, iconHeight) + if not zoom or not iconWidth or not iconHeight or iconWidth == 0 then + return 0, 1, 0, 1 + end + + local aspectRatio = iconHeight / iconWidth + local horizontalCrop = math.max(0, (1 - (1 / aspectRatio)) / 2) + local verticalCrop = math.max(0, (1 - aspectRatio) / 2) + return zoom + horizontalCrop, 1 - zoom - horizontalCrop, zoom + verticalCrop, 1 - zoom - verticalCrop +end + -- local function FetchClassColour() -- local CooldownManagerDB = BCDM.db.profile -- local GeneralDB = CooldownManagerDB.General @@ -208,8 +219,9 @@ local function StyleIcons() if childFrame then if childFrame.Icon then BCDM:StripTextures(childFrame.Icon) - local iconZoomAmount = cooldownManagerSettings.General.IconZoom * 0.5 - childFrame.Icon:SetTexCoord(iconZoomAmount, 1 - iconZoomAmount, iconZoomAmount, 1 - iconZoomAmount) + local zoom = cooldownManagerSettings.General.IconZoom + local viewerSettings = cooldownManagerSettings[BCDM.CooldownManagerViewerToDBViewer[viewerName]] + childFrame.Icon:SetTexCoord(BCDM:CalculateTexCoords(zoom, viewerSettings.IconWidth, viewerSettings.IconHeight)) end if childFrame.Cooldown then local borderSize = cooldownManagerSettings.General.BorderSize @@ -223,7 +235,7 @@ local function StyleIcons() end if childFrame.CooldownFlash then childFrame.CooldownFlash:SetAlpha(0) end if childFrame.DebuffBorder then childFrame.DebuffBorder:SetAlpha(0) end - childFrame:SetSize(cooldownManagerSettings[BCDM.CooldownManagerViewerToDBViewer[viewerName]].IconSize, cooldownManagerSettings[BCDM.CooldownManagerViewerToDBViewer[viewerName]].IconSize) + childFrame:SetSize(cooldownManagerSettings[BCDM.CooldownManagerViewerToDBViewer[viewerName]].IconWidth, cooldownManagerSettings[BCDM.CooldownManagerViewerToDBViewer[viewerName]].IconHeight) BCDM:AddBorder(childFrame) if not childFrame.layoutIndex then childFrame:SetShown(false) end end @@ -363,7 +375,8 @@ function BCDM:UpdateCooldownViewer(viewerType) if childFrame then if childFrame.Icon and ShouldSkin() then BCDM:StripTextures(childFrame.Icon) - childFrame.Icon:SetTexCoord(cooldownManagerSettings.General.IconZoom, 1 - cooldownManagerSettings.General.IconZoom, cooldownManagerSettings.General.IconZoom, 1 - cooldownManagerSettings.General.IconZoom) + local zoom = cooldownManagerSettings.General.IconZoom + childFrame.Icon:SetTexCoord(BCDM:CalculateTexCoords(zoom, cooldownManagerSettings[viewerType].IconWidth, cooldownManagerSettings[viewerType].IconHeight)) end if childFrame.Cooldown then childFrame.Cooldown:ClearAllPoints() @@ -375,7 +388,7 @@ function BCDM:UpdateCooldownViewer(viewerType) childFrame.Cooldown:SetSwipeTexture("Interface\\Buttons\\WHITE8X8") end if childFrame.CooldownFlash then childFrame.CooldownFlash:SetAlpha(0) end - childFrame:SetSize(cooldownManagerSettings[viewerType].IconSize, cooldownManagerSettings[viewerType].IconSize) + childFrame:SetSize(cooldownManagerSettings[viewerType].IconWidth, cooldownManagerSettings[viewerType].IconHeight) end end diff --git a/Modules/CustomCooldownViewer.lua b/Modules/CustomCooldownViewer.lua index fdf4f46..1921229 100755 --- a/Modules/CustomCooldownViewer.lua +++ b/Modules/CustomCooldownViewer.lua @@ -65,7 +65,7 @@ local function CreateCustomIcon(spellId) else customIcon:SetBackdropBorderColor(0, 0, 0, 1) end - customIcon:SetSize(CustomDB.IconSize, CustomDB.IconSize) + customIcon:SetSize(CustomDB.IconWidth, CustomDB.IconHeight) local anchorParent = CustomDB.Layout[2] == "NONE" and UIParent or _G[CustomDB.Layout[2]] customIcon:SetPoint(CustomDB.Layout[1], anchorParent, CustomDB.Layout[3], CustomDB.Layout[4], CustomDB.Layout[5]) customIcon:RegisterEvent("SPELL_UPDATE_COOLDOWN") @@ -114,8 +114,8 @@ local function CreateCustomIcon(spellId) local borderSize = BCDM.db.profile.CooldownManager.General.BorderSize customIcon.Icon:SetPoint("TOPLEFT", customIcon, "TOPLEFT", borderSize, -borderSize) customIcon.Icon:SetPoint("BOTTOMRIGHT", customIcon, "BOTTOMRIGHT", -borderSize, borderSize) - local iconZoom = BCDM.db.profile.CooldownManager.General.IconZoom * 0.5 - customIcon.Icon:SetTexCoord(iconZoom, 1 - iconZoom, iconZoom, 1 - iconZoom) + local zoom = BCDM.db.profile.CooldownManager.General.IconZoom + customIcon.Icon:SetTexCoord(BCDM:CalculateTexCoords(zoom, CustomDB.IconWidth, CustomDB.IconHeight)) customIcon.Icon:SetTexture(C_Spell.GetSpellInfo(spellId).iconID) return customIcon @@ -183,7 +183,8 @@ local function LayoutCustomCooldownViewer() CreateCustomIcons(customCooldownViewerIcons) - local iconSize = CustomDB.IconSize + local iconWidth = CustomDB.IconWidth + local iconHeight = CustomDB.IconHeight local iconSpacing = CustomDB.Spacing -- Calculate and set container size first @@ -195,11 +196,11 @@ local function LayoutCustomCooldownViewer() local totalWidth, totalHeight = 0, 0 if useCenteredLayout or growthDirection == "RIGHT" or growthDirection == "LEFT" then - totalWidth = (#customCooldownViewerIcons * iconSize) + ((#customCooldownViewerIcons - 1) * iconSpacing) - totalHeight = iconSize + totalWidth = (#customCooldownViewerIcons * iconWidth) + ((#customCooldownViewerIcons - 1) * iconSpacing) + totalHeight = iconHeight elseif growthDirection == "UP" or growthDirection == "DOWN" then - totalWidth = iconSize - totalHeight = (#customCooldownViewerIcons * iconSize) + ((#customCooldownViewerIcons - 1) * iconSpacing) + totalWidth = iconWidth + totalHeight = (#customCooldownViewerIcons * iconHeight) + ((#customCooldownViewerIcons - 1) * iconSpacing) end BCDM.CustomCooldownViewerContainer:SetSize(totalWidth, totalHeight) end @@ -220,15 +221,15 @@ local function LayoutCustomCooldownViewer() local useCenteredLayout = (point == "TOP" or point == "BOTTOM") and (growthDirection == "LEFT" or growthDirection == "RIGHT") if useCenteredLayout and #customCooldownViewerIcons > 0 then - local totalWidth = (#customCooldownViewerIcons * iconSize) + ((#customCooldownViewerIcons - 1) * iconSpacing) - local startOffset = -(totalWidth / 2) + (iconSize / 2) + local totalWidth = (#customCooldownViewerIcons * iconWidth) + ((#customCooldownViewerIcons - 1) * iconSpacing) + local startOffset = -(totalWidth / 2) + (iconWidth / 2) for i, spellIcon in ipairs(customCooldownViewerIcons) do spellIcon:SetParent(BCDM.CustomCooldownViewerContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() - local xOffset = startOffset + ((i - 1) * (iconSize + iconSpacing)) + local xOffset = startOffset + ((i - 1) * (iconWidth + iconSpacing)) spellIcon:SetPoint("CENTER", BCDM.CustomCooldownViewerContainer, "CENTER", xOffset, 0) ApplyCooldownText() spellIcon:Show() @@ -236,7 +237,7 @@ local function LayoutCustomCooldownViewer() else for i, spellIcon in ipairs(customCooldownViewerIcons) do spellIcon:SetParent(BCDM.CustomCooldownViewerContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() if i == 1 then diff --git a/Modules/CustomItemSpellViewer.lua b/Modules/CustomItemSpellViewer.lua index 8078db8..522d883 100755 --- a/Modules/CustomItemSpellViewer.lua +++ b/Modules/CustomItemSpellViewer.lua @@ -74,7 +74,7 @@ local function CreateCustomItemIcon(itemId) else customIcon:SetBackdropBorderColor(0, 0, 0, 1) end - customIcon:SetSize(CustomDB.IconSize, CustomDB.IconSize) + customIcon:SetSize(CustomDB.IconWidth, CustomDB.IconHeight) local anchorParent = CustomDB.Layout[2] == "NONE" and UIParent or _G[CustomDB.Layout[2]] customIcon:SetPoint(CustomDB.Layout[1], anchorParent, CustomDB.Layout[3], CustomDB.Layout[4], CustomDB.Layout[5]) customIcon:RegisterEvent("SPELL_UPDATE_COOLDOWN") @@ -130,8 +130,8 @@ local function CreateCustomItemIcon(itemId) local borderSize = BCDM.db.profile.CooldownManager.General.BorderSize customIcon.Icon:SetPoint("TOPLEFT", customIcon, "TOPLEFT", borderSize, -borderSize) customIcon.Icon:SetPoint("BOTTOMRIGHT", customIcon, "BOTTOMRIGHT", -borderSize, borderSize) - local iconZoom = BCDM.db.profile.CooldownManager.General.IconZoom * 0.5 - customIcon.Icon:SetTexCoord(iconZoom, 1 - iconZoom, iconZoom, 1 - iconZoom) + local zoom = BCDM.db.profile.CooldownManager.General.IconZoom * 0.5 + customIcon.Icon:SetTexCoord(BCDM:CalculateTexCoords(zoom, CustomDB.IconWidth, CustomDB.IconHeight)) customIcon.Icon:SetTexture(select(10, C_Item.GetItemInfo(itemId))) return customIcon @@ -152,7 +152,7 @@ local function CreateCustomSpellIcon(spellId) else customIcon:SetBackdropBorderColor(0, 0, 0, 1) end - customIcon:SetSize(CustomDB.IconSize, CustomDB.IconSize) + customIcon:SetSize(CustomDB.IconWidth, CustomDB.IconHeight) local anchorParent = CustomDB.Layout[2] == "NONE" and UIParent or _G[CustomDB.Layout[2]] customIcon:SetPoint(CustomDB.Layout[1], anchorParent, CustomDB.Layout[3], CustomDB.Layout[4], CustomDB.Layout[5]) customIcon:RegisterEvent("SPELL_UPDATE_COOLDOWN") @@ -201,8 +201,8 @@ local function CreateCustomSpellIcon(spellId) local borderSize = BCDM.db.profile.CooldownManager.General.BorderSize customIcon.Icon:SetPoint("TOPLEFT", customIcon, "TOPLEFT", borderSize, -borderSize) customIcon.Icon:SetPoint("BOTTOMRIGHT", customIcon, "BOTTOMRIGHT", -borderSize, borderSize) - local iconZoom = BCDM.db.profile.CooldownManager.General.IconZoom * 0.5 - customIcon.Icon:SetTexCoord(iconZoom, 1 - iconZoom, iconZoom, 1 - iconZoom) + local zoom = BCDM.db.profile.CooldownManager.General.IconZoom * 0.5 + customIcon.Icon:SetTexCoord(BCDM:CalculateTexCoords(zoom, CustomDB.IconWidth, CustomDB.IconHeight)) customIcon.Icon:SetTexture(C_Spell.GetSpellInfo(spellId).iconID) return customIcon @@ -285,7 +285,8 @@ local function LayoutCustomItemsSpellsBar() CreateCustomIcons(customItemBarIcons) - local iconSize = CustomDB.IconSize + local iconWidth = CustomDB.IconWidth + local iconHeight = CustomDB.IconHeight local iconSpacing = CustomDB.Spacing if #customItemBarIcons == 0 then @@ -296,11 +297,11 @@ local function LayoutCustomItemsSpellsBar() local totalWidth, totalHeight = 0, 0 if useCenteredLayout or growthDirection == "RIGHT" or growthDirection == "LEFT" then - totalWidth = (#customItemBarIcons * iconSize) + ((#customItemBarIcons - 1) * iconSpacing) - totalHeight = iconSize + totalWidth = (#customItemBarIcons * iconWidth) + ((#customItemBarIcons - 1) * iconSpacing) + totalHeight = iconHeight elseif growthDirection == "UP" or growthDirection == "DOWN" then - totalWidth = iconSize - totalHeight = (#customItemBarIcons * iconSize) + ((#customItemBarIcons - 1) * iconSpacing) + totalWidth = iconWidth + totalHeight = (#customItemBarIcons * iconHeight) + ((#customItemBarIcons - 1) * iconSpacing) end BCDM.CustomItemSpellBarContainer:SetWidth(totalWidth) BCDM.CustomItemSpellBarContainer:SetHeight(totalHeight) @@ -322,15 +323,15 @@ local function LayoutCustomItemsSpellsBar() local useCenteredLayout = (point == "TOP" or point == "BOTTOM") and (growthDirection == "LEFT" or growthDirection == "RIGHT") if useCenteredLayout and #customItemBarIcons > 0 then - local totalWidth = (#customItemBarIcons * iconSize) + ((#customItemBarIcons - 1) * iconSpacing) - local startOffset = -(totalWidth / 2) + (iconSize / 2) + local totalWidth = (#customItemBarIcons * iconWidth) + ((#customItemBarIcons - 1) * iconSpacing) + local startOffset = -(totalWidth / 2) + (iconWidth / 2) for i, spellIcon in ipairs(customItemBarIcons) do spellIcon:SetParent(BCDM.CustomItemSpellBarContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() - local xOffset = startOffset + ((i - 1) * (iconSize + iconSpacing)) + local xOffset = startOffset + ((i - 1) * (iconWidth + iconSpacing)) spellIcon:SetPoint("CENTER", BCDM.CustomItemSpellBarContainer, "CENTER", xOffset, 0) ApplyCooldownText() spellIcon:Show() @@ -338,7 +339,7 @@ local function LayoutCustomItemsSpellsBar() else for i, spellIcon in ipairs(customItemBarIcons) do spellIcon:SetParent(BCDM.CustomItemSpellBarContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() if i == 1 then diff --git a/Modules/CustomItemViewer.lua b/Modules/CustomItemViewer.lua index 21fbcba..04a4ecf 100755 --- a/Modules/CustomItemViewer.lua +++ b/Modules/CustomItemViewer.lua @@ -74,7 +74,7 @@ local function CreateCustomIcon(itemId) else customIcon:SetBackdropBorderColor(0, 0, 0, 1) end - customIcon:SetSize(CustomDB.IconSize, CustomDB.IconSize) + customIcon:SetSize(CustomDB.IconWidth, CustomDB.IconHeight) local anchorParent = CustomDB.Layout[2] == "NONE" and UIParent or _G[CustomDB.Layout[2]] customIcon:SetPoint(CustomDB.Layout[1], anchorParent, CustomDB.Layout[3], CustomDB.Layout[4], CustomDB.Layout[5]) customIcon:RegisterEvent("SPELL_UPDATE_COOLDOWN") @@ -130,8 +130,8 @@ local function CreateCustomIcon(itemId) local borderSize = BCDM.db.profile.CooldownManager.General.BorderSize customIcon.Icon:SetPoint("TOPLEFT", customIcon, "TOPLEFT", borderSize, -borderSize) customIcon.Icon:SetPoint("BOTTOMRIGHT", customIcon, "BOTTOMRIGHT", -borderSize, borderSize) - local iconZoom = BCDM.db.profile.CooldownManager.General.IconZoom * 0.5 - customIcon.Icon:SetTexCoord(iconZoom, 1 - iconZoom, iconZoom, 1 - iconZoom) + local zoom = BCDM.db.profile.CooldownManager.General.IconZoom + customIcon.Icon:SetTexCoord(BCDM:CalculateTexCoords(zoom, CustomDB.IconWidth, CustomDB.IconHeight)) customIcon.Icon:SetTexture(select(10, C_Item.GetItemInfo(itemId))) return customIcon @@ -214,7 +214,8 @@ local function LayoutCustomItemBar() CreateCustomIcons(customItemBarIcons) - local iconSize = CustomDB.IconSize + local iconWidth = CustomDB.IconWidth + local iconHeight = CustomDB.IconHeight local iconSpacing = CustomDB.Spacing if #customItemBarIcons == 0 then @@ -225,11 +226,11 @@ local function LayoutCustomItemBar() local totalWidth, totalHeight = 0, 0 if useCenteredLayout or growthDirection == "RIGHT" or growthDirection == "LEFT" then - totalWidth = (#customItemBarIcons * iconSize) + ((#customItemBarIcons - 1) * iconSpacing) - totalHeight = iconSize + totalWidth = (#customItemBarIcons * iconWidth) + ((#customItemBarIcons - 1) * iconSpacing) + totalHeight = iconHeight elseif growthDirection == "UP" or growthDirection == "DOWN" then - totalWidth = iconSize - totalHeight = (#customItemBarIcons * iconSize) + ((#customItemBarIcons - 1) * iconSpacing) + totalWidth = iconWidth + totalHeight = (#customItemBarIcons * iconHeight) + ((#customItemBarIcons - 1) * iconSpacing) end BCDM.CustomItemBarContainer:SetWidth(totalWidth) BCDM.CustomItemBarContainer:SetHeight(totalHeight) @@ -251,15 +252,15 @@ local function LayoutCustomItemBar() local useCenteredLayout = (point == "TOP" or point == "BOTTOM") and (growthDirection == "LEFT" or growthDirection == "RIGHT") if useCenteredLayout and #customItemBarIcons > 0 then - local totalWidth = (#customItemBarIcons * iconSize) + ((#customItemBarIcons - 1) * iconSpacing) - local startOffset = -(totalWidth / 2) + (iconSize / 2) + local totalWidth = (#customItemBarIcons * iconWidth) + ((#customItemBarIcons - 1) * iconSpacing) + local startOffset = -(totalWidth / 2) + (iconWidth / 2) for i, spellIcon in ipairs(customItemBarIcons) do spellIcon:SetParent(BCDM.CustomItemBarContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() - local xOffset = startOffset + ((i - 1) * (iconSize + iconSpacing)) + local xOffset = startOffset + ((i - 1) * (iconWidth + iconSpacing)) spellIcon:SetPoint("CENTER", BCDM.CustomItemBarContainer, "CENTER", xOffset, 0) ApplyCooldownText() spellIcon:Show() @@ -267,7 +268,7 @@ local function LayoutCustomItemBar() else for i, spellIcon in ipairs(customItemBarIcons) do spellIcon:SetParent(BCDM.CustomItemBarContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() if i == 1 then diff --git a/Modules/TrinketBar.lua b/Modules/TrinketBar.lua index 6f334a7..a008f64 100755 --- a/Modules/TrinketBar.lua +++ b/Modules/TrinketBar.lua @@ -72,7 +72,7 @@ local function CreateCustomIcon(itemId) else customIcon:SetBackdropBorderColor(0, 0, 0, 1) end - customIcon:SetSize(CustomDB.IconSize, CustomDB.IconSize) + customIcon:SetSize(CustomDB.IconWidth, CustomDB.IconHeight) local anchorParent = CustomDB.Layout[2] == "NONE" and UIParent or _G[CustomDB.Layout[2]] customIcon:SetPoint(CustomDB.Layout[1], anchorParent, CustomDB.Layout[3], CustomDB.Layout[4], CustomDB.Layout[5]) customIcon:RegisterEvent("SPELL_UPDATE_COOLDOWN") @@ -105,8 +105,8 @@ local function CreateCustomIcon(itemId) local borderSize = BCDM.db.profile.CooldownManager.General.BorderSize customIcon.Icon:SetPoint("TOPLEFT", customIcon, "TOPLEFT", borderSize, -borderSize) customIcon.Icon:SetPoint("BOTTOMRIGHT", customIcon, "BOTTOMRIGHT", -borderSize, borderSize) - local iconZoom = BCDM.db.profile.CooldownManager.General.IconZoom * 0.5 - customIcon.Icon:SetTexCoord(iconZoom, 1 - iconZoom, iconZoom, 1 - iconZoom) + local zoom = BCDM.db.profile.CooldownManager.General.IconZoom + customIcon.Icon:SetTexCoord(BCDM:CalculateTexCoords(zoom, CustomDB.IconWidth, CustomDB.IconHeight)) customIcon.Icon:SetTexture(select(10, C_Item.GetItemInfo(itemId))) return customIcon @@ -170,7 +170,8 @@ local function LayoutTrinketBar() CreateCustomIcons(customTrinketIcons) - local iconSize = CustomDB.IconSize + local iconWidth = CustomDB.IconWidth + local iconHeight = CustomDB.IconHeight local iconSpacing = CustomDB.Spacing if #customTrinketIcons == 0 then @@ -181,11 +182,11 @@ local function LayoutTrinketBar() local totalWidth, totalHeight = 0, 0 if useCenteredLayout or growthDirection == "RIGHT" or growthDirection == "LEFT" then - totalWidth = (#customTrinketIcons * iconSize) + ((#customTrinketIcons - 1) * iconSpacing) - totalHeight = iconSize + totalWidth = (#customTrinketIcons * iconWidth) + ((#customTrinketIcons - 1) * iconSpacing) + totalHeight = iconHeight elseif growthDirection == "UP" or growthDirection == "DOWN" then - totalWidth = iconSize - totalHeight = (#customTrinketIcons * iconSize) + ((#customTrinketIcons - 1) * iconSpacing) + totalWidth = iconWidth + totalHeight = (#customTrinketIcons * iconHeight) + ((#customTrinketIcons - 1) * iconSpacing) end BCDM.TrinketBarContainer:SetWidth(totalWidth) BCDM.TrinketBarContainer:SetHeight(totalHeight) @@ -207,15 +208,15 @@ local function LayoutTrinketBar() local useCenteredLayout = (point == "TOP" or point == "BOTTOM") and (growthDirection == "LEFT" or growthDirection == "RIGHT") if useCenteredLayout and #customTrinketIcons > 0 then - local totalWidth = (#customTrinketIcons * iconSize) + ((#customTrinketIcons - 1) * iconSpacing) - local startOffset = -(totalWidth / 2) + (iconSize / 2) + local totalWidth = (#customTrinketIcons * iconWidth) + ((#customTrinketIcons - 1) * iconSpacing) + local startOffset = -(totalWidth / 2) + (iconWidth / 2) for i, spellIcon in ipairs(customTrinketIcons) do spellIcon:SetParent(BCDM.TrinketBarContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() - local xOffset = startOffset + ((i - 1) * (iconSize + iconSpacing)) + local xOffset = startOffset + ((i - 1) * (iconWidth + iconSpacing)) spellIcon:SetPoint("CENTER", BCDM.TrinketBarContainer, "CENTER", xOffset, 0) ApplyCooldownText() spellIcon:Show() @@ -223,7 +224,7 @@ local function LayoutTrinketBar() else for i, spellIcon in ipairs(customTrinketIcons) do spellIcon:SetParent(BCDM.TrinketBarContainer) - spellIcon:SetSize(iconSize, iconSize) + spellIcon:SetSize(iconWidth, iconHeight) spellIcon:ClearAllPoints() if i == 1 then