@@ -211,7 +211,9 @@ function SideBarMixin:SetupHook()
211211 if not self .importDialog then
212212 self .importDialog = self :CreateImportDialog ();
213213 end
214- self :SecureHookScript (self :GetTalentsTab (), " OnShow" , " OnTalentsTabShow" );
214+ local talentsTab = self :GetTalentsTab ();
215+ self :SecureHookScript (talentsTab , " OnShow" , " OnTalentsTabShow" );
216+ self :SecureHook (talentsTab , " OnUpdate" , " OnTalentsChanged" );
215217
216218 API :RegisterCallback (API .Event .LoadoutListUpdated , self .RefreshSideBarData , self );
217219end
232234 error (' override in implementation' );
233235 end
234236
237+ --- @return TalentLoadoutManagerAPI_LoadoutInfo | nil - selected loadout ' s info, if any
235238 function SideBarMixin :GetActiveLoadout (forceRefresh )
236239 error (' override in implementation' );
237240 end
249252 error (' override in implementation' );
250253 end
251254
255+ function SideBarMixin :GetExportString ()
256+ error (' override in implementation' );
257+ end
258+
252259 function SideBarMixin :UpdateCustomLoadoutWithCurrentTalents (loadoutID )
253260 error (' override in implementation' );
254261 end
263270 end
264271end
265272
273+ function SideBarMixin :OnTalentsChanged ()
274+ if self .talentChangePending then return ; end
275+ self .talentChangePending = true
276+ RunNextFrame (function ()
277+ self .talentChangePending = false
278+
279+ self :SaveButtonUpdateEnableState ();
280+ end );
281+ end
282+
283+ function SideBarMixin :SaveButtonUpdateEnableState ()
284+ local activeLoadout = self :GetActiveLoadout ();
285+ local identicalTalents = false ;
286+ if activeLoadout then
287+ local savedExportString = GlobalAPI :GetExportString (activeLoadout .id );
288+ local currentExportString = self :GetExportString ();
289+
290+ if savedExportString == currentExportString then
291+ identicalTalents = true ;
292+ elseif savedExportString and currentExportString and savedExportString ~= " " and currentExportString ~= " " then
293+ local serializedSavedExportString = GlobalAPI :SerializeLoadoutString (savedExportString );
294+ local serializedCurrentExportString = GlobalAPI :SerializeLoadoutString (currentExportString );
295+
296+ identicalTalents = serializedSavedExportString == serializedCurrentExportString ;
297+ end
298+ end
299+
300+ self .SideBar .SaveButton :SetEnabled (
301+ activeLoadout
302+ and not activeLoadout .isBlizzardLoadout
303+ and not activeLoadout .isLocked
304+ and not identicalTalents
305+ );
306+ end
307+
266308function SideBarMixin :OnTalentsTabShow (frame )
267309 self :UpdateScaleForFit (frame :GetParent ());
268310 self :UpdatePosition (frame :GetParent ());
@@ -565,6 +607,7 @@ function SideBarMixin:CreateSideBar()
565607 if not activeLoadout or not activeLoadout .id then return ; end
566608
567609 self :UpdateCustomLoadoutWithCurrentTalents (activeLoadout .id );
610+ self :SaveButtonUpdateEnableState ();
568611 end );
569612 sideBar .SaveButton .tooltipText = " Save the current talents into the currently selected loadout" ;
570613
@@ -839,7 +882,7 @@ function SideBarMixin:SetElementAsActive(frame, loadoutInfo)
839882 previouslyActiveLoadoutFrame :ApplyColors ();
840883 end
841884 frame :ApplyColors ();
842- self . SideBar . SaveButton : SetEnabled ( self . activeLoadout and not self . activeLoadout . isBlizzardLoadout and not self . activeLoadout . isLocked );
885+ self : SaveButtonUpdateEnableState ( );
843886end
844887
845888--- @param frame TLM_ElementFrame
@@ -1036,7 +1079,7 @@ function SideBarMixin:RefreshSideBarData()
10361079 self .DataProvider = CreateDataProvider (dataProviderEntries );
10371080 self .SideBar .ScrollBoxContainer .ScrollBox :SetDataProvider (self .DataProvider );
10381081
1039- self . SideBar . SaveButton : SetEnabled ( self . activeLoadout and not self . activeLoadout . isBlizzardLoadout and not self . activeLoadout . isLocked );
1082+ self : SaveButtonUpdateEnableState ( );
10401083end
10411084
10421085function SideBarMixin :ShowConfigDialog ()
0 commit comments