88 lines
2.4 KiB
C#
88 lines
2.4 KiB
C#
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.");
|
|
}
|
|
}
|
|
}
|
|
}
|