拆分 UIController 组装 Context 职责 + 描述文本滚动展示
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using GeometryTD.CustomEvent;
|
||||
using GeometryTD.Definition;
|
||||
using GameFramework.Event;
|
||||
using GeometryTD.CustomUtility;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public sealed class ShopFormController : UIFormControllerCommonBase<ShopFormContext, ShopForm>
|
||||
public sealed partial class ShopFormController : UIFormControllerCommonBase<ShopFormContext, ShopForm>
|
||||
{
|
||||
private ShopFormUseCase _useCase;
|
||||
|
||||
@@ -134,56 +133,5 @@ namespace GeometryTD.UI
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ShopFormContext BuildContext(ShopFormRawData rawData)
|
||||
{
|
||||
GoodsItemContext[] goodsItemContexts = System.Array.Empty<GoodsItemContext>();
|
||||
if (rawData?.GoodsItems != null && rawData.GoodsItems.Count > 0)
|
||||
{
|
||||
goodsItemContexts = new GoodsItemContext[rawData.GoodsItems.Count];
|
||||
for (int i = 0; i < rawData.GoodsItems.Count; i++)
|
||||
{
|
||||
GoodsItemRawData item = rawData.GoodsItems[i];
|
||||
goodsItemContexts[i] = new GoodsItemContext
|
||||
{
|
||||
GoodsIndex = item?.GoodsIndex ?? i,
|
||||
Title = item?.Title ?? string.Empty,
|
||||
TypeText = item?.TypeText ?? string.Empty,
|
||||
Description = BuildDescription(item),
|
||||
TagTexts = BuildTagTexts(item),
|
||||
PurchaseButtonText = item != null && item.IsPurchased ? "已购买" : $"购买 {item?.Price ?? 0}",
|
||||
CanPurchase = item != null && !item.IsPurchased,
|
||||
IconAreaContext = item?.IconAreaContext
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return new ShopFormContext
|
||||
{
|
||||
GoldText = $"金币: {rawData?.PlayerGold ?? 0}",
|
||||
GoodsItems = goodsItemContexts
|
||||
};
|
||||
}
|
||||
|
||||
private static string BuildDescription(GoodsItemRawData rawData)
|
||||
{
|
||||
string baseDescription = rawData?.Description ?? string.Empty;
|
||||
string tagDescription = TagDisplayUtility.BuildTagDescriptionText(rawData?.Tags);
|
||||
if (string.IsNullOrWhiteSpace(tagDescription))
|
||||
{
|
||||
return baseDescription;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(baseDescription))
|
||||
{
|
||||
return tagDescription;
|
||||
}
|
||||
|
||||
return $"{baseDescription}\n{tagDescription}";
|
||||
}
|
||||
|
||||
private static string[] BuildTagTexts(GoodsItemRawData rawData)
|
||||
{
|
||||
return TagDisplayUtility.BuildTagTexts(rawData?.Tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user