Commit 87b7bae8 authored by ElderLich's avatar ElderLich

Bug Fix: Deck Selector throws Addressables InvalidKeyException after deleting decks

After deleting some decks, certain deck entries keep an invalid deck case ID (0).
When Deck Selector refreshes, it tries to load a deck-case sprite using that invalid value (0__L_SD), then falls back to a mismatched default key (DeckCase0001_L), which is also missing for this UI path. This causes repeated Addressables errors and icon loading failures.
parent b3287b74
...@@ -100,7 +100,8 @@ namespace MDPro3 ...@@ -100,7 +100,8 @@ namespace MDPro3
public List<Item> wallpapers; // 113 public List<Item> wallpapers; // 113
public List<List<Item>> kinds; public List<List<Item>> kinds;
private const string ADDRESS_DEFAULT_DECK_CASE = "DeckCase0001_L"; private const int CODE_DEFAULT_DECK_CASE = 1080001;
private const string ADDRESS_DEFAULT_DECK_CASE_LEGACY = "DeckCase0001_L";
public const string STRING_NULL = "coming soon"; public const string STRING_NULL = "coming soon";
public const int CODE_NONE = 0; public const int CODE_NONE = 0;
...@@ -627,15 +628,35 @@ namespace MDPro3 ...@@ -627,15 +628,35 @@ namespace MDPro3
} }
public async UniTask<Sprite> LoadDeckCaseIconAsync(int code, string suffix) public async UniTask<Sprite> LoadDeckCaseIconAsync(int code, string suffix)
{
var sprite = await TryLoadAddressableSprite(GetDeckCaseAddress(code, suffix));
if (sprite != null)
return sprite;
sprite = await TryLoadAddressableSprite(GetDeckCaseAddress(CODE_DEFAULT_DECK_CASE, suffix));
if (sprite != null)
return sprite;
return await TryLoadAddressableSprite(ADDRESS_DEFAULT_DECK_CASE_LEGACY);
}
private static string GetDeckCaseAddress(int code, string suffix)
{
if (code < 1080000 || code > 1089999)
code = CODE_DEFAULT_DECK_CASE;
return $"DeckCase{code.ToString()[3..]}{suffix ?? string.Empty}";
}
private async UniTask<Sprite> TryLoadAddressableSprite(string address)
{ {
try try
{ {
return await LoadAddressableSprite($"DeckCase{code.ToString()[3..]}{suffix}"); return await LoadAddressableSprite(address);
} }
catch catch
{ {
Debug.LogError("Addressables Not Found: " + $"DeckCase {code}_{suffix}"); return null;
return await LoadAddressableSprite(ADDRESS_DEFAULT_DECK_CASE);
} }
} }
......
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