Skip to content

Commit

Permalink
BugFix: Statuses Class&Spec Load filter did not work (ticket #1017).
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelnpsp committed Jul 18, 2021
1 parent 6e3fb10 commit 656ea52
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 32 deletions.
13 changes: 9 additions & 4 deletions GridStatusLoad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local next = next
-- local variables
local indicators = {} -- indicators marked for update
local registered = {} -- registered messages
local statuses = { playerSpec = {}, groupInstType = {}, instNameID = {} }
local statuses = { playerClassSpec = {}, groupInstType = {}, instNameID = {} }

-- local functions
local function RegisterMessage(message, enabled)
Expand All @@ -22,11 +22,11 @@ local function RegisterMessage(message, enabled)
end

local function UpdateMessages(status, load)
statuses.playerSpec[status] = load and load.playerSpec~=nil or nil
statuses.playerClassSpec[status] = load and load.playerClassSpec~=nil or nil
statuses.instNameID[status] = load and load.instNameID~=nil or nil
statuses.groupInstType[status] = load and (load.groupType~=nil or load.instType~=nil) or nil
RegisterMessage( "Grid_GroupTypeChanged", next(statuses.groupInstType) )
RegisterMessage( "Grid_PlayerSpecChanged", next(statuses.playerSpec) )
RegisterMessage( "Grid_PlayerSpecChanged", next(statuses.playerClassSpec) )
RegisterMessage( "Grid_ZoneChangedNewArea", next(statuses.instNameID) )
end

Expand Down Expand Up @@ -85,12 +85,17 @@ local function RefreshStatus(self)
end

local function RefreshStatuses(filterType)
local notify
for status in pairs(statuses[filterType]) do
if UpdateStatus(status) then
RegisterIndicators(status)
notify = true
end
end
UpdateIndicators()
if notify then
Grid2:SendMessage("Grid_StatusLoadChanged")
end
end

-- message events
Expand All @@ -99,7 +104,7 @@ function Grid2:Grid_GroupTypeChanged()
end

function Grid2:Grid_PlayerSpecChanged()
RefreshStatuses('playerSpec')
RefreshStatuses('playerClassSpec')
end

function Grid2:Grid_ZoneChangedNewArea()
Expand Down
2 changes: 1 addition & 1 deletion Options/GridIndicators.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ do
if len>2 or len==0 then
Grid2Options.LI[name] = len>2 and text or nil
Grid2Options:MakeIndicatorOptions(Grid2.indicators[name])
LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2")
Grid2Options:NotifyChange()
end
end)
end
Expand Down
15 changes: 8 additions & 7 deletions Options/GridStatuses.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,23 +246,24 @@ end
function Grid2Options:MakeStatusOptions(status)
local catGroup, name, desc, icon, coords, deletable, params = self:GetStatusInfo(status)
if catGroup then
local order = params and params.groupOrder
local group = catGroup.args[status.name]
local gorder = params and params.groupOrder
local order = (type(gorder)=='function' and gorder(status) or gorder) or (status.name==status.dbx.type and 100 or 200)
local group = catGroup.args[status.name]
if group then
wipe(group.args)
else
group = { type = "group", args = {} }
catGroup.args[status.name] = group
end
group.name = name
group.desc = desc
group.icon = icon
group.iconCoords = coords
group.childGroups = params and params.childGroups or "tab"
group.order = (type(order)=='function' and order(status) or order) or (status.name==status.dbx.type and 100 or 200)
if status.suspended then
group.order = group.order+500
group.name = string.format('|cFF808080%s|r',group.name)
group.order = function(info)
return status.suspended and order+500 or order
end
group.name = function(info)
return status.suspended and string.format('|cFF808080%s|r',name) or name
end
self:MakeStatusChildOptions(status, group.args)
end
Expand Down
6 changes: 3 additions & 3 deletions Options/GridThemes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ do
db.extraThemes[index] = CopyTheme( itemp==0 and db or db.extraThemes[itemp] )
end
Grid2Options:MakeThemeOptions(index)
LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2")
Grid2Options:NotifyChange()
end)
end,
values = GetThemes,
Expand All @@ -257,7 +257,7 @@ do
local name = editedTheme.db.names[index] or L['Default']
Grid2Options:ShowEditDialog( L["Rename Theme:"], name, function(text)
editedTheme.db.names[index] = text
LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2")
Grid2Options:NotifyChange()
end)
end,
values = GetThemes,
Expand Down Expand Up @@ -356,7 +356,7 @@ function Grid2Options:MakeThemeOptions( index )
options[tostring(index)] = { type = "group", childGroups = "tab", order = index+300, name = GetThemeName, desc = "", arg = index, args = themeOptions }
end

Grid2:RegisterMessage("Grid_ThemeChanged", function() LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2") end)
Grid2:RegisterMessage("Grid_ThemeChanged", Grid2Options.NotifyChange)

--===========================================================================================

Expand Down
7 changes: 6 additions & 1 deletion Options/GridUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ function Grid2Options:PackColor( r,g,b,a, dbx, key )
return { r=r, g=g, b=b, a=a }
end

-- Refresh AceConfig options window
function Grid2Options:NotifyChange() -- do not use self variable inside this function (self can be nil or ~=Grid2Options)
LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2")
end

-- Grid2Options:EnableLoadOnDemand()
-- Delays the creation of indicators and statuses options, until the user clicks on each option,
-- reducing initial memory usage and load time. Instead of the real options, a "description" type option
Expand All @@ -153,7 +158,7 @@ do
else
methods[typ..'_']( Grid2Options, Grid2[typ][key] )
end
LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2")
Grid2Options:NotifyChange()
end
}
local function hook(self, options, extraOptions)
Expand Down
2 changes: 1 addition & 1 deletion Options/modules/general/GridExportImport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ local function ImportProfile(sender, data, Hex, importCustomLayouts)
end
end
self:ProfileChanged()
LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2")
Grid2Options:NotifyChange()
end
Grid2.db:SetProfile(profileName)
if importCustomLayouts then
Expand Down
15 changes: 2 additions & 13 deletions Options/modules/statuses/Status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,11 @@ do
end
end

local function RefreshStatusOptions(status)
local name = Grid2Options.LocalizeStatus(status, true)
local group = Grid2Options:GetStatusGroup(status)
if status.suspended then
group.order = group.order - 500
group.name = string.format('|cFF808080%s|r',name)
else
group.order = group.order + 500
group.name = name
end
end

local function RefreshStatus(status, isUnitFilter)
if isUnitFilter then
status:Refresh(true)
elseif status:RefreshLoad() then
RefreshStatusOptions(status)
Grid2Options:NotifyChange()
end
end

Expand Down Expand Up @@ -279,6 +267,7 @@ do
end
return options
end
Grid2:RegisterMessage("Grid_StatusLoadChanged", Grid2Options.NotifyChange)
end

-- Grid2Options:MakeStatusDeleteOptions()
Expand Down
2 changes: 1 addition & 1 deletion Options/modules/statuses/StatusAura.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function Grid2Options:MakeStatusAuraUseSpellIdOptions(status, options, optionPar
status.dbx.useSpellId = (type(text)=="number") or nil
status:UpdateDB()
Grid2Options:MakeStatusOptions(status)
LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2")
Grid2Options:NotifyChange()
end
end,
}
Expand Down
2 changes: 1 addition & 1 deletion Options/modules/themes/GridGeneral.lua
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,4 @@ Grid2Options:AddThemeOptions( "appearance", "Appearance", options )
-- Refresh theme general options the first time they are displayed, it's a workaround to a weird bug in AceConfig/AceGUI:
-- sometimes all editboxes of sliders do not display any value, this only happens when we have 3 nested groups like in:
-- "Themes>Default>General Tab>options width sliders", and clicking very fast to open general theme options.
options.bugfix = { type = "header", order = 500, name = "", hidden = function() options.bugfix = nil; LibStub("AceConfigRegistry-3.0"):NotifyChange("Grid2"); return true end }
options.bugfix = { type = "header", order = 500, name = "", hidden = function() options.bugfix = nil; Grid2Options:NotifyChange(); return true end }

0 comments on commit 656ea52

Please sign in to comment.