From 1d8bfc1e6fa86c398a12752b7edda0826c00ce3b Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Sun, 6 Feb 2022 23:41:08 +0100 Subject: [PATCH 01/31] actual pixel perfect borders (with mouseanchor) --- TipTac/ttCore.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index bf3ddc3..4673134 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -33,6 +33,11 @@ end local modName = ...; local tt = CreateFrame("Frame",modName,UIParent,BackdropTemplateMixin and "BackdropTemplate"); -- 9.0.1: Using BackdropTemplate +-- actual pixel perfect scale +local ui_scale = UIParent:GetEffectiveScale() +local height = select(2, GetPhysicalScreenSize()) +local ppScale = (768 / height) / ui_scale + -- Global Chat Message Function function AzMsg(msg) DEFAULT_CHAT_FRAME:AddMessage(tostring(msg):gsub("|1","|cffffff80"):gsub("|2","|cffffffff"),0.5,0.75,1.0); end @@ -561,9 +566,9 @@ end -- Settings -- -------------------------------------------------------------------------------------------------------- --- Get nearest pixel size (e.g. to avoid 1-pixel borders, which are sometimes 0/2-pixels wide) +-- Get nearest pixel size (e.g. to avoid 1-pixel borders, which are sometimes 2-pixels wide) local function GetNearestPixelSize(size) - return PixelUtil.GetNearestPixelSize(size, cfg.gttScale); + return size * ppScale; end -- Resolves the given table array of string names into their global objects @@ -905,8 +910,9 @@ end function tt:AnchorFrameToMouse(frame) local x, y = GetCursorPosition(); local effScale = frame:GetEffectiveScale(); + local offsetX, offsetY = cfg.mouseOffsetX * ppScale, cfg.mouseOffsetY * ppScale; frame:ClearAllPoints(); - frame:SetPoint(frame.ttAnchorPoint,UIParent,"BOTTOMLEFT",(x / effScale + cfg.mouseOffsetX),(y / effScale + cfg.mouseOffsetY)); + frame:SetPoint(frame.ttAnchorPoint,UIParent,"BOTTOMLEFT",(x / effScale + offsetX),(y / effScale + offsetY)); end -- Re-anchor for anchor type mouse From 8758aba0c633e9706e73da6fac69a3ce985bdcb2 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Mon, 7 Feb 2022 02:37:54 +0100 Subject: [PATCH 02/31] borders for icon and auras with various options --- TipTac/ttAuras.lua | 69 ++++++++++++++++++++++++++----------- TipTac/ttCore.lua | 8 +++++ TipTacItemRef/ttItemRef.lua | 34 ++++++++++++++++-- TipTacOptions/ttOptions.lua | 14 ++++++++ 4 files changed, 102 insertions(+), 23 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 3c162bb..ab5ec67 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -4,6 +4,11 @@ local gtt = GameTooltip; local tt = TipTac; local cfg; +-- actual pixel perfect scale +local ui_scale = UIParent:GetEffectiveScale() +local height = select(2, GetPhysicalScreenSize()) +local ppScale = (768 / height) / ui_scale + -- element registration local ttAuras = tt:RegisterElement({ auras = {} },"Auras"); local auras = ttAuras.auras; @@ -20,8 +25,8 @@ local validSelfCasterUnits = { -------------------------------------------------------------------------------------------------------- local function CreateAuraFrame(parent) - local aura = CreateFrame("Frame",nil,parent); - aura:SetSize(cfg.auraSize,cfg.auraSize); + local aura = CreateFrame("Frame", nil, parent, BackdropTemplateMixin and "BackdropTemplate"); + aura:SetSize(cfg.auraSize*ppScale, cfg.auraSize*ppScale); aura.count = aura:CreateFontString(nil,"OVERLAY"); aura.count:SetPoint("BOTTOMRIGHT",1,0); @@ -37,11 +42,20 @@ local function CreateAuraFrame(parent) aura.cooldown:SetFrameLevel(aura:GetFrameLevel()); aura.cooldown.noCooldownCount = cfg.noCooldownCount or nil; - aura.border = aura:CreateTexture(nil,"OVERLAY"); - aura.border:SetPoint("TOPLEFT",-1,1); - aura.border:SetPoint("BOTTOMRIGHT",1,-1); - aura.border:SetTexture("Interface\\Buttons\\UI-Debuff-Overlays"); - aura.border:SetTexCoord(0.296875,0.5703125,0,0.515625); + if (cfg.auraCustomBorder) then + aura.border = CreateFrame("Frame", nil, aura, BackdropTemplateMixin and "BackdropTemplate"); + aura.border:SetSize(cfg.auraSize*ppScale, cfg.auraSize*ppScale); + aura.border:SetPoint("CENTER", aura, "CENTER"); + aura.border:SetBackdrop(parent.backdropInfo); + aura.border:SetBackdropColor(0, 0, 0, 0); + aura.border:SetFrameLevel(aura.cooldown:GetFrameLevel()+1); + else + aura.border = aura:CreateTexture(nil,"OVERLAY"); + aura.border:SetPoint("TOPLEFT",-1,1); + aura.border:SetPoint("BOTTOMRIGHT",1,-1); + aura.border:SetTexture("Interface\\Buttons\\UI-Debuff-Overlays"); + aura.border:SetTexCoord(0.296875,0.5703125,0,0.515625); + end auras[#auras + 1] = aura; return aura; @@ -49,9 +63,10 @@ end -- querires auras of the specific auraType, and sets up the aura frame and anchors it in the desired place function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) - - local aurasPerRow = floor((tip:GetWidth() - 4) / (cfg.auraSize + 2)); -- auras we can fit into one row based on the current size of the tooltip - local xOffsetBasis = (auraType == "HELPFUL" and 1 or -1); -- is +1 or -1 based on horz anchoring + -- want them to be flush with the tooltips borders, means we subtract 1 offset since the very last one doesn't need to be there + -- also assure at least auraMinOffsetBetweenBuffAndDebuff pixels between buffs/debuffs + local aurasPerRow = floor((tip:GetWidth() - cfg.auraOffsetX*ppScale - cfg.auraMinOffsetBetweenBuffAndDebuff*ppScale) / ((cfg.auraSize + cfg.auraOffsetX)*ppScale)); -- auras we can fit into one row based on the current size of the tooltip + local xOffsetBasis = (auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX) * ppScale; -- is +1 or -1 based on horz anchoring local queryIndex = 1; -- aura query index for this auraType local auraFrameIndex = startingAuraFrameIndex; -- array index for the next aura frame, initialized to the starting index @@ -70,6 +85,7 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) if (not iconTexture) or (auraFrameIndex / aurasPerRow > cfg.auraMaxRows) then break; end + if (not cfg.selfAurasOnly or validSelfCasterUnits[casterUnit]) then local aura = auras[auraFrameIndex] or CreateAuraFrame(tip); @@ -77,13 +93,13 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) aura:ClearAllPoints(); if ((auraFrameIndex - 1) % aurasPerRow == 0) or (auraFrameIndex == startingAuraFrameIndex) then -- new aura line - local x = (xOffsetBasis * 2); - local y = (cfg.auraSize + 2) * floor((auraFrameIndex - 1) / aurasPerRow) + 1; + local x = 0; + local y = (cfg.auraSize*ppScale + 2) * floor((auraFrameIndex - 1) / aurasPerRow) + cfg.auraOffsetY*ppScale; y = (cfg.aurasAtBottom and -y or y); aura:SetPoint(anchor1,tip,anchor2,x,y); else -- anchor to last - aura:SetPoint(horzAnchor1, auras[auraFrameIndex - 1], horzAnchor2, (xOffsetBasis * 2), 0); + aura:SetPoint(horzAnchor1, auras[auraFrameIndex - 1], horzAnchor2, (xOffsetBasis), 0); end -- Cooldown @@ -98,12 +114,24 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) aura.count:SetText(count and count > 1 and count or ""); -- Border -- Only shown for debuffs - if (auraType == "HARMFUL") then - local color = DebuffTypeColor[debuffType] or DebuffTypeColor["none"]; - aura.border:SetVertexColor(color.r,color.g,color.b); - aura.border:Show(); + if (cfg.auraCustomBorder) then + if (cfg.auraBorderUseParentColor) then + aura.border:SetBackdropBorderColor(tip:GetBackdropBorderColor()); + else + if (auraType == "HARMFUL") then + aura.border:SetBackdropBorderColor(unpack(cfg.auraBorderDebuffColor)); + else + aura.border:SetBackdropBorderColor(unpack(cfg.auraBorderBuffColor)); + end + end else - aura.border:Hide(); + if (auraType == "HARMFUL") then + local color = DebuffTypeColor[debuffType] or DebuffTypeColor["none"]; + aura.border:SetVertexColor(color.r,color.g,color.b); + aura.border:Show(); + else + aura.border:Hide(); + end end -- Show + Next, Break if exceed max desired rows of aura @@ -147,8 +175,9 @@ function ttAuras:OnApplyConfig(cfg) local gameFont = GameFontNormal:GetFont(); for _, aura in ipairs(auras) do if (cfg.showBuffs or cfg.showDebuffs) then - aura:SetWidth(cfg.auraSize,cfg.auraSize); - aura.count:SetFont(gameFont,(cfg.auraSize / 2),"OUTLINE"); + aura:SetSize(cfg.auraSize*ppScale,cfg.auraSize*ppScale); + aura.border:SetSize(cfg.auraSize*ppScale,cfg.auraSize*ppScale); + aura.count:SetFont(gameFont,(cfg.auraSize*ppScale / 2),"OUTLINE"); aura.cooldown.noCooldownCount = cfg.noCooldownCount; else aura:Hide(); diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index 4673134..b863f06 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -146,6 +146,13 @@ local TT_DefaultConfig = { auraMaxRows = 2, showAuraCooldown = true, noCooldownCount = false, + auraCustomBorder = true, + auraBorderUseParentColor = false, + auraBorderBuffColor = { 0, 1, 0 }, + auraBorderDebuffColor = { 1, 0, 0 }, + auraOffsetX = 2, + auraOffsetY = 2, + auraMinOffsetBetweenBuffAndDebuff = 10, iconRaid = true, iconFaction = false, @@ -234,6 +241,7 @@ local TT_DefaultConfig = { if_iconTooltipAnchor = "TOPLEFT", if_iconOffsetX = 2.5, if_iconOffsetY = -2.5, + if_copyParentBorder = false, }; -- Tips modified by TipTac in appearance and scale, you can add to this list if you want to modify more tips. diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index 239724d..26e19a7 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -40,6 +40,11 @@ end local modName = ...; local ttif = CreateFrame("Frame", modName); +-- actual pixel perfect scale +local ui_scale = UIParent:GetEffectiveScale() +local height = select(2, GetPhysicalScreenSize()) +local ppScale = (768 / height) / ui_scale + -- Register with TipTac core addon if available if (TipTac) then TipTac:RegisterElement(ttif,"ItemRef"); @@ -102,6 +107,7 @@ local cfg = { if_iconTooltipAnchor = "TOPLEFT", if_iconOffsetX = 2.5, if_iconOffsetY = -2.5, + if_copyParentBorder = false, }; -- Tooltips to Hook into -- MUST be a GameTooltip widget -- If the main TipTac is installed, the TT_TipsToModify is used instead @@ -173,8 +179,14 @@ local function ttSetIconTextureAndText(self, texture, count) else self.ttCount:SetText(""); end + if (not cfg.if_copyParentBorder) then + self.ttIcon.border:Hide(); + else + self.ttIcon.border:Show(); + end self.ttIcon:Show(); else + self.ttIcon.border:Hide(); self.ttIcon:Hide(); self.ttCount:SetText(""); end @@ -183,14 +195,28 @@ end -- Create Icon with Counter Text for Tooltip function ttif:CreateTooltipIcon(tip) tip.ttIcon = tip:CreateTexture(nil, "BACKGROUND"); - tip.ttIcon:SetPoint(cfg.if_iconAnchor,tip, cfg.if_iconTooltipAnchor, cfg.if_iconOffsetX, cfg.if_iconOffsetY); + tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, cfg.if_iconOffsetX * ppScale, cfg.if_iconOffsetY * ppScale); + tip.ttIcon:SetScale(tip:GetScale()); tip.ttIcon:Hide(); + tip.ttIcon.border = CreateFrame("Frame", nil, tip, BackdropTemplateMixin and "BackdropTemplate"); + tip.ttIcon.border:SetPoint("BOTTOMLEFT", tip.ttIcon, "BOTTOMLEFT"); + tip.ttIcon.border:SetScale(tip:GetScale()); + --tip.ttIcon.border:Hide(); + tip.ttCount = tip:CreateFontString(nil, "ARTWORK"); tip.ttCount:SetTextColor(1, 1, 1); tip.ttCount:SetPoint("BOTTOMRIGHT", tip.ttIcon, "BOTTOMRIGHT", -3, 3); end +function ttif:ApplyBorderToTooltipIcon(tip) + if (cfg.if_copyParentBorder) then + tip.ttIcon.border:SetBackdrop(tip.backdropInfo); + tip.ttIcon.border:SetBackdropColor(0, 0, 0, 0); + tip.ttIcon.border:SetBackdropBorderColor(tip:GetBackdropBorderColor()); + end +end + -------------------------------------------------------------------------------------------------------- -- TipTacItemRef Frame -- -------------------------------------------------------------------------------------------------------- @@ -254,16 +280,17 @@ function ttif:OnApplyConfig() for index, tip in ipairs(tipsToModify) do if (type(tip) == "table") and (tipsToAddIcon[tip:GetName()]) and (tip.ttIcon) then if (cfg.if_showIcon) then + tip.ttIcon.border:SetSize(cfg.if_iconSize, cfg.if_iconSize); tip.ttIcon:SetSize(cfg.if_iconSize, cfg.if_iconSize); tip.ttCount:SetFont(gameFont, (cfg.if_iconSize / 3), "OUTLINE"); tip.ttSetIconTextureAndText = ttSetIconTextureAndText; - if (cfg.if_borderlessIcons) then + if (cfg.if_borderlessIcons or cfg.if_copyParentBorder) then tip.ttIcon:SetTexCoord(0.07, 0.93, 0.07, 0.93); else tip.ttIcon:SetTexCoord(0, 1, 0, 1); end tip.ttIcon:ClearAllPoints(); - tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, cfg.if_iconOffsetX, cfg.if_iconOffsetY); + tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, cfg.if_iconOffsetX * ppScale, cfg.if_iconOffsetY * ppScale); elseif (tip.ttSetIconTextureAndText) then tip.ttIcon:Hide(); tip.ttSetIconTextureAndText = nil; @@ -1727,6 +1754,7 @@ function ttif:SetBackdropBorderColorLocked(tip, lockColor, r, g, b, a) tip.ttSetBackdropBorderColorLocked = false; tip:SetBackdropBorderColor(r, g, b, (a or 1) * ((cfg.tipBorderColor and cfg.tipBorderColor[4]) or 1)); tip.ttSetBackdropBorderColorLocked = true; + self:ApplyBorderToTooltipIcon(tip); if (lockColor) then tip.ttBackdropBorderColorApplied = true; diff --git a/TipTacOptions/ttOptions.lua b/TipTacOptions/ttOptions.lua index a1b2082..00c4135 100644 --- a/TipTacOptions/ttOptions.lua +++ b/TipTacOptions/ttOptions.lua @@ -181,8 +181,21 @@ local options = { { type = "Check", var = "selfAurasOnly", label = "Only Show Auras Coming from You", tip = "This will filter out and only display auras you cast yourself", y = 12 }, { type = "Slider", var = "auraSize", label = "Aura Icon Dimension", min = 8, max = 60, step = 1, y = 12 }, { type = "Slider", var = "auraMaxRows", label = "Max Aura Rows", min = 1, max = 8, step = 1 }, + + { type = "Slider", var = "auraOffsetX", label = "X offset between aura icons", min = 0, max = 20, step = 1 }, + { type = "Slider", var = "auraOffsetY", label = "Y offset between aura rows", min = 0, max = 20, step = 1 }, + { type = "Slider", var = "auraMinOffsetBetweenBuffAndDebuff", label = "Min. dist. between buffs/debuffs", min = 0, max = 50, step = 1 }, + + { type = "Check", var = "showAuraCooldown", label = "Show Cooldown Models", tip = "With this option on, you will see a visual progress of the time left on the buff", y = 8 }, { type = "Check", var = "noCooldownCount", label = "No Cooldown Count Text", tip = "Tells cooldown enhancement addons, such as OmniCC, not to display cooldown text" }, + + { type = "Check", var = "auraCustomBorder", label = "Custom aura icon border", tip = "Use a custom aura icon border" }, + { type = "Check", var = "auraBorderUseParentColor", label = "Copy border color of tooltip", tip = "Copies the bordercolor of the tooltip for the aura icons" }, + { type = "Color", var = "auraBorderBuffColor", label = "Custom buff border color" }, + { type = "Color", var = "auraBorderDebuffColor", label = "Custom debuff border color" }, + + }, -- Icon { @@ -317,6 +330,7 @@ if (TipTacItemRef) then { type = "Check", var = "if_showIcon", label = "Show Icon Texture and Stack Count (when available)", tip = "Shows an icon next to the tooltip. For items, the stack count will also be shown", y = 12 }, { type = "Check", var = "if_smartIcons", label = "Smart Icon Appearance", tip = "When enabled, TipTacItemRef will determine if an icon is needed, based on where the tip is shown. It will not be shown on actionbars or bag slots for example, as they already show an icon" }, { type = "Check", var = "if_borderlessIcons", label = "Borderless Icons", tip = "Turn off the border on icons" }, + { type = "Check", var = "if_copyParentBorder", label = "Copy border from tooltip", tip = "Copies the border from the tooltip" }, { type = "Slider", var = "if_iconSize", label = "Icon Size", min = 16, max = 128, step = 1 }, { type = "DropDown", var = "if_iconAnchor", label = "Icon Anchor", tip = "The anchor of the icon", list = DROPDOWN_ANCHORPOS }, { type = "DropDown", var = "if_iconTooltipAnchor", label = "Icon Tooltip Anchor", tip = "The anchor of the tooltip that the icon should anchor to.", list = DROPDOWN_ANCHORPOS }, From 25e2abf48c5d3c276ed95fdd9428fe4396287c7d Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Mon, 7 Feb 2022 03:11:35 +0100 Subject: [PATCH 03/31] compacted the old borderstyle within the new one --- TipTac/ttAuras.lua | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index ab5ec67..9045ef6 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -42,20 +42,12 @@ local function CreateAuraFrame(parent) aura.cooldown:SetFrameLevel(aura:GetFrameLevel()); aura.cooldown.noCooldownCount = cfg.noCooldownCount or nil; - if (cfg.auraCustomBorder) then - aura.border = CreateFrame("Frame", nil, aura, BackdropTemplateMixin and "BackdropTemplate"); - aura.border:SetSize(cfg.auraSize*ppScale, cfg.auraSize*ppScale); - aura.border:SetPoint("CENTER", aura, "CENTER"); - aura.border:SetBackdrop(parent.backdropInfo); - aura.border:SetBackdropColor(0, 0, 0, 0); - aura.border:SetFrameLevel(aura.cooldown:GetFrameLevel()+1); - else - aura.border = aura:CreateTexture(nil,"OVERLAY"); - aura.border:SetPoint("TOPLEFT",-1,1); - aura.border:SetPoint("BOTTOMRIGHT",1,-1); - aura.border:SetTexture("Interface\\Buttons\\UI-Debuff-Overlays"); - aura.border:SetTexCoord(0.296875,0.5703125,0,0.515625); - end + aura.border = CreateFrame("Frame", nil, aura, BackdropTemplateMixin and "BackdropTemplate"); + aura.border:SetSize(cfg.auraSize*ppScale, cfg.auraSize*ppScale); + aura.border:SetPoint("CENTER", aura, "CENTER"); + aura.border:SetBackdrop(aura:GetParent().backdropInfo); + aura.border:SetBackdropColor(0, 0, 0, 0); + aura.border:SetFrameLevel(aura.cooldown:GetFrameLevel()+1); auras[#auras + 1] = aura; return aura; @@ -127,8 +119,7 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) else if (auraType == "HARMFUL") then local color = DebuffTypeColor[debuffType] or DebuffTypeColor["none"]; - aura.border:SetVertexColor(color.r,color.g,color.b); - aura.border:Show(); + aura.border:SetBackdropBorderColor(unpack(cfg.auraBorderDebuffColor)); else aura.border:Hide(); end From 286d2a58bbd40eec84d11dd64d2bd02b1e019f7e Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Mon, 7 Feb 2022 03:18:22 +0100 Subject: [PATCH 04/31] small fix --- TipTac/ttAuras.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 9045ef6..97b2b45 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -168,6 +168,7 @@ function ttAuras:OnApplyConfig(cfg) if (cfg.showBuffs or cfg.showDebuffs) then aura:SetSize(cfg.auraSize*ppScale,cfg.auraSize*ppScale); aura.border:SetSize(cfg.auraSize*ppScale,cfg.auraSize*ppScale); + aura.border:Show(); aura.count:SetFont(gameFont,(cfg.auraSize*ppScale / 2),"OUTLINE"); aura.cooldown.noCooldownCount = cfg.noCooldownCount; else From a61003266ab8bad06b6163de7310c1d2950acf40 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Mon, 7 Feb 2022 03:38:54 +0100 Subject: [PATCH 05/31] removed min distance between buffs/debuffs --- TipTac/ttAuras.lua | 3 +-- TipTac/ttCore.lua | 1 - TipTacOptions/ttOptions.lua | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 97b2b45..fe9688a 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -56,8 +56,7 @@ end -- querires auras of the specific auraType, and sets up the aura frame and anchors it in the desired place function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) -- want them to be flush with the tooltips borders, means we subtract 1 offset since the very last one doesn't need to be there - -- also assure at least auraMinOffsetBetweenBuffAndDebuff pixels between buffs/debuffs - local aurasPerRow = floor((tip:GetWidth() - cfg.auraOffsetX*ppScale - cfg.auraMinOffsetBetweenBuffAndDebuff*ppScale) / ((cfg.auraSize + cfg.auraOffsetX)*ppScale)); -- auras we can fit into one row based on the current size of the tooltip + local aurasPerRow = floor((tip:GetWidth() - cfg.auraOffsetX*ppScale) / ((cfg.auraSize + cfg.auraOffsetX)*ppScale)); -- auras we can fit into one row based on the current size of the tooltip local xOffsetBasis = (auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX) * ppScale; -- is +1 or -1 based on horz anchoring local queryIndex = 1; -- aura query index for this auraType diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index b863f06..5f6c389 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -152,7 +152,6 @@ local TT_DefaultConfig = { auraBorderDebuffColor = { 1, 0, 0 }, auraOffsetX = 2, auraOffsetY = 2, - auraMinOffsetBetweenBuffAndDebuff = 10, iconRaid = true, iconFaction = false, diff --git a/TipTacOptions/ttOptions.lua b/TipTacOptions/ttOptions.lua index 00c4135..f632263 100644 --- a/TipTacOptions/ttOptions.lua +++ b/TipTacOptions/ttOptions.lua @@ -184,7 +184,6 @@ local options = { { type = "Slider", var = "auraOffsetX", label = "X offset between aura icons", min = 0, max = 20, step = 1 }, { type = "Slider", var = "auraOffsetY", label = "Y offset between aura rows", min = 0, max = 20, step = 1 }, - { type = "Slider", var = "auraMinOffsetBetweenBuffAndDebuff", label = "Min. dist. between buffs/debuffs", min = 0, max = 50, step = 1 }, { type = "Check", var = "showAuraCooldown", label = "Show Cooldown Models", tip = "With this option on, you will see a visual progress of the time left on the buff", y = 8 }, From 5c6ea09dc59dba70b964eb0540e9b93b5c0af0b8 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Mon, 7 Feb 2022 03:59:52 +0100 Subject: [PATCH 06/31] better "slight fix" --- TipTac/ttAuras.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index fe9688a..99f76ec 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -115,6 +115,7 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) aura.border:SetBackdropBorderColor(unpack(cfg.auraBorderBuffColor)); end end + aura.border:Show(); else if (auraType == "HARMFUL") then local color = DebuffTypeColor[debuffType] or DebuffTypeColor["none"]; @@ -167,7 +168,6 @@ function ttAuras:OnApplyConfig(cfg) if (cfg.showBuffs or cfg.showDebuffs) then aura:SetSize(cfg.auraSize*ppScale,cfg.auraSize*ppScale); aura.border:SetSize(cfg.auraSize*ppScale,cfg.auraSize*ppScale); - aura.border:Show(); aura.count:SetFont(gameFont,(cfg.auraSize*ppScale / 2),"OUTLINE"); aura.cooldown.noCooldownCount = cfg.noCooldownCount; else From 5196e9669f5266921671496ddbcf28c0d5cc1cce Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Mon, 7 Feb 2022 05:28:11 +0100 Subject: [PATCH 07/31] pixelperfect borders now work with any scale set in the "Special" options --- TipTac/ttAuras.lua | 17 +++++++++-------- TipTac/ttCore.lua | 16 ++++++++-------- TipTacItemRef/ttItemRef.lua | 11 ++++++----- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 99f76ec..27bbd5e 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -26,7 +26,7 @@ local validSelfCasterUnits = { local function CreateAuraFrame(parent) local aura = CreateFrame("Frame", nil, parent, BackdropTemplateMixin and "BackdropTemplate"); - aura:SetSize(cfg.auraSize*ppScale, cfg.auraSize*ppScale); + aura:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); aura.count = aura:CreateFontString(nil,"OVERLAY"); aura.count:SetPoint("BOTTOMRIGHT",1,0); @@ -43,7 +43,7 @@ local function CreateAuraFrame(parent) aura.cooldown.noCooldownCount = cfg.noCooldownCount or nil; aura.border = CreateFrame("Frame", nil, aura, BackdropTemplateMixin and "BackdropTemplate"); - aura.border:SetSize(cfg.auraSize*ppScale, cfg.auraSize*ppScale); + aura.border:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); aura.border:SetPoint("CENTER", aura, "CENTER"); aura.border:SetBackdrop(aura:GetParent().backdropInfo); aura.border:SetBackdropColor(0, 0, 0, 0); @@ -56,8 +56,9 @@ end -- querires auras of the specific auraType, and sets up the aura frame and anchors it in the desired place function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) -- want them to be flush with the tooltips borders, means we subtract 1 offset since the very last one doesn't need to be there - local aurasPerRow = floor((tip:GetWidth() - cfg.auraOffsetX*ppScale) / ((cfg.auraSize + cfg.auraOffsetX)*ppScale)); -- auras we can fit into one row based on the current size of the tooltip - local xOffsetBasis = (auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX) * ppScale; -- is +1 or -1 based on horz anchoring + -- aura icons don't scale because we need the exact width, hav to change the size manually in the options instead. + local aurasPerRow = floor((tip:GetWidth() - tt:GetNearestPixelSize(cfg.auraSize)) / (tt:GetNearestPixelSize(cfg.auraSize + cfg.auraOffsetX)*ppScale)); -- auras we can fit into one row based on the current size of the tooltip + local xOffsetBasis = tt:GetNearestPixelSize(auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX); -- is +1 or -1 based on horz anchoring local queryIndex = 1; -- aura query index for this auraType local auraFrameIndex = startingAuraFrameIndex; -- array index for the next aura frame, initialized to the starting index @@ -85,7 +86,7 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) if ((auraFrameIndex - 1) % aurasPerRow == 0) or (auraFrameIndex == startingAuraFrameIndex) then -- new aura line local x = 0; - local y = (cfg.auraSize*ppScale + 2) * floor((auraFrameIndex - 1) / aurasPerRow) + cfg.auraOffsetY*ppScale; + local y = (tt:GetNearestPixelSize(cfg.auraSize) + 2) * floor((auraFrameIndex - 1) / aurasPerRow) + tt:GetNearestPixelSize(cfg.auraOffsetY); y = (cfg.aurasAtBottom and -y or y); aura:SetPoint(anchor1,tip,anchor2,x,y); else @@ -166,9 +167,9 @@ function ttAuras:OnApplyConfig(cfg) local gameFont = GameFontNormal:GetFont(); for _, aura in ipairs(auras) do if (cfg.showBuffs or cfg.showDebuffs) then - aura:SetSize(cfg.auraSize*ppScale,cfg.auraSize*ppScale); - aura.border:SetSize(cfg.auraSize*ppScale,cfg.auraSize*ppScale); - aura.count:SetFont(gameFont,(cfg.auraSize*ppScale / 2),"OUTLINE"); + aura:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); + aura.border:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); + aura.count:SetFont(gameFont,(tt:GetNearestPixelSize(cfg.auraSize) / 2),"OUTLINE"); aura.cooldown.noCooldownCount = cfg.noCooldownCount; else aura:Hide(); diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index 5f6c389..3f0823e 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -574,8 +574,8 @@ end -------------------------------------------------------------------------------------------------------- -- Get nearest pixel size (e.g. to avoid 1-pixel borders, which are sometimes 2-pixels wide) -local function GetNearestPixelSize(size) - return size * ppScale; +function tt:GetNearestPixelSize(size) + return (size * ppScale) / cfg.gttScale; end -- Resolves the given table array of string names into their global objects @@ -653,11 +653,11 @@ function tt:ApplySettings() end tipBackdrop.tile = false; tipBackdrop.tileEdge = false; - tipBackdrop.edgeSize = GetNearestPixelSize(cfg.backdropEdgeSize); - tipBackdrop.insets.left = GetNearestPixelSize(cfg.backdropInsets); - tipBackdrop.insets.right = GetNearestPixelSize(cfg.backdropInsets); - tipBackdrop.insets.top = GetNearestPixelSize(cfg.backdropInsets); - tipBackdrop.insets.bottom = GetNearestPixelSize(cfg.backdropInsets); + tipBackdrop.edgeSize = tt:GetNearestPixelSize(cfg.backdropEdgeSize); + tipBackdrop.insets.left = tt:GetNearestPixelSize(cfg.backdropInsets); + tipBackdrop.insets.right = tt:GetNearestPixelSize(cfg.backdropInsets); + tipBackdrop.insets.top = tt:GetNearestPixelSize(cfg.backdropInsets); + tipBackdrop.insets.bottom = tt:GetNearestPixelSize(cfg.backdropInsets); tipBackdrop.backdropColor:SetRGBA(unpack(cfg.tipColor)); tipBackdrop.backdropBorderColor:SetRGBA(unpack(cfg.tipBorderColor)); @@ -917,7 +917,7 @@ end function tt:AnchorFrameToMouse(frame) local x, y = GetCursorPosition(); local effScale = frame:GetEffectiveScale(); - local offsetX, offsetY = cfg.mouseOffsetX * ppScale, cfg.mouseOffsetY * ppScale; + local offsetX, offsetY = tt:GetNearestPixelSize(cfg.mouseOffsetX), tt:GetNearestPixelSize(cfg.mouseOffsetY); frame:ClearAllPoints(); frame:SetPoint(frame.ttAnchorPoint,UIParent,"BOTTOMLEFT",(x / effScale + offsetX),(y / effScale + offsetY)); end diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index 26e19a7..4fa3917 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -166,6 +166,10 @@ local COLOR_INCOMPLETE = { 0.5, 0.5, 0.5 }; -- Colored text string (red/green) local BoolCol = { [false] = "|cffff8080", [true] = "|cff80ff80" }; +local function GetNearestPixelSize(size) + return (size * ppScale) / cfg.gttScale; +end + -------------------------------------------------------------------------------------------------------- -- Create Tooltip Icon -- -------------------------------------------------------------------------------------------------------- @@ -195,14 +199,11 @@ end -- Create Icon with Counter Text for Tooltip function ttif:CreateTooltipIcon(tip) tip.ttIcon = tip:CreateTexture(nil, "BACKGROUND"); - tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, cfg.if_iconOffsetX * ppScale, cfg.if_iconOffsetY * ppScale); - tip.ttIcon:SetScale(tip:GetScale()); + tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); tip.ttIcon:Hide(); tip.ttIcon.border = CreateFrame("Frame", nil, tip, BackdropTemplateMixin and "BackdropTemplate"); tip.ttIcon.border:SetPoint("BOTTOMLEFT", tip.ttIcon, "BOTTOMLEFT"); - tip.ttIcon.border:SetScale(tip:GetScale()); - --tip.ttIcon.border:Hide(); tip.ttCount = tip:CreateFontString(nil, "ARTWORK"); tip.ttCount:SetTextColor(1, 1, 1); @@ -290,7 +291,7 @@ function ttif:OnApplyConfig() tip.ttIcon:SetTexCoord(0, 1, 0, 1); end tip.ttIcon:ClearAllPoints(); - tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, cfg.if_iconOffsetX * ppScale, cfg.if_iconOffsetY * ppScale); + tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); elseif (tip.ttSetIconTextureAndText) then tip.ttIcon:Hide(); tip.ttSetIconTextureAndText = nil; From a276986fdde0a9290fe39806ac4b3ea2feae28a5 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Mon, 7 Feb 2022 05:36:19 +0100 Subject: [PATCH 08/31] itemicon should be above the comparing tooltip --- TipTacItemRef/ttItemRef.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index 4fa3917..8fc6644 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -198,7 +198,7 @@ end -- Create Icon with Counter Text for Tooltip function ttif:CreateTooltipIcon(tip) - tip.ttIcon = tip:CreateTexture(nil, "BACKGROUND"); + tip.ttIcon = tip:CreateTexture(nil, "ARTWORK"); tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); tip.ttIcon:Hide(); From 3cdb83d24af5a6b8d3713b1f4d95f394c5fc10f3 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Tue, 8 Feb 2022 05:14:33 +0100 Subject: [PATCH 09/31] made applicable without /reload, fixed calc error --- TipTac/ttAuras.lua | 57 +++++++++++++++++++++++-------------- TipTac/ttCore.lua | 1 + TipTacOptions/ttOptions.lua | 7 +---- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 27bbd5e..bdcbfb7 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -25,17 +25,13 @@ local validSelfCasterUnits = { -------------------------------------------------------------------------------------------------------- local function CreateAuraFrame(parent) - local aura = CreateFrame("Frame", nil, parent, BackdropTemplateMixin and "BackdropTemplate"); + local aura = CreateFrame("Frame", nil, parent); aura:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); aura.count = aura:CreateFontString(nil,"OVERLAY"); aura.count:SetPoint("BOTTOMRIGHT",1,0); aura.count:SetFont(GameFontNormal:GetFont(),(cfg.auraSize / 2),"OUTLINE"); - aura.icon = aura:CreateTexture(nil,"BACKGROUND"); - aura.icon:SetAllPoints(); - aura.icon:SetTexCoord(0.07,0.93,0.07,0.93); - aura.cooldown = CreateFrame("Cooldown",nil,aura,"CooldownFrameTemplate"); aura.cooldown:SetReverse(1); aura.cooldown:SetAllPoints(); @@ -43,21 +39,32 @@ local function CreateAuraFrame(parent) aura.cooldown.noCooldownCount = cfg.noCooldownCount or nil; aura.border = CreateFrame("Frame", nil, aura, BackdropTemplateMixin and "BackdropTemplate"); - aura.border:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); - aura.border:SetPoint("CENTER", aura, "CENTER"); + --aura.border:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); + aura.border:SetAllPoints(); aura.border:SetBackdrop(aura:GetParent().backdropInfo); aura.border:SetBackdropColor(0, 0, 0, 0); aura.border:SetFrameLevel(aura.cooldown:GetFrameLevel()+1); + aura.icon = aura:CreateTexture(nil,"BACKGROUND"); + aura.icon:SetPoint("CENTER",aura,"CENTER"); + aura.icon:SetTexCoord(0.07,0.93,0.07,0.93); + ttAuras:ApplyInsetsToIconTexture(aura.icon, aura:GetParent().backdropInfo); + auras[#auras + 1] = aura; return aura; end +function ttAuras:ApplyInsetsToIconTexture(texture, backdropInfo) + -- manually implementing border insets because otherwise we cant remove the ugly default border + -- assumes symmetrical insets + texture:SetSize(tt:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.left * 2, tt:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.top * 2); +end + -- querires auras of the specific auraType, and sets up the aura frame and anchors it in the desired place function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) -- want them to be flush with the tooltips borders, means we subtract 1 offset since the very last one doesn't need to be there - -- aura icons don't scale because we need the exact width, hav to change the size manually in the options instead. - local aurasPerRow = floor((tip:GetWidth() - tt:GetNearestPixelSize(cfg.auraSize)) / (tt:GetNearestPixelSize(cfg.auraSize + cfg.auraOffsetX)*ppScale)); -- auras we can fit into one row based on the current size of the tooltip + -- aura icons don't scale because we need the exact width, have to change the size manually in the options instead. + local aurasPerRow = floor((tip:GetWidth() - tt:GetNearestPixelSize(cfg.auraOffsetX)) / tt:GetNearestPixelSize(cfg.auraSize + cfg.auraOffsetX)); -- auras we can fit into one row based on the current size of the tooltip local xOffsetBasis = tt:GetNearestPixelSize(auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX); -- is +1 or -1 based on horz anchoring local queryIndex = 1; -- aura query index for this auraType @@ -86,12 +93,12 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) if ((auraFrameIndex - 1) % aurasPerRow == 0) or (auraFrameIndex == startingAuraFrameIndex) then -- new aura line local x = 0; - local y = (tt:GetNearestPixelSize(cfg.auraSize) + 2) * floor((auraFrameIndex - 1) / aurasPerRow) + tt:GetNearestPixelSize(cfg.auraOffsetY); + local y = (cfg.auraSize + cfg.auraOffsetY) * floor((auraFrameIndex - 1) / aurasPerRow) + cfg.auraOffsetY; y = (cfg.aurasAtBottom and -y or y); - aura:SetPoint(anchor1,tip,anchor2,x,y); + aura:SetPoint(anchor1, tip, anchor2, x, tt:GetNearestPixelSize(y)); else -- anchor to last - aura:SetPoint(horzAnchor1, auras[auraFrameIndex - 1], horzAnchor2, (xOffsetBasis), 0); + aura:SetPoint(horzAnchor1, auras[auraFrameIndex - 1], horzAnchor2, xOffsetBasis, 0); end -- Cooldown @@ -105,24 +112,28 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) aura.icon:SetTexture(iconTexture); aura.count:SetText(count and count > 1 and count or ""); - -- Border -- Only shown for debuffs + -- Border if (cfg.auraCustomBorder) then if (cfg.auraBorderUseParentColor) then aura.border:SetBackdropBorderColor(tip:GetBackdropBorderColor()); else if (auraType == "HARMFUL") then - aura.border:SetBackdropBorderColor(unpack(cfg.auraBorderDebuffColor)); + if (cfg.auraBorderUseDebuffTypeColors) then + local color = DebuffTypeColor[debuffType] or DebuffTypeColor["none"]; + aura.border:SetBackdropBorderColor(color.r, color.g, color.b); + else + aura.border:SetBackdropBorderColor(unpack(cfg.auraBorderDebuffColor)); + end else aura.border:SetBackdropBorderColor(unpack(cfg.auraBorderBuffColor)); end end aura.border:Show(); else + -- old way (only debuffs) if (auraType == "HARMFUL") then local color = DebuffTypeColor[debuffType] or DebuffTypeColor["none"]; - aura.border:SetBackdropBorderColor(unpack(cfg.auraBorderDebuffColor)); - else - aura.border:Hide(); + aura.border:SetBackdropBorderColor(color.r, color.g, color.b); end end @@ -141,12 +152,12 @@ end function ttAuras:SetupAuras(tip) --printf("[%.2f] %-24s %d x %d",GetTime(),"SetupAuras",tip:GetWidth(),tip:GetHeight()) local auraCount = 0; - if (cfg.showBuffs) then - auraCount = auraCount + self:DisplayAuras(tip,"HELPFUL",auraCount + 1); - end if (cfg.showDebuffs) then auraCount = auraCount + self:DisplayAuras(tip,"HARMFUL",auraCount + 1); end + if (cfg.showBuffs) then + auraCount = auraCount + self:DisplayAuras(tip,"HELPFUL",auraCount + 1); + end -- Hide the Unused for i = (auraCount + 1), #auras do @@ -168,7 +179,11 @@ function ttAuras:OnApplyConfig(cfg) for _, aura in ipairs(auras) do if (cfg.showBuffs or cfg.showDebuffs) then aura:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); - aura.border:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); + aura.border:SetBackdrop(nil); + aura.border:SetBackdrop(aura:GetParent().backdropInfo); + aura.border:SetBackdropColor(0, 0, 0, 0); + aura.border:SetAllPoints(); + ttAuras:ApplyInsetsToIconTexture(aura.icon, aura:GetParent().backdropInfo); aura.count:SetFont(gameFont,(tt:GetNearestPixelSize(cfg.auraSize) / 2),"OUTLINE"); aura.cooldown.noCooldownCount = cfg.noCooldownCount; else diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index 3f0823e..77a2fd4 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -152,6 +152,7 @@ local TT_DefaultConfig = { auraBorderDebuffColor = { 1, 0, 0 }, auraOffsetX = 2, auraOffsetY = 2, + auraBorderUseDebuffTypeColors = true, iconRaid = true, iconFaction = false, diff --git a/TipTacOptions/ttOptions.lua b/TipTacOptions/ttOptions.lua index f632263..3859381 100644 --- a/TipTacOptions/ttOptions.lua +++ b/TipTacOptions/ttOptions.lua @@ -181,20 +181,15 @@ local options = { { type = "Check", var = "selfAurasOnly", label = "Only Show Auras Coming from You", tip = "This will filter out and only display auras you cast yourself", y = 12 }, { type = "Slider", var = "auraSize", label = "Aura Icon Dimension", min = 8, max = 60, step = 1, y = 12 }, { type = "Slider", var = "auraMaxRows", label = "Max Aura Rows", min = 1, max = 8, step = 1 }, - { type = "Slider", var = "auraOffsetX", label = "X offset between aura icons", min = 0, max = 20, step = 1 }, { type = "Slider", var = "auraOffsetY", label = "Y offset between aura rows", min = 0, max = 20, step = 1 }, - - { type = "Check", var = "showAuraCooldown", label = "Show Cooldown Models", tip = "With this option on, you will see a visual progress of the time left on the buff", y = 8 }, { type = "Check", var = "noCooldownCount", label = "No Cooldown Count Text", tip = "Tells cooldown enhancement addons, such as OmniCC, not to display cooldown text" }, - { type = "Check", var = "auraCustomBorder", label = "Custom aura icon border", tip = "Use a custom aura icon border" }, { type = "Check", var = "auraBorderUseParentColor", label = "Copy border color of tooltip", tip = "Copies the bordercolor of the tooltip for the aura icons" }, { type = "Color", var = "auraBorderBuffColor", label = "Custom buff border color" }, { type = "Color", var = "auraBorderDebuffColor", label = "Custom debuff border color" }, - - + { type = "Check", var = "auraBorderUseDebuffTypeColors", label = "Use blizz DEBUFF type color instead", tip = "Uses the default blizzard DEBUFF type colors instead (curse/poison/magic/disease" }, }, -- Icon { From 58bf6bbdb92e7b23958ed272cdb1ee0689aba95f Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Tue, 8 Feb 2022 05:17:59 +0100 Subject: [PATCH 10/31] made applicable without /reload --- TipTacItemRef/ttItemRef.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index 8fc6644..dde432f 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -212,6 +212,7 @@ end function ttif:ApplyBorderToTooltipIcon(tip) if (cfg.if_copyParentBorder) then + tip.ttIcon.border:SetBackdrop(nil); tip.ttIcon.border:SetBackdrop(tip.backdropInfo); tip.ttIcon.border:SetBackdropColor(0, 0, 0, 0); tip.ttIcon.border:SetBackdropBorderColor(tip:GetBackdropBorderColor()); From 703faa0ebc05b5c04337c74e5cc194d7dbf274ec Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Tue, 8 Feb 2022 05:23:48 +0100 Subject: [PATCH 11/31] small bug --- TipTac/ttAuras.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index bdcbfb7..ee6d74e 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -134,6 +134,8 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) if (auraType == "HARMFUL") then local color = DebuffTypeColor[debuffType] or DebuffTypeColor["none"]; aura.border:SetBackdropBorderColor(color.r, color.g, color.b); + else + aura.border:Hide(); end end From a10f5b4aa904f0cfaa365448072483b344394b00 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Wed, 9 Feb 2022 02:53:45 +0100 Subject: [PATCH 12/31] item compare now takes itemicons into account --- TipTac/ttCore.lua | 30 ++++++++++++++++++++++++++++-- TipTacOptions/ttOptions.lua | 4 ++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index 77a2fd4..e1a8490 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -239,8 +239,8 @@ local TT_DefaultConfig = { if_iconSize = 42, if_iconAnchor = "BOTTOMLEFT", if_iconTooltipAnchor = "TOPLEFT", - if_iconOffsetX = 2.5, - if_iconOffsetY = -2.5, + if_iconOffsetX = 0, + if_iconOffsetY = 0, if_copyParentBorder = false, }; @@ -944,6 +944,31 @@ function tt:ReApplyAnchorTypeForMouse(frame, noUpdateAnchorPosition, ignoreWorld end end +-- anchors the comparing items tooltip with an appropriate offset to account for the item icon +function tt:anchorShoppingTooltips(frame) + if (frame:GetName() == "ShoppingTooltip1" or frame:GetName() == "ShoppingTooltip2") then + -- calculate offset if the icon is to the left or right of the tooltip + local iconDistance = 0; + if (cfg.if_showIcon) then + local leftDistance = gtt:GetLeft() - gtt.ttIcon:GetLeft(); + local rightDistance = gtt.ttIcon:GetRight() - gtt:GetRight(); + if (leftDistance > 0) then + iconDistance = leftDistance; + elseif (rightDistance > 0) then + iconDistance = rightDistance + end + end + + local anchor, aFrame, anchorTo, x, y = frame:GetPoint(); + local gapOffset = tt:GetNearestPixelSize(5); + local toTheLeft = (anchor == "TOPRIGHT"); + local xOffset = (toTheLeft and -(gapOffset + iconDistance) or (gapOffset + iconDistance)); + + frame:ClearAllPoints(); + frame:SetPoint(anchor, aFrame, anchorTo, xOffset, 0); + end +end + -- Removes lines from the tooltip which are unwanted, such as "PvP", "Alliance", "Horde" -- Also removes the coalesced realm line(s), which I am unsure is still in BfA? function tt:RemoveUnwantedLines(tip) @@ -1297,6 +1322,7 @@ end -- EventHook: OnTooltipSetItem function gttScriptHooks:OnTooltipSetItem() tt:ReApplyAnchorTypeForMouse(self); + tt:anchorShoppingTooltips(self, "ontooltipsetitem"); end -- OnHide Script -- Used to default the background and border color -- Az: May cause issues with embedded tooltips, see GameTooltip.lua:396 diff --git a/TipTacOptions/ttOptions.lua b/TipTacOptions/ttOptions.lua index 3859381..91c7028 100644 --- a/TipTacOptions/ttOptions.lua +++ b/TipTacOptions/ttOptions.lua @@ -328,8 +328,8 @@ if (TipTacItemRef) then { type = "Slider", var = "if_iconSize", label = "Icon Size", min = 16, max = 128, step = 1 }, { type = "DropDown", var = "if_iconAnchor", label = "Icon Anchor", tip = "The anchor of the icon", list = DROPDOWN_ANCHORPOS }, { type = "DropDown", var = "if_iconTooltipAnchor", label = "Icon Tooltip Anchor", tip = "The anchor of the tooltip that the icon should anchor to.", list = DROPDOWN_ANCHORPOS }, - { type = "Slider", var = "if_iconOffsetX", label = "Icon X Offset", min = -200, max = 200, step = 0.5 }, - { type = "Slider", var = "if_iconOffsetY", label = "Icon Y Offset", min = -200, max = 200, step = 0.5 }, + { type = "Slider", var = "if_iconOffsetX", label = "Icon X Offset", min = -200, max = 200, step = 1 }, -- only whole numbers or we get jitters + { type = "Slider", var = "if_iconOffsetY", label = "Icon Y Offset", min = -200, max = 200, step = 1 }, -- only whole numbers or we get jitters }; end From 88737caedc1ae5f31dda32f0c418c1bc75723859 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Wed, 9 Feb 2022 08:18:53 +0100 Subject: [PATCH 13/31] fixed retail and added SmartIcon support for comparing items --- TipTac/ttCore.lua | 69 ++++++++++++++++++++++++++++++++----- TipTacItemRef/ttItemRef.lua | 10 ++++++ 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index e1a8490..4e72b20 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -947,21 +947,72 @@ end -- anchors the comparing items tooltip with an appropriate offset to account for the item icon function tt:anchorShoppingTooltips(frame) if (frame:GetName() == "ShoppingTooltip1" or frame:GetName() == "ShoppingTooltip2") then - -- calculate offset if the icon is to the left or right of the tooltip + + -- retail has 2 points instead of 1 in tbcc, that anchor a bit differently, here we only set the relevant point + if (isWoWRetail) then + if (frame:GetNumPoints() == 0) then + return; + end + + for n = 1, frame:GetNumPoints() do + local point, anchor, anchoredTo, x, y = frame:GetPoint(n); + if (point == "LEFT" or point == "RIGHT" or point == "TOPLEFT" or point == "TOPRIGHT") then + -- this is the point we want + -- remove y offset by changing the anchor + if (point == "LEFT") then + point = "TOPLEFT"; + anchoredTo = "TOPRIGHT"; + elseif (point == "RIGHT") then + point = "TOPRIGHT"; + anchoredTo = "TOPLEFT"; + end + frame:ClearAllPoints() + frame:SetPoint(point, anchor, anchoredTo, x, y); + break; + end + end + end + + local anchor, aFrame, anchorTo, x, y = frame:GetPoint(); + local gapOffset = tt:GetNearestPixelSize(5); + local toTheLeft = (anchor == "TOPRIGHT"); + local iconDistance = 0; - if (cfg.if_showIcon) then - local leftDistance = gtt:GetLeft() - gtt.ttIcon:GetLeft(); - local rightDistance = gtt.ttIcon:GetRight() - gtt:GetRight(); + local leftIcon = false; + local rightIcon = false; + + -- calculate offset if the icon is to the left or right of the tooltip + if (cfg.if_showIcon and (gtt.ttIcon ~= nil)) then + local leftDistance = frame:GetLeft() - frame.ttIcon:GetLeft(); + local rightDistance = frame.ttIcon:GetRight() - frame:GetRight(); if (leftDistance > 0) then + leftIcon = true; iconDistance = leftDistance; elseif (rightDistance > 0) then - iconDistance = rightDistance + rightIcon = true; + iconDistance = rightDistance; end end - local anchor, aFrame, anchorTo, x, y = frame:GetPoint(); - local gapOffset = tt:GetNearestPixelSize(5); - local toTheLeft = (anchor == "TOPRIGHT"); + -- check if icon is hidden because of "Smart Icon Appearance" + -- this doesn't work because this happens before ttitemref had a chance to update gtt + --if (not gtt.ttIcon:IsShown()) then + -- calling directly into ttitemref instead + local iconShown = (TipTacItemRef and cfg.if_showIcon); + local _, link = gtt:GetItem(); + if (link and TipTacItemRef and cfg.if_smartIcons) then + local linkType, id = link:match("H?(%a+):(%d+)"); + iconShown = TipTacItemRef:SmartIconEvaluation(gtt, linkType); + end + if (not iconShown) then + -- if it is, set the iconDistance to 0 for the first tooltip + if ((frame:GetName() == "ShoppingTooltip1" and toTheLeft and leftIcon) or + (frame:GetName() == "ShoppingTooltip2" and not toTheLeft and rightIcon) or + (frame:GetName() == "ShoppingTooltip1" and not toTheLeft and rightIcon and not stt2:IsShown())) then + iconDistance = 0; + end + end + local xOffset = (toTheLeft and -(gapOffset + iconDistance) or (gapOffset + iconDistance)); frame:ClearAllPoints(); @@ -1322,7 +1373,7 @@ end -- EventHook: OnTooltipSetItem function gttScriptHooks:OnTooltipSetItem() tt:ReApplyAnchorTypeForMouse(self); - tt:anchorShoppingTooltips(self, "ontooltipsetitem"); + tt:anchorShoppingTooltips(self); end -- OnHide Script -- Used to default the background and border color -- Az: May cause issues with embedded tooltips, see GameTooltip.lua:396 diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index dde432f..a50f61e 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -189,6 +189,8 @@ local function ttSetIconTextureAndText(self, texture, count) self.ttIcon.border:Show(); end self.ttIcon:Show(); + self.ttCount:Show(); + self.ttCount.border:Show(); else self.ttIcon.border:Hide(); self.ttIcon:Hide(); @@ -293,6 +295,10 @@ function ttif:OnApplyConfig() end tip.ttIcon:ClearAllPoints(); tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); + tip.ttIcon:Hide(); + tip.ttIcon.border:Hide(); + tip.ttCount:Hide(); + tip.ttCount:SetText(""); elseif (tip.ttSetIconTextureAndText) then tip.ttIcon:Hide(); tip.ttSetIconTextureAndText = nil; @@ -1743,6 +1749,10 @@ local function SmartIconEvaluation(tip,linkType) return true; end +function ttif:SmartIconEvaluation(tip,linkType) + return SmartIconEvaluation(tip, linkType); +end + -------------------------------------------------------------------------------------------------------- -- Tip LinkType Functions -- -------------------------------------------------------------------------------------------------------- From 55608babd15e3152093248e57631a49e0951a977 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Wed, 9 Feb 2022 09:05:38 +0100 Subject: [PATCH 14/31] typo --- TipTacItemRef/ttItemRef.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index a50f61e..c897d3d 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -190,7 +190,7 @@ local function ttSetIconTextureAndText(self, texture, count) end self.ttIcon:Show(); self.ttCount:Show(); - self.ttCount.border:Show(); + self.ttIcon.border:Show(); else self.ttIcon.border:Hide(); self.ttIcon:Hide(); From 5cf6599c95f97cfd3e64236f2ea9efe126cdc193 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Wed, 9 Feb 2022 10:56:46 +0100 Subject: [PATCH 15/31] tooltip icon is now also clamped to the screen --- TipTacItemRef/ttItemRef.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index c897d3d..b89acec 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -196,6 +196,8 @@ local function ttSetIconTextureAndText(self, texture, count) self.ttIcon:Hide(); self.ttCount:SetText(""); end + + ttif:SetClamp(self); end -- Create Icon with Counter Text for Tooltip @@ -212,6 +214,35 @@ function ttif:CreateTooltipIcon(tip) tip.ttCount:SetPoint("BOTTOMRIGHT", tip.ttIcon, "BOTTOMRIGHT", -3, 3); end +function ttif:SetClamp(tip) + local basicOffset = GetNearestPixelSize(6); + local leftOffset = -basicOffset; + local rightOffset = basicOffset; + local topOffset = basicOffset; + local bottomOffset = -basicOffset; + if(tip.ttIcon:IsShown() and tip.ttIcon:GetLeft() ~= nil) then + local leftDistance = tip:GetLeft() - tip.ttIcon:GetLeft(); + local rightDistance = tip.ttIcon:GetRight() - tip:GetRight(); + local topDistance = tip.ttIcon:GetTop() - tip:GetTop(); + local bottomDistance = tip:GetBottom() - tip.ttIcon:GetBottom(); + if (leftDistance > 0) then + leftOffset = leftOffset - leftDistance; + end + if (rightDistance > 0) then + rightOffset = rightOffset + rightDistance; + end + if (topDistance > 0) then + topOffset = topOffset + topDistance; + end + if (bottomDistance > 0) then + bottomOffset = bottomOffset - bottomDistance; + end + end + + tip:SetClampedToScreen(true); + tip:SetClampRectInsets(leftOffset, rightOffset, topOffset, bottomOffset); +end + function ttif:ApplyBorderToTooltipIcon(tip) if (cfg.if_copyParentBorder) then tip.ttIcon.border:SetBackdrop(nil); From f1457fb3db4691aa34d362b9f1c4aaca65974a58 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Wed, 9 Feb 2022 11:23:03 +0100 Subject: [PATCH 16/31] set insets on item icon, some applyconfig stuff --- TipTacItemRef/ttItemRef.lua | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index b89acec..a090226 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -203,17 +203,24 @@ end -- Create Icon with Counter Text for Tooltip function ttif:CreateTooltipIcon(tip) tip.ttIcon = tip:CreateTexture(nil, "ARTWORK"); - tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); - tip.ttIcon:Hide(); - + tip.ttIcon.border = CreateFrame("Frame", nil, tip, BackdropTemplateMixin and "BackdropTemplate"); - tip.ttIcon.border:SetPoint("BOTTOMLEFT", tip.ttIcon, "BOTTOMLEFT"); + tip.ttIcon.border:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); + + tip.ttIcon:SetPoint("CENTER", tip.ttIcon.border, "CENTER"); + tip.ttIcon:Hide(); tip.ttCount = tip:CreateFontString(nil, "ARTWORK"); tip.ttCount:SetTextColor(1, 1, 1); tip.ttCount:SetPoint("BOTTOMRIGHT", tip.ttIcon, "BOTTOMRIGHT", -3, 3); end +function ttif:ApplyInsetsToIconTexture(texture, backdropInfo) + -- manually implementing border insets because otherwise we cant remove the ugly default border + -- assumes symmetrical insets + texture:SetSize(cfg.if_iconSize - backdropInfo.insets.left * 2, cfg.if_iconSize - backdropInfo.insets.top * 2); +end + function ttif:SetClamp(tip) local basicOffset = GetNearestPixelSize(6); local leftOffset = -basicOffset; @@ -249,6 +256,8 @@ function ttif:ApplyBorderToTooltipIcon(tip) tip.ttIcon.border:SetBackdrop(tip.backdropInfo); tip.ttIcon.border:SetBackdropColor(0, 0, 0, 0); tip.ttIcon.border:SetBackdropBorderColor(tip:GetBackdropBorderColor()); + + ttif:ApplyInsetsToIconTexture(tip.ttIcon, tip.backdropInfo); end end @@ -315,21 +324,25 @@ function ttif:OnApplyConfig() for index, tip in ipairs(tipsToModify) do if (type(tip) == "table") and (tipsToAddIcon[tip:GetName()]) and (tip.ttIcon) then if (cfg.if_showIcon) then + tip.ttIcon.border:SetBackdrop(nil); + ttif:ApplyBorderToTooltipIcon(tip); tip.ttIcon.border:SetSize(cfg.if_iconSize, cfg.if_iconSize); tip.ttIcon:SetSize(cfg.if_iconSize, cfg.if_iconSize); tip.ttCount:SetFont(gameFont, (cfg.if_iconSize / 3), "OUTLINE"); tip.ttSetIconTextureAndText = ttSetIconTextureAndText; - if (cfg.if_borderlessIcons or cfg.if_copyParentBorder) then - tip.ttIcon:SetTexCoord(0.07, 0.93, 0.07, 0.93); - else - tip.ttIcon:SetTexCoord(0, 1, 0, 1); - end tip.ttIcon:ClearAllPoints(); - tip.ttIcon:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); + tip.ttIcon.border:ClearAllPoints(); + tip.ttIcon.border:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); + tip.ttIcon:SetPoint("CENTER", tip.ttIcon.border, "CENTER"); tip.ttIcon:Hide(); tip.ttIcon.border:Hide(); tip.ttCount:Hide(); tip.ttCount:SetText(""); + if (cfg.if_borderlessIcons or cfg.if_copyParentBorder) then + tip.ttIcon:SetTexCoord(0.07, 0.93, 0.07, 0.93); + else + tip.ttIcon:SetTexCoord(0, 1, 0, 1); + end elseif (tip.ttSetIconTextureAndText) then tip.ttIcon:Hide(); tip.ttSetIconTextureAndText = nil; From 65dc8ed8aadbdffa5ba15c4e60dfb766535fae04 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Wed, 9 Feb 2022 11:44:24 +0100 Subject: [PATCH 17/31] fixed rare error --- TipTac/ttCore.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index 4e72b20..d30e873 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -982,7 +982,7 @@ function tt:anchorShoppingTooltips(frame) local rightIcon = false; -- calculate offset if the icon is to the left or right of the tooltip - if (cfg.if_showIcon and (gtt.ttIcon ~= nil)) then + if (cfg.if_showIcon and (gtt.ttIcon ~= nil) and (frame:GetLeft() ~= nil)) then local leftDistance = frame:GetLeft() - frame.ttIcon:GetLeft(); local rightDistance = frame.ttIcon:GetRight() - frame:GetRight(); if (leftDistance > 0) then From 75cef6e5a60a05009eafa0d69f2a0147dfe81e29 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Wed, 9 Feb 2022 11:46:25 +0100 Subject: [PATCH 18/31] actually fixed the rare error --- TipTac/ttCore.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index d30e873..4042a5a 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -950,10 +950,6 @@ function tt:anchorShoppingTooltips(frame) -- retail has 2 points instead of 1 in tbcc, that anchor a bit differently, here we only set the relevant point if (isWoWRetail) then - if (frame:GetNumPoints() == 0) then - return; - end - for n = 1, frame:GetNumPoints() do local point, anchor, anchoredTo, x, y = frame:GetPoint(n); if (point == "LEFT" or point == "RIGHT" or point == "TOPLEFT" or point == "TOPRIGHT") then @@ -973,6 +969,10 @@ function tt:anchorShoppingTooltips(frame) end end + if (frame:GetNumPoints() == 0) then + return; + end + local anchor, aFrame, anchorTo, x, y = frame:GetPoint(); local gapOffset = tt:GetNearestPixelSize(5); local toTheLeft = (anchor == "TOPRIGHT"); @@ -982,7 +982,7 @@ function tt:anchorShoppingTooltips(frame) local rightIcon = false; -- calculate offset if the icon is to the left or right of the tooltip - if (cfg.if_showIcon and (gtt.ttIcon ~= nil) and (frame:GetLeft() ~= nil)) then + if (cfg.if_showIcon and (gtt.ttIcon ~= nil)) then local leftDistance = frame:GetLeft() - frame.ttIcon:GetLeft(); local rightDistance = frame.ttIcon:GetRight() - frame:GetRight(); if (leftDistance > 0) then From c272c50d1ce564abc868c7b3606762601d0a9ac7 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Wed, 9 Feb 2022 12:21:16 +0100 Subject: [PATCH 19/31] actually actually fixed the rare error --- TipTac/ttCore.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index 4042a5a..bfe3344 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -982,7 +982,7 @@ function tt:anchorShoppingTooltips(frame) local rightIcon = false; -- calculate offset if the icon is to the left or right of the tooltip - if (cfg.if_showIcon and (gtt.ttIcon ~= nil)) then + if (cfg.if_showIcon and (gtt.ttIcon ~= nil) and (frame.ttIcon:GetLeft() ~= nil)) then local leftDistance = frame:GetLeft() - frame.ttIcon:GetLeft(); local rightDistance = frame.ttIcon:GetRight() - frame:GetRight(); if (leftDistance > 0) then From 5ad859db99b49013897cecf1ada88d5634de0cfd Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Thu, 10 Feb 2022 09:19:45 +0100 Subject: [PATCH 20/31] apply insets to the cooldown texture aswell --- TipTac/ttAuras.lua | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index ee6d74e..653427c 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -32,23 +32,28 @@ local function CreateAuraFrame(parent) aura.count:SetPoint("BOTTOMRIGHT",1,0); aura.count:SetFont(GameFontNormal:GetFont(),(cfg.auraSize / 2),"OUTLINE"); - aura.cooldown = CreateFrame("Cooldown",nil,aura,"CooldownFrameTemplate"); - aura.cooldown:SetReverse(1); - aura.cooldown:SetAllPoints(); - aura.cooldown:SetFrameLevel(aura:GetFrameLevel()); - aura.cooldown.noCooldownCount = cfg.noCooldownCount or nil; + aura.icon = CreateFrame("Frame", nil, aura); + aura.icon:SetPoint("CENTER",aura,"CENTER"); + aura.icon:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); + + aura.icon.texture = aura:CreateTexture(nil,"BACKGROUND"); + aura.icon.texture:SetPoint("CENTER",aura.icon,"CENTER"); + aura.icon.texture:SetTexCoord(0.07,0.93,0.07,0.93); + ttAuras:ApplyInsetsToIconTexture(aura.icon.texture, aura:GetParent().backdropInfo); + + aura.icon.cooldown = CreateFrame("Cooldown",nil,aura.icon,"CooldownFrameTemplate"); + aura.icon.cooldown:SetReverse(1); + aura.icon.cooldown:SetPoint("CENTER",aura.icon,"CENTER"); + aura.icon.cooldown:SetFrameLevel(aura:GetFrameLevel()); + aura.icon.cooldown.noCooldownCount = cfg.noCooldownCount or nil; + + ttAuras:ApplyInsetsToIconTexture(aura.icon, aura:GetParent().backdropInfo); aura.border = CreateFrame("Frame", nil, aura, BackdropTemplateMixin and "BackdropTemplate"); - --aura.border:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); aura.border:SetAllPoints(); aura.border:SetBackdrop(aura:GetParent().backdropInfo); aura.border:SetBackdropColor(0, 0, 0, 0); - aura.border:SetFrameLevel(aura.cooldown:GetFrameLevel()+1); - - aura.icon = aura:CreateTexture(nil,"BACKGROUND"); - aura.icon:SetPoint("CENTER",aura,"CENTER"); - aura.icon:SetTexCoord(0.07,0.93,0.07,0.93); - ttAuras:ApplyInsetsToIconTexture(aura.icon, aura:GetParent().backdropInfo); + aura.border:SetFrameLevel(aura.icon.cooldown:GetFrameLevel()+1); auras[#auras + 1] = aura; return aura; @@ -103,13 +108,13 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) -- Cooldown if (cfg.showAuraCooldown) and (duration and duration > 0 and endTime and endTime > 0) then - aura.cooldown:SetCooldown(endTime - duration,duration); + aura.icon.cooldown:SetCooldown(endTime - duration,duration); else - aura.cooldown:Hide(); + aura.icon.cooldown:Hide(); end -- Set Texture + Count - aura.icon:SetTexture(iconTexture); + aura.icon.texture:SetTexture(iconTexture); aura.count:SetText(count and count > 1 and count or ""); -- Border @@ -186,8 +191,9 @@ function ttAuras:OnApplyConfig(cfg) aura.border:SetBackdropColor(0, 0, 0, 0); aura.border:SetAllPoints(); ttAuras:ApplyInsetsToIconTexture(aura.icon, aura:GetParent().backdropInfo); + ttAuras:ApplyInsetsToIconTexture(aura.icon.texture, aura:GetParent().backdropInfo); aura.count:SetFont(gameFont,(tt:GetNearestPixelSize(cfg.auraSize) / 2),"OUTLINE"); - aura.cooldown.noCooldownCount = cfg.noCooldownCount; + aura.icon.cooldown.noCooldownCount = cfg.noCooldownCount; else aura:Hide(); end From f551e2a08b71b6cb8df9e23e40ffec8ccab98eaa Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Thu, 10 Feb 2022 22:43:51 +0100 Subject: [PATCH 21/31] typo --- TipTac/ttAuras.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 653427c..7586747 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -69,7 +69,7 @@ end function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) -- want them to be flush with the tooltips borders, means we subtract 1 offset since the very last one doesn't need to be there -- aura icons don't scale because we need the exact width, have to change the size manually in the options instead. - local aurasPerRow = floor((tip:GetWidth() - tt:GetNearestPixelSize(cfg.auraOffsetX)) / tt:GetNearestPixelSize(cfg.auraSize + cfg.auraOffsetX)); -- auras we can fit into one row based on the current size of the tooltip + local aurasPerRow = floor((tip:GetWidth() + tt:GetNearestPixelSize(cfg.auraOffsetX)) / tt:GetNearestPixelSize(cfg.auraSize + cfg.auraOffsetX)); -- auras we can fit into one row based on the current size of the tooltip local xOffsetBasis = tt:GetNearestPixelSize(auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX); -- is +1 or -1 based on horz anchoring local queryIndex = 1; -- aura query index for this auraType From 7a9c669c8e0e6aef308869f8603de42809ce0d3f Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Fri, 11 Feb 2022 13:08:09 +0100 Subject: [PATCH 22/31] aura icons are also clamped to the screen now --- TipTac/ttAuras.lua | 24 +++++++++++++++++++++++- TipTacItemRef/ttItemRef.lua | 26 ++++++++------------------ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 7586747..24ea50a 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -65,6 +65,26 @@ function ttAuras:ApplyInsetsToIconTexture(texture, backdropInfo) texture:SetSize(tt:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.left * 2, tt:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.top * 2); end +function ttAuras:SetClamp(tip, furthestAuraIcon) + local basicOffset = tt:GetNearestPixelSize(5); + local left, right, top, bottom = -basicOffset, basicOffset, basicOffset, -basicOffset; + + if(furthestAuraIcon ~= nil) then + local leftDistance = tip:GetLeft() - furthestAuraIcon:GetLeft(); + local rightDistance = furthestAuraIcon:GetRight() - tip:GetRight(); + local topDistance = furthestAuraIcon:GetTop() - tip:GetTop(); + local bottomDistance = tip:GetBottom() - furthestAuraIcon:GetBottom(); + + left = left + ((leftDistance > 0) and -leftDistance or 0); + right = right + ((rightDistance > 0) and rightDistance or 0); + top = top + ((topDistance > 0) and topDistance or 0); + bottom = bottom + ((bottomDistance > 0) and -bottomDistance or 0); + end + + tip:SetClampedToScreen(true); + tip:SetClampRectInsets(left, right, top, bottom); +end + -- querires auras of the specific auraType, and sets up the aura frame and anchors it in the desired place function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) -- want them to be flush with the tooltips borders, means we subtract 1 offset since the very last one doesn't need to be there @@ -151,8 +171,10 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) queryIndex = (queryIndex + 1); end + local aurasDisplayed = (auraFrameIndex - startingAuraFrameIndex); + ttAuras:SetClamp(tip, auras[aurasDisplayed]); -- last one should be the furthest out -- return the number of auras displayed - return (auraFrameIndex - startingAuraFrameIndex); + return aurasDisplayed; end -- display buffs and debuffs and hide unused aura frames diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index a090226..e1e622a 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -222,32 +222,22 @@ function ttif:ApplyInsetsToIconTexture(texture, backdropInfo) end function ttif:SetClamp(tip) - local basicOffset = GetNearestPixelSize(6); - local leftOffset = -basicOffset; - local rightOffset = basicOffset; - local topOffset = basicOffset; - local bottomOffset = -basicOffset; + local basicOffset = GetNearestPixelSize(5); + local left, right, top, bottom = -basicOffset, basicOffset, basicOffset, -basicOffset; if(tip.ttIcon:IsShown() and tip.ttIcon:GetLeft() ~= nil) then local leftDistance = tip:GetLeft() - tip.ttIcon:GetLeft(); local rightDistance = tip.ttIcon:GetRight() - tip:GetRight(); local topDistance = tip.ttIcon:GetTop() - tip:GetTop(); local bottomDistance = tip:GetBottom() - tip.ttIcon:GetBottom(); - if (leftDistance > 0) then - leftOffset = leftOffset - leftDistance; - end - if (rightDistance > 0) then - rightOffset = rightOffset + rightDistance; - end - if (topDistance > 0) then - topOffset = topOffset + topDistance; - end - if (bottomDistance > 0) then - bottomOffset = bottomOffset - bottomDistance; - end + + left = left + ((leftDistance > 0) and -leftDistance or 0); + right = right + ((rightDistance > 0) and rightDistance or 0); + top = top + ((topDistance > 0) and topDistance or 0); + bottom = bottom + ((bottomDistance > 0) and -bottomDistance or 0); end tip:SetClampedToScreen(true); - tip:SetClampRectInsets(leftOffset, rightOffset, topOffset, bottomOffset); + tip:SetClampRectInsets(left, right, top, bottom); end function ttif:ApplyBorderToTooltipIcon(tip) From fc809bcdb23c4b367d029d476e616d237abc7fe2 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Sat, 12 Feb 2022 11:55:11 +0100 Subject: [PATCH 23/31] small fix for auraicons clamping --- TipTac/ttAuras.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 24ea50a..61a31c4 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -171,10 +171,8 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) queryIndex = (queryIndex + 1); end - local aurasDisplayed = (auraFrameIndex - startingAuraFrameIndex); - ttAuras:SetClamp(tip, auras[aurasDisplayed]); -- last one should be the furthest out -- return the number of auras displayed - return aurasDisplayed; + return (auraFrameIndex - startingAuraFrameIndex); end -- display buffs and debuffs and hide unused aura frames @@ -188,6 +186,8 @@ function ttAuras:SetupAuras(tip) auraCount = auraCount + self:DisplayAuras(tip,"HELPFUL",auraCount + 1); end + ttAuras:SetClamp(tip, auras[auraCount]); -- last one should be the furthest out + -- Hide the Unused for i = (auraCount + 1), #auras do auras[i]:Hide(); From 7d4ff4afce9f090668bc33c60c438621e19d4209 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Fri, 18 Feb 2022 00:29:27 +0100 Subject: [PATCH 24/31] removed unnecessary pixelconversion on itemicon --- TipTac/ttAuras.lua | 5 ----- TipTac/ttCore.lua | 2 +- TipTacItemRef/ttItemRef.lua | 15 +++------------ 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 61a31c4..907b3bc 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -4,11 +4,6 @@ local gtt = GameTooltip; local tt = TipTac; local cfg; --- actual pixel perfect scale -local ui_scale = UIParent:GetEffectiveScale() -local height = select(2, GetPhysicalScreenSize()) -local ppScale = (768 / height) / ui_scale - -- element registration local ttAuras = tt:RegisterElement({ auras = {} },"Auras"); local auras = ttAuras.auras; diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index bfe3344..a9c27ad 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -576,7 +576,7 @@ end -- Get nearest pixel size (e.g. to avoid 1-pixel borders, which are sometimes 2-pixels wide) function tt:GetNearestPixelSize(size) - return (size * ppScale) / cfg.gttScale; + return PixelUtil.GetNearestPixelSize(size, UIParent:GetEffectiveScale()) / cfg.gttScale; end -- Resolves the given table array of string names into their global objects diff --git a/TipTacItemRef/ttItemRef.lua b/TipTacItemRef/ttItemRef.lua index e1e622a..3c51d17 100644 --- a/TipTacItemRef/ttItemRef.lua +++ b/TipTacItemRef/ttItemRef.lua @@ -40,11 +40,6 @@ end local modName = ...; local ttif = CreateFrame("Frame", modName); --- actual pixel perfect scale -local ui_scale = UIParent:GetEffectiveScale() -local height = select(2, GetPhysicalScreenSize()) -local ppScale = (768 / height) / ui_scale - -- Register with TipTac core addon if available if (TipTac) then TipTac:RegisterElement(ttif,"ItemRef"); @@ -166,10 +161,6 @@ local COLOR_INCOMPLETE = { 0.5, 0.5, 0.5 }; -- Colored text string (red/green) local BoolCol = { [false] = "|cffff8080", [true] = "|cff80ff80" }; -local function GetNearestPixelSize(size) - return (size * ppScale) / cfg.gttScale; -end - -------------------------------------------------------------------------------------------------------- -- Create Tooltip Icon -- -------------------------------------------------------------------------------------------------------- @@ -205,7 +196,7 @@ function ttif:CreateTooltipIcon(tip) tip.ttIcon = tip:CreateTexture(nil, "ARTWORK"); tip.ttIcon.border = CreateFrame("Frame", nil, tip, BackdropTemplateMixin and "BackdropTemplate"); - tip.ttIcon.border:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); + tip.ttIcon.border:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, cfg.if_iconOffsetX, cfg.if_iconOffsetY); tip.ttIcon:SetPoint("CENTER", tip.ttIcon.border, "CENTER"); tip.ttIcon:Hide(); @@ -222,7 +213,7 @@ function ttif:ApplyInsetsToIconTexture(texture, backdropInfo) end function ttif:SetClamp(tip) - local basicOffset = GetNearestPixelSize(5); + local basicOffset = 5; local left, right, top, bottom = -basicOffset, basicOffset, basicOffset, -basicOffset; if(tip.ttIcon:IsShown() and tip.ttIcon:GetLeft() ~= nil) then local leftDistance = tip:GetLeft() - tip.ttIcon:GetLeft(); @@ -322,7 +313,7 @@ function ttif:OnApplyConfig() tip.ttSetIconTextureAndText = ttSetIconTextureAndText; tip.ttIcon:ClearAllPoints(); tip.ttIcon.border:ClearAllPoints(); - tip.ttIcon.border:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, GetNearestPixelSize(cfg.if_iconOffsetX), GetNearestPixelSize(cfg.if_iconOffsetY)); + tip.ttIcon.border:SetPoint(cfg.if_iconAnchor, tip, cfg.if_iconTooltipAnchor, cfg.if_iconOffsetX, cfg.if_iconOffsetY); tip.ttIcon:SetPoint("CENTER", tip.ttIcon.border, "CENTER"); tip.ttIcon:Hide(); tip.ttIcon.border:Hide(); From b31494e35b00983f2a305ae79aa9e7c6b14d3080 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Fri, 18 Feb 2022 01:25:31 +0100 Subject: [PATCH 25/31] cleanup --- TipTac/ttCore.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index a9c27ad..527a7ac 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -33,11 +33,6 @@ end local modName = ...; local tt = CreateFrame("Frame",modName,UIParent,BackdropTemplateMixin and "BackdropTemplate"); -- 9.0.1: Using BackdropTemplate --- actual pixel perfect scale -local ui_scale = UIParent:GetEffectiveScale() -local height = select(2, GetPhysicalScreenSize()) -local ppScale = (768 / height) / ui_scale - -- Global Chat Message Function function AzMsg(msg) DEFAULT_CHAT_FRAME:AddMessage(tostring(msg):gsub("|1","|cffffff80"):gsub("|2","|cffffffff"),0.5,0.75,1.0); end From 8617a2c128ddd189650d47f55e72dc7f0721bbe1 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Fri, 18 Feb 2022 02:07:46 +0100 Subject: [PATCH 26/31] insets need to be converted too, or it will be wrong for different scales. --- TipTac/ttCore.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index c1ce18d..6095e88 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -670,10 +670,10 @@ function tt:ApplySettings() tipBackdrop.tile = false; tipBackdrop.tileEdge = false; tipBackdrop.edgeSize = ((cfg.pixelPerfectBackdropEdgeSize and tt:GetNearestPixelSize(cfg.backdropEdgeSize)) or cfg.backdropEdgeSize); - tipBackdrop.insets.left = cfg.backdropInsets; - tipBackdrop.insets.right = cfg.backdropInsets; - tipBackdrop.insets.top = cfg.backdropInsets; - tipBackdrop.insets.bottom = cfg.backdropInsets; + tipBackdrop.insets.left = tt:GetNearestPixelSize(cfg.backdropInsets); + tipBackdrop.insets.right = tt:GetNearestPixelSize(cfg.backdropInsets); + tipBackdrop.insets.top = tt:GetNearestPixelSize(cfg.backdropInsets); + tipBackdrop.insets.bottom = tt:GetNearestPixelSize(cfg.backdropInsets); tipBackdrop.backdropColor:SetRGBA(unpack(cfg.tipColor)); tipBackdrop.backdropBorderColor:SetRGBA(unpack(cfg.tipBorderColor)); From cac420f72084e7bee4fbdf97075a6fbe0e433e59 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Fri, 18 Feb 2022 02:16:52 +0100 Subject: [PATCH 27/31] insets only with option set --- TipTac/ttCore.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index 6095e88..0580294 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -670,10 +670,10 @@ function tt:ApplySettings() tipBackdrop.tile = false; tipBackdrop.tileEdge = false; tipBackdrop.edgeSize = ((cfg.pixelPerfectBackdropEdgeSize and tt:GetNearestPixelSize(cfg.backdropEdgeSize)) or cfg.backdropEdgeSize); - tipBackdrop.insets.left = tt:GetNearestPixelSize(cfg.backdropInsets); - tipBackdrop.insets.right = tt:GetNearestPixelSize(cfg.backdropInsets); - tipBackdrop.insets.top = tt:GetNearestPixelSize(cfg.backdropInsets); - tipBackdrop.insets.bottom = tt:GetNearestPixelSize(cfg.backdropInsets); + tipBackdrop.insets.left = ((cfg.pixelPerfectBackdropEdgeSize and tt:GetNearestPixelSize(cfg.backdropInsets)) or cfg.backdropInsets); + tipBackdrop.insets.right = ((cfg.pixelPerfectBackdropEdgeSize and tt:GetNearestPixelSize(cfg.backdropInsets)) or cfg.backdropInsets); + tipBackdrop.insets.top = ((cfg.pixelPerfectBackdropEdgeSize and tt:GetNearestPixelSize(cfg.backdropInsets)) or cfg.backdropInsets); + tipBackdrop.insets.bottom = ((cfg.pixelPerfectBackdropEdgeSize and tt:GetNearestPixelSize(cfg.backdropInsets)) or cfg.backdropInsets); tipBackdrop.backdropColor:SetRGBA(unpack(cfg.tipColor)); tipBackdrop.backdropBorderColor:SetRGBA(unpack(cfg.tipBorderColor)); From 80311c25c21cc5f6fff70f7acfd259f43d1ef968 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Fri, 18 Feb 2022 03:22:18 +0100 Subject: [PATCH 28/31] need this to be able to set real pixel sizes --- TipTac/ttAuras.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 907b3bc..cd48ec4 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -15,6 +15,16 @@ local validSelfCasterUnits = { vehicle = true, }; +-- actual pixel perfect scale +local ui_scale = UIParent:GetEffectiveScale() +local height = select(2, GetPhysicalScreenSize()) +local ppScale = (768 / height) / ui_scale + +-- Get nearest pixel size (e.g. to avoid 1-pixel borders, which are sometimes 0/2-pixels wide) +function tt:GetNearestPixelSize(size) + return (size * ppScale) / cfg.gttScale; +end + -------------------------------------------------------------------------------------------------------- -- Misc -- -------------------------------------------------------------------------------------------------------- @@ -200,6 +210,9 @@ end function ttAuras:OnApplyConfig(cfg) -- If disabled, hide auras, else set their size local gameFont = GameFontNormal:GetFont(); + ui_scale = UIParent:GetEffectiveScale() + height = select(2, GetPhysicalScreenSize()) + ppScale = (768 / height) / ui_scale for _, aura in ipairs(auras) do if (cfg.showBuffs or cfg.showDebuffs) then aura:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); From 9810a3d535e6a2b1c909b78fb9d8990c25b09d73 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Fri, 18 Feb 2022 03:24:05 +0100 Subject: [PATCH 29/31] need this to be able to set real pixel sizes --- TipTac/ttAuras.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index cd48ec4..4fa1087 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -21,7 +21,7 @@ local height = select(2, GetPhysicalScreenSize()) local ppScale = (768 / height) / ui_scale -- Get nearest pixel size (e.g. to avoid 1-pixel borders, which are sometimes 0/2-pixels wide) -function tt:GetNearestPixelSize(size) +function ttAuras:GetNearestPixelSize(size) return (size * ppScale) / cfg.gttScale; end @@ -31,7 +31,7 @@ end local function CreateAuraFrame(parent) local aura = CreateFrame("Frame", nil, parent); - aura:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); + aura:SetSize(ttAuras:GetNearestPixelSize(cfg.auraSize), ttAuras:GetNearestPixelSize(cfg.auraSize)); aura.count = aura:CreateFontString(nil,"OVERLAY"); aura.count:SetPoint("BOTTOMRIGHT",1,0); @@ -39,7 +39,7 @@ local function CreateAuraFrame(parent) aura.icon = CreateFrame("Frame", nil, aura); aura.icon:SetPoint("CENTER",aura,"CENTER"); - aura.icon:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); + aura.icon:SetSize(ttAuras:GetNearestPixelSize(cfg.auraSize), ttAuras:GetNearestPixelSize(cfg.auraSize)); aura.icon.texture = aura:CreateTexture(nil,"BACKGROUND"); aura.icon.texture:SetPoint("CENTER",aura.icon,"CENTER"); @@ -67,11 +67,11 @@ end function ttAuras:ApplyInsetsToIconTexture(texture, backdropInfo) -- manually implementing border insets because otherwise we cant remove the ugly default border -- assumes symmetrical insets - texture:SetSize(tt:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.left * 2, tt:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.top * 2); + texture:SetSize(ttAuras:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.left * 2, ttAuras:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.top * 2); end function ttAuras:SetClamp(tip, furthestAuraIcon) - local basicOffset = tt:GetNearestPixelSize(5); + local basicOffset = ttAuras:GetNearestPixelSize(5); local left, right, top, bottom = -basicOffset, basicOffset, basicOffset, -basicOffset; if(furthestAuraIcon ~= nil) then @@ -94,8 +94,8 @@ end function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) -- want them to be flush with the tooltips borders, means we subtract 1 offset since the very last one doesn't need to be there -- aura icons don't scale because we need the exact width, have to change the size manually in the options instead. - local aurasPerRow = floor((tip:GetWidth() + tt:GetNearestPixelSize(cfg.auraOffsetX)) / tt:GetNearestPixelSize(cfg.auraSize + cfg.auraOffsetX)); -- auras we can fit into one row based on the current size of the tooltip - local xOffsetBasis = tt:GetNearestPixelSize(auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX); -- is +1 or -1 based on horz anchoring + local aurasPerRow = floor((tip:GetWidth() + ttAuras:GetNearestPixelSize(cfg.auraOffsetX)) / ttAuras:GetNearestPixelSize(cfg.auraSize + cfg.auraOffsetX)); -- auras we can fit into one row based on the current size of the tooltip + local xOffsetBasis = ttAuras:GetNearestPixelSize(auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX); -- is +1 or -1 based on horz anchoring local queryIndex = 1; -- aura query index for this auraType local auraFrameIndex = startingAuraFrameIndex; -- array index for the next aura frame, initialized to the starting index @@ -125,7 +125,7 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) local x = 0; local y = (cfg.auraSize + cfg.auraOffsetY) * floor((auraFrameIndex - 1) / aurasPerRow) + cfg.auraOffsetY; y = (cfg.aurasAtBottom and -y or y); - aura:SetPoint(anchor1, tip, anchor2, x, tt:GetNearestPixelSize(y)); + aura:SetPoint(anchor1, tip, anchor2, x, ttAuras:GetNearestPixelSize(y)); else -- anchor to last aura:SetPoint(horzAnchor1, auras[auraFrameIndex - 1], horzAnchor2, xOffsetBasis, 0); @@ -215,14 +215,14 @@ function ttAuras:OnApplyConfig(cfg) ppScale = (768 / height) / ui_scale for _, aura in ipairs(auras) do if (cfg.showBuffs or cfg.showDebuffs) then - aura:SetSize(tt:GetNearestPixelSize(cfg.auraSize), tt:GetNearestPixelSize(cfg.auraSize)); + aura:SetSize(ttAuras:GetNearestPixelSize(cfg.auraSize), ttAuras:GetNearestPixelSize(cfg.auraSize)); aura.border:SetBackdrop(nil); aura.border:SetBackdrop(aura:GetParent().backdropInfo); aura.border:SetBackdropColor(0, 0, 0, 0); aura.border:SetAllPoints(); ttAuras:ApplyInsetsToIconTexture(aura.icon, aura:GetParent().backdropInfo); ttAuras:ApplyInsetsToIconTexture(aura.icon.texture, aura:GetParent().backdropInfo); - aura.count:SetFont(gameFont,(tt:GetNearestPixelSize(cfg.auraSize) / 2),"OUTLINE"); + aura.count:SetFont(gameFont,(ttAuras:GetNearestPixelSize(cfg.auraSize) / 2),"OUTLINE"); aura.icon.cooldown.noCooldownCount = cfg.noCooldownCount; else aura:Hide(); From 46ddf43ed47321081a56f64be61a98caea317971 Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Sun, 20 Feb 2022 01:37:15 +0100 Subject: [PATCH 30/31] refactored, optional aura pixelperfect scaling --- TipTac/ttAuras.lua | 97 +++++++++++++++++++++++++------------ TipTac/ttCore.lua | 3 ++ TipTacOptions/ttOptions.lua | 1 + 3 files changed, 70 insertions(+), 31 deletions(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 4fa1087..825e215 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -15,23 +15,17 @@ local validSelfCasterUnits = { vehicle = true, }; --- actual pixel perfect scale -local ui_scale = UIParent:GetEffectiveScale() -local height = select(2, GetPhysicalScreenSize()) -local ppScale = (768 / height) / ui_scale - --- Get nearest pixel size (e.g. to avoid 1-pixel borders, which are sometimes 0/2-pixels wide) -function ttAuras:GetNearestPixelSize(size) - return (size * ppScale) / cfg.gttScale; -end - -------------------------------------------------------------------------------------------------------- -- Misc -- -------------------------------------------------------------------------------------------------------- local function CreateAuraFrame(parent) local aura = CreateFrame("Frame", nil, parent); - aura:SetSize(ttAuras:GetNearestPixelSize(cfg.auraSize), ttAuras:GetNearestPixelSize(cfg.auraSize)); + if (cfg.auraPixelPerfectPositioning) then + aura:SetScale(tt.ppScale / cfg.gttScale); + end + print(aura:GetScale()) + aura:SetSize(cfg.auraSize, cfg.auraSize); aura.count = aura:CreateFontString(nil,"OVERLAY"); aura.count:SetPoint("BOTTOMRIGHT",1,0); @@ -39,7 +33,7 @@ local function CreateAuraFrame(parent) aura.icon = CreateFrame("Frame", nil, aura); aura.icon:SetPoint("CENTER",aura,"CENTER"); - aura.icon:SetSize(ttAuras:GetNearestPixelSize(cfg.auraSize), ttAuras:GetNearestPixelSize(cfg.auraSize)); + aura.icon:SetSize(cfg.auraSize, cfg.auraSize); aura.icon.texture = aura:CreateTexture(nil,"BACKGROUND"); aura.icon.texture:SetPoint("CENTER",aura.icon,"CENTER"); @@ -56,29 +50,68 @@ local function CreateAuraFrame(parent) aura.border = CreateFrame("Frame", nil, aura, BackdropTemplateMixin and "BackdropTemplate"); aura.border:SetAllPoints(); - aura.border:SetBackdrop(aura:GetParent().backdropInfo); - aura.border:SetBackdropColor(0, 0, 0, 0); + ttAuras:ApplyParentBackdropToAura(aura.border, aura:GetParent()) aura.border:SetFrameLevel(aura.icon.cooldown:GetFrameLevel()+1); auras[#auras + 1] = aura; return aura; end +function ttAuras:ApplyParentBackdropToAura(aura, parent) + -- using the normal values here since the entire aura is scaled already + local parentBackdropInfo = parent.backdropInfo; + local backdropInfo; + if (cfg.auraPixelPerfectPositioning) then + local parentBackdropInfo = parent.backdropInfo; + backdropInfo = { + bgFile = parentBackdropInfo.bgFile, + edgeFile = parentBackdropInfo.edgeFile, + edgeSize = cfg.backdropEdgeSize, + insets = {left = cfg.backdropInsets, right = cfg.backdropInsets, top = cfg.backdropInsets, bottom = cfg.backdropInsets}, + } + else + backdropInfo = parentBackdropInfo + end + + aura:SetBackdrop(backdropInfo); + aura:SetBackdropColor(0, 0, 0, 0); +end + function ttAuras:ApplyInsetsToIconTexture(texture, backdropInfo) -- manually implementing border insets because otherwise we cant remove the ugly default border -- assumes symmetrical insets - texture:SetSize(ttAuras:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.left * 2, ttAuras:GetNearestPixelSize(cfg.auraSize) - backdropInfo.insets.top * 2); + if (cfg.auraPixelPerfectPositioning) then + texture:SetSize(cfg.auraSize - cfg.backdropInsets * 2, cfg.auraSize - cfg.backdropInsets * 2); + else + texture:SetSize(cfg.auraSize - backdropInfo.insets.left * 2, cfg.auraSize - backdropInfo.insets.top * 2); + end +end + +function ttAuras:ConvertToRealPixels(pos) + if (cfg.auraPixelPerfectPositioning) then + return (pos / tt.ppScale * cfg.gttScale) + else + return pos + end +end + +function ttAuras:ConvertToFakePixels(pos) + if (cfg.auraPixelPerfectPositioning) then + return (pos * tt.ppScale / cfg.gttScale) + else + return pos + end end function ttAuras:SetClamp(tip, furthestAuraIcon) - local basicOffset = ttAuras:GetNearestPixelSize(5); + local basicOffset = 5; local left, right, top, bottom = -basicOffset, basicOffset, basicOffset, -basicOffset; if(furthestAuraIcon ~= nil) then - local leftDistance = tip:GetLeft() - furthestAuraIcon:GetLeft(); - local rightDistance = furthestAuraIcon:GetRight() - tip:GetRight(); - local topDistance = furthestAuraIcon:GetTop() - tip:GetTop(); - local bottomDistance = tip:GetBottom() - furthestAuraIcon:GetBottom(); + local leftDistance = ttAuras:ConvertToRealPixels(tip:GetLeft()) - furthestAuraIcon:GetLeft(); + local rightDistance = furthestAuraIcon:GetRight() - ttAuras:ConvertToRealPixels(tip:GetRight()); + local topDistance = furthestAuraIcon:GetTop() - ttAuras:ConvertToRealPixels(tip:GetTop()); + local bottomDistance = ttAuras:ConvertToRealPixels(tip:GetBottom()) - furthestAuraIcon:GetBottom(); left = left + ((leftDistance > 0) and -leftDistance or 0); right = right + ((rightDistance > 0) and rightDistance or 0); @@ -87,15 +120,16 @@ function ttAuras:SetClamp(tip, furthestAuraIcon) end tip:SetClampedToScreen(true); - tip:SetClampRectInsets(left, right, top, bottom); + tip:SetClampRectInsets(ttAuras:ConvertToFakePixels(left), ttAuras:ConvertToFakePixels(right), ttAuras:ConvertToFakePixels(top), ttAuras:ConvertToFakePixels(bottom)); end -- querires auras of the specific auraType, and sets up the aura frame and anchors it in the desired place function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) -- want them to be flush with the tooltips borders, means we subtract 1 offset since the very last one doesn't need to be there -- aura icons don't scale because we need the exact width, have to change the size manually in the options instead. - local aurasPerRow = floor((tip:GetWidth() + ttAuras:GetNearestPixelSize(cfg.auraOffsetX)) / ttAuras:GetNearestPixelSize(cfg.auraSize + cfg.auraOffsetX)); -- auras we can fit into one row based on the current size of the tooltip - local xOffsetBasis = ttAuras:GetNearestPixelSize(auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX); -- is +1 or -1 based on horz anchoring + local tooltipWidth = ttAuras:ConvertToRealPixels(tip:GetWidth()); + local aurasPerRow = floor((tooltipWidth + cfg.auraOffsetX) / (cfg.auraSize + cfg.auraOffsetX)); -- auras we can fit into one row based on the current size of the tooltip + local xOffsetBasis = auraType == "HELPFUL" and cfg.auraOffsetX or -cfg.auraOffsetX; -- is +1 or -1 based on horz anchoring local queryIndex = 1; -- aura query index for this auraType local auraFrameIndex = startingAuraFrameIndex; -- array index for the next aura frame, initialized to the starting index @@ -125,7 +159,7 @@ function ttAuras:DisplayAuras(tip,auraType,startingAuraFrameIndex) local x = 0; local y = (cfg.auraSize + cfg.auraOffsetY) * floor((auraFrameIndex - 1) / aurasPerRow) + cfg.auraOffsetY; y = (cfg.aurasAtBottom and -y or y); - aura:SetPoint(anchor1, tip, anchor2, x, ttAuras:GetNearestPixelSize(y)); + aura:SetPoint(anchor1, tip, anchor2, x, y); else -- anchor to last aura:SetPoint(horzAnchor1, auras[auraFrameIndex - 1], horzAnchor2, xOffsetBasis, 0); @@ -210,19 +244,20 @@ end function ttAuras:OnApplyConfig(cfg) -- If disabled, hide auras, else set their size local gameFont = GameFontNormal:GetFont(); - ui_scale = UIParent:GetEffectiveScale() - height = select(2, GetPhysicalScreenSize()) - ppScale = (768 / height) / ui_scale for _, aura in ipairs(auras) do if (cfg.showBuffs or cfg.showDebuffs) then - aura:SetSize(ttAuras:GetNearestPixelSize(cfg.auraSize), ttAuras:GetNearestPixelSize(cfg.auraSize)); + if (cfg.auraPixelPerfectPositioning) then + aura:SetScale(tt.ppScale / cfg.gttScale); + else + aura:SetScale(1); + end + aura:SetSize(cfg.auraSize, cfg.auraSize); aura.border:SetBackdrop(nil); - aura.border:SetBackdrop(aura:GetParent().backdropInfo); - aura.border:SetBackdropColor(0, 0, 0, 0); + ttAuras:ApplyParentBackdropToAura(aura.border, aura:GetParent()) aura.border:SetAllPoints(); ttAuras:ApplyInsetsToIconTexture(aura.icon, aura:GetParent().backdropInfo); ttAuras:ApplyInsetsToIconTexture(aura.icon.texture, aura:GetParent().backdropInfo); - aura.count:SetFont(gameFont,(ttAuras:GetNearestPixelSize(cfg.auraSize) / 2),"OUTLINE"); + aura.count:SetFont(gameFont,(cfg.auraSize / 2),"OUTLINE"); aura.icon.cooldown.noCooldownCount = cfg.noCooldownCount; else aura:Hide(); diff --git a/TipTac/ttCore.lua b/TipTac/ttCore.lua index 7083838..a68c005 100644 --- a/TipTac/ttCore.lua +++ b/TipTac/ttCore.lua @@ -149,6 +149,7 @@ local TT_DefaultConfig = { auraOffsetX = 2, auraOffsetY = 2, auraBorderUseDebuffTypeColors = true, + auraPixelPerfectPositioning = false, iconRaid = true, iconFaction = false, @@ -344,11 +345,13 @@ orgGTTSFontFlags = ""; -- Set during VARIABLES_LOADED -- Pixel Perfect Scale local physicalScreenWidth, physicalScreenHeight, uiUnitFactor, uiScale; local mouseOffsetX, mouseOffsetY = 0, 0; +tt.ppScale = nil local function updatePixelPerfectScale() physicalScreenWidth, physicalScreenHeight = GetPhysicalScreenSize(); uiUnitFactor = 768.0 / physicalScreenHeight; uiScale = UIParent:GetEffectiveScale(); + tt.ppScale = uiUnitFactor / uiScale if (cfg) then mouseOffsetX, mouseOffsetY = tt:GetNearestPixelSize(cfg.mouseOffsetX), tt:GetNearestPixelSize(cfg.mouseOffsetY); end diff --git a/TipTacOptions/ttOptions.lua b/TipTacOptions/ttOptions.lua index 00f6393..222f283 100644 --- a/TipTacOptions/ttOptions.lua +++ b/TipTacOptions/ttOptions.lua @@ -177,6 +177,7 @@ local options = { { [0] = "Auras", { type = "Check", var = "aurasAtBottom", label = "Put Aura Icons at the Bottom Instead of Top", tip = "Puts the aura icons at the bottom of the tip instead of the default top" }, + { type = "Check", var = "auraPixelPerfectPositioning", label = "Pixel Perfect Aura Scale, Sizing and Positioning", tip = "Sizes and offsets correspond to real screen pixels, unscaled", y = 6 }, { type = "Check", var = "showBuffs", label = "Show Unit Buffs", tip = "Show buffs of the unit", y = 12 }, { type = "Check", var = "showDebuffs", label = "Show Unit Debuffs", tip = "Show debuffs of the unit" }, { type = "Check", var = "selfAurasOnly", label = "Only Show Auras Coming from You", tip = "This will filter out and only display auras you cast yourself", y = 12 }, From d41132aa7940896e8f5b37bcbfb00fc865702c3b Mon Sep 17 00:00:00 2001 From: NoBetaBoredom <82800139+NoBetaBoredom@users.noreply.github.com> Date: Sun, 20 Feb 2022 01:37:53 +0100 Subject: [PATCH 31/31] cleanup --- TipTac/ttAuras.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/TipTac/ttAuras.lua b/TipTac/ttAuras.lua index 825e215..9f98be6 100644 --- a/TipTac/ttAuras.lua +++ b/TipTac/ttAuras.lua @@ -24,7 +24,6 @@ local function CreateAuraFrame(parent) if (cfg.auraPixelPerfectPositioning) then aura:SetScale(tt.ppScale / cfg.gttScale); end - print(aura:GetScale()) aura:SetSize(cfg.auraSize, cfg.auraSize); aura.count = aura:CreateFontString(nil,"OVERLAY");