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