This commit is contained in:
Crum
2019-01-02 21:21:52 -06:00
parent c57fccf201
commit b75736e34d
2 changed files with 73 additions and 28 deletions
+34
View File
@@ -16,6 +16,7 @@ local GetContainerItemLink = GetContainerItemLink
local GetContainerNumSlots = GetContainerNumSlots local GetContainerNumSlots = GetContainerNumSlots
local GetInventoryItemTexture = GetInventoryItemTexture local GetInventoryItemTexture = GetInventoryItemTexture
local GetItemInfo = GetItemInfo local GetItemInfo = GetItemInfo
local GetShapeshiftFormInfo = GetShapeshiftFormInfo
local GetQuestGreenRange = GetQuestGreenRange local GetQuestGreenRange = GetQuestGreenRange
local GetRealZoneText = GetRealZoneText local GetRealZoneText = GetRealZoneText
local IsInInstance = IsInInstance local IsInInstance = IsInInstance
@@ -839,3 +840,36 @@ function GetItemLevelColor(unit)
return 1, 1, 1 return 1, 1, 1
end end
end end
local shapeshiftForms = {
-- Druid
["Bear Form"] = 1,
["Aquatic Form"] = 2,
["Cat Form"] = 3,
["Travel Form"] = 4,
["Moonkin Form"] = 5,
-- Rogue
["Stealth"] = 1,
-- Warrior
["Battle Stance"] = 1,
["Defensive Stance"] = 2,
["Berserker Stance"] = 3,
}
function GetShapeshiftForm()
local numForms = GetNumShapeshiftForms()
for i = 1, NUM_SHAPESHIFT_SLOTS do
if i <= numForms then
local _, name, isActive = GetShapeshiftFormInfo(i)
name = name == "Dire Bear Form" and "Bear Form" or name
local formIndex = shapeshiftForms[name]
if formIndex and isActive then
return formIndex
end
end
end
return 0
end
+38 -27
View File
@@ -30,9 +30,10 @@ function AB:SPELL_UPDATE_COOLDOWN()
end end
function AB:StyleShapeShift() function AB:StyleShapeShift()
local buttonName, button, icon, cooldown
local texture, name, isActive, isCastable, _
local numForms = GetNumShapeshiftForms() local numForms = GetNumShapeshiftForms()
local texture, name, isActive, isCastable, _
local buttonName, button, icon, cooldown
local stance = GetShapeshiftForm()
for i = 1, NUM_SHAPESHIFT_SLOTS do for i = 1, NUM_SHAPESHIFT_SLOTS do
buttonName = "ElvUI_StanceBarButton"..i buttonName = "ElvUI_StanceBarButton"..i
@@ -44,7 +45,7 @@ function AB:StyleShapeShift()
texture, name, isActive, isCastable = GetShapeshiftFormInfo(i) texture, name, isActive, isCastable = GetShapeshiftFormInfo(i)
if self.db.barShapeShift.style == "darkenInactive" then if self.db.barShapeShift.style == "darkenInactive" then
if name then if texture then
texture = texture texture = texture
end end
end end
@@ -71,7 +72,7 @@ function AB:StyleShapeShift()
button:SetChecked(self.db.barShapeShift.style ~= "darkenInactive") button:SetChecked(self.db.barShapeShift.style ~= "darkenInactive")
end end
else else
if numForms == 1 then if numForms == 1 or stance == 0 then
button:SetChecked(false) button:SetChecked(false)
else else
button:SetChecked(self.db.barShapeShift.style == "darkenInactive") button:SetChecked(self.db.barShapeShift.style == "darkenInactive")
@@ -94,21 +95,22 @@ function AB:StyleShapeShift()
end end
function AB:PositionAndSizeBarShapeShift() function AB:PositionAndSizeBarShapeShift()
local buttonSpacing = E:Scale(self.db["barShapeShift"].buttonspacing) local buttonSpacing = E:Scale(self.db.barShapeShift.buttonspacing)
local backdropSpacing = E:Scale((self.db["barShapeShift"].backdropSpacing or self.db["barShapeShift"].buttonspacing)) local backdropSpacing = E:Scale((self.db.barShapeShift.backdropSpacing or self.db.barShapeShift.buttonspacing))
local buttonsPerRow = self.db["barShapeShift"].buttonsPerRow local buttonsPerRow = self.db.barShapeShift.buttonsPerRow
local numButtons = self.db["barShapeShift"].buttons local numButtons = self.db.barShapeShift.buttons
local size = E:Scale(self.db["barShapeShift"].buttonsize) local size = E:Scale(self.db.barShapeShift.buttonsize)
local point = self.db["barShapeShift"].point local point = self.db.barShapeShift.point
local widthMult = self.db["barShapeShift"].widthMult local widthMult = self.db.barShapeShift.widthMult
local heightMult = self.db["barShapeShift"].heightMult local heightMult = self.db.barShapeShift.heightMult
if bar.mover then if bar.mover then
bar.mover.positionOverride = point bar.mover.positionOverride = point
E:UpdatePositionOverride(bar:GetName()) E:UpdatePositionOverride(bar:GetName())
end end
bar.db = self.db["barShapeShift"] bar.db = self.db.barShapeShift
bar.db.position = nil --Depreciated bar.db.position = nil --Depreciated
bar.mouseover = self.db["barShapeShift"].mouseover bar.mouseover = self.db.barShapeShift.mouseover
if bar.LastButton and numButtons > bar.LastButton then if bar.LastButton and numButtons > bar.LastButton then
numButtons = bar.LastButton numButtons = bar.LastButton
@@ -127,20 +129,21 @@ function AB:PositionAndSizeBarShapeShift()
numColumns = 1 numColumns = 1
end end
if self.db["barShapeShift"].backdrop == true then if self.db.barShapeShift.backdrop == true then
bar.backdrop:Show() bar.backdrop:Show()
else else
bar.backdrop:Hide() bar.backdrop:Hide()
--Set size multipliers to 1 when backdrop is disabled
widthMult = 1 widthMult = 1
heightMult = 1 heightMult = 1
end end
local barWidth = (size * (buttonsPerRow * widthMult)) + ((buttonSpacing * (buttonsPerRow - 1)) * widthMult) + (buttonSpacing * (widthMult-1)) + ((self.db["barShapeShift"].backdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2) local barWidth = (size * (buttonsPerRow * widthMult)) + ((buttonSpacing * (buttonsPerRow - 1)) * widthMult) + (buttonSpacing * (widthMult-1)) + ((self.db.barShapeShift.backdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2)
local barHeight = (size * (numColumns * heightMult)) + ((buttonSpacing * (numColumns - 1)) * heightMult) + (buttonSpacing * (heightMult-1)) + ((self.db["barShapeShift"].backdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2) local barHeight = (size * (numColumns * heightMult)) + ((buttonSpacing * (numColumns - 1)) * heightMult) + (buttonSpacing * (heightMult-1)) + ((self.db.barShapeShift.backdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2)
E:Size(bar, barWidth, barHeight) bar:SetWidth(barWidth)
bar:SetHeight(barHeight)
if self.db["barShapeShift"].enabled then if self.db.barShapeShift.enabled then
bar:SetScale(1) bar:SetScale(1)
bar:SetAlpha(bar.db.alpha) bar:SetAlpha(bar.db.alpha)
E:EnableMover(bar.mover:GetName()) E:EnableMover(bar.mover:GetName())
@@ -164,25 +167,26 @@ function AB:PositionAndSizeBarShapeShift()
horizontalGrowth = "LEFT" horizontalGrowth = "LEFT"
end end
if self.db["barShapeShift"].inheritGlobalFade then if self.db.barShapeShift.inheritGlobalFade then
bar:SetParent(self.fadeParent) bar:SetParent(self.fadeParent)
else else
bar:SetParent(E.UIParent) bar:SetParent(E.UIParent)
end end
local button, lastButton, lastColumnButton local button, lastButton, lastColumnButton
local firstButtonSpacing = (self.db["barShapeShift"].backdrop == true and (E.Border + backdropSpacing) or E.Spacing) local firstButtonSpacing = (self.db.barShapeShift.backdrop == true and (E.Border + backdropSpacing) or E.Spacing)
for i = 1, NUM_SHAPESHIFT_SLOTS do for i = 1, NUM_SHAPESHIFT_SLOTS do
button = _G["ElvUI_StanceBarButton"..i] button = _G["ElvUI_StanceBarButton"..i]
lastButton = _G["ElvUI_StanceBarButton"..i-1] lastButton = _G["ElvUI_StanceBarButton"..i - 1]
lastColumnButton = _G["ElvUI_StanceBarButton"..i-buttonsPerRow] lastColumnButton = _G["ElvUI_StanceBarButton"..i - buttonsPerRow]
button:SetParent(bar) button:SetParent(bar)
button:ClearAllPoints() button:ClearAllPoints()
E:Size(button, size) E:Size(button, size)
_G[button:GetName().."Cooldown"]:SetModelScale(size / 40) _G[button:GetName().."Cooldown"]:SetModelScale(size / 40)
if self.db["barShapeShift"].mouseover == true then if self.db.barShapeShift.mouseover == true then
bar:SetAlpha(0) bar:SetAlpha(0)
else else
bar:SetAlpha(bar.db.alpha) bar:SetAlpha(bar.db.alpha)
@@ -237,13 +241,14 @@ function AB:PositionAndSizeBarShapeShift()
end end
end end
if (self.LBFGroup and E.private.actionbar.lbf.enable) then self.LBFGroup:Skin(E.private.actionbar.lbf.skin) end if self.LBFGroup and E.private.actionbar.lbf.enable then self.LBFGroup:Skin(E.private.actionbar.lbf.skin) end
end end
function AB:AdjustMaxStanceButtons(event) function AB:AdjustMaxStanceButtons(event)
for i = 1, getn(bar.buttons) do for i = 1, getn(bar.buttons) do
bar.buttons[i]:Hide() bar.buttons[i]:Hide()
end end
local numButtons = GetNumShapeshiftForms() local numButtons = GetNumShapeshiftForms()
for i = 1, NUM_SHAPESHIFT_SLOTS do for i = 1, NUM_SHAPESHIFT_SLOTS do
if not bar.buttons[i] then if not bar.buttons[i] then
@@ -266,16 +271,21 @@ function AB:AdjustMaxStanceButtons(event)
self:PositionAndSizeBarShapeShift() self:PositionAndSizeBarShapeShift()
-- sometimes after combat lock down `event` may be true because of passing it back with `AB.NeedsAdjustMaxStanceButtons`
if event == "UPDATE_SHAPESHIFT_FORMS" then if event == "UPDATE_SHAPESHIFT_FORMS" then
self:StyleShapeShift() self:StyleShapeShift()
end end
end end
function AB:UpdateStanceBindings() function AB:UpdateStanceBindings()
local color = self.db.fontColor
for i = 1, NUM_SHAPESHIFT_SLOTS do for i = 1, NUM_SHAPESHIFT_SLOTS do
if self.db.hotkeytext then if self.db.hotkeytext then
local key = GetBindingKey("SHAPESHIFTBUTTON"..i)
_G["ElvUI_StanceBarButton"..i.."HotKey"]:Show() _G["ElvUI_StanceBarButton"..i.."HotKey"]:Show()
_G["ElvUI_StanceBarButton"..i.."HotKey"]:SetText(GetBindingKey("SHAPESHIFTBUTTON" .. i)) _G["ElvUI_StanceBarButton"..i.."HotKey"]:SetText(key)
_G["ElvUI_StanceBarButton"..i.."HotKey"]:SetTextColor(color.r, color.g, color.b)
self:FixKeybindText(_G["ElvUI_StanceBarButton"..i]) self:FixKeybindText(_G["ElvUI_StanceBarButton"..i])
else else
_G["ElvUI_StanceBarButton"..i.."HotKey"]:Hide() _G["ElvUI_StanceBarButton"..i.."HotKey"]:Hide()
@@ -286,6 +296,7 @@ end
function AB:CreateBarShapeShift() function AB:CreateBarShapeShift()
E:CreateBackdrop(bar, "Default") E:CreateBackdrop(bar, "Default")
bar.backdrop:SetAllPoints() bar.backdrop:SetAllPoints()
bar:EnableMouse(true)
E:Point(bar, "TOPLEFT", E.UIParent, "TOPLEFT", 4, -4) E:Point(bar, "TOPLEFT", E.UIParent, "TOPLEFT", 4, -4)
bar.buttons = {} bar.buttons = {}