1- local thisAddonName = ...
1+ local thisAddonName , NAP = ...
22
33local s_trim = string .trim
44local t_insert = table.insert
55local t_removemulti = table .removemulti
6- local t_wipe = table .wipe
76local pairs = pairs
87local GetTime = GetTime
98
@@ -14,7 +13,6 @@ local Enum_AddOnProfilerMetric_RecentAverageTime = Enum.AddOnProfilerMetric.Rece
1413local Enum_AddOnProfilerMetric_EncounterAverageTime = Enum .AddOnProfilerMetric .EncounterAverageTime ;
1514local Enum_AddOnProfilerMetric_PeakTime = Enum .AddOnProfilerMetric .PeakTime ;
1615
17- local NAP = {};
1816NAP .eventFrame = CreateFrame (' Frame' );
1917
2018_G .NumyAddonProfiler = NAP ;
@@ -357,12 +355,16 @@ function NAP:InitDB()
357355 hide = false ,
358356 },
359357 pinnedAddons = {},
358+ historySelectionType = self .currentHistorySelection .type ,
359+ historySelectionTimeRange = self .currentHistorySelection .timeRange ,
360360 };
361361 for key , value in pairs (defaults ) do
362362 if self .db [key ] == nil then
363363 self .db [key ] = value ;
364364 end
365365 end
366+ self .currentHistorySelection .type = self .db .historySelectionType ;
367+ self .currentHistorySelection .timeRange = self .db .historySelectionTimeRange ;
366368end
367369
368370function NAP :ADDON_LOADED (addonName )
@@ -726,6 +728,11 @@ function NAP:GetCurrentMetrics(metric)
726728 return currentMetrics ;
727729end
728730
731+ function NAP :PersistHistorySelection ()
732+ self .db .historySelectionType = self .currentHistorySelection .type ;
733+ self .db .historySelectionTimeRange = self .currentHistorySelection .timeRange ;
734+ end
735+
729736--- @return string historyType
730737--- @return number | nil historyIndex # combatIndex, encounterIndex, or timeRange
731738function NAP :GetActiveHistoryRange ()
@@ -1614,6 +1621,7 @@ function NAP:InitUI()
16141621 local function onAfterSelection ()
16151622 display .elapsed = UPDATE_INTERVAL ;
16161623 display :UpdateHistoryRangeText ();
1624+ NAP :PersistHistorySelection ();
16171625 end
16181626 local function isTypeSelected (data )
16191627 return data == NAP :GetActiveHistoryRange ();
@@ -2287,6 +2295,11 @@ function NAP:InitUI()
22872295 self :SetClampRectInsets (clampWidth , - clampWidth , top or 0 , bottom or 0 )
22882296 end
22892297 pinContainer :UpdateClampInsets ();
2298+
2299+ pinContainer .rowPool = CreateUnsecuredRegionPoolInstance (nil , function () return makeStandaloneRow (pinContainer ); end );
2300+ pinContainer .pinnedAddons = {};
2301+ pinContainer .addonOrder = {};
2302+ pinContainer .elapsed = UPDATE_INTERVAL ;
22902303 end
22912304
22922305 local bg = pinContainer :CreateTexture (nil , " BACKGROUND" );
@@ -2305,14 +2318,23 @@ function NAP:InitUI()
23052318
23062319 local mover = CreateFrame (" Frame" , nil , pinContainer , " PanelDragBarTemplate" );
23072320 pinContainer .Mover = mover ;
2308- mover :SetFrameLevel (3 );
2309- mover :SetAllPoints (header );
2310- mover :SetPropagateMouseMotion (true );
2321+ do
2322+ mover :SetFrameLevel (3 );
2323+ mover :SetAllPoints (header );
2324+ mover :SetPropagateMouseMotion (true );
2325+ end
23112326
2312- pinContainer .rowPool = CreateUnsecuredRegionPoolInstance (nil , function () return makeStandaloneRow (pinContainer ); end );
2313- pinContainer .pinnedAddons = {};
2314- pinContainer .addonOrder = {};
2315- pinContainer .elapsed = UPDATE_INTERVAL ;
2327+ local noDataTextContainer = CreateFrame (" Frame" , nil , pinContainer );
2328+ pinContainer .NoDataTextContainer = noDataTextContainer ;
2329+ do
2330+ noDataTextContainer :SetHeight (ROW_HEIGHT );
2331+ noDataTextContainer :SetPoint (" BOTTOMLEFT" , pinContainer , " BOTTOMLEFT" , 0 , 5 );
2332+ noDataTextContainer :SetPoint (" BOTTOMRIGHT" , pinContainer , " BOTTOMRIGHT" , 0 , 5 );
2333+
2334+ local noDataText = noDataTextContainer :CreateFontString (nil , " ARTWORK" , " GameFontHighlightLarge" )
2335+ noDataText :SetText (" No data available for the selected History Range." )
2336+ noDataText :SetPoint (" CENTER" )
2337+ end
23162338
23172339 function pinContainer :ToggleAddonPin (addonName )
23182340 if self .pinnedAddons [addonName ] then
@@ -2365,23 +2387,29 @@ function NAP:InitUI()
23652387 end
23662388
23672389 function pinContainer :DoUpdate ()
2390+ self .Header :UpdateColumns ();
2391+ for columnText in self .Header .columnPool :EnumerateActive () do
2392+ local column = columnText .column
2393+ columnText :SetText (column .title )
2394+ self :SetWidth (self .Header :GetWidth () + 5 );
2395+ end
2396+
23682397 local filteredData , displayNothing = NAP :CollectData (self .pinnedAddons );
23692398 if not filteredData or displayNothing then
2370- -- what to do? show an overlay?
2399+ for _ , row in pairs (self .pinnedAddons ) do
2400+ row :Hide ();
2401+ end
2402+ self .NoDataTextContainer :Show ();
2403+ self :SetHeight (2 * ROW_HEIGHT + 5 );
23712404 return ;
23722405 end
23732406
2374- local elementDataByAddon = {}
2407+ self .NoDataTextContainer :Hide ();
2408+ local elementDataByAddon = {};
23752409 for _ , elementData in pairs (filteredData ) do
23762410 elementDataByAddon [elementData .addonName ] = elementData ;
23772411 end
23782412
2379- self .Header :UpdateColumns ();
2380- for columnText in self .Header .columnPool :EnumerateActive () do
2381- local column = columnText .column
2382- columnText :SetText (column .title )
2383- end
2384-
23852413 for i , addonName in ipairs (self .addonOrder ) do
23862414 --- @type NAP_StandloneRow ?
23872415 local row = self .pinnedAddons [addonName ];
0 commit comments