Remove ResourceItemMeta.
This commit is contained in:
@@ -1,12 +0,0 @@
|
|||||||
using Cryville.Common;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Cryville.Crtr.Browsing {
|
|
||||||
public struct ResourceItemMeta {
|
|
||||||
public bool IsDirectory { get; set; }
|
|
||||||
public AsyncDelivery<Texture2D> Icon { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string DescriptionMain { get; set; }
|
|
||||||
public string DescriptionSub { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f535064222dd08c4f8e52d6e9144079a
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -3,8 +3,8 @@ using UnityEngine;
|
|||||||
namespace Cryville.Crtr.Browsing.UI {
|
namespace Cryville.Crtr.Browsing.UI {
|
||||||
internal abstract class BrowserItem : MonoBehaviour {
|
internal abstract class BrowserItem : MonoBehaviour {
|
||||||
public int? Id { get; private set; }
|
public int? Id { get; private set; }
|
||||||
protected ResourceItemMeta meta;
|
protected ChartDetail meta;
|
||||||
internal void Load(int id, ResourceItemMeta item, bool selected) {
|
internal void Load(int id, ChartDetail item, bool selected) {
|
||||||
OnReset();
|
OnReset();
|
||||||
Id = id;
|
Id = id;
|
||||||
meta = item;
|
meta = item;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
Sprite m_iconPlaceholder;
|
Sprite m_iconPlaceholder;
|
||||||
#pragma warning restore IDE0044
|
#pragma warning restore IDE0044
|
||||||
|
|
||||||
bool _dir;
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
Image m_icon;
|
Image m_icon;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
@@ -29,7 +28,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
OnReset();
|
OnReset();
|
||||||
}
|
}
|
||||||
protected override void OnReset() {
|
protected override void OnReset() {
|
||||||
if (meta.Icon != null) meta.Icon.Cancel();
|
if (meta.Cover != null) meta.Cover.Cancel();
|
||||||
if (m_icon.sprite != null && m_icon.sprite != m_iconPlaceholder) {
|
if (m_icon.sprite != null && m_icon.sprite != m_iconPlaceholder) {
|
||||||
Destroy(m_icon.sprite.texture);
|
Destroy(m_icon.sprite.texture);
|
||||||
Destroy(m_icon.sprite);
|
Destroy(m_icon.sprite);
|
||||||
@@ -38,11 +37,16 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLoad(bool selected) {
|
protected override void OnLoad(bool selected) {
|
||||||
_dir = meta.IsDirectory;
|
|
||||||
m_icon.sprite = m_iconPlaceholder;
|
m_icon.sprite = m_iconPlaceholder;
|
||||||
if (meta.Icon != null) meta.Icon.Destination = DisplayCover;
|
if (meta.Cover != null) meta.Cover.Destination = DisplayCover;
|
||||||
m_title.text = meta.Name;
|
if (meta.Meta != null) {
|
||||||
m_desc.text = string.Format("{0}\n{1}", meta.DescriptionMain, meta.DescriptionSub);
|
m_title.text = meta.Meta.name;
|
||||||
|
m_desc.text = meta.Meta.song.name;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_title.text = "<color=#ff0000>Invalid resource</color>";
|
||||||
|
m_desc.text = string.Empty;
|
||||||
|
}
|
||||||
if (selected) _tweener.EnterState("Selected");
|
if (selected) _tweener.EnterState("Selected");
|
||||||
}
|
}
|
||||||
private void DisplayCover(bool succeeded, Texture2D tex) {
|
private void DisplayCover(bool succeeded, Texture2D tex) {
|
||||||
@@ -53,8 +57,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
public void OnClick() {
|
public void OnClick() {
|
||||||
if (Id == null) return;
|
if (Id == null) return;
|
||||||
var resourceBrowser = GetComponentInParent<PathedResourceBrowser>();
|
var resourceBrowser = GetComponentInParent<PathedResourceBrowser>();
|
||||||
if (_dir) resourceBrowser.OnDirectoryItemClicked(Id.Value);
|
resourceBrowser.OnObjectItemClicked(Id.Value);
|
||||||
else resourceBrowser.OnObjectItemClicked(Id.Value);
|
|
||||||
}
|
}
|
||||||
public void OnPointerClick(PointerEventData eventData) {
|
public void OnPointerClick(PointerEventData eventData) {
|
||||||
OnClick();
|
OnClick();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
bi.Load(id, item, _selectedItems.Contains(id));
|
bi.Load(id, item, _selectedItems.Contains(id));
|
||||||
}
|
}
|
||||||
catch (Exception) {
|
catch (Exception) {
|
||||||
bi.Load(id, new ResourceItemMeta { Name = "<color=#ff0000>Invalid resource</color>" }, _selectedItems.Contains(id));
|
bi.Load(id, default(ChartDetail), _selectedItems.Contains(id));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user