Sort services by name in `Help` > `Features...`

This commit is contained in:
YoshiRulz 2025-05-26 06:20:29 +10:00
parent ab587289a8
commit 0e3d786c70
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 7 additions and 18 deletions

View File

@ -5,6 +5,7 @@ using System.Windows.Forms;
using System.Reflection;
using BizHawk.Client.Common;
using BizHawk.Common.CollectionExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores;
@ -24,27 +25,15 @@ namespace BizHawk.Client.EmuHawk
{
CoreName = emu.Attributes().CoreName;
Released = emu.Attributes().Released;
Services = new Dictionary<string, ServiceInfo>();
var ser = emu.ServiceProvider;
foreach (Type t in ser.AvailableServices.Where(type => type != emu.GetType()))
{
var si = new ServiceInfo(t, ser.GetService(t));
Services.Add(si.TypeName, si);
}
Services = ser.AvailableServices.Except([ emu.GetType() ])
.Select(t => new ServiceInfo(t, ser.GetService(t)))
.OrderBy(si => si.TypeName)
.ToDictionary(static si => si.TypeName);
var notApplicableAttribute = ((ServiceNotApplicableAttribute)Attribute
.GetCustomAttribute(emu.GetType(), typeof(ServiceNotApplicableAttribute)));
if (notApplicableAttribute != null)
{
NotApplicableTypes = notApplicableAttribute.NotApplicableTypes
.Select(x => x.ToString())
.ToList();
}
else
{
NotApplicableTypes = new List<string>();
}
NotApplicableTypes = (notApplicableAttribute?.NotApplicableTypes ?? [ ])
.Select(static x => x.ToString()).Order().ToList();
}
}