Add vertical grip to resize columns. Add Test Mode. Add quick right click menu to title bar.
This commit is contained in:
@@ -20,10 +20,6 @@ local LSM = LibStub("LibSharedMedia-3.0")
|
||||
_G["Omen"] = Omen
|
||||
|
||||
|
||||
-- TODO: Add TPS calculations
|
||||
-- TODO: Code optimizations
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Keybinding globals
|
||||
BINDING_HEADER_OMEN = "Omen"
|
||||
@@ -73,6 +69,9 @@ local defaults = {
|
||||
NumBars = 10,
|
||||
CollapseHide = false,
|
||||
Locked = false,
|
||||
PositionW = 200,
|
||||
PositionH = 82,
|
||||
VGrip1 = 120,
|
||||
Background = {
|
||||
Texture = "Blizzard Parchment",
|
||||
BorderTexture = "Blizzard Dialog",
|
||||
@@ -193,13 +192,13 @@ end
|
||||
-----------------------------------------------------------------------------
|
||||
-- Omen initialization and frame functions
|
||||
|
||||
local function startmoving()
|
||||
local function startmoving(self)
|
||||
if not db.Locked then
|
||||
Omen.Anchor.IsMovingOrSizing = 1
|
||||
Omen.Anchor:StartMoving()
|
||||
end
|
||||
end
|
||||
local function stopmoving()
|
||||
local function stopmoving(self)
|
||||
if Omen.Anchor.IsMovingOrSizing then
|
||||
Omen.Anchor:StopMovingOrSizing()
|
||||
Omen:SetAnchors()
|
||||
@@ -207,10 +206,30 @@ local function stopmoving()
|
||||
Omen.Anchor.IsMovingOrSizing = nil
|
||||
end
|
||||
end
|
||||
local function sizing()
|
||||
local function sizing(self)
|
||||
local w = Omen.Anchor:GetWidth()
|
||||
db.VGrip1 = w * Omen.Anchor.VGrip1Ratio
|
||||
if db.VGrip1 < 10 then db.VGrip1 = 10 end
|
||||
if db.VGrip1 > w - 10 then db.VGrip1 = w - 10 end
|
||||
Omen.VGrip1:ClearAllPoints()
|
||||
Omen.VGrip1:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", db.VGrip1, 0)
|
||||
Omen.VGrip1:SetPoint("BOTTOMLEFT", Omen.BarList, "BOTTOMLEFT", db.VGrip1, 0)
|
||||
Omen:ResizeBars()
|
||||
Omen:ReAnchorLabels()
|
||||
Omen:UpdateBars()
|
||||
end
|
||||
local function movegrip(self)
|
||||
local x = GetCursorPosition() / UIParent:GetEffectiveScale()
|
||||
local x1 = Omen.Anchor:GetLeft() + 10
|
||||
local x2 = Omen.Anchor:GetRight() - 10
|
||||
if x > x1 and x < x2 then
|
||||
db.VGrip1 = x - x1 + 10
|
||||
Omen.VGrip1:ClearAllPoints()
|
||||
Omen.VGrip1:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", db.VGrip1, 0)
|
||||
Omen.VGrip1:SetPoint("BOTTOMLEFT", Omen.BarList, "BOTTOMLEFT", db.VGrip1, 0)
|
||||
end
|
||||
Omen:ReAnchorLabels()
|
||||
end
|
||||
|
||||
function Omen:CreateFrames()
|
||||
-- Create anchor
|
||||
@@ -225,7 +244,7 @@ function Omen:CreateFrames()
|
||||
self.Anchor:SetScript("OnHide", stopmoving)
|
||||
|
||||
-- Create Title
|
||||
self.Title = CreateFrame("Frame", "OmenTitle", self.Anchor)
|
||||
self.Title = CreateFrame("Button", "OmenTitle", self.Anchor)
|
||||
self.Title:SetPoint("TOPLEFT", self.Anchor, "TOPLEFT")
|
||||
self.Title:SetPoint("TOPRIGHT", self.Anchor, "TOPRIGHT")
|
||||
self.Title:SetHeight(16)
|
||||
@@ -233,6 +252,12 @@ function Omen:CreateFrames()
|
||||
self.Title:EnableMouse(true)
|
||||
self.Title:SetScript("OnMouseDown", startmoving)
|
||||
self.Title:SetScript("OnMouseUp", stopmoving)
|
||||
self.Title:SetScript("OnClick", function(self, button, down)
|
||||
if button == "RightButton" then
|
||||
ToggleDropDownMenu(1, nil, Omen_TitleDropDownMenu, self:GetName(), 0, 0)
|
||||
end
|
||||
end)
|
||||
self.Title:RegisterForClicks("RightButtonUp")
|
||||
|
||||
-- Create Title text
|
||||
self.TitleText = self.Title:CreateFontString(nil, nil, "GameFontNormal")
|
||||
@@ -260,26 +285,45 @@ function Omen:CreateFrames()
|
||||
self.Grip:SetWidth(16)
|
||||
self.Grip:SetHeight(16)
|
||||
self.Grip:SetPoint("BOTTOMRIGHT", self.BarList, "BOTTOMRIGHT", 0, 1)
|
||||
if db.Locked then
|
||||
self.Grip:Hide()
|
||||
end
|
||||
self.Grip:SetScript("OnMouseDown", function()
|
||||
self.Grip:SetScript("OnMouseDown", function(self, button)
|
||||
if not db.Locked then
|
||||
self.Anchor.IsMovingOrSizing = 2
|
||||
self.Anchor:SetScript("OnSizeChanged", sizing)
|
||||
self.Anchor:StartSizing()
|
||||
Omen.Anchor.IsMovingOrSizing = 2
|
||||
Omen.Anchor.VGrip1Ratio = db.VGrip1 / Omen.Anchor:GetWidth()
|
||||
Omen.Anchor:SetScript("OnSizeChanged", sizing)
|
||||
Omen.Anchor:StartSizing()
|
||||
end
|
||||
end)
|
||||
self.Grip:SetScript("OnMouseUp", function()
|
||||
if self.Anchor.IsMovingOrSizing then
|
||||
self.Anchor:SetScript("OnSizeChanged", nil)
|
||||
self.Anchor:StopMovingOrSizing()
|
||||
self.Grip:SetScript("OnMouseUp", function(self)
|
||||
if Omen.Anchor.IsMovingOrSizing then
|
||||
Omen.Anchor:SetScript("OnSizeChanged", nil)
|
||||
Omen.Anchor:StopMovingOrSizing()
|
||||
sizing()
|
||||
self:SetAnchors()
|
||||
self.Anchor.IsMovingOrSizing = nil
|
||||
Omen:SetAnchors()
|
||||
Omen.Anchor.IsMovingOrSizing = nil
|
||||
Omen.Anchor.VGrip1Ratio = nil
|
||||
end
|
||||
end)
|
||||
self.Grip:SetScript("OnHide", self.Grip:GetScript("OnMouseUp"))
|
||||
|
||||
-- Create label resizing vertical grip
|
||||
self.VGrip1 = CreateFrame("Button", "OmenVResizeGrip1", self.BarList)
|
||||
self.VGrip1:SetWidth(1)
|
||||
self.VGrip1:SetPoint("TOPLEFT", self.BarList, "TOPLEFT", db.VGrip1, 0)
|
||||
self.VGrip1:SetPoint("BOTTOMLEFT", self.BarList, "BOTTOMLEFT", db.VGrip1, 0)
|
||||
self.VGrip1:SetNormalTexture("Interface\\Tooltips\\UI-Tooltip-Background")
|
||||
self.VGrip1:SetHighlightTexture("Interface\\Tooltips\\UI-Tooltip-Background")
|
||||
self.VGrip1:GetNormalTexture():SetVertexColor(1, 1, 1, 0.5)
|
||||
self.VGrip1:GetHighlightTexture():SetVertexColor(1, 1, 1, 0.5)
|
||||
self.VGrip1:SetScript("OnMouseDown", function(self)
|
||||
if not db.Locked then
|
||||
self:SetScript("OnUpdate", movegrip)
|
||||
end
|
||||
end)
|
||||
self.VGrip1:SetScript("OnMouseUp", function(self)
|
||||
self:SetScript("OnUpdate", nil)
|
||||
end)
|
||||
self.VGrip1:SetScript("OnHide", self.Grip:GetScript("OnMouseUp"))
|
||||
self.VGrip1:SetFrameLevel(self.BarList:GetFrameLevel() + 2)
|
||||
end
|
||||
|
||||
function Omen:OnInitialize()
|
||||
@@ -296,6 +340,7 @@ function Omen:OnInitialize()
|
||||
|
||||
self:UpdateBackdrop()
|
||||
self:UpdateTitleBar()
|
||||
self:UpdateGrips()
|
||||
|
||||
self:RegisterEvent("PLAYER_LOGIN")
|
||||
end
|
||||
@@ -386,8 +431,10 @@ function Omen:OnProfileChanged(event, database, newProfileKey)
|
||||
self:SetAnchors(true)
|
||||
self:UpdateBackdrop()
|
||||
self:UpdateTitleBar()
|
||||
self:UpdateGrips()
|
||||
self:ResizeBars()
|
||||
self:ReAnchorBars()
|
||||
self:ReAnchorLabels()
|
||||
self:UpdateBarLabelSettings()
|
||||
self:UpdateVisible()
|
||||
self:UpdateBars()
|
||||
@@ -524,6 +571,19 @@ function Omen:UpdateFuBarSettings()
|
||||
end
|
||||
end
|
||||
|
||||
function Omen:UpdateGrips()
|
||||
self.VGrip1:ClearAllPoints()
|
||||
self.VGrip1:SetPoint("TOPLEFT", self.BarList, "TOPLEFT", db.VGrip1, 0)
|
||||
self.VGrip1:SetPoint("BOTTOMLEFT", self.BarList, "BOTTOMLEFT", db.VGrip1, 0)
|
||||
if db.Locked then
|
||||
self.Grip:Hide()
|
||||
self.VGrip1:Hide()
|
||||
else
|
||||
self.Grip:Show()
|
||||
self.VGrip1:Show()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Omen warnings
|
||||
@@ -674,12 +734,18 @@ do
|
||||
bar.Text1:SetJustifyH("LEFT")
|
||||
bar.Text1:SetFont(LSM:Fetch("font", db.Bar.Font), db.Bar.FontSize, db.Bar.FontOutline)
|
||||
bar.Text1:SetTextColor(color.r, color.g, color.b, color.a)
|
||||
bar.Text1:SetWidth(db.VGrip1 - 5)
|
||||
bar.Text1:SetHeight(db.Bar.FontSize)
|
||||
bar.Text1:SetNonSpaceWrap(false)
|
||||
|
||||
bar.Text2 = bar:CreateFontString(nil, nil, "GameFontNormalSmall")
|
||||
bar.Text2:SetPoint("RIGHT", bar, "RIGHT", -5, 1)
|
||||
bar.Text2:SetJustifyH("RIGHT")
|
||||
bar.Text2:SetFont(LSM:Fetch("font", db.Bar.Font), db.Bar.FontSize, db.Bar.FontOutline)
|
||||
bar.Text2:SetTextColor(color.r, color.g, color.b, color.a)
|
||||
bar.Text2:SetWidth(Omen.BarList:GetWidth() - db.VGrip1 - 5)
|
||||
bar.Text2:SetHeight(db.Bar.FontSize)
|
||||
bar.Text2:SetNonSpaceWrap(false)
|
||||
|
||||
bar.texture = bar:CreateTexture()
|
||||
bar.texture:SetTexture(LSM:Fetch("statusbar", db.Bar.Texture))
|
||||
@@ -721,9 +787,21 @@ function Omen:UpdateBarLabelSettings()
|
||||
bars[i].Text2:SetFont(font, size, flags)
|
||||
bars[i].Text1:SetTextColor(color.r, color.g, color.b, color.a)
|
||||
bars[i].Text2:SetTextColor(color.r, color.g, color.b, color.a)
|
||||
bars[i].Text1:SetHeight(size)
|
||||
bars[i].Text2:SetHeight(size)
|
||||
end
|
||||
end
|
||||
|
||||
function Omen:ReAnchorLabels()
|
||||
local w = db.VGrip1
|
||||
local w2 = Omen.BarList:GetWidth() - w
|
||||
for i = 1, #bars do
|
||||
bars[i].Text1:SetWidth(w - 5)
|
||||
bars[i].Text2:SetWidth(w2 - 5)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Omen event functions
|
||||
|
||||
@@ -750,7 +828,7 @@ function Omen:PLAYER_TARGET_CHANGED()
|
||||
timers.UpdateBars = nil
|
||||
end
|
||||
|
||||
if UnitExists("target") then
|
||||
if UnitExists("target") or testMode then
|
||||
self:UpdateBars()
|
||||
else
|
||||
self:ClearAll()
|
||||
@@ -1031,20 +1109,22 @@ function Omen:UpdateBars()
|
||||
self.BarList:Show()
|
||||
|
||||
-- Threat warnings
|
||||
local pGUID = UnitGUID("player")
|
||||
local pClass = guidClassLookup[pGUID]
|
||||
local myThreatPercent = threatTable[pGUID] / tankThreat * 100
|
||||
local t = db.Warnings
|
||||
if lastWarn.mobGUID == mobGUID and myThreatPercent >= t.Threshold and t.Threshold > lastWarn.threatpercent then
|
||||
if not t.DisableWhileTanking or not (pClass == "WARRIOR" and GetBonusBarOffset() == 2 or
|
||||
pClass == "DRUID" and GetBonusBarOffset() == 3 or
|
||||
pClass == "PALADIN" and UnitAura("player", GetSpellInfo(25780)) or
|
||||
pClass == "DEATHKNIGHT" and GetShapeshiftFormInfo(GetShapeshiftForm()) == "Interface\\Icons\\Spell_Deathknight_FrostPresence") then
|
||||
self:Warn(t.Sound, t.Flash, t.Shake, t.Message and L["Passed %s%% of %s's threat!"]:format(t.Threshold, guidNameLookup[tankGUID or mobTargetGUID or sortTable[1]]))
|
||||
if not testMode then
|
||||
local pGUID = UnitGUID("player")
|
||||
local pClass = guidClassLookup[pGUID]
|
||||
local myThreatPercent = threatTable[pGUID] / tankThreat * 100
|
||||
local t = db.Warnings
|
||||
if lastWarn.mobGUID == mobGUID and myThreatPercent >= t.Threshold and t.Threshold > lastWarn.threatpercent then
|
||||
if not t.DisableWhileTanking or not (pClass == "WARRIOR" and GetBonusBarOffset() == 2 or
|
||||
pClass == "DRUID" and GetBonusBarOffset() == 3 or
|
||||
pClass == "PALADIN" and UnitAura("player", GetSpellInfo(25780)) or
|
||||
pClass == "DEATHKNIGHT" and GetShapeshiftFormInfo(GetShapeshiftForm()) == "Interface\\Icons\\Spell_Deathknight_FrostPresence") then
|
||||
self:Warn(t.Sound, t.Flash, t.Shake, t.Message and L["Passed %s%% of %s's threat!"]:format(t.Threshold, guidNameLookup[tankGUID or mobTargetGUID or sortTable[1]]))
|
||||
end
|
||||
end
|
||||
lastWarn.mobGUID = mobGUID
|
||||
lastWarn.threatpercent = myThreatPercent
|
||||
end
|
||||
lastWarn.mobGUID = mobGUID
|
||||
lastWarn.threatpercent = myThreatPercent
|
||||
end
|
||||
|
||||
function Omen:ClearAll()
|
||||
@@ -1064,6 +1144,56 @@ function Omen:ClearAll()
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Title Right Click menu
|
||||
|
||||
do
|
||||
local info = {}
|
||||
local Omen_TitleDropDownMenu = CreateFrame("Frame", "Omen_TitleDropDownMenu")
|
||||
Omen_TitleDropDownMenu.displayMode = "MENU"
|
||||
Omen_TitleDropDownMenu.initialize = function(self, level)
|
||||
if (not level) then return end
|
||||
for k in pairs(info) do info[k] = nil end
|
||||
if (level == 1) then
|
||||
-- Create the title of the menu
|
||||
info.isTitle = 1
|
||||
info.text = "Omen Quick Menu"
|
||||
info.notCheckable = 1
|
||||
UIDropDownMenu_AddButton(info, level)
|
||||
|
||||
info.disabled = nil
|
||||
info.isTitle = nil
|
||||
info.notCheckable = nil
|
||||
info.text = testMode and L["Exit Test Mode"] or L["Enter Test Mode"]
|
||||
info.func = function()
|
||||
testMode = not testMode
|
||||
Omen:UpdateBars()
|
||||
end
|
||||
UIDropDownMenu_AddButton(info, level)
|
||||
|
||||
info.text = db.Locked and L["Unlock Omen"] or L["Lock Omen"]
|
||||
info.func = function()
|
||||
db.Locked = not db.Locked
|
||||
Omen:UpdateGrips()
|
||||
end
|
||||
UIDropDownMenu_AddButton(info, level)
|
||||
|
||||
info.text = L["Open Config"]
|
||||
info.func = function() Omen:ShowConfig() end
|
||||
UIDropDownMenu_AddButton(info, level)
|
||||
|
||||
-- Close menu item
|
||||
info.text = CLOSE
|
||||
info.func = CloseDropDownMenus
|
||||
info.checked = nil
|
||||
info.arg1 = nil
|
||||
info.notCheckable = 1
|
||||
UIDropDownMenu_AddButton(info, level)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Omen config stuff
|
||||
|
||||
@@ -1126,7 +1256,7 @@ local options = {
|
||||
order = 7,
|
||||
set = function(info, value)
|
||||
db.Locked = value
|
||||
if value then Omen.Grip:Hide() else Omen.Grip:Show() end
|
||||
Omen:UpdateGrips()
|
||||
end,
|
||||
},
|
||||
Autocollapse = {
|
||||
|
||||
Reference in New Issue
Block a user