1
0
mirror of synced 2024-11-30 17:24:33 +01:00

Fixed dani dojo page showing non-existing dans

This commit is contained in:
S-Sebb 2024-06-05 16:42:45 +01:00
parent 9b9009ac42
commit 4a5be9371f
4 changed files with 14 additions and 9 deletions

View File

@ -28,10 +28,9 @@ else
<MudItem xs="12">
<MudPaper Elevation="0" Outlined="true">
<MudTabs ActivePanelIndex="0" Rounded="true" Border="true" PanelClass="pa-8">
@for (uint i = 1; i <= 19; i++)
@foreach (var danId in danMap.Keys)
{
var danId = i;
var danData = GameDataService.GetDanDataById(danId);
var danData = danMap[danId];
<MudTabPanel Text="@GetDanTitle(danData.Title)" Icon="@GetDanResultIcon(danId)">
<MudText Typo="Typo.h5" Class="mb-4">@Localizer["Details"]</MudText>

View File

@ -1,4 +1,5 @@
using Microsoft.JSInterop;
using System.Collections.Immutable;
using Microsoft.JSInterop;
namespace TaikoWebUI.Pages;
@ -14,6 +15,7 @@ public partial class DaniDojo
private static Dictionary<uint, DanBestData> _bestDataMap = new();
private Dictionary<uint, MusicDetail> musicDetailDictionary = new();
private ImmutableDictionary<uint, DanData> danMap = ImmutableDictionary<uint, DanData>.Empty;
private readonly List<BreadcrumbItem> breadcrumbs = new();
@ -32,6 +34,8 @@ public partial class DaniDojo
.Sort((stageData, otherStageData) => stageData.SongNumber.CompareTo(otherStageData.SongNumber)));
_bestDataMap = response.DanBestDataList.ToDictionary(data => data.DanId);
danMap = GameDataService.GetDanMap();
SongNameLanguage = await LocalStorage.GetItemAsync<string>("songNameLanguage");
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");

View File

@ -116,11 +116,11 @@ public class GameDataService : IGameDataService
return musicDetails.TryGetValue(songId, out var musicDetail) ? musicDetail.Index : int.MaxValue;
}
public DanData GetDanDataById(uint danId)
public ImmutableDictionary<uint, DanData> GetDanMap()
{
return danMap.GetValueOrDefault(danId, new DanData());
return danMap;
}
public int GetMusicStarLevel(Dictionary<uint, MusicDetail> musicDetails, uint songId, Difficulty difficulty)
{
var success = musicDetails.TryGetValue(songId, out var musicDetail);

View File

@ -1,4 +1,6 @@
namespace TaikoWebUI.Services;
using System.Collections.Immutable;
namespace TaikoWebUI.Services;
public interface IGameDataService
{
@ -22,7 +24,7 @@ public interface IGameDataService
public int GetMusicIndexBySongId(Dictionary<uint, MusicDetail> musicDetails,uint songId);
public DanData GetDanDataById(uint danId);
public ImmutableDictionary<uint, DanData> GetDanMap();
public int GetMusicStarLevel(Dictionary<uint, MusicDetail> musicDetails, uint songId, Difficulty difficulty);