重构
- 统一 ItemDescForm/RewardItem/GoodsItem 的描述格式 - 减少组件属性的 Clone 数量,目前只在合并仓库、组装防御塔时才进行复制 - 删除先前留下的冗余 fallback 代码
This commit is contained in:
@@ -148,8 +148,8 @@ namespace GeometryTD.UI
|
||||
GoodsIndex = item?.GoodsIndex ?? i,
|
||||
Title = item?.Title ?? string.Empty,
|
||||
TypeText = item?.TypeText ?? string.Empty,
|
||||
Description = item?.Description ?? string.Empty,
|
||||
TagTexts = BuildTagTexts(item?.Tags),
|
||||
Description = BuildDescription(item),
|
||||
TagTexts = BuildTagTexts(item),
|
||||
PurchaseButtonText = item != null && item.IsPurchased ? "已购买" : $"购买 {item?.Price ?? 0}",
|
||||
CanPurchase = item != null && !item.IsPurchased,
|
||||
IconAreaContext = item?.IconAreaContext
|
||||
@@ -164,9 +164,26 @@ namespace GeometryTD.UI
|
||||
};
|
||||
}
|
||||
|
||||
private static string[] BuildTagTexts(TagType[] tags)
|
||||
private static string BuildDescription(GoodsItemRawData rawData)
|
||||
{
|
||||
return TagDisplayUtility.BuildTagTexts(tags);
|
||||
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