Files
crtr/Assets/Cryville/Crtr/Browsing/UI/ResourceBrowserMaster.cs

66 lines
1.9 KiB
C#

using Cryville.Crtr.Config.UI;
using Cryville.Crtr.UI;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace Cryville.Crtr.Browsing.UI {
public class ResourceBrowserMaster : MonoBehaviour {
[SerializeField]
private Button m_playButton;
[SerializeField]
private Button m_configButton;
[SerializeField]
private ConfigPanelMaster m_configPanel;
[SerializeField]
private PathedResourceBrowser m_mainBrowser;
[SerializeField]
private DetailPanel m_detailPanel;
readonly List<ResourceBrowser> _units = new List<ResourceBrowser>();
void Awake() {
m_mainBrowser.ResourceManager = new LegacyResourceManager(Settings.Default.GameDataPath);
_units.Add(m_mainBrowser);
// _units.Add(m_detailPanel);
}
public void ShowDetail(int id, ChartDetail detail) {
// SlideIntoView(1);
m_detailPanel.Load(id, detail);
m_playButton.gameObject.SetActive(true);
m_configButton.gameObject.SetActive(true);
}
public bool Back() {
// if (_slideDest == 0) return false;
// SlideIntoView(_slideDest - 1);
return true;
}
public void Open(int id, ChartDetail detail) {
SetDataSettings(id, detail);
#if UNITY_5_3_OR_NEWER
SceneManager.LoadScene("Play", LoadSceneMode.Additive);
#else
Application.LoadLevelAdditive("Play");
#endif
GameObject.Find("/Master").GetComponent<Master>().HideMenu();
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
DiscordController.Instance.SetPlaying(string.Format("{0} - {1}", detail.Meta.song.name, detail.Meta.name), detail.Meta.length);
#endif
}
public void OpenConfig(int id, ChartDetail detail) {
SetDataSettings(id, detail);
}
void SetDataSettings(int id, ChartDetail detail) {
Settings.Default.LoadRuleset = detail.Meta.ruleset + "/.umgr";
Settings.Default.LoadRulesetConfig = detail.Meta.ruleset + ".json";
Settings.Default.LoadChart = m_mainBrowser.ResourceManager.GetItemPath(id);
}
}
}