annotate Classes/ItemData.class.lua @ 110:67bd5057ecb7

Implemented vendor restocking with the mover. Comitting so I can always review this working version, but I?ll be disabling all part of it as it is not going to work properly without seriously compromising the code structure. Debug messages are now appended with ?Inventorium? (my MailOpener addon was making stuff difficult). Now properly removing the refill window from the displayed static popup windows list so new popups won?t be aligned at odd locations. Changed ?CreateMoverFrame? to not contain any scenario-specific info. All settings can be set with SetFrameSettings. Items that belong to speciality bags are now put there. Other items now ignore spaciality bags. Implemented test code for mailbox refill support. It has been disabled due to some issues but may be introduced later. The guild withdrawal limit is now taken into consideration. Queue is now reset before scanning again.
author Zerotorescue
date Fri, 14 Jan 2011 23:25:05 +0100
parents 3bec0ea44607
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