vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local MYINVENTORY_DEFAULT_OPTIONS = { |
2 | Columns = 6, |
||
3 | Replace = TRUE, |
||
4 | Bag = "bar", |
||
5 | Graphics = "default", |
||
6 | Count = "free", |
||
7 | HlItems = TRUE, |
||
8 | HlBags = TRUE, |
||
9 | Freeze = FALSE, |
||
10 | NoEsc = FALSE, |
||
11 | Lock = FALSE, |
||
12 | Title = TRUE, |
||
13 | Cash = TRUE, |
||
14 | Buttons = TRUE, |
||
15 | AIOI = FALSE, |
||
16 | Border = TRUE, |
||
17 | Cache = nil, |
||
18 | Player = FALSE, |
||
19 | Scale = FALSE, |
||
20 | Anchor = "bottomright", |
||
21 | BackColor = {0.7,0,0,0}, |
||
22 | SlotColor = nil, |
||
23 | AmmoColor = nil, |
||
24 | EnchantColor = nil, |
||
25 | EngColor = nil, |
||
26 | HerbColor = nil, |
||
27 | KeyRingColor = nil, |
||
28 | Companion = nil, |
||
29 | } |
||
30 | |||
31 | MyInventoryClass = MyBagsCoreClass:new({ |
||
32 | name = MYINVENTORY_NAME, |
||
33 | description = MYINVENTORY_DESCRIPTION, |
||
34 | db = AceDbClass:new("MyInventoryDB"), |
||
35 | defaults = MYINVENTORY_DEFAULT_OPTIONS, |
||
36 | frameName = "MyInventoryFrame", |
||
37 | cmd = AceChatCmdClass:new(MYINVENTORY_COMMANDS, MYINVENTORY_CMD_OPTIONS), |
||
38 | |||
39 | totalBags = 5, |
||
40 | firstBag = 0, |
||
41 | anchorPoint = "BOTTOMRIGHT", |
||
42 | anchorParent = "UIParent", |
||
43 | anchorOffsetX = -5, |
||
44 | anchorOffsetY = 100, |
||
45 | }) |
||
46 | |||
47 | function MyInventoryClass:RegisterEvents() |
||
48 | MyBagsCoreClass.RegisterEvents(self) |
||
49 | end |
||
50 | function MyInventoryClass:UnregisterEvents() |
||
51 | MyBagsCoreClass.UnregisterEvents(self) |
||
52 | end |
||
53 | function MyInventoryClass:HookFunctions() |
||
54 | MyBagsCoreClass.HookFunctions(self) |
||
55 | self:Hook("ToggleKeyRing") |
||
56 | self:Hook("ToggleBackpack") |
||
57 | self:Hook("OpenBackpack") |
||
58 | self:Hook("CloseBackpack") |
||
59 | end |
||
60 | |||
61 | function MyInventoryClass:ToggleKeyRing() |
||
62 | if not (self.GetOpt("Replace") and self:IncludeBag(KEYRING_CONTAINER)) then |
||
63 | self.Hooks["ToggleKeyRing"].orig() |
||
64 | else |
||
65 | self:Toggle() |
||
66 | end |
||
67 | end |
||
68 | function MyInventoryClass:ToggleBackpack() |
||
69 | if not (self.GetOpt("Replace") and self:IncludeBag(0)) then |
||
70 | self.Hooks["ToggleBackpack"].orig() |
||
71 | else |
||
72 | self:Toggle() |
||
73 | end |
||
74 | end |
||
75 | function MyInventoryClass:OpenBackpack() |
||
76 | if not (self.GetOpt("Replace") and self:IncludeBag(0)) then |
||
77 | self.Hooks["OpenBackpack"].orig() |
||
78 | else |
||
79 | if MailFrame:IsVisible() then self.Companion = TRUE end |
||
80 | if self.frame:IsVisible() then self.holdOpen = TRUE end |
||
81 | self:Open() |
||
82 | end |
||
83 | end |
||
84 | function MyInventoryClass:CloseBackpack() |
||
85 | self:debug("CloseBackpack") |
||
86 | if not (self.GetOpt("Replace") and self:IncludeBag(0)) then |
||
87 | self.Hooks["CloseBackpack"].orig() |
||
88 | elseif not self.Freeze then |
||
89 | self:Close() |
||
90 | elseif self.Freeze == "sticky" then |
||
91 | if self.holdOpen then |
||
92 | self.holdOpen = nil |
||
93 | else |
||
94 | self:Close() |
||
95 | end |
||
96 | end |
||
97 | end |
||
98 | function MyInventoryClass:CompanionOpen() |
||
99 | self.Companion = TRUE |
||
100 | self:OpenBackpack() |
||
101 | end |
||
102 | function MyInventoryClass:CompanionClose() |
||
103 | if self.Companion then -- if not true it's a duplicate event |
||
104 | self.Companion = nil |
||
105 | self:CloseBackpack() |
||
106 | end |
||
107 | end |
||
108 | function MyInventoryClass:BAG_UPDATE() |
||
109 | local bag = arg1 |
||
110 | if self.isLive and (bag == -2 or (bag >= 0 and bag < 5)) then |
||
111 | self:LayoutFrame() |
||
112 | end |
||
113 | end |
||
114 | |||
115 | function MyInventoryClass:GetInfoFunc() |
||
116 | if self.isLive then |
||
117 | return self.GetInfoLive |
||
118 | end |
||
119 | if IsAddOnLoaded("KC_Items") and KC_Items.inventory then |
||
120 | return self.GetInfoKC |
||
121 | end |
||
122 | if IsAddOnLoaded("MyBagsCache") then |
||
123 | return self.GetInfoMyBagsCache |
||
124 | end |
||
125 | return self.GetInfoNone |
||
126 | end |
||
127 | function MyInventoryClass:GetInfoKC(bag, slot) |
||
128 | if not MYBAGS_KC_CHARS then return self.GetInfoNone end |
||
129 | local texture, count, ID, locked, quality, readable = nil |
||
130 | charID = self.Player |
||
131 | local faction = MYBAGS_KC_CHARS[charID]["faction"] |
||
132 | local itype,isubtype = nil |
||
133 | if slot then |
||
134 | ID,count = KC_Items.inventory:SlotInfo(bag, slot, faction, charID) |
||
135 | else |
||
136 | ID,count = KC_Items.inventory:BagInfo(bag, faction, charID) |
||
137 | if bag == 0 then |
||
138 | texture = "Interface\\Buttons\\Button-Backpack-Up" |
||
139 | end |
||
140 | end |
||
141 | if ID == "" or ID == "nil" then ID = nil end |
||
142 | if ID then |
||
143 | _,_,quality,_,itype,isubtype,_,_,texture = GetItemInfo("item:"..ID) |
||
144 | _,_,_,quality = GetItemQualityColor(quality or 0) |
||
145 | if not slot then readable = ace.IsSpecialtyBag(itype,isubtype) end |
||
146 | quality = (strsub(quality,5)) -- here instead of return to keep nil if empty slot |
||
147 | end |
||
148 | count = ace.tonum(count) |
||
149 | return texture, count, ID, locked, quality, readable, nil |
||
150 | end |
||
151 | |||
152 | function MyInventoryClass:BagIDToInvSlotID(bag) |
||
153 | if bag == 0 then return nil end |
||
154 | return ContainerIDToInventoryID(bag) |
||
155 | end |
||
156 | function MyInventoryClass:IsBagSlotUsable(slot) |
||
157 | if (slot >= 0 and slot <= 4) or slot == KEYRING_CONTAINER then return true end |
||
158 | return false |
||
159 | end |
||
160 | |||
161 | MyInventory = MyInventoryClass:new() |
||
162 | MyInventory:RegisterForLoad() |