Add various autocollapse options.
Fix position saving bugs resulting from adding autocollapse options. Fix grip hiding script bug. Uncomment LDB launcher code now that config code is in. Fix OnProfileChanged code. Add ShowWith options. Add mouseover and mouseovertarget to raid scanning. Fix division by 0 percentage display. Add FAQ section.
This commit is contained in:
@@ -31,6 +31,7 @@ local defaults = {
|
||||
GrowUp = false,
|
||||
Autocollapse = false,
|
||||
NumBars = 10,
|
||||
CollapseHide = false,
|
||||
Locked = false,
|
||||
BarHeight = 16,
|
||||
ShowWith = {
|
||||
@@ -110,13 +111,17 @@ end
|
||||
|
||||
local function startmoving()
|
||||
if not db.Locked then
|
||||
Omen.Anchor.IsMovingOrSizing = true
|
||||
Omen.Anchor:StartMoving()
|
||||
end
|
||||
end
|
||||
local function stopmoving()
|
||||
Omen.Anchor:StopMovingOrSizing()
|
||||
Omen:SetAnchors()
|
||||
Omen:UpdateBars()
|
||||
if Omen.Anchor.IsMovingOrSizing then
|
||||
Omen.Anchor:StopMovingOrSizing()
|
||||
Omen:SetAnchors()
|
||||
Omen:UpdateBars()
|
||||
Omen.Anchor.IsMovingOrSizing = nil
|
||||
end
|
||||
end
|
||||
local function sizing()
|
||||
Omen:ResizeBars()
|
||||
@@ -187,13 +192,15 @@ function Omen:CreateFrames()
|
||||
end
|
||||
end)
|
||||
self.Grip:SetScript("OnMouseUp", function()
|
||||
self.Anchor:SetScript("OnSizeChanged", nil)
|
||||
self.Anchor:StopMovingOrSizing()
|
||||
self.Anchor.IsMovingOrSizing = nil
|
||||
sizing()
|
||||
self:SetAnchors()
|
||||
if self.Anchor.IsMovingOrSizing then
|
||||
self.Anchor:SetScript("OnSizeChanged", nil)
|
||||
self.Anchor:StopMovingOrSizing()
|
||||
sizing()
|
||||
self:SetAnchors()
|
||||
self.Anchor.IsMovingOrSizing = nil
|
||||
end
|
||||
end)
|
||||
self.Grip:SetScript("OnHide", self.Grip:GetScript("OnHide"))
|
||||
self.Grip:SetScript("OnHide", self.Grip:GetScript("OnMouseUp"))
|
||||
end
|
||||
|
||||
function Omen:OnInitialize()
|
||||
@@ -221,7 +228,6 @@ function Omen:PLAYER_LOGIN()
|
||||
self:SetAnchors(true)
|
||||
self:UnregisterEvent("PLAYER_LOGIN")
|
||||
|
||||
--[[
|
||||
-- Optional launcher support for LDB-1.1 if present, this code is placed here so
|
||||
-- that it runs after all other addons have loaded since we don't embed LDB-1.1
|
||||
local DataBroker = LibStub("LibDataBroker-1.1", true)
|
||||
@@ -234,7 +240,6 @@ function Omen:PLAYER_LOGIN()
|
||||
end,
|
||||
})
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
function Omen:OnEnable()
|
||||
@@ -246,7 +251,6 @@ function Omen:OnEnable()
|
||||
|
||||
self:PARTY_MEMBERS_CHANGED()
|
||||
self:PLAYER_TARGET_CHANGED()
|
||||
self:Toggle(true)
|
||||
end
|
||||
|
||||
function Omen:Disable()
|
||||
@@ -269,6 +273,9 @@ end
|
||||
|
||||
function Omen:OnProfileChanged(db, name)
|
||||
db = self.db.profile
|
||||
self:SetAnchors(true)
|
||||
self:UpdateVisible()
|
||||
self:UpdateBars()
|
||||
end
|
||||
|
||||
function Omen:SetAnchors(useDB)
|
||||
@@ -316,6 +323,27 @@ function Omen:Toggle(setting)
|
||||
end
|
||||
end
|
||||
|
||||
function Omen:UpdateVisible()
|
||||
local inInstance, instanceType = IsInInstance()
|
||||
local show
|
||||
if not db.ShowWith.Resting and IsResting() then
|
||||
show = false
|
||||
end
|
||||
if not db.ShowWith.PVP and inInstance and (instanceType == "pvp" or instanceType == "arena") then
|
||||
show = false
|
||||
end
|
||||
if not db.ShowWith.Dungeon and inInstance and (instanceType == "party" or instanceType == "raid") then
|
||||
show = false
|
||||
end
|
||||
if show == nil then
|
||||
show = (db.ShowWith.Pet and UnitExists("pet")) or
|
||||
(db.ShowWith.Alone and GetNumPartyMembers() + GetNumRaidMembers() == 0 and not UnitExists("pet")) or
|
||||
(db.ShowWith.Party and GetNumPartyMembers() > 0) or
|
||||
(db.ShowWith.Raid and GetNumRaidMembers() > 0)
|
||||
end
|
||||
self:Toggle(show)
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Omen bar stuff
|
||||
@@ -382,14 +410,13 @@ end
|
||||
|
||||
function Omen:UNIT_PET()
|
||||
self:PARTY_MEMBERS_CHANGED()
|
||||
-- TODO: Add automatic show/hide triggers
|
||||
end
|
||||
|
||||
function Omen:PLAYER_ENTERING_WORLD()
|
||||
if UnitGUID("player") then
|
||||
guidNameLookup[UnitGUID("player")] = UnitName("player")
|
||||
end
|
||||
-- TODO: Add automatic show/hide triggers
|
||||
self:UpdateVisible()
|
||||
end
|
||||
|
||||
local lastPartyUpdateTime = GetTime()
|
||||
@@ -397,6 +424,7 @@ local lastPartyUpdateTime = GetTime()
|
||||
function Omen:PARTY_MEMBERS_CHANGED()
|
||||
inRaid = GetNumRaidMembers() > 0
|
||||
inParty = GetNumPartyMembers() > 0
|
||||
self:UpdateVisible()
|
||||
|
||||
-- Run the update if the last call is more than 0.5 seconds ago else
|
||||
-- schedule an update 0.5 seconds later if one isn't already scheduled
|
||||
@@ -507,7 +535,7 @@ local function updatethreat(unitid, mobunitid)
|
||||
end
|
||||
|
||||
function Omen:UpdateBars()
|
||||
if not self.Anchor:IsShown() then return end
|
||||
if not self.Anchor:IsShown() and not db.CollapseHide then return end
|
||||
|
||||
-- TODO: Put a update throtle on this function
|
||||
|
||||
@@ -574,6 +602,8 @@ function Omen:UpdateBars()
|
||||
updatethreat("focus", mob)
|
||||
updatethreat("focustarget", mob)
|
||||
updatethreat(mobTarget, mob)
|
||||
updatethreat("mouseover", mob)
|
||||
updatethreat("mouseovertarget", mob)
|
||||
|
||||
-- Sort the threatTable
|
||||
local i = 1
|
||||
@@ -605,7 +635,11 @@ function Omen:UpdateBars()
|
||||
if class == nil or db.Classes[class] then -- class == nil implies its not in your raid
|
||||
local bar = bars[j]
|
||||
bar.Text1:SetText(guidNameLookup[guid] or L["Unknown"])
|
||||
bar.Text2:SetText(floor(threatTable[guid] / 100).." ["..floor(threatTable[guid] / tankThreat * 100).."%]")
|
||||
if tankThreat == 0 then
|
||||
bar.Text2:SetFormattedText("%d [100%%]", threatTable[guid] / 100)
|
||||
else
|
||||
bar.Text2:SetFormattedText("%d [%d%%]", threatTable[guid] / 100, threatTable[guid] / tankThreat * 100)
|
||||
end
|
||||
local c = (class == "PET" and pet_color) or RAID_CLASS_COLORS[class] or default_color
|
||||
bar.texture:SetVertexColor(c.r, c.g, c.b)
|
||||
bar.texture:SetWidth(w * threatTable[guid] / topthreat)
|
||||
@@ -625,6 +659,7 @@ function Omen:UpdateBars()
|
||||
if db.Autocollapse then
|
||||
self.Anchor:SetHeight(i*db.BarHeight)
|
||||
end
|
||||
self.Anchor:Show()
|
||||
end
|
||||
|
||||
function Omen:ClearAll()
|
||||
@@ -634,6 +669,9 @@ function Omen:ClearAll()
|
||||
self.TitleText:SetText(self.defaultTitle)
|
||||
if db.Autocollapse then
|
||||
self.Anchor:SetHeight(db.BarHeight)
|
||||
if db.CollapseHide and not self.Anchor.IsMovingOrSizing then
|
||||
self.Anchor:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -652,14 +690,8 @@ end
|
||||
local options = {
|
||||
type = "group",
|
||||
name = "Omen",
|
||||
get = function(info)
|
||||
local key = info[#info]
|
||||
return Omen.db.profile[key]
|
||||
end,
|
||||
set = function(info, value)
|
||||
local key = info[#info]
|
||||
Omen.db.profile[key] = value
|
||||
end,
|
||||
get = function(info) return Omen.db.profile[ info[#info] ] end,
|
||||
set = function(info, value) Omen.db.profile[ info[#info] ] = value end,
|
||||
args = {
|
||||
general = {
|
||||
order = 1,
|
||||
@@ -675,10 +707,10 @@ local options = {
|
||||
Alpha = {
|
||||
order = 3,
|
||||
name = L["Alpha"],
|
||||
desc = L["Controls the transparency of the main Omen window."],
|
||||
type = "range",
|
||||
min = 0, max = 1, step = 0.01,
|
||||
isPercent = true,
|
||||
desc = L["Controls the transparency of the main Omen window."],
|
||||
set = function(info, value)
|
||||
local key = info[#info]
|
||||
Omen.db.profile[key] = value
|
||||
@@ -688,16 +720,152 @@ local options = {
|
||||
Scale = {
|
||||
order = 5,
|
||||
name = L["Scale"],
|
||||
desc = L["Controls the scaling of the main Omen window."],
|
||||
type = "range",
|
||||
min = 0.50, max = 1.50, step = 0.01,
|
||||
isPercent = true,
|
||||
desc = L["Controls the scaling of the main Omen window."],
|
||||
set = function(info, value)
|
||||
local key = info[#info]
|
||||
Omen.db.profile[key] = value
|
||||
Omen.db.profile[ info[#info] ] = value
|
||||
Omen:SetAnchors()
|
||||
end,
|
||||
},
|
||||
Autocollapse = {
|
||||
type = "toggle",
|
||||
name = L["Autocollapse"],
|
||||
desc = L["Collapse to show a minimum number of bars"],
|
||||
order = 7,
|
||||
set = function(info, value)
|
||||
Omen.db.profile[ info[#info] ] = value
|
||||
Omen:UpdateVisible()
|
||||
Omen:UpdateBars()
|
||||
end,
|
||||
},
|
||||
AutocollapseGroup = {
|
||||
type = "group",
|
||||
name = L["Autocollapse Options"],
|
||||
guiInline = true,
|
||||
order = 8,
|
||||
disabled = function() return not Omen.db.profile.Autocollapse end,
|
||||
set = function(info, value)
|
||||
Omen.db.profile[ info[#info] ] = value
|
||||
Omen:UpdateVisible()
|
||||
Omen:UpdateBars()
|
||||
end,
|
||||
args = {
|
||||
GrowUp = {
|
||||
order = 1,
|
||||
type = "toggle",
|
||||
name = L["Grow bars upwards"],
|
||||
desc = L["Grow bars upwards"],
|
||||
},
|
||||
CollapseHide = {
|
||||
order = 2,
|
||||
type = "toggle",
|
||||
name = L["Hide Omen on 0 bars"],
|
||||
desc = L["Hide Omen entirely if it collapses to show 0 bars"],
|
||||
},
|
||||
NumBars = {
|
||||
order = 3,
|
||||
name = L["Max bars to show"],
|
||||
desc = L["Max number of bars to show"],
|
||||
type = "range",
|
||||
min = 1, max = 40, step = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ShowWhen = {
|
||||
type = "group",
|
||||
name = L["Show When..."],
|
||||
desc = L["Show Omen when..."],
|
||||
get = function(info) return Omen.db.profile.ShowWith[ info[#info] ] end,
|
||||
set = function(info, value)
|
||||
Omen.db.profile.ShowWith[ info[#info] ] = value
|
||||
Omen:UpdateVisible()
|
||||
Omen:UpdateBars()
|
||||
end,
|
||||
args = {
|
||||
intro = {
|
||||
order = 1,
|
||||
type = "description",
|
||||
name = L["Show Omen when any of the following are true"],
|
||||
},
|
||||
Pet = {
|
||||
type = "toggle",
|
||||
name = L["You have a pet"],
|
||||
desc = L["Show Omen when you have a pet out"],
|
||||
},
|
||||
Alone = {
|
||||
type = "toggle",
|
||||
name = L["You are alone"],
|
||||
desc = L["Show Omen when you are alone"],
|
||||
},
|
||||
Party = {
|
||||
type = "toggle",
|
||||
name = L["You are in a party"],
|
||||
desc = L["Show Omen when you are in a 5-man party"],
|
||||
},
|
||||
Raid = {
|
||||
type = "toggle",
|
||||
name = L["You are in a raid"],
|
||||
desc = L["Show Omen when you are in a raid"],
|
||||
},
|
||||
Resting = {
|
||||
type = "toggle",
|
||||
name = L["You are resting"],
|
||||
desc = L["Show Omen when you are resting"],
|
||||
},
|
||||
PVP = {
|
||||
type = "toggle",
|
||||
name = L["You are in a battleground"],
|
||||
desc = L["Show Omen when you are in a battleground or arena"],
|
||||
},
|
||||
Dungeon = {
|
||||
type = "toggle",
|
||||
name = L["You are in a dungeon"],
|
||||
desc = L["Show Omen when you are in a dungeon (5 man and raid)"],
|
||||
},
|
||||
},
|
||||
},
|
||||
Help = {
|
||||
type = "group",
|
||||
name = L["Help File"],
|
||||
desc = L["A collection of help pages"],
|
||||
childGroups = "select",
|
||||
args = {
|
||||
FAQ = {
|
||||
type = "group",
|
||||
name = "FAQ",
|
||||
args = {
|
||||
header = {
|
||||
type = "header",
|
||||
name = L["Frequently Asked Questions"],
|
||||
order = 0,
|
||||
},
|
||||
text = {
|
||||
order = 1,
|
||||
type = "description",
|
||||
name = L["GENERAL_FAQ"],
|
||||
},
|
||||
},
|
||||
},
|
||||
WARRIOR = {
|
||||
type = "group",
|
||||
name = "Warrior",
|
||||
args = {
|
||||
header = {
|
||||
type = "header",
|
||||
name = L["Warrior"],
|
||||
order = 0,
|
||||
},
|
||||
text = {
|
||||
order = 1,
|
||||
type = "description",
|
||||
name = L["WARRIOR_FAQ"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -739,10 +907,11 @@ local optionsSlash = {
|
||||
Omen:ShowConfig()
|
||||
end,
|
||||
guiHidden = true,
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
function Omen:SetupOptions()
|
||||
self.optionsFrames = {}
|
||||
|
||||
@@ -753,6 +922,8 @@ function Omen:SetupOptions()
|
||||
|
||||
self:RegisterModuleOptions("Profiles", LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db), L["Profiles"])
|
||||
self:RegisterModuleOptions("OmenSlashCommand", optionsSlash, L["Slash Command"])
|
||||
self.optionsFrames["Help"] = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Help File"], "Omen", "Help")
|
||||
self.optionsFrames["ShowWhen"] = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Show When..."], "Omen", "ShowWhen")
|
||||
end
|
||||
|
||||
function Omen:RegisterModuleOptions(name, optionTbl, displayName)
|
||||
|
||||
Reference in New Issue
Block a user