UI HUGE UPDATE
This commit is contained in:
+144
-105
@@ -50,7 +50,6 @@ public class uBag : MonoBehaviour
|
||||
[Header("OBJ")]
|
||||
public GameObject bagObj;
|
||||
public GameObject equipObj;
|
||||
public Button closeBagButton;
|
||||
|
||||
[Header("right panel")]
|
||||
public Image btmImg;
|
||||
@@ -58,7 +57,10 @@ public class uBag : MonoBehaviour
|
||||
public TextMeshProUGUI itemAmount;
|
||||
public Text itemName;
|
||||
public Text itemUse;
|
||||
public Text itemUsageLegacy;
|
||||
public Text itemDescription;
|
||||
public Image bottom_rarityImg;
|
||||
public Sprite[] bottom_rarityImg_sprites;
|
||||
|
||||
[Header("list")]
|
||||
public Transform itemParent;
|
||||
@@ -72,8 +74,10 @@ public class uBag : MonoBehaviour
|
||||
public int introductionHorizontalOffset = 12;
|
||||
|
||||
[Header("colors")]
|
||||
public bool useRarityColorForItemName = true;
|
||||
public Color fallbackColor = Color.white;
|
||||
public Sprite fallbackItemIcon;
|
||||
public Sprite fallbackBackgroundSprite;
|
||||
public ItemRarityColorConfigSO rarityColorConfig;
|
||||
|
||||
[Header("paths")]
|
||||
@@ -97,7 +101,6 @@ public class uBag : MonoBehaviour
|
||||
{
|
||||
InitializeToggleGroup();
|
||||
BindToggles();
|
||||
BindCloseButton();
|
||||
BindLedgerEvents();
|
||||
InitializeViewMode();
|
||||
SelectDefaultCategory();
|
||||
@@ -107,7 +110,6 @@ public class uBag : MonoBehaviour
|
||||
{
|
||||
InitializeToggleGroup();
|
||||
BindToggles();
|
||||
BindCloseButton();
|
||||
BindLedgerEvents();
|
||||
InitializeViewMode();
|
||||
Rebuild();
|
||||
@@ -120,7 +122,6 @@ public class uBag : MonoBehaviour
|
||||
UnbindToggle(preciousToggle, HandlePreciousChanged);
|
||||
UnbindToggle(otherToggle, HandleOtherChanged);
|
||||
UnbindToggle(equipSystemToggle, HandleEquipSystemChanged);
|
||||
UnbindCloseButton();
|
||||
UnbindLedgerEvents();
|
||||
HideCurrentPreview();
|
||||
}
|
||||
@@ -163,27 +164,6 @@ public class uBag : MonoBehaviour
|
||||
RebindToggle(equipSystemToggle, HandleEquipSystemChanged);
|
||||
}
|
||||
|
||||
private void BindCloseButton()
|
||||
{
|
||||
if (closeBagButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
closeBagButton.onClick.RemoveListener(HandleCloseBagClicked);
|
||||
closeBagButton.onClick.AddListener(HandleCloseBagClicked);
|
||||
}
|
||||
|
||||
private void UnbindCloseButton()
|
||||
{
|
||||
if (closeBagButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
closeBagButton.onClick.RemoveListener(HandleCloseBagClicked);
|
||||
}
|
||||
|
||||
private void RebindToggle(Toggle toggle, UnityAction<bool> action)
|
||||
{
|
||||
if (toggle == null)
|
||||
@@ -277,11 +257,6 @@ public class uBag : MonoBehaviour
|
||||
SetObjectActive(equipObj, isOn);
|
||||
}
|
||||
|
||||
private void HandleCloseBagClicked()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void ApplyCategory(BagCategory category)
|
||||
{
|
||||
currentCategory = category;
|
||||
@@ -412,7 +387,10 @@ public class uBag : MonoBehaviour
|
||||
Color color = rarityColorConfig != null
|
||||
? rarityColorConfig.GetColor(entry.rarity, fallbackColor)
|
||||
: fallbackColor;
|
||||
previewView.Bind(color, icon, entry.displayName, entry.usage, entry.description, entry.amountText);
|
||||
Sprite backgroundSprite = rarityColorConfig != null
|
||||
? rarityColorConfig.GetBackgroundSprite(entry.rarity, fallbackBackgroundSprite)
|
||||
: fallbackBackgroundSprite;
|
||||
previewView.Bind(color, backgroundSprite, icon, entry.displayName, entry.usage, entry.description, entry.amountText);
|
||||
}
|
||||
|
||||
PositionIntroduction(source, spawnedIntroduction);
|
||||
@@ -466,7 +444,7 @@ public class uBag : MonoBehaviour
|
||||
: definition != null && !string.IsNullOrEmpty(definition.expBottleName) ? definition.expBottleName : descriptor.DisplayName,
|
||||
countText = count.ToString(),
|
||||
amountText = count.ToString(),
|
||||
usage = ResolveExpBottleUsage(sourceDefinition),
|
||||
usage = ItemUsageTagUtility.ResolveDisplayName(sourceDefinition),
|
||||
description = BuildPreferredDescription(
|
||||
storeItem != null ? storeItem.itemDetailedDescription : null,
|
||||
sourceDefinition != null ? sourceDefinition.expBottleDescription : null,
|
||||
@@ -508,7 +486,7 @@ public class uBag : MonoBehaviour
|
||||
: definition != null && !string.IsNullOrEmpty(definition.growthMaterialName) ? definition.growthMaterialName : descriptor.DisplayName,
|
||||
countText = count.ToString(),
|
||||
amountText = count.ToString(),
|
||||
usage = ResolveGrowthMaterialUsage(sourceDefinition),
|
||||
usage = ItemUsageTagUtility.ResolveDisplayName(sourceDefinition),
|
||||
description = BuildPreferredDescription(
|
||||
storeItem != null ? storeItem.itemDetailedDescription : null,
|
||||
sourceDefinition != null ? sourceDefinition.growthMaterialDescription : null,
|
||||
@@ -550,7 +528,7 @@ public class uBag : MonoBehaviour
|
||||
: definition != null && !string.IsNullOrEmpty(definition.consumableName) ? definition.consumableName : descriptor.DisplayName,
|
||||
countText = count.ToString(),
|
||||
amountText = count.ToString(),
|
||||
usage = ResolveEquipmentConsumableUsage(sourceDefinition),
|
||||
usage = ItemUsageTagUtility.ResolveDisplayName(sourceDefinition),
|
||||
description = BuildPreferredDescription(
|
||||
storeItem != null ? storeItem.itemDetailedDescription : null,
|
||||
sourceDefinition != null ? sourceDefinition.consumableDescription : null,
|
||||
@@ -588,7 +566,7 @@ public class uBag : MonoBehaviour
|
||||
displayName = story.class_name,
|
||||
countText = "1",
|
||||
amountText = "1",
|
||||
usage = ResolveNotebookUsage(story),
|
||||
usage = ItemUsageTagUtility.ResolveDisplayName(story),
|
||||
description = story.class_description,
|
||||
icon = ResolvePreferredSprite(story.class_image, fallbackItemIcon),
|
||||
category = BagCategory.Precious,
|
||||
@@ -620,7 +598,7 @@ public class uBag : MonoBehaviour
|
||||
displayName = item.itemName,
|
||||
countText = "1",
|
||||
amountText = "1",
|
||||
usage = kind == PreciousKind.Character ? "角色" : "关卡",
|
||||
usage = ItemUsageTagUtility.ResolveDisplayName(item),
|
||||
description = BuildPreferredDescription(item.itemDetailedDescription, item.itemDescription),
|
||||
icon = ResolvePreferredSprite(item.itemIcon, fallbackItemIcon),
|
||||
category = BagCategory.Precious,
|
||||
@@ -705,7 +683,10 @@ public class uBag : MonoBehaviour
|
||||
Color color = rarityColorConfig != null
|
||||
? rarityColorConfig.GetColor(entry.rarity, fallbackColor)
|
||||
: fallbackColor;
|
||||
prefabView.Bind(this, icon, entry.countText, color, introductionHoverDelay);
|
||||
Sprite backgroundSprite = rarityColorConfig != null
|
||||
? rarityColorConfig.GetBackgroundSprite(entry.rarity, fallbackBackgroundSprite)
|
||||
: fallbackBackgroundSprite;
|
||||
prefabView.Bind(this, icon, entry.countText, color, backgroundSprite, introductionHoverDelay);
|
||||
viewEntries[prefabView] = entry;
|
||||
}
|
||||
|
||||
@@ -754,10 +735,22 @@ public class uBag : MonoBehaviour
|
||||
Color color = rarityColorConfig != null
|
||||
? rarityColorConfig.GetColor(entry.rarity, fallbackColor)
|
||||
: fallbackColor;
|
||||
Sprite backgroundSprite = rarityColorConfig != null
|
||||
? rarityColorConfig.GetBackgroundSprite(entry.rarity, fallbackBackgroundSprite)
|
||||
: fallbackBackgroundSprite;
|
||||
|
||||
if (btmImg != null)
|
||||
{
|
||||
btmImg.color = color;
|
||||
btmImg.sprite = backgroundSprite;
|
||||
btmImg.color = backgroundSprite != null ? Color.white : color;
|
||||
}
|
||||
|
||||
if (bottom_rarityImg != null)
|
||||
{
|
||||
Sprite raritySprite = ResolveBottomRaritySprite(entry.rarity);
|
||||
bottom_rarityImg.sprite = raritySprite;
|
||||
bottom_rarityImg.enabled = raritySprite != null;
|
||||
bottom_rarityImg.color = Color.white;
|
||||
}
|
||||
|
||||
if (itemDprofile != null)
|
||||
@@ -774,7 +767,9 @@ public class uBag : MonoBehaviour
|
||||
|
||||
if (itemName != null)
|
||||
{
|
||||
itemName.text = entry.displayName ?? string.Empty;
|
||||
itemName.supportRichText = false;
|
||||
itemName.text = StripRichTextTags(entry.displayName);
|
||||
itemName.color = useRarityColorForItemName ? color : Color.white;
|
||||
}
|
||||
|
||||
if (itemUse != null)
|
||||
@@ -782,6 +777,11 @@ public class uBag : MonoBehaviour
|
||||
itemUse.text = entry.usage ?? string.Empty;
|
||||
}
|
||||
|
||||
if (itemUsageLegacy != null)
|
||||
{
|
||||
itemUsageLegacy.text = entry.usage ?? string.Empty;
|
||||
}
|
||||
|
||||
if (itemDescription != null)
|
||||
{
|
||||
itemDescription.text = entry.description ?? string.Empty;
|
||||
@@ -792,7 +792,16 @@ public class uBag : MonoBehaviour
|
||||
{
|
||||
if (btmImg != null)
|
||||
{
|
||||
btmImg.color = fallbackColor;
|
||||
btmImg.sprite = fallbackBackgroundSprite;
|
||||
btmImg.color = fallbackBackgroundSprite != null ? Color.white : fallbackColor;
|
||||
}
|
||||
|
||||
if (bottom_rarityImg != null)
|
||||
{
|
||||
Sprite fallbackRaritySprite = GetBottomRarityFallbackSprite();
|
||||
bottom_rarityImg.sprite = fallbackRaritySprite;
|
||||
bottom_rarityImg.enabled = fallbackRaritySprite != null;
|
||||
bottom_rarityImg.color = Color.white;
|
||||
}
|
||||
|
||||
if (itemDprofile != null)
|
||||
@@ -809,7 +818,9 @@ public class uBag : MonoBehaviour
|
||||
|
||||
if (itemName != null)
|
||||
{
|
||||
itemName.supportRichText = false;
|
||||
itemName.text = string.Empty;
|
||||
itemName.color = Color.white;
|
||||
}
|
||||
|
||||
if (itemUse != null)
|
||||
@@ -817,6 +828,11 @@ public class uBag : MonoBehaviour
|
||||
itemUse.text = string.Empty;
|
||||
}
|
||||
|
||||
if (itemUsageLegacy != null)
|
||||
{
|
||||
itemUsageLegacy.text = string.Empty;
|
||||
}
|
||||
|
||||
if (itemDescription != null)
|
||||
{
|
||||
itemDescription.text = string.Empty;
|
||||
@@ -855,6 +871,94 @@ public class uBag : MonoBehaviour
|
||||
return string.CompareOrdinal(left.displayName, right.displayName);
|
||||
}
|
||||
|
||||
private static string StripRichTextTags(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
bool insideTag = false;
|
||||
System.Text.StringBuilder builder = null;
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
{
|
||||
char current = value[i];
|
||||
if (current == '<')
|
||||
{
|
||||
if (!insideTag)
|
||||
{
|
||||
builder ??= new System.Text.StringBuilder(value.Length);
|
||||
}
|
||||
|
||||
insideTag = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (current == '>')
|
||||
{
|
||||
insideTag = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!insideTag)
|
||||
{
|
||||
if (builder != null)
|
||||
{
|
||||
builder.Append(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return builder != null ? builder.ToString() : value;
|
||||
}
|
||||
|
||||
private Sprite ResolveBottomRaritySprite(ItemRarity rarity)
|
||||
{
|
||||
if (bottom_rarityImg_sprites != null)
|
||||
{
|
||||
if (bottom_rarityImg_sprites.Length >= System.Enum.GetValues(typeof(ItemRarity)).Length)
|
||||
{
|
||||
int enumIndex = (int)rarity;
|
||||
if (enumIndex >= 0 && enumIndex < bottom_rarityImg_sprites.Length)
|
||||
{
|
||||
Sprite directSprite = bottom_rarityImg_sprites[enumIndex];
|
||||
if (directSprite != null)
|
||||
{
|
||||
return directSprite;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rarity != ItemRarity.None)
|
||||
{
|
||||
int compactIndex = (int)rarity - 1;
|
||||
if (compactIndex >= 0 && compactIndex < bottom_rarityImg_sprites.Length)
|
||||
{
|
||||
Sprite compactSprite = bottom_rarityImg_sprites[compactIndex];
|
||||
if (compactSprite != null)
|
||||
{
|
||||
return compactSprite;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GetBottomRarityFallbackSprite();
|
||||
}
|
||||
|
||||
private Sprite GetBottomRarityFallbackSprite()
|
||||
{
|
||||
if (rarityColorConfig != null)
|
||||
{
|
||||
Sprite noneSprite = rarityColorConfig.GetBackgroundSprite(ItemRarity.None, fallbackBackgroundSprite);
|
||||
if (noneSprite != null)
|
||||
{
|
||||
return noneSprite;
|
||||
}
|
||||
}
|
||||
|
||||
return fallbackBackgroundSprite;
|
||||
}
|
||||
|
||||
private expBottlesSO[] LoadExpBottleDefinitions()
|
||||
{
|
||||
var result = new List<expBottlesSO>();
|
||||
@@ -1115,71 +1219,6 @@ public class uBag : MonoBehaviour
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string ResolveNotebookUsage(notebook_faterType story)
|
||||
{
|
||||
if (story == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
switch (story.fatherType)
|
||||
{
|
||||
case notebook_faterType.notebook_fatherType.idols:
|
||||
return "角色线索";
|
||||
case notebook_faterType.notebook_fatherType.content:
|
||||
return "故事线索";
|
||||
default:
|
||||
return "珍贵物品";
|
||||
}
|
||||
}
|
||||
|
||||
private static string ResolveExpBottleUsage(expBottlesSO definition)
|
||||
{
|
||||
if (definition != null && !string.IsNullOrWhiteSpace(definition.expBottleUsage))
|
||||
{
|
||||
return definition.expBottleUsage;
|
||||
}
|
||||
|
||||
return "角色培养";
|
||||
}
|
||||
|
||||
private static string ResolveGrowthMaterialUsage(growthMaterialSO definition)
|
||||
{
|
||||
if (definition != null && !string.IsNullOrWhiteSpace(definition.growthMaterialUsage))
|
||||
{
|
||||
return definition.growthMaterialUsage;
|
||||
}
|
||||
|
||||
return "角色突破";
|
||||
}
|
||||
|
||||
private static string ResolveEquipmentConsumableUsage(equipmentConsumableSO definition)
|
||||
{
|
||||
if (definition != null && !string.IsNullOrWhiteSpace(definition.consumableUsage))
|
||||
{
|
||||
return definition.consumableUsage;
|
||||
}
|
||||
|
||||
if (definition == null)
|
||||
{
|
||||
return "装备材料";
|
||||
}
|
||||
|
||||
switch (definition.consumableType)
|
||||
{
|
||||
case equipmentConsumableSO.EquipmentConsumableType.UpgradeMaterial:
|
||||
return "装备升级";
|
||||
case equipmentConsumableSO.EquipmentConsumableType.BreakthroughMaterial:
|
||||
return "装备幻化";
|
||||
case equipmentConsumableSO.EquipmentConsumableType.TransferMaterial:
|
||||
return "装备洗炼";
|
||||
case equipmentConsumableSO.EquipmentConsumableType.FinalDreamMaterial:
|
||||
return "梦醒登顶";
|
||||
default:
|
||||
return "装备材料";
|
||||
}
|
||||
}
|
||||
|
||||
private static Sprite ResolvePreferredSprite(params Sprite[] sprites)
|
||||
{
|
||||
for (int i = 0; i < sprites.Length; i++)
|
||||
|
||||
Reference in New Issue
Block a user