vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | AllInOneInventoryItems_Cache = {}; |
||
3 | |||
4 | AllInOneInventoryItems_NoItem = { |
||
5 | ["c"] = 0 |
||
6 | }; |
||
7 | |||
8 | local AllInOneInventoryItemsFrame_Events = { |
||
9 | "BAG_UPDATE"; |
||
10 | "BAG_UPDATE_COOLDOWN"; |
||
11 | "ITEM_LOCK_CHANGED"; |
||
12 | "UPDATE_INVENTORY_ALERTS"; |
||
13 | }; |
||
14 | |||
15 | function AllInOneInventoryItemsFrame_OnLoad() |
||
16 | local f = AllInOneInventoryItemsFrame; |
||
17 | f:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
18 | f:RegisterEvent("PLAYER_LEAVING_WORLD"); |
||
19 | f:RegisterEvent("VARIABLES_LOADED"); |
||
20 | for k,v in AllInOneInventoryItemsFrame_Events do |
||
21 | f:RegisterEvent(v); |
||
22 | end |
||
23 | end |
||
24 | |||
25 | function AllInOneInventoryItems_GetInfo(bag, slot) |
||
26 | if ( AllInOneInventoryItems_Cache[bag] ) and ( AllInOneInventoryItems_Cache[bag][slot] ) then |
||
27 | local arr = AllInOneInventoryItems_Cache[bag][slot]; |
||
28 | if ( arr.n ) then |
||
29 | return arr; |
||
30 | end |
||
31 | end |
||
32 | return nil; |
||
33 | end |
||
34 | |||
35 | function AllInOneInventoryItems_UpdateBag(bag) |
||
36 | bag = tonumber(bag); |
||
37 | if ( not bag ) then |
||
38 | for i = 0, 4 do |
||
39 | AllInOneInventoryItems_UpdateBag(i); |
||
40 | end |
||
41 | return; |
||
42 | end |
||
43 | if ( not AllInOneInventoryItems_Cache[bag] ) then |
||
44 | AllInOneInventoryItems_Cache[bag] = {}; |
||
45 | end |
||
46 | local slotMax = GetContainerNumSlots(bag); |
||
47 | local name, link; |
||
48 | local textureName, itemCount, itemLocked, itemQuality, itemReadable; |
||
49 | local ic_start, ic_duration, ic_enable; |
||
50 | for slot = 1, slotMax do |
||
51 | textureName, itemCount, itemLocked, itemQuality, itemReadable = GetContainerItemInfo(bag, slot); |
||
52 | if ( textureName ) then |
||
53 | link = GetContainerItemLink(bag, slot); |
||
54 | for nameStr in string.gfind(link, "|c%x+|Hitem:%d+:%d+:%d+:%d+|h%[(.-)%]|h|r") do |
||
55 | name = nameStr; |
||
56 | break; |
||
57 | end |
||
58 | local arr = AllInOneInventoryItems_Cache[bag][slot]; |
||
59 | if ( not arr ) then |
||
60 | arr = {}; |
||
61 | end |
||
62 | arr.n = name; |
||
63 | arr.c = itemCount; |
||
64 | arr.t = textureName; |
||
65 | arr.l = itemLocked; |
||
66 | arr.q = itemQuality; |
||
67 | arr.r = itemReadable; |
||
68 | ic_start, ic_duration, ic_enable = GetContainerItemCooldown(bag, slot); |
||
69 | arr.cs = ic_start; |
||
70 | arr.cd = ic_duration; |
||
71 | arr.ce = ic_enable; |
||
72 | if ( not AllInOneInventoryItems_Cache[bag][slot] ) then |
||
73 | AllInOneInventoryItems_Cache[bag][slot] = arr; |
||
74 | end |
||
75 | else |
||
76 | AllInOneInventoryItems_Cache[bag][slot] = {}; |
||
77 | end |
||
78 | end |
||
79 | for slot = (slotMax+1), MAX_CONTAINER_ITEMS do |
||
80 | AllInOneInventoryItems_Cache[bag][slot] = nil; |
||
81 | end |
||
82 | end |
||
83 | |||
84 | function AllInOneInventoryItems_UpdateBagCooldown(bag) |
||
85 | if ( not bag ) then |
||
86 | for i = 0, 4 do |
||
87 | AllInOneInventoryItems_UpdateBag(i); |
||
88 | end |
||
89 | return; |
||
90 | end |
||
91 | if ( not AllInOneInventoryItems_Cache[bag] ) then |
||
92 | AllInOneInventoryItems_Cache[bag] = {}; |
||
93 | end |
||
94 | local slotMax = GetContainerNumSlots(bag); |
||
95 | local name, link; |
||
96 | local ic_start, ic_duration, ic_enable; |
||
97 | local arr; |
||
98 | for slot = 1, slotMax do |
||
99 | arr = AllInOneInventoryItems_Cache[bag][slot]; |
||
100 | if ( arr ) then |
||
101 | ic_start, ic_duration, ic_enable = GetContainerItemCooldown(bag, slot); |
||
102 | arr.cs = ic_start; |
||
103 | arr.cd = ic_duration; |
||
104 | arr.ce = ic_enable; |
||
105 | end |
||
106 | end |
||
107 | end |
||
108 | |||
109 | AllInOneInventoryItemsFrame_DoUpdate_Name = "AIOI_REFRESH"; |
||
110 | AllInOneInventoryItemsFrame_DoUpdate_Names = { |
||
111 | "AIOI_REFRESH_0", |
||
112 | "AIOI_REFRESH_1", |
||
113 | "AIOI_REFRESH_2", |
||
114 | "AIOI_REFRESH_3", |
||
115 | "AIOI_REFRESH_4" |
||
116 | }; |
||
117 | |||
118 | function AllInOneInventoryItemsFrame_DoUpdate(bag, ignoreVisibility, noSchedule) |
||
119 | AllInOneInventoryItems_UpdateBag(bag); |
||
120 | AllInOneInventoryItems_UpdateFrame(ignoreVisibility); |
||
121 | if ( not noSchedule ) then |
||
122 | local n = AllInOneInventoryItemsFrame_DoUpdate_Name; |
||
123 | if ( bag ) then n = AllInOneInventoryItemsFrame_DoUpdate_Names[bag]; end |
||
124 | AIOI_ScheduleByName(n, 1.0, AllInOneInventoryItemsFrame_DoUpdate, bag, ignoreVisibility, true); |
||
125 | end |
||
126 | end |
||
127 | |||
128 | function AllInOneInventoryItemsFrame_OnEvent(event) |
||
129 | if ( event == "PLAYER_ENTERING_WORLD" ) then |
||
130 | for k,v in AllInOneInventoryItemsFrame_Events do |
||
131 | AllInOneInventoryItemsFrame:RegisterEvent(v); |
||
132 | end |
||
133 | return; |
||
134 | elseif ( event == "PLAYER_LEAVING_WORLD" ) then |
||
135 | for k,v in AllInOneInventoryItemsFrame_Events do |
||
136 | AllInOneInventoryItemsFrame:UnregisterEvent(v); |
||
137 | end |
||
138 | return; |
||
139 | elseif ( event == "BAG_UPDATE" ) then |
||
140 | AllInOneInventoryItemsFrame_DoUpdate(arg1); |
||
141 | end |
||
142 | if ( event == "BAG_UPDATE_COOLDOWN" ) then |
||
143 | AllInOneInventoryItemsFrame_DoUpdate(arg1, true); |
||
144 | end |
||
145 | if ( event == "ITEM_LOCK_CHANGED" ) then |
||
146 | AllInOneInventoryItems_UpdateFrame(); |
||
147 | end |
||
148 | if ( event == "UPDATE_INVENTORY_ALERTS" ) then |
||
149 | AllInOneInventoryItems_UpdateFrame(); |
||
150 | end |
||
151 | if ( event == "VARIABLES_LOADED" ) then |
||
152 | local f = AllInOneInventoryItemsFrame; |
||
153 | f:UnregisterEvent(event); |
||
154 | AllInOneInventoryItemsFrame_DoUpdate(); |
||
155 | end |
||
156 | end |
||
157 | |||
158 | function AllInOneInventoryItems_UpdateFrame(ignoreVisibility) |
||
159 | local frame = getglobal("AllInOneInventoryFrame"); |
||
160 | if ( frame ) and ( ( frame:IsVisible() ) or ( ignoreVisibility ) ) then |
||
161 | AllInOneInventoryFrame_Update(frame); |
||
162 | end |
||
163 | end |