Flick@276
|
1 local _, ns = ...
|
Flick@276
|
2 local ReAction = ns.ReAction
|
flickerstreak@146
|
3 local L = ReAction.L
|
flickerstreak@146
|
4 local _G = _G
|
flickerstreak@146
|
5 local CreateFrame = CreateFrame
|
flickerstreak@146
|
6 local format = string.format
|
flickerstreak@146
|
7 local GetCVar = GetCVar
|
flickerstreak@146
|
8 local ContainerIDToInventoryID = ContainerIDToInventoryID
|
flickerstreak@146
|
9 local NUM_CONTAINER_FRAMES = NUM_CONTAINER_FRAMES
|
flickerstreak@146
|
10 local IsModifiedClick = IsModifiedClick
|
flickerstreak@146
|
11 local CursorHasItem = CursorHasItem
|
flickerstreak@146
|
12 local GetInventoryItemTexture = GetInventoryItemTexture
|
flickerstreak@146
|
13 local GetInventorySlotInfo = GetInventorySlotInfo
|
flickerstreak@146
|
14 local PickupBagFromSlot = PickupBagFromSlot
|
flickerstreak@146
|
15 local CursorCanGoInSlot = CursorCanGoInSlot
|
flickerstreak@146
|
16
|
flickerstreak@146
|
17 -- class declarations
|
flickerstreak@218
|
18 local buttonTypeID = "Bag"
|
Flick@234
|
19 local weak = { __mode = "k" }
|
flickerstreak@146
|
20 local Super = ReAction.Button
|
flickerstreak@218
|
21 local BagBase = setmetatable(
|
flickerstreak@218
|
22 {
|
flickerstreak@218
|
23 defaultBarConfig = {
|
flickerstreak@218
|
24 type = buttonTypeID,
|
flickerstreak@218
|
25 btnWidth = 30,
|
flickerstreak@218
|
26 btnHeight = 30,
|
flickerstreak@218
|
27 btnRows = 1,
|
flickerstreak@218
|
28 btnColumns = 6,
|
flickerstreak@221
|
29 spacing = 4,
|
flickerstreak@221
|
30 buttons = { }
|
flickerstreak@218
|
31 },
|
flickerstreak@218
|
32
|
flickerstreak@218
|
33 barType = L["Bag Bar"],
|
Flick@234
|
34 buttonTypeID = buttonTypeID,
|
Flick@234
|
35
|
Flick@234
|
36 allButtons = setmetatable( { }, weak )
|
flickerstreak@218
|
37 },
|
flickerstreak@218
|
38 { __index = Super } )
|
flickerstreak@218
|
39
|
flickerstreak@146
|
40 local Bag = setmetatable( { }, { __index = BagBase } )
|
flickerstreak@146
|
41 local Backpack = setmetatable( { }, { __index = BagBase } )
|
flickerstreak@146
|
42 local Keyring = setmetatable( { }, { __index = BagBase } )
|
flickerstreak@146
|
43
|
flickerstreak@146
|
44 ReAction.Button.Bag = BagBase
|
flickerstreak@223
|
45 ReAction:RegisterBarType(BagBase)
|
flickerstreak@146
|
46
|
flickerstreak@146
|
47 --
|
flickerstreak@146
|
48 -- Bag Button base class
|
flickerstreak@146
|
49 --
|
flickerstreak@146
|
50
|
Flick@234
|
51 function BagBase:New( btnCfg, bar, idx, idHint )
|
flickerstreak@146
|
52 -- use a variable private leaf implementation class
|
flickerstreak@146
|
53 -- unlike traditional OO programming, we can initialize the leaf
|
flickerstreak@221
|
54 -- class before initializing its parent
|
flickerstreak@146
|
55 local class = Bag
|
flickerstreak@146
|
56 if idx == 1 then
|
flickerstreak@146
|
57 class = Backpack
|
flickerstreak@146
|
58 elseif idx == 6 then
|
flickerstreak@146
|
59 class = Keyring
|
flickerstreak@146
|
60 end
|
Flick@277
|
61 self = class:New(btnCfg, bar, idx)
|
flickerstreak@146
|
62
|
flickerstreak@146
|
63 local f = self:GetFrame()
|
flickerstreak@146
|
64 local config = self:GetConfig()
|
flickerstreak@146
|
65
|
flickerstreak@146
|
66 -- set up the bag ID pool
|
flickerstreak@146
|
67 self:SetActionIDPool("bag",6)
|
flickerstreak@146
|
68 config.bagID = self:AcquireActionID(config.bagID, idHint, true)
|
flickerstreak@146
|
69
|
flickerstreak@146
|
70 -- non secure scripts
|
flickerstreak@146
|
71 f:SetScript("OnEvent", function(frame, ...) self:OnEvent(...) end)
|
flickerstreak@146
|
72 f:SetScript("OnEnter", function(frame) self:OnEnter() end)
|
flickerstreak@146
|
73 f:SetScript("OnLeave", function(frame) self:OnLeave() end)
|
flickerstreak@146
|
74 f:SetScript("OnReceiveDrag", function(frame, ...) self:OnReceiveDrag(...) end)
|
flickerstreak@146
|
75 f:SetScript("OnClick", function(frame, ...) self:OnClick(...) end)
|
flickerstreak@146
|
76
|
flickerstreak@146
|
77 -- secure handlers
|
flickerstreak@146
|
78 -- (none)
|
flickerstreak@146
|
79
|
flickerstreak@146
|
80 -- event registration
|
flickerstreak@146
|
81 f:RegisterEvent("UPDATE_BINDINGS")
|
flickerstreak@146
|
82
|
flickerstreak@146
|
83 -- frame setup
|
flickerstreak@146
|
84 f:SetID(self:GetBagID())
|
flickerstreak@146
|
85
|
flickerstreak@146
|
86 if not f.hotkey then
|
flickerstreak@146
|
87 local h = f:CreateFontString(name.."HotKey","ARTWORK","NumberFontNormalSmallGray")
|
flickerstreak@152
|
88 h:SetWidth(30)
|
flickerstreak@146
|
89 h:SetHeight(10)
|
flickerstreak@146
|
90 h:SetJustifyH("RIGHT")
|
flickerstreak@146
|
91 h:SetPoint("TOPLEFT",f,"TOPLEFT",-2,-2)
|
flickerstreak@146
|
92 h:Show()
|
flickerstreak@146
|
93 f.hotkey = h
|
flickerstreak@146
|
94 end
|
flickerstreak@146
|
95
|
flickerstreak@146
|
96 if not _G[name.."ItemAnim"] then
|
flickerstreak@146
|
97 local anim = CreateFrame("Model",name.."ItemAnim",f,"ItemAnimTemplate")
|
flickerstreak@146
|
98 anim:SetPoint("BOTTOMRIGHT",f,"BOTTOMRIGHT",-10,0)
|
flickerstreak@146
|
99 anim:Hide()
|
flickerstreak@146
|
100 end
|
flickerstreak@146
|
101
|
flickerstreak@152
|
102 if not f.border then
|
flickerstreak@152
|
103 local b = f:CreateTexture(name.."Border","OVERLAY")
|
flickerstreak@152
|
104 b:SetAllPoints()
|
flickerstreak@152
|
105 b:SetWidth(f:GetWidth()*(62/36))
|
flickerstreak@152
|
106 b:SetHeight(f:GetHeight()*(62/36))
|
flickerstreak@152
|
107 b:SetTexture("Interface\\Buttons\UI-ActionButton-Border")
|
flickerstreak@152
|
108 b:SetBlendMode("ADD")
|
flickerstreak@152
|
109 b:Hide()
|
flickerstreak@152
|
110 f.border = b
|
flickerstreak@152
|
111 end
|
flickerstreak@152
|
112
|
flickerstreak@146
|
113 self.frames.count:SetDrawLayer("ARTWORK")
|
flickerstreak@146
|
114
|
flickerstreak@146
|
115 self.frames.hotkey = f.hotkey
|
flickerstreak@152
|
116 self.frames.border = _G[name.."Border"]
|
flickerstreak@146
|
117 self.frames.icon = _G[name.."IconTexture"]
|
flickerstreak@146
|
118 self.frames.anim = _G[name.."ItemAnim"]
|
flickerstreak@146
|
119
|
flickerstreak@146
|
120 -- initial display
|
flickerstreak@146
|
121 if ReAction:GetConfigMode() then
|
flickerstreak@146
|
122 self:GetFrame():Show()
|
flickerstreak@146
|
123 end
|
flickerstreak@146
|
124
|
flickerstreak@146
|
125 self:Refresh()
|
flickerstreak@146
|
126
|
Flick@234
|
127 BagBase.allButtons[self] = true
|
Flick@234
|
128
|
flickerstreak@146
|
129 return self
|
flickerstreak@146
|
130 end
|
flickerstreak@146
|
131
|
Flick@234
|
132 function BagBase:Destroy()
|
Flick@234
|
133 BagBase.allButtons[self] = nil
|
Flick@234
|
134 Super.Destroy(self)
|
Flick@234
|
135 end
|
Flick@234
|
136
|
Flick@234
|
137
|
flickerstreak@146
|
138 function BagBase:GetActionID()
|
flickerstreak@146
|
139 return self.config.bagID
|
flickerstreak@146
|
140 end
|
flickerstreak@146
|
141
|
flickerstreak@146
|
142 function BagBase:GetBagID()
|
flickerstreak@146
|
143 return self:GetActionID() - 1
|
flickerstreak@146
|
144 end
|
flickerstreak@146
|
145
|
flickerstreak@146
|
146 function BagBase:Refresh()
|
flickerstreak@146
|
147 Super.Refresh(self)
|
flickerstreak@146
|
148 self:UpdateHotkey()
|
flickerstreak@146
|
149 self:Update()
|
flickerstreak@146
|
150 end
|
flickerstreak@146
|
151
|
flickerstreak@146
|
152 function BagBase:Update()
|
flickerstreak@146
|
153 self:UpdateChecked()
|
flickerstreak@146
|
154 end
|
flickerstreak@146
|
155
|
flickerstreak@146
|
156 function BagBase:UpdateChecked(force)
|
flickerstreak@146
|
157 if force == nil then
|
flickerstreak@146
|
158 for i=1, NUM_CONTAINER_FRAMES do
|
flickerstreak@146
|
159 local c = _G["ContainerFrame"..i]
|
flickerstreak@146
|
160 if c:GetID() == self:GetBagID() and c:IsShown() then
|
flickerstreak@146
|
161 self:GetFrame():SetChecked(1)
|
flickerstreak@146
|
162 return
|
flickerstreak@146
|
163 end
|
flickerstreak@146
|
164 end
|
flickerstreak@146
|
165 self:GetFrame():SetChecked(0)
|
flickerstreak@146
|
166 end
|
flickerstreak@146
|
167 self:GetFrame():SetChecked(force)
|
flickerstreak@146
|
168 end
|
flickerstreak@146
|
169
|
flickerstreak@146
|
170 function BagBase:OnEvent(evt, ...)
|
flickerstreak@146
|
171 if self[evt] then
|
flickerstreak@146
|
172 self[evt](self, ...)
|
flickerstreak@146
|
173 end
|
flickerstreak@146
|
174 end
|
flickerstreak@146
|
175
|
flickerstreak@146
|
176 function BagBase:OnEnter()
|
flickerstreak@146
|
177 self:SetTooltip()
|
flickerstreak@146
|
178 end
|
flickerstreak@146
|
179
|
flickerstreak@146
|
180 function BagBase:OnLeave()
|
flickerstreak@146
|
181 GameTooltip:Hide()
|
flickerstreak@146
|
182 end
|
flickerstreak@146
|
183
|
flickerstreak@146
|
184 function BagBase:UPDATE_BINDINGS()
|
flickerstreak@146
|
185 self:UpdateHotkey()
|
flickerstreak@146
|
186 end
|
flickerstreak@146
|
187
|
Flick@234
|
188 function BagBase:IterateAllButtons()
|
Flick@234
|
189 return pairs(self.allButtons)
|
Flick@234
|
190 end
|
Flick@234
|
191
|
flickerstreak@146
|
192
|
flickerstreak@146
|
193 --
|
flickerstreak@146
|
194 -- Bag Button class
|
flickerstreak@146
|
195 --
|
flickerstreak@146
|
196 function Bag:New(name, cfg, bar, idx)
|
flickerstreak@146
|
197 self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" )
|
flickerstreak@146
|
198
|
flickerstreak@146
|
199 local f = self:GetFrame()
|
flickerstreak@146
|
200
|
flickerstreak@146
|
201 f:SetCheckedTexture("Interface\\Buttons\\CheckButtonHilight")
|
flickerstreak@146
|
202
|
flickerstreak@146
|
203 f:RegisterEvent("CURSOR_UPDATE")
|
flickerstreak@151
|
204 f:RegisterEvent("BAG_UPDATE")
|
flickerstreak@146
|
205 f:RegisterEvent("BAG_CLOSED")
|
flickerstreak@146
|
206 f:SetScript("OnDragStart", function(frame, ...) self:OnDragStart(...) end)
|
flickerstreak@146
|
207 f:RegisterForDrag("LeftButton")
|
flickerstreak@146
|
208
|
flickerstreak@146
|
209 -- attach to skinner
|
flickerstreak@146
|
210 bar:SkinButton(self,
|
flickerstreak@146
|
211 {
|
flickerstreak@146
|
212 Icon = _G[name.."IconTexture"]
|
flickerstreak@146
|
213 }
|
flickerstreak@146
|
214 )
|
flickerstreak@146
|
215
|
flickerstreak@146
|
216 return self
|
flickerstreak@146
|
217 end
|
flickerstreak@146
|
218
|
flickerstreak@146
|
219 function Bag:GetInventorySlot()
|
flickerstreak@146
|
220 return ContainerIDToInventoryID(self:GetBagID())
|
flickerstreak@146
|
221 end
|
flickerstreak@146
|
222
|
flickerstreak@146
|
223 function Bag:GetInventorySlotName()
|
flickerstreak@146
|
224 return "Bag"..(self:GetBagID()-1).."Slot"
|
flickerstreak@146
|
225 end
|
flickerstreak@146
|
226
|
flickerstreak@146
|
227 function Bag:SetTooltip()
|
flickerstreak@146
|
228 GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_LEFT")
|
flickerstreak@146
|
229 if not GameTooltip:SetInventoryItem("player", self:GetInventorySlot()) then
|
flickerstreak@146
|
230 GameTooltip:SetText(EQUIP_CONTAINER, 1.0, 1.0, 1.0)
|
flickerstreak@146
|
231 end
|
flickerstreak@146
|
232 end
|
flickerstreak@146
|
233
|
flickerstreak@146
|
234 function Bag:Update()
|
flickerstreak@146
|
235 local texture = GetInventoryItemTexture("player", self:GetInventorySlot())
|
flickerstreak@146
|
236 if texture then
|
flickerstreak@146
|
237 self.frames.icon:SetTexture(texture)
|
flickerstreak@146
|
238 self.frames.icon:Show()
|
flickerstreak@146
|
239 self:GetFrame():SetNormalTexture("Interface\\Buttons\\UI-Quickslot2")
|
flickerstreak@146
|
240 else
|
flickerstreak@146
|
241 local _, bgTex = GetInventorySlotInfo(self:GetInventorySlotName())
|
flickerstreak@146
|
242 self.frames.icon:SetTexture(bgTex)
|
flickerstreak@146
|
243 self:GetFrame():SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
|
flickerstreak@146
|
244 end
|
flickerstreak@146
|
245 self:UpdateChecked()
|
flickerstreak@146
|
246 end
|
flickerstreak@146
|
247
|
flickerstreak@146
|
248 function Bag:OnClick()
|
flickerstreak@146
|
249 if IsModifiedClick("OPENALLBAGS") then
|
flickerstreak@146
|
250 OpenAllBags()
|
flickerstreak@146
|
251 else
|
flickerstreak@146
|
252 if not PutItemInBag(self:GetInventorySlot()) then
|
flickerstreak@146
|
253 ToggleBag(self:GetBagID())
|
flickerstreak@146
|
254 end
|
flickerstreak@146
|
255 end
|
flickerstreak@146
|
256 self:UpdateChecked()
|
flickerstreak@146
|
257 end
|
flickerstreak@146
|
258
|
flickerstreak@146
|
259 function Bag:OnReceiveDrag()
|
flickerstreak@146
|
260 if CursorHasItem() then
|
flickerstreak@146
|
261 PutItemInBag(self:GetInventorySlot())
|
flickerstreak@146
|
262 end
|
flickerstreak@146
|
263 end
|
flickerstreak@146
|
264
|
flickerstreak@146
|
265 function Bag:OnDragStart()
|
flickerstreak@146
|
266 PickupBagFromSlot(self:GetInventorySlot())
|
flickerstreak@146
|
267 self:Update()
|
flickerstreak@146
|
268 end
|
flickerstreak@146
|
269
|
flickerstreak@151
|
270 function Bag:BAG_UPDATE(bag)
|
flickerstreak@151
|
271 if bag == self:GetBagID() then
|
flickerstreak@146
|
272 self:Update()
|
flickerstreak@146
|
273 end
|
flickerstreak@146
|
274 end
|
flickerstreak@146
|
275
|
flickerstreak@146
|
276 function Bag:CURSOR_UPDATE()
|
flickerstreak@146
|
277 if CursorCanGoInSlot(self:GetInventorySlot()) then
|
flickerstreak@146
|
278 self:GetFrame():LockHighlight()
|
flickerstreak@146
|
279 else
|
flickerstreak@146
|
280 self:GetFrame():UnlockHighlight()
|
flickerstreak@146
|
281 end
|
flickerstreak@146
|
282 end
|
flickerstreak@146
|
283
|
flickerstreak@146
|
284 function Bag:BAG_CLOSED(bag)
|
flickerstreak@146
|
285 if bag == self:GetBagID() then
|
flickerstreak@146
|
286 self:Update()
|
flickerstreak@146
|
287 end
|
flickerstreak@146
|
288 end
|
flickerstreak@146
|
289
|
flickerstreak@146
|
290
|
flickerstreak@146
|
291 --
|
flickerstreak@146
|
292 -- Backpack Button class
|
flickerstreak@146
|
293 --
|
flickerstreak@146
|
294 function Backpack:New(name, cfg, bar, idx)
|
flickerstreak@146
|
295 self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" )
|
flickerstreak@146
|
296
|
flickerstreak@146
|
297 local f = self:GetFrame()
|
flickerstreak@146
|
298 local icon = _G[name.."IconTexture"]
|
flickerstreak@146
|
299 icon:SetTexture("Interface\\Buttons\\Button-Backpack-Up")
|
flickerstreak@146
|
300 icon:Show()
|
flickerstreak@146
|
301 f:SetCheckedTexture("Interface\\Buttons\\CheckButtonHilight")
|
flickerstreak@146
|
302 f:RegisterEvent("PLAYER_ENTERING_WORLD");
|
flickerstreak@146
|
303 f:RegisterEvent("CVAR_UPDATE");
|
flickerstreak@146
|
304 f:SetScript("OnShow", function(frame, ...) self:OnShow(...) end)
|
flickerstreak@146
|
305
|
flickerstreak@146
|
306 -- attach to skinner
|
flickerstreak@146
|
307 bar:SkinButton(self,
|
flickerstreak@146
|
308 {
|
flickerstreak@146
|
309 Icon = _G[name.."IconTexture"]
|
flickerstreak@146
|
310 }
|
flickerstreak@146
|
311 )
|
flickerstreak@146
|
312
|
flickerstreak@146
|
313 return self
|
flickerstreak@146
|
314 end
|
flickerstreak@146
|
315
|
flickerstreak@146
|
316 function Backpack:Update()
|
flickerstreak@146
|
317 self:UpdateFreeSlots()
|
flickerstreak@146
|
318 self:UpdateChecked()
|
flickerstreak@146
|
319 end
|
flickerstreak@146
|
320
|
flickerstreak@146
|
321 function Backpack:UpdateFreeSlots()
|
flickerstreak@146
|
322 if GetCVar("displayFreeBagSlots") == "1" then
|
flickerstreak@146
|
323 local total = 0
|
flickerstreak@146
|
324 for i = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
|
flickerstreak@146
|
325 local free, family = GetContainerNumFreeSlots(i)
|
flickerstreak@146
|
326 if family == 0 then
|
flickerstreak@146
|
327 total = total + free
|
flickerstreak@146
|
328 end
|
flickerstreak@146
|
329 end
|
flickerstreak@146
|
330
|
flickerstreak@146
|
331 self.freeSlots = total
|
flickerstreak@146
|
332 self.frames.count:SetText(format("(%s)", self.freeSlots))
|
flickerstreak@146
|
333 self.frames.count:Show()
|
flickerstreak@146
|
334 elseif self.frames.count:IsShown() then
|
flickerstreak@146
|
335 self.frames.count:Hide()
|
flickerstreak@146
|
336 end
|
flickerstreak@146
|
337 end
|
flickerstreak@146
|
338
|
flickerstreak@146
|
339 function Backpack:SetTooltip()
|
flickerstreak@146
|
340 GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_LEFT")
|
flickerstreak@146
|
341 GameTooltip:SetText(BACKPACK_TOOLTIP, 1.0, 1.0, 1.0)
|
flickerstreak@146
|
342 GameTooltip:AddLine(string.format(NUM_FREE_SLOTS, (self.freeSlots or 0)))
|
flickerstreak@146
|
343 GameTooltip:Show();
|
flickerstreak@146
|
344 end
|
flickerstreak@146
|
345
|
flickerstreak@146
|
346 function Backpack:OnShow()
|
flickerstreak@146
|
347 self:UpdateFreeSlots()
|
flickerstreak@146
|
348 end
|
flickerstreak@146
|
349
|
flickerstreak@146
|
350 function Backpack:OnClick()
|
flickerstreak@146
|
351 if IsModifiedClick("OPENALLBAGS") then
|
flickerstreak@146
|
352 OpenAllBags()
|
flickerstreak@146
|
353 else
|
flickerstreak@146
|
354 if not PutItemInBackpack() then
|
flickerstreak@146
|
355 ToggleBackpack()
|
flickerstreak@146
|
356 end
|
flickerstreak@146
|
357 end
|
flickerstreak@146
|
358 self:UpdateChecked()
|
flickerstreak@146
|
359 end
|
flickerstreak@146
|
360
|
flickerstreak@146
|
361 function Backpack:OnReceiveDrag()
|
flickerstreak@146
|
362 if CursorHasItem() then
|
flickerstreak@146
|
363 PutItemInBackpack()
|
flickerstreak@146
|
364 end
|
flickerstreak@146
|
365 end
|
flickerstreak@146
|
366
|
flickerstreak@146
|
367 function Backpack:PLAYER_ENTERING_WORLD()
|
flickerstreak@146
|
368 self:CVAR_UPDATE("DISPLAY_FREE_BAG_SLOTS", GetCVar("displayFreeBagSlots"))
|
flickerstreak@146
|
369 end
|
flickerstreak@146
|
370
|
flickerstreak@146
|
371 function Backpack:CVAR_UPDATE( cvar, value )
|
flickerstreak@146
|
372 if cvar == "DISPLAY_FREE_BAG_SLOTS" then
|
flickerstreak@146
|
373 if value == "1" then
|
flickerstreak@146
|
374 self:GetFrame():RegisterEvent("BAG_UPDATE")
|
flickerstreak@146
|
375 else
|
flickerstreak@146
|
376 self:GetFrame():UnregisterEvent("BAG_UPDATE")
|
flickerstreak@146
|
377 end
|
flickerstreak@146
|
378 self:UpdateFreeSlots()
|
flickerstreak@146
|
379 end
|
flickerstreak@146
|
380 end
|
flickerstreak@146
|
381
|
flickerstreak@146
|
382 function Backpack:BAG_UPDATE(bag)
|
flickerstreak@146
|
383 if bag >= BACKPACK_CONTAINER and bag <= NUM_BAG_SLOTS then
|
flickerstreak@146
|
384 self:UpdateFreeSlots()
|
flickerstreak@146
|
385 end
|
flickerstreak@146
|
386 end
|
flickerstreak@146
|
387
|
flickerstreak@146
|
388
|
flickerstreak@146
|
389 --
|
flickerstreak@146
|
390 -- Keyring Button class
|
flickerstreak@146
|
391 --
|
flickerstreak@146
|
392 function Keyring:New(name, cfg, bar, idx)
|
flickerstreak@146
|
393 self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" )
|
flickerstreak@146
|
394
|
flickerstreak@146
|
395 local f = self:GetFrame()
|
flickerstreak@146
|
396
|
flickerstreak@146
|
397 f:SetWidth(18)
|
flickerstreak@146
|
398 f:SetHeight(39)
|
flickerstreak@146
|
399
|
flickerstreak@146
|
400 local tex = f:GetNormalTexture()
|
flickerstreak@146
|
401 tex:ClearAllPoints()
|
flickerstreak@152
|
402 tex:SetAllPoints()
|
flickerstreak@146
|
403
|
flickerstreak@146
|
404 f:SetNormalTexture("Interface\\Buttons\\UI-Button-KeyRing")
|
flickerstreak@146
|
405 f:SetHighlightTexture("Interface\\Buttons\\UI-Button-KeyRing-Highlight")
|
flickerstreak@146
|
406 f:SetPushedTexture("Interface\\Buttons\\UI-Button-KeyRing-Down")
|
flickerstreak@146
|
407 f:GetNormalTexture():SetTexCoord(0,0.5625,0,0.609375)
|
flickerstreak@146
|
408 f:GetHighlightTexture():SetTexCoord(0,0.5625,0,0.609375)
|
flickerstreak@146
|
409 f:GetPushedTexture():SetTexCoord(0,0.5625,0,0.609375)
|
flickerstreak@146
|
410
|
flickerstreak@146
|
411 if not HasKey() then
|
flickerstreak@146
|
412 f:Hide()
|
flickerstreak@146
|
413 end
|
flickerstreak@146
|
414
|
flickerstreak@146
|
415 -- DO NOT attach to skinner
|
flickerstreak@146
|
416
|
flickerstreak@146
|
417 return self
|
flickerstreak@146
|
418 end
|
flickerstreak@146
|
419
|
flickerstreak@146
|
420 function Keyring:GetBagID()
|
flickerstreak@146
|
421 return KEYRING_CONTAINER
|
flickerstreak@146
|
422 end
|
flickerstreak@146
|
423
|
flickerstreak@146
|
424 function Keyring:Refresh()
|
flickerstreak@146
|
425 local f = self:GetFrame()
|
flickerstreak@146
|
426 self.bar:PlaceButton( self, f:GetHeight(), f:GetHeight() ) -- use height x height since it's an odd size
|
flickerstreak@146
|
427 self:UpdateHotkey()
|
flickerstreak@146
|
428 self:Update()
|
flickerstreak@146
|
429 end
|
flickerstreak@146
|
430
|
flickerstreak@146
|
431 function Keyring:SetTooltip()
|
flickerstreak@146
|
432 GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_RIGHT");
|
flickerstreak@146
|
433 GameTooltip:SetText(KEYRING, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
|
flickerstreak@146
|
434 GameTooltip:AddLine();
|
flickerstreak@146
|
435 end
|
flickerstreak@146
|
436
|
flickerstreak@146
|
437 function Keyring:OnReceiveDrag()
|
flickerstreak@146
|
438 if CursorHasItem() then
|
flickerstreak@146
|
439 PutKeyInKeyRing()
|
flickerstreak@146
|
440 end
|
flickerstreak@146
|
441 end
|
flickerstreak@146
|
442
|
flickerstreak@146
|
443 function Keyring:OnClick()
|
flickerstreak@146
|
444 if CursorHasItem() then
|
flickerstreak@146
|
445 PutKeyInKeyRing()
|
flickerstreak@146
|
446 else
|
flickerstreak@146
|
447 ToggleKeyRing()
|
flickerstreak@146
|
448 end
|
flickerstreak@146
|
449 self:UpdateChecked()
|
flickerstreak@146
|
450 end
|
flickerstreak@146
|
451
|
flickerstreak@146
|
452 function Keyring:ShowGridTemp(show)
|
flickerstreak@146
|
453 if not HasKey() then
|
flickerstreak@146
|
454 if show then
|
flickerstreak@146
|
455 self:GetFrame():Show()
|
flickerstreak@146
|
456 else
|
flickerstreak@146
|
457 self:GetFrame():Hide()
|
flickerstreak@146
|
458 end
|
flickerstreak@146
|
459 end
|
flickerstreak@146
|
460 end
|
flickerstreak@146
|
461
|
Flick@234
|
462
|
Flick@234
|
463
|
Flick@234
|
464 -- hook some functions to propagate to our bag buttons
|
Flick@234
|
465 hooksecurefunc("Disable_BagButtons",
|
Flick@234
|
466 function()
|
Flick@234
|
467 for b in BagBase:IterateAllButtons() do
|
Flick@234
|
468 local f = b:GetFrame()
|
Flick@234
|
469 f:Disable()
|
Flick@234
|
470 SetDesaturation(b.frames.icon,1)
|
Flick@234
|
471 end
|
Flick@234
|
472 end)
|
Flick@234
|
473
|
Flick@234
|
474 hooksecurefunc("Enable_BagButtons",
|
Flick@234
|
475 function()
|
Flick@234
|
476 for b in BagBase:IterateAllButtons() do
|
Flick@234
|
477 local f = b:GetFrame()
|
Flick@234
|
478 f:Enable()
|
Flick@234
|
479 SetDesaturation(b.frames.icon,nil)
|
Flick@234
|
480 end
|
Flick@234
|
481 end)
|
Flick@234
|
482
|
Flick@234
|
483 hooksecurefunc("ContainerFrame_OnHide",
|
Flick@234
|
484 function()
|
Flick@234
|
485 for b in BagBase:IterateAllButtons() do
|
Flick@234
|
486 b:Update()
|
Flick@234
|
487 end
|
Flick@234
|
488 end)
|
Flick@234
|
489
|
Flick@234
|
490 hooksecurefunc("ContainerFrame_OnShow",
|
Flick@234
|
491 function()
|
Flick@234
|
492 for b in BagBase:IterateAllButtons() do
|
Flick@234
|
493 b:Update()
|
Flick@234
|
494 end
|
Flick@234
|
495 end)
|