Commit a2364503 authored by SherryChaos's avatar SherryChaos

Bug Fix: Card Protector items bleed outside

parent 6367fe13
...@@ -331,7 +331,16 @@ namespace MDPro3 ...@@ -331,7 +331,16 @@ namespace MDPro3
} }
} }
private static Shader defaultProtectorShader;
private const string defaultProtectorCode = "1070002";
public static async UniTask<Material> LoadProtectorMaterial(string code, CancellationToken token) public static async UniTask<Material> LoadProtectorMaterial(string code, CancellationToken token)
{
if(defaultProtectorShader == null)
await InternalLoadProtectorMaterialAsync(defaultProtectorCode, token);
return await InternalLoadProtectorMaterialAsync(code, token);
}
public static async UniTask<Material> InternalLoadProtectorMaterialAsync(string code, CancellationToken token)
{ {
await protectorSemaphoreSlim.WaitAsync(token); await protectorSemaphoreSlim.WaitAsync(token);
...@@ -381,14 +390,15 @@ namespace MDPro3 ...@@ -381,14 +390,15 @@ namespace MDPro3
return null; return null;
} }
if (defaultProtectorShader == null &&
code == defaultProtectorCode)
defaultProtectorShader = material.shader;
if (material.shader.name.Contains("3D"))
material.shader = defaultProtectorShader;
material.renderQueue = 3000; material.renderQueue = 3000;
foreach (var bundle in bundles) foreach (var bundle in bundles)
bundle.Unload(false); bundle.Unload(false);
cachedPMat.TryAdd(code, material);
if (cachedPMat.ContainsKey(code))
material = cachedPMat[code];
else
cachedPMat.Add(code, material);
return material; return material;
} }
......
...@@ -55,8 +55,9 @@ namespace MDPro3.UI ...@@ -55,8 +55,9 @@ namespace MDPro3.UI
private Image premiumOverlayIcon; private Image premiumOverlayIcon;
private Coroutine premiumCrossfadeCoroutine; private Coroutine premiumCrossfadeCoroutine;
private const float CrossfadeHoldSeconds = 2.0f; private const float CrossfadeHoldSeconds = 3.0f;
private const float CrossfadeFadeSeconds = 0.6f; private const float CrossfadeFadeSeconds = 1.0f;
private static readonly Dictionary<int, Sprite> cachedArtSprites = new();
protected override void Awake() protected override void Awake()
{ {
...@@ -84,16 +85,15 @@ namespace MDPro3.UI ...@@ -84,16 +85,15 @@ namespace MDPro3.UI
if (path.StartsWith("Protector")) if (path.StartsWith("Protector"))
{ {
Protector.material = await ABLoader.LoadProtector.material(itemID.ToString(), destroyCancellationToken);
Protector.color = Color.white;
Icon.gameObject.SetActive(false); Icon.gameObject.SetActive(false);
Protector.material = await ABLoader.LoadProtectorMaterial(itemID.ToString(), destroyCancellationToken);
Protector.color = Color.white;
} }
else if (path.Length > 0) else if (path.Length > 0)
{ {
Icon.sprite = await Program.items.LoadItemIconAsync(itemID.ToString(), Items.ItemType.Unknown); Icon.sprite = await Program.items.LoadItemIconAsync(itemID.ToString(), Items.ItemType.Unknown);
if (cancellationToken.IsCancellationRequested || this == null || Manager == null) if (cancellationToken.IsCancellationRequested || this == null || Manager == null)
return; return;
Icon.color = Color.white;
if (path.StartsWith("ProfileFrame")) if (path.StartsWith("ProfileFrame"))
{ {
Icon.rectTransform.localScale = Vector3.one * 0.8f; Icon.rectTransform.localScale = Vector3.one * 0.8f;
...@@ -102,7 +102,6 @@ namespace MDPro3.UI ...@@ -102,7 +102,6 @@ namespace MDPro3.UI
return; return;
Icon.material.SetTexture("_ProfileFrameTex", Icon.sprite.texture); Icon.material.SetTexture("_ProfileFrameTex", Icon.sprite.texture);
Icon.sprite = TextureManager.container.black; Icon.sprite = TextureManager.container.black;
Icon.color = Color.white;
} }
else if (path.StartsWith("DeckCase")) else if (path.StartsWith("DeckCase"))
{ {
...@@ -112,15 +111,22 @@ namespace MDPro3.UI ...@@ -112,15 +111,22 @@ namespace MDPro3.UI
{ {
WallpaperBG.gameObject.SetActive(true); WallpaperBG.gameObject.SetActive(true);
} }
Icon.color = Color.white;
Protector.gameObject.SetActive(false); Protector.gameObject.SetActive(false);
} }
else //CrossDuel Mate else //CrossDuel Mate
{ {
var art = await CardImageLoader.LoadArtAsync(itemID, true, cancellationToken); if(!cachedArtSprites.TryGetValue(itemID, out var sprite))
if (cancellationToken.IsCancellationRequested || this == null) {
return; var art = await CardImageLoader.LoadArtAsync(itemID, true, cancellationToken);
if (cancellationToken.IsCancellationRequested || this == null)
return;
sprite = TextureManager.Texture2Sprite(art);
cachedArtSprites.TryAdd(itemID, sprite);
}
Icon.sprite = sprite;
Icon.color = Color.white; Icon.color = Color.white;
Icon.sprite = TextureManager.Texture2Sprite(art);
Protector.gameObject.SetActive(false); Protector.gameObject.SetActive(false);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment