Advertisement
j311yf1sh

EStsm

Nov 19th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.47 KB | None | 0 0
  1. EnchantingShuffler = LibStub("AceAddon-3.0"):NewAddon("EnchantingShuffler", "AceConsole-3.0")
  2. ESAceGUI = LibStub("AceGUI-3.0")
  3.  
  4. -----------------------------------------------------------------------
  5.  
  6. EnchantingShuffler:RegisterChatCommand("es2", "ESOpen")
  7.  
  8. EnchantingShuffler_Opened = "No"
  9.  
  10. EnchantingShufflerErrorRunOnce = 0
  11.  
  12. EnchantingShuffler_Database = "ESDBPHolder"
  13.  
  14. -------------------------------------------------------------------------
  15.  
  16. local ESframe = ESAceGUI:Create("Window")
  17. ESframe:EnableResize(false)
  18. ESframe:SetTitle("Enchanting Shuffler")
  19. ESframe:SetWidth(350)
  20. ESframe:SetHeight(350)
  21. ESframe:SetLayout("Flow")
  22. ESframe:Hide()
  23.  
  24. local ESEnchantingMaterialsGroup = ESAceGUI:Create("SimpleGroup")
  25. ESEnchantingMaterialsGroup:SetWidth(60)
  26. ESEnchantingMaterialsGroup:SetHeight(350)
  27. ESEnchantingMaterialsGroup:SetFullWidth(true)
  28. ESframe:AddChild(ESEnchantingMaterialsGroup)
  29.  
  30. local ESSpiritDustIcon = ESAceGUI:Create("Icon")
  31. ESSpiritDustIcon:SetImage("Interface\\ICONS\\inv_misc_powder_copper")
  32. ESSpiritDustIcon:SetLabel("Spirit Dust")
  33. ESSpiritDustIcon:SetImageSize(50,50)
  34. ESSpiritDustIcon:SetCallback("OnEnter", function() ESPricingTooltips("Spirit Dust") end)
  35. ESSpiritDustIcon:SetCallback("OnLeave", function() HideTooltips() end)
  36. ESEnchantingMaterialsGroup:AddChild(ESSpiritDustIcon)
  37.  
  38. local ESMysteriousEssenceIcon = ESAceGUI:Create("Icon")
  39. ESMysteriousEssenceIcon:SetImage("Interface\\ICONS\\trade_enchanting_greatermysteriousessence")
  40. ESMysteriousEssenceIcon:SetLabel("Mysterious Essence")
  41. ESMysteriousEssenceIcon:SetImageSize(50,50)
  42. ESMysteriousEssenceIcon:SetCallback("OnEnter", function() ESPricingTooltips("Mysterious Essence") end)
  43. ESMysteriousEssenceIcon:SetCallback("OnLeave", function() HideTooltips() end)
  44. ESEnchantingMaterialsGroup:AddChild(ESMysteriousEssenceIcon)
  45.  
  46. local ESEtherealShardIcon = ESAceGUI:Create("Icon")
  47. ESEtherealShardIcon:SetImage("Interface\\ICONS\\trade_enchanting_largeetherealshard")
  48. ESEtherealShardIcon:SetLabel("Ethereal Shard")
  49. ESEtherealShardIcon:SetImageSize(50,50)
  50. ESEtherealShardIcon:SetCallback("OnEnter", function() ESPricingTooltips("Ethereal Shard") end)
  51. ESEtherealShardIcon:SetCallback("OnLeave", function() HideTooltips() end)
  52. ESEnchantingMaterialsGroup:AddChild(ESEtherealShardIcon)
  53.  
  54. local ESShaCrystalIcon = ESAceGUI:Create("Icon")
  55. ESShaCrystalIcon:SetImage("Interface\\ICONS\\inv_misc_crystalepic2")
  56. ESShaCrystalIcon:SetLabel("Sha Crystal")
  57. ESShaCrystalIcon:SetImageSize(50,50)
  58. ESShaCrystalIcon:SetCallback("OnEnter", function() ESPricingTooltips("Sha Crystal") end)
  59. ESShaCrystalIcon:SetCallback("OnLeave", function() HideTooltips() end)
  60. ESEnchantingMaterialsGroup:AddChild(ESShaCrystalIcon)
  61.  
  62. local ESUpPricesGroup = ESAceGUI:Create("SimpleGroup")
  63. ESUpPricesGroup:SetWidth(60)
  64. ESUpPricesGroup:SetHeight(350)
  65. ESUpPricesGroup:SetFullWidth(true)
  66. ESframe:AddChild(ESUpPricesGroup)
  67.  
  68. local ESPriceUpLabel = ESAceGUI:Create("Label")
  69. ESPriceUpLabel:SetText("UP:")
  70. ESPriceUpLabel:SetFont("GameFontNormal",30)
  71. ESPriceUpLabel:SetRelativeWidth(0.5)
  72. ESUpPricesGroup:AddChild(ESPriceUpLabel)
  73.  
  74.  
  75. --- Slash Commands ---
  76. function EnchantingShuffler:ESOpen(input)
  77.     if EnchantingShuffler_Opened == "No" then
  78.         EnchantingShuffler_Opened = "Yes"
  79.         ESframe:Show()
  80.     elseif EnchantingShuffler_Opened == "Yes" then
  81.         EnchantingShuffler_Opened = "No"
  82.         ESframe:Hide()
  83.     end
  84. end
  85.  
  86. function ESDatabaseSelection()
  87.     -- Database selection --
  88.     if TSMAPI then
  89.         EnchantingShuffler_Database = "TradeSkillMaster"
  90.     elseif AuctionatorLoaded then
  91.         EnchantingShuffler_Database = "Auctionator"
  92.     else
  93.         if EnchantingShufflerErrorRunOnce == 0 then
  94.             EnchantingShuffler:Print("No database found, please install one of the following databases: TradeSkillMaster_AuctionDB or Auctionator")
  95.             EnchantingShufflerErrorRunOnce = 1
  96.         end
  97.     end
  98. end
  99.  
  100.  
  101. --- tool tips Pricing Modules ---
  102.  
  103. function ESPricingTooltips(ITEM)
  104.     local PriceMin = 0
  105.     local PriceMarket = 0
  106.     local PriceMinEach = 0
  107.     local PriceMarketEach = 0
  108.     if ITEM == "Spirit Dust" then
  109.         PriceMin = EnchantingShuffler_GetValue(74249,"Stack","Min")
  110.         PriceMarket = EnchantingShuffler_GetValue(74249,"Stack","Market")
  111.         PriceMinEach = EnchantingShuffler_GetValue(74249,"Each","Min")
  112.         PriceMarketEach = EnchantingShuffler_GetValue(74249,"Each","Market")
  113.     elseif ITEM == "Mysterious Essence" then
  114.         PriceMin = EnchantingShuffler_GetValue(74250,"Stack","Min")
  115.         PriceMarket = EnchantingShuffler_GetValue(74250,"Stack","Market")
  116.         PriceMinEach = EnchantingShuffler_GetValue(74250,"Each","Min")
  117.         PriceMarketEach = EnchantingShuffler_GetValue(74250,"Each","Market")
  118.     elseif ITEM == "Ethereal Shard" then
  119.         PriceMin = EnchantingShuffler_GetValue(74247,"Stack","Min")
  120.         PriceMarket = EnchantingShuffler_GetValue(74247,"Stack","Market")
  121.         PriceMinEach = EnchantingShuffler_GetValue(74247,"Each","Min")
  122.         PriceMarketEach = EnchantingShuffler_GetValue(74247,"Each","Market")
  123.     elseif ITEM == "Sha Crystal" then
  124.         PriceMin = EnchantingShuffler_GetValue(74248,"Stack","Min")
  125.         PriceMarket = EnchantingShuffler_GetValue(74248,"Stack","Market")
  126.         PriceMinEach = EnchantingShuffler_GetValue(74248,"Each","Min")
  127.         PriceMarketEach = EnchantingShuffler_GetValue(74248,"Each","Market")
  128.     end
  129.     if TSMAPI then
  130.         GameTooltip:ClearLines();
  131.         GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
  132.         GameTooltip:AddLine(ITEM.." details:")
  133.         GameTooltip:AddLine("Each:")
  134.         GameTooltip:AddLine("Lowest price: "..PriceMinEach.."g")
  135.         GameTooltip:AddLine("Market Price: "..PriceMarketEach.."g")
  136.         GameTooltip:AddLine("Per stack:")
  137.         GameTooltip:AddLine("Lowest price: "..PriceMin.."g")
  138.         GameTooltip:AddLine("Market Price: "..PriceMarket.."g")
  139.         GameTooltip:Show();
  140.     elseif AuctionatorLoaded then
  141.         GameTooltip:ClearLines();
  142.         GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
  143.         GameTooltip:AddLine(ITEM.." details:")
  144.         GameTooltip:AddLine("Each:")
  145.         GameTooltip:AddLine("Lowest price: "..PriceMinEach.."g")
  146.         GameTooltip:AddLine("Per stack:")
  147.         GameTooltip:AddLine("Lowest price: "..PriceMin.."g")
  148.         GameTooltip:Show();
  149.     end
  150. end
  151.  
  152. function HideTooltips()
  153.     GameTooltip:Hide()
  154. end
  155.  
  156. --- Price getting --
  157. function EnchantingShuffler_GetValue(ITEM,TYPE,TSMVar)
  158.     local Price -- create price local
  159.     if EnchantingShuffler_Database == "TradeSkillMaster" then
  160.         if TSMVar == "Market" then
  161.             if TYPE == "Stack" then
  162.                 Price = ((TSMAPI:GetItemValue(ITEM,"DBMarket") / 10000) * 20)
  163.             elseif TYPE == "Each" then
  164.                 Price = (TSMAPI:GetItemValue(ITEM,"DBMarket") / 10000)
  165.             end
  166.         elseif TSMVar == "Min" or TSMVar == nil then
  167.             if TYPE == "Stack" then
  168.                 Price = ((TSMAPI:GetItemValue(ITEM,"DBMinBuyout") / 10000) * 20)
  169.             elseif TYPE == "Each" then
  170.                 Price = (TSMAPI:GetItemValue(ITEM,"DBMinBuyout") / 10000)
  171.             end
  172.         end
  173.     -- Auctionator Database --
  174.     elseif EnchantingShuffler_Database == "Auctionator" then
  175.         if TSMVar == "Market" or TSMVar == "Min" or TSMVar == nil or TSMVar == "Market" then
  176.             if TYPE == "Stack" then
  177.                 Price = ((GetAuctionBuyout(ITEM) / 10000) * 20)
  178.             elseif TYPE == "Each" then
  179.                 Price = (GetAuctionBuyout(ITEM) / 10000)
  180.             end
  181.         end
  182.     else
  183.         if EnchantingShufflerErrorRunOnce == 0 then
  184.             Price = 0
  185.             EnchantingShuffler:Print("No database found, please install on of the following databases: TradeSkillMaster_AuctionDB or Auctionator")
  186.             EnchantingShufflerErrorRunOnce = 1
  187.         end
  188.     end
  189.  
  190.     if Price == nil or Price == 0 then
  191.         Price = 0
  192.     end
  193.     --EnchantingShuffler:Print(Price)
  194.     return Price
  195. end
  196.  
  197.  
  198. function EnchantingShuffler:OnEnable()
  199.     ESDatabaseSelection()
  200.     EnchantingShuffler:Print("Yep done")
  201. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement