Commit f2b99dad authored by Merathilis's avatar Merathilis

Added another AutoBar for usable items.

parent d2b53489
......@@ -33,4 +33,16 @@
<Binding name="CLICK AutoQuestButton10:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoQuestButton11:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoQuestButton12:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton1:LeftButton" header= "AutoUsableButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton2:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton3:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton4:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton5:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton6:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton7:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton8:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton9:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton10:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton11:LeftButton" category="BINDING_HEADER_MER"/>
<Binding name="CLICK AutoUsableButton12:LeftButton" category="BINDING_HEADER_MER"/>
</Bindings>
......@@ -40,10 +40,12 @@ local garrisonsc = {114116, 114119, 114120, 120301, 120302}
_G.BINDING_HEADER_MER_AutoSlotButton = MER.Title..L["soltAutoButtons"]
_G.BINDING_HEADER_MER_AutoQuestButton = MER.Title..L["questAutoButtons"]
_G.BINDING_HEADER_MER_AutoUsableButton = MER.Title..L["usableAutoButtons"]
for i = 1, 12 do
_G["BINDING_NAME_CLICK AutoSlotButton"..i..":LeftButton"] = L["soltAutoButtons"]..i
_G["BINDING_NAME_CLICK AutoQuestButton"..i..":LeftButton"] = L["questAutoButtons"]..i
_G["BINDING_NAME_CLICK AutoUsableButton"..i..":LeftButton"] = L["usableAutoButtons"]..i
end
local function GetQuestItemList()
......@@ -146,6 +148,9 @@ local function HideAllButton(event)
for i = 1, 12 do
AutoButtonHide(_G["AutoSlotButton" .. i])
end
for i = 1, 12 do
AutoButtonHide(_G["AutoUsableButton" .. i])
end
end
local function AutoButtonShow(AutoButton)
......@@ -248,7 +253,9 @@ function module:ScanItem(event)
GetWorldQuestItemList("init")
local questItemIDList = {}
local usableItemIDList = {}
local minimapZoneText = GetMinimapZoneText()
if minimapZoneText == L["Alliance Mine"] or minimapZoneText == L["Horde Mine"] then
for i = 1, #garrisonsmv do
local count = GetItemCount(garrisonsmv[i])
......@@ -271,14 +278,14 @@ function module:ScanItem(event)
end
end
end
for k, v in pairs(db["whiteList"]) do
for k, v in pairs(db.whiteList) do
local count = GetItemCount(k)
if count and (count > 0) and v and (not db.blackList[k]) then
tinsert(questItemIDList, k)
tinsert(usableItemIDList, k)
end
end
if GetItemCount(123866) and (GetItemCount(123866) >= 5) and (not db.blackList[123866]) and (C_Map_GetBestMapForUnit("player") == 945) then
tinsert(questItemIDList, 123866)
tinsert(usableItemIDList, 123866)
end
end
......@@ -292,6 +299,16 @@ function module:ScanItem(event)
end
end)
tsort(usableItemIDList, function(v1, v2)
local itemType1 = select(7, GetItemInfo(v1))
local itemType2 = select(7, GetItemInfo(v2))
if itemType1 and itemType2 then
return itemType1 > itemType2
else
return v1 > v2
end
end)
if db.questAutoButtons["enable"] == true and db.questAutoButtons["questNum"] > 0 then
for i = 1, #questItemIDList do
local itemID = questItemIDList[i]
......@@ -392,6 +409,59 @@ function module:ScanItem(event)
end
end
end
if db.usableAutoButtons["enable"] == true and db.usableAutoButtons["usableNum"] > 0 then
for i = 1, #usableItemIDList do
local itemID = usableItemIDList[i]
local itemName, _, rarity = GetItemInfo(itemID)
if i > db.usableAutoButtons["usableNum"] then break end
local AutoButton = _G["AutoUsableButton" .. i]
local count = GetItemCount(itemID, nil, 1)
local itemIcon = GetItemIcon(itemID)
if not AutoButton then break end
AutoButton.Texture:SetTexture(itemIcon)
AutoButton.itemName = itemName
AutoButton.itemID = itemID
--AutoButton.ap = false
AutoButton.spellName = IsUsableItem(itemID)
AutoButton:SetBackdropBorderColor(nil)
if db.usableAutoButtons["usableBBColorByItem"] then
if rarity and rarity > LE_ITEM_QUALITY_COMMON then
local r, g, b = GetItemQualityColor(rarity)
AutoButton:SetBackdropBorderColor(r, g, b)
else
AutoButton:SetBackdropBorderColor(1, 1, 1)
end
else
local colorDB = db.usableAutoButtons["usableBBColor"]
local r, g, b = colorDB.r, colorDB.g, colorDB.b
AutoButton:SetBackdropBorderColor(r, g, b)
end
if count and count > 1 then
AutoButton.Count:SetText(count)
else
AutoButton.Count:SetText("")
end
AutoButton:SetScript("OnUpdate", function(self, elapsed)
local start, duration, enable
start, duration, enable = GetItemCooldown(self.itemID)
CooldownFrame_Set(self.Cooldown, start, duration, enable)
if (duration and duration > 0 and enable and enable == 0) then
self.Texture:SetVertexColor(0.4, 0.4, 0.4)
elseif IsItemInRange(itemID, "target") == 0 then
self.Texture:SetVertexColor(1, 0, 0)
else
self.Texture:SetVertexColor(1, 1, 1)
end
end)
AutoButtonShow(AutoButton)
end
end
end
local lastUpdate = 0
......@@ -407,6 +477,18 @@ function module:ScanItemCount(elapsed)
if f and f.itemName then
local count = GetItemCount(f.itemID, nil, 1)
if count and count > 1 then
f.Count:SetText(count)
else
f.Count:SetText("")
end
end
end
for i = 1, db.usableAutoButtons["usableNum"] do
local f = _G["AutoUsableButton" .. i]
if f and f.itemName then
local count = GetItemCount(f.itemID, nil, 1)
if count and count > 1 then
f.Count:SetText(count)
else
......@@ -451,6 +533,23 @@ function module:UpdateBind()
if button then button.HotKey:SetText(bindText) end
end
end
if module.db.usableAutoButtons["enable"] == true then
for i = 1, module.db.usableAutoButtons["usableNum"] do
local bindButton = "CLICK AutoUsableButton" .. i .. ":LeftButton"
local button = _G["AutoUsableButton" .. i]
local bindText = GetBindingKey(bindButton)
if not bindText then
bindText = ""
else
bindText = gsub(bindText, "SHIFT--", "S")
bindText = gsub(bindText, "CTRL--", "C")
bindText = gsub(bindText, "ALT--", "A")
end
if button then button.HotKey:SetText(bindText) end
end
end
end
function module:PLAYER_SPECIALIZATION_CHANGED()
......@@ -468,6 +567,7 @@ function module:ToggleAutoButton()
self:RegisterEvent("QUEST_LOG_UPDATE", GetQuestItemList)
self:RegisterEvent("QUEST_ACCEPTED", GetWorldQuestItemList)
self:RegisterEvent("QUEST_TURNED_IN", GetWorldQuestItemList)
if not module.Update then module.Update = CreateFrame("Frame") end
self.Update:SetScript("OnUpdate", module.ScanItemCount)
self:ScanItem("FIRST")
......@@ -538,6 +638,33 @@ function module:UpdateAutoButton()
end
end
end
if module.db.usableAutoButtons["enable"] == true then
for i = 1, module.db.usableAutoButtons["usableNum"] do
local f = CreateButton("AutoUsableButton" .. i, module.db.usableAutoButtons["usableSize"])
buttonsPerRow = module.db.usableAutoButtons["usablePerRow"]
lastButton = _G["AutoUsableButton" .. i - 1]
lastColumnButton = _G["AutoUsableButton" .. i - buttonsPerRow]
if module.db.usableAutoButtons["usableNum"] < module.db.usableAutoButtons["usablePerRow"] then
buttonsPerRow = module.db.usableAutoButtons["usableNum"]
end
f:ClearAllPoints()
if i == 1 then
f:Point("LEFT", _G.AutoButtonAnchor3, "LEFT", 0, 0)
elseif (i - 1) % buttonsPerRow == 0 then
f:Point("TOP", lastColumnButton, "BOTTOM", 0, -3)
else
if module.db.usableAutoButtons["usableDirection"] == "RIGHT" then
f:Point("LEFT", lastButton, "RIGHT", module.db.usableAutoButtons["usableSpace"], 0)
elseif module.db.usableAutoButtons["usableDirection"] == "LEFT" then
f:Point("RIGHT", lastButton, "LEFT", -(module.db.usableAutoButtons["usableSpace"]), 0)
end
end
end
end
self:ToggleAutoButton()
end
......@@ -555,16 +682,22 @@ function module:Initialize()
local AutoButtonAnchor = CreateFrame("Frame", "AutoButtonAnchor", UIParent)
AutoButtonAnchor:SetClampedToScreen(true)
AutoButtonAnchor:Point("BOTTOMLEFT", _G.RightChatPanel or _G.LeftChatPanel, "TOPLEFT", 0, 4)
AutoButtonAnchor:Size(module.db.questAutoButtons["questNum"] > 0 and module.db.questAutoButtons["questSize"] * module.db.questAutoButtons["questNum"] or 260, module.db.questAutoButtons["questNum"] > 0 and module.db.questAutoButtons["questSize"] or 40)
E:CreateMover(AutoButtonAnchor, "AutoButtonAnchorMover", L["mUI AutoButton Quest"], nil, nil, nil, "ALL,ACTIONBARS,MERATHILISUI", function() return module.db["enable"] end, 'mui,modules,actionbars,autoButtons')
AutoButtonAnchor:Point("BOTTOMLEFT", _G.RightChatPanel or _G.LeftChatPanel, "TOPLEFT", 0, 90)
AutoButtonAnchor:Size(module.db.questAutoButtons.questNum > 0 and module.db.questAutoButtons.questSize * module.db.questAutoButtons.questNum or 260, module.db.questAutoButtons.questNum > 0 and module.db.questAutoButtons.questSize or 40)
E:CreateMover(AutoButtonAnchor, "AutoButtonAnchorMover", L["mUI AutoButton Quest"], nil, nil, nil, "ALL,ACTIONBARS,MERATHILISUI", function() return module.db.enable end, 'mui,modules,actionbars,autoButtons')
local AutoButtonAnchor2 = CreateFrame("Frame", "AutoButtonAnchor2", UIParent)
AutoButtonAnchor2:SetClampedToScreen(true)
AutoButtonAnchor2:Point("BOTTOMLEFT", _G.RightChatPanel or _G.LeftChatPanel, "TOPLEFT", 0, 48)
AutoButtonAnchor2:Size(module.db.soltAutoButtons["slotNum"] > 0 and module.db.soltAutoButtons["slotSize"] * module.db.soltAutoButtons["slotNum"] or 260, module.db.soltAutoButtons["slotNum"] > 0 and module.db.soltAutoButtons["slotSize"] or 40)
AutoButtonAnchor2:Size(module.db.soltAutoButtons.slotNum > 0 and module.db.soltAutoButtons.slotSize * module.db.soltAutoButtons.slotNum or 260, module.db.soltAutoButtons.slotNum > 0 and module.db.soltAutoButtons.slotSize or 40)
E:CreateMover(AutoButtonAnchor2, "AutoButtonAnchor2Mover", L["mUI AutoButton Inventory"], nil, nil, nil, "ALL,ACTIONBARS,MERATHILISUI", function() return module.db["enable"] end, 'mui,modules,actionbars,autoButtons')
local AutoButtonAnchor3 = CreateFrame("Frame", "AutoButtonAnchor3", UIParent)
AutoButtonAnchor3:SetClampedToScreen(true)
AutoButtonAnchor3:Point("BOTTOMLEFT", _G.RightChatPanel or _G.LeftChatPanel, "TOPLEFT", 0, 4)
AutoButtonAnchor3:Size(module.db.usableAutoButtons.usableNum > 0 and module.db.usableAutoButtons.usableSize * module.db.usableAutoButtons.usableNum or 260, module.db.usableAutoButtons.usableNum > 0 and module.db.usableAutoButtons.usableSize or 40)
E:CreateMover(AutoButtonAnchor3, "AutoButtonAnchor3Mover", L["mUI AutoButton Usables"], nil, nil, nil, "ALL,ACTIONBARS,MERATHILISUI", function() return module.db["enable"] end, 'mui,modules,actionbars,autoButtons')
self:UpdateAutoButton()
end
......
......@@ -240,7 +240,7 @@ local function abTable()
type = "range",
name = L["Button Spacing"],
min = -1, max = 10, step = 1,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons["enable"] end,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons.enable end,
},
slotDirection = {
order = 5,
......@@ -250,28 +250,28 @@ local function abTable()
["RIGHT"] = L["Right"],
["LEFT"] = L["Left"],
},
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons["enable"] end,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons.enable end,
},
slotNum = {
order = 6,
type = "range",
name = L["Buttons"],
min = 0, max = 12, step = 1,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons["enable"] end,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons.enable end,
},
slotPerRow = {
order = 7,
type = "range",
name = L["Buttons Per Row"],
min = 1, max = 12, step = 1,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons["enable"] end,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons.enable end,
},
slotSize = {
order = 8,
type = "range",
name = L["Size"],
min = 10, max = 100, step = 1,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons["enable"] end,
hidden = function() return not E.db.mui.actionbars.autoButtons.soltAutoButtons.enable end,
},
}
},
......@@ -301,7 +301,7 @@ local function abTable()
type = "toggle",
name = L["Color by Quality"],
hidden = function()
return not E.db.mui.actionbars.autoButtons.questAutoButtons["enable"]
return not E.db.mui.actionbars.autoButtons.questAutoButtons.enable
end,
},
questBBColor = {
......@@ -309,10 +309,10 @@ local function abTable()
type = "color",
name = COLOR,
hidden = function()
return not E.db.mui.actionbars.autoButtons.questAutoButtons["enable"]
return not E.db.mui.actionbars.autoButtons.questAutoButtons.enable
end,
disabled = function()
return E.db.mui.actionbars.autoButtons.questAutoButtons["questBBColorByItem"]
return E.db.mui.actionbars.autoButtons.questAutoButtons.questBBColorByItem
end,
get = function(info)
local t = E.db.mui.actionbars.autoButtons.questAutoButtons[info[#info]]
......@@ -332,7 +332,7 @@ local function abTable()
name = L["Button Spacing"],
min = -1, max = 10, step = 1,
hidden = function()
return not E.db.mui.actionbars.autoButtons.questAutoButtons["enable"]
return not E.db.mui.actionbars.autoButtons.questAutoButtons.enable
end,
},
questDirection = {
......@@ -344,7 +344,7 @@ local function abTable()
["LEFT"] = L["Left"],
},
hidden = function()
return not E.db.mui.actionbars.autoButtons.questAutoButtons["enable"]
return not E.db.mui.actionbars.autoButtons.questAutoButtons.enable
end,
},
questNum = {
......@@ -353,7 +353,7 @@ local function abTable()
name = L["Buttons"],
min = 0, max = 12, step = 1,
hidden = function()
return not E.db.mui.actionbars.autoButtons.questAutoButtons["enable"]
return not E.db.mui.actionbars.autoButtons.questAutoButtons.enable
end,
},
questPerRow = {
......@@ -362,7 +362,7 @@ local function abTable()
name = L["Buttons Per Row"],
min = 1, max = 12, step = 1,
hidden = function()
return not E.db.mui.actionbars.autoButtons.questAutoButtons["enable"]
return not E.db.mui.actionbars.autoButtons.questAutoButtons.enable
end,
},
questSize = {
......@@ -371,13 +371,114 @@ local function abTable()
name = L["Size"],
min = 10, max = 100, step = 1,
hidden = function()
return not E.db.mui.actionbars.autoButtons.questAutoButtons["enable"]
return not E.db.mui.actionbars.autoButtons.questAutoButtons.enable
end,
},
},
},
whiteItemID = {
usableAutoButtons = {
order = 5,
type = "group",
guiInline = true,
name = L["Usable Buttons"],
get = function(info)
return E.db.mui.actionbars.autoButtons.usableAutoButtons[info[#info]]
end,
set = function(info, value)
E.db.mui.actionbars.autoButtons.usableAutoButtons[info[#info]] = value
MER:GetModule("AutoButtons"):UpdateAutoButton()
end,
args = {
enable = {
order = 1,
type = "toggle",
name = L["Enable"],
set = function(info, value)
E.db.mui.actionbars.autoButtons.usableAutoButtons[info[#info]] = value
end,
},
usableBBColorByItem = {
order = 2,
type = "toggle",
name = L["Color by Quality"],
hidden = function()
return not E.db.mui.actionbars.autoButtons.usableAutoButtons.enable
end,
},
usableBBColor = {
order = 3,
type = "color",
name = COLOR,
hidden = function()
return not E.db.mui.actionbars.autoButtons.usableAutoButtons.enable
end,
disabled = function()
return E.db.mui.actionbars.autoButtons.usableAutoButtons.usableBBColorByItem
end,
get = function(info)
local t = E.db.mui.actionbars.autoButtons.usableAutoButtons[info[#info]]
local d = P.mui.actionbars.autoButtons.usableAutoButtons[info[#info]]
return t.r, t.g, t.b, t.a, d.r, d.g, d.b, d.a
end,
set = function(info, r, g, b, a)
E.db.mui.actionbars.autoButtons.usableAutoButtons[info[#info]] = {}
local t = E.db.mui.actionbars.autoButtons.usableButtons[info[#info]]
t.r, t.g, t.b, t.a = r, g, b, a
MER:GetModule("AutoButtons"):UpdateAutoButton()
end,
},
usableSpace = {
order = 4,
type = "range",
name = L["Button Spacing"],
min = -1, max = 10, step = 1,
hidden = function()
return not E.db.mui.actionbars.autoButtons.usableAutoButtons.enable
end,
},
usableDirection = {
order = 5,
type = "select",
name = L["Anchor Point"],
values = {
["RIGHT"] = L["Right"],
["LEFT"] = L["Left"],
},
hidden = function()
return not E.db.mui.actionbars.autoButtons.usableAutoButtons.enable
end,
},
usableNum = {
order = 6,
type = "range",
name = L["Buttons"],
min = 0, max = 12, step = 1,
hidden = function()
return not E.db.mui.actionbars.autoButtons.usableAutoButtons.enable
end,
},
usablePerRow = {
order = 7,
type = "range",
name = L["Buttons Per Row"],
min = 1, max = 12, step = 1,
hidden = function()
return not E.db.mui.actionbars.autoButtons.usableAutoButtons.enable
end,
},
usableSize = {
order = 8,
type = "range",
name = L["Size"],
min = 10, max = 100, step = 1,
hidden = function()
return not E.db.mui.actionbars.autoButtons.usableAutoButtons.enable
end,
},
},
},
whiteItemID = {
order = 6,
type = "input",
name = L["Whitelist Item"],
get = function() return whiteItemID or "" end,
......
......@@ -159,6 +159,16 @@ MP.actionbars = {
questPerRow = 5,
questSize = 40,
},
usableAutoButtons = {
enable = true,
usableBBColorByItem = true,
usableBBColor = {r = 1, g = 1, b = 1, a = 1},
usableSpace = 1,
usableDirection = "RIGHT",
usableNum = 5,
usablePerRow = 5,
usableSize = 40,
},
whiteList = {
[5512] = true, -- Healthstone
[49040] = true, -- Jeeves
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment