Skip to content

Commit

Permalink
Fixed issue with settings checkboxes and improved AH / overall item d…
Browse files Browse the repository at this point in the history
…etection
  • Loading branch information
Caerdon committed Nov 27, 2022
1 parent 56aea40 commit 2354669
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 46 deletions.
59 changes: 59 additions & 0 deletions CaerdonAPI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,64 @@ end
-- return classArmor
-- end

function CaerdonAPIMixin:CompareCIMI(feature, item, bag, slot)
if CaerdonWardrobeConfig.Debug.Enabled and CanIMogIt and not item:IsItemEmpty() and item:GetCaerdonItemType() == CaerdonItemType.Equipment then
item:ContinueOnItemLoad(function ()
local itemData = item:GetItemData()
local transmogInfo = itemData:GetTransmogInfo()
local isReady, mogStatus, bindingStatus, bindingResult = item:GetCaerdonStatus(feature, { bag = bag, slot = slot })

local mismatch = true

local modifiedText, compareText = CanIMogIt:GetTooltipText(item:GetItemLink(), bag, slot)
if compareText == CanIMogIt.KNOWN or compareText == CanIMogIt.KNOWN_BOE or compareText == CanIMogIt.KNOWN_BY_ANOTHER_CHARACTER or compareText == CanIMogIt.KNOWN_BY_ANOTHER_CHARACTER_BOE or
compareText == CanIMogIt.KNOWN_BUT_TOO_LOW_LEVEL or compareText == CanIMogIt.KNOWN_BUT_TOO_LOW_LEVEL_BOE then
if mogStatus == "collected" or mogStatus == "sellable" or mogStatus == "upgrade" or mogStatus == "" then
mismatch = false
end
elseif compareText == CanIMogIt.KNOWN_FROM_ANOTHER_ITEM_BUT_TOO_LOW_LEVEL or compareText == CanIMogIt.KNOWN_FROM_ANOTHER_ITEM_BUT_TOO_LOW_LEVEL_BOE then
if mogStatus == "lowSkillPlus" then
mismatch = false
end
elseif compareText == CanIMogIt.NOT_TRANSMOGABLE or compareText == CanIMogIt.NOT_TRANSMOGABLE_BOE then
if mogStatus == "collected" or mogStatus == "sellable" or mogStatus == "upgrade" then
mismatch = false
end
elseif compareText == CanIMogIt.UNKNOWABLE_SOULBOUND then
if not transmogInfo.needsItem and transmogInfo.otherNeedsItem then
if mogStatus == "collected" or mogStatus == "sellable" or mogStatus == "upgrade" then
mismatch = false
end
end
elseif compareText == CanIMogIt.UNKNOWABLE_BY_CHARACTER then
if mogStatus == "other" or mogStatus == "otherPlus" then
mismatch = false
end
elseif compareText == CanIMogIt.KNOWN_FROM_ANOTHER_ITEM_AND_CHARACTER or compareText == CanIMogIt.KNOWN_FROM_ANOTHER_ITEM_AND_CHARACTER_BOE then
if mogStatus == "otherPlus" then
mismatch = false
end
elseif compareText == CanIMogIt.KNOWN_FROM_ANOTHER_ITEM or compareText == CanIMogIt.KNOWN_FROM_ANOTHER_ITEM_BOE then
if mogStatus == "ownPlus" or mogStatus == "lowSkill" then
mismatch = false
end
elseif compareText == CanIMogIt.UNKNOWN then
if mogStatus == "lowSkill" or mogStatus == "own" then
mismatch = false
end
elseif compareText == nil then
print("Caerdon (Debug Mode): Close and reopen bags. CIMI data not yet ready: " .. item:GetItemLink())
mismatch = false
else
print("Caerdon (Debug Mode): CIMI Unknown - " .. item:GetItemLink() .. ": " .. tostring(compareText) .. " vs. " .. mogStatus)
end

if mismatch then
print("Caerdon (Debug Mode): CIMI Mismatch - " .. item:GetItemLink() .. " " .. tostring(compareText) .. " vs. " .. mogStatus)
end
end)
end
end

CaerdonAPI = CreateFromMixins(CaerdonAPIMixin)
CaerdonAPI:OnLoad()
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.3.1
## Version: v3.3.2
## SavedVariables: CaerdonWardrobeConfig
## OptionalDeps: WagoAnalytics, WoWUnit, AdiBags, AngrierWorldQuests, ArkInventory, Bagnon, BaudBag, cargBags_Nivaya, Combuctor, ElvUI, Inventorian, KkthnxUI, Pawn, Sorted, VenturePlan, WorldQuestsList, WorldQuestTab, WorldQuestTracker, ZygorGuidesViewer

Expand Down
1 change: 1 addition & 0 deletions config/Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function CaerdonWardrobeConfigMixin:OnEvent(event, ...)
self:UnregisterEvent(event);

if not CaerdonWardrobeConfig or CaerdonWardrobeConfig.Version ~= NS:GetDefaultConfig().Version then
print("Caerdon: Old settings detected - updating to defaults. Please check your settings!")
CaerdonWardrobeConfig = CopyTable(NS:GetDefaultConfig())
end

Expand Down
8 changes: 7 additions & 1 deletion config/ConfigPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ function CaerdonWardrobeConfigPanelMixin:ConfigureCheckboxNew(info)
end)
checkbox.label = _G[checkbox:GetName() .. "Text"]
checkbox.label:SetText(info.text)
checkbox:SetChecked(section[info.configValue] or defaultSection[info.configValue])

local isChecked = section[info.configValue]
if isChecked == nil then
isChecked = defaultSection[info.configValue]
end

checkbox:SetChecked(isChecked)
end

function CaerdonWardrobeConfigPanelMixin:ConfigureDropdownNew(info, dropdownValues)
Expand Down
78 changes: 69 additions & 9 deletions features/Auction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ end

-- TODO: Look into ScrollUtil.AddAcquiredFrameCallback and friends for all the ScrollBox integrations
function AuctionMixin:Init(frame)
self.waitingForItemKeyInfo = {}
self.auctionContinuableContainer = ContinuableContainer:Create()
self.shouldHookAuction = true

return {
"AUCTION_HOUSE_SHOW",
"ITEM_KEY_ITEM_INFO_RECEIVED"
-- "AUCTION_HOUSE_BROWSE_RESULTS_UPDATED",
-- "OWNED_AUCTIONS_UPDATED"
}
Expand All @@ -30,6 +32,20 @@ function AuctionMixin:AUCTION_HOUSE_SHOW()
end
end

function AuctionMixin:ITEM_KEY_ITEM_INFO_RECEIVED(itemID)
local processQueue = self.waitingForItemKeyInfo[itemID]
if processQueue then
for locationKey, processInfo in pairs(processQueue) do
local itemKeyInfo = C_AuctionHouse.GetItemKeyInfo(processInfo.itemKey)
if itemKeyInfo then
self:ProcessItemKeyInfo(processInfo.itemKey, itemKeyInfo, processInfo.frame)
end
end

self.waitingForItemKeyInfo[itemID] = nil
end
end

function AuctionMixin:OnAllAuctionsInitializedFrame(auctionFrame, frame, elementData)
local button = frame
local item
Expand Down Expand Up @@ -58,9 +74,9 @@ function AuctionMixin:OnAllAuctionsInitializedFrame(auctionFrame, frame, element
})
end

function AuctionMixin:OnInitializedFrame(auctionFrame, frame, elementData)
local button = frame
function AuctionMixin:ProcessItemKeyInfo(itemKey, itemKeyInfo, button)
local item
local rowData = button.rowData

local options = {
overrideStatusPosition = "LEFT",
Expand All @@ -70,27 +86,71 @@ function AuctionMixin:OnInitializedFrame(auctionFrame, frame, elementData)
-- relativeFrame=cell.Icon
}

if not elementData then return end
if not frame.rowData then return end

local itemKey = frame.rowData.itemKey
local itemKeyInfo = C_AuctionHouse.GetItemKeyInfo(itemKey)

if itemKeyInfo and itemKeyInfo.battlePetLink then
item = CaerdonItem:CreateFromItemLink(itemKeyInfo.battlePetLink)
CaerdonWardrobe:UpdateButton(button, item, self, {
locationKey = format("pet-%s", itemKeyInfo.battlePetLink),
itemKey = itemKey
}, options)
elseif rowData.appearanceLink then
-- Using appearance link if it's available due to not getting full item link from AH in any other way right now.
-- This fixes Nimble Hexweave Cloak, for example, but doesn't fix Ceremonious Greaves (which doesn't have appearanceLink)
local appearanceSourceID = string.match(rowData.appearanceLink, ".*transmogappearance:(%d*)")
local category, itemAppearanceID, canHaveIllusion, icon, isCollected, itemLink, transmoglink, sourceType, itemSubClass =
C_TransmogCollection.GetAppearanceSourceInfo(appearanceSourceID)
item = CaerdonItem:CreateFromItemLink(itemLink, { appearanceSourceID = appearanceSourceID, appearanceID = itemAppearanceID })

CaerdonAPI:CompareCIMI(self, item)

CaerdonWardrobe:UpdateButton(button, item, self, {
locationKey = format("%d-%d-%d-%d", itemKey.itemID, itemKey.itemLevel, itemKey.itemSuffix, ((itemKeyInfo and itemKeyInfo.quality) or 0)),
itemKey = itemKey
}, options)
else
item = CaerdonItem:CreateFromItemID(itemKey.itemID)
-- local requiredLevel = C_AuctionHouse.GetItemKeyRequiredLevel(itemKey)
-- local tooltipInfo = C_TooltipInfo and C_TooltipInfo.GetItemKey(itemKey.itemID, itemKey.itemLevel, itemKey.itemSuffix, requiredLevel)
-- local tooltipData = CaerdonAPI:ProcessTooltipData(tooltipInfo)
local tooltipData = nil

if tooltipData then
if tooltipData.isRetrieving then -- shouldn't hit here because of previous check on GetItemKeyInfo... but just in case.
C_Timer.After(0.1, function () -- TODO: Switch to a waiting to process queue tied to TOOLTIP_DATA_UPDATE
self:ProcessItemKeyInfo(itemKey, itemKeyInfo, button)
end)
return
elseif tooltipData.hyperlink then
item = CaerdonItem:CreateFromItemLink(tooltipData.hyperlink)
end
else
item = CaerdonItem:CreateFromItemID(itemKey.itemID)
end

CaerdonAPI:CompareCIMI(self, item)

CaerdonWardrobe:UpdateButton(button, item, self, {
locationKey = format("%d-%d-%d-%d", itemKey.itemID, itemKey.itemLevel, itemKey.itemSuffix, ((itemKeyInfo and itemKeyInfo.quality) or 0)),
itemKey = itemKey
}, options)
end
end

function AuctionMixin:OnInitializedFrame(auctionFrame, frame, elementData)
if not elementData then return end
if not frame.rowData then return end

local itemKey = frame.rowData.itemKey
local itemKeyInfo = C_AuctionHouse.GetItemKeyInfo(itemKey)
if not itemKeyInfo then
local processKey = format("%d-%d-%d-%d", itemKey.itemID, itemKey.itemLevel, itemKey.itemSuffix, itemKey.battlePetSpeciesID)
self.waitingForItemKeyInfo[itemKey.itemID] = self.waitingForItemKeyInfo[itemKey.itemID] or {}
self.waitingForItemKeyInfo[itemKey.itemID][processKey] = { itemKey = itemKey, frame = frame }
CaerdonWardrobe:ClearButton(frame)
return
end

self:ProcessItemKeyInfo(itemKey, itemKeyInfo, frame)
end

function AuctionMixin:GetTooltipData(item, locationInfo)
local itemKey = locationInfo.itemKey
if itemKey and itemKey.itemID and itemKey.itemLevel and itemKey.itemSuffix then
Expand Down
3 changes: 3 additions & 0 deletions features/Bags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ function BagsMixin:OnUpdateItems(frame)
local slot = button:GetID()

local item = CaerdonItem:CreateFromBagAndSlot(bag, slot)

CaerdonAPI:CompareCIMI(self, item, bag, slot)

CaerdonWardrobe:UpdateButton(button, item, self, {
bag = bag,
slot = slot
Expand Down
Loading

0 comments on commit 2354669

Please sign in to comment.