ui基本完毕,修了一大把的bug

This commit is contained in:
2026-07-13 02:28:39 +08:00
parent 1e20d73e90
commit fd22501f71
958 changed files with 378289 additions and 41038 deletions
+110 -6
View File
@@ -49,10 +49,12 @@ public class idolUpgrade : MonoBehaviour
public Text upgradeText;
private readonly List<materialPrefab> spawnedMaterials = new List<materialPrefab>();
private readonly Dictionary<materialPrefab, expBottlesSO> spawnedBottleBindings = new Dictionary<materialPrefab, expBottlesSO>();
private expBottlesSO selectedBottle;
private DushMaterialKind? selectedBreakthroughMaterialKind;
private bool isShowingBreakthrough;
private string lastOperationSuccessMessage;
private storeItemSO[] cachedStoreItems;
private static readonly Color UpgradeWarningColor = new Color32(120, 36, 36, 255);
private static readonly Color UpgradeMaxColor = new Color32(205, 170, 64, 255);
@@ -220,7 +222,7 @@ public class idolUpgrade : MonoBehaviour
return;
}
string bottleName = selectedBottle.expBottleName;
string bottleName = GetDisplayName(selectedBottle);
string failure;
int consumedCount;
int grantedExp;
@@ -263,11 +265,13 @@ public class idolUpgrade : MonoBehaviour
item.Bind(
bottle.expBottleSprite,
bottle.expBottleName,
GetDisplayName(bottle),
Mathf.Max(0, ExpBottleLedger.EnsureInstance().GetCount(bottle.bottleKind)).ToString(),
bottle.itemRarity,
bottle == selectedBottle,
true,
() => SelectBottle(bottle));
spawnedBottleBindings[item] = bottle;
}
return true;
@@ -337,9 +341,12 @@ public class idolUpgrade : MonoBehaviour
? (requirement.bottle != null ? requirement.bottle.expBottleSprite : null)
: (requirement.material != null ? requirement.material.growthMaterialSprite : null),
requirement.isBottleRequirement
? (requirement.bottle != null ? requirement.bottle.expBottleName : requirement.bottleKind.ToString())
: (requirement.material != null ? requirement.material.growthMaterialName : requirement.materialKind.ToString()),
? GetDisplayName(requirement.bottle, requirement.bottleKind)
: GetDisplayName(requirement.material, requirement.materialKind),
amountText,
requirement.isBottleRequirement
? (requirement.bottle != null ? requirement.bottle.itemRarity : ItemRarity.None)
: (requirement.material != null ? requirement.material.itemRarity : ItemRarity.None),
ShouldHighlightBreakthroughRequirement(requirement, requiresFullSubmission, bundledSelection),
!requiresFullSubmission,
() => SelectBreakthroughMaterial(requirement.materialKind));
@@ -356,7 +363,7 @@ public class idolUpgrade : MonoBehaviour
return;
}
SetInfoText(selectedBottle.expBottleName);
SetInfoText(GetDisplayName(selectedBottle));
SetConfirmInteractable(true);
SetConfirmButtonText("使用");
}
@@ -372,7 +379,10 @@ public class idolUpgrade : MonoBehaviour
continue;
}
bool isSelected = bottle != null && item.materialName != null && item.materialName.text == bottle.expBottleName;
expBottlesSO boundBottle;
bool isSelected = bottle != null
&& spawnedBottleBindings.TryGetValue(item, out boundBottle)
&& boundBottle == bottle;
item.SetSelected(isSelected);
}
@@ -1202,6 +1212,100 @@ public class idolUpgrade : MonoBehaviour
}
spawnedMaterials.Clear();
spawnedBottleBindings.Clear();
}
private string GetDisplayName(expBottlesSO bottle)
{
return GetDisplayName(bottle, bottle != null ? bottle.bottleKind : default);
}
private string GetDisplayName(expBottlesSO bottle, ExpBottleKind fallbackKind)
{
if (bottle != null)
{
storeItemSO storeItem = FindStoreItemForBottle(bottle);
if (storeItem != null && !string.IsNullOrWhiteSpace(storeItem.itemName))
{
return storeItem.itemName.Trim();
}
if (!string.IsNullOrWhiteSpace(bottle.expBottleName))
{
return bottle.expBottleName.Trim();
}
}
return fallbackKind.ToString().Trim();
}
private string GetDisplayName(growthMaterialSO material, DushMaterialKind fallbackKind)
{
if (material != null)
{
storeItemSO storeItem = FindStoreItemForGrowthMaterial(material);
if (storeItem != null && !string.IsNullOrWhiteSpace(storeItem.itemName))
{
return storeItem.itemName.Trim();
}
if (!string.IsNullOrWhiteSpace(material.growthMaterialName))
{
return material.growthMaterialName.Trim();
}
}
return fallbackKind.ToString().Trim();
}
private storeItemSO FindStoreItemForBottle(expBottlesSO bottle)
{
if (bottle == null)
{
return null;
}
storeItemSO[] storeItems = GetStoreItems();
for (int i = 0; i < storeItems.Length; i++)
{
storeItemSO storeItem = storeItems[i];
if (storeItem != null && storeItem.associatedExpBottle == bottle)
{
return storeItem;
}
}
return null;
}
private storeItemSO FindStoreItemForGrowthMaterial(growthMaterialSO material)
{
if (material == null)
{
return null;
}
storeItemSO[] storeItems = GetStoreItems();
for (int i = 0; i < storeItems.Length; i++)
{
storeItemSO storeItem = storeItems[i];
if (storeItem != null && storeItem.associatedGrowthMaterial == material)
{
return storeItem;
}
}
return null;
}
private storeItemSO[] GetStoreItems()
{
if (cachedStoreItems == null)
{
cachedStoreItems = RuntimeResourcesCache.LoadAllStoreItems() ?? Array.Empty<storeItemSO>();
}
return cachedStoreItems;
}
private void SetInfoText(string content)
+51 -3
View File
@@ -7,6 +7,8 @@ public class materialPrefab : MonoBehaviour
{
[Header("imgs")]
public Image boarder;
public Image qualityBorder;
public Sprite[] qualityBorderSprites;
public Image materialImg;
public Button materialButton;
public TextMeshProUGUI materialAmount;
@@ -23,7 +25,7 @@ public class materialPrefab : MonoBehaviour
}
}
public void Bind(Sprite sprite, string displayName, string amountText, bool selected, bool interactable, Action onClick)
public void Bind(Sprite sprite, string displayName, string amountText, ItemRarity rarity, bool selected, bool interactable, Action onClick)
{
clickAction = onClick;
@@ -43,6 +45,7 @@ public class materialPrefab : MonoBehaviour
materialAmount.text = amountText ?? string.Empty;
}
ApplyQualityBorder(rarity);
SetSelected(selected);
if (materialButton != null)
@@ -51,13 +54,23 @@ public class materialPrefab : MonoBehaviour
}
}
public void BindOwnedRequired(Sprite sprite, string displayName, int ownedAmount, int requiredAmount, bool selected, bool interactable, Action onClick)
public void Bind(Sprite sprite, string displayName, string amountText, bool selected, bool interactable, Action onClick)
{
Bind(sprite, displayName, amountText, ItemRarity.None, selected, interactable, onClick);
}
public void BindOwnedRequired(Sprite sprite, string displayName, int ownedAmount, int requiredAmount, ItemRarity rarity, bool selected, bool interactable, Action onClick)
{
string ownedText = ownedAmount < requiredAmount
? $"<color=#FF4D4D>{Mathf.Max(0, ownedAmount)}</color>"
: Mathf.Max(0, ownedAmount).ToString();
string amountText = $"{ownedText}/{Mathf.Max(0, requiredAmount)}";
Bind(sprite, displayName, amountText, selected, interactable, onClick);
Bind(sprite, displayName, amountText, rarity, selected, interactable, onClick);
}
public void BindOwnedRequired(Sprite sprite, string displayName, int ownedAmount, int requiredAmount, bool selected, bool interactable, Action onClick)
{
BindOwnedRequired(sprite, displayName, ownedAmount, requiredAmount, ItemRarity.None, selected, interactable, onClick);
}
public void SetSelected(bool selected)
@@ -68,6 +81,41 @@ public class materialPrefab : MonoBehaviour
}
}
private void ApplyQualityBorder(ItemRarity rarity)
{
if (qualityBorder == null)
{
return;
}
Sprite sprite = ResolveQualityBorderSprite(rarity);
qualityBorder.sprite = sprite;
qualityBorder.enabled = sprite != null;
}
private Sprite ResolveQualityBorderSprite(ItemRarity rarity)
{
if (qualityBorderSprites != null && qualityBorderSprites.Length > 0)
{
int enumIndex = (int)rarity;
if (enumIndex >= 0 && enumIndex < qualityBorderSprites.Length)
{
Sprite sprite = qualityBorderSprites[enumIndex];
if (sprite != null)
{
return sprite;
}
}
if (qualityBorderSprites[0] != null)
{
return qualityBorderSprites[0];
}
}
return null;
}
private void HandleClick()
{
if (materialButton != null && !materialButton.interactable)
@@ -34,8 +34,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -49.994003}
m_SizeDelta: {x: 0, y: -59.836}
m_AnchoredPosition: {x: 0.25, y: -53.308105}
m_SizeDelta: {x: 10, y: -62.3838}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7708545175036600530
CanvasRenderer:
@@ -66,11 +66,11 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: bd4be44636ad6c24a9b117a7108a75e9, type: 3}
m_FontSize: 12
m_Font: {fileID: 12800000, guid: d254d20d93651ae448ff13d10dff30ab, type: 3}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 1
m_MinSize: 1
m_MinSize: 8
m_MaxSize: 16
m_Alignment: 4
m_AlignByGeometry: 0
@@ -142,6 +142,16 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
boarder: {fileID: 4301219412316587214}
qualityBorder: {fileID: 1657374318142278237}
qualityBorderSprites:
- {fileID: 21300000, guid: c1d3013bdbb080f4f8806bc4d6c58db2, type: 3}
- {fileID: 21300000, guid: 0edbf3fabc7d78e43b1c48516f08667a, type: 3}
- {fileID: 21300000, guid: d878370cc5eb0cb409882bb8e6fd7537, type: 3}
- {fileID: 21300000, guid: 3ce075becece84045b16ac2fe217f415, type: 3}
- {fileID: 21300000, guid: 0eab00cf603f6694c89603352de122e6, type: 3}
- {fileID: 21300000, guid: 5ce43da28e0e4464a8a3bd79cfdd18de, type: 3}
- {fileID: 21300000, guid: 01f1bbba4db2f5042b08ca58ec475d34, type: 3}
- {fileID: 21300000, guid: 3c5a917f2e9787643a2bfc1c8f394784, type: 3}
materialImg: {fileID: 6433794917799223522}
materialButton: {fileID: 6223024646424990969}
materialAmount: {fileID: 1761526427795409056}
@@ -330,8 +340,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 80, y: 80}
m_AnchoredPosition: {x: 0.25, y: 0}
m_SizeDelta: {x: 90, y: 90}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &334864567550305053
CanvasRenderer:
@@ -361,7 +371,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 9ebd9ce7600225b48a92c3900b8188fc, type: 3}
m_Sprite: {fileID: 21300000, guid: c123f863b7b5604489f0ddc316ae874c, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
@@ -574,8 +584,8 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 7f3b1220317607e44bbb8f0e1998044a, type: 3}
m_Type: 1
m_Sprite: {fileID: 21300000, guid: 0eab00cf603f6694c89603352de122e6, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4