Use actions in resource browser.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Cryville.Common.Unity;
|
using Cryville.Common.Unity;
|
||||||
using Cryville.Common.Unity.UI;
|
using Cryville.Common.Unity.UI;
|
||||||
|
using Cryville.Crtr.Browsing.Actions;
|
||||||
using Cryville.Crtr.UI;
|
using Cryville.Crtr.UI;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -19,6 +20,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
GameObject m_actionBar;
|
GameObject m_actionBar;
|
||||||
|
|
||||||
IPathedResourceManager<ChartDetail> _manager;
|
IPathedResourceManager<ChartDetail> _manager;
|
||||||
|
IResourceAction _importAction;
|
||||||
|
|
||||||
readonly HashSet<int> _selectedItems = new HashSet<int>();
|
readonly HashSet<int> _selectedItems = new HashSet<int>();
|
||||||
readonly Dictionary<int, BrowserItem> _items = new Dictionary<int, BrowserItem>();
|
readonly Dictionary<int, BrowserItem> _items = new Dictionary<int, BrowserItem>();
|
||||||
@@ -34,6 +36,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
UnregisterManager();
|
UnregisterManager();
|
||||||
}
|
}
|
||||||
void UnregisterManager() {
|
void UnregisterManager() {
|
||||||
|
Master.Actions.Unregister(_importAction);
|
||||||
_manager.ItemChanged -= OnItemChanged;
|
_manager.ItemChanged -= OnItemChanged;
|
||||||
_manager.DirectoryChanged -= OnDirectoryChanged;
|
_manager.DirectoryChanged -= OnDirectoryChanged;
|
||||||
}
|
}
|
||||||
@@ -53,6 +56,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
_manager = manager;
|
_manager = manager;
|
||||||
_manager.ItemChanged += OnItemChanged;
|
_manager.ItemChanged += OnItemChanged;
|
||||||
_manager.DirectoryChanged += OnDirectoryChanged;
|
_manager.DirectoryChanged += OnDirectoryChanged;
|
||||||
|
Master.Actions.Register(_importAction = new ImportResourceAction(_manager));
|
||||||
|
|
||||||
OnItemChanged();
|
OnItemChanged();
|
||||||
OnDirectoryChanged();
|
OnDirectoryChanged();
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
|
using Cryville.Crtr.Browsing.Actions;
|
||||||
using Cryville.Crtr.Config.UI;
|
using Cryville.Crtr.Config.UI;
|
||||||
using Cryville.Crtr.UI;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
|
||||||
|
|
||||||
namespace Cryville.Crtr.Browsing.UI {
|
namespace Cryville.Crtr.Browsing.UI {
|
||||||
public class ResourceBrowserMaster : MonoBehaviour {
|
public class ResourceBrowserMaster : MonoBehaviour {
|
||||||
@@ -21,8 +19,12 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
BrowserTab _currentTab;
|
BrowserTab _currentTab;
|
||||||
readonly Dictionary<BrowserTab, ResourceBrowser> _tabs = new Dictionary<BrowserTab, ResourceBrowser>();
|
readonly Dictionary<BrowserTab, ResourceBrowser> _tabs = new Dictionary<BrowserTab, ResourceBrowser>();
|
||||||
|
|
||||||
|
public ActionManager Actions { get; private set; }
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
m_mainBrowser.ResourceManager = new LegacyResourceManager(Settings.Default.GameDataPath);
|
Actions = new ActionManager();
|
||||||
|
Actions.Register(new PlayChartAction());
|
||||||
|
|
||||||
OnTabClicked(AddTab("Local", m_mainBrowser));
|
OnTabClicked(AddTab("Local", m_mainBrowser));
|
||||||
m_mainBrowser.Init(this, new LegacyResourceManager(Settings.Default.GameDataPath));
|
m_mainBrowser.Init(this, new LegacyResourceManager(Settings.Default.GameDataPath));
|
||||||
|
|
||||||
@@ -54,28 +56,5 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
public bool Back() {
|
public bool Back() {
|
||||||
return true; // TODO
|
return true; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
Master.Instance.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 = Path.Combine(detail.Meta.ruleset, ".umgr");
|
|
||||||
Settings.Default.LoadRulesetConfig = detail.Meta.ruleset + ".json";
|
|
||||||
Settings.Default.LoadChart = m_mainBrowser.ResourceManager.GetItemUri(id).LocalPath;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user