@@ -66,6 +66,7 @@ function TLM:OnInitialize()
6666 self .db = TalentLoadoutManagerDB ;
6767 self .charDb = TalentLoadoutManagerCharDB ;
6868 self .cache = {
69+ --- @type table<string | number , TLM_LoadoutDisplayInfo>
6970 loadoutByID = {},
7071 exportStrings = {},
7172 deserializationCache = {},
@@ -234,6 +235,7 @@ function TLM:RebuildLoadoutByIDCache()
234235 if playerName ~= self .playerName then
235236 displayName = displayName .. " (" .. playerName .. " )" ;
236237 end
238+ --- @type TLM_LoadoutDisplayInfo
237239 local displayInfo = {
238240 id = configID ,
239241 displayName = displayName ,
@@ -244,6 +246,7 @@ function TLM:RebuildLoadoutByIDCache()
244246 parentMapping = nil ,
245247 classID = classID ,
246248 specID = specID ,
249+ isLocked = loadoutInfo .isLocked or false ,
247250 };
248251 self .cache .loadoutByID [configID ] = displayInfo ;
249252 end
@@ -255,6 +258,7 @@ function TLM:RebuildLoadoutByIDCache()
255258 for specID , loadoutList in pairs (specList ) do
256259 for loadoutID , loadoutInfo in pairs (loadoutList ) do
257260 local namePrefix = loadoutInfo .levelingOrder and XP_ATLAS or " " ;
261+ --- @type TLM_LoadoutDisplayInfo
258262 local displayInfo = {
259263 id = loadoutID ,
260264 displayName = namePrefix .. (loadoutInfo .name ):gsub (' .-||' , ' ' , 1 ),
@@ -265,6 +269,7 @@ function TLM:RebuildLoadoutByIDCache()
265269 parentMapping = self :GetParentMappingForLoadout (loadoutInfo , specID ),
266270 classID = classID ,
267271 specID = specID ,
272+ isLocked = loadoutInfo .isLocked or false ,
268273 };
269274 self .cache .loadoutByID [loadoutID ] = displayInfo ;
270275 end
@@ -445,9 +450,11 @@ function TLM:UpdateBlizzardLoadout(configID, specID)
445450 selectedNodes = serialized ,
446451 name = configInfo .name ,
447452 id = configID ,
453+ isLocked = false ,
448454 };
449455 self .db .blizzardLoadouts [classID ][specID ][self .playerName ][configID ] = loadoutInfo ;
450456 local displayName = BLIZZ_ATLAS .. (loadoutInfo .name ):gsub (' .-||' , ' ' , 1 );
457+ --- @type TLM_LoadoutDisplayInfo
451458 local displayInfo = {
452459 id = configID ,
453460 displayName = displayName ,
@@ -457,6 +464,7 @@ function TLM:UpdateBlizzardLoadout(configID, specID)
457464 isBlizzardLoadout = true ,
458465 classID = classID ,
459466 specID = specID ,
467+ isLocked = loadoutInfo .isLocked or false ,
460468 };
461469 self .cache .loadoutByID [configID ] = displayInfo ;
462470 self :TriggerEvent (self .Event .LoadoutUpdated , classID , specID , configID , displayInfo );
@@ -482,6 +490,7 @@ function TLM:UpdateCustomLoadout(customLoadoutID, selectedNodes, levelingOrder,
482490 loadoutInfo .levelingOrder = levelingOrder ;
483491
484492 local namePrefix = loadoutInfo .levelingOrder and XP_ATLAS or " " ;
493+ --- @type TLM_LoadoutDisplayInfo
485494 local displayInfo = {
486495 id = customLoadoutID ,
487496 displayName = namePrefix .. (loadoutInfo .name ):gsub (' .-||' , ' ' , 1 ),
@@ -492,6 +501,7 @@ function TLM:UpdateCustomLoadout(customLoadoutID, selectedNodes, levelingOrder,
492501 parentMapping = self :GetParentMappingForLoadout (loadoutInfo , specID ),
493502 classID = classID ,
494503 specID = specID ,
504+ isLocked = loadoutInfo .isLocked or false ,
495505 }
496506 self .cache .loadoutByID [customLoadoutID ] = displayInfo ;
497507 self :TriggerEvent (self .Event .LoadoutUpdated , classID , specID , customLoadoutID , displayInfo );
@@ -852,6 +862,7 @@ function TLM:ApplyCustomLoadout(loadoutInfo, autoApply)
852862
853863 self .charDb .selectedCustomLoadoutID [self .playerSpecID ] = loadoutInfo .id ;
854864 local namePrefix = loadoutInfo .levelingOrder and XP_ATLAS or " " ;
865+ --- @type TLM_LoadoutDisplayInfo
855866 local displayInfo = {
856867 id = loadoutInfo .id ,
857868 displayName = namePrefix .. (loadoutInfo .name ):gsub (' .-||' , ' ' , 1 ),
@@ -862,6 +873,7 @@ function TLM:ApplyCustomLoadout(loadoutInfo, autoApply)
862873 parentMapping = self :GetParentMappingForLoadout (loadoutInfo , self .playerSpecID ),
863874 classID = self .playerClassID ,
864875 specID = self .playerSpecID ,
876+ isLocked = loadoutInfo .isLocked or false ,
865877 }
866878 self :TriggerEvent (self .Event .CustomLoadoutApplied , self .playerClassID , specID , loadoutInfo .id , displayInfo );
867879
@@ -1016,6 +1028,7 @@ function TLM:CreateCustomLoadoutFromLoadoutData(loadoutInfo, classIDOrNil, specI
10161028 selectedNodes = loadoutInfo .selectedNodes ,
10171029 levelingOrder = loadoutInfo .levelingOrder ,
10181030 parentMapping = {},
1031+ isLocked = false ,
10191032 }
10201033 if classID == self .playerClassID and specID == self .playerSpecID then
10211034 newLoadoutInfo .parentMapping [self .playerName ] = self :GetActiveBlizzardLoadoutConfigID ();
@@ -1033,6 +1046,7 @@ function TLM:CreateCustomLoadoutFromLoadoutData(loadoutInfo, classIDOrNil, specI
10331046 parentMapping = self :GetParentMappingForLoadout (newLoadoutInfo , specID ),
10341047 classID = classID ,
10351048 specID = specID ,
1049+ isLocked = newLoadoutInfo .isLocked or false ,
10361050 }
10371051 self .cache .loadoutByID [id ] = displayInfo ;
10381052 self :TriggerEvent (self .Event .LoadoutUpdated , classID , specID , id , displayInfo );
@@ -1055,6 +1069,7 @@ function TLM:CreateCustomLoadoutFromImportString(importString, autoApply, name,
10551069 name = name ,
10561070 selectedNodes = selectedNodes ,
10571071 levelingOrder = errorOrLevelingOrder ,
1072+ isLocked = false ,
10581073 }
10591074 loadoutInfo = self :CreateCustomLoadoutFromLoadoutData (loadoutInfo , classID , specID );
10601075 if load and classID == self .playerClassID and specID == self .playerSpecID then
@@ -1075,13 +1090,36 @@ function TLM:CreateCustomLoadoutFromActiveTalents(name, classIDOrNil, specIDOrNi
10751090 name = name ,
10761091 selectedNodes = selectedNodes ,
10771092 levelingOrder = nil ,
1093+ isLocked = false ,
10781094 }
10791095 loadoutInfo = self :CreateCustomLoadoutFromLoadoutData (loadoutInfo , classID , specID );
10801096 self :ApplyCustomLoadout (loadoutInfo );
10811097
10821098 return loadoutInfo ;
10831099end
10841100
1101+ function TLM :SetLoadoutLocked (classIDOrNil , specIDOrNil , loadoutID , isLocked )
1102+ local classID = tonumber (classIDOrNil ) or self .playerClassID ;
1103+ local specID = tonumber (specIDOrNil ) or self .playerSpecID ;
1104+ assert (type (loadoutID ) == " string" or type (loadoutID ) == " number" , " loadoutID must be a string or number" );
1105+
1106+ if self .db .customLoadouts [classID ] and self .db .customLoadouts [classID ][specID ] and self .db .customLoadouts [classID ][specID ][loadoutID ] then
1107+ local loadoutInfo = self .db .customLoadouts [classID ][specID ][loadoutID ];
1108+ loadoutInfo .isLocked = isLocked ;
1109+
1110+ local displayInfo = self .cache .loadoutByID [loadoutID ]
1111+ displayInfo .isLocked = isLocked ;
1112+
1113+ self .cache .loadoutByID [loadoutID ] = displayInfo ;
1114+ self :TriggerEvent (self .Event .LoadoutUpdated , classID , specID , loadoutID , displayInfo );
1115+ self :TriggerEvent (self .Event .LoadoutListUpdated );
1116+
1117+ return true ;
1118+ end
1119+
1120+ return false ;
1121+ end
1122+
10851123function TLM :RenameCustomLoadout (classIDOrNil , specIDOrNil , loadoutID , newName )
10861124 local classID = tonumber (classIDOrNil ) or self .playerClassID ;
10871125 local specID = tonumber (specIDOrNil ) or self .playerSpecID ;
@@ -1092,17 +1130,9 @@ function TLM:RenameCustomLoadout(classIDOrNil, specIDOrNil, loadoutID, newName)
10921130 loadoutInfo .name = newName ;
10931131
10941132 local namePrefix = loadoutInfo .levelingOrder and XP_ATLAS or " " ;
1095- local displayInfo = {
1096- id = loadoutID ,
1097- displayName = namePrefix .. (loadoutInfo .name ):gsub (' .-||' , ' ' , 1 ),
1098- loadoutInfo = loadoutInfo ,
1099- owner = nil ,
1100- playerIsOwner = true ,
1101- isBlizzardLoadout = false ,
1102- parentMapping = self :GetParentMappingForLoadout (loadoutInfo , specID ),
1103- classID = classID ,
1104- specID = specID ,
1105- }
1133+ local displayInfo = self .cache .loadoutByID [loadoutID ]
1134+ displayInfo .displayName = namePrefix .. (loadoutInfo .name ):gsub (' .-||' , ' ' , 1 );
1135+
11061136 self .cache .loadoutByID [loadoutID ] = displayInfo ;
11071137 self :TriggerEvent (self .Event .LoadoutUpdated , classID , specID , loadoutID , displayInfo );
11081138 self :TriggerEvent (self .Event .LoadoutListUpdated );
0 commit comments