comparison Classes/ItemData.class.lua @ 84:3bec0ea44607

Cleaned the Inventorium folder; moved all classes to classes directory, modules to modules directory and support addons to plugins directory. In addition support addons are now references within XML files rather than inside the TOC. Fixed the default local item count setting, you can now exclude bag and AH data from it. Fixed some mover algorithm bugs. Mover can no longer freeze the game but instead will terminate the process after a 1000 passes. Now reversing the moves table after making it, rather than every single time it is used. Fixed guild bank support. Now displaying the amount of items moved. Scanner now scans all guild bank tabs rather than only the current. Fixed a bug with local item data not being retrieved properly. Disabled ?enterClicksFirstButton? within dialogs as this causes the dialog to consume all keypress. Events are now at the addon object rather than local.
author Zerotorescue
date Thu, 06 Jan 2011 20:05:30 +0100
parents ItemData.class.lua@958aba5f3297
children
comparison
equal deleted inserted replaced
83:6b60f7a1410c 84:3bec0ea44607
1 local addon = select(2, ...);
2
3 -- Define the class
4
5 addon.ItemData = {};
6 addon.ItemData.__index = addon.ItemData;
7
8 -- Construct
9 function addon.ItemData:New(itemId)
10 local self = {};
11
12 setmetatable(self, addon.ItemData);
13
14 local itemName, itemLink, itemRarity, _, _, _, _, _, _, itemTexture = GetItemInfo(itemId);
15
16 -- Standard info everything needs
17 self.id = itemId;
18 self.name = itemName;
19 self.link = itemLink;
20 self.rarity = itemRarity;
21 self.icon = itemTexture;
22
23 -- Detailed stuff
24 self.value = -3;
25 self.globalCount = -3;
26 self.localCount = -3;
27 self.set = {};
28
29 return self;
30 end
31
32 function addon.ItemData:AddToGroup(groupName)
33 if self:InGroup() then
34 return false;
35 end
36
37 if not addon.db.profile.groups[groupName].items then
38 addon.db.profile.groups[groupName].items = {};
39 end
40
41 -- Set this item
42 addon.db.profile.groups[groupName].items[self.id] = true;
43
44 return true;
45 end
46
47 -- To remove an item without groupname just do RemoveFromGroup(InGroup()), although providing the group name is a nice sanity check
48 function addon.ItemData:RemoveFromGroup(groupName)
49 if self:InGroup() ~= groupName then
50 return false;
51 end
52
53 -- Unset this item
54 addon.db.profile.groups[groupName].items[self.id] = nil;
55
56 return true;
57 end
58
59 function addon.ItemData:InGroup()
60 -- Go through all groups to see if this item is already somewhere
61 for groupName, values in pairs(addon.db.profile.groups) do
62 if values.items and values.items[self.id] then
63 return groupName;
64 end
65 end
66
67 return;
68 end