using Cryville.Common;
using Cryville.Crtr.Browsing;
using Microsoft.Win32;
using System;
using System.IO;

namespace Cryville.Crtr.Extensions.osu {
	public class osuChartFinder : LocalResourceFinder {
		public override string Name { get { return "osu! beatmaps"; } }

		public override string GetRootPath() {
			switch (Environment.OSVersion.Platform) {
				case PlatformID.Win32NT:
					var reg = Registry.ClassesRoot.OpenSubKey(@"osu!\Shell\Open\Command");
					if (reg == null) return null;
					var pathObj = reg.GetValue(null);
					if (pathObj == null) return null;
					var path = (string)pathObj;
					return Path.Combine(new FileInfo(StringUtils.GetProcessPathFromCommand(path)).Directory.FullName, "Songs");
				default: return null;
			}
		}
	}
}
