Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollyonn committed Sep 5, 2018
1 parent 66555e7 commit fe6e4c3
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions ElvUI/modules/bags/bagbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ local CreateFrame = CreateFrame
local NUM_BAG_FRAMES = NUM_BAG_FRAMES
local RegisterStateDriver = RegisterStateDriver

local TOTAL_BAGS = NUM_BAG_FRAMES + 2

local ElvUIKeyRing = CreateFrame("CheckButton", "ElvUIKeyRingButton", UIParent, "ItemButtonTemplate")
ElvUIKeyRing:RegisterForClicks("anyUp")
ElvUIKeyRing:StripTextures()
ElvUIKeyRing:SetScript("OnClick", function() if CursorHasItem() then PutKeyInKeyRing() else ToggleKeyRing() end end)
ElvUIKeyRing:SetScript("OnReceiveDrag", function() if CursorHasItem() then PutKeyInKeyRing() end end)
ElvUIKeyRing:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_LEFT") local color = HIGHLIGHT_FONT_COLOR GameTooltip:SetText(KEYRING, color.r, color.g, color.b) GameTooltip:AddLine() end)
ElvUIKeyRing:SetScript("OnLeave", function() GameTooltip:Hide() end)
_G[ElvUIKeyRing:GetName().."IconTexture"]:SetTexture("Interface\\ContainerFrame\\KeyRing-Bag-Icon")
_G[ElvUIKeyRing:GetName().."IconTexture"]:SetTexCoord(unpack(E.TexCoords))

local function OnEnter()
if not E.db.bags.bagBar.mouseover then return end
E:UIFrameFadeOut(ElvUIBags, 0.2, ElvUIBags:GetAlpha(), 1)
Expand All @@ -36,9 +24,9 @@ function B:SkinBag(bag)
bag.oldTex = icon:GetTexture()

bag:StripTextures()
bag:CreateBackdrop("Default", true)
bag.backdrop:SetAllPoints()
bag:SetTemplate("Default", true)
bag:StyleButton(true)

icon:SetTexture(bag.oldTex)
icon:SetInside()
icon:SetTexCoord(unpack(E.TexCoords))
Expand All @@ -53,8 +41,8 @@ function B:SizeAndPositionBagBar()
local showBackdrop = E.db.bags.bagBar.showBackdrop
local growthDirection = E.db.bags.bagBar.growthDirection
local sortDirection = E.db.bags.bagBar.sortDirection

local visibility = E.db.bags.bagBar.visibility

if visibility and visibility:match("[\n\r]") then
visibility = visibility:gsub("[\n\r]","")
end
Expand All @@ -78,9 +66,11 @@ function B:SizeAndPositionBagBar()

for i = 1, #ElvUIBags.buttons do
local button = ElvUIBags.buttons[i]
local prevButton = ElvUIBags.buttons[i-1]
button:Size(E.db.bags.bagBar.size)
local prevButton = ElvUIBags.buttons[i - 1]

button:Size(bagBarSize)
button:ClearAllPoints()

if growthDirection == "HORIZONTAL" and sortDirection == "ASCENDING" then
if i == 1 then
button:Point("LEFT", ElvUIBags, "LEFT", (showBackdrop and (backdropSpacing + E.Border) or 0), 0)
Expand Down Expand Up @@ -109,10 +99,10 @@ function B:SizeAndPositionBagBar()
end

if growthDirection == "HORIZONTAL" then
ElvUIBags:Width(bagBarSize*(TOTAL_BAGS) + buttonSpacing*(TOTAL_BAGS-1) + ((showBackdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2))
ElvUIBags:Width(bagBarSize*(NUM_BAG_FRAMES + 2) + buttonSpacing*(NUM_BAG_FRAMES + 1) + ((showBackdrop and (E.Border + backdropSpacing) or E.Spacing)*2))
ElvUIBags:Height(bagBarSize + ((showBackdrop and (E.Border + backdropSpacing) or E.Spacing)*2))
else
ElvUIBags:Height(bagBarSize*(TOTAL_BAGS) + buttonSpacing*(TOTAL_BAGS-1) + ((showBackdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2))
ElvUIBags:Height(bagBarSize*(NUM_BAG_FRAMES + 2) + buttonSpacing*(NUM_BAG_FRAMES + 1) + ((showBackdrop and (E.Border + backdropSpacing) or E.Spacing)*2))
ElvUIBags:Width(bagBarSize + ((showBackdrop and (E.Border + backdropSpacing) or E.Spacing)*2))
end
end
Expand All @@ -121,7 +111,7 @@ function B:LoadBagBar()
if not E.private.bags.bagBar then return end

local ElvUIBags = CreateFrame("Frame", "ElvUIBags", E.UIParent)
ElvUIBags:SetPoint("TOPRIGHT", RightChatPanel, "TOPLEFT", -4, 0)
ElvUIBags:Point("TOPRIGHT", RightChatPanel, "TOPLEFT", -4, 0)
ElvUIBags.buttons = {}
ElvUIBags:CreateBackdrop()
ElvUIBags.backdrop:SetAllPoints()
Expand All @@ -132,12 +122,16 @@ function B:LoadBagBar()
MainMenuBarBackpackButton:SetParent(ElvUIBags)
MainMenuBarBackpackButton.SetParent = E.dummy
MainMenuBarBackpackButton:ClearAllPoints()

MainMenuBarBackpackButtonCount:FontTemplate(nil, 10)
MainMenuBarBackpackButtonCount:ClearAllPoints()
MainMenuBarBackpackButtonCount:Point("BOTTOMRIGHT", MainMenuBarBackpackButton, "BOTTOMRIGHT", -1, 4)

MainMenuBarBackpackButton:HookScript("OnEnter", OnEnter)
MainMenuBarBackpackButton:HookScript("OnLeave", OnLeave)

tinsert(ElvUIBags.buttons, MainMenuBarBackpackButton)

self:SkinBag(MainMenuBarBackpackButton)

for i = 0, NUM_BAG_FRAMES - 1 do
Expand All @@ -151,15 +145,29 @@ function B:LoadBagBar()
tinsert(ElvUIBags.buttons, b)
end

ElvUIKeyRingButton:SetTemplate()
ElvUIKeyRingButton:StyleButton(true)
_G[ElvUIKeyRingButton:GetName().."IconTexture"]:SetInside()
ElvUIKeyRingButton:SetParent(ElvUIBags)
ElvUIKeyRingButton.SetParent = E.dummy
ElvUIKeyRingButton:HookScript("OnEnter", OnEnter)
ElvUIKeyRingButton:HookScript("OnLeave", OnLeave)
tinsert(ElvUIBags.buttons, ElvUIKeyRingButton)
local ElvUIKeyRing = CreateFrame("CheckButton", "ElvUIKeyRingButton", UIParent, "ItemButtonTemplate")
ElvUIKeyRing:StripTextures()
ElvUIKeyRing:SetTemplate()
ElvUIKeyRing:StyleButton(true)
ElvUIKeyRing:SetParent(ElvUIBags)
ElvUIKeyRing.SetParent = E.dummy
ElvUIKeyRing:RegisterForClicks("anyUp")

_G[ElvUIKeyRing:GetName().."IconTexture"]:SetTexture("Interface\\ContainerFrame\\KeyRing-Bag-Icon")
_G[ElvUIKeyRing:GetName().."IconTexture"]:SetInside()
_G[ElvUIKeyRing:GetName().."IconTexture"]:SetTexCoord(unpack(E.TexCoords))

ElvUIKeyRing:SetScript("OnClick", function() if CursorHasItem() then PutKeyInKeyRing() else ToggleKeyRing() end end)
ElvUIKeyRing:SetScript("OnReceiveDrag", function() if CursorHasItem() then PutKeyInKeyRing() end end)
ElvUIKeyRing:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_LEFT") local color = HIGHLIGHT_FONT_COLOR GameTooltip:SetText(KEYRING, color.r, color.g, color.b) GameTooltip:AddLine() end)
ElvUIKeyRing:SetScript("OnLeave", function() GameTooltip:Hide() end)

ElvUIKeyRing:HookScript("OnEnter", OnEnter)
ElvUIKeyRing:HookScript("OnLeave", OnLeave)

tinsert(ElvUIBags.buttons, ElvUIKeyRing)

self:SizeAndPositionBagBar()

E:CreateMover(ElvUIBags, "BagsMover", L["Bags"])
end

0 comments on commit fe6e4c3

Please sign in to comment.