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

namespace Cryville.Crtr.Extensions.Malody {
	public class MalodyChartFinder : LocalResourceFinder {
		public override string Name { get { return "Malody beatmaps"; } }

		public override string GetRootPath() {
			switch (Environment.OSVersion.Platform) {
				case PlatformID.Unix:
					return "/storage/emulated/0/data/malody/beatmap";
				case PlatformID.Win32NT:
					var reg = Registry.ClassesRoot.OpenSubKey(@"malody\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, "beatmap");
				default: return null;
			}
		}
	}
}
