Clean up hardcoded UI paths.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Cryville.Common.Unity.UI;
|
||||
using Cryville.Crtr.Config.UI;
|
||||
using Cryville.Crtr.UI;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,57 +13,32 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
private Button m_configButton;
|
||||
[SerializeField]
|
||||
private ConfigPanelMaster m_configPanel;
|
||||
[SerializeField]
|
||||
private PathedResourceBrowser m_mainBrowser;
|
||||
[SerializeField]
|
||||
private DetailPanel m_detailPanel;
|
||||
|
||||
private DockLayoutGroup _group;
|
||||
public ResourceBrowser MainBrowser { get; private set; }
|
||||
private DetailPanel _detailPanel;
|
||||
readonly List<ResourceBrowserUnit> _units = new List<ResourceBrowserUnit>();
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
_group = GetComponent<DockLayoutGroup>();
|
||||
MainBrowser = transform.GetChild(0).GetComponent<ResourceBrowser>();
|
||||
MainBrowser.ResourceManager = new LegacyResourceManager(Settings.Default.GameDataPath);
|
||||
_detailPanel = transform.GetChild(1).GetComponent<DetailPanel>();
|
||||
m_mainBrowser.ResourceManager = new LegacyResourceManager(Settings.Default.GameDataPath);
|
||||
_units.Add(MainBrowser);
|
||||
_units.Add(_detailPanel);
|
||||
}
|
||||
|
||||
int _slideDest = 0;
|
||||
void Update() {
|
||||
var cv = _group.SlideIndex;
|
||||
_group.SlideIndex = (cv - _slideDest) * 0.86f + _slideDest;
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
public void ShowDetail(int id, ChartDetail detail) {
|
||||
SlideIntoView(1);
|
||||
_detailPanel.Load(id, detail);
|
||||
// SlideIntoView(1);
|
||||
m_detailPanel.Load(id, detail);
|
||||
m_playButton.gameObject.SetActive(true);
|
||||
m_configButton.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
/*[Obsolete]
|
||||
public void ShowSettings(int id, ChartDetail detail) {
|
||||
SlideIntoView(2);
|
||||
_settingsPanel.Load(id, detail);
|
||||
}*/
|
||||
|
||||
public bool Back() {
|
||||
if (_slideDest == 0) return false;
|
||||
SlideIntoView(_slideDest - 1);
|
||||
// if (_slideDest == 0) return false;
|
||||
// SlideIntoView(_slideDest - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SlideIntoView(int v) {
|
||||
v = Mathf.Clamp(v, 0, _units.Count - 1);
|
||||
var cv = _group.SlideIndex;
|
||||
if (cv < v) _slideDest = v - 1;
|
||||
else _slideDest = v;
|
||||
_units[_slideDest].SlideToLeft();
|
||||
_units[_slideDest + 1].SlideToRight();
|
||||
}
|
||||
|
||||
public void Open(int id, ChartDetail detail) {
|
||||
SetDataSettings(id, detail);
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
@@ -85,7 +59,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
void SetDataSettings(int id, ChartDetail detail) {
|
||||
Settings.Default.LoadRuleset = detail.Meta.ruleset + "/.umgr";
|
||||
Settings.Default.LoadRulesetConfig = detail.Meta.ruleset + ".json";
|
||||
Settings.Default.LoadChart = MainBrowser.ResourceManager.GetItemPath(id);
|
||||
Settings.Default.LoadChart = m_mainBrowser.ResourceManager.GetItemPath(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user