Commit 23cf6fc8 authored by ElderLich's avatar ElderLich

Update CardImageLoader.cs

Fixing the "No Art" for Overframe.
parent f4498ea9
...@@ -21,6 +21,7 @@ namespace MDPro3.Utility ...@@ -21,6 +21,7 @@ namespace MDPro3.Utility
private static readonly ConcurrentDictionary<int, CacheEntry> cachedCards = new(); private static readonly ConcurrentDictionary<int, CacheEntry> cachedCards = new();
private static readonly ConcurrentDictionary<int, Texture2D> cachedCardNames = new(); private static readonly ConcurrentDictionary<int, Texture2D> cachedCardNames = new();
private static readonly ConcurrentDictionary<int, Texture> cachedVideoCards = new(); private static readonly ConcurrentDictionary<int, Texture> cachedVideoCards = new();
private static readonly ConcurrentDictionary<int, byte> knownOverFrameArts = new();
private static readonly ConcurrentDictionary<int, SemaphoreSlim> artLoadingLocks = new(); private static readonly ConcurrentDictionary<int, SemaphoreSlim> artLoadingLocks = new();
private static readonly ConcurrentDictionary<int, SemaphoreSlim> cardLoadingLocks = new(); private static readonly ConcurrentDictionary<int, SemaphoreSlim> cardLoadingLocks = new();
...@@ -86,7 +87,7 @@ namespace MDPro3.Utility ...@@ -86,7 +87,7 @@ namespace MDPro3.Utility
Interlocked.Increment(ref entry.ReferenceCount); Interlocked.Increment(ref entry.ReferenceCount);
entry.IsPersistent |= persistent; entry.IsPersistent |= persistent;
} }
else else if (!HasOverFrameArtFile(code))
Debug.LogError($"Art texture is null for code {code}"); Debug.LogError($"Art texture is null for code {code}");
return entry.Texture; return entry.Texture;
...@@ -111,7 +112,7 @@ namespace MDPro3.Utility ...@@ -111,7 +112,7 @@ namespace MDPro3.Utility
cachedArts.TryRemove(code, out _); cachedArts.TryRemove(code, out _);
throw ex; throw ex;
} }
if (newEntry.Texture == null) if (newEntry.Texture == null && !HasOverFrameArtFile(code))
Debug.LogError($"{code} art is null"); Debug.LogError($"{code} art is null");
newEntry.LoadingTask = null; newEntry.LoadingTask = null;
...@@ -255,6 +256,7 @@ namespace MDPro3.Utility ...@@ -255,6 +256,7 @@ namespace MDPro3.Utility
cachedCardNames.Clear(); cachedCardNames.Clear();
ClearArtVideos(); ClearArtVideos();
knownOverFrameArts.Clear();
} }
#endregion #endregion
...@@ -290,7 +292,7 @@ namespace MDPro3.Utility ...@@ -290,7 +292,7 @@ namespace MDPro3.Utility
} }
if (art == null) if (art == null)
{ {
lastCardFoundArt = false; lastCardFoundArt = HasOverFrameArtFile(code);
return null; return null;
} }
...@@ -354,7 +356,8 @@ namespace MDPro3.Utility ...@@ -354,7 +356,8 @@ namespace MDPro3.Utility
if (art == null) if (art == null)
{ {
Debug.LogError($"Get null from ArtLoad for Card {data.Id}:"); if (!HasOverFrameArtFile(data.Id))
Debug.LogError($"Get null from ArtLoad for Card {data.Id}:");
art = TextureManager.container.unknownArt.texture; art = TextureManager.container.unknownArt.texture;
} }
if (!Program.instance.cardRenderer.RenderCard(code, art)) if (!Program.instance.cardRenderer.RenderCard(code, art))
...@@ -397,7 +400,8 @@ namespace MDPro3.Utility ...@@ -397,7 +400,8 @@ namespace MDPro3.Utility
if (art == null) if (art == null)
{ {
Debug.LogError($"Get null from ArtLoad for Card {data.Id}:"); if (!HasOverFrameArtFile(data.Id))
Debug.LogError($"Get null from ArtLoad for Card {data.Id}:");
art = TextureManager.container.unknownArt.texture; art = TextureManager.container.unknownArt.texture;
} }
...@@ -559,6 +563,30 @@ namespace MDPro3.Utility ...@@ -559,6 +563,30 @@ namespace MDPro3.Utility
#region Art File List Cache #region Art File List Cache
private static bool HasOverFrameArtFile(int code)
{
if (knownOverFrameArts.ContainsKey(code))
return true;
var fileName = code + Program.EXPANSION_PNG;
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS)
var overFramePath = Path.Combine(Application.persistentDataPath, "Picture", "OverFrame", fileName);
var overframePath = Path.Combine(Application.persistentDataPath, "Picture", "Overframe", fileName);
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX
var overFramePath = Path.Combine(Environment.CurrentDirectory, "Picture", "OverFrame", fileName);
var overframePath = Path.Combine(Environment.CurrentDirectory, "Picture", "Overframe", fileName);
#else
var overFramePath = Path.Combine(Environment.CurrentDirectory, "Picture", "OverFrame", fileName);
var overframePath = Path.Combine(Environment.CurrentDirectory, "Picture", "Overframe", fileName);
#endif
var exists = File.Exists(overFramePath) || File.Exists(overframePath);
if (exists)
knownOverFrameArts.TryAdd(code, 0);
return exists;
}
private static readonly List<int> artFileList = new(); private static readonly List<int> artFileList = new();
private static readonly Dictionary<int, string> artAltFileList = new(); private static readonly Dictionary<int, string> artAltFileList = new();
private static bool artFileListInitialized; private static bool artFileListInitialized;
...@@ -688,4 +716,4 @@ namespace MDPro3.Utility ...@@ -688,4 +716,4 @@ namespace MDPro3.Utility
#endregion #endregion
} }
} }
\ No newline at end of file
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