diff --git a/Bindings.xml b/Bindings.xml index 1ebba84..b7a989c 100644 --- a/Bindings.xml +++ b/Bindings.xml @@ -1,5 +1,5 @@ - + Omen:Toggle() \ No newline at end of file diff --git a/Localization/enUS.lua b/Localization/enUS.lua index 0ff4e43..062b02c 100644 --- a/Localization/enUS.lua +++ b/Localization/enUS.lua @@ -3,7 +3,7 @@ local L = AceLocale:NewLocale("Omen", "enUS", true) if not L then return end -- Main Omen window -L["Unknown"] = true +L[""] = true -- Config module titles L["General Settings"] = true @@ -59,6 +59,31 @@ L["Bar Height"] = true L["Height of each bar"] = true L["Bar Spacing"] = true L["Spacing between each bar"] = true +L["Bar Label Options"] = true +L["Font"] = true +L["The font that the labels will use"] = true +L["Font Size"] = true +L["Control the font size of the labels"] = true +L["Font Color"] = true +L["The color of the labels"] = true +L["Font Outline"] = true +L["The outline that the labels will use"] = true +L["None"] = true +L["Outline"] = true +L["Thick Outline"] = true + +L["Classes"] = true +L["DEATHKNIGHT"] = "Death Knight" +L["DRUID"] = "Druid" +L["HUNTER"] = "Hunter" +L["MAGE"] = "Mage" +L["PALADIN"] = "Paladin" +L["PET"] = "Pet" +L["PRIEST"] = "Priest" +L["ROGUE"] = "Rogue" +L["SHAMAN"] = "Shaman" +L["WARLOCK"] = "Warlock" +L["WARRIOR"] = "Warrior" -- Config strings, slash command section L["OMEN_SLASH_DESC"] = "These buttons execute the same functions as the ones in the slash command /omen" diff --git a/Omen.lua b/Omen.lua index ac3d7f8..c40d9e6 100644 --- a/Omen.lua +++ b/Omen.lua @@ -70,6 +70,10 @@ local defaults = { Spacing = 0, AnimateBars = true, ShortNumbers = true, + Font = "Friz Quadrata TT", + FontOutline = "", + FontColor = {r = 1, g = 1, b = 1, a = 1,}, + FontSize = 10, }, ShowWith = { Pet = true, @@ -308,11 +312,12 @@ function Omen:Disable() self:Toggle(false) end -function Omen:OnProfileChanged(db, name) - db = self.db.profile +function Omen:OnProfileChanged(event, database, newProfileKey) + db = database.profile self:SetAnchors(true) self:ResizeBars() self:ReAnchorBars() + self:UpdateBarLabelSettings() self:UpdateVisible() self:UpdateBars() end @@ -388,8 +393,9 @@ end -- Omen bar stuff do - local function animate(self, v) - self.animationCursor = self.animationCursor + v + -- OnUpdate function for bar animation + local function animate(self, elapsed) + self.animationCursor = self.animationCursor + elapsed if self.animationCursor > self.animationTime then self.texture:SetWidth(self.animations[1]) tremove(self.animations, 1) @@ -404,6 +410,7 @@ do end end + -- function to start/queue bar animations local function AnimateTo(self, val) if val == 1/0 or val == -1/0 then return end if val == 0 then val = 1 end @@ -415,33 +422,33 @@ do tinsert(self.animations, val) tinsert(self.animations, currentWidth) tinsert(self.animations, diff) - - if #self.animations > 0 then - self:SetScript("OnUpdate", self.animate) - end + self:SetScript("OnUpdate", animate) end + -- Create bars on demand setmetatable(bars, {__index = function(self, barID) local bar = CreateFrame("Frame", nil, Omen.BarList) self[barID] = bar - + bar:SetWidth(Omen.BarList:GetWidth()) bar:SetHeight(db.Bar.Height) bar:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", 0, (barID-1) * -(db.Bar.Height + db.Bar.Spacing)) + local color = db.Bar.FontColor + bar.Text1 = bar:CreateFontString(nil, nil, "GameFontNormalSmall") - bar.Text1:SetPoint("LEFT", bar, "LEFT", 10, 0) + bar.Text1:SetPoint("LEFT", bar, "LEFT", 5, 0) bar.Text1:SetJustifyH("LEFT") - bar.Text1:SetTextColor(1, 1, 1, 1) - bar.Text1:SetText("abc") + 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.Text2 = bar:CreateFontString(nil, nil, "GameFontNormalSmall") - bar.Text2:SetPoint("RIGHT", bar, "RIGHT", -10, 0) + bar.Text2:SetPoint("RIGHT", bar, "RIGHT", -5, 0) bar.Text2:SetJustifyH("RIGHT") - bar.Text2:SetTextColor(1, 1, 1, 1) - bar.Text2:SetText("def") + 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.texture = bar:CreateTexture() - --bar.texture:SetTexture(1, 1, 1, 0.6) bar.texture:SetTexture(LSM:Fetch("statusbar", db.Bar.Texture)) bar.texture:SetPoint("TOPLEFT", bar, "TOPLEFT") bar.texture:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT") @@ -449,13 +456,38 @@ do bar.animations = {} bar.animationCursor = 0 bar.animationTime = 0.25 - bar.animate = animate bar.AnimateTo = AnimateTo return bar end}) end +function Omen:ResizeBars() + local w = Omen.BarList:GetWidth() + for i = 1, #bars do + bars[i]:SetWidth(w) + bars[i]:SetHeight(db.Bar.Height) + end +end + +function Omen:ReAnchorBars() + for i = 1, #bars do + bars[i]:SetPoint("TOPLEFT", self.BarList, "TOPLEFT", 0, (i-1) * -(db.Bar.Height + db.Bar.Spacing)) + end +end + +function Omen:UpdateBarLabelSettings() + local font = LSM:Fetch("font", db.Bar.Font) + local size = db.Bar.FontSize + local flags = db.Bar.FontOutline + local color = db.Bar.FontColor + for i = 1, #bars do + bars[i].Text1:SetFont(font, size, flags) + 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) + end +end ----------------------------------------------------------------------------- -- Omen event functions @@ -625,6 +657,7 @@ function Omen:UpdateBars() -- It has to be attackable and not human controlled, otherwise return local mob = "target" if UnitIsPlayer(mob) or UnitPlayerControlled(mob) or not UnitCanAttack("player", mob) then + guidNameLookup[UnitGUID(mob)] = UnitName(mob) mob = "targettarget" end if not UnitExists(mob) or UnitIsPlayer(mob) or UnitPlayerControlled(mob) or not UnitCanAttack("player", mob) then @@ -723,7 +756,7 @@ function Omen:UpdateBars() end local bar = bars[j] local threat = threatTable[guid] - bar.Text1:SetText(guidNameLookup[guid] or L["Unknown"]) + bar.Text1:SetText(guidNameLookup[guid] or L[""]) if db.Bar.ShortNumbers and threat > 100000 then bar.Text2:SetFormattedText("%2.1fk [%d%%]", threat / 100000, tankThreat == 0 and 0 or threat / tankThreat * 100) else @@ -763,24 +796,16 @@ function Omen:ClearAll() end end -function Omen:ResizeBars() - local w = Omen.BarList:GetWidth() - for i = 1, #bars do - bars[i]:SetWidth(w) - bars[i]:SetHeight(db.Bar.Height) - end -end - -function Omen:ReAnchorBars() - for i = 1, #bars do - bars[i]:SetPoint("TOPLEFT", self.BarList, "TOPLEFT", 0, (i-1) * -(db.Bar.Height + db.Bar.Spacing)) - end -end - ----------------------------------------------------------------------------- -- Omen config stuff +local outlines = { + [""] = L["None"], + ["OUTLINE"] = L["Outline"], + ["THICKOUTLINE"] = L["Thick Outline"], +} + local function GetLSMIndex(t, value) for k, v in pairs(LSM:List(t)) do if v == value then @@ -793,8 +818,8 @@ end local options = { type = "group", name = "Omen", - get = function(info) return Omen.db.profile[ info[#info] ] end, - set = function(info, value) Omen.db.profile[ info[#info] ] = value end, + get = function(info) return db[ info[#info] ] end, + set = function(info, value) db[ info[#info] ] = value end, args = { general = { order = 1, @@ -861,9 +886,9 @@ local options = { name = L["Autocollapse Options"], guiInline = true, order = 11, - disabled = function() return not Omen.db.profile.Autocollapse end, + disabled = function() return not db.Autocollapse end, set = function(info, value) - Omen.db.profile[ info[#info] ] = value + db[ info[#info] ] = value Omen:UpdateVisible() Omen:UpdateBars() end, @@ -899,9 +924,9 @@ local options = { type = "group", name = L["Show When..."], desc = L["Show Omen when..."], - get = function(info) return Omen.db.profile.ShowWith[ info[#info] ] end, + get = function(info) return db.ShowWith[ info[#info] ] end, set = function(info, value) - Omen.db.profile.ShowWith[ info[#info] ] = value + db.ShowWith[ info[#info] ] = value Omen:UpdateVisible() Omen:UpdateBars() end, @@ -952,9 +977,9 @@ local options = { type = "group", name = L["Bar Settings"], desc = L["Bar Settings"], - get = function(info) return Omen.db.profile.Bar[ info[#info] ] end, + get = function(info) return db.Bar[ info[#info] ] end, set = function(info, value) - Omen.db.profile.Bar[ info[#info] ] = value + db.Bar[ info[#info] ] = value Omen:UpdateBars() end, args = { @@ -965,30 +990,19 @@ local options = { }, AnimateBars = { type = "toggle", + order = 2, name = L["Animate Bars"], desc = L["Smoothly animate bar changes"], }, ShortNumbers = { type = "toggle", + order = 3, name = L["Short Numbers"], desc = L["Display large numbers in Ks"], }, - Texture = { - type = "select", - name = L["Bar Texture"], - desc = L["The texture that the bar will use"], - values = function() return LSM:List("statusbar") end, - get = function(info) return GetLSMIndex("statusbar", db.Bar.Texture) end, - set = function(info, v) - db.Bar.Texture = LSM:List("statusbar")[v] - local texturepath = LSM:Fetch("statusbar", db.Bar.Texture) - for i = 1, #bars do - bars[i].texture:SetTexture(texturepath) - end - end - }, Height = { type = "range", + order = 4, name = L["Bar Height"], desc = L["Height of each bar"], min = 5, max = 50, step = 1, bigStep = 1, @@ -1001,6 +1015,7 @@ local options = { }, Spacing = { type = "range", + order = 5, name = L["Bar Spacing"], desc = L["Spacing between each bar"], min = 0, max = 20, step = 1, bigStep = 1, @@ -1010,6 +1025,75 @@ local options = { Omen:UpdateBars() end, }, + Texture = { + type = "select", + order = 10, + name = L["Bar Texture"], + desc = L["The texture that the bar will use"], + values = function() return LSM:List("statusbar") end, + get = function(info) return GetLSMIndex("statusbar", db.Bar.Texture) end, + set = function(info, v) + db.Bar.Texture = LSM:List("statusbar")[v] + local texturepath = LSM:Fetch("statusbar", db.Bar.Texture) + for i = 1, #bars do + bars[i].texture:SetTexture(texturepath) + end + end, + }, + BarLabelsGroup = { + type = "group", + name = L["Bar Label Options"], + guiInline = true, + order = 20, + set = function(info, v) + db.Bar[ info[#info] ] = v + Omen:UpdateBarLabelSettings() + end, + args = { + Font = { + type = "select", + order = 1, + name = L["Font"], + desc = L["The font that the labels will use"], + values = function() return LSM:List("font") end, + get = function(info) return GetLSMIndex("font", db.Bar.Font) end, + set = function(info, v) + db.Bar.Font = LSM:List("font")[v] + Omen:UpdateBarLabelSettings() + end, + }, + FontOutline = { + type = "select", + order = 2, + name = L["Font Outline"], + desc = L["The outline that the labels will use"], + values = outlines, + }, + FontColor = { + type = "color", + order = 3, + name = L["Font Color"], + desc = L["The color of the labels"], + hasAlpha = true, + get = function(info) + local t = db.Bar.FontColor + return t.r, t.g, t.b, t.a + end, + set = function(info, r, g, b, a) + local t = db.Bar.FontColor + t.r, t.g, t.b, t.a = r, g, b, a + Omen:UpdateBarLabelSettings() + end, + }, + FontSize = { + type = "range", + order = 4, + name = L["Font Size"], + desc = L["Control the font size of the labels"], + min = 4, max = 30, step = 1, + }, + }, + }, }, }, Help = {