Skip to content

Commit

Permalink
implement hide at max level
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuller committed Sep 22, 2024
1 parent 70111a2 commit cecf357
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Dominos_Progress/localization/localization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,29 @@

local L = LibStub('AceLocale-3.0'):NewLocale('Dominos-Progress', 'enUS', true)

L.AlwaysShowText = 'Always Show Text'
L.AutoSwitchModes = 'Auto Switch Modes'
L.Azerite = 'Azerite Power'
L.CompressValues = 'Compress Values'
L.Font = 'Font'
L.GoldGoal = "Gold Goal Amount"
L.Height = 'Height'
L.HideAtMaxLevel = 'Hide at Max Level'
L.OneBarMode = 'One Bar Mode'
L.Paragon = 'Paragon'
L.Progress = 'Progress'
L.SegmentCount = 'Segement Count'
L.Segmented = 'Segmented'
L.SkipInactiveModes = "Skip Inactive Modes"
L.Texture = 'Texture'
L.Width = 'Width'
L.Height = 'Height'
L.AlwaysShowText = 'Always Show Text'
L.Segmented = 'Segmented'
L.SegmentCount = 'Segement Count'
L.Font = 'Font'
L.AutoSwitchModes = 'Auto Switch Modes'

L.Display_label = 'Show Labels'
L.Display_value = 'Show Current Value'
L.Display_max = 'Show Maximum Value'
L.Display_bonus = 'Show Rest/Bonus'
L.Display_percent = 'Show Percentage'
L.Display_remaining = 'Show Remaining'
L.CompressValues = 'Compress Values'

L.Color_xp = 'XP Bar Color'
L.Color_xp_bonus = 'Bonus XP Color'
Expand All @@ -32,7 +38,3 @@ L.Color_azerite = 'Azerite Color'
L.Color_gold = 'Gold Color'
L.Color_gold_realm = 'Gold Realm Color'

L.Paragon = 'Paragon'
L.Azerite = 'Azerite Power'
L.SkipInactiveModes = "Skip Inactive Modes"
L.GoldGoal = "Gold Goal Amount"
15 changes: 15 additions & 0 deletions Dominos_Progress/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function ProgressBarModule:OnFirstLoad()

-- xp bar events
self:RegisterEvent("PLAYER_XP_UPDATE")
self:RegisterEvent("PLAYER_LEVEL_UP")

-- reputation events
self:RegisterEvent("UPDATE_FACTION")
Expand Down Expand Up @@ -92,6 +93,7 @@ end

function ProgressBarModule:PLAYER_ENTERING_WORLD()
self:UpdateAllBars()
self:ForAllBars("UpdateDisplayConditions")
end

function ProgressBarModule:PLAYER_UPDATE_RESTING()
Expand All @@ -102,6 +104,10 @@ function ProgressBarModule:UPDATE_EXHAUSTION()
self:UpdateAllBars()
end

function ProgressBarModule:PLAYER_LEVEL_UP()
self:ForAllBars("UpdateDisplayConditions")
end

function ProgressBarModule:PLAYER_XP_UPDATE()
self:UpdateAllBars()
end
Expand Down Expand Up @@ -152,6 +158,15 @@ function ProgressBarModule:UpdateAllBars()
end
end

function ProgressBarModule:ForAllBars(method, ...)
local bars = self.bars
if bars then
for _, bar in pairs(bars) do
bar[method](bar, ...)
end
end
end

function ProgressBarModule:AddOptionsPanel()
local colors = { }
for i, key in pairs{ "xp", "xp_bonus", "honor", "artifact", "azerite", "gold", "gold_realm" } do
Expand Down
30 changes: 30 additions & 0 deletions Dominos_Progress/progressBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,24 @@ function ProgressBar:UpdateLockMode()
self:UpdateMode()
end

function ProgressBar:SetHideAtMaxLevel(hide)
if self:HideAtMaxLevel() ~= hide then
self.sets.hideAtMaxLevel = hide
self:UpdateDisplayConditions()
end
end

function ProgressBar:HideAtMaxLevel()
return self.sets.hideAtMaxLevel or false
end

function ProgressBar:GetDisplayConditions()
if self.sets.hideAtMaxLevel then
if UnitLevel("player") == (GetMaxLevelForPlayerExpansion or GetMaxPlayerLevel)() then
return "hide"
end
end
end

--[[ value display ]]--

Expand Down Expand Up @@ -771,6 +789,18 @@ do
local l = LibStub('AceLocale-3.0'):GetLocale('Dominos-Progress')
local panel = menu:NewPanel(_G.DISPLAY)

panel:NewCheckButton{
name = l.HideAtMaxLevel,

get = function()
return panel.owner:HideAtMaxLevel()
end,

set = function(_, enable)
panel.owner:SetHideAtMaxLevel(enable)
end
}

if #self.modes > 1 then
panel:NewCheckButton{
name = l.AutoSwitchModes,
Expand Down

0 comments on commit cecf357

Please sign in to comment.