vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local MYBAGS_MAXEQUIPSLOTS = 19 |
2 | local MYBAGS_SLOTCOLOR = { 0.5, 0.5, 0.5 } |
||
3 | local MYEQUIPMENT_SLOT = {} |
||
4 | local SLOTNAMES = {"HEADSLOT","NECKSLOT","SHOULDERSLOT","BACKSLOT","CHESTSLOT","SHIRTSLOT","TABARDSLOT","WRISTSLOT","HANDSSLOT","WAISTSLOT","LEGSSLOT","FEETSLOT","FINGER0SLOT","FINGER1SLOT","TRINKET0SLOT","TRINKET1SLOT","MAINHANDSLOT","SECONDARYHANDSLOT","RANGEDSLOT","AMMOSLOT"} |
||
5 | local MYEQUIPMENT_DEFAULT_OPTIONS = { |
||
6 | Columns = 6, |
||
7 | Graphics = "default", |
||
8 | Lock = FALSE, |
||
9 | NoEsc = FALSE, |
||
10 | Title = TRUE, |
||
11 | Cash = TRUE, |
||
12 | Buttons = TRUE, |
||
13 | Border = TRUE, |
||
14 | Cache = nil, |
||
15 | Player = FALSE, |
||
16 | Scale = FALSE, |
||
17 | Anchor = "bottomright", |
||
18 | BackColor = {0.7,0,0,0}, |
||
19 | SlotColor = nil, |
||
20 | } |
||
21 | MyEquipmentClass = MyBagsCoreClass:new({ |
||
22 | name = MYEQUIPMENT_NAME, |
||
23 | description = MYEQUIPMENT_DESCRIPTION, |
||
24 | db = AceDbClass:new("MyEquipmentDB"), |
||
25 | defaults = MYEQUIPMENT_DEFAULT_OPTIONS, |
||
26 | frameName = "MyEquipmentFrame", |
||
27 | cmd = AceChatCmdClass:new(MYEQUIPMENT_COMMANDS, MYEQUIPMENT_CMD_OPTIONS), |
||
28 | isEquipment = TRUE, |
||
29 | anchorPoint = "BOTTOM", |
||
30 | anchorParent = "UIParent", |
||
31 | anchorOffsetX = -5, |
||
32 | anchorOffsetY = 100, |
||
33 | }) |
||
34 | function MyEquipmentClass:Enable() |
||
35 | MyBagsCoreClass.Enable(self) |
||
36 | MyEquipmentFramePortrait:SetTexture("Interface\\Addons\\MyBags\\Skin\\MyEquipmentPortrait") |
||
37 | for key,value in SLOTNAMES do -- Just in case Blizzard shuffles the slot name table around |
||
38 | local slotId = GetInventorySlotInfo(value) |
||
39 | MYEQUIPMENT_SLOT[slotId] = value |
||
40 | end |
||
41 | end |
||
42 | function MyEquipmentClass:Disable() |
||
43 | end |
||
44 | function MyEquipmentClass:RegisterEvents() |
||
45 | self:RegisterEvent("UNIT_INVENTORY_CHANGED", "LayoutFrameOnEvent") |
||
46 | self:RegisterEvent("ITEM_LOCK_CHANGED", "LayoutFrameOnEvent") |
||
47 | end |
||
48 | function MyEquipmentClass:BAG_UPDATE() -- no bags here, move along |
||
49 | end |
||
50 | function MyEquipmentClass:GetRelic(charID) |
||
51 | if self.isLive then |
||
52 | return UnitHasRelicSlot("player") |
||
53 | elseif KC_Items and KC_Items.equipment then |
||
54 | if not MYBAGS_KC_CHARS then return nil end |
||
55 | local faction = MYBAGS_KC_CHARS[charID]["faction"] |
||
56 | return KC_Items.equipment:HasRelic(faction,charID) |
||
57 | elseif MyBagsCache then |
||
58 | return MyBagsCache:GetRelic(charID) |
||
59 | end |
||
60 | return nil |
||
61 | end |
||
62 | function MyEquipmentClass:GetInfoFunc() |
||
63 | if self.isLive then |
||
64 | return self.GetEquipInfoLive |
||
65 | elseif KC_Items and KC_Items.inventory then |
||
66 | return self.GetEquipInfoKC |
||
67 | elseif IsAddOnLoaded("MyBagsCache") then |
||
68 | return self.GetInfoMyBagsCache |
||
69 | end |
||
70 | return self.GetInfoNone |
||
71 | end |
||
72 | function MyEquipmentClass:GetEquipInfoKC(slot) |
||
73 | if not MYBAGS_KC_CHARS then return self.GetInfoNone end |
||
74 | local texture, count, ID, locked, quality, readable = nil |
||
75 | local charID = self.Player |
||
76 | local faction = MYBAGS_KC_CHARS[charID]["faction"] |
||
77 | ID,count = KC_Items.equipment:SlotInfo(faction, charID, slot) |
||
78 | if ID == "" or ID == "nil" then ID = nil end |
||
79 | if ID then |
||
80 | local itype,isubtype |
||
81 | _,_,quality,_,itype,isubtype,_,_,texture = GetItemInfo("item:"..ID) |
||
82 | _,_,_,quality = GetItemQualityColor(quality or 0) |
||
83 | quality = (strsub(quality,5)) -- here instead of return to keep nil if empty slot |
||
84 | end |
||
85 | count = ace.tonum(count) |
||
86 | return texture, count, ID, nil, quality, nil, nil |
||
87 | end |
||
88 | function MyEquipmentClass:GetEquipInfoLive(itemIndex) |
||
89 | local itemLink = GetInventoryItemLink("player",itemIndex) |
||
90 | local myColor, myLink, myName = nil |
||
91 | local texture, count, quality = nil |
||
92 | if itemLink or itemIndex == 0 then |
||
93 | texture = GetInventoryItemTexture("player",itemIndex) |
||
94 | count = GetInventoryItemCount("player",itemIndex) |
||
95 | if itemIndex ~= 0 then |
||
96 | _, quality, _, ID = ace.GetItemInfoFromLink(itemLink) |
||
97 | end |
||
98 | end |
||
99 | local hasRelic = UnitHasRelicSlot("player") |
||
100 | local locked = IsInventoryItemLocked(itemIndex) |
||
101 | return texture, count, ID, locked, quality, readable, nil |
||
102 | end |
||
103 | function MyEquipmentClass:MyEquipmentItemSlotButton_OnLoad() |
||
104 | this:RegisterForDrag("LeftButton") |
||
105 | getglobal(this:GetName().."NormalTexture"):SetTexture("Interface\\AddOns\\MyBags\\Skin\\Button") |
||
106 | end |
||
107 | function MyEquipmentClass:MyEquipmentItemSlotButton_OnEnter() |
||
108 | local text |
||
109 | self:TooltipSetOwner(this) |
||
110 | if self.isLive then |
||
111 | local hasItem, hasCooldown, repairCost = GameTooltip:SetInventoryItem("player", this:GetID()) |
||
112 | if not hasItem then |
||
113 | text = TEXT(getglobal(MYEQUIPMENT_SLOT[ace.tonum(strsub(this:GetName(), 21))])) |
||
114 | if this.hasRelic then text = TEXT(getglobal("RELICSLOT")) end |
||
115 | GameTooltip:SetText(text) |
||
116 | end |
||
117 | if ( InRepairMode() and repairCost and (repairCost > 0) ) then |
||
118 | GameTooltip:AddLine(TEXT(REPAIR_COST), "", 1, 1, 1) |
||
119 | SetTooltipMoney(GameTooltip, repairCost) |
||
120 | GameTooltip:Show() |
||
121 | elseif hasItem and IsControlKeyDown() then |
||
122 | ShowInspectCursor() |
||
123 | else |
||
124 | CursorUpdate() |
||
125 | end |
||
126 | else |
||
127 | local _, count, ID, _, quality, _, name = self:GetInfo(this:GetID()) |
||
128 | if ID and ID ~= "" then |
||
129 | local hyperlink = self:GetHyperlink(ID) |
||
130 | if hyperlink then GameTooltip:SetHyperlink(hyperlink) end |
||
131 | if IsControlKeyDown() and hyperlink then ShowInspectCursor() end |
||
132 | else |
||
133 | text = TEXT(getglobal(MYEQUIPMENT_SLOT[ace.tonum(strsub(this:GetName(), 21))])) |
||
134 | if this.hasRelic then text = TEXT(getglobal("RELICSLOT")) end |
||
135 | if name then -- it's a bleeding ammo slot |
||
136 | text = name |
||
137 | GameTooltip:SetText(text, ace.ColorConvertHexToDigit(quality)) |
||
138 | if count >= 1000 then |
||
139 | GameTooltip:AddLine(count,1,1,1) |
||
140 | GameTooltip:Show() |
||
141 | end |
||
142 | else |
||
143 | GameTooltip:SetText(text) |
||
144 | end |
||
145 | end |
||
146 | end |
||
147 | end |
||
148 | function MyEquipmentClass:MyEquipmentItemSlotButton_OnClick(button, ignoreModifiers) |
||
149 | if self.isLive then |
||
150 | if ( button == "LeftButton" ) then |
||
151 | if ( IsControlKeyDown() and not ignoreModifiers ) then |
||
152 | DressUpItemLink(GetInventoryItemLink("player", this:GetID())); |
||
153 | elseif ( IsShiftKeyDown() and not ignoreModifiers ) then |
||
154 | if ( ChatFrameEditBox:IsVisible() ) then |
||
155 | ChatFrameEditBox:Insert(GetInventoryItemLink("player", this:GetID())); |
||
156 | end |
||
157 | else |
||
158 | PickupInventoryItem(this:GetID()) |
||
159 | PaperDollItemSlotButton_UpdateLock() |
||
160 | self.watchLock = 1 |
||
161 | end |
||
162 | elseif ( button == "RightButton" ) then |
||
163 | UseInventoryItem(this:GetID()); |
||
164 | end |
||
165 | else |
||
166 | local _, _, ID = self:GetInfo(this:GetID()) |
||
167 | if ( button == "LeftButton" ) then |
||
168 | if ( IsControlKeyDown() ) then |
||
169 | DressUpItemLink("item:"..ID) |
||
170 | elseif ( IsShiftKeyDown() ) then |
||
171 | if ( ChatFrameEditBox:IsVisible() ) then |
||
172 | ChatFrameEditBox:Insert(MyBagsCoreClass:GetTextLink(ID)) |
||
173 | end |
||
174 | end |
||
175 | end |
||
176 | end |
||
177 | end |
||
178 | function MyEquipmentClass:MyEquipmentItemSlotButton_OnDragStart() |
||
179 | if self.isLive then |
||
180 | PaperDollItemSlotButton_OnClick("LeftButton", 1) |
||
181 | end |
||
182 | end |
||
183 | |||
184 | function MyEquipmentClass:MyEquipmentItemSlotButton_OnEvent(event) |
||
185 | if self.isLive then |
||
186 | PaperDollItemSlotButton_OnEvent(event) |
||
187 | else |
||
188 | if ( event == "CURSOR_UPDATE" ) then |
||
189 | if ( CursorCanGoInSlot(this:GetID()) ) then |
||
190 | this:LockHighlight() |
||
191 | else |
||
192 | this:UnlockHighlight() |
||
193 | end |
||
194 | return |
||
195 | end |
||
196 | end |
||
197 | end |
||
198 | function MyEquipmentClass:MyEquipmentItemSlotButton_OnUpdate(elapsed) |
||
199 | if ( GameTooltip:IsOwned(this) ) and self.isLive then |
||
200 | self:MyEquipmentItemSlotButton_OnEnter()() |
||
201 | end |
||
202 | end |
||
203 | function MyEquipmentClass:LayoutEquipmentFrame(self) |
||
204 | local itemBase = "MyEquipmentSlotsItem" |
||
205 | local texture, count, _, locked, quality, ammo |
||
206 | local slotColor = ((self.GetOpt("SlotColor")) or MYBAGS_SLOTCOLOR) |
||
207 | local charID = self:GetCurrentPlayer() |
||
208 | local hasRelic = self:GetRelic(charID) |
||
209 | local hideAmmo = nil |
||
210 | self.watchLock = nil |
||
211 | -- KC Items does not currently save AmmoSlot details (no ID is returned by the blizzard code) so hide it |
||
212 | if (not self.isLive) and KC_Items and KC_Items.equipment then hideAmmo = TRUE end |
||
213 | if self.aioiOrder and (hasRelic or hideAmmo) then self.curCol = self.curCol + 1 end |
||
214 | for key,value in SLOTNAMES do |
||
215 | local slot = GetInventorySlotInfo(value) |
||
216 | local itemButton = getglobal(itemBase .. slot) |
||
217 | if value == "AMMOSLOT" and (hasRelic or hideAmmo) then itemButton:Hide() break end |
||
218 | if self.curCol >= self.GetOpt("Columns") then |
||
219 | self.curCol = 0 |
||
220 | self.curRow = self.curRow + 1 |
||
221 | end |
||
222 | itemButton:Show() |
||
223 | itemButton:ClearAllPoints() |
||
224 | itemButton:SetPoint("TOPLEFT", self.frame:GetName(), "TOPLEFT", self:GetXY(self.curRow, self.curCol)) |
||
225 | self.curCol = self.curCol + 1 |
||
226 | texture, count, id, locked, quality = self:GetInfo(slot) |
||
227 | if id and id ~= "" then itemButton.hasItem = 1 end |
||
228 | if self.isLive then |
||
229 | local start,duration, enable = GetInventoryItemCooldown("player", slot) |
||
230 | local cooldown = getglobal(itemButton:GetName() .. "Cooldown") |
||
231 | CooldownFrame_SetTimer(cooldown,start,duration,enable) |
||
232 | if duration>0 and enable==0 then |
||
233 | SetItemButtonTextureVertexColor(itemButton, 0.4,0.4,0.4) |
||
234 | end |
||
235 | end |
||
236 | if value == "RANGEDSLOT" and hasRelic then itemButton.hasRelic = 1 end |
||
237 | SetItemButtonTexture(itemButton, (texture or "")) |
||
238 | SetItemButtonCount(itemButton, count) |
||
239 | SetItemButtonDesaturated(itemButton, locked, 0.5, 0.5, 0.5) |
||
240 | if locked and locked ~= "" then |
||
241 | itemButton:LockHighlight() |
||
242 | self.watchLock =1 |
||
243 | else itemButton:UnlockHighlight() end |
||
244 | if quality and self.GetOpt("Border") then |
||
245 | SetItemButtonNormalTextureVertexColor(itemButton, ace.ColorConvertHexToDigit(quality)) |
||
246 | else |
||
247 | SetItemButtonNormalTextureVertexColor(itemButton, unpack(slotColor)) |
||
248 | end |
||
249 | end |
||
250 | end |
||
251 | |||
252 | MyEquipment = MyEquipmentClass:new() |
||
253 | MyEquipment:RegisterForLoad() |