Advertisement
j311yf1sh

destroybtn.lua

Aug 22nd, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.73 KB | None | 0 0
  1. -- loads the localization table --
  2. local L = LibStub("AceLocale-3.0"):GetLocale("TradeSkillMaster_Destroying")
  3.  
  4. -- load the parent file (TSM) into a local variable and register this file as a module
  5. local TSM = select(2, ...)
  6. local destroybtn = TSM:NewModule("destroybtn", "AceEvent-3.0", "AceHook-3.0")--TSM:NewModule("GUI", "AceEvent-3.0")
  7. local AceGUI = LibStub("AceGUI-3.0") -- load the AceGUI libraries
  8.  
  9. --Professions--
  10. local prospecting = 31252
  11. local milling = 51005
  12. local disenchanting = 13262
  13.  
  14. --Useful Globals--
  15. local mat
  16.  
  17. local speedTable ={
  18.     ["Slow"]   = "Slow",
  19.     ["Normal"] = "Normal",
  20.     ["Fast"]   = "Fast"
  21. }
  22.  
  23. local function getSpells()
  24.     local t = {}
  25.     local num = 0
  26.     local mode = nil
  27.     if IsSpellKnown(disenchanting) then
  28.         t["Disenchanting"] = "Disenchanting"
  29.         num = num + 1
  30.         mode = "Disenchanting"
  31.     end
  32.     if IsSpellKnown(milling) then
  33.         t["Milling"] = "Milling"
  34.         num = num + 1
  35.         mode = "Milling"
  36.     end
  37.     if IsSpellKnown(prospecting) then
  38.         t["Prospecting"] = "Prospecting"
  39.         num = num + 1
  40.         mode = "Prospecting"
  41.     end
  42.  
  43.     return t,num,mode
  44. end
  45.  
  46. local frame = nil
  47. function destroybtn:Show()
  48.     if frame and frame:IsVisible() then return end
  49.  
  50.     local spellTable, numSpells, spell = getSpells()
  51.     if numSpells > 0 then
  52.         TSM:Print(L["The Destroyer has risen!"])
  53.  
  54.         frame = AceGUI:Create("TSMWindow")
  55.         local dButton = AceGUI:Create("TSMFastDestroyButton")
  56.         local dropSpell = AceGUI:Create("TSMDropdown")
  57.         local dropSpeed = AceGUI:Create("TSMDropdown")
  58.  
  59.         frame:SetCallback("OnClose", function(widget) AceGUI:Release(widget) end)
  60.         frame:SetTitle(L["The Destroyer"])
  61.         frame:SetLayout("Flow")
  62.         frame:SetHeight(175)
  63.         frame:SetWidth(200)
  64.         --frame:EnableResize(false)
  65.         frame:SetPoint(TSM.db.global.anchor, TSM.db.global.xPos, TSM.db.global.yPos)
  66.         frame:SetCallback("OnClose", function (self)
  67.             TSM.db.global.anchor,_, _,TSM.db.global.xPos,TSM.db.global.yPos = self:GetPoint()
  68.             AceGUI:Release(self)
  69.             dButton:SetSpell(nil)
  70.         end)
  71.  
  72.         dButton:SetText("Destroy")
  73.         dButton:SetHeight(75)
  74.         dButton:SetMode("normal")
  75.         dButton:SetLocationsFunc( function(previous)
  76.             TSM.loot:show()
  77.             if mat == "Disenchantable" then return end
  78.             return TSM.util:searchAndDestroy(mat,previous)
  79.         end)
  80.  
  81.         dropSpeed:SetList(speedTable)
  82.         dropSpeed:SetCallback("OnValueChanged",function(this, event, item)
  83.             TSM.db.global.dMode = item
  84.             dButton:SetMode(item)
  85.         end)
  86.         dropSpeed:SetValue(TSM.db.global.dMode)
  87.  
  88.         dropSpell:SetList(spellTable)
  89.         dropSpell:SetCallback("OnValueChanged",function(this, event, item)
  90.             dButton:SetSpell(item)
  91.             TSM.loot:setAction(item)
  92.             if item == "Disenchanting" then
  93.                 dButton:SetLocationsFunc(
  94.                 function(previous)
  95.                     TSM.loot:show()
  96.                     return TSM.de:searchAndDestroy(previous)
  97.                 end)
  98.                 return
  99.             end
  100.  
  101.             if item =="Prospecting" then
  102.                 mat = "Prospectable"
  103.             elseif item == "Milling" then
  104.                 mat = "Millable"
  105.             end
  106.  
  107.             dButton:SetLocationsFunc( function(previous)
  108.                 TSM.loot:show()
  109.                 return TSM.util:searchAndDestroy(mat,previous)
  110.             end)
  111.  
  112.         end)
  113.  
  114.         frame:AddChild(dropSpell)
  115.         frame:AddChild(dropSpeed)
  116.         frame:AddChild(dButton)
  117.  
  118.         return
  119.     end
  120.      TSM:Print(L["You do not know Milling, Prospecting or Disenchanting."])
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement