Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit d933402

Browse files
committed
C_Everywhere update
1 parent ba530bb commit d933402

21 files changed

+97
-467
lines changed

.gitmodules

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
[submodule "libs/WildAddon-1.0"]
2-
path = libs/WildAddon-1.0
3-
url = https://github.com/Jaliborc/WildAddon-1.0.git
41
[submodule "libs/MutexDelay-1.0"]
52
path = libs/MutexDelay-1.0
63
url = https://github.com/Jaliborc/MutexDelay-1.0.git
7-
[submodule "libs/C_Everywhere"]
8-
path = libs/C_Everywhere
9-
url = https://github.com/Jaliborc/C_Everywhere.git
104
[submodule "libs/Unfit-1.0"]
115
path = libs/Unfit-1.0
126
url = https://github.com/Jaliborc/Unfit-1.0.git

Wildpants.lua

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
local ADDON, Addon = ...
77
local Addon = LibStub('WildAddon-1.0'):NewAddon(ADDON, Addon, 'LibItemCache-2.0')
8+
Addon.NumBags = NUM_TOTAL_EQUIPPED_BAG_SLOTS or NUM_BAG_SLOTS
89
Addon.IsRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
910
Addon.IsClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
1011
Addon.Version = GetAddOnMetadata(ADDON, 'Version')

api/events.lua

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
local ADDON, Addon = ...
1515
local Events = Addon:NewModule('Events')
16+
local C = LibStub('C_Everywhere').Container
1617

1718

1819
--[[ Events ]]--
@@ -67,7 +68,7 @@ end
6768
--[[ API ]]--
6869

6970
function Events:UpdateBags()
70-
for bag = 1, NUM_BAG_SLOTS do
71+
for bag = 1, Addon.NumBags do
7172
if not self:UpdateSize(bag) then
7273
self:UpdateType(bag)
7374
end
@@ -79,7 +80,7 @@ function Events:UpdateBags()
7980
end
8081

8182
function Events:UpdateBankBags()
82-
for bag = 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
83+
for bag = 1, Addon.NumBags + NUM_BANKBAGSLOTS do
8384
if not self:UpdateSize(bag) then
8485
self:UpdateType(bag)
8586
end
@@ -88,10 +89,10 @@ end
8889

8990
function Events:UpdateSize(bag)
9091
local old = self.sizes[bag]
91-
local new = GetContainerNumSlots(bag) or 0
92+
local new = C.GetContainerNumSlots(bag) or 0
9293

9394
if old ~= new then
94-
local _, kind = GetContainerNumFreeSlots(bag)
95+
local _, kind = C.GetContainerNumFreeSlots(bag)
9596
self.types[bag] = kind
9697
self.sizes[bag] = new
9798
self.queue[bag] = nil
@@ -102,7 +103,7 @@ end
102103

103104
function Events:UpdateType(bag)
104105
local old = self.types[bag]
105-
local _, new = GetContainerNumFreeSlots(bag)
106+
local _, new = C.GetContainerNumFreeSlots(bag)
106107

107108
if old ~= new then
108109
self.types[bag] = new

classes/bag.lua

+20-20
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ end
8080

8181
function Bag:OnClick(button)
8282
if button == 'RightButton' and ContainerFrame1FilterDropDown then
83-
if not self:IsReagents() and self:GetInfo().owned then
83+
if not self:IsReagents() and self.info.owned then
8484
ContainerFrame1FilterDropDown:SetParent(self)
8585
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
8686
ToggleDropDownMenu(1, nil, ContainerFrame1FilterDropDown, self, 0, 0)
8787
end
8888
elseif self:IsPurchasable() then
8989
self:Purchase()
90-
elseif CursorHasItem() and not self:GetInfo().cached then
90+
elseif CursorHasItem() and not self.info.cached then
9191
if self:IsBackpack() then
9292
PutItemInBackpack()
9393
else
94-
PutItemInBag(self:GetInfo().slot)
94+
PutItemInBag(self.info.slot)
9595
end
9696
elseif self:CanToggle() then
9797
self:Toggle()
@@ -101,9 +101,9 @@ function Bag:OnClick(button)
101101
end
102102

103103
function Bag:OnDrag()
104-
if self:IsCustomSlot() and not self:GetInfo().cached then
104+
if self:IsCustomSlot() and not self.info.cached then
105105
PlaySound(SOUNDKIT.IG_BACKPACK_OPEN)
106-
PickupBagFromSlot(self:GetInfo().slot)
106+
PickupBagFromSlot(self.info.slot)
107107
end
108108
end
109109

@@ -134,7 +134,7 @@ function Bag:RegisterEvents()
134134
self:RegisterMessage('CACHE_BANK_CLOSED', 'RegisterEvents')
135135
end
136136

137-
if not self:GetInfo().cached then
137+
if not self.info.cached then
138138
if self:IsReagents() then
139139
self:RegisterEvent('REAGENTBANK_PURCHASED', 'Update')
140140
elseif self:IsCustomSlot() then
@@ -162,21 +162,22 @@ end
162162
function Bag:Update()
163163
local info = self:GetInfo()
164164

165+
self.info = info
165166
self.FilterIcon:SetShown(not info.cached)
166167
self.Count:SetText(info.free and info.free > 0 and info.free or '')
167168
self:UpdateCursor()
168169
self:UpdateToggle()
169170
self:UpdateLock()
170171

171-
if self:IsBackpack() or self:IsBank() then
172+
if self:IsBackpack() or self:IsBank() then
172173
self:SetIcon('Interface/Buttons/Button-Backpack-Up')
173174
elseif self:IsReagents() then
174175
self:SetIcon('Interface/Icons/Achievement_GuildPerk_BountifulBags')
175176
elseif self:IsKeyring() then
176177
self:SetIcon('Interface/ContainerFrame/KeyRing-Bag-Icon')
177178
else
178179
self:SetIcon(info.icon or 'Interface/PaperDoll/UI-PaperDoll-Slot-Bag')
179-
self.link = info.link
180+
self.link = info.link
180181

181182
if not info.icon then
182183
self.Count:SetText('')
@@ -187,7 +188,7 @@ function Bag:Update()
187188
local id = self:GetID()
188189
for i, atlas in ipairs(self.FILTER_ICONS) do
189190
local active = C_Container and (id > 0 and C_Container.GetBagSlotFlag(id, 2^i)) or
190-
GetBagSlotFlag and (self:IsBankBag() and GetBankBagSlotFlag(id - NUM_BAG_SLOTS, i) or GetBagSlotFlag(id, i))
191+
GetBagSlotFlag and (self:IsBankBag() and GetBankBagSlotFlag(id - NUM_BAG_SLOTS, i) or GetBagSlotFlag(id, i))
191192
if active then
192193
return self.FilterIcon.Icon:SetAtlas(atlas)
193194
end
@@ -196,13 +197,13 @@ function Bag:Update()
196197
end
197198

198199
function Bag:UpdateCursor()
199-
if not self:IsCustomSlot() then
200-
if CursorCanGoInSlot(self:GetInfo().slot) then
200+
--[[if not self:IsCustomSlot() then
201+
if CursorCanGoInSlot(self.info.slot) then
201202
self:LockHighlight()
202203
else
203204
self:UnlockHighlight()
204205
end
205-
end
206+
end--]]
206207
end
207208

208209
function Bag:UpdateToggle()
@@ -223,7 +224,7 @@ function Bag:UpdateTooltip()
223224
GameTooltip:SetText(self:IsReagents() and REAGENT_BANK or BANK_BAG_PURCHASE, 1, 1, 1)
224225
GameTooltip:AddLine(L.TipPurchaseBag:format(L.Click))
225226

226-
SetTooltipMoney(GameTooltip, self:GetInfo().cost)
227+
SetTooltipMoney(GameTooltip, self.info.cost)
227228
elseif self:IsBackpack() then
228229
GameTooltip:SetText(BACKPACK_TOOLTIP, 1,1,1)
229230
elseif self:IsBank() then
@@ -232,10 +233,10 @@ function Bag:UpdateTooltip()
232233
GameTooltip:SetText(REAGENT_BANK, 1,1,1)
233234
elseif self:IsKeyring() then
234235
GameTooltip:SetText(KEYRING, 1,1,1)
235-
elseif self.link and self:GetInfo().cached then
236+
elseif self.link and self.info.cached then
236237
GameTooltip:SetHyperlink(self.link)
237238
elseif self.link then
238-
GameTooltip:SetInventoryItem('player', ContainerIDToInventoryID(self:GetID()))
239+
GameTooltip:SetInventoryItem('player', self.info.slot)
239240
elseif self:IsBankBag() then
240241
GameTooltip:SetText(BANK_BAG, 1, 1, 1)
241242
else
@@ -287,7 +288,7 @@ function Bag:SetFocus(focus)
287288
end
288289

289290
function Bag:SetIcon(icon)
290-
local color = self:GetInfo().owned and 1 or .1
291+
local color = self.info.owned and 1 or .1
291292
SetItemButtonTexture(self, icon)
292293
SetItemButtonTextureVertexColor(self, 1, color, color)
293294
end
@@ -324,19 +325,18 @@ function Bag:IsCustomSlot()
324325
end
325326

326327
function Bag:CanToggle()
327-
return self:IsBackpack() or self:IsBank() or self:GetInfo().owned
328+
return self:IsBackpack() or self:IsBank() or self.info.owned
328329
end
329330

330331

331332
--[[ Info ]]--
332333

333334
function Bag:IsPurchasable()
334-
local info = self:GetInfo()
335-
return not info.cached and not info.owned
335+
return not self.info.cached and not self.info.owned
336336
end
337337

338338
function Bag:IsToggled()
339-
return self:GetFrame():IsShowingBag(self:GetID()) and self:GetInfo().owned
339+
return self:GetFrame():IsShowingBag(self:GetID()) and self.info.owned
340340
end
341341

342342
function Bag:GetInfo()

classes/bank.lua

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
--]]
55

66
local ADDON, Addon = ...
7+
local C = LibStub('C_Everywhere').Container
78
local Bank = Addon.Frame:NewClass('BankFrame')
89
Bank.Title = LibStub('AceLocale-3.0'):GetLocale(ADDON).TitleBank
910
Bank.Bags = {BANK_CONTAINER}
1011

1112
for slot = 1, NUM_BANKBAGSLOTS do
12-
tinsert(Bank.Bags, slot + (NUM_TOTAL_EQUIPPED_BAG_SLOTS or NUM_BAG_SLOTS))
13+
tinsert(Bank.Bags, slot + Addon.NumBags)
1314
end
1415

1516
function Bank:OnHide()
@@ -18,8 +19,8 @@ function Bank:OnHide()
1819
end
1920

2021
function Bank:SortItems()
21-
if SortBankBags then
22-
SortBankBags()
22+
if C.SortBankBags then
23+
C.SortBankBags()
2324

2425
if self.SortReagents then
2526
self:Delay(.3, 'SortReagents')
@@ -33,7 +34,7 @@ if REAGENTBANK_CONTAINER then
3334
tinsert(Bank.Bags, REAGENTBANK_CONTAINER)
3435

3536
function Bank:SortReagents()
36-
SortReagentBankBags()
37+
C.SortReagentBankBags()
3738
end
3839

3940
function Bank:IsShowingBag(bag)

classes/currency.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
local ADDON, Addon = ...
9-
local L = LibStub('AceLocale-3.0'):GetLocale(ADDON)
9+
local C = LibStub('C_Everywhere').CurrencyInfo
1010
local Currency = Addon.Tipped:NewClass('Currency', 'Button')
1111

1212
function Currency:New(parent)
@@ -23,18 +23,18 @@ function Currency:Set(data)
2323
self:SetText(format('%s|T%s:14:14:2:0%s|t ', data.quantity, data.iconFileID, data.iconArgs or ''))
2424
self.data = data
2525
self:Show()
26-
self:SetWidth(self:GetTextWidth() + 2)
26+
self:SetWidth(self:GetTextWidth() + 2)
2727
end
2828

2929
function Currency:OnClick()
3030
if IsModifiedClick('CHATLINK') then
31-
HandleModifiedItemClick((GetCurrencyLink or C_CurrencyInfo.GetCurrencyLink)(self.data.currencyTypesID, self.data.quantity))
31+
HandleModifiedItemClick(C.GetCurrencyLink(self.data.currencyTypesID, self.data.quantity))
3232
elseif not self:IsCached() then
3333
ToggleCharacter('TokenFrame')
3434
end
3535
end
3636

3737
function Currency:OnEnter()
3838
GameTooltip:SetOwner(self:GetTipAnchor())
39-
GameTooltip:SetCurrencyTokenByID(self.data.currencyTypesID)
39+
GameTooltip:SetBackpackToken(self.data.index)
4040
end

classes/currencyTracker.lua

+14-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
--]]
55

66
local ADDON, Addon = ...
7-
local L = LibStub('AceLocale-3.0'):GetLocale(ADDON)
7+
local C = LibStub('C_Everywhere').CurrencyInfo
88
local CurrencyTracker = Addon.Parented:NewClass('CurrencyTracker', 'Frame')
99

1010
if BackpackTokenFrame then
@@ -20,13 +20,13 @@ function CurrencyTracker:New(parent)
2020
f:SetScript('OnShow', f.RegisterEvents)
2121
f:SetScript('OnHide', f.UnregisterAll)
2222
f:RegisterEvents()
23-
f:SetHeight(24)
23+
f:SetHeight(24)
2424

25-
hooksecurefunc(SetCurrencyBackpack and _G or C_CurrencyInfo, 'SetCurrencyBackpack', function()
26-
if f:IsVisible() then
27-
f:Update()
28-
end
29-
end)
25+
C.hooksecurefunc('SetCurrencyBackpack', function()
26+
if f:IsVisible() then
27+
f:Update()
28+
end
29+
end)
3030
return f
3131
end
3232

@@ -45,14 +45,12 @@ function CurrencyTracker:Update()
4545
end
4646

4747
local function getCurrency(i) -- temporary till bagbrother expansion
48-
if GetBackpackCurrencyInfo then
49-
local name, quantity, icon, id = GetBackpackCurrencyInfo(i)
50-
return name and {
51-
name = name, quantity = quantity, iconFileID = icon, currencyTypesID = id,
52-
iconArgs = tContains(HONOR_POINT_TEXTURES, icon) and ':64:64:0:40:0:40'}
53-
else
54-
return C_CurrencyInfo.GetBackpackCurrencyInfo(i)
48+
local data = C.GetBackpackCurrencyInfo(i)
49+
if data then
50+
data.iconArgs = HONOR_POINT_TEXTURES and tContains(HONOR_POINT_TEXTURES, data.iconFileID) and ':64:64:0:40:0:40'
51+
data.index = i
5552
end
53+
return data
5654
end
5755

5856
function CurrencyTracker:Layout()
@@ -63,15 +61,15 @@ function CurrencyTracker:Layout()
6361
local w = 0
6462
for i = 1, BackpackTokenFrame:GetMaxTokensWatched() do -- safety limit
6563
local data = getCurrency(i)
66-
if data then
64+
if data then
6765
self.buttons[i] = self.buttons[i] or Addon.Currency(self)
6866
self.buttons[i]:SetPoint('LEFT', self.buttons[i-1] or self, i > 1 and 'RIGHT' or 'LEFT')
6967
self.buttons[i]:Set(data)
7068

7169
w = w + self.buttons[i]:GetWidth()
7270
else
7371
break
74-
end
72+
end
7573
end
7674

7775
self:SetWidth(max(w, 2))

classes/inventory.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
--]]
55

66
local ADDON, Addon = ...
7+
local C = LibStub('C_Everywhere').Container
78
local Inventory = Addon.Frame:NewClass('InventoryFrame')
89
Inventory.Title = LibStub('AceLocale-3.0'):GetLocale(ADDON).TitleBags
910
Inventory.Bags = {}
@@ -46,8 +47,8 @@ function Inventory:HighlightMainMenu(checked)
4647
end
4748

4849
function Inventory:SortItems()
49-
if SortBags and Addon.sets.serverSort then
50-
SortBags()
50+
if C.SortBags and Addon.sets.serverSort then
51+
C.SortBags()
5152
else
5253
self:Super(Inventory):SortItems(self)
5354
end

0 commit comments

Comments
 (0)