diff --git a/BagSync.lua b/BagSync.lua
index 33615da..861da15 100644
--- a/BagSync.lua
+++ b/BagSync.lua
@@ -29,7 +29,6 @@ local BS_GD
local BS_TD
local MAX_GUILDBANK_SLOTS_PER_TAB = 98
local doTokenUpdate = 0
-local ammoCount = 0
local SILVER = '|cffc7c7cf%s|r'
local MOSS = '|cFF80FF00%s|r'
@@ -44,7 +43,8 @@ local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local dataobj = ldb:NewDataObject("BagSyncLDB", {
type = "data source",
- icon = "Interface\\Icons\\INV_Misc_Bag_12",
+ --icon = "Interface\\Icons\\INV_Misc_Bag_12",
+ icon = "Interface\\AddOns\\BagSync\\media\\icon",
label = "BagSync",
text = "BagSync",
@@ -122,11 +122,6 @@ function BagSync:PLAYER_LOGIN()
BS_DB.guild = nil
end
- --check for hunter
- if playerClass == "HUNTER" then
- ammoCount = GetInventoryItemCount('player', 0) or 0
- end
-
--this will force an update of the -2 key ring
self:SaveBag('key', KEYRING_CONTAINER, true)
@@ -140,7 +135,14 @@ function BagSync:PLAYER_LOGIN()
--force token scan
self:ScanTokens()
-
+
+ --check for minimap toggle
+ if BagSyncOpt.enableMinimap and not BagSync_MinimapButton:IsVisible() then
+ BagSync_MinimapButton:Show()
+ elseif not BagSyncOpt.enableMinimap and BagSync_MinimapButton:IsVisible() then
+ BagSync_MinimapButton:Hide()
+ end
+
self:RegisterEvent('PLAYER_MONEY')
self:RegisterEvent('BANKFRAME_OPENED')
self:RegisterEvent('BANKFRAME_CLOSED')
@@ -196,6 +198,14 @@ function BagSync:PLAYER_LOGIN()
elseif c and c:lower() == L["fixdb"] then
self:FixDB_Data()
return true
+ elseif c and c:lower() == L["minimap"] then
+ BagSyncOpt.enableMinimap = not BagSyncOpt.enableMinimap
+ if BagSyncOpt.enableMinimap and not BagSync_MinimapButton:IsVisible() then
+ BagSync_MinimapButton:Show()
+ elseif not BagSyncOpt.enableMinimap and BagSync_MinimapButton:IsVisible() then
+ BagSync_MinimapButton:Hide()
+ end
+ return true
elseif c and slashChk[c:lower()] and BagSyncOpt[slashChk[c:lower()]] ~= nil then
lastDisplayed = {}
lastItem = nil
@@ -228,6 +238,7 @@ function BagSync:PLAYER_LOGIN()
DEFAULT_CHAT_FRAME:AddMessage(L["/bgs guildname - Toggles the [Guild Name] display in tooltips."])
DEFAULT_CHAT_FRAME:AddMessage(L["/bgs throttle - Toggles the throttle when displaying tooltips. (ON = Prevents Lag)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/bgs guild - Toggles the displaying of guild information."])
+ DEFAULT_CHAT_FRAME:AddMessage(L["/bgs minimap - Toggles the displaying of BagSync minimap button."])
end
@@ -335,6 +346,7 @@ function BagSync:StartupDB()
if BagSyncOpt.enableGuild == nil then BagSyncOpt.enableGuild = true end
if BagSyncOpt.enableMailbox == nil then BagSyncOpt.enableMailbox = true end
if BagSyncOpt.enableUnitClass == nil then BagSyncOpt.enableUnitClass = false end
+ if BagSyncOpt.enableMinimap == nil then BagSyncOpt.enableMinimap = false end
BagSyncGUILD_DB = BagSyncGUILD_DB or {}
BagSyncGUILD_DB[currentRealm] = BagSyncGUILD_DB[currentRealm] or {}
@@ -376,7 +388,7 @@ function BagSync:FixDB_Data()
BagSyncDB[realm][k][q] = nil
end
elseif db1 == 'equip' then
- if not(db2 >= 0 and db2 <= NUM_EQUIPMENT_SLOTS) then
+ if not(db2 >= 0 and (db2 > 0 and db2 <= NUM_EQUIPMENT_SLOTS) ) then
BagSyncDB[realm][k][q] = nil
end
end
@@ -548,9 +560,6 @@ end
function BagSync:OnBagUpdate(bagid)
- --do hunter check
- if BagSync:DoHunterCheck() then return end
-
--this will update the bank/bag slots
local bagname
@@ -594,10 +603,8 @@ function BagSync:SaveEquipment()
lastItem = nil
lastDisplayed = {}
- --do hunter check
- if BagSync:DoHunterCheck(true) then return end
-
- for slot = 0, NUM_EQUIPMENT_SLOTS do
+ --start at 1, 0 used to be the old range slot (not needed anymore)
+ for slot = 1, NUM_EQUIPMENT_SLOTS do
local link = GetInventoryItemLink('player', slot)
local index = GetTag('equip', 0, slot)
@@ -607,12 +614,7 @@ function BagSync:SaveEquipment()
count = count > 1 and count or nil
if (linkItem and count) then
- --check for ranged slot ammo, don't add twice
- if slot == GetInventorySlotInfo("AmmoSlot") and count <= 1 then
- BS_DB[index] = format('%s,%d', linkItem, count)
- elseif slot ~= GetInventorySlotInfo("AmmoSlot") then
BS_DB[index] = format('%s,%d', linkItem, count)
- end
else
BS_DB[index] = linkItem
end
@@ -722,24 +724,6 @@ function BagSync:ScanMailbox()
BagSync.isCheckingMail = nil
end
-function BagSync:DoHunterCheck(equipSwitch)
- --if not hunter return true, or if not in combat return true
- if playerClass ~= "HUNTER" then return false end
- if not UnitAffectingCombat("player") then return false end
-
- --this function is used to prevent scan spamming of the bags due to hunter ammo being used
- local currAmmo = (GetInventoryItemCount('player', 0) or 0)
-
- if not equipSwitch and ammoCount ~= currAmmo then
- return true
- elseif ammoCount ~= currAmmo then
- ammoCount = (GetInventoryItemCount('player', 0) or 0)
- return true
- end
-
- return false
-end
-
------------------------
-- Money Tooltip --
------------------------
@@ -860,8 +844,9 @@ function BagSync:ScanTokens()
local lastHeader
for i=1, GetCurrencyListSize() do
- local name, isHeader, isExpanded, _, _, count, extraCurrencyType, icon, itemID = GetCurrencyListInfo(i)
- --extraCurrencyType = 1 for arena points, 2 for honor points; 0 otherwise (an item-based currency).
+ local name, isHeader, isExpanded, _, _, count, icon = GetCurrencyListInfo(i)
+ --extraCurrencyType = 1 for arena points, 2 for honor points; 0 otherwise (an item-based currency).
+
if name then
if(isHeader and not isExpanded) then
ExpandCurrencyList(i,1)
@@ -870,13 +855,12 @@ function BagSync:ScanTokens()
lastHeader = name
end
if (not isHeader) then
- if BS_TD and itemID then
+ if BS_TD then
BS_TD = BS_TD or {}
- BS_TD[itemID] = BS_TD[itemID] or {}
- BS_TD[itemID].name = name
- BS_TD[itemID].icon = icon
- BS_TD[itemID].header = lastHeader
- BS_TD[itemID][currentPlayer] = count
+ BS_TD[name] = BS_TD[name] or {}
+ BS_TD[name].icon = icon
+ BS_TD[name].header = lastHeader
+ BS_TD[name][currentPlayer] = count
end
end
end
@@ -884,33 +868,6 @@ function BagSync:ScanTokens()
end
-function BagSync:AddTokenTooltip(self)
- if not self:GetParent().index then return end
- local _, _, _, _, _, _, _, _, itemID = GetCurrencyListInfo(self:GetParent().index)
-
- if not BS_TD then return end
- if not BS_TD[itemID] then return end
-
- tmp = {}
- for k, v in pairs(BS_TD[itemID]) do
- if k ~= "name" and k ~= "icon" and k ~= "header" then
- if v > 0 then
- table.insert(tmp, { name=k, count=v} )
- end
- end
- end
-
- if #tmp > 0 then
- table.sort(tmp, function(a,b) return (a.name < b.name) end)
-
- GameTooltip:AddLine(' ')
- for i=1, #tmp do
- GameTooltip:AddDoubleLine(format(MOSS, tmp[i].name), format(SILVER, tmp[i].count))
- end
- GameTooltip:Show()
- end
-end
-
function BagSync:PLAYER_REGEN_ENABLED()
if BagSync:IsInBG() or BagSync:IsInArena() or InCombatLockdown() or UnitAffectingCombat("player") then return end
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
@@ -941,19 +898,6 @@ function BagSync:IsInArena()
return true
end
---display in currency window tooltip, this is from Blizzard_TokenUI
---hooksecurefunc("TokenFrame_Update", function()
- --if TokenFrameContainer.buttons == nil then return end
- --local buttons = TokenFrameContainer.buttons
- --for i = 1, #buttons do
- -- local button = buttons[i]
- -- if not button.hookedOnEnter then
- -- button.LinkButton:HookScript("OnEnter", function(self) BagSync:AddTokenTooltip(self) end)
- -- button.hookedOnEnter = true
- -- end
- -- end
---end)
-
hooksecurefunc("BackpackTokenFrame_Update", BagSync.ScanTokens)
------------------------
diff --git a/BagSync.toc b/BagSync.toc
index 59c4db9..d01fcf6 100644
--- a/BagSync.toc
+++ b/BagSync.toc
@@ -2,7 +2,7 @@
## Title: BagSync
## Notes: BagSync tracks your characters items and displays it within tooltips.
## Author: Xruptor
-## Version: 5.0.1
+## Version: 5.1
## SavedVariables: BagSyncDB, BagSyncOpt, BagSyncGUILD_DB, BagSyncTOKEN_DB
localization\localization.lua
@@ -16,4 +16,5 @@ libs\LibDataBroker-1.1.lua
BagSync_Search.lua
BagSync_Tokens.lua
BagSync_Profiles.lua
+BagSync_Minimap.lua
BagSync.lua
\ No newline at end of file
diff --git a/BagSync_Minimap.lua b/BagSync_Minimap.lua
new file mode 100644
index 0000000..de902ad
--- /dev/null
+++ b/BagSync_Minimap.lua
@@ -0,0 +1,62 @@
+--Minimap Button for BagSync
+--So people can stop PESTERING me about a dang button, why can't they just use DataBroker sheesh
+
+local bgMinimapButton = CreateFrame("Frame","BagSync_MinimapButton", Minimap)
+bgMinimapButton:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end)
+
+bgMinimapButton:SetHeight(32)
+bgMinimapButton:SetWidth(32)
+bgMinimapButton:SetMovable(1)
+bgMinimapButton:SetUserPlaced(1)
+bgMinimapButton:EnableMouse(1)
+bgMinimapButton:RegisterForDrag('LeftButton')
+bgMinimapButton:SetFrameStrata('MEDIUM')
+bgMinimapButton:SetPoint('CENTER', Minimap:GetWidth()/3*-0.9, Minimap:GetHeight()/2*-1);
+bgMinimapButton:CreateTexture('bgMinimapButtonTexture', 'BACKGROUND')
+bgMinimapButton:SetClampedToScreen(true)
+
+bgMinimapButtonTexture:SetWidth(32)
+bgMinimapButtonTexture:SetHeight(32)
+bgMinimapButtonTexture:SetTexture('Interface\\AddOns\\BagSync\\media\\minimap.tga')
+bgMinimapButtonTexture:SetPoint('CENTER')
+
+bgMinimapButton:SetScript('OnMouseUp', function(self, button)
+ if button == 'LeftButton' then
+ if BagSync_SearchFrame:IsVisible() then
+ BagSync_SearchFrame:Hide()
+ else
+ BagSync_SearchFrame:Show()
+ end
+ end
+end)
+
+bgMinimapButton:SetScript('OnDragStart', function(self, button)
+ if IsShiftKeyDown() then
+ bgMinimapButton:SetScript('OnUpdate', function(self, elapsed)
+ local x, y = Minimap:GetCenter()
+ local cx, cy = GetCursorPosition()
+ x, y = cx / self:GetEffectiveScale() - x, cy / self:GetEffectiveScale() - y
+ if x > Minimap:GetWidth()/2+bgMinimapButton:GetWidth()/2 then x = Minimap:GetWidth()/2+bgMinimapButton:GetWidth()/2 end
+ if x < Minimap:GetWidth()/2*-1-bgMinimapButton:GetWidth()/2 then x = Minimap:GetWidth()/2*-1-bgMinimapButton:GetWidth()/2 end
+ if y > Minimap:GetHeight()/2+bgMinimapButton:GetHeight()/2 then y = Minimap:GetHeight()/2+bgMinimapButton:GetHeight()/2 end
+ if y < Minimap:GetHeight()/2*-1-bgMinimapButton:GetHeight()/2 then y = Minimap:GetHeight()/2*-1-bgMinimapButton:GetHeight()/2 end
+ bgMinimapButton:ClearAllPoints()
+ bgMinimapButton:SetPoint('CENTER', x, y)
+ end)
+ end
+end)
+
+bgMinimapButton:SetScript('OnDragStop', function(self, button)
+ bgMinimapButton:SetScript('OnUpdate', nil)
+end)
+
+bgMinimapButton:SetScript('OnEnter', function(self)
+ GameTooltip:SetOwner(bgMinimapButton)
+ GameTooltip:SetText('BagSync')
+ GameTooltip:Show()
+end)
+
+bgMinimapButton:SetScript('OnLeave', function(self)
+ GameTooltip:Hide()
+end)
+
diff --git a/BagSync_Tokens.lua b/BagSync_Tokens.lua
index e6f4a70..a0be19a 100644
--- a/BagSync_Tokens.lua
+++ b/BagSync_Tokens.lua
@@ -118,15 +118,11 @@ function bgTokens:LoadSlider()
for i,row in ipairs(tRows) do
if (i + offset) <= #tokensTable then
if tokensTable[i + offset] then
- if tokensTable[i + offset].rarity then
- local hex = (select(4, GetItemQualityColor(tokensTable[i + offset].rarity)))
- row.title:SetText(format('%s%s|r', hex, tokensTable[i + offset].name) or tokensTable[i + offset].name)
+
+ if tokensTable[i + offset].isHeader then
+ row.title:SetText("|cFFFFFFFF"..tokensTable[i + offset].name.."|r")
else
- if tokensTable[i + offset].isHeader then
- row.title:SetText("|cFFFFFFFF"..tokensTable[i + offset].name.."|r")
- else
- row.title:SetText(tokensTable[i + offset].name)
- end
+ row.title:SetText(tokensTable[i + offset].name)
end
--header texture and parameters
@@ -196,23 +192,20 @@ function bgTokens:DoTokens()
-----------------------------------
if BS_TD then
for k, v in pairs(BS_TD) do
- local _, _, dRarity = GetItemInfo(k)
-
+
tmp = {}
+ --this will loop and store all characters whom have counts greater then zero,
+ --ignoring the icon and header table entry, then it sorts it by character name
for q, r in pairs(v) do
- if q ~= "name" and q ~= "icon" and q ~= "header" and r > 0 then
+ if q ~= "icon" and q ~= "header" and r > 0 then
--only show counts that are greater then zero
table.insert(tmp, { name=q, count=r} )
end
end
table.sort(tmp, function(a,b) return (a.name < b.name) end)
- if dRarity and k ~= 43307 and k ~= 43308 then
- --43307 = Arena, 43308 = Honor Points
- table.insert(tokensTable, {name=v.name, link=k, icon=v.icon, header=v.header, tooltip=tmp, rarity=dRarity})
- else
- table.insert(tokensTable, {name=v.name, link=k, icon=v.icon, header=v.header, tooltip=tmp})
- end
+ --now sort the entire table
+ table.insert(tokensTable, {name=k, icon=v.icon, header=v.header, tooltip=tmp})
end
end
-----------------------------------
diff --git a/media/icon.tga b/media/icon.tga
new file mode 100644
index 0000000..f7669fa
Binary files /dev/null and b/media/icon.tga differ
diff --git a/media/minimap.tga b/media/minimap.tga
new file mode 100644
index 0000000..045905a
Binary files /dev/null and b/media/minimap.tga differ