Skip to content

Commit d2a1b11

Browse files
committed
Port Transmog feature from retail AL
1 parent 0fbfa7f commit d2a1b11

File tree

4 files changed

+372
-207
lines changed

4 files changed

+372
-207
lines changed

AtlasLootClassic/AtlasLootClassic.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Core\TooltipScan.lua
5858
Core\ItemQuery.lua
5959
Core\ItemString.lua
6060
Core\TargetScan.lua
61+
Core\Transmog.lua
6162

6263
MiniMapButton.lua
6364

AtlasLootClassic/Core/Transmog.lua

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
local _G = _G
2+
local AtlasLoot = _G.AtlasLoot
3+
local Transmog = {}
4+
AtlasLoot.Transmog = Transmog
5+
6+
local Proto = {}
7+
8+
-- Functions
9+
local next, pairs = _G.next, _G.pairs
10+
11+
-- WoW
12+
local TransmogGetItemInfo, GetSourceInfo, PlayerHasTransmogItemModifiedAppearance = C_TransmogCollection.GetItemInfo, C_TransmogCollection.GetSourceInfo, C_TransmogCollection.PlayerHasTransmogItemModifiedAppearance
13+
local TRANSMOG_UPDATE_EVENT = "TRANSMOG_SOURCE_COLLECTABILITY_UPDATE" -- sourceID, canCollect
14+
15+
--[[
16+
nil cannot collect
17+
false can collect, not collected
18+
true can collect, collected
19+
]]
20+
function Proto:IsItemUnlocked(itemID, sourceID, callbackFunc, callbackArg)
21+
if not itemID and not sourceID then return end
22+
local isInfoReady, canCollect
23+
if itemID then
24+
_, sourceID = TransmogGetItemInfo(itemID)
25+
end
26+
if not sourceID then return end
27+
-- TODO: FIX when API works
28+
-- canCollect seems broken in MoP Classic? Just assume that it is collectable if info exists, for now.
29+
local isInfoReady = GetSourceInfo(sourceID)
30+
canCollect = isInfoReady.isValidSourceForPlayer
31+
32+
if isInfoReady then
33+
if canCollect then
34+
canCollect = PlayerHasTransmogItemModifiedAppearance(sourceID)
35+
else
36+
canCollect = nil
37+
end
38+
if callbackFunc then
39+
callbackFunc(callbackArg, canCollect)
40+
else
41+
return canCollect
42+
end
43+
else
44+
self:AddUnknownItem(sourceID, callbackFunc, callbackArg)
45+
end
46+
end
47+
48+
function Proto:AddUnknownItem(sourceID, callbackFunc, callbackArg)
49+
if not next(self.itemList) then
50+
self.frame:RegisterEvent(TRANSMOG_UPDATE_EVENT)
51+
end
52+
self.itemList[sourceID] = { callbackFunc, callbackArg }
53+
end
54+
55+
function Proto:Clear()
56+
self.itemList = {}
57+
self.frame:UnregisterEvent(TRANSMOG_UPDATE_EVENT)
58+
end
59+
60+
local function OnEvent(self, event, sourceID, canCollect)
61+
if sourceID and self.obj.itemList[sourceID] then
62+
self.obj:IsItemUnlocked(nil, sourceID, self.obj.itemList[sourceID][1], self.obj.itemList[sourceID][2])
63+
self.obj.itemList[sourceID] = nil
64+
end
65+
if not next(self.obj.itemList) then
66+
self:UnregisterEvent(TRANSMOG_UPDATE_EVENT)
67+
end
68+
end
69+
70+
function Transmog:New()
71+
local tab = {}
72+
73+
-- Add protos
74+
for k,v in pairs(Proto) do
75+
tab[k] = v
76+
end
77+
78+
tab.itemList = {}
79+
80+
81+
tab.frame = CreateFrame("FRAME")
82+
tab.frame.obj = tab
83+
tab.frame:SetScript("OnEvent", OnEvent)
84+
85+
return tab
86+
end

AtlasLootClassic/GUI/GUI.lua

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ local function GameVersionSelect_OnClick(self, mouseButton)
444444
return button
445445
end
446446

447-
-- Create game version buttons from newest xpac to oldest
448-
local gameVersions = {}
447+
-- Create game version buttons from newest xpac to oldest
448+
local gameVersions = {}
449449
if AtlasLoot:GameVersion_GE(AtlasLoot.MOP_VERSION_NUM) then
450450
table.insert(gameVersions, AtlasLoot.MOP_VERSION_NUM)
451451
end
@@ -460,12 +460,12 @@ local function GameVersionSelect_OnClick(self, mouseButton)
460460
end
461461
table.insert(gameVersions, AtlasLoot.CLASSIC_VERSION_NUM)
462462

463-
local GVButton = createGVButton(gameVersions[1], GAME_VERSION_TEXTURES[gameVersions[1]])
463+
local GVButton = createGVButton(gameVersions[1], GAME_VERSION_TEXTURES[gameVersions[1]])
464464
GVButton:SetPoint("TOP", frame, "TOP", 0, -5)
465-
for i = 2, #gameVersions do
466-
GVButton = createGVButton(gameVersions[i], GAME_VERSION_TEXTURES[gameVersions[i]])
467-
GVButton:SetPoint("TOP", frame.buttons[#frame.buttons-1], "BOTTOM", 0, -buttonGap)
468-
end
465+
for i = 2, #gameVersions do
466+
GVButton = createGVButton(gameVersions[i], GAME_VERSION_TEXTURES[gameVersions[i]])
467+
GVButton:SetPoint("TOP", frame.buttons[#frame.buttons-1], "BOTTOM", 0, -buttonGap)
468+
end
469469

470470
frame:SetSize(width, height + (#frame.buttons * 32) + ((#frame.buttons-1) * buttonGap))
471471
frame:Hide()
@@ -550,6 +550,36 @@ local function GUI_InfoOnLeave(self)
550550
GetAlTooltip():Hide()
551551
end
552552

553+
-- Transmog
554+
local function TransmogButton_Refresh(self)
555+
self.texture:SetDesaturated(not AtlasLoot.db.GUI.transmogHighlighter)
556+
557+
if GUI.frame.contentFrame.shownFrame and GUI.frame.contentFrame.shownFrame.OnTransMogUpdate then
558+
GUI.frame.contentFrame.shownFrame.OnTransMogUpdate()
559+
end
560+
end
561+
562+
local function TransmogButton_OnClick(self, button)
563+
AtlasLoot.db.GUI.transmogHighlighter = not AtlasLoot.db.GUI.transmogHighlighter
564+
TransmogButton_Refresh(self)
565+
end
566+
567+
local function TransmogButton_OnEnter(self, owner)
568+
local tooltip = GetAlTooltip()
569+
tooltip:ClearLines()
570+
if owner and type(owner) == "table" then
571+
tooltip:SetOwner(owner[1], owner[2], owner[3], owner[4])
572+
else
573+
tooltip:SetOwner(self, "ANCHOR_RIGHT", -(self:GetWidth() * 0.5), 5)
574+
end
575+
tooltip:AddLine(TRANSMOGRIFY)
576+
tooltip:Show()
577+
end
578+
579+
local function TransmogButton_OnLeave(self)
580+
GetAlTooltip():Hide()
581+
end
582+
553583
-- ################################
554584
-- DropDowns/Select
555585
-- ################################
@@ -1185,6 +1215,10 @@ function GUI:Create()
11851215
frame.contentFrame.contentPhaseButton:SetScript("OnClick", ContentPhaseButton_OnClick)
11861216
frame.contentFrame.contentPhaseButton.mainButton = true
11871217

1218+
frame.contentFrame.contentPhaseButton.texture = frame.contentFrame.contentPhaseButton:CreateTexture(frameName.."-contentPhaseButton-texture","ARTWORK")
1219+
frame.contentFrame.contentPhaseButton.texture:SetAllPoints(frame.contentFrame.contentPhaseButton)
1220+
frame.contentFrame.contentPhaseButton.texture:SetTexture(AtlasLoot.Data.ContentPhase:GetActivePhaseTexture())
1221+
11881222
-- Sound
11891223
frame.contentFrame.soundsButton = GUI.CreateButton()
11901224
frame.contentFrame.soundsButton:SetPoint("RIGHT", frame.contentFrame.modelButton, "LEFT", -5, 0)
@@ -1243,9 +1277,20 @@ function GUI:Create()
12431277
frame.contentFrame.clasFilterButton.texture:SetAllPoints(frame.contentFrame.clasFilterButton)
12441278
--frame.contentFrame.clasFilterButton.texture:SetTexture(CLASS_ICON_PATH[PLAYER_CLASS_FN])
12451279

1246-
frame.contentFrame.contentPhaseButton.texture = frame.contentFrame.contentPhaseButton:CreateTexture(frameName.."-contentPhaseButton-texture","ARTWORK")
1247-
frame.contentFrame.contentPhaseButton.texture:SetAllPoints(frame.contentFrame.contentPhaseButton)
1248-
frame.contentFrame.contentPhaseButton.texture:SetTexture(AtlasLoot.Data.ContentPhase:GetActivePhaseTexture())
1280+
-- Transmog
1281+
frame.contentFrame.transmogButton = CreateFrame("Button", frameName.."-transmofButton")
1282+
frame.contentFrame.transmogButton:SetParent(frame.contentFrame)
1283+
frame.contentFrame.transmogButton:RegisterForClicks("LeftButtonUp", "RightButtonUp");
1284+
frame.contentFrame.transmogButton:SetWidth(25)
1285+
frame.contentFrame.transmogButton:SetHeight(25)
1286+
frame.contentFrame.transmogButton:SetPoint("LEFT", frame.contentFrame.clasFilterButton, "RIGHT", 5, 0)
1287+
frame.contentFrame.transmogButton:SetScript("OnClick", TransmogButton_OnClick)
1288+
frame.contentFrame.transmogButton:SetScript("OnEnter", TransmogButton_OnEnter)
1289+
frame.contentFrame.transmogButton:SetScript("OnLeave", TransmogButton_OnLeave)
1290+
frame.contentFrame.transmogButton.texture = frame.contentFrame.transmogButton:CreateTexture(frameName.."-transmogButton-texture","ARTWORK")
1291+
frame.contentFrame.transmogButton.texture:SetAllPoints(frame.contentFrame.transmogButton)
1292+
frame.contentFrame.transmogButton.texture:SetTexture("Interface\\Icons\\INV_Arcane_Orb")
1293+
frame.contentFrame.transmogButton.texture:SetDesaturated(not AtlasLoot.db.GUI.transmogHighlighter)
12491294

12501295
ContentPhaseButton_Refresh(frame.contentFrame.contentPhaseButton)
12511296

0 commit comments

Comments
 (0)