# HG changeset patch # User Zerotorescue # Date 1294591773 -3600 # Node ID 252292b703ceede54ff47fbf4dcb54fd5dbb5900 # Parent ae268e5c782586dfac5a690a2b915da100b6b95e All print(...) function calls are now handled by addon:Print(text, color). The cursor will be cleared of any items/spells before moving as well as when aborting. diff -r ae268e5c7825 -r 252292b703ce Core.lua --- a/Core.lua Sun Jan 09 01:34:05 2011 +0100 +++ b/Core.lua Sun Jan 09 17:49:33 2011 +0100 @@ -93,7 +93,7 @@ if name:upper() == "DEBUG" then this.debugChannel = _G["ChatFrame" .. i]; - print("A debug channel already exists, used the old one. (" .. i .. ")"); + addon:Print("A debug channel already exists, used the old one. (" .. i .. ")"); return; end end @@ -104,7 +104,7 @@ ChatFrame_RemoveAllMessageGroups(chatFrame); this.debugChannel = chatFrame; - print("New debug channel created."); + addon:Print("New debug channel created."); end end, { "d", "debug" }); @@ -133,10 +133,10 @@ if not self.db.global.version then -- Old version was before version was saved, many changes were done in that revision - print("Updating Inventorium database from version " .. (self.db.global.version or "Unknown") .. " to version " .. addonRevision .. "..."); + addon:Print("Updating Inventorium database from version " .. (self.db.global.version or "Unknown") .. " to version " .. addonRevision .. "..."); if self.db.global and self.db.global.defaults then - print("Moving all global data into your current profile..."); + addon:Print("Moving all global data into your current profile..."); -- All data mustn't be global but profile-based self.db.profile.defaults = CopyTable(self.db.global.defaults); @@ -152,7 +152,7 @@ end if self.db.profile.defaults.minimumStock then - print("Copying the minimum stock value into the minimum global stock..."); + addon:Print("Copying the minimum stock value into the minimum global stock..."); -- We added another stock option and renamed the old to be more obvious about what it means self.db.profile.defaults.minGlobalStock = self.db.profile.defaults.minimumStock; @@ -160,7 +160,7 @@ end if self.db.profile.defaults.minimumLocalStock then - print("Renaming the minimum local stock property..."); + addon:Print("Renaming the minimum local stock property..."); -- We added another stock option and then renamed it self.db.profile.defaults.minLocalStock = self.db.profile.defaults.minimumLocalStock; @@ -168,7 +168,7 @@ end if self.db.profile.defaults.alertBelowMinimum then - print("Copying the alert below minimum value into the alert below global minimum value..."); + addon:Print("Copying the alert below minimum value into the alert below global minimum value..."); -- We added another stock option and then renamed it self.db.profile.defaults.alertBelowGlobalMinimum = self.db.profile.defaults.alertBelowMinimum; @@ -306,7 +306,7 @@ -- Pass a reference to the addon (to be used as "self") and the provided arg slashArgs[cmd](addon, arg); else - print(slashError); + addon:Print(slashError); end end @@ -426,7 +426,11 @@ addon.Colors = { Red = { 1, 0, 0 }, + Orange = { 1, .46, .1 }, Green = { 0, 1, 0 }, + Blue = { 0, 0, 1 }, + Yellow = { 1, 1, 0 }, + Cyan = { 0, 1, 1 }, }; -- easy to extend if more colors are needed function addon:Print(text, color) local red, green, blue; diff -r ae268e5c7825 -r 252292b703ce Modules/Config.lua --- a/Modules/Config.lua Sun Jan 09 01:34:05 2011 +0100 +++ b/Modules/Config.lua Sun Jan 09 17:49:33 2011 +0100 @@ -104,7 +104,7 @@ local groupName = groupIdToName[groupId]; if not itemData:AddToGroup(groupName) then - print("|cffff0000Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.|r"); + addon:Print("Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.", addon.Colors.Red); end if AceConfigRegistry then @@ -893,14 +893,14 @@ local itemData = addon.ItemData:New(itemId); if itemData:AddToGroup(groupName) then - addon.Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green); + addon:Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green); if AceConfigRegistry then -- Now rebuild the list AceConfigRegistry:NotifyChange("InventoriumOptions"); end else - addon.Print(("%s is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red); + addon:Print(("%s is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red); end end end, @@ -923,12 +923,13 @@ local itemData = addon.ItemData:New(itemId); if itemData:InGroup() then - addon.Print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(itemData.link or "Unknown", itemId, itemData:InGroup()), addon.Colors.Red); + addon:Print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(itemData.link or "Unknown", itemId, itemData:InGroup()), addon.Colors.Red); + addon:Print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(itemData.link or "Unknown", itemId, itemData:InGroup()), addon.Colors.Red); elseif itemData:AddToGroup(groupName) then - addon.Print(("Added %s to the group |cfffed000%s|r."):format(itemData.link or unknownItemName:format(itemId), groupName), addon.Colors.Green); + addon:Print(("Added %s to the group |cfffed000%s|r."):format(itemData.link or unknownItemName:format(itemId), groupName), addon.Colors.Green); end else - addon.Print(("\"%s\" is not a number."):format(value), addon.Colors.Red); + addon:Print(("\"%s\" is not a number."):format(value), addon.Colors.Red); end end @@ -955,7 +956,7 @@ set = function(info, value) local groupName = groupIdToName[info[2]]; - print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(value)); + addon:Print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(value)); -- Remember we imported this group and it's version so if it is ever changed, people can be notified if not addon.db.profile.groups[groupName].premadeGroups then @@ -971,11 +972,11 @@ local itemData = addon.ItemData:New(itemId); if not itemId then - addon.Print(("\"|cfffed000%s|r\" is not a number."):format(value), addon.Colors.Red); + addon:Print(("\"|cfffed000%s|r\" is not a number."):format(value), addon.Colors.Red); elseif itemData:InGroup() then - addon.Print(("Skipping |cfffed000%s|r as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red); + addon:Print(("Skipping |cfffed000%s|r as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red); elseif itemData:AddToGroup(groupName) then - addon.Print(("Added %s to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), groupName ), addon.Colors.Green); + addon:Print(("Added %s to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), groupName ), addon.Colors.Green); end end end @@ -1020,9 +1021,9 @@ if itemData.name:lower():find(value) then if itemData:AddToGroup(groupName) then - addon.Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green); + addon:Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green); else - addon.Print(("Couldn't add %s because it is already in a group."):format(itemData.link or unknownItemName:format(itemId)), addon.Colors.Red); + addon:Print(("Couldn't add %s because it is already in a group."):format(itemData.link or unknownItemName:format(itemId)), addon.Colors.Red); end end end @@ -1120,7 +1121,7 @@ if itemData.name:lower():find(value) then itemData:RemoveFromGroup(groupName); - addon.Print(("Removed %s from the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Red); + addon:Print(("Removed %s from the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Red); end end end @@ -1157,7 +1158,7 @@ addon.db.profile.groups[groupName].premadeGroups[value] = nil; - print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value)); + addon:Print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value)); end end, get = false, @@ -1959,13 +1960,13 @@ local result, temp = AceSerializer:Deserialize(current); if not temp.name then - print("|cffff0000The provided data is not supported.|r"); + addon:Print("The provided data is not supported.", addon.Colors.Red); elseif ValidateGroupName(nil, temp.name) ~= true then - print(("|cffff0000Aborting: A group named \"%s\" already exists.|r"):format(temp.name)); + addon:Print(("Aborting: A group named \"%s\" already exists."):format(temp.name), addon.Colors.Red); else local name = temp.name; temp.name = nil; - print(("Importing %s..."):format(name)); + addon:Print(("Importing %s..."):format(name)); if temp.items then -- Remove items that are already in another group @@ -1975,10 +1976,10 @@ local itemData = addon.ItemData:New(itemId); if not itemId then - print(("\"%s\" is not a number."):format(value)); + addon:Print(("\"%s\" is not a number."):format(value), addon.Colors.Red); temp.items[value] = nil; elseif itemData:InGroup() then - print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); + addon:Print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red); temp.items[value] = nil; else -- Ensure the keys are numeric @@ -2066,17 +2067,17 @@ -- This item was added in a more recent version than this group: Add item if itemData:InGroup() then - print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); + addon:Print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); elseif itemData:AddToGroup(groupName) then - addon.Print(("Added %s found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), premadeGroupName, itemData:InGroup() ), addon.Colors.Green); + addon:Print(("Added %s found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), premadeGroupName, itemData:InGroup() ), addon.Colors.Green); end elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then if itemData:InGroup() == groupName then itemData:RemoveFromGroup(groupName); - addon.Print(("Removed %s from the group |cfffed000%s|r as it was removed from the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup(), premadeGroupName ), addon.Colors.Red); + addon:Print(("Removed %s from the group |cfffed000%s|r as it was removed from the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup(), premadeGroupName ), addon.Colors.Red); else - print(("Skipping the removal of %s as it isn't in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); + addon:Print(("Skipping the removal of %s as it isn't in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); end end end @@ -2100,7 +2101,7 @@ if version > values.premadeGroups[premadeGroupName] then -- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it - print(("Skipping %s found in the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); + addon:Print(("Skipping %s found in the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); end end diff -r ae268e5c7825 -r 252292b703ce Modules/Mover.lua --- a/Modules/Mover.lua Sun Jan 09 01:34:05 2011 +0100 +++ b/Modules/Mover.lua Sun Jan 09 17:49:33 2011 +0100 @@ -49,7 +49,7 @@ for _, singleMove in pairs(queuedMoves) do local sourceItem = sourceContents[singleMove.id]; if not sourceItem then - print("Can't move " .. IdToItemLink(singleMove.id) .. ", non-existant in source"); + addon:Print("Can't move " .. IdToItemLink(singleMove.id) .. ", this doesn't exist in the source.", addon.Colors.Red); else -- We want to move the smallest stacks first to keep stuff pretty (and minimize space usage, splitting a stack takes 2 slots, moving something only 1) table.sort(sourceItem.locations, function(a, b) @@ -132,7 +132,7 @@ local firstAvailableSlot = emptySlots[1]; if not firstAvailableSlot then - print("Bags are full. Skipping " .. IdToItemLink(outgoingMove.itemId) .. "."); + addon:Print(("Bags are full. Skipping %s."):format(IdToItemLink(outgoingMove.itemId)), addon.Colors.Orange); outgoingMove.itemId = nil; -- remove this record from the outgoingMoves-table else @@ -260,14 +260,16 @@ addon:Debug("ProcessMove"); if #combinedMoves == 0 then - print("Nothing to move."); + addon:Print("Nothing to move."); self:Abort(); return; end - --self:RegisterEvent("BAG_UPDATE"); + -- Make sure nothing is at the mouse + ClearCursor(); + self:RegisterEvent("ITEM_LOCK_CHANGED"); self:RegisterEvent("UI_ERROR_MESSAGE"); @@ -298,7 +300,7 @@ if move and not isSourceLocked and not isTargetLocked then - print(("Moving %dx%s."):format(move.num, IdToItemLink(move.itemId))); + addon:Print(("Moving %dx%s."):format(move.num, IdToItemLink(move.itemId))); addon:Debug("Moving %dx%s from (%d,%d) to (%d,%d)", move.num, IdToItemLink(move.itemId), move.sourceContainer, move.sourceSlot, move.targetContainer, move.targetSlot); @@ -352,7 +354,7 @@ addon:Debug("%d moves processed. %d moves remaining.", (combinedMovesOriginalLength - #combinedMoves), #combinedMoves); if #combinedMoves == 0 then - print("Finished."); + addon:Print("Finished.", addon.Colors.Green); self:Abort(); @@ -383,11 +385,14 @@ addon:Debug("Aborting:%s", debugMsg); end if simple then - print("|cffff0000Aborting: " .. simple .. ".|r"); + addon:Print(("Aborting: %s."):format(simple), addon.Colors.Red); end table.wipe(combinedMoves); movesSource = nil; + -- Make sure nothing is at the mouse + ClearCursor(); + -- Stop timer self:UnregisterEvent("ITEM_LOCK_CHANGED"); self:CancelTimer(tmrProcessNext, true); -- silent diff -r ae268e5c7825 -r 252292b703ce Modules/Queue.lua --- a/Modules/Queue.lua Sun Jan 09 01:34:05 2011 +0100 +++ b/Modules/Queue.lua Sun Jan 09 17:49:33 2011 +0100 @@ -37,7 +37,7 @@ function mod:QueueGroup(groupName) if not addon.db.profile.groups[groupName] then - print(("Tried to queue items from a group named \"%s\", but no such group exists."):format(groupName)); + addon:Print(("Tried to queue items from a group named \"%s\", but no such group exists."):format(groupName), addon.Colors.Red); return; end @@ -58,7 +58,7 @@ if not temp[itemId] then local itemLink = select(2, GetItemInfo(itemId)); - print("Couldn't queue " .. (itemLink or itemId or "???") .. " (not part of this profession)"); + addon:Print(("Couldn't queue %s (not part of this profession)"):format((itemLink or itemId or "???")), addon.Colors.Orange); end end end @@ -116,11 +116,11 @@ self:Queue(i, amount, groupName); - print("Queued " .. amount .. " of " .. itemLink); + addon:Print(("Queued %d of %s"):format(amount, itemLink)); end end else - print("No usable itemcount addon found."); + addon:Print("No usable itemcount addon found."); end end end diff -r ae268e5c7825 -r 252292b703ce Modules/Scanner.lua --- a/Modules/Scanner.lua Sun Jan 09 01:34:05 2011 +0100 +++ b/Modules/Scanner.lua Sun Jan 09 17:49:33 2011 +0100 @@ -138,11 +138,11 @@ local availableItems = ((itemCache[itemId] and itemCache[itemId].totalCount) or 0); if availableItems > 0 then - print("Insufficient " .. select(2, GetItemInfo(itemId)) .. " but this location has " .. availableItems .. " (moving " .. missingItems .. ")"); + addon:Print("Insufficient " .. select(2, GetItemInfo(itemId)) .. " but this location has " .. availableItems .. " (moving " .. missingItems .. ")"); Mover:AddMove(itemId, missingItems); else - print("Insufficient " .. IdToItemLink(itemId)); + addon:Print("Insufficient " .. IdToItemLink(itemId)); end end end diff -r ae268e5c7825 -r 252292b703ce Modules/Summary v2.lua --- a/Modules/Summary v2.lua Sun Jan 09 01:34:05 2011 +0100 +++ b/Modules/Summary v2.lua Sun Jan 09 17:49:33 2011 +0100 @@ -28,7 +28,7 @@ mod.frame:SetWidth(700); mod.frame:SetHeight(600); - print("Resetting width and height of the summary frame."); + addon:Print("Resetting width and height of the summary frame."); end end, { "r", "reset" }, "|Hfunction:InventoriumCommandHandler:reset|h|cff00fff7/im reset|r|h (or /im r) - Reset the size of the summary frame."); end @@ -334,7 +334,7 @@ name = "Queue", desc = "Queue all items in this group.", exec = function() - print("Queueing all items within " .. groupName .. " craftable by the currently open profession."); + addon:Print(("Queueing all items within %s craftable by the currently open profession."):format(groupName)); self:SendMessage("IM_QUEUE_GROUP", groupName); end, }); diff -r ae268e5c7825 -r 252292b703ce Modules/Summary.lua --- a/Modules/Summary.lua Sun Jan 09 01:34:05 2011 +0100 +++ b/Modules/Summary.lua Sun Jan 09 17:49:33 2011 +0100 @@ -28,7 +28,7 @@ mod.frame:SetWidth(700); mod.frame:SetHeight(600); - print("Resetting width and height of the summary frame."); + addon:Print("Resetting width and height of the summary frame."); end end, { "r", "reset" }, "|Hfunction:InventoriumCommandHandler:reset|h|cff00fff7/im reset|r|h (or /im r) - Reset the size of the summary frame."); end @@ -256,7 +256,7 @@ name = "Queue", desc = "Queue all items in this group.", exec = function() - print("Queueing all items within " .. groupName .. " craftable by the currently open profession."); + addon:Print(("Queueing all items within %s craftable by the currently open profession."):format(groupName)); self:SendMessage("IM_QUEUE_GROUP", groupName); end, });