Utils/ResourceExtensions.cs
using Sandbox.Internal;
using Sandbox.UI;

namespace HC3;

public static class ResourceUtils
{
	/// <summary>
	/// Get a list of <typeparamref name="T"/>	resources as options for use in dropdowns.
	/// </summary>
	/// <typeparam name="T"></typeparam>
	/// <param name="includeNone"></param>
	/// <returns></returns>
	public static List<Option> GetOptions<T>( bool includeNone = true ) where T : Resource
	{
		var options = new List<Option>();

		if ( includeNone )
		{
			options.Add( new Option( "None", "none" ) );
		}

		options.AddRange( ResourceLibrary.GetAll<T>().Select( x => new Option( (x as ITitleProvider)?.Value ?? x.ResourceName, x.ResourcePath ) ).OrderBy( x => x.Title ) );
		return options;
	}
}