Mercurial > wow > inventory
comparison Core.lua @ 65:ac1189599769
Added warning to AuctionLite pricing addon selection stating the addon wasn?t tested properly yet.
Premade groups check now occurs when the config is opened rather than upon login.
All multiselects are now dropdowns as they are meant to be. Please ensure the pullouts are closed before switching groups or closing the window or you may get some LUA errors (thanks Wowace for not fixing what seems to be a year old issue).
Hopefully added support for the crafting addon ?Cauldron?, but this still has to be tested.
author | Zerotorescue |
---|---|
date | Thu, 23 Dec 2010 03:19:27 +0100 |
parents | fee06221176f |
children | 057f6661ad9d |
comparison
equal
deleted
inserted
replaced
64:0bd50500561c | 65:ac1189599769 |
---|---|
115 self.db.factionrealm.characters[playerName] = true; | 115 self.db.factionrealm.characters[playerName] = true; |
116 | 116 |
117 -- Default to tracking on all chars, untracking is a convenience, not tracking by default would probably get multiple issue reports. | 117 -- Default to tracking on all chars, untracking is a convenience, not tracking by default would probably get multiple issue reports. |
118 self.db.profile.defaults.trackAtCharacters[playerName] = true; | 118 self.db.profile.defaults.trackAtCharacters[playerName] = true; |
119 end | 119 end |
120 | 120 end |
121 self:PremadeGroupsCheck(); | 121 |
122 end | 122 |
123 | |
124 | |
125 | |
126 -- Database patching after new revisions | |
123 | 127 |
124 function addon:UpdateDatabase() | 128 function addon:UpdateDatabase() |
125 if not self.db.global.version or self.db.global.version < addonRevision then | 129 if not self.db.global.version or self.db.global.version < addonRevision then |
126 -- Is our database outdated? Then patch it. | 130 -- Is our database outdated? Then patch it. |
127 | 131 |
182 -- Remember the version of our database | 186 -- Remember the version of our database |
183 self.db.global.version = addonRevision; | 187 self.db.global.version = addonRevision; |
184 end | 188 end |
185 end | 189 end |
186 | 190 |
187 function addon:PremadeGroupsCheck(updateGroupName, updateKey, accept) | |
188 -- Compare the current premade groups with those used, notify about changes | |
189 if addon.defaultGroups then | |
190 for premadeGroupName, groupInfo in pairs(addon.defaultGroups) do | |
191 -- Go through all default groups | |
192 | |
193 for groupName, values in pairs(addon.db.profile.groups) do | |
194 -- Go through all groups to find those with this premade group | |
195 | |
196 if values.premadeGroups and values.premadeGroups[premadeGroupName] and values.premadeGroups[premadeGroupName] < groupInfo.version then | |
197 -- Outdated group | |
198 | |
199 if updateGroupName and updateKey then | |
200 -- This function was called after pressing yes or no in a confirm box | |
201 | |
202 if accept then | |
203 -- Yes was clicked | |
204 | |
205 for itemId, version in pairs(groupInfo.items) do | |
206 -- Go through all items in this premade group | |
207 | |
208 if version > values.premadeGroups[premadeGroupName] then | |
209 -- This item was added in a more recent version than this group: Add item | |
210 | |
211 if self:InGroup(itemId) then | |
212 print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, self:InGroup(itemId))); | |
213 elseif self:AddItemToGroup(groupName, itemId) then | |
214 print(("|cff00ff00Added|r %s (#%d) found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, premadeGroupName, self:InGroup(itemId))); | |
215 end | |
216 elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then | |
217 if self:InGroup(itemId) == groupName then | |
218 print(("|cffff0000Removed|r %s (#%d) from the group |cfffed000%s|r as it was removed from the premade group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, self:InGroup(itemId), premadeGroupName)); | |
219 self:RemoveItemFromGroup(groupName, itemId); | |
220 else | |
221 print(("Skipping the removal of %s (#%d) as it isn't in this group."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, self:InGroup(itemId))); | |
222 end | |
223 end | |
224 end | |
225 | |
226 -- Remember the new version | |
227 values.premadeGroups[premadeGroupName] = groupInfo.version; | |
228 else | |
229 -- No was clicked | |
230 | |
231 -- Let user know what was not added | |
232 for itemId, version in pairs(groupInfo.items) do | |
233 -- Go through all items in this premade group | |
234 | |
235 if version > values.premadeGroups[premadeGroupName] then | |
236 -- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it | |
237 | |
238 print(("Skipping %s (#%d) found in the premade group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, self:InGroup(itemId))); | |
239 end | |
240 end | |
241 | |
242 -- Remember the new version | |
243 values.premadeGroups[premadeGroupName] = groupInfo.version; | |
244 end | |
245 else | |
246 StaticPopupDialogs["InventoriumConfirmUpdatePremadeGroup"] = { | |
247 text = "The premade group |cfffed000%s|r used in the group |cfffed000%s|r has been changed. Do you wish to copy these changes?", | |
248 button1 = YES, | |
249 button2 = NO, | |
250 OnAccept = function(self) | |
251 addon:PremadeGroupsCheck(groupName, premadeGroupName, true); | |
252 end, | |
253 OnCancel = function(self, _, reason) | |
254 if reason == "clicked" then | |
255 addon:PremadeGroupsCheck(groupName, premadeGroupName, false); | |
256 end | |
257 end, | |
258 timeout = 0, | |
259 whileDead = 1, | |
260 hideOnEscape = 1, | |
261 }; | |
262 StaticPopup_Show("InventoriumConfirmUpdatePremadeGroup", premadeGroupName, groupName); | |
263 | |
264 return; | |
265 end | |
266 end | |
267 end | |
268 end | |
269 end | |
270 end | |
271 | |
272 function addon:GetItemId(itemLink) | 191 function addon:GetItemId(itemLink) |
273 itemLink = itemLink and itemLink:match("|Hitem:([-0-9]+):"); -- if itemLink is nil, it won't execute the second part | 192 itemLink = itemLink and itemLink:match("|Hitem:([-0-9]+):"); -- if itemLink is nil, it won't execute the second part |
274 itemLink = itemLink and tonumber(itemLink); | 193 itemLink = itemLink and tonumber(itemLink); |
275 | 194 |
276 return itemLink; | 195 return itemLink; |
374 end | 293 end |
375 | 294 |
376 return -2; | 295 return -2; |
377 end | 296 end |
378 | 297 |
298 | |
299 | |
300 | |
301 | |
379 -- Slash commands | 302 -- Slash commands |
380 | 303 |
381 local slashArgs = {}; | 304 local slashArgs = {}; |
382 local slashError = "Wrong argument, the following arguments are available:"; | 305 local slashError = "Wrong argument, the following arguments are available:"; |
383 | 306 |
401 if description then | 324 if description then |
402 slashError = slashError .. "\n" .. description; | 325 slashError = slashError .. "\n" .. description; |
403 end | 326 end |
404 end | 327 end |
405 | 328 |
329 | |
330 | |
331 | |
332 | |
406 -- Group functions | 333 -- Group functions |
407 | 334 |
408 function addon:InGroup(itemId) | 335 function addon:InGroup(itemId) |
409 -- Go through all groups to see if this item is already somewhere | 336 -- Go through all groups to see if this item is already somewhere |
410 for groupName, values in pairs(addon.db.profile.groups) do | 337 for groupName, values in pairs(addon.db.profile.groups) do |
444 -- Unset this item | 371 -- Unset this item |
445 addon.db.profile.groups[groupName].items[itemId] = nil; | 372 addon.db.profile.groups[groupName].items[itemId] = nil; |
446 | 373 |
447 return true; | 374 return true; |
448 end | 375 end |
376 | |
377 | |
378 | |
379 | |
449 | 380 |
450 -- Readable money | 381 -- Readable money |
451 | 382 |
452 local goldText = "%s%d|cffffd700g|r "; | 383 local goldText = "%s%d|cffffd700g|r "; |
453 local silverText = "%s%d|cffc7c7cfs|r "; | 384 local silverText = "%s%d|cffc7c7cfs|r "; |
505 end | 436 end |
506 end | 437 end |
507 | 438 |
508 | 439 |
509 | 440 |
441 | |
442 | |
510 -- Public | 443 -- Public |
511 | 444 |
512 function IMRegisterPricingAddon(name, get, enabled, onSelect) | 445 function IMRegisterPricingAddon(name, get, enabled, onSelect) |
513 addon.supportedAddons.auctionPricing[name] = { | 446 addon.supportedAddons.auctionPricing[name] = { |
514 GetValue = get, | 447 GetValue = get, |
539 addon:CommandHandler(msg); | 472 addon:CommandHandler(msg); |
540 end | 473 end |
541 | 474 |
542 | 475 |
543 | 476 |
477 | |
478 | |
544 -- Debug | 479 -- Debug |
545 | 480 |
546 function addon:Debug(t) | 481 function addon:Debug(t) |
547 if not self.debugChannel and self.debugChannel ~= false then | 482 if not self.debugChannel and self.debugChannel ~= false then |
548 -- We want to check just once, so if you add a debug channel later just do a /reload (registering an event for this is wasted resources) | 483 -- We want to check just once, so if you add a debug channel later just do a /reload (registering an event for this is wasted resources) |