diff --git a/Localization/enUS.lua b/Localization/enUS.lua index c8f8378..0ff4e43 100644 --- a/Localization/enUS.lua +++ b/Localization/enUS.lua @@ -18,6 +18,8 @@ L["Scale"] = true L["Controls the scaling of the main Omen window."] = true L["Autocollapse"] = true L["Collapse to show a minimum number of bars"] = true +L["Lock Omen"] = true +L["Locks Omen in place and prevents it from being dragged or resized."] = true L["Autocollapse Options"] = true L["Grow bars upwards"] = true L["Hide Omen on 0 bars"] = true @@ -53,7 +55,11 @@ L["Short Numbers"] = true L["Display large numbers in Ks"] = true L["Bar Texture"] = true L["The texture that the bar will use"] = true - +L["Bar Height"] = true +L["Height of each bar"] = true +L["Bar Spacing"] = true +L["Spacing between each bar"] = true + -- Config strings, slash command section L["OMEN_SLASH_DESC"] = "These buttons execute the same functions as the ones in the slash command /omen" L["Toggle Omen"] = true diff --git a/Omen.lua b/Omen.lua index 3b52add..ac3d7f8 100644 --- a/Omen.lua +++ b/Omen.lua @@ -38,6 +38,7 @@ LSM:Register("sound", "Humm", [[Sound\Spells\SimonGame_Visual_GameStart.wav]]) LSM:Register("sound", "Short Circuit", [[Sound\Spells\SimonGame_Visual_BadPress.wav]]) LSM:Register("sound", "Fel Portal", [[Sound\Spells\Sunwell_Fel_PortalStand.wav]]) LSM:Register("sound", "Fel Nova", [[Sound\Spells\SeepingGaseous_Fel_Nova.wav]]) +LSM:Register("sound", "You Will Die!", [[Sound\Creature\CThun\CThunYouWillDIe.wav]]) ----------------------------------------------------------------------------- @@ -147,7 +148,7 @@ end local function startmoving() if not db.Locked then - Omen.Anchor.IsMovingOrSizing = true + Omen.Anchor.IsMovingOrSizing = 1 Omen.Anchor:StartMoving() end end @@ -168,7 +169,7 @@ function Omen:CreateFrames() -- Create anchor self.Anchor = CreateFrame("Frame", "OmenAnchor", UIParent) self.Anchor:SetResizable(true) - self.Anchor:SetMinResize(90, db.Bar.Height) + self.Anchor:SetMinResize(90, 16) self.Anchor:SetMovable(true) self.Anchor:SetPoint("CENTER", UIParent, "CENTER") self.Anchor:SetWidth(225) @@ -222,7 +223,7 @@ function Omen:CreateFrames() end self.Grip:SetScript("OnMouseDown", function() if not db.Locked then - self.Anchor.IsMovingOrSizing = true + self.Anchor.IsMovingOrSizing = 2 self.Anchor:SetScript("OnSizeChanged", sizing) self.Anchor:StartSizing() end @@ -310,6 +311,8 @@ end function Omen:OnProfileChanged(db, name) db = self.db.profile self:SetAnchors(true) + self:ResizeBars() + self:ReAnchorBars() self:UpdateVisible() self:UpdateBars() end @@ -424,7 +427,7 @@ do bar:SetWidth(Omen.BarList:GetWidth()) bar:SetHeight(db.Bar.Height) - bar:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", 0, (barID-1) * -db.Bar.Height) + bar:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", 0, (barID-1) * -(db.Bar.Height + db.Bar.Spacing)) bar.Text1 = bar:CreateFontString(nil, nil, "GameFontNormalSmall") bar.Text1:SetPoint("LEFT", bar, "LEFT", 10, 0) @@ -713,6 +716,11 @@ function Omen:UpdateBars() local guid = sortTable[j] local class = guidClassLookup[guid] if class == nil or db.Classes[class] then -- class == nil implies its not in your raid + if db.Autocollapse then + if i > db.NumBars then break end + else + if i*db.Bar.Height + (i-1)*db.Bar.Spacing > h then break end + end local bar = bars[j] local threat = threatTable[guid] bar.Text1:SetText(guidNameLookup[guid] or L["Unknown"]) @@ -723,18 +731,13 @@ function Omen:UpdateBars() 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) - if db.Bar.AnimateBars then + if db.Bar.AnimateBars and self.Anchor.IsMovingOrSizing ~= 2 then bar:AnimateTo(w * threat / topthreat) else bar.texture:SetWidth(w * threat / topthreat) end bar:Show() i = i + 1 - if db.Autocollapse then - if i > db.NumBars then break end - else - if floor(h / bar:GetHeight()) < i then break end - end end end -- And hide the rest @@ -742,7 +745,7 @@ function Omen:UpdateBars() bars[j]:Hide() end if db.Autocollapse then - self.Anchor:SetHeight(i*db.Bar.Height) + self.Anchor:SetHeight((i-1)*db.Bar.Height + (i-2)*db.Bar.Spacing + 16) end self.Anchor:Show() end @@ -753,7 +756,7 @@ function Omen:ClearAll() end self.TitleText:SetText(self.defaultTitle) if db.Autocollapse then - self.Anchor:SetHeight(db.Bar.Height) + self.Anchor:SetHeight(16) if db.CollapseHide and not self.Anchor.IsMovingOrSizing then self.Anchor:Hide() end @@ -768,6 +771,12 @@ function Omen:ResizeBars() 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 @@ -796,7 +805,6 @@ local options = { order = 1, type = "description", name = L["OMEN_DESC"], - cmdHidden = true, }, Alpha = { order = 3, @@ -806,8 +814,7 @@ local options = { min = 0, max = 1, step = 0.01, isPercent = true, set = function(info, value) - local key = info[#info] - Omen.db.profile[key] = value + db.Alpha = value Omen.Anchor:SetAlpha(value) end, }, @@ -819,17 +826,32 @@ local options = { min = 0.50, max = 1.50, step = 0.01, isPercent = true, set = function(info, value) - Omen.db.profile[ info[#info] ] = value + db.Scale = value Omen:SetAnchors() end, }, + Locked = { + type = "toggle", + name = L["Lock Omen"], + desc = L["Locks Omen in place and prevents it from being dragged or resized."], + order = 7, + set = function(info, value) + db.Locked = value + if value then Omen.Grip:Hide() else Omen.Grip:Show() end + end, + }, + linebreak = { + order = 9, + type = "description", + name = "", + }, Autocollapse = { type = "toggle", name = L["Autocollapse"], desc = L["Collapse to show a minimum number of bars"], - order = 7, + order = 10, set = function(info, value) - Omen.db.profile[ info[#info] ] = value + db.Autocollapse = value Omen:UpdateVisible() Omen:UpdateBars() end, @@ -838,7 +860,7 @@ local options = { type = "group", name = L["Autocollapse Options"], guiInline = true, - order = 8, + order = 11, disabled = function() return not Omen.db.profile.Autocollapse end, set = function(info, value) Omen.db.profile[ info[#info] ] = value @@ -851,6 +873,10 @@ local options = { type = "toggle", name = L["Grow bars upwards"], desc = L["Grow bars upwards"], + set = function(info, value) + db.GrowUp = value + Omen:SetAnchors() + end, }, CollapseHide = { order = 2, @@ -961,6 +987,29 @@ local options = { end end }, + Height = { + type = "range", + name = L["Bar Height"], + desc = L["Height of each bar"], + min = 5, max = 50, step = 1, bigStep = 1, + set = function(info, value) + db.Bar.Height = value + Omen:ReAnchorBars() + Omen:ResizeBars() + Omen:UpdateBars() + end, + }, + Spacing = { + type = "range", + name = L["Bar Spacing"], + desc = L["Spacing between each bar"], + min = 0, max = 20, step = 1, bigStep = 1, + set = function(info, value) + db.Bar.Spacing = value + Omen:ReAnchorBars() + Omen:UpdateBars() + end, + }, }, }, Help = {