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 {
|
||||
internal abstract class BrowserItem : MonoBehaviour {
|
||||
public int? Id { get; private set; }
|
||||
protected ResourceItemMeta meta;
|
||||
internal void Load(int id, ResourceItemMeta item, bool selected) {
|
||||
protected ChartDetail meta;
|
||||
internal void Load(int id, ChartDetail item, bool selected) {
|
||||
OnReset();
|
||||
Id = id;
|
||||
meta = item;
|
||||
|
@@ -11,7 +11,6 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
Sprite m_iconPlaceholder;
|
||||
#pragma warning restore IDE0044
|
||||
|
||||
bool _dir;
|
||||
[SerializeField]
|
||||
Image m_icon;
|
||||
[SerializeField]
|
||||
@@ -29,7 +28,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
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) {
|
||||
Destroy(m_icon.sprite.texture);
|
||||
Destroy(m_icon.sprite);
|
||||
@@ -38,11 +37,16 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
}
|
||||
|
||||
protected override void OnLoad(bool selected) {
|
||||
_dir = meta.IsDirectory;
|
||||
m_icon.sprite = m_iconPlaceholder;
|
||||
if (meta.Icon != null) meta.Icon.Destination = DisplayCover;
|
||||
m_title.text = meta.Name;
|
||||
m_desc.text = string.Format("{0}\n{1}", meta.DescriptionMain, meta.DescriptionSub);
|
||||
if (meta.Cover != null) meta.Cover.Destination = DisplayCover;
|
||||
if (meta.Meta != null) {
|
||||
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");
|
||||
}
|
||||
private void DisplayCover(bool succeeded, Texture2D tex) {
|
||||
@@ -53,8 +57,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
public void OnClick() {
|
||||
if (Id == null) return;
|
||||
var resourceBrowser = GetComponentInParent<PathedResourceBrowser>();
|
||||
if (_dir) resourceBrowser.OnDirectoryItemClicked(Id.Value);
|
||||
else resourceBrowser.OnObjectItemClicked(Id.Value);
|
||||
resourceBrowser.OnObjectItemClicked(Id.Value);
|
||||
}
|
||||
public void OnPointerClick(PointerEventData eventData) {
|
||||
OnClick();
|
||||
|
@@ -44,7 +44,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
bi.Load(id, item, _selectedItems.Contains(id));
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user