Quantcast

V0.2.1

Brandon Talbot [07-06-16 - 14:34]
V0.2.1
* Fixed text issue on dialog
* Added auto tools
** Sell junk
** Deposit reagents
* Added settings for auto tools
Filename
src/lua/controllers/bag.lua
src/lua/controllers/bank.lua
src/lua/core.lua
src/lua/elements/categoryDialog.lua
src/lua/elements/item.lua
src/lua/settings/defaults/auto.lua
src/lua/settings/editor.lua
src/manifest.xml
diff --git a/src/lua/controllers/bag.lua b/src/lua/controllers/bag.lua
index 2ffe62f..f4a076b 100644
--- a/src/lua/controllers/bag.lua
+++ b/src/lua/controllers/bag.lua
@@ -23,6 +23,22 @@ function bag:Init()
     self.frame:HookScript('OnHide', function()
         self:UnRegister()
     end)
+
+    ADDON.eventManager:AddEvent(self, 'MERCHANT_SHOW')
+end
+
+function bag:MERCHANT_SHOW()
+    if ADDON.settings.auto.sellJunk then
+        for bag = 0, NUM_BAG_SLOTS do
+            for slot = 1 , GetContainerNumSlots(bag) do
+                if select(4, GetContainerItemInfo(bag, slot)) == LE_ITEM_QUALITY_POOR then
+                    ShowMerchantSellCursor(1)
+                    UseContainerItem(bag, slot)
+                end
+            end
+        end
+        ResetCursor()
+    end
 end

 function bag:Open()
diff --git a/src/lua/controllers/bank.lua b/src/lua/controllers/bank.lua
index 2299599..bbff954 100644
--- a/src/lua/controllers/bank.lua
+++ b/src/lua/controllers/bank.lua
@@ -76,6 +76,10 @@ function bank:OnShow()
     PanelTemplates_SetTab(self, 1)
     bank.bankContainer:Show()
     bank.reagentContainer:Hide()
+
+    if ADDON.settings.auto.depositReagents and IsReagentBankUnlocked() then
+        DepositReagentBank();
+    end
 end

 function bank:OnHide()
diff --git a/src/lua/core.lua b/src/lua/core.lua
index ab3e34c..812ae53 100644
--- a/src/lua/core.lua
+++ b/src/lua/core.lua
@@ -70,9 +70,7 @@ end

 SLASH_TDJBAGS1, SLASH_TDJBAGS2 = '/tt', '/ttt';
 function SlashCmdList.TDJBAGS(msg, editbox)
-    for k, v in pairs(C_NewItems) do
-            print(k, v)
-    end
+
 end

 SLASH_RELOAD1 = '/rl'
diff --git a/src/lua/elements/categoryDialog.lua b/src/lua/elements/categoryDialog.lua
index 510e8be..c532c0b 100644
--- a/src/lua/elements/categoryDialog.lua
+++ b/src/lua/elements/categoryDialog.lua
@@ -119,7 +119,7 @@ function dialog:CreateFrame()
         dialog.frame:Hide()
     end)

-    self.errorText = self.frame:CreateFontString('DJBagsCategoryDialogTitle', 'GameFontNormal')
+    self.errorText = self.frame:CreateFontString('DJBagsCategoryDialogTitle', 'OVERLAY', 'GameFontNormal')
     self.errorText:SetFont(select(1, self.errorText:GetFont()), 18, 'OUTLINE')
     self.errorText:SetTextColor(1, 0, 0, 1)
     self.errorText:SetPoint("TOPRIGHT", self.editBox, 'TOPLEFT', -5, 0)
diff --git a/src/lua/elements/item.lua b/src/lua/elements/item.lua
index 2932aeb..a30346c 100644
--- a/src/lua/elements/item.lua
+++ b/src/lua/elements/item.lua
@@ -221,6 +221,7 @@ function item:Update()
     self.name = id and select(1, GetItemInfo(id)) or ''
     self.quality = quality or 0
     self.ilevel = id and select(4, GetItemInfo(id)) or 0
+    self.button.hasItem = nil


     if self:GetID() == BANK_CONTAINER or self:GetID() == REAGENTBANK_CONTAINER then
@@ -236,6 +237,8 @@ function item:Update()
         local isBattlePayItem = IsBattlePayItem(self:GetID(), self.button:GetID())
         local shouldDoRelicChecks = not BagHelpBox:IsShown() and not GetCVarBitfield("closedInfoFrames", LE_FRAME_TUTORIAL_ARTIFACT_RELIC_MATCH)

+        self.button.hasItem = true
+
         if (equipable) then
             count = count > 1 and count or select(4, GetItemInfo(id))
         end
diff --git a/src/lua/settings/defaults/auto.lua b/src/lua/settings/defaults/auto.lua
new file mode 100644
index 0000000..6f5e4ef
--- /dev/null
+++ b/src/lua/settings/defaults/auto.lua
@@ -0,0 +1,8 @@
+local NAME, ADDON = ...
+
+ADDON.settings = ADDON.settings or {}
+
+ADDON.settings.auto = {
+    depositReagents = false,
+    sellJunk = false,
+}
\ No newline at end of file
diff --git a/src/lua/settings/editor.lua b/src/lua/settings/editor.lua
index 35d1300..8f09d17 100644
--- a/src/lua/settings/editor.lua
+++ b/src/lua/settings/editor.lua
@@ -75,6 +75,7 @@ function settings:CreateFrame()

     self.scrollFrame:SetScrollChild(self.content)

+    self:CreateAutoSettings()
     self:CreateCategorySettings()
     self:CreateItemSettings()
     self:CreateContainerSettings()
@@ -420,4 +421,24 @@ function settings:CreateCategorySettings()

     container:SetHeight(35 - y)
     self:AddSettingsPanel(container)
+end
+
+function settings:CreateAutoSettings()
+    local container = ADDON.container('DJBagsSettingsAutoScreen', nil)
+
+    CreateTitle('Automatic tools', container)
+
+    local autoSellJunk = CreateCheckBox("Auto sell junk", container, ADDON.settings.auto.sellJunk, function(value)
+        ADDON.settings.auto.sellJunk = value
+        ADDON.eventManager:FireEvent('SETTINGS_UPDATE', true)
+    end)
+    autoSellJunk:SetPoint('TOPLEFT', 5, -20)
+    local autoDeposit = CreateCheckBox("Auto deposit reagents", container, ADDON.settings.auto.depositReagents, function(value)
+        ADDON.settings.auto.depositReagents = value
+        ADDON.eventManager:FireEvent('SETTINGS_UPDATE', true)
+    end)
+    autoDeposit:SetPoint('LEFT', autoSellJunk, 'RIGHT', 75, 0)
+
+    container:SetHeight(55)
+    self:AddSettingsPanel(container)
 end
\ No newline at end of file
diff --git a/src/manifest.xml b/src/manifest.xml
index 1f0a9d4..208f409 100644
--- a/src/manifest.xml
+++ b/src/manifest.xml
@@ -16,6 +16,7 @@
     <Script file="src/lua/settings/defaults/categoryContainer.lua"/>
     <Script file="src/lua/settings/defaults/mainBar.lua"/>
     <Script file="src/lua/settings/defaults/bagItem.lua"/>
+    <Script file="src/lua/settings/defaults/auto.lua"/>
     <Script file="src/lua/settings/editor.lua"/>
     <Script file="src/lua/settings/settings.lua"/>