Quantcast

Fixed bank bag not refreshing when moving items

Brandon Talbot [08-04-16 - 18:02]
Fixed bank bag not refreshing when moving items
Fixed BoA/BoE with caged battle pet
Added Sold junk text to LOCALE and made zhTW translation (thanks to gaspy10)
Fixed issue where bank bags were not "locking"
Fixed slash commands
Added close buttons back with alpha focusing
Added ReStack buttons for bags and bank
Filename
src/lua/constants/contstants.lua
src/lua/controller/bag.lua
src/lua/controller/bank.lua
src/lua/core.lua
src/lua/element/item.lua
src/xml/element/bankBar.xml
src/xml/element/container.xml
src/xml/element/mainBar.xml
src/xml/settings/settingsContainer.xml
diff --git a/src/lua/constants/contstants.lua b/src/lua/constants/contstants.lua
index 66c41d4..2415476 100644
--- a/src/lua/constants/contstants.lua
+++ b/src/lua/constants/contstants.lua
@@ -69,6 +69,7 @@ localeText['enUS'] = function()
     DJBags_LOCALE_VERTICAL = 'Vertical'
     DJBags_LOCALE_MAX_ITEMS = 'Max items'
     DJBags_LOCALE_MAX_HEIGHT = 'Max height'
+    DJBags_LOCALE_SOLD_JUNK = 'Sold junk for: %s'
 end
 localeText['zhTW'] = function()
     DJBags_LOCALE_MAIN_SETTINGS = '主設定:'
@@ -99,6 +100,7 @@ localeText['zhTW'] = function()
     DJBags_LOCALE_VERTICAL = '垂直'
     DJBags_LOCALE_MAX_ITEMS = '分類寬度最多物品數目'
     DJBags_LOCALE_MAX_HEIGHT = '最大高度'
+    DJBags_LOCALE_SOLD_JUNK = '賣出垃圾獲得: %s'
 end

 if localeText[GetLocale()] then
diff --git a/src/lua/controller/bag.lua b/src/lua/controller/bag.lua
index 006d020..29eab45 100644
--- a/src/lua/controller/bag.lua
+++ b/src/lua/controller/bag.lua
@@ -83,7 +83,7 @@ function controller:MERCHANT_SHOW()
         end
         ResetCursor()
         if price ~= 0 then
-            DEFAULT_CHAT_FRAME:AddMessage("Sold junk for: " .. GetCoinTextureString(price))
+            DEFAULT_CHAT_FRAME:AddMessage(string.format(DJBags_LOCALE_SOLD_JUNK, GetCoinTextureString(price)))
         end
     end
 end
diff --git a/src/lua/controller/bank.lua b/src/lua/controller/bank.lua
index 10406a0..bc72f52 100644
--- a/src/lua/controller/bank.lua
+++ b/src/lua/controller/bank.lua
@@ -115,6 +115,7 @@ end
 function controller:BAG_UPDATE(bag)
     if bag > NUM_BAG_SLOTS then
         ADDON:UpdateBags({bag})
+        DJBagsBankContainer:Arrange()
     end
 end

@@ -155,9 +156,13 @@ function controller:BAG_UPDATE_COOLDOWN()
 end

 function controller:ITEM_LOCK_CHANGED(bag, slot)
-    if bag ~= BANK_CONTAINER and bag ~= REAGENTBANK_CONTAINER and bag <= NUM_BAG_SLOTS then return end
+    if (bag ~= BANK_CONTAINER and bag ~= REAGENTBANK_CONTAINER and bag <= NUM_BAG_SLOTS) or not slot then return end

-    ADDON.cache:GetItem(bag, slot):UpdateLock()
+    if bag == BANK_CONTAINER and slot > NUM_BANKGENERIC_SLOTS then
+        _G[DJBagsBankBar:GetName() .. 'Bag' .. slot-NUM_BANKGENERIC_SLOTS]:UpdateLock()
+    else
+        ADDON.cache:GetItem(bag, slot):UpdateLock()
+    end
 end

 function controller:PLAYERREAGENTBANKSLOTS_CHANGED()
diff --git a/src/lua/core.lua b/src/lua/core.lua
index d007dcf..f421a5e 100644
--- a/src/lua/core.lua
+++ b/src/lua/core.lua
@@ -53,7 +53,7 @@ end

 --endregion

-SLASH_DJBAGS1, SLASH_DJBAGS2, SLASH_DJBAGS3 = '/djb', '/dj', 'djbags';
+SLASH_DJBAGS1, SLASH_DJBAGS2, SLASH_DJBAGS3, SLASH_DJBAGS4 = '/djb', '/dj', '/djbags', '/db';
 function SlashCmdList.DJBAGS(msg, editbox)
     DJBagsSettingsContainer:Show()
 end
diff --git a/src/lua/element/item.lua b/src/lua/element/item.lua
index 1a015c7..55349ba 100644
--- a/src/lua/element/item.lua
+++ b/src/lua/element/item.lua
@@ -65,12 +65,15 @@ function item:GetContainerName()
         end

         local subClassSplitList = ADDON.settings:GetSettings(DJBags_TYPE_SUB_CLASS)
-        if subClassSplitList[DJBags_SETTING_BOE] and DJBagsTooltip:IsItemBOE(self.link) then
-            return DJBags_LOCALE_BOE
-        end
-        if subClassSplitList[DJBags_SETTING_BOA] and DJBagsTooltip:IsItemBOA(self.link) then
-            return DJBags_LOCALE_BOA
+        if self.classId ~= LE_ITEM_CLASS_BATTLEPET then
+            if subClassSplitList[DJBags_SETTING_BOE] and DJBagsTooltip:IsItemBOE(self.link) then
+                return DJBags_LOCALE_BOE
+            end
+            if subClassSplitList[DJBags_SETTING_BOA] and DJBagsTooltip:IsItemBOA(self.link) then
+                return DJBags_LOCALE_BOA
+            end
         end
+
         if subClassSplitList[self.classId] then
             return self.class .. (self.subClass == BAG_FILTER_JUNK and '' or '_' .. self.subClass)
         end
diff --git a/src/xml/element/bankBar.xml b/src/xml/element/bankBar.xml
index 55e9e67..b0f63d3 100644
--- a/src/xml/element/bankBar.xml
+++ b/src/xml/element/bankBar.xml
@@ -80,10 +80,34 @@
                     </OnLoad>
                 </Scripts>
             </Button>
+            <Button name="$parentRestackButton">
+                <Size x="16" y="16" />
+                <Anchors>
+                    <Anchor point="TOPRIGHT" relativeTo="$parentBag7" relativePoint="BOTTOMRIGHT" y="-9.5" />
+                </Anchors>
+                <NormalTexture file="Interface\Buttons\UI-GuildButton-PublicNote-Disabled" />
+                <PushedTexture file="Interface\Buttons\UI-GuildButton-OfficerNote-Up" />
+                <HighlightTexture file="Interface\Buttons\UI-GuildButton-PublicNote-Up" alphaMode="ADD" />
+                <Scripts>
+                    <OnEnter>
+                        GameTooltip:SetOwner(self, 'TOPRIGHT')
+                        GameTooltip:SetText(BAG_CLEANUP_BANK)
+                        GameTooltip:Show()
+                    </OnEnter>
+                    <OnLeave>
+                        GameTooltip:Hide()
+                    </OnLeave>
+                    <OnClick>
+                        PlaySound("UI_BagSorting_01");
+                        SortBankBags()
+                        SortReagentBankBags()
+                    </OnClick>
+                </Scripts>
+            </Button>
             <Button name="$parentDepositReagent" inherits="UIPanelButtonTemplate" text="REAGENTBANK_DEPOSIT">
                 <Size x="150" y="25" />
                 <Anchors>
-                    <Anchor point="TOPRIGHT" relativeTo="$parentBag7" relativePoint="BOTTOMRIGHT" y="-5" />
+                    <Anchor point="RIGHT" relativeTo="$parentRestackButton" relativePoint="LEFT" x="-3" />
                 </Anchors>
                 <Scripts>
                     <OnClick>
@@ -152,6 +176,23 @@
                     </OnClick>
                 </Scripts>
             </Button>
+            <Button name="$parentClose" parentKey="close" inherits="UIPanelCloseButton">
+                <Anchors>
+                    <Anchor point="CENTER" relativePoint="TOPRIGHT" x="-2" y="-2"/>
+                </Anchors>
+                <NormalTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Disabled" />
+                <Scripts>
+                    <OnLoad>
+                        self:SetAlpha(0.2)
+                    </OnLoad>
+                    <OnEnter>
+                        self:SetAlpha(1)
+                    </OnEnter>
+                    <OnLeave>
+                        self:SetAlpha(0.2)
+                    </OnLeave>
+                </Scripts>
+            </Button>
         </Frames>
         <Scripts>
             <OnLoad>
diff --git a/src/xml/element/container.xml b/src/xml/element/container.xml
index 33b72ec..a7704d6 100644
--- a/src/xml/element/container.xml
+++ b/src/xml/element/container.xml
@@ -26,6 +26,23 @@
                     <Anchor point="TOPRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" x="0" y="-5"/>
                 </Anchors>
             </Frame>
+            <Button name="$parentClose" parentKey="close" inherits="UIPanelCloseButton">
+                <Anchors>
+                    <Anchor point="CENTER" relativePoint="TOPRIGHT" x="-2" y="-2"/>
+                </Anchors>
+                <NormalTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Disabled" />
+                <Scripts>
+                    <OnLoad>
+                        self:SetAlpha(0.2)
+                    </OnLoad>
+                    <OnEnter>
+                        self:SetAlpha(1)
+                    </OnEnter>
+                    <OnLeave>
+                        self:SetAlpha(0.2)
+                    </OnLeave>
+                </Scripts>
+            </Button>
         </Frames>
         <Scripts>
             <OnShow>
diff --git a/src/xml/element/mainBar.xml b/src/xml/element/mainBar.xml
index 6418ff9..cf54895 100644
--- a/src/xml/element/mainBar.xml
+++ b/src/xml/element/mainBar.xml
@@ -1,6 +1,6 @@
 <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
     <Frame name="DJBagsMainBarTemplate" virtual="true" movable="true" enableMouse="true">
-        <Size x="300" y="25" />
+        <Size x="325" y="25" />
         <Backdrop bgFile="Interface\ChatFrame\ChatFrameBackground" edgeFile="Interface\Buttons\WHITE8x8">
             <EdgeSize>
                 <AbsValue val="1" />
@@ -17,10 +17,33 @@
                     </OnClick>
                 </Scripts>
             </CheckButton>
+            <Button name="$parentRestackBtn">
+                <Size x="16" y="16" />
+                <Anchors>
+                    <Anchor point="RIGHT" relativeTo="$parentBagBtn" relativePoint="LEFT" x="-3" />
+                </Anchors>
+                <NormalTexture file="Interface\Buttons\UI-GuildButton-PublicNote-Disabled" />
+                <PushedTexture file="Interface\Buttons\UI-GuildButton-OfficerNote-Up" />
+                <HighlightTexture file="Interface\Buttons\UI-GuildButton-PublicNote-Up" alphaMode="ADD" />
+                <Scripts>
+                    <OnEnter>
+                        GameTooltip:SetOwner(self, 'TOPRIGHT')
+                        GameTooltip:SetText(BAG_CLEANUP_BAGS)
+                        GameTooltip:Show()
+                    </OnEnter>
+                    <OnLeave>
+                        GameTooltip:Hide()
+                    </OnLeave>
+                    <OnClick>
+                        PlaySound("UI_BagSorting_01");
+                        SortBags()
+                    </OnClick>
+                </Scripts>
+            </Button>
             <Button name="$parentClearButton">
                 <Size x="25" y="25" />
                 <Anchors>
-                    <Anchor point="RIGHT" relativeTo="$parentBagBtn" relativePoint="LEFT" x="-3" />
+                    <Anchor point="RIGHT" relativeTo="$parentRestackBtn" relativePoint="LEFT" x="-3" />
                 </Anchors>
                 <NormalTexture file="Interface\Buttons\UI-RotationLeft-Button-Up" />
                 <PushedTexture file="Interface\Buttons\UI-RotationLeft-Button-Down" />
diff --git a/src/xml/settings/settingsContainer.xml b/src/xml/settings/settingsContainer.xml
index 7be7051..05370f1 100644
--- a/src/xml/settings/settingsContainer.xml
+++ b/src/xml/settings/settingsContainer.xml
@@ -105,6 +105,23 @@
                     </OnValueChanged>
                 </Scripts>
             </Slider>
+            <Button name="$parentClose" parentKey="close" inherits="UIPanelCloseButton">
+                <Anchors>
+                    <Anchor point="CENTER" relativePoint="TOPRIGHT" x="-2" y="-2"/>
+                </Anchors>
+                <NormalTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Disabled" />
+                <Scripts>
+                    <OnLoad>
+                        self:SetAlpha(0.2)
+                    </OnLoad>
+                    <OnEnter>
+                        self:SetAlpha(1)
+                    </OnEnter>
+                    <OnLeave>
+                        self:SetAlpha(0.2)
+                    </OnLeave>
+                </Scripts>
+            </Button>
         </Frames>
         <Scripts>
             <OnLoad>