Add diagnostic display and make CustomizeManager a DataContainer.

This commit is contained in:
Ottermandias 2023-12-24 13:38:29 +01:00
parent 4531cdadbe
commit 44a65f61fb
5 changed files with 29 additions and 8 deletions

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Interface.Internal; using Dalamud.Interface.Internal;
@ -12,7 +13,7 @@ using Race = Penumbra.GameData.Enums.Race;
namespace Glamourer.GameData; namespace Glamourer.GameData;
/// <summary> Generate everything about customization per tribe and gender. </summary> /// <summary> Generate everything about customization per tribe and gender. </summary>
public class CustomizeManager : IAsyncService public class CustomizeManager : IAsyncDataContainer
{ {
/// <summary> All races except for Unknown </summary> /// <summary> All races except for Unknown </summary>
public static readonly IReadOnlyList<Race> Races = ((Race[])Enum.GetValues(typeof(Race))).Skip(1).ToArray(); public static readonly IReadOnlyList<Race> Races = ((Race[])Enum.GetValues(typeof(Race))).Skip(1).ToArray();
@ -52,10 +53,21 @@ public class CustomizeManager : IAsyncService
public CustomizeManager(ITextureProvider textures, IDataManager gameData, IPluginLog log, NpcCustomizeSet npcCustomizeSet) public CustomizeManager(ITextureProvider textures, IDataManager gameData, IPluginLog log, NpcCustomizeSet npcCustomizeSet)
{ {
_icons = new IconStorage(textures, gameData); _icons = new IconStorage(textures, gameData);
var tmpTask = Task.Run(() => new CustomizeSetFactory(gameData, log, _icons, npcCustomizeSet)); var stopwatch = new Stopwatch();
var tmpTask = Task.Run(() =>
{
stopwatch.Start();
return new CustomizeSetFactory(gameData, log, _icons, npcCustomizeSet);
});
var setTasks = AllSets().Select(p var setTasks = AllSets().Select(p
=> tmpTask.ContinueWith(t => _customizationSets[ToIndex(p.Clan, p.Gender)] = t.Result.CreateSet(p.Clan, p.Gender))); => tmpTask.ContinueWith(t => _customizationSets[ToIndex(p.Clan, p.Gender)] = t.Result.CreateSet(p.Clan, p.Gender)));
Awaiter = Task.WhenAll(setTasks); Awaiter = Task.WhenAll(setTasks).ContinueWith(_ =>
{
// This is far too hard to estimate sensibly.
TotalCount = 0;
Memory = 0;
Time = stopwatch.ElapsedMilliseconds;
});
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -78,4 +90,12 @@ public class CustomizeManager : IAsyncService
return idx; return idx;
} }
public long Time { get; private set; }
public long Memory { get; private set; }
public string Name
=> nameof(CustomizeManager);
public int TotalCount { get; private set; }
} }

View file

@ -274,7 +274,7 @@ internal class CustomizeSetFactory(
{ {
// If none exists and the id corresponds to highlights, set the Highlights name. // If none exists and the id corresponds to highlights, set the Highlights name.
if (c == CustomizeIndex.Highlights) if (c == CustomizeIndex.Highlights)
return _lobbySheet.GetRow(237)?.Text.ToDalamudString().ToString() ?? "Highlights"; return string.Intern(_lobbySheet.GetRow(237)?.Text.ToDalamudString().ToString() ?? "Highlights");
// Otherwise there is an error and we use the default name. // Otherwise there is an error and we use the default name.
return c.ToDefaultName(); return c.ToDefaultName();
@ -282,7 +282,7 @@ internal class CustomizeSetFactory(
// Otherwise all is normal, get the menu name or if it does not work the default name. // Otherwise all is normal, get the menu name or if it does not work the default name.
var textRow = _lobbySheet.GetRow(menu.Value.Id); var textRow = _lobbySheet.GetRow(menu.Value.Id);
return textRow?.Text.ToDalamudString().ToString() ?? c.ToDefaultName(); return string.Intern(textRow?.Text.ToDalamudString().ToString() ?? c.ToDefaultName());
}).ToArray(); }).ToArray();
// Add names for both eye colors. // Add names for both eye colors.

View file

@ -45,6 +45,7 @@ public class DebugTabHeader(string label, params IGameDataDrawer[] subTrees)
=> new => new
( (
"Game Data", "Game Data",
provider.GetRequiredService<DataServiceDiagnosticsDrawer>(),
provider.GetRequiredService<IdentificationDrawer>(), provider.GetRequiredService<IdentificationDrawer>(),
provider.GetRequiredService<RestrictedGearDrawer>(), provider.GetRequiredService<RestrictedGearDrawer>(),
provider.GetRequiredService<ActorDataDrawer>(), provider.GetRequiredService<ActorDataDrawer>(),

@ -1 +1 @@
Subproject commit bdf053ea9e7ac7b96dcd6aceadff8d92c3050b34 Subproject commit 4df65fb330f3746b7836c39cb96d1e36a53bcec0

@ -1 +1 @@
Subproject commit a7d2d73217113eadf02e21865a82deb92ea9eb53 Subproject commit 3073db1fc8a1894a4af8974ea9c22a63acd7316e