引入 UISerializationRoot 和 Item
- 完成 MenuForm 和 SelectRoleForm 的迁移
This commit is contained in:
@@ -29,7 +29,7 @@ namespace SepCore.UI
|
||||
ShowRecycleButton = false;
|
||||
}
|
||||
|
||||
public ItemTooltipContext(ItemTooltipRawData rawData)
|
||||
public ItemTooltipContext(ItemTooltipRawData rawData) : this()
|
||||
{
|
||||
Index = rawData.Index;
|
||||
ItemType = rawData.ItemType;
|
||||
@@ -37,19 +37,15 @@ namespace SepCore.UI
|
||||
Price = rawData.Price;
|
||||
TargetPos = rawData.TargetPos;
|
||||
ShowRecycleButton = rawData.OnRecycle != null;
|
||||
if (ItemType == ItemType.None)
|
||||
{
|
||||
IconAssetName = string.Empty;
|
||||
Title = string.Empty;
|
||||
}
|
||||
else if (ItemType == ItemType.Weapon)
|
||||
|
||||
if (ItemType == ItemType.Weapon)
|
||||
{
|
||||
var data = rawData.WeaponData;
|
||||
IconAssetName = data.IconAssetName;
|
||||
Title = data.Title;
|
||||
Description = ItemDescUtility.CreateWeaponDescription(data);
|
||||
}
|
||||
else
|
||||
else if (ItemType == ItemType.Prop)
|
||||
{
|
||||
var data = rawData.PropData;
|
||||
IconAssetName = data.IconAssetName;
|
||||
|
||||
@@ -71,7 +71,6 @@ namespace SepCore.UI
|
||||
ItemTooltipContext context = BuildContext(rawData);
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("ItemTooltipController.OpenUIAsync() rawData is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,7 +88,7 @@ namespace SepCore.UI
|
||||
{
|
||||
if (useCase != null)
|
||||
{
|
||||
Log.Warning("ItemTooltipController does not use a use case.");
|
||||
Log.Error("ItemTooltipController does not use a use case.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,33 +40,21 @@ namespace SepCore.UI
|
||||
|
||||
public async UniTaskVoid RefreshUI(ItemTooltipContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("ItemTooltipForm context is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
_context = context;
|
||||
|
||||
_targetPos = ConvertWorldToAnchored(_context.TargetPos);
|
||||
Log.Info($"{_context.TargetPos}->{_targetPos}");
|
||||
|
||||
if (_content != null)
|
||||
{
|
||||
_content.anchoredPosition3D = _targetPos;
|
||||
}
|
||||
_content.anchoredPosition3D = _targetPos;
|
||||
|
||||
_itemTitle.text = _context.Title ?? string.Empty;
|
||||
_itemTypeText.text = BuildTypeText(_context.ItemType) ?? string.Empty;
|
||||
_itemDescription.text = _context.Description ?? string.Empty;
|
||||
_itemTitle.text = _context.Title;
|
||||
_itemTypeText.text = BuildTypeText(_context.ItemType);
|
||||
_itemDescription.text = _context.Description;
|
||||
_itemPrice.text = $"{_context.Price} <sprite name=\"coin\" index=0>";
|
||||
|
||||
if (_recycleButton != null)
|
||||
{
|
||||
_recycleButton.gameObject.SetActive(_context.ShowRecycleButton);
|
||||
}
|
||||
_recycleButton.gameObject.SetActive(_context.ShowRecycleButton);
|
||||
|
||||
if (_iconArea != null && !string.IsNullOrEmpty(_context.IconAssetName))
|
||||
if (!string.IsNullOrEmpty(_context.IconAssetName))
|
||||
{
|
||||
string iconAssetName = _context.IconAssetName;
|
||||
var sprite = await SpriteLoader.LoadSpriteByKeyAsync(iconAssetName);
|
||||
@@ -103,12 +91,7 @@ namespace SepCore.UI
|
||||
|
||||
private void ResizeToFitContent()
|
||||
{
|
||||
if (!_autoResizeHeight || _content == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_itemDescription == null)
|
||||
if (!_autoResizeHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -126,11 +109,6 @@ namespace SepCore.UI
|
||||
|
||||
private void ApplyClampedTargetPos()
|
||||
{
|
||||
if (_content == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RectTransform parent = _content.parent as RectTransform;
|
||||
if (parent == null)
|
||||
{
|
||||
@@ -160,11 +138,6 @@ namespace SepCore.UI
|
||||
|
||||
private Vector3 ConvertWorldToAnchored(Vector3 worldPos)
|
||||
{
|
||||
if (_content == null)
|
||||
{
|
||||
return worldPos;
|
||||
}
|
||||
|
||||
RectTransform parent = _content.parent as RectTransform;
|
||||
if (parent == null)
|
||||
{
|
||||
@@ -192,7 +165,6 @@ namespace SepCore.UI
|
||||
|
||||
public void OnRecycleButtonClick()
|
||||
{
|
||||
if (_context == null) return;
|
||||
GameEntry.Event.Fire(this, ItemTooltipRecycleEventArgs.Create(_context.Index, _context.Price));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user