优化 UI 效果

This commit is contained in:
2026-10-03 18:30:31 +08:00
parent e0488cc790
commit 0077e3449d
89 changed files with 58194 additions and 23636 deletions
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using SepCore.Event;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace SepCore.UI
@@ -55,11 +56,19 @@ namespace SepCore.UI
View.statForm.OnInit(context.StatContext);
context.NeedRefreshStat = false;
}
bool weaponCapacityFull = context.WeaponListContext.CurrentCount >= context.WeaponListContext.MaxCount;
foreach (ShopGoodsItem item in _goodsItems)
{
item.RefreshAvailability(context.PlayerCoin, weaponCapacityFull);
}
View.refreshButton.interactable = context.PlayerCoin >= context.RefreshPrice;
}
protected override void OnOpen(object userData)
{
base.OnOpen(userData);
SetAttributesVisible(false);
if (userData is not ShopContext context)
{
@@ -72,6 +81,7 @@ namespace SepCore.UI
protected override void OnClose(bool isShutdown, object userData)
{
SetAttributesVisible(false);
_context = null;
for (int i = 0; i < _goodsItems.Count; i++)
@@ -96,6 +106,9 @@ namespace SepCore.UI
View.continueButton.onClick.AddListener(OnContinueButtonClick);
View.refreshButton.onClick.AddListener(OnRefreshButtonClick);
View.attributeToggleButton.onClick.AddListener(ShowAttributes);
View.attributeCloseButton.onClick.AddListener(HideAttributes);
View.attributeDismissButton.onClick.AddListener(HideAttributes);
}
private void RefreshGoodsItems(List<GoodsItemContext> goodsItems)
@@ -112,8 +125,16 @@ namespace SepCore.UI
}
else
{
item.OnReset();
item.gameObject.SetActive(false);
if (i < goodsItems.Count)
{
item.MarkPurchased();
item.gameObject.SetActive(true);
}
else
{
item.OnReset();
item.gameObject.SetActive(false);
}
}
}
}
@@ -136,5 +157,40 @@ namespace SepCore.UI
{
GameEntry.Event.Fire(this, ShopRefreshEventArgs.Create(_context.RefreshPrice));
}
private void ShowAttributes()
{
SetAttributesVisible(true);
}
private void HideAttributes()
{
SetAttributesVisible(false);
}
private void SetAttributesVisible(bool visible)
{
View.attributeDrawer.gameObject.SetActive(visible);
View.attributeToggleButton.gameObject.SetActive(!visible);
}
protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
base.OnUpdate(elapseSeconds, realElapseSeconds);
if (!View.attributeDrawer.gameObject.activeSelf)
{
return;
}
#if ENABLE_INPUT_SYSTEM
var keyboard = UnityEngine.InputSystem.Keyboard.current;
if (keyboard != null && keyboard.escapeKey.wasPressedThisFrame)
#else
if (Input.GetKeyDown(KeyCode.Escape))
#endif
{
HideAttributes();
}
}
}
}