补全 UI 设计
- `ItemDescForm` 道具详细信息面板,目前还未添加 DescText 内容的赋值 - `RepoForm` 道具入槽逻辑调整,为了适应 `ItemDescForm` 的点击打开逻辑,点击道具自动匹配槽位改成拖动道具到相应槽位 - 添加了一系列图片素材
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
using System.Collections.Generic;
|
||||
using GameFramework.Event;
|
||||
using GeometryTD.Definition;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public class ItemDescFormController : UIFormControllerCommonBase<
|
||||
ItemDescFormContext, ItemDescForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.ItemDescForm;
|
||||
|
||||
|
||||
protected override void RefreshUI(ItemDescForm form, ItemDescFormContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
protected override void CloseLoadedFormDirect(ItemDescForm form)
|
||||
{
|
||||
GameEntry.UI.CloseUIForm(form);
|
||||
}
|
||||
|
||||
private static ItemDescFormContext BuildContext(ItemDescFormRawData rawData)
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ItemDescFormContext
|
||||
{
|
||||
Title = rawData.Title,
|
||||
TypeText = rawData.TypeText,
|
||||
Description = rawData.Description,
|
||||
Price = rawData.Price,
|
||||
TargetPos = rawData.TargetPos,
|
||||
Tags = BuildTags(rawData.Tags)
|
||||
};
|
||||
}
|
||||
|
||||
private static List<TagType> BuildTags(TagType[] tags)
|
||||
{
|
||||
if (tags == null || tags.Length <= 0)
|
||||
{
|
||||
return new List<TagType>();
|
||||
}
|
||||
|
||||
return new List<TagType>(tags);
|
||||
}
|
||||
|
||||
public int? OpenUI(ItemDescFormRawData rawData)
|
||||
{
|
||||
ItemDescFormContext context = BuildContext(rawData);
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
if (userData is ItemDescFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData is ItemDescFormRawData rawData)
|
||||
{
|
||||
return OpenUI(rawData);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("ItemDescFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(Context);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (!(useCase is ItemDescFormUseCase))
|
||||
{
|
||||
Log.Error("ItemDescForm.BindUseCase() useCase is invalid.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2970dfbfc4901234ca38bda4d94d01d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,6 +3,7 @@ using GeometryTD.CustomEvent;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
using GameFramework.Event;
|
||||
using GeometryTD.CustomUtility;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
@@ -132,8 +133,10 @@ namespace GeometryTD.UI
|
||||
RewardId = rawItem.RewardId,
|
||||
IconArea = new IconAreaContext
|
||||
{
|
||||
ComponentSlotType = rawItem.SlotType,
|
||||
Icon = rawItem.Icon,
|
||||
Rarity = rawItem.Rarity
|
||||
Rarity = rawItem.Rarity,
|
||||
Color = ResolveIconColor(rawItem)
|
||||
},
|
||||
Title = rawItem.Title ?? string.Empty,
|
||||
TypeText = ResolveTypeText(rawItem),
|
||||
@@ -147,6 +150,16 @@ namespace GeometryTD.UI
|
||||
return contexts;
|
||||
}
|
||||
|
||||
private static Color ResolveIconColor(RewardSelectItemRawData rawItem)
|
||||
{
|
||||
if (rawItem?.SourceItem == null)
|
||||
{
|
||||
return Color.white;
|
||||
}
|
||||
|
||||
return IconColorGenerator.GenerateForComponent(rawItem.SourceItem);
|
||||
}
|
||||
|
||||
private static string ResolveTypeText(RewardSelectItemRawData rawItem)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(rawItem.TypeText))
|
||||
|
||||
Reference in New Issue
Block a user