diff --git a/ProfessionMenu/Libs/DewdropLib/Dewdrop-2.0/Dewdrop-2.0.lua b/ProfessionMenu/Libs/DewdropLib/Dewdrop-2.0/Dewdrop-2.0.lua index c07198e..eda0833 100644 --- a/ProfessionMenu/Libs/DewdropLib/Dewdrop-2.0/Dewdrop-2.0.lua +++ b/ProfessionMenu/Libs/DewdropLib/Dewdrop-2.0/Dewdrop-2.0.lua @@ -1,6 +1,6 @@ --[[ Name: Dewdrop-2.0 -Revision: $Rev: 326 $ +Revision: $Rev: 327 $ Author(s): ckknight (ckknight@gmail.com) Website: http://ckknight.wowinterface.com/ Documentation: http://wiki.wowace.com/index.php/Dewdrop-2.0 @@ -11,7 +11,7 @@ License: LGPL v2.1 ]] local MAJOR_VERSION = "Dewdrop-2.0" -local MINOR_VERSION = tonumber(strmatch("$Revision: 326 $", "%d+")) + 90000 +local MINOR_VERSION = tonumber(strmatch("$Revision: 327 $", "%d+")) + 90000 if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end @@ -232,6 +232,7 @@ eventFrame:RegisterEvent("PLAYER_REGEN_DISABLED") function createSecureFrame() if secureFrame or InCombatLockdown() then return end secureFrame = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate") + secureFrame:RegisterForClicks("AnyDown") secureFrame:Hide() secureFrame:SetScript("OnLeave", @@ -243,10 +244,10 @@ secureFrame:SetScript("OnLeave", ) secureFrame:HookScript("OnClick", - function(this) + function(this , buttonClick) local realthis = this this = this.owner - this:GetScript("OnClick")(this) + this:GetScript("OnClick")(this, buttonClick) end ) @@ -601,6 +602,7 @@ local function AcquireButton(self, level) button = CreateFrame("Button", "Dewdrop20Button" .. numButtons, nil) button:SetFrameStrata("FULLSCREEN_DIALOG") button:SetHeight(16) + button:RegisterForClicks("AnyDown") local highlight = button:CreateTexture(nil, "BACKGROUND") highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") button.highlight = highlight @@ -677,7 +679,7 @@ local function AcquireButton(self, level) GameTooltip:Hide() end) local first = true - button:SetScript("OnClick", function(this) + button:SetScript("OnClick", function(this, buttonClick) if not this.disabled then if this.hasColorSwatch then local func = button.colorFunc @@ -730,7 +732,39 @@ local function AcquireButton(self, level) end self:Close(1) ShowUIPanel(ColorPickerFrame) - elseif this.func then + elseif this.funcRight and buttonClick == "RightButton" then + local level = this.level + if type(this.funcRight) == "string" then + if type(this.argRight1[this.funcRight]) ~= "function" then + self:error("Cannot call method %q", this.funcRight) + end + this.argRight1[this.funcRight](this.argRight1, getArgs(this, 'arg', 2)) + else + this.funcRight(getArgs(this, 'arg', 1)) + end + if this.closeWhenClicked then + self:Close() + elseif level:IsShown() then + for i = 1, level.num do + Refresh(self, levels[i]) + end + local value = levels[level.num].value + for i = level.num-1, 1, -1 do + local level = levels[i] + local good = false + for _,button in ipairs(level.buttons) do + if button.value == value then + good = true + break + end + end + if not good then + Dewdrop:Close(i+1) + end + value = levels[i].value + end + end + elseif this.func and buttonClick == "LeftButton" then local level = this.level if type(this.func) == "string" then if type(this.arg1[this.func]) ~= "function" then @@ -762,9 +796,9 @@ local function AcquireButton(self, level) value = levels[i].value end end - elseif this.closeWhenClicked then - self:Close() - end + elseif this.closeWhenClicked then + self:Close() + end end end) local text = button:CreateFontString(nil, "ARTWORK") @@ -772,12 +806,12 @@ local function AcquireButton(self, level) text:SetFontObject(GameFontHighlightSmall) button.text:SetFont(STANDARD_TEXT_FONT, UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT) button:SetScript("OnMouseDown", function(this) - if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then + if not this.disabled and (this.func or this.funcRight or this.colorFunc or this.closeWhenClicked) then text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 1 or 25, -1) end end) button:SetScript("OnMouseUp", function(this) - if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then + if not this.disabled and (this.func or this.funcRight or this.colorFunc or this.closeWhenClicked) then text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 0 or 24, 0) end end) @@ -3166,6 +3200,7 @@ function Dewdrop:AddLine(...) end if not button.disabled then button.func = info.func + button.funcRight = info.funcRight button.secure = info.secure end button.hasColorSwatch = info.hasColorSwatch @@ -3178,6 +3213,7 @@ function Dewdrop:AddLine(...) button.colorSwatch.texture:SetVertexColor(button.r, button.g, button.b) button.checked = false button.func = nil + button.funcRight = nil button.colorFunc = info.colorFunc local i = 1 while true do diff --git a/ProfessionMenu/ProfessionMenu.lua b/ProfessionMenu/ProfessionMenu.lua index fc1d61d..c6c7b24 100644 --- a/ProfessionMenu/ProfessionMenu.lua +++ b/ProfessionMenu/ProfessionMenu.lua @@ -23,7 +23,10 @@ local DefaultSettings = { { TableName = "DeleteItem", false, CheckBox = "ProfessionMenuOptions_DeleteMenu"}, { TableName = "minimap", false, CheckBox = "ProfessionMenuOptions_HideMinimap"}, { TableName = "txtSize", 12}, - { TableName = "autoMenu", false, CheckBox = "ProfessionMenuOptions_AutoMenu"} + { TableName = "autoMenu", false, CheckBox = "ProfessionMenuOptions_AutoMenu"}, + { TableName = "FilterList", {false,false,false,false} }, + { TableName = "BagFilter", {false,false,false,false,false} }, + { TableName = "ItemBlacklist", { [9149] = true }} } --[[ TableName = Name of the saved setting @@ -79,6 +82,7 @@ local profList = { 7413, -- Expert 225 7412, -- Journeyman 150 7411, -- Apprentice 75 + frame = {"ProfessionMenuExtractFrame", "Enchanting", "Right click to open disenchanting frame"} }, --ENCHANTING { 51306, -- Grand Master 450 @@ -147,11 +151,12 @@ local profSubList = { } function PM:UNIT_SPELLCAST_SUCCEEDED(event, arg1, arg2) PM:RemoveItem(arg2) + PM:UpdateItemFrame(arg2) end local cTip = CreateFrame("GameTooltip","cTooltip",nil,"GameTooltipTemplate") -local function IsSoulbound(bag, slot) +function PM:IsSoulbound(bag, slot) cTip:SetOwner(UIParent, "ANCHOR_NONE") cTip:SetBagItem(bag, slot) cTip:Show() @@ -194,7 +199,7 @@ function PM:RemoveItem(arg2) for _, item in ipairs(items) do if arg2 == item[2] then local found, bag, slot = PM:HasItem(item[1]) - if found and C_VanityCollection.IsCollectionItemOwned(item[1]) and IsSoulbound(bag, slot) then + if found and C_VanityCollection.IsCollectionItemOwned(item[1]) and PM:IsSoulbound(bag, slot) then PickupContainerItem(bag, slot) DeleteCursorItem() end @@ -285,13 +290,22 @@ local function ProfessionMenu_DewdropRegister(self) type1 = 'spell', spell = spellID } + local openFrame, tooltipTitle, tooltipText + if prof.frame then + openFrame = true + tooltipTitle = prof.frame[2] + tooltipText = prof.frame[3] + end dewdrop:AddLine( 'text', name, 'icon', icon, 'secure', secure, 'closeWhenClicked', true, + 'funcRight', function() PM:InventoryFrame_Open(openFrame) end, 'textHeight', PM.db.txtSize, - 'textWidth', PM.db.txtSize + 'textWidth', PM.db.txtSize, + 'tooltipTitle', tooltipTitle, + 'tooltipText', tooltipText ) end end diff --git a/ProfessionMenu/ProfessionMenu.toc b/ProfessionMenu/ProfessionMenu.toc index f72ed6b..cc50b74 100644 --- a/ProfessionMenu/ProfessionMenu.toc +++ b/ProfessionMenu/ProfessionMenu.toc @@ -7,6 +7,6 @@ ## X-Category: Profession ## X-OptionsFrame: ProfessionMenuOptionsFrame ## DefaultState: enabled -## Version: 0.10 +## Version: 1.0 embeds.xml diff --git a/ProfessionMenu/ProfessionMenuInventory.lua b/ProfessionMenu/ProfessionMenuInventory.lua new file mode 100644 index 0000000..386a1b3 --- /dev/null +++ b/ProfessionMenu/ProfessionMenuInventory.lua @@ -0,0 +1,266 @@ +local PM = LibStub("AceAddon-3.0"):GetAddon("ProfessionMenu") +local dewdrop = AceLibrary("Dewdrop-2.0") +local mainframe = CreateFrame("FRAME", "ProfessionMenuExtractFrame", UIParent,"UIPanelDialogTemplate") + mainframe:SetSize(460,508) + mainframe:SetPoint("CENTER",0,0) + mainframe:EnableMouse(true) + mainframe:SetMovable(true) + mainframe:RegisterForDrag("LeftButton") + mainframe:SetScript("OnDragStart", function(self) mainframe:StartMoving() end) + mainframe:SetScript("OnDragStop", function(self) mainframe:StopMovingOrSizing() end) + mainframe:SetScript("OnShow", function() + PM:SearchBags() + PM:RegisterEvent("BAG_UPDATE", PM.SearchBags) + end) + mainframe:SetScript("OnHide", function() + PM:UnregisterEvent("BAG_UPDATE") + end) + mainframe.TitleText = mainframe:CreateFontString() + mainframe.TitleText:SetFont("Fonts\\FRIZQT__.TTF", 12) + mainframe.TitleText:SetFontObject(GameFontNormal) + mainframe.TitleText:SetText("Disenchanting List") + mainframe.TitleText:SetPoint("TOP", 0, -9) + mainframe.TitleText:SetShadowOffset(1,-1) + mainframe:Hide() + +PM.FilterList = { + [1] = {"Uncommon", 2}, + [2] = {"Rare", 3}, + [3] = {"Epic", 4}, + Soulbound = "Soulbound", + Bags = { + "Backpack", + "Bag 1", + "Bag 2", + "Bag 3", + "Bag 4", + } +} + +local InventoryTypes = { + ["Weapon"] = true, + ["Armor"] = true +} + +function PM:InventoryFrame_Open(isEnabled) + if not isEnabled then return end + if mainframe:IsVisible() then + mainframe:Hide() + else + mainframe:Show() + end +end + +function PM:UpdateItemFrame(arg2) + if arg2 ~= "Disenchant" then return end + PM:RegisterEvent("BAG_UPDATE") + PM:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED") +end + +function PM:BAG_UPDATE() + PM:ScheduleTimer(function() PM:SearchBags() end, .10) + PM:UnregisterEvent("BAG_UPDATE") +end + +local function filterCheck(quality, bagID, slotID) + for _, _ in ipairs(PM.FilterList) do + if (PM.db.FilterList[4] and PM:IsSoulbound(bagID, slotID)) or (quality < 1 or quality > 5) or PM.db.FilterList[quality-1] then + return true + end + end + return false +end + +local inventoryItems +local bagThrottle = false +--finds the next bag slot with an item with an enchant on it +function PM:SearchBags() + if not bagThrottle then + inventoryItems = {} + for bagID = 0, 4 do + if not PM.db.BagFilter[bagID+1] then + for slotID = 1, GetContainerNumSlots(bagID) do + local quality,_,_,link = select(4,GetContainerItemInfo(bagID,slotID)) + local itemID = GetContainerItemID(bagID,slotID) + if link and not PM.db.ItemBlacklist[itemID] then + local itemType = select(6,GetItemInfo(itemID)) + if not filterCheck(quality, bagID, slotID) and InventoryTypes[itemType] then + tinsert(inventoryItems,{bagID,slotID,link,quality}) + end + end + end + end + end + bagThrottle = true + PM.bagThrottle = PM:ScheduleTimer(function() bagThrottle = false end, .1) + ProfessionMenu_InventroyScrollFrameUpdate() + end +end + +function PM:ItemMenuRegister(self) + dewdrop:Register(self, + 'point', function(parent) + return "TOP", "BOTTOM" + end, + 'children', function(level, value) + if level == 1 then + for k, v in ipairs(PM.FilterList) do + local text = v[1] + if tonumber(v[2]) then + text = select(4, GetItemQualityColor(v[2])) .. v[1] + end + dewdrop:AddLine( + 'text', text, + 'func', function() PM.db.FilterList[k] = not PM.db.FilterList[k] PM:SearchBags() end, + 'checked', PM.db.FilterList[k], + 'textHeight', 12, + 'textWidth', 12 + ) + end + dewdrop:AddLine( + 'text', PM.FilterList.Soulbound, + 'func', function() PM.db.FilterList[4] = not PM.db.FilterList[4] PM:SearchBags() end, + 'checked', PM.db.FilterList[4], + 'textHeight', 12, + 'textWidth', 12 + ) + dewdrop:AddLine( + 'text', "Bag Filter", + 'value', "BagFilter", + 'hasArrow', true, + 'textHeight', 12, + 'textWidth', 12, + "notCheckable", true + ) + dewdrop:AddLine( + 'text', "Close Menu", + 'textR', 0, + 'textG', 1, + 'textB', 1, + 'textHeight', 12, + 'textWidth', 12, + 'closeWhenClicked', true, + 'notCheckable', true + ) + elseif level == 2 then + if value and value == "BagFilter" then + for i, bag in ipairs(PM.FilterList.Bags) do + dewdrop:AddLine( + 'text', bag, + 'func', function() PM.db.BagFilter[i] = not PM.db.BagFilter[i] PM:SearchBags() end, + 'checked', PM.db.BagFilter[i], + 'textHeight', 12, + 'textWidth', 12 + ) + end + end + end + end, + 'dontHook', true + ) +end + +------------------ScrollFrameTooltips--------------------------- +local function ItemTemplate_OnEnter(self) + if not self.link then return end + GameTooltip:SetOwner(self, "ANCHOR_RIGHT", -13, -50) + GameTooltip:SetHyperlink(self.link) + GameTooltip:Show() +end + +local function ItemTemplate_OnLeave() + GameTooltip:Hide() +end + +--ScrollFrame + +local ROW_HEIGHT = 16 -- How tall is each row? +local MAX_ROWS = 25 -- How many rows can be shown at once? + +local scrollFrame = CreateFrame("Frame", "ProfessionMenu_DE_ScrollFrame", ProfessionMenuExtractFrame) + scrollFrame:EnableMouse(true) + scrollFrame:SetSize(420, ROW_HEIGHT * MAX_ROWS + 16) + scrollFrame:SetPoint("TOPLEFT",20,-42) + scrollFrame:SetBackdrop({ + bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tile = true, tileSize = 16, + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, + insets = { left = 4, right = 4, top = 4, bottom = 4 }, + }) + +function ProfessionMenu_InventroyScrollFrameUpdate() + local maxValue = #inventoryItems + FauxScrollFrame_Update(scrollFrame.scrollBar, maxValue, MAX_ROWS, ROW_HEIGHT) + local offset = FauxScrollFrame_GetOffset(scrollFrame.scrollBar) + for i = 1, MAX_ROWS do + local value = i + offset + scrollFrame.rows[i]:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD") + if value <= maxValue then + local row = scrollFrame.rows[i] + row.Text:SetText(inventoryItems[value][3]) + row.link = inventoryItems[value][3] + row.bag = inventoryItems[value][1] + row.slot = inventoryItems[value][2] + row:SetAttribute("type", "spell") + row:SetAttribute("spell", "Disenchant") + row:SetAttribute("target-bag", row.bag) + row:SetAttribute("target-slot", row.slot) + row.tNumber = value + row:Show() + else + scrollFrame.rows[i]:Hide() + end + end +end + +local scrollSlider = CreateFrame("ScrollFrame","ProfessionMenuDEListFrameScroll",ProfessionMenu_DE_ScrollFrame,"FauxScrollFrameTemplate") +scrollSlider:SetPoint("TOPLEFT", 0, -8) +scrollSlider:SetPoint("BOTTOMRIGHT", -30, 8) +scrollSlider:SetScript("OnVerticalScroll", function(self, offset) + self.offset = math.floor(offset / ROW_HEIGHT + 0.5) + ProfessionMenu_InventroyScrollFrameUpdate() +end) + +scrollFrame.scrollBar = scrollSlider + +local rows = setmetatable({}, { __index = function(t, i) + local row = CreateFrame("Button", "$parentRow"..i, scrollFrame, "SecureActionButtonTemplate") + row:SetSize(405, ROW_HEIGHT) + row:SetNormalFontObject(GameFontHighlightLeft) + row.Text = row:CreateFontString("$parentRow"..i.."Text","OVERLAY","GameFontNormal") + row.Text:SetSize(260, ROW_HEIGHT) + row.Text:SetPoint("LEFT",row) + row.Text:SetJustifyH("LEFT") + row:SetScript("OnMouseDown", function() + PM:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") + end) + row:SetScript("OnEnter", function(self) + ItemTemplate_OnEnter(self) + end) + row:SetScript("OnLeave", ItemTemplate_OnLeave) + if i == 1 then + row:SetPoint("TOPLEFT", scrollFrame, 8, -8) + else + row:SetPoint("TOPLEFT", scrollFrame.rows[i-1], "BOTTOMLEFT") + end + + rawset(t, i, row) + return row +end }) + +scrollFrame.rows = rows + +--Shows a menu with options and sharing options +local extractMenu = CreateFrame("Button", "ProfessionMenu_ExtractInterface_FilterMenu", ProfessionMenu_DE_ScrollFrame, "FilterDropDownMenuTemplate") + extractMenu:SetSize(133, 30) + extractMenu:SetPoint("BOTTOMRIGHT", ProfessionMenu_DE_ScrollFrame, "BOTTOMRIGHT", 0, -35) + extractMenu:RegisterForClicks("LeftButtonDown") + extractMenu:SetScript("OnClick", function(self) + if dewdrop:IsOpen() then + dewdrop:Close() + else + PM:ItemMenuRegister(self) + dewdrop:Open(self) + end + end) + + diff --git a/ProfessionMenu/embeds.xml b/ProfessionMenu/embeds.xml index 997401d..8ee5203 100644 --- a/ProfessionMenu/embeds.xml +++ b/ProfessionMenu/embeds.xml @@ -17,5 +17,7 @@