重构:统一 UI 模块目录结构规范
- 事件命名规范化:RefreshEventArgs → LevelUpRefreshEventArgs - LevelUp 子组件目录调整:LevelUpRewardItem + LevelUpRewardItemContext 移动到 LevelUp/ - Shop 子组件目录调整:DisplayItem/DisplayListArea/GoodsItem/ShopGoodsItem 及其 Context/RawData 全部移动到 Shop/ - 删除冗余文件:LevelUpRewardItemRawData(从未被使用) - 新增 ObjectPool 目录结构 - 更新 LevelUpController 和 LevelUpForm 中的事件引用
This commit is contained in:
@@ -21,14 +21,14 @@ namespace SepCore.UI
|
||||
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Subscribe(RefreshEventArgs.EventId, OnRefresh);
|
||||
GameEntry.Event.Subscribe(LevelUpPropSelectedEventArgs.EventId, OnLevelUpPropSelected);
|
||||
GameEntry.Event.Subscribe(LevelUpRefreshEventArgs.EventId, LevelUpRefresh);
|
||||
GameEntry.Event.Subscribe(LevelUpPropSelectedEventArgs.EventId, LevelUpPropSelected);
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(RefreshEventArgs.EventId, OnRefresh);
|
||||
GameEntry.Event.Unsubscribe(LevelUpPropSelectedEventArgs.EventId, OnLevelUpPropSelected);
|
||||
GameEntry.Event.Unsubscribe(LevelUpRefreshEventArgs.EventId, LevelUpRefresh);
|
||||
GameEntry.Event.Unsubscribe(LevelUpPropSelectedEventArgs.EventId, LevelUpPropSelected);
|
||||
}
|
||||
|
||||
private static LevelUpContext BuildContext(LevelUpRawData rawData)
|
||||
@@ -144,14 +144,14 @@ namespace SepCore.UI
|
||||
await OpenUIAsync(rawData);
|
||||
}
|
||||
|
||||
private void OnRefresh(object sender, GameEventArgs e)
|
||||
private void LevelUpRefresh(object sender, GameEventArgs e)
|
||||
{
|
||||
if (sender is not LevelUpForm levelUpForm || levelUpForm != Form)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e is not RefreshEventArgs args)
|
||||
if (e is not LevelUpRefreshEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ namespace SepCore.UI
|
||||
RefreshRewardListAsync(args.Cost).Forget();
|
||||
}
|
||||
|
||||
private void OnLevelUpPropSelected(object sender, GameEventArgs e)
|
||||
private void LevelUpPropSelected(object sender, GameEventArgs e)
|
||||
{
|
||||
if (sender is not LevelUpForm levelUpForm || levelUpForm != Form)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace SepCore.UI
|
||||
|
||||
public void OnRefreshButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, RefreshEventArgs.Create(_context.RefreshPrice));
|
||||
GameEntry.Event.Fire(this, LevelUpRefreshEventArgs.Create(_context.RefreshPrice));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class LevelUpRewardItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private IconArea _iconArea;
|
||||
|
||||
[SerializeField] private TMP_Text _titleText;
|
||||
|
||||
[SerializeField] private TMP_Text _typeText;
|
||||
|
||||
[SerializeField] private TMP_Text _descriptionText;
|
||||
|
||||
private LevelUpRewardItemContext _context;
|
||||
|
||||
|
||||
public void Init(LevelUpRewardItemContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
Log.Error("LevelUpPropContext context is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
_context = context;
|
||||
|
||||
if (_titleText != null) _titleText.text = context.Title;
|
||||
if (_descriptionText != null) _descriptionText.text = context.Description;
|
||||
if (_iconArea != null) _iconArea.OnInit(context.Icon, context.ItemRarity);
|
||||
|
||||
LoadIcon(_context.IconAssetName).Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid LoadIcon(string iconAssetName)
|
||||
{
|
||||
if (_iconArea == null) return;
|
||||
|
||||
if (string.IsNullOrEmpty(iconAssetName)) return;
|
||||
|
||||
var sprite = await GameEntry.SpriteCache.GetSprite(iconAssetName);
|
||||
_iconArea.SetIcon(sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 237d64392d274c14f9f5c81b54122a93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class LevelUpRewardItemContext : UIContext
|
||||
{
|
||||
public string Title;
|
||||
public Sprite Icon;
|
||||
public ItemRarity ItemRarity;
|
||||
public string Description;
|
||||
public string IconAssetName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 424ceeba7cae4fa4faaeef9035f31e31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user