Skip to content

Commit

Permalink
Fix icon positioning and a few errors
Browse files Browse the repository at this point in the history
Icon positioning wasn't working correctly for loot frame (and possibly
others) - got it back and working again.

Wago was causing some errors.  I'm disabling it for now (but may try
again later).

There was a report of an error while buying recipes from the vendor.  I
wasn't able to duplicate this locally, but I made some fixes that should
at least help avoid it.
  • Loading branch information
Caerdon committed May 11, 2024
1 parent 78f4f2a commit 059c1f4
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 119 deletions.
210 changes: 101 additions & 109 deletions CaerdonWardrobe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,54 @@ function CaerdonWardrobeMixin:SetItemButtonMogStatusFilter(originalButton, isFil
end
end

function CaerdonWardrobeMixin:SetupCaerdonButton(originalButton, item, feature, locationInfo, options)
local button = originalButton.caerdonButton
if not button then
button = CreateFrame("Frame", nil, originalButton)
button.searchOverlay = originalButton.searchOverlay
originalButton.caerdonButton = button
end

if not button.mogStatus then
mogStatusBackground = button:CreateTexture(nil, "ARTWORK", nil, 1)
mogStatus = button:CreateTexture(nil, "ARTWORK", nil, 2)
mogStatus.mogStatusBackground = mogStatusBackground
button.mogStatus = mogStatus
end

if not button.bindsOnText then
button.bindsOnText = button:CreateFontString(nil, "ARTWORK", "SystemFont_Outline_Small") -- TODO: Note: placing directly on button to enable search fade - need to check on other addons
end

end

function CaerdonWardrobeMixin:SetItemButtonStatus(originalButton, item, feature, locationInfo, options, status, bindingStatus)
local button = originalButton.caerdonButton

-- Make sure it's sitting in front of the frame it's going to overlay
local levelCheckFrame = originalButton
if options and options.relativeFrame then
if options.relativeFrame:GetObjectType() == "Texture" then
levelCheckFrame = options.relativeFrame:GetParent()
else
levelCheckFrame = options.relativeFrame
end
end

if levelCheckFrame then
button:SetFrameStrata(levelCheckFrame:GetFrameStrata())
button:SetFrameLevel(levelCheckFrame:GetFrameLevel() + 1)
end

button:ClearAllPoints()
button:SetSize(0,0)

if options and options.relativeFrame then
button:SetAllPoints(options.relativeFrame)
else
button:SetAllPoints(originalButton)
end

-- Had some addons messing with frame level resulting in this getting covered by the parent button.
-- Haven't seen any negative issues with bumping it up, yet, but keep an eye on it if
-- the status icon overlaps something it shouldn't.
Expand All @@ -172,6 +217,17 @@ function CaerdonWardrobeMixin:SetItemButtonStatus(originalButton, item, feature,
end
end

-- local mogFlash = button.mogFlash
-- if not mogFlash then
-- mogFlash = button:CreateTexture(nil, "OVERLAY")
-- mogFlash:SetAlpha(0)
-- mogFlash:SetBlendMode("ADD")
-- mogFlash:SetAtlas("bags-glow-flash", true)
-- mogFlash:SetPoint("CENTER")

-- button.mogFlash = mogFlash
-- end

local showAnim = false
if status == "waiting" then
showAnim = true
Expand Down Expand Up @@ -440,7 +496,7 @@ function CaerdonWardrobeMixin:SetItemButtonStatus(originalButton, item, feature,
mogStatus:SetTexCoord(-1/32, 33/32, -1/32, 33/32)
mogStatus:SetTexture("Interface\\MINIMAP\\MapQuestHub_Icon32")
elseif status == "collected" then
if IsGearSetStatus(bindingStatus, item) and (CaerdonWardrobeConfig.Binding.ShowGearSetsAsIcon or options.forceGearSetsAsIcon) then
if IsGearSetStatus(bindingStatus, item) and CaerdonWardrobeConfig.Binding.ShowGearSetsAsIcon then
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-clothes")
end
Expand All @@ -454,7 +510,7 @@ function CaerdonWardrobeMixin:SetItemButtonStatus(originalButton, item, feature,
alpha = 0.5
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Common\\StreamCircle")
-- elseif IsGearSetStatus(bindingStatus, item) and (CaerdonWardrobeConfig.Binding.ShowGearSetsAsIcon or options.forceGearSetsAsIcon) then
-- elseif IsGearSetStatus(bindingStatus, item) and CaerdonWardrobeConfig.Binding.ShowGearSetsAsIcon then
-- mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
-- mogStatus:SetTexture("Interface\\Store\\category-icon-clothes")
end
Expand Down Expand Up @@ -526,14 +582,9 @@ function CaerdonWardrobeMixin:SetItemButtonBindType(button, item, feature, locat
return
end

if not bindsOnText then
bindsOnText = button:CreateFontString(nil, "ARTWORK", "SystemFont_Outline_Small") -- TODO: Note: placing directly on button to enable search fade - need to check on other addons
caerdonButton.bindsOnText = bindsOnText
end

local bindingText = ""
if IsGearSetStatus(bindingStatus, item) then -- is gear set
if (CaerdonWardrobeConfig.Binding.ShowGearSets and not options.forceGearSetsAsIcon) then
if CaerdonWardrobeConfig.Binding.ShowGearSets then
bindingText = "|cFFFFFFFF" .. bindingStatus .. "|r"
end
else
Expand Down Expand Up @@ -570,55 +621,53 @@ function CaerdonWardrobeMixin:SetItemButtonBindType(button, item, feature, locat

bindsOnText:SetText(bindingText)

if not options.fixedBindingPosition then
-- Measure text and resize accordingly
bindsOnText:ClearAllPoints()
bindsOnText:SetSize(0,0)
bindsOnText:SetPoint("LEFT")
bindsOnText:SetPoint("RIGHT")
-- Measure text and resize accordingly
bindsOnText:ClearAllPoints()
bindsOnText:SetSize(0,0)
bindsOnText:SetPoint("LEFT")
bindsOnText:SetPoint("RIGHT")

local newWidth = bindsOnText:GetStringWidth()
if newWidth > button:GetWidth() then
newWidth = button:GetWidth()
end
local newHeight = bindsOnText:GetHeight()

bindsOnText:ClearAllPoints()
bindsOnText:SetSize(newWidth, newHeight)

local bindingScale = options.bindingScale or 1
local bindingPosition = options.overrideBindingPosition or CaerdonWardrobeConfig.Binding.Position
local xOffset = 1
if options.bindingOffsetX ~= nil then
xOffset = options.bindingOffsetX
end
local newWidth = bindsOnText:GetStringWidth()
if newWidth > button:GetWidth() then
newWidth = button:GetWidth()
end
local newHeight = bindsOnText:GetHeight()

local yOffset = 2
if options.bindingOffsetY ~= nil then
yOffset = options.bindingOffsetY
end
bindsOnText:ClearAllPoints()
bindsOnText:SetSize(newWidth, newHeight)

local hasCount = (button.count and button.count > 1) or options.hasCount

if string.find(bindingPosition, "BOTTOM") then
if hasCount then
yOffset = options.itemCountOffset or 15
end
end
local bindingScale = options.bindingScale or 1
local bindingPosition = options.overrideBindingPosition or CaerdonWardrobeConfig.Binding.Position
local xOffset = 1
if options.bindingOffsetX ~= nil then
xOffset = options.bindingOffsetX
end

if string.find(bindingPosition, "TOP") then
yOffset = yOffset * -1
end
local yOffset = 2
if options.bindingOffsetY ~= nil then
yOffset = options.bindingOffsetY
end

if string.find(bindingPosition, "RIGHT") then
xOffset = xOffset * -1
local hasCount = (button.count and button.count > 1) or options.hasCount

if string.find(bindingPosition, "BOTTOM") then
if hasCount then
yOffset = options.itemCountOffset or 15
end
end

if options and options.relativeFrame then
bindsOnText:SetAllPoints(options.relativeFrame, xOffset, yOffset)
else
bindsOnText:SetPoint(bindingPosition, xOffset, yOffset)
end
if string.find(bindingPosition, "TOP") then
yOffset = yOffset * -1
end

if string.find(bindingPosition, "RIGHT") then
xOffset = xOffset * -1
end

if options and options.relativeFrame then
bindsOnText:SetAllPoints(options.relativeFrame, xOffset, yOffset)
else
bindsOnText:SetPoint(bindingPosition, xOffset, yOffset)
end

if(options.bindingScale) then
Expand Down Expand Up @@ -698,65 +747,8 @@ function CaerdonWardrobeMixin:ClearButton(button)
end
end

function CaerdonWardrobeMixin:CreateButtonIfNeeded(originalButton, item, feature, locationInfo, options)
local button = originalButton.caerdonButton

if not button then
button = CreateFrame("Frame", nil, originalButton)
button.searchOverlay = originalButton.searchOverlay
originalButton.caerdonButton = button
end

-- Make sure it's sitting in front of the frame it's going to overlay
local levelCheckFrame = originalButton
if options and options.relativeFrame then
if options.relativeFrame:GetObjectType() == "Texture" then
levelCheckFrame = options.relativeFrame:GetParent()
else
levelCheckFrame = options.relativeFrame
end
end

if levelCheckFrame then
button:SetFrameStrata(levelCheckFrame:GetFrameStrata())
button:SetFrameLevel(levelCheckFrame:GetFrameLevel() + 1)
end

if options and not options.fixedStatusPosition and not options.fixedBindingPosition then
button:ClearAllPoints()
button:SetSize(0,0)

if options and options.relativeFrame then
button:SetAllPoints(options.relativeFrame)
else
button:SetAllPoints(originalButton)
end
end

local mogStatus = button.mogStatus
if not mogStatus then
local mogStatusBackground = button:CreateTexture(nil, "ARTWORK", nil, 1)
mogStatus = button:CreateTexture(nil, "ARTWORK", nil, 2)
mogStatus.mogStatusBackground = mogStatusBackground
button.mogStatus = mogStatus
end

local bindsOnText = button.bindsOnText
if not bindsOnText then
bindsOnText = button:CreateFontString(nil, "ARTWORK", "SystemFont_Outline_Small") -- TODO: Note: placing directly on button to enable search fade - need to check on other addons
button.bindsOnText = bindsOnText
end

local newWidth = bindsOnText:GetStringWidth()
if newWidth > button:GetWidth() then
newWidth = button:GetWidth()
end
local newHeight = bindsOnText:GetHeight()
bindsOnText:SetSize(newWidth, newHeight)
end

function CaerdonWardrobeMixin:UpdateButton(button, item, feature, locationInfo, options)
self:CreateButtonIfNeeded(button, item, feature, locationInfo, options)
self:SetupCaerdonButton(button, item, feature, locationInfo, options)

if item == nil then
self:ClearButton(button)
Expand Down Expand Up @@ -992,4 +984,4 @@ end
function CaerdonWardrobeMixin:UPDATE_EXPANSION_LEVEL()
-- Can change while logged in!
self:RefreshItems()
end
end
2 changes: 1 addition & 1 deletion CaerdonWardrobe.toc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Title: Caerdon Wardrobe
## Notes: Shows BOE / BOA, openable, and unlearned pets, toys, mounts and wardrobe indicator on bank / bag / auction / merchant / guild bank / loot frame / loot roll / encounter journal slots
## Author: Caerdon
## Version: v3.6.2
## Version: v3.6.3
## SavedVariables: CaerdonWardrobeConfig
## OptionalDeps: WoWUnit, AdiBags, AngrierWorldQuests, ArkInventory, Baganator, Bagnon, BaudBag, BetterBags, cargBags_Nivaya, Combuctor, ElvUI, Inventorian, KkthnxUI, LiteBag, Pawn, Skillet, Sorted, VenturePlan, WorldQuestsList, WorldQuestTracker, ZygorGuidesViewer

Expand Down
12 changes: 5 additions & 7 deletions external/Baganator/Core.Baganator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ end
local options = {
fixedStatusPosition = true,
statusProminentSize = 16,
-- forceGearSetsAsIcon = false
}

function BaganatorMixin:Init()
Expand All @@ -35,6 +34,8 @@ function BaganatorMixin:Init()
CaerdonWardrobe:UpdateButton(itemButton, item, self, { locationKey = details.itemLink }, options)
end

-- Ideally, we'd only show if we have a status to show, but UpdateButton is running asynchronously, so we can't account for it here.
-- Unfortunately, this means that mog status will override options in Baganator's icon corner setup even if it doesn't have anything to show.
return shouldShow
end, function(itemButton)
-- Create Caerdon Button with nil item to create caerdonButton ahead of time for all slots
Expand All @@ -61,17 +62,14 @@ function BaganatorMixin:Init()
end
CaerdonWardrobe:UpdateButton(itemButton, item, self, { locationKey = details.itemLink }, options)
end

-- if shouldShow and (bindsOnText:GetText() == "" or bindsOnText:GetText() == nil) then
-- shouldShow = false
-- end

-- return shouldShow
-- Ideally, we'd only show if we have a binding to show, but UpdateButton is running asynchronously, so we can't account for it here.
-- Unfortunately, this means that binding will override options in Baganator's icon corner setup even if it doesn't have anything to show.
return true
end, function(itemButton)
CaerdonWardrobe:UpdateButton(itemButton, nil, self, nil, options)
return itemButton.caerdonButton.bindsOnText
end, {corner = "bottom_right", priority = 2})
end, {corner = "bottom_left", priority = 2})
end

function BaganatorMixin:GetTooltipData(item, locationInfo)
Expand Down
5 changes: 3 additions & 2 deletions types/RecipeMixin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,16 @@ end
-- local recipeName, recipeID = C_Item.GetItemSpell(caerdonItem:GetItemLink())
-- print(recipeName or "" .. ": " .. tostring(recipeID))

local spellName, spellID = C_Item.GetItemSpell(caerdonItem:GetItemLink())
-- local spellName, spellID = C_Item.GetItemSpell(caerdonItem:GetItemLink())
-- print(spellName)

if caerdonItem.extraData and caerdonItem.extraData.recipeInfo then
itemType.recipe = caerdonItem.extraData.recipeInfo
end

if not itemType.recipe then
local recipeName = string.gsub(caerdonItem:GetItemName(), "Recipe: ", "")
local checkName = caerdonItem:GetItemName()
local recipeName = string.gsub(checkName or "", "Recipe: ", "")
recipeName = string.gsub(recipeName, "Schematic: ", "")
recipeName = string.gsub(recipeName, "Design: ", "")
recipeName = string.gsub(recipeName, "Plans: ", "")
Expand Down

0 comments on commit 059c1f4

Please sign in to comment.