Skip to content

Commit

Permalink
Hide empty top line in DurabilityFu tooltip when durability is at 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
azuraji committed Dec 5, 2022
1 parent 5f642dd commit 0881e82
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 45 deletions.
5 changes: 3 additions & 2 deletions FuBar_DurabilityFu/DurabilityFu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
DurabilityFu = AceLibrary("AceAddon-2.0"):new("FuBarPlugin-2.0", "AceDB-2.0", "AceEvent-2.0", "AceHook-2.1", "AceConsole-2.0")
local DurabilityFu = DurabilityFu

DurabilityFu.version = "3.00." .. string.sub("$Revision: 200 $", 12, -3)
DurabilityFu.date = string.sub("$Date: 2022-11-16 23:20:00 +0100 (Wed, 16 Nov 2022) $", 8, 17)
DurabilityFu.hasIcon = true
DurabilityFu.canHideText = true
Expand Down Expand Up @@ -421,6 +420,7 @@ do
max = max + item[MAX]
end
end

cat = Tablet:AddCategory(
"columns", 2,
"text", L["Total"],
Expand All @@ -429,7 +429,8 @@ do
"child_textB", 0,
"child_text2R", 1,
"child_text2G", 1,
"child_text2B", 1
"child_text2B", 1,
'hideBlankLine', cost == 0
)
local r, g, b = Crayon:GetThresholdColor(value / max)
cat:AddLine(
Expand Down
6 changes: 1 addition & 5 deletions FuBar_DurabilityFu/FuBar_DurabilityFu.toc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
## Notes-ruRU: Следит за прочностью вашего снаряжения и показывает диалог починки у торговца, умеющего чинить.
## Notes-zhTW: 持續追蹤裝備耐久度,並在可修裝NPC處顯示是否要自動修裝的對話框。
## Notes-esES: Vigila la durabilidad y muestra una ventana para reparar cuando vas a un vendedor.
## Version: 2.14
## Version: 10.0.2.1
## X-eMail: ckknight AT gmail DOT com
## X-Donate: PayPal:ckknight AT gmail DOT com
## X-Website: http://www.wowace.com/
## X-Category: Inventory
## X-Website: http://ckknight.wowinterface.com/
## OptionalDeps: FuBar, Ace2, Deformat, DewdropLib, GratuityLib, FuBarPlugin-2.0, TabletLib, CrayonLib
## SavedVariables: DurabilityFuDB
## X-Curse-Packaged-Version: r127
## X-Curse-Project-Name: FuBar_DurabilityFu
## X-Curse-Project-ID: fubar_durabilityfu
## X-Curse-Repository-ID: wow/fubar_durabilityfu/mainline

embeds.xml

Expand Down
10 changes: 4 additions & 6 deletions FuBar_DurabilityFu/libs/Dewdrop-2.0/Dewdrop-2.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ local function AcquireLevel(self, level)
end
frame:EnableMouse(true)
frame:EnableMouseWheel(true)
local backdrop = CreateFrame("Frame", nil, frame)
local backdrop = CreateFrame("Frame", nil, frame, "BackdropTemplate")
backdrop:SetAllPoints(frame)
backdrop:SetBackdrop(tmp(
'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
Expand Down Expand Up @@ -1921,7 +1921,7 @@ end

function OpenSlider(self, parent)
if not sliderFrame then
sliderFrame = CreateFrame("Frame", nil, nil)
sliderFrame = CreateFrame("Frame", nil, nil, "BackdropTemplate")
sliderFrame:SetWidth(100)
sliderFrame:SetHeight(170)
sliderFrame:SetScale(UIParent:GetScale())
Expand All @@ -1946,9 +1946,8 @@ function OpenSlider(self, parent)
sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
sliderFrame:EnableMouse(true)
sliderFrame:EnableMouseWheel(true)
sliderFrame:Hide()
sliderFrame:SetPoint("CENTER", UIParent, "CENTER")
local slider = CreateFrame("Slider", nil, sliderFrame)
local slider = CreateFrame("Slider", nil, sliderFrame, "BackdropTemplate")
sliderFrame.slider = slider
slider:SetOrientation("VERTICAL")
slider:SetMinMaxValues(0, 1)
Expand Down Expand Up @@ -2277,7 +2276,6 @@ function OpenSlider(self, parent)
end
end


sliderFrame.lastValue = parent.sliderValue

local level = parent.level
Expand Down Expand Up @@ -2344,7 +2342,7 @@ end

function OpenEditBox(self, parent)
if not editBoxFrame then
editBoxFrame = CreateFrame("Frame", nil, nil)
editBoxFrame = CreateFrame("Frame", nil, nil, "BackdropTemplate")
editBoxFrame:SetWidth(200)
editBoxFrame:SetHeight(40)
editBoxFrame:SetScale(UIParent:GetScale())
Expand Down
24 changes: 17 additions & 7 deletions FuBar_DurabilityFu/libs/FuBarPlugin-2.0/FuBarPlugin-2.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ function FuBarPlugin:Hide(check)
if Dewdrop:IsOpen(self.frame) or (self.minimapFrame and Dewdrop:IsOpen(self.minimapFrame)) then
Dewdrop:Close()
end

if type(self.OnHide) == "function" then
if not self:IsDisabled() then
self:OnHide()
end
end
end

function FuBarPlugin:SetIcon(path)
Expand Down Expand Up @@ -1161,17 +1167,21 @@ function FuBarPlugin:OpenMenu(frame)
end
end,
'point', function(frame)
local pluginSide = self.panel and self.panel:GetPluginSide(self)

local x, y = frame:GetCenter()
local leftRight
if x < GetScreenWidth() / 2 then
leftRight = "LEFT"
local horizontalPosition
if (pluginSide == "CENTER") then
horizontalPosition = ""
elseif (x < GetScreenWidth() / 2) then
horizontalPosition = "LEFT"
else
leftRight = "RIGHT"
horizontalPosition = "RIGHT"
end
if y < GetScreenHeight() / 2 then
return "BOTTOM" .. leftRight, "TOP" .. leftRight
return "BOTTOM" .. horizontalPosition, "TOP" .. horizontalPosition
else
return "TOP" .. leftRight, "BOTTOM" .. leftRight
return "TOP" .. horizontalPosition, "BOTTOM" .. horizontalPosition
end
end,
'dontHook', true
Expand Down Expand Up @@ -1217,7 +1227,7 @@ function FuBarPlugin.OnEmbedInitialize(FuBarPlugin, self)
local text = frame:CreateFontString(name .. "Text", "ARTWORK")
text:SetWidth(134)
text:SetHeight(24)
text:SetPoint("LEFT", icon, "RIGHT", 0, 1)
text:SetPoint("LEFT", icon, "RIGHT", 0, 0)
text:SetFontObject(GameFontNormal)
end
self.frame = frame
Expand Down
60 changes: 35 additions & 25 deletions FuBar_DurabilityFu/libs/Tablet-2.0/Tablet-2.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ end})

local headerSize, normalSize
if GameTooltipHeaderText then
headerSize = select(2,GameTooltipHeaderText:GetFont())
-- headerSize = select(2,GameTooltipHeaderText:GetFont())
headerSize = 5
else
headerSize = 14
end
Expand Down Expand Up @@ -786,6 +787,7 @@ do
end

local fontSizePercent = category.tabletData.tablet.fontSizePercent

local w = 0
self.checkWidth = 0
testString = category.tabletData.tablet.buttons[1].col1
Expand Down Expand Up @@ -1160,7 +1162,8 @@ local function AcquireFrame(self, registration, data, detachedData)
tooltip.data = data
tooltip.detachedData = detachedData
local fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1
local transparency = tooltip.data and tooltip.data.transparency or 0.75
--local fontSizePercent = 1
local transparency = tooltip.data and tooltip.data.transparency or 0.8
local r = tooltip.data and tooltip.data.r or 0
local g = tooltip.data and tooltip.data.g or 0
local b = tooltip.data and tooltip.data.b or 0
Expand All @@ -1174,7 +1177,7 @@ local function AcquireFrame(self, registration, data, detachedData)
frame:SetFrameLevel(12)
end
else
tooltip = CreateFrame("Frame", "Tablet20Frame", UIParent)
tooltip = CreateFrame("Frame", "Tablet20Frame", UIParent, "BackdropTemplate")
tooltip:SetParent(GetMainFrame())
self.tooltip = tooltip
tooltip.data = data
Expand All @@ -1190,10 +1193,10 @@ local function AcquireFrame(self, registration, data, detachedData)
'tileSize', 16,
'edgeSize', 16,
'insets', new(
'left', 5,
'right', 5,
'top', 5,
'bottom', 5
'left', 3,
'right', 3,
'top', 3,
'bottom', 3
)
)
tooltip:SetBackdrop(backdrop)
Expand Down Expand Up @@ -1253,7 +1256,7 @@ local function AcquireFrame(self, registration, data, detachedData)
scrollFrame:SetPoint("BOTTOMRIGHT", -5, 5)
scrollChild:SetWidth(1)
scrollChild:SetHeight(1)
local slider = CreateFrame("Slider", "Tablet20FrameSlider", scrollFrame)
local slider = CreateFrame("Slider", "Tablet20FrameSlider", scrollFrame, "BackdropTemplate")
tooltip.slider = slider
slider:SetOrientation("VERTICAL")
slider:SetMinMaxValues(0, 1)
Expand Down Expand Up @@ -1397,7 +1400,12 @@ local function AcquireFrame(self, registration, data, detachedData)
val = 0
end
self.scrollFrame:SetVerticalScroll(val)
self.slider:SetValue(val/max)
-- TODO: In Dragonflight both values are 0?
if max > 0 then
self.slider:SetValue(val / max)
else
self.slider:SetValue(0)
end
end
tooltip.Show = wrap(tooltip.Show, "tooltip:Show")

Expand Down Expand Up @@ -1996,7 +2004,7 @@ function AcquireDetachedFrame(self, registration, data, detachedData)
if not tooltip then
AcquireFrame(self, {})
end
local detached = CreateFrame("Frame", "Tablet20DetachedFrame" .. (#detachedTooltips + 1), GetMainFrame())
local detached = CreateFrame("Frame", "Tablet20DetachedFrame" .. (#detachedTooltips + 1), GetMainFrame(), "BackdropTemplate")
detachedTooltips[#detachedTooltips+1] = detached
detached.notInUse = true
detached:EnableMouse(not data.locked)
Expand All @@ -2009,7 +2017,7 @@ function AcquireDetachedFrame(self, registration, data, detachedData)
detached.fontSizePercent = 1
detached.maxLines = 0
detached.buttons = {}
detached.transparency = 0.75
detached.transparency = 1
detached.r = 0
detached.g = 0
detached.b = 0
Expand All @@ -2021,10 +2029,10 @@ function AcquireDetachedFrame(self, registration, data, detachedData)
'tileSize', 16,
'edgeSize', 16,
'insets', tmp.b(
'left', 5,
'right', 5,
'top', 5,
'bottom', 5
'left', 3,
'right', 3,
'top', 3,
'bottom', 3
)
))
detached.locked = detachedData.locked
Expand All @@ -2045,8 +2053,8 @@ function AcquireDetachedFrame(self, registration, data, detachedData)
detached:SetScript("OnDragStop", function(this)
detached:StopMovingOrSizing()
detached.moving = nil
detached:SetClampedToScreen(1)
detached:SetClampedToScreen(nil)
detached:SetClampedToScreen(true)
detached:SetClampedToScreen(false)
local anchor
local offsetx
local offsety
Expand Down Expand Up @@ -2236,7 +2244,7 @@ function AcquireDetachedFrame(self, registration, data, detachedData)
scrollFrame:SetPoint("BOTTOMRIGHT", -5, 5)
scrollChild:SetWidth(1)
scrollChild:SetHeight(1)
local slider = CreateFrame("Slider", detached:GetName() .. "Slider", scrollFrame)
local slider = CreateFrame("Slider", detached:GetName() .. "Slider", scrollFrame, "BackdropTemplate")
detached.slider = slider
slider:SetOrientation("VERTICAL")
slider:SetMinMaxValues(0, 1)
Expand Down Expand Up @@ -2436,8 +2444,8 @@ function Tablet:Open(fakeParent, parent)
end
local offsetx = 0
local offsety = 0
frame:SetClampedToScreen(1)
frame:SetClampedToScreen(nil)
frame:SetClampedToScreen(true)
frame:SetClampedToScreen(false)
if frame:GetBottom() and frame:GetLeft() then
if frame:GetRight() > GetScreenWidth() then
offsetx = frame:GetRight() - GetScreenWidth()
Expand Down Expand Up @@ -2555,16 +2563,18 @@ function Tablet:Register(parent, ...)
if script then
script(...)
end
if self.registry[parent] and self.registry[parent].tooltip and self.registry[parent].tooltip == self.tooltip then
self.tooltip:Hide()
end
-- Prevent Tablet from closing on parent mousedown

-- if self.registry[parent] and self.registry[parent].tooltip and self.registry[parent].tooltip == self.tooltip then
-- self.tooltip:Hide()
-- end
end)
end
if parent:HasScript("OnMouseWheel") then
local script = parent:GetScript("OnMouseWheel")
parent:SetScript("OnMouseWheel", function(...)
parent:SetScript("OnMouseWheel", function(this, arg1)
if script then
script(...)
script(this, arg1)
end
if self.registry[parent] and self.registry[parent].tooltip then
self.registry[parent].tooltip:Scroll(arg1 < 0)
Expand Down

0 comments on commit 0881e82

Please sign in to comment.