annotate 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
rev   line source
Zerotorescue@74 1 local addon = select(2, ...);
Zerotorescue@74 2
Zerotorescue@74 3 -- Define the class
Zerotorescue@74 4
Zerotorescue@74 5 addon.ItemData = {};
Zerotorescue@74 6 addon.ItemData.__index = addon.ItemData;
Zerotorescue@74 7
Zerotorescue@74 8 -- Construct
Zerotorescue@74 9 function addon.ItemData:New(itemId)
Zerotorescue@74 10 local self = {};
Zerotorescue@74 11
Zerotorescue@74 12 setmetatable(self, addon.ItemData);
Zerotorescue@74 13
Zerotorescue@74 14 local itemName, itemLink, itemRarity, _, _, _, _, _, _, itemTexture = GetItemInfo(itemId);
Zerotorescue@74 15
Zerotorescue@74 16 -- Standard info everything needs
Zerotorescue@74 17 self.id = itemId;
Zerotorescue@74 18 self.name = itemName;
Zerotorescue@74 19 self.link = itemLink;
Zerotorescue@74 20 self.rarity = itemRarity;
Zerotorescue@74 21 self.icon = itemTexture;
Zerotorescue@74 22
Zerotorescue@74 23 -- Detailed stuff
Zerotorescue@74 24 self.value = -3;
Zerotorescue@74 25 self.globalCount = -3;
Zerotorescue@74 26 self.localCount = -3;
Zerotorescue@74 27 self.set = {};
Zerotorescue@74 28
Zerotorescue@74 29 return self;
Zerotorescue@74 30 end
Zerotorescue@76 31
Zerotorescue@76 32 function addon.ItemData:AddToGroup(groupName)
Zerotorescue@76 33 if self:InGroup() then
Zerotorescue@76 34 return false;
Zerotorescue@76 35 end
Zerotorescue@76 36
Zerotorescue@76 37 if not addon.db.profile.groups[groupName].items then
Zerotorescue@76 38 addon.db.profile.groups[groupName].items = {};
Zerotorescue@76 39 end
Zerotorescue@76 40
Zerotorescue@76 41 -- Set this item
Zerotorescue@76 42 addon.db.profile.groups[groupName].items[self.id] = true;
Zerotorescue@76 43
Zerotorescue@76 44 return true;
Zerotorescue@76 45 end
Zerotorescue@76 46
Zerotorescue@76 47 -- To remove an item without groupname just do RemoveFromGroup(InGroup()), although providing the group name is a nice sanity check
Zerotorescue@76 48 function addon.ItemData:RemoveFromGroup(groupName)
Zerotorescue@76 49 if self:InGroup() ~= groupName then
Zerotorescue@76 50 return false;
Zerotorescue@76 51 end
Zerotorescue@76 52
Zerotorescue@76 53 -- Unset this item
Zerotorescue@76 54 addon.db.profile.groups[groupName].items[self.id] = nil;
Zerotorescue@76 55
Zerotorescue@76 56 return true;
Zerotorescue@76 57 end
Zerotorescue@76 58
Zerotorescue@76 59 function addon.ItemData:InGroup()
Zerotorescue@76 60 -- Go through all groups to see if this item is already somewhere
Zerotorescue@76 61 for groupName, values in pairs(addon.db.profile.groups) do
Zerotorescue@76 62 if values.items and values.items[self.id] then
Zerotorescue@76 63 return groupName;
Zerotorescue@76 64 end
Zerotorescue@76 65 end
Zerotorescue@76 66
Zerotorescue@76 67 return;
Zerotorescue@76 68 end