Add LocalResourceFinder.
This commit is contained in:
@@ -44,5 +44,21 @@ namespace Cryville.Common {
|
||||
if (result.Length == 0) return "_";
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the process path from a command.
|
||||
/// </summary>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <returns>The process path.</returns>
|
||||
public static string GetProcessPathFromCommand(string command) {
|
||||
command = command.Trim();
|
||||
if (command[0] == '"') {
|
||||
return command.Substring(1, command.IndexOf('"', 1) - 1);
|
||||
}
|
||||
else {
|
||||
int e = command.IndexOf(' ');
|
||||
if (e == -1) return command;
|
||||
else return command.Substring(0, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
Assets/Cryville/Crtr/Browsing/LocalResourceFinder.cs
Normal file
6
Assets/Cryville/Crtr/Browsing/LocalResourceFinder.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public abstract class LocalResourceFinder {
|
||||
public abstract string Name { get; }
|
||||
public abstract string GetRootPath();
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Browsing/LocalResourceFinder.cs.meta
Normal file
11
Assets/Cryville/Crtr/Browsing/LocalResourceFinder.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5b3f3294f679f14f8ec1195b0def630
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Assets/Cryville/Crtr/Extensions/Malody/MalodyChartFinder.cs
Normal file
26
Assets/Cryville/Crtr/Extensions/Malody/MalodyChartFinder.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c9beaff62143a2468e18ad4642232c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Cryville/Crtr/Extensions/Quaver/QuaverChartFinder.cs
Normal file
24
Assets/Cryville/Crtr/Extensions/Quaver/QuaverChartFinder.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Cryville.Crtr.Extensions.Quaver {
|
||||
public class QuaverChartFinder : LocalResourceFinder {
|
||||
public override string Name { get { return "Quaver beatmaps"; } }
|
||||
|
||||
public override string GetRootPath() {
|
||||
switch (Environment.OSVersion.Platform) {
|
||||
case PlatformID.Win32NT:
|
||||
var reg = Registry.ClassesRoot.OpenSubKey(@"quaver\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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68bacf7746cbeea42a78a7d55cfdbea0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Cryville/Crtr/Extensions/osu/osuChartFinder.cs
Normal file
24
Assets/Cryville/Crtr/Extensions/osu/osuChartFinder.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Extensions/osu/osuChartFinder.cs.meta
Normal file
11
Assets/Cryville/Crtr/Extensions/osu/osuChartFinder.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 365d879536c05284fa2335a7676c6cf4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user