Skip to content

Commit cfb63d7

Browse files
committed
Added a right-click menu option to permanently hide all loadouts from a specific character (closes #30)
1 parent faead82 commit cfb63d7

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

core/Config.lua

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function Config:Initialize()
3333
sideBarInactiveElementTextColor = { r = 1, g = 1, b = 1, a = 1 },
3434
sideBarInactiveElementBackgroundColor = { r = 0, g = 0, b = 0, a = 0.5 },
3535
sideBarInactiveElementHighlightBackgroundColor = { r = 0.5, g = 0.5, b = 0.5, a = 0.5 },
36+
characterVisibility = {},
3637
};
3738
for key, value in pairs(self.defaultConfig) do
3839
if TLM.db.config[key] == nil then
@@ -116,6 +117,14 @@ You can create a leveling build yourself, either using the IcyVeins talent calcu
116117
descStyle = "inline",
117118
width = "full",
118119
},
120+
resetCharacterVisibility = {
121+
order = orderCount(),
122+
type = "execute",
123+
name = "Reset Hidden Characters",
124+
desc = "Resets characters whose loadouts were hidden in the sidebar.",
125+
func = function() self:ClearCharacterVisibility(); end,
126+
width = "double",
127+
},
119128
sideBarColors = {
120129
order = orderCount(),
121130
type = "description",
@@ -200,10 +209,13 @@ You can create a leveling build yourself, either using the IcyVeins talent calcu
200209
},
201210
};
202211

203-
return options
212+
return options;
204213
end
205214

206-
Config.Event = { OptionValueChanged = 'OptionValueChanged' };
215+
Config.Event = {
216+
OptionValueChanged = 'OptionValueChanged',
217+
CharacterVisibilityChanged = 'CharacterVisibilityChanged',
218+
};
207219

208220
function Config:RegisterOptions()
209221
LibStub("AceConfig-3.0"):RegisterOptionsTable(addonName, self:GetOptions());
@@ -229,6 +241,20 @@ function Config:IsOptionDisabled(option)
229241
return false;
230242
end
231243

244+
function Config:ClearCharacterVisibility()
245+
TLM.db.config.characterVisibility = {};
246+
self:TriggerEvent(self.Event.CharacterVisibilityChanged);
247+
end
248+
249+
function Config:SetCharacterShown(characterName, isShown)
250+
TLM.db.config.characterVisibility[characterName] = isShown;
251+
self:TriggerEvent(self.Event.CharacterVisibilityChanged);
252+
end
253+
254+
function Config:IsCharacterShown(characterName)
255+
return TLM.db.config.characterVisibility[characterName] ~= false;
256+
end
257+
232258
--- @param option TLM_ConfigOptions
233259
function Config:GetConfig(option, default)
234260
local value = not self:IsOptionDisabled(option) and TLM.db.config[option];

modules/SideBarMixin.lua

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ function SideBarMixin:OnDisable()
199199
self:UnhookAll();
200200

201201
API:UnregisterCallback(API.Event.LoadoutListUpdated, self);
202+
Config:UnregisterCallback(Config.Event.CharacterVisibilityChanged, self);
202203
end
203204

204205
function SideBarMixin:SetupHook()
@@ -216,6 +217,7 @@ function SideBarMixin:SetupHook()
216217
self:SecureHook(talentsTab, "OnUpdate", "OnTalentsChanged");
217218

218219
API:RegisterCallback(API.Event.LoadoutListUpdated, self.RefreshSideBarData, self);
220+
Config:RegisterCallback(Config.Event.CharacterVisibilityChanged, self.RefreshSideBarData, self);
219221
end
220222

221223
do
@@ -850,6 +852,10 @@ function SideBarMixin:GenerateMenu(rootDescription, frame, loadoutInfo)
850852
rootDescription:CreateButton("Remove all loadouts from this character from the list", function()
851853
StaticPopup_Show(self.removeFromListBulkDialogName, loadoutInfo.owner, nil, loadoutInfo);
852854
end);
855+
rootDescription:CreateButton("Permanently hide all loadouts from this character", function()
856+
Config:SetCharacterShown(loadoutInfo.owner, false);
857+
TLM:Printf("Loadouts from %s are now hidden. You can reset this in the config.", loadoutInfo.owner);
858+
end);
853859
end
854860
end
855861

@@ -1055,21 +1061,23 @@ function SideBarMixin:RefreshSideBarData()
10551061
local activeLoadoutID = self.activeLoadout and self.activeLoadout.id or nil;
10561062
local dataProviderEntries = {}
10571063
for _, loadout in pairs(loadouts) do
1058-
--- @type TLM_SideBarLoadoutInfo
1059-
local loadout = loadout ---@diagnostic disable-line: assign-type-mismatch, redefined-local
1060-
--- @type number?
1061-
local parentID = loadout.parentMapping and loadout.parentMapping[0];
1062-
loadout.parentID = parentID;
1063-
--- @type TLM_SideBarDataProviderEntry
1064-
local entry = {
1065-
text = loadout.displayName,
1066-
data = loadout,
1067-
isActive = loadout.id == activeLoadoutID,
1068-
parentID = parentID,
1069-
};
1070-
table.insert(dataProviderEntries, entry);
1071-
if loadout.id == activeLoadoutID then
1072-
foundActiveLoadout = true;
1064+
if loadout.playerIsOwner or not loadout.owner or Config:IsCharacterShown(loadout.owner) then
1065+
--- @type TLM_SideBarLoadoutInfo
1066+
local loadout = loadout ---@diagnostic disable-line: assign-type-mismatch, redefined-local
1067+
--- @type number?
1068+
local parentID = loadout.parentMapping and loadout.parentMapping[0];
1069+
loadout.parentID = parentID;
1070+
--- @type TLM_SideBarDataProviderEntry
1071+
local entry = {
1072+
text = loadout.displayName,
1073+
data = loadout,
1074+
isActive = loadout.id == activeLoadoutID,
1075+
parentID = parentID,
1076+
};
1077+
table.insert(dataProviderEntries, entry);
1078+
if loadout.id == activeLoadoutID then
1079+
foundActiveLoadout = true;
1080+
end
10731081
end
10741082
end
10751083
if not foundActiveLoadout then

0 commit comments

Comments
 (0)