228 lines
11 KiB
Plaintext
228 lines
11 KiB
Plaintext
@using TaikoWebUI.Services
|
|
@using SharedProject.Models.Responses
|
|
@using SharedProject.Models
|
|
@using SharedProject.Models.Requests
|
|
@using SharedProject.Enums
|
|
@using Throw
|
|
@inject IGameDataService GameDataService
|
|
@inject HttpClient Client
|
|
|
|
@page "/Cards/{baid:int}/TaikoMode"
|
|
|
|
<MudBreadcrumbs Items="breadcrumbs" Class="px-0"></MudBreadcrumbs>
|
|
|
|
<h1>Taiko Mode</h1>
|
|
<MudText Typo="Typo.caption">Card: @Baid</MudText>
|
|
|
|
<MudGrid Class="my-8">
|
|
@if (response is null)
|
|
{
|
|
<MudItem xs="12">
|
|
<MudText Align="Align.Center">
|
|
No data.
|
|
</MudText>
|
|
</MudItem>
|
|
}
|
|
else
|
|
{
|
|
<MudItem xs="12">
|
|
<MudTabs Elevation="0" Border="true" Rounded="true" ApplyEffectsToContainer="true" PanelClass="py-6">
|
|
@foreach (var difficulty in Enum.GetValues<Difficulty>())
|
|
{
|
|
@if (difficulty is not Difficulty.None)
|
|
{
|
|
<MudTabPanel Text="@GetDifficultyTitle(difficulty)" Icon="@GetDifficultyIcon(difficulty)">
|
|
<MudDataGrid Items="@response.SongBestData.Where(data => data.Difficulty == difficulty)"
|
|
ColumnResizeMode="ResizeMode.Container">
|
|
<Columns>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.SongId)" Title="Song" StickyLeft="true" Class="clm-row-large">
|
|
<CellTemplate>
|
|
<MudGrid Justify="Justify.Center">
|
|
<MudItem xs="10">
|
|
<MudStack Spacing="0">
|
|
<MudText Typo="Typo.body2" Style="font-weight:bold">@GameDataService.GetMusicNameBySongId(context.Item.SongId)</MudText>
|
|
<MudText Typo="Typo.caption">@GameDataService.GetMusicArtistBySongId(context.Item.SongId)</MudText>
|
|
</MudStack>
|
|
</MudItem>
|
|
<MudItem xs="2">
|
|
<MudStack Justify="Justify.Center" AlignItems="AlignItems.End" Style="height:100%">
|
|
<MudTooltip Text="@(context.Item.IsFavorite ? "Remove from favorites" : "Add to favorites")" Arrow="true" Placement="Placement.Top">
|
|
<MudToggleIconButton Toggled="@context.Item.IsFavorite"
|
|
ToggledChanged="@(async () => await OnFavoriteToggled(context.Item))"
|
|
Icon="@Icons.Material.Filled.FavoriteBorder" Color="@Color.Secondary"
|
|
ToggledIcon="@Icons.Material.Filled.Favorite" ToggledColor="@Color.Secondary"
|
|
Size="Size.Small"
|
|
ToggledSize="Size.Small"/>
|
|
</MudTooltip>
|
|
</MudStack>
|
|
</MudItem>
|
|
</MudGrid>
|
|
</CellTemplate>
|
|
</Column>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.SongId)" Title="Genre" Sortable="false">
|
|
<CellTemplate>
|
|
<MudChip Style="@GetGenreStyle(GameDataService.GetMusicGenreBySongId(context.Item.SongId))"
|
|
Size="Size.Small">
|
|
@GetGenreTitle(GameDataService.GetMusicGenreBySongId(context.Item.SongId))
|
|
</MudChip>
|
|
</CellTemplate>
|
|
</Column>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.BestScore)" Title="Best Score"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.BestCrown)" Title="Best Crown">
|
|
<CellTemplate>
|
|
<MudTooltip Text="@(GetCrownText(context.Item.BestCrown))" Arrow="true" Placement="Placement.Top">
|
|
<img src="@($"/images/crown_{context.Item.BestCrown}.png")" alt="@(context.Item.BestCrown)" style="@ICON_STYLE"/>
|
|
</MudTooltip>
|
|
</CellTemplate>
|
|
</Column>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.BestScoreRank)" Title="Best Rank">
|
|
<CellTemplate>
|
|
@if (context.Item.BestScoreRank is not ScoreRank.None)
|
|
{
|
|
<MudTooltip Text="@(GetRankText(context.Item.BestScoreRank))" Arrow="true" Placement="Placement.Top">
|
|
<img src="@($"/images/rank_{context.Item.BestScoreRank}.png")" alt="@(context.Item.BestScoreRank)" style="@ICON_STYLE"/>
|
|
</MudTooltip>
|
|
}
|
|
</CellTemplate>
|
|
</Column>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.GoodCount)" Title="Good" Sortable="false"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.OkCount)" Title="Ok" Sortable="false"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.MissCount)" Title="Bad" Sortable="false"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.DrumrollCount)" Title="Drum Roll" Sortable="false"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.ComboCount)" Title="Max Combo" Sortable="false"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.LastPlayTime)" Title="Last Played"/>
|
|
</Columns>
|
|
<PagerContent>
|
|
<MudDataGridPager T="SongBestData"/>
|
|
</PagerContent>
|
|
</MudDataGrid>
|
|
</MudTabPanel>
|
|
}
|
|
}
|
|
</MudTabs>
|
|
</MudItem>
|
|
}
|
|
</MudGrid>
|
|
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
public int Baid { get; set; }
|
|
|
|
private SongBestResponse? response;
|
|
|
|
private const string ICON_STYLE = "width:25px; height:25px;";
|
|
|
|
private readonly List<BreadcrumbItem> breadcrumbs = new()
|
|
{
|
|
new BreadcrumbItem("Cards", href: "/Cards"),
|
|
};
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
response = await Client.GetFromJsonAsync<SongBestResponse>($"api/PlayData/{Baid}");
|
|
response.ThrowIfNull();
|
|
response.SongBestData.Sort((data1, data2) =>
|
|
{
|
|
return GameDataService.GetMusicIndexBySongId(data1.SongId)
|
|
.CompareTo(GameDataService.GetMusicIndexBySongId(data2.SongId));
|
|
});
|
|
|
|
breadcrumbs.Add(new BreadcrumbItem($"Card: {Baid}", href: null, disabled: true));
|
|
breadcrumbs.Add(new BreadcrumbItem("Taiko Mode", href: $"/Cards/{Baid}/TaikoMode", disabled: false));
|
|
}
|
|
|
|
private async Task OnFavoriteToggled(SongBestData data)
|
|
{
|
|
var request = new SetFavoriteRequest
|
|
{
|
|
Baid = (uint)Baid,
|
|
IsFavorite = !data.IsFavorite,
|
|
SongId = data.SongId
|
|
};
|
|
var result = await Client.PostAsJsonAsync("api/FavoriteSongs", request);
|
|
if (result.IsSuccessStatusCode)
|
|
{
|
|
data.IsFavorite = !data.IsFavorite;
|
|
}
|
|
}
|
|
|
|
private static string GetCrownText(CrownType crown)
|
|
{
|
|
return crown switch
|
|
{
|
|
CrownType.None => "Fail",
|
|
CrownType.Clear => "Clear",
|
|
CrownType.Gold => "Full Combo",
|
|
CrownType.Dondaful => "Donderful Combo",
|
|
_ => ""
|
|
};
|
|
}
|
|
|
|
private static string GetRankText(ScoreRank rank)
|
|
{
|
|
return rank switch
|
|
{
|
|
ScoreRank.White => "Stylish",
|
|
ScoreRank.Bronze => "Stylish",
|
|
ScoreRank.Silver => "Stylish",
|
|
ScoreRank.Gold => "Graceful",
|
|
ScoreRank.Sakura => "Graceful",
|
|
ScoreRank.Purple => "Graceful",
|
|
ScoreRank.Dondaful => "Top Class",
|
|
_ => ""
|
|
};
|
|
}
|
|
|
|
private static string GetDifficultyTitle(Difficulty difficulty)
|
|
{
|
|
return difficulty switch
|
|
{
|
|
Difficulty.Easy => "Easy",
|
|
Difficulty.Normal => "Normal",
|
|
Difficulty.Hard => "Hard",
|
|
Difficulty.Oni => "Oni",
|
|
Difficulty.UraOni => "Ura Oni",
|
|
_ => ""
|
|
};
|
|
}
|
|
|
|
private static string GetDifficultyIcon(Difficulty difficulty)
|
|
{
|
|
return $"<image href='/images/difficulty_{difficulty}.png' alt='{difficulty}' width='24' height='24'/>";
|
|
}
|
|
|
|
private static string GetGenreTitle(SongGenre genre)
|
|
{
|
|
return genre switch
|
|
{
|
|
SongGenre.Pop => "Pop",
|
|
SongGenre.Anime => "Anime",
|
|
SongGenre.Kids => "Kids",
|
|
SongGenre.Vocaloid => "Vocaloid",
|
|
SongGenre.GameMusic => "Game Music",
|
|
SongGenre.NamcoOriginal => "NAMCO Original",
|
|
SongGenre.Variety => "Variety",
|
|
SongGenre.Classical => "Classical",
|
|
_ => ""
|
|
};
|
|
}
|
|
|
|
private static string GetGenreStyle(SongGenre genre)
|
|
{
|
|
return genre switch
|
|
{
|
|
SongGenre.Pop => "background: #42c0d2; color: #fff",
|
|
SongGenre.Anime => "background: #ff90d3; color: #fff",
|
|
SongGenre.Kids => "background: #fec000; color: #fff",
|
|
SongGenre.Vocaloid => "background: #ddd",
|
|
SongGenre.GameMusic => "background: #cc8aea; color: #fff",
|
|
SongGenre.NamcoOriginal => "background: #ff7027; color: #fff",
|
|
SongGenre.Variety => "background: #1dc83b; color: #fff",
|
|
SongGenre.Classical => "background: #bfa356",
|
|
_ => ""
|
|
};
|
|
}
|
|
} |