UI update 02

This commit is contained in:
FloatGaming
2026-06-30 21:21:30 +08:00
parent b2a1e307a4
commit f62f643cfc
1666 changed files with 211081 additions and 22799 deletions
+91 -6
View File
@@ -160,7 +160,12 @@ public class UI_Panel_Mail : MonoBehaviour
if (slot.mailTitle != null) slot.mailTitle.text = mail.mail_title;
if (slot.mailSender != null) slot.mailSender.text = mail.mail_sender;
if (slot.mailTime != null) slot.mailTime.text = mail.mail_date;
if (slot.mailImage != null) slot.mailImage.sprite = mail.mail_image;
if (slot.mailImage != null)
{
slot.mailImage.sprite = mail.mail_image;
}
slot.RefreshRewardsWithMailText(mail);
slot.RefreshRewardPreviews(mail);
TryBindServerMailImage(mail, slot);
UpdateSlotVisuals(slot, mail);
SetSelectedState(slot, false);
@@ -295,7 +300,8 @@ public class UI_Panel_Mail : MonoBehaviour
reward_description = rewardEntry.reward_description ?? string.Empty,
reward_key = rewardEntry.reward_key ?? string.Empty,
reward_store_item_id = rewardEntry.reward_store_item_id,
reward_image = null
reward_image = null,
reward_icon_url = rewardEntry.reward_icon_url ?? string.Empty
};
MailRewardGrantService.PopulateRewardDisplay(reward);
mail.rewardList.Add(reward);
@@ -418,10 +424,7 @@ public class UI_Panel_Mail : MonoBehaviour
var go = Instantiate(rewardSlotPrefab, content_Reward_Slot);
var slot = go.GetComponent<rewardSlotPrefab>();
if (slot == null) continue;
if (slot.rewardName != null) slot.rewardName.text = reward.rewardName;
if (slot.rewardAmount != null) slot.rewardAmount.text = reward.reward_ammount == 1 ? string.Empty : reward.reward_ammount.ToString();
if (slot.rewardIcon != null) slot.rewardIcon.sprite = reward.reward_image;
if (slot.detailText != null) slot.detailText.text = reward.reward_description;
slot.BindReward(reward);
if (slot.detailBtm != null) slot.detailBtm.SetActive(false);
}
@@ -486,17 +489,20 @@ public class UI_Panel_Mail : MonoBehaviour
if (mail.mail_image != null)
{
slot.mailImage.sprite = mail.mail_image;
SetMailImageVisible(slot, true);
return;
}
if (!_serverMailImageUrls.TryGetValue(mail.mail_id, out string url) || string.IsNullOrWhiteSpace(url))
{
SetMailImageVisible(slot, false);
return;
}
string normalizedUrl = NormalizeMailImageUrl(url);
if (string.IsNullOrWhiteSpace(normalizedUrl))
{
SetMailImageVisible(slot, false);
return;
}
@@ -504,6 +510,7 @@ public class UI_Panel_Mail : MonoBehaviour
{
mail.mail_image = cachedSprite;
slot.mailImage.sprite = cachedSprite;
SetMailImageVisible(slot, true);
return;
}
@@ -512,6 +519,7 @@ public class UI_Panel_Mail : MonoBehaviour
return;
}
SetMailImageVisible(slot, false);
StartCoroutine(LoadServerMailImageRoutine(normalizedUrl, mail, slot));
}
@@ -547,6 +555,7 @@ public class UI_Panel_Mail : MonoBehaviour
if (slot != null && slot.mailImage != null)
{
slot.mailImage.sprite = sprite;
SetMailImageVisible(slot, true);
}
}
finally
@@ -556,6 +565,20 @@ public class UI_Panel_Mail : MonoBehaviour
}
}
private static void SetMailImageVisible(mailSlotPrefab slot, bool visible)
{
if (slot == null || slot.mailImage == null)
{
return;
}
GameObject imageObject = slot.mailImage.gameObject;
if (imageObject != null && imageObject.activeSelf != visible)
{
imageObject.SetActive(visible);
}
}
string NormalizeMailImageUrl(string imageUrl)
{
string trimmed = imageUrl?.Trim() ?? string.Empty;
@@ -1287,6 +1310,53 @@ public static class MailRewardGrantService
}
}
public static bool TryGetRewardRarity(mail_so.rewardItem reward, out ItemRarity rarity)
{
rarity = ItemRarity.None;
if (reward == null)
{
return false;
}
EnsureAssetsLoaded();
int amount = Mathf.Max(1, reward.reward_ammount);
string rewardKey = string.IsNullOrWhiteSpace(reward.reward_key) ? string.Empty : reward.reward_key.Trim();
string rewardName = string.IsNullOrWhiteSpace(reward.rewardName) ? string.Empty : reward.rewardName.Trim();
if (TryFindStoreItemReference(reward, rewardKey, rewardName, out storeItemSO storeItem) && storeItem != null)
{
rarity = storeItem.itemRarity;
return true;
}
if (reward.reward_Type == mail_so.reward_type.expBottles_allies)
{
if (TryResolveExpBottle(reward, rewardKey, rewardName, amount, out ResolvedReward resolved) && resolved != null && resolved.ExpBottleAsset != null)
{
rarity = resolved.ExpBottleAsset.itemRarity;
return true;
}
}
else if (reward.reward_Type == mail_so.reward_type.growth_material)
{
if (TryResolveGrowthMaterial(reward, rewardKey, rewardName, amount, out ResolvedReward resolved) && resolved != null && resolved.GrowthMaterialAsset != null)
{
rarity = resolved.GrowthMaterialAsset.itemRarity;
return true;
}
}
else if (reward.reward_Type == mail_so.reward_type.equipment_consumable)
{
if (TryResolveEquipmentConsumable(reward, rewardKey, rewardName, amount, out ResolvedReward resolved) && resolved != null && resolved.EquipmentConsumableAsset != null)
{
rarity = resolved.EquipmentConsumableAsset.itemRarity;
return true;
}
}
return false;
}
public static bool TryGrantAll(mail_so mail, out string failureMessage)
{
failureMessage = string.Empty;
@@ -1482,6 +1552,21 @@ public static class MailRewardGrantService
{
StoreItemsByName[item.name] = item;
}
// expBottlesSO / growthMaterialSO / equipmentConsumableSO live outside Resources,
// so Resources.LoadAll returns nothing. Backfill from storeItemSO direct references instead.
if (item.associatedExpBottle != null && !ExpBottleAssets.ContainsKey(item.associatedExpBottle.bottleKind))
{
ExpBottleAssets[item.associatedExpBottle.bottleKind] = item.associatedExpBottle;
}
if (item.associatedGrowthMaterial != null && !GrowthMaterialAssets.ContainsKey(item.associatedGrowthMaterial.materialKind))
{
GrowthMaterialAssets[item.associatedGrowthMaterial.materialKind] = item.associatedGrowthMaterial;
}
if (item.associatedEquipmentConsumable != null && !EquipmentConsumableAssets.ContainsKey(item.associatedEquipmentConsumable.consumableKind))
{
EquipmentConsumableAssets[item.associatedEquipmentConsumable.consumableKind] = item.associatedEquipmentConsumable;
}
}
}