Quantcast

V0.2.1

Brandon Talbot [07-05-16 - 19:44]
V0.2.1

* Added new bag system
* Added global bag container settings in dialog
* Ensured new items only get reset with new button
* Changed to use GameNormalFont for chinese support
*
Filename
src/lua/controllers/bag.lua
src/lua/core.lua
src/lua/elements/categoryDialog.lua
src/lua/elements/item.lua
src/lua/elements/itemContainer.lua
src/lua/elements/mainBar.lua
src/lua/settings/defaults/itemContainer.lua
src/lua/settings/defaults/mainBar.lua
src/lua/settings/settings.lua
src/lua/utils/utils.lua
diff --git a/src/lua/controllers/bag.lua b/src/lua/controllers/bag.lua
index ce040e7..2ffe62f 100644
--- a/src/lua/controllers/bag.lua
+++ b/src/lua/controllers/bag.lua
@@ -44,6 +44,12 @@ function bag:Toggle()
     end
 end

+function bag:NewItemsUpdated()
+    if self.frame:IsVisible() then
+        self:UpdateAllItems()
+    end
+end
+
 function bag:UpdateAllItems()
     local arrangeList = {}
     for bag = 0, NUM_BAG_SLOTS do
diff --git a/src/lua/core.lua b/src/lua/core.lua
index 33f35bf..ab3e34c 100644
--- a/src/lua/core.lua
+++ b/src/lua/core.lua
@@ -70,6 +70,9 @@ 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 7ca5a7d..510e8be 100644
--- a/src/lua/elements/categoryDialog.lua
+++ b/src/lua/elements/categoryDialog.lua
@@ -64,7 +64,14 @@ function dialog:Init(id)

     UIDropDownMenu_Initialize(self.dropDown, InitDropDown)
     self.errorText:Hide()
-    local text = ADDON.settings.categories.userDefined[id] or ''
+    local text = ''
+    if ADDON.settings.categories.userDefined[id] then
+        text = ADDON.settings.categories.userDefined[id]
+        self.globalCheckbox:SetChecked(false)
+    elseif ADDON.globalCategories[id] then
+        text = ADDON.globalCategories[id]
+        self.globalCheckbox:SetChecked(true)
+    end
     self:SetText(text)

     self.frame:SetHeight(75 + self.title:GetStringHeight())
@@ -85,8 +92,8 @@ function dialog:CreateFrame()
     self.frame:SetPoint('CENTER')
     table.insert(UISpecialFrames, self.frame:GetName())

-    self.title = self.frame:CreateFontString('DJBagsCategoryDialogTitle', 'OVERLAY')
-    self.title:SetFont('Fonts\\FRIZQT__.TTF', 18, 'OUTLINE')
+    self.title = self.frame:CreateFontString('DJBagsCategoryDialogTitle', 'OVERLAY', 'GameFontNormal')
+    self.title:SetFont(select(1, self.title:GetFont()), 18, 'OUTLINE')
     self.title:SetTextColor(1, 1, 1, 1)
     self.title:SetPoint("TOPLEFT", 5, -5)
     self.title:SetPoint("TOPRIGHT", -5, -5)
@@ -112,8 +119,8 @@ function dialog:CreateFrame()
         dialog.frame:Hide()
     end)

-    self.errorText = self.frame:CreateFontString('DJBagsCategoryDialogTitle', 'OVERLAY')
-    self.errorText:SetFont('Fonts\\FRIZQT__.TTF', 18, 'OUTLINE')
+    self.errorText = self.frame:CreateFontString('DJBagsCategoryDialogTitle', '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)
     self.errorText:SetText('A Category name needs to be entered!')
@@ -140,11 +147,19 @@ function dialog:CreateFrame()
     self.resetBtn:SetBackdropColor(0, 0, 0, 0)
     self.resetBtn:SetPoint('BOTTOMLEFT', self.frame, 'BOTTOMLEFT', 5, 5)
     self.resetBtn:SetScript('OnClick', function()
-        ADDON.settings.categories.userDefined[dialog.id] = nil
+        if self.globalCheckbox:GetChecked() then
+            ADDON.globalCategories[dialog.id] = nil
+        else
+            ADDON.settings.categories.userDefined[dialog.id] = nil
+        end
         ADDON.eventManager:FireEvent('SETTINGS_UPDATE', true)
         dialog.frame:Hide()
     end)

+    self.globalCheckbox = CreateFrame("CheckButton", 'DJBagsCategoryDialogGlobalCheckbox', self.frame, 'OptionsSmallCheckButtonTemplate')
+    self.globalCheckbox:SetPoint('LEFT', self.resetBtn, 'RIGHT', 5, 0)
+    _G[self.globalCheckbox:GetName().."Text"]:SetText(ALL)
+
     self.okBtn = CreateFrame('BUTTON', 'DJBagsCategoryDialogOkButton', self.frame)
     self.okBtn:SetNormalFontObject("GameFontHighlight")
     self.okBtn:SetSize(75, 20)
@@ -163,7 +178,11 @@ function dialog:CreateFrame()
         local text = dialog.editBox:GetText()
         dialog.errorText:Hide()
         if not text or text ~= '' then
-            ADDON.settings.categories.userDefined[dialog.id] = text
+            if self.globalCheckbox:GetChecked() then
+                ADDON.globalCategories[dialog.id] = text
+            else
+                ADDON.settings.categories.userDefined[dialog.id] = text
+            end
             ADDON.eventManager:FireEvent('SETTINGS_UPDATE', true)
             dialog.frame:Hide()
         else
diff --git a/src/lua/elements/item.lua b/src/lua/elements/item.lua
index 70d74fd..2932aeb 100644
--- a/src/lua/elements/item.lua
+++ b/src/lua/elements/item.lua
@@ -61,6 +61,7 @@ function item:Init()
     self.button:Show()

     self.button:HookScript('OnClick', self.OnClick)
+    self.button:SetScript('OnEnter', self.OnEnter)
 end

 function item:Setup()
@@ -70,6 +71,73 @@ function item:Setup()
     self.button.Count:SetFont(name, math.min(settings.size / 3, 13), outline)
 end

+function item:OnEnter(...)
+    local bag = self:GetParent():GetID()
+
+    if bag == BANK_CONTAINER or bag == REAGENTBANK_CONTAINER then
+        BankFrameItemButton_OnEnter(self, ...)
+    else
+        self:GetParent().OnEnterBag(self)
+    end
+end
+
+function item:OnEnterBag()
+    GameTooltip:SetOwner(self, "ANCHOR_NONE")
+
+    local newItemTexture = self.NewItemTexture
+    local battlepayItemTexture = self.BattlepayItemTexture
+    local flash = self.flashAnim
+    local newItemGlowAnim = self.newitemglowAnim
+
+    newItemTexture:Hide()
+    battlepayItemTexture:Hide()
+
+    if (flash:IsPlaying() or newItemGlowAnim:IsPlaying()) then
+        flash:Stop()
+        newItemGlowAnim:Stop()
+    end
+
+    local showSell
+    local _, repairCost, speciesID, level, breedQuality, maxHealth, power, speed, name = GameTooltip:SetBagItem(self:GetParent():GetID(), self:GetID())
+    if(speciesID and speciesID > 0) then
+        ContainerFrameItemButton_CalculateItemTooltipAnchors(self, GameTooltip)
+        BattlePetToolTip_Show(speciesID, level, breedQuality, maxHealth, power, speed, name)
+        return;
+    else
+        if (BattlePetTooltip) then
+            BattlePetTooltip:Hide()
+        end
+    end
+
+    local requiresCompareTooltipReanchor = ContainerFrameItemButton_CalculateItemTooltipAnchors(self, GameTooltip)
+
+    if ( requiresCompareTooltipReanchor and (IsModifiedClick("COMPAREITEMS") or GetCVarBool("alwaysCompareItems")) ) then
+        GameTooltip_ShowCompareItem(GameTooltip)
+    end
+
+    if ( InRepairMode() and (repairCost and repairCost > 0) ) then
+        GameTooltip:AddLine(REPAIR_COST, nil, nil, nil, true)
+        SetTooltipMoney(GameTooltip, repairCost)
+        GameTooltip:Show()
+    elseif ( MerchantFrame:IsShown() and MerchantFrame.selectedTab == 1 ) then
+        showSell = 1
+    end
+
+    if ( IsModifiedClick("DRESSUP") and self.hasItem ) then
+        ShowInspectCursor()
+    elseif ( showSell ) then
+        ShowContainerSellCursor(self:GetParent():GetID(),self:GetID())
+    elseif ( self.readable ) then
+        ShowInspectCursor()
+    else
+        ResetCursor()
+    end
+
+    if ArtifactFrame and self.hasItem then
+        ArtifactFrame:OnInventoryItemMouseEnter(self:GetParent():GetID(), self:GetID())
+    end
+end
+
 --region Update Events

 local function UpdateQuest(self, isQuestItem, questId, isActive)
diff --git a/src/lua/elements/itemContainer.lua b/src/lua/elements/itemContainer.lua
index efef94a..791cacc 100644
--- a/src/lua/elements/itemContainer.lua
+++ b/src/lua/elements/itemContainer.lua
@@ -24,7 +24,7 @@ setmetatable(container, {
 function container:Init(hasTitle)
     self.items = {}
     if hasTitle == nil or hasTitle then
-        self.title = self:CreateFontString(self:GetName() .. 'Title', 'OVERLAY')
+        self.title = self:CreateFontString(self:GetName() .. 'Title', 'OVERLAY', 'GameFontNormal')
     end
 end

@@ -39,7 +39,8 @@ function container:Setup()
     self.sortFunction = ADDON.sorters.items[settings.sortFunction]

     if self.title then
-        self.title:SetFont(settings.font, settings.fontSize, '')
+        local font, _, outline = self.title:GetFont()
+        self.title:SetFont(font, settings.fontSize, outline)
         self.title:SetText(self.name)
         self.title:SetTextColor(unpack(settings.fontColor))
         self.title:ClearAllPoints()
diff --git a/src/lua/elements/mainBar.lua b/src/lua/elements/mainBar.lua
index 2a6050f..1b4f27a 100644
--- a/src/lua/elements/mainBar.lua
+++ b/src/lua/elements/mainBar.lua
@@ -35,7 +35,7 @@ function bar:Init()
     end)

     self.currencyBox = CreateFrame('FRAME', 'DJBagsMainBarCurrencyBox', self)
-    self.currency = self.currencyBox:CreateFontString('DJBagMainBarCurrencyText', 'OVERLAY')
+    self.currency = self.currencyBox:CreateFontString('DJBagMainBarCurrencyText', 'OVERLAY', 'GameFontNormal')
     self.currency:SetAllPoints()
     self.currencyBox:SetPoint('TOPLEFT', 5, -5)
     self.currencyBox:SetPoint('BOTTOMLEFT', 5, 5)
@@ -43,11 +43,11 @@ function bar:Init()
     self.searchBox:SetPoint('TOPLEFT', self.currencyBox, 'TOPRIGHT', 10, 0)
     self.searchBox:SetPoint('BOTTOMLEFT', self.currencyBox, 'BOTTOMRIGHT', 10, 0)
     self.searchBox:SetWidth(125)
-    self.slots = self:CreateFontString('DJBagMainBarSlotsText', 'OVERLAY')
+    self.slots = self:CreateFontString('DJBagMainBarSlotsText', 'OVERLAY', 'GameFontNormal')
     self.slots:SetPoint('TOPLEFT', self.searchBox, 'TOPRIGHT', 5, 0)
     self.slots:SetPoint('BOTTOMLEFT', self.searchBox, 'BOTTOMRIGHT', 5, 0)

-    self.bagBtn = CreateFrame("CheckButton", 'TestBtnThingy', self, 'UIRadioButtonTemplate')
+    self.bagBtn = CreateFrame("CheckButton", 'DJMainBarBagBtn', self, 'UIRadioButtonTemplate')
     self.bagBtn:SetPoint('RIGHT', -5, 0)
     self.bagBtn:SetScript('OnClick', function()
         if self.bagFrame then
@@ -59,6 +59,28 @@ function bar:Init()
         end
     end)

+    self.clearBtn = CreateFrame('Button', 'DJMainBarClearBtn', self)
+    self.clearBtn:SetNormalTexture([[Interface\Buttons\UI-RotationLeft-Button-Up]])
+    self.clearBtn:SetPushedTexture([[Interface\Buttons\UI-RotationLeft-Button-Down]])
+    self.clearBtn:SetHighlightTexture([[Interface\Buttons\ButtonHilight-Square]])
+    self.clearBtn:GetHighlightTexture():ClearAllPoints()
+    self.clearBtn:GetHighlightTexture():SetPoint('TOPLEFT', 3, -3)
+    self.clearBtn:GetHighlightTexture():SetPoint('BOTTOMRIGHT', -3, 3)
+    self.clearBtn:SetPoint('RIGHT', self.bagBtn, 'LEFT', -1, 0)
+    self.clearBtn:SetSize(25, 25)
+    self.clearBtn:SetScript('OnEnter', function(self)
+        GameTooltip:SetOwner(self, 'TOPRIGHT')
+        GameTooltip:SetText('Clear New Items')
+        GameTooltip:Show()
+    end)
+    self.clearBtn:SetScript('OnLeave', function(self)
+        GameTooltip:Hide()
+    end)
+    self.clearBtn:SetScript('OnClick', function(self)
+        C_NewItems:ClearAll()
+        ADDON.bag:NewItemsUpdated()
+    end)
+
     self.currencyBox:SetScript('OnEnter', function()
         local cnt = GetCurrencyListSize()
         GameTooltip:SetOwner(self.currencyBox, "ANCHOR_NONE")
@@ -91,9 +113,12 @@ function bar:Setup()
     ADDON.container.Setup(self)

     local settings = ADDON.settings.mainBar
-    self.currency:SetFont(settings.currencyFont, settings.currencyFontSize, '')
+    local font, _, outline = self.currency:GetFont()
+    self.currency:SetFont(font, settings.currencyFontSize, outline)
     self.currency:SetTextColor(unpack(settings.currencyFontColor))
-    self.slots:SetFont(settings.slotsFont, settings.slotsFontSize, '')
+
+    font, _, outline = self.slots:GetFont()
+    self.slots:SetFont(font, settings.slotsFontSize, outline)
     self.slots:SetTextColor(unpack(settings.slotsFontColor))
 end

@@ -108,5 +133,5 @@ function bar:Update()
     self.slots:SetText(string.format("%d/%d", total - free, total))

     self.currencyBox:SetWidth(self.currency:GetStringWidth())
-    self:SetSize(self.currency:GetStringWidth() + self.slots:GetStringWidth() + 165, math.max(self.currency:GetStringHeight(), self.slots:GetStringHeight()) + 12)
+    self:SetSize(self.currency:GetStringWidth() + self.slots:GetStringWidth() + 190, math.max(self.currency:GetStringHeight(), self.slots:GetStringHeight()) + 12)
 end
diff --git a/src/lua/settings/defaults/itemContainer.lua b/src/lua/settings/defaults/itemContainer.lua
index 3fd258e..60042ea 100644
--- a/src/lua/settings/defaults/itemContainer.lua
+++ b/src/lua/settings/defaults/itemContainer.lua
@@ -6,7 +6,6 @@ ADDON.settings.itemContainer = {
     spacing = 3,
     padding = 5,
     cols = 5,
-    font = 'Fonts\\FRIZQT__.TTF',
     fontSize = 13,
     fontColor = { 0.5, 1, 0.5, 1 },
     titleMargin = 5,
diff --git a/src/lua/settings/defaults/mainBar.lua b/src/lua/settings/defaults/mainBar.lua
index 40664d3..b063dca 100644
--- a/src/lua/settings/defaults/mainBar.lua
+++ b/src/lua/settings/defaults/mainBar.lua
@@ -5,8 +5,6 @@ ADDON.settings = ADDON.settings or {}
 ADDON.settings.mainBar = {
     currencyFontSize = 12,
     currencyFontColor = { 1, 1, 1, 1 },
-    currencyFont = 'Fonts\\FRIZQT__.TTF',
     slotsFontSize = 12,
     slotsFontColor = { 1, 1, 1, 1 },
-    slotsFont = 'Fonts\\FRIZQT__.TTF',
 }
\ No newline at end of file
diff --git a/src/lua/settings/settings.lua b/src/lua/settings/settings.lua
index 23e6f22..26685a7 100644
--- a/src/lua/settings/settings.lua
+++ b/src/lua/settings/settings.lua
@@ -53,14 +53,14 @@ function settings:MigrateSettings(table, default)
             if type(v) ~= type(table[k]) then
                 table[k] = v
             elseif type(v) == 'table' then
-                migrate(table[k], v)
+                self:MigrateSettings(table[k], v)
             end
         else
             table[k] = v
         end
     end
     for k, v in pairs(table) do
-        if not default[k] then
+        if not default[k] and type(v) == 'table' then
             table[k] = nil
         end
     end
diff --git a/src/lua/utils/utils.lua b/src/lua/utils/utils.lua
index bc3c526..b590eb4 100644
--- a/src/lua/utils/utils.lua
+++ b/src/lua/utils/utils.lua
@@ -43,11 +43,20 @@ function utils:GetItemContainerName(bag, slot)
             return setName
         end

+        if bag >= 0 and bag <= NUM_BAG_SLOTS and C_NewItems.IsNewItem(bag, slot) then
+            return NEW
+        end
+
         local userDefinedList = ADDON.settings.categories.userDefined
         if userDefinedList[id] then
             return userDefinedList[id] .. '*'
         end

+        local globalDefinedList = ADDON.globalCategories
+        if globalDefinedList[id] then
+            return globalDefinedList[id] .. '**'
+        end
+
         local subClassSplitList = ADDON.settings.categories.subClass
         if subClassSplitList[cId] then
             return className .. ' ' .. subClassName