Add resource action. Implement play chart and import resource action.

This commit is contained in:
2023-11-23 00:02:55 +08:00
parent 33c0826f3b
commit ed496859cb
8 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
using Cryville.Crtr.UI;
using System;
using System.IO;
using UnityEngine.SceneManagement;
namespace Cryville.Crtr.Browsing.Actions {
internal class PlayChartAction : ResourceAction<ChartDetail> {
public override string Name { get { return "Play"; } }
public override int Priority { get { return -100; } }
public override void Invoke(Uri uri, ChartDetail resource) {
Settings.Default.LoadRuleset = Path.Combine(resource.Meta.ruleset, ".umgr");
Settings.Default.LoadRulesetConfig = resource.Meta.ruleset + ".json";
Settings.Default.LoadChart = uri.LocalPath;
#if UNITY_5_3_OR_NEWER
SceneManager.LoadScene("Play", LoadSceneMode.Additive);
#else
Application.LoadLevelAdditive("Play");
#endif
Master.Instance.HideMenu();
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
DiscordController.Instance.SetPlaying(string.Format("{0} - {1}", resource.Meta.song.name, resource.Meta.name), resource.Meta.length);
#endif
}
}
}