Skip to content

Commit 078b490

Browse files
committed
Update UI.lua
* Updated so if you finish everything in that modular it hides it self
1 parent da1229a commit 078b490

1 file changed

Lines changed: 38 additions & 18 deletions

File tree

UI.lua

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -708,14 +708,12 @@ function MR:RefreshUI()
708708
for _, mod in ipairs(MR:GetOrderedModules()) do
709709
local modVisible = not mod.isVisible or mod:isVisible()
710710
if MR:IsModuleEnabled(mod.key) and modVisible and not MR:IsModuleDetached(mod.key) then
711-
local h = self:MeasureSection(mod)
712-
table.insert(visibleMods, { mod = mod, h = h })
713-
for _, row in ipairs(mod.rows) do
714-
local rowVisible = not row.isVisible or row.isVisible()
715-
if rowVisible and MR:IsRowEnabled(mod.key, row.key) then
716-
allTotal = allTotal + 1
717-
if row.max and MR:GetProgress(mod.key, row.key) >= row.max then allDone = allDone + 1 end
718-
end
711+
local totalRows, doneRows, shownRows = self:GetModuleRowStats(mod)
712+
if shownRows > 0 then
713+
local h = self:MeasureSection(mod)
714+
table.insert(visibleMods, { mod = mod, h = h })
715+
allTotal = allTotal + shownRows
716+
allDone = allDone + math.min(doneRows, shownRows)
719717
end
720718
end
721719
end
@@ -791,7 +789,8 @@ function MR:RefreshUI()
791789
local modVisible = not mod.isVisible or mod:isVisible()
792790
local detached = MR:IsModuleDetached(mod.key)
793791
local frame = self.detachedFrames[mod.key]
794-
if detached and MR:IsModuleEnabled(mod.key) and modVisible then
792+
local _, _, shownRows = self:GetModuleRowStats(mod)
793+
if detached and MR:IsModuleEnabled(mod.key) and modVisible and shownRows > 0 then
795794
frame = self:EnsureDetachedFrame(mod)
796795
seenDetached[mod.key] = true
797796
local savedSize = self:GetDetachedModuleSize(mod.key)
@@ -846,15 +845,18 @@ end
846845

847846
function MR:MeasureSection(mod)
848847
local isOpen = MR:IsModuleOpen(mod.key)
849-
local hideComplete = MR:IsModuleHideComplete(mod.key)
848+
local _, _, shownRows = self:GetModuleRowStats(mod)
849+
if shownRows == 0 then
850+
return 0
851+
end
850852
local h = HEADER_HEIGHT + 1
851853
if isOpen then
852854
for _, row in ipairs(mod.rows) do
853855
local rowVisible = not row.isVisible or row.isVisible()
854856
if rowVisible and MR:IsRowEnabled(mod.key, row.key) then
855857
local done = MR:GetProgress(mod.key, row.key)
856858
local isComplete = not row.noMax and done >= row.max
857-
if not (hideComplete and isComplete) then
859+
if not (MR:IsModuleHideComplete(mod.key) and isComplete) then
858860
h = h + ROW_HEIGHT
859861
end
860862
end
@@ -863,19 +865,37 @@ function MR:MeasureSection(mod)
863865
return h
864866
end
865867

868+
function MR:GetModuleRowStats(mod)
869+
local hideComplete = MR:IsModuleHideComplete(mod.key)
870+
local totalRows, doneRows, shownRows = 0, 0, 0
871+
872+
for _, row in ipairs(mod.rows) do
873+
local rowVisible = not row.isVisible or row.isVisible()
874+
if rowVisible and MR:IsRowEnabled(mod.key, row.key) then
875+
totalRows = totalRows + 1
876+
877+
local isComplete = row.max and not row.noMax and MR:GetProgress(mod.key, row.key) >= row.max
878+
if isComplete then
879+
doneRows = doneRows + 1
880+
end
881+
if not (hideComplete and isComplete) then
882+
shownRows = shownRows + 1
883+
end
884+
end
885+
end
886+
887+
return totalRows, doneRows, shownRows
888+
end
889+
866890
function MR:BuildSection(mod, yOff, xOff, colW, col, parent, widgetBucket, opts)
867891
parent = parent or self.content
868892
widgetBucket = widgetBucket or self.widgets
869893
opts = opts or {}
870894
local isOpen = MR:IsModuleOpen(mod.key)
871895

872-
local secDone, secTotal = 0, 0
873-
for _, row in ipairs(mod.rows) do
874-
local rowVisible = not row.isVisible or row.isVisible()
875-
if rowVisible and MR:IsRowEnabled(mod.key, row.key) then
876-
secTotal = secTotal + 1
877-
if row.max and MR:GetProgress(mod.key, row.key) >= row.max then secDone = secDone + 1 end
878-
end
896+
local secTotal, secDone, shownRows = self:GetModuleRowStats(mod)
897+
if shownRows == 0 then
898+
return yOff
879899
end
880900
local allDone = (secTotal > 0) and (secDone == secTotal)
881901

0 commit comments

Comments
 (0)