1
0
mirror of synced 2024-11-15 02:47:35 +01:00

Code formatting

This commit is contained in:
shiibe 2024-03-08 18:42:56 -05:00
parent 374319decd
commit 6212b68ea4
28 changed files with 129 additions and 135 deletions

View File

@ -8,14 +8,14 @@ public partial class AccessCode
{
[Parameter]
public int Baid { get; set; }
private string inputAccessCode = "";
private MudForm bindAccessCodeForm = default!;
private User? User { get; set; } = new();
private DashboardResponse? response;
private readonly List<BreadcrumbItem> breadcrumbs = new()
{
new BreadcrumbItem("Users", href: "/Users"),
@ -28,7 +28,7 @@ public partial class AccessCode
breadcrumbs.Add(new BreadcrumbItem($"User: {Baid}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem("Access Code Management", href: $"/Users/{Baid}/AccessCode", disabled: false));
}
private async Task InitializeUser()
{
response = await Client.GetFromJsonAsync<DashboardResponse>("api/Dashboard");
@ -45,7 +45,7 @@ public partial class AccessCode
User = LoginService.GetLoggedInUser();
}
}
private async Task DeleteAccessCode(string accessCode)
{
var parameters = new DialogParameters<AccessCodeDeleteConfirmDialog>
@ -58,7 +58,7 @@ public partial class AccessCode
var result = await dialog.Result;
if (result.Canceled) return;
await InitializeUser();
NavigationManager.NavigateTo(NavigationManager.Uri);
}

View File

@ -2,18 +2,18 @@
public partial class AccessCodeDeleteConfirmDialog
{
[CascadingParameter]
MudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public User User { get; set; } = new();
[Parameter]
public string AccessCode { get; set; } = "";
private void Cancel() => MudDialog.Cancel();
private async Task DeleteAccessCode()
{
if (User.AccessCodes.Count == 1)
@ -22,7 +22,7 @@ public partial class AccessCodeDeleteConfirmDialog
MudDialog.Close(DialogResult.Ok(false));
return;
}
var cardResponseMessage = await Client.DeleteAsync($"api/Cards/{AccessCode}");
if (!cardResponseMessage.IsSuccessStatusCode)

View File

@ -11,14 +11,14 @@
</ColGroup>
<ToolBarContent>
<MudTextField @bind-Value="searchString" Placeholder="Search" Adornment="Adornment.Start" Immediate="true"
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0">
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0">
</MudTextField>
</ToolBarContent>
<HeaderContent>
<MudTh>
<MudTableSortLabel SortBy="@(new Func<Title, object>(x => x.TitleId))">
@Localizer["ID"]
</MudTableSortLabel>
</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="@(new Func<Title, object>(x => x.TitleName))">
@ -29,24 +29,24 @@
<RowTemplate>
@{
// Disable nullable warnings, which seems to be a false positive
# pragma warning disable CS8602
#pragma warning disable CS8602
}
<MudTd DataLabel="Id" Class="cursor-pointer">@context.TitleId</MudTd>
<MudTd DataLabel="Title" Class="cursor-pointer">@context.TitleName</MudTd>
@{
#pragma warning restore CS8602
#pragma warning restore CS8602
}
</RowTemplate>
<PagerContent>
<MudTablePager/>
<MudTablePager />
</PagerContent>
</MudTable>
<MudText Class="mt-4 d-block" Typo="Typo.caption"> <b>@Localizer["Selected Title:"]</b> @selectedTitle?.TitleName</MudText>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">
@Localizer["Cancel"]
</MudButton>
<MudButton OnClick="Cancel">
@Localizer["Cancel"]
</MudButton>
<MudButton Color="Color.Primary" OnClick="Submit">
@Localizer["Okay"]
</MudButton>
@ -81,15 +81,15 @@
}
titles = titleSet.ToImmutableList().Sort((title, title1) => title.TitleId.CompareTo(title1.TitleId));
var currentTitle = new Title
{
TitleName = UserSetting.Title
};
if (titleSet.Contains(currentTitle))
{
titleSet.TryGetValue(new Title
{
TitleName = UserSetting.Title
}, out selectedTitle);
};
if (titleSet.Contains(currentTitle))
{
titleSet.TryGetValue(new Title
{
TitleName = UserSetting.Title
}, out selectedTitle);
}
}
@ -100,7 +100,7 @@
return false;
}
return string.IsNullOrEmpty(searchString) ||
title.TitleName.Contains(searchString, StringComparison.InvariantCultureIgnoreCase);
title.TitleName.Contains(searchString, StringComparison.InvariantCultureIgnoreCase);
}
private void Submit()

View File

@ -2,7 +2,7 @@
public partial class ResetPasswordConfirmDialog
{
[CascadingParameter]
MudDialogInstance MudDialog { get; set; } = null!;
@ -10,7 +10,7 @@ public partial class ResetPasswordConfirmDialog
public User User { get; set; } = new();
private void Cancel() => MudDialog.Cancel();
private async Task ResetPassword()
{
var request = new SetPasswordRequest
@ -27,7 +27,7 @@ public partial class ResetPasswordConfirmDialog
MudDialog.Close(DialogResult.Ok(false));
return;
}
Snackbar.Add("Reset password success!", Severity.Success);
MudDialog.Close(DialogResult.Ok(true));
}

View File

@ -4,7 +4,7 @@
<MudDialog>
<TitleContent>
<MudText Typo="Typo.h6">
<MudIcon Icon="@Icons.Material.Filled.DeleteForever" Class="mr-3 mb-n1"/>
<MudIcon Icon="@Icons.Material.Filled.DeleteForever" Class="mr-3 mb-n1" />
Delete user?
</MudText>
</TitleContent>

View File

@ -2,7 +2,7 @@
public partial class UserDeleteConfirmDialog
{
[CascadingParameter]
MudDialogInstance MudDialog { get; set; } = null!;
@ -10,7 +10,7 @@ public partial class UserDeleteConfirmDialog
public User User { get; set; } = new();
private void Cancel() => MudDialog.Cancel();
private async Task DeleteUser()
{
var responseMessage = await Client.DeleteAsync($"api/Users/{User.Baid}");
@ -21,7 +21,7 @@ public partial class UserDeleteConfirmDialog
MudDialog.Close(DialogResult.Ok(false));
return;
}
Snackbar.Add("Delete success!", Severity.Success);
MudDialog.Close(DialogResult.Ok(true));
}

View File

@ -4,11 +4,7 @@
<MudDialog Class="dialog-user-qr-code">
<DialogContent>
<MudExtensions.MudBarcode
Value="@qrCode"
BarcodeFormat="ZXing.BarcodeFormat.QR_CODE"
Height="300"
Width="300" />
<MudExtensions.MudBarcode Value="@qrCode" BarcodeFormat="ZXing.BarcodeFormat.QR_CODE" Height="300" Width="300" />
</DialogContent>
<DialogActions>
<MudButton Color="Color.Primary" OnClick="Submit">Ok</MudButton>

View File

@ -2,7 +2,7 @@
using System;
using Microsoft.JSInterop;
namespace TaikoWebUI.Pages;
namespace TaikoWebUI.Pages;
public partial class HighScores
{
@ -10,7 +10,7 @@ public partial class HighScores
public int Baid { get; set; }
private const string IconStyle = "width:25px; height:25px;";
private SongBestResponse? response;
private Dictionary<Difficulty, List<SongBestData>> songBestDataMap = new();
@ -35,16 +35,16 @@ public partial class HighScores
data.MusicName = GameDataService.GetMusicNameBySongId(songId, string.IsNullOrEmpty(language) ? "ja" : language);
data.MusicArtist = GameDataService.GetMusicArtistBySongId(songId, string.IsNullOrEmpty(language) ? "ja" : language);
});
songBestDataMap = response.SongBestData.GroupBy(data => data.Difficulty)
.ToDictionary(data => data.Key,
.ToDictionary(data => data.Key,
data => data.ToList());
foreach (var songBestDataList in songBestDataMap.Values)
{
songBestDataList.Sort((data1, data2) => GameDataService.GetMusicIndexBySongId(data1.SongId)
.CompareTo(GameDataService.GetMusicIndexBySongId(data2.SongId)));
}
breadcrumbs.Add(new BreadcrumbItem($"User: {Baid}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem("High Scores", href: $"/Users/{Baid}/HighScores", disabled: false));
@ -74,7 +74,7 @@ public partial class HighScores
CrownType.Gold => "Full Combo",
CrownType.Dondaful => "Donderful Combo",
_ => ""
};
};
}
private static string GetRankText(ScoreRank rank)
@ -89,7 +89,7 @@ public partial class HighScores
ScoreRank.Purple => "Graceful",
ScoreRank.Dondaful => "Top Class",
_ => ""
};
};
}
private static string GetDifficultyTitle(Difficulty difficulty)
@ -102,7 +102,7 @@ public partial class HighScores
Difficulty.Oni => "Oni",
Difficulty.UraOni => "Ura Oni",
_ => ""
};
};
}
private static string GetDifficultyIcon(Difficulty difficulty)
@ -123,7 +123,7 @@ public partial class HighScores
SongGenre.Variety => "Variety",
SongGenre.Classical => "Classical",
_ => ""
};
};
}
private static string GetGenreStyle(SongGenre genre)
@ -154,4 +154,3 @@ public partial class HighScores
return aiData.Count > 0;
}
}

View File

@ -6,7 +6,7 @@ public partial class Register
private string confirmPassword = "";
private string password = "";
private MudForm registerForm = default!;
private MudDatePicker datePicker = new();
private MudTimePicker timePicker = new();
private DateTime? date = DateTime.Today;

View File

@ -49,7 +49,7 @@ public partial class Users
await DialogService.ShowMessageBox(
"Error",
"Only admin can reset password.",
"Ok", null , null, options);
"Ok", null, null, options);
return;
}
var parameters = new DialogParameters
@ -64,7 +64,7 @@ public partial class Users
response = await Client.GetFromJsonAsync<DashboardResponse>("api/Dashboard");
}
private async Task OnLogin()
{
if (response != null)
@ -112,7 +112,7 @@ public partial class Users
LoginService.Logout();
NavigationManager.NavigateTo("/Users");
}
private Task ShowQrCode(User user)
{
var parameters = new DialogParameters

View File

@ -6,18 +6,18 @@ namespace TaikoWebUI.Services;
public class GameDataService : IGameDataService
{
private string[] bodyTitles = {};
private string[] bodyTitles = { };
private readonly HttpClient client;
private string[] faceTitles = {};
private string[] faceTitles = { };
private string[] headTitles = {};
private string[] kigurumiTitles = {};
private string[] headTitles = { };
private string[] kigurumiTitles = { };
private readonly Dictionary<uint, MusicDetail> musicMap = new();
private string[] puchiTitles = {};
private string[] puchiTitles = { };
private List<int> costumeFlagArraySizes = new();
private int titleFlagArraySize;
private ImmutableDictionary<uint, DanData> danMap = ImmutableDictionary<uint, DanData>.Empty;
@ -46,7 +46,7 @@ public class GameDataService : IGameDataService
var dict = wordList.WordListEntries.GroupBy(entry => entry.Key)
.ToImmutableDictionary(group => group.Key, group => group.First());
await Task.Run(() => InitializeMusicMap(musicInfo, dict, musicOrder));
InitializeCostumeFlagArraySizes(donCosRewardData);
InitializeTitleFlagArraySize(shougouData);
@ -64,7 +64,7 @@ public class GameDataService : IGameDataService
data.ThrowIfNull();
return data;
}
public string GetMusicNameBySongId(uint songId, string? language = "ja")
{
return musicMap.TryGetValue(songId, out var musicDetail) ? language switch
@ -150,12 +150,12 @@ public class GameDataService : IGameDataService
{
return titles;
}
public List<int> GetCostumeFlagArraySizes()
{
return costumeFlagArraySizes;
}
private void InitializeTitleFlagArraySize(Shougous? shougouData)
{
shougouData.ThrowIfNull("Shouldn't happen!");
@ -165,20 +165,21 @@ public class GameDataService : IGameDataService
private void InitializeTitles(ImmutableDictionary<string, WordListEntry> dict, Shougous? shougouData)
{
shougouData.ThrowIfNull("Shouldn't happen!");
var set = ImmutableHashSet.CreateBuilder<Title>();
for (var i = 1; i < titleFlagArraySize; i++)
{
var key = $"syougou_{i}";
var titleWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
var titleRarity = shougouData.ShougouEntries
.Where(entry => entry.UniqueId == i)
.Select(entry => entry.Rarity)
.FirstOrDefault();
set.Add(new Title{
set.Add(new Title
{
TitleName = titleWordlistItem.JapaneseText,
TitleId = i,
TitleRarity = titleRarity
@ -187,7 +188,7 @@ public class GameDataService : IGameDataService
titles = set.ToImmutable();
}
private void InitializeCostumeFlagArraySizes(DonCosRewards? donCosRewardData)
{
donCosRewardData.ThrowIfNull("Shouldn't happen!");
@ -206,7 +207,7 @@ public class GameDataService : IGameDataService
var puchiUniqueIdList = donCosRewardData.DonCosRewardEntries
.Where(entry => entry.CosType == "puchi")
.Select(entry => entry.UniqueId);
costumeFlagArraySizes = new List<int>
{
(int)kigurumiUniqueIdList.Max() + 1,
@ -216,7 +217,7 @@ public class GameDataService : IGameDataService
(int)puchiUniqueIdList.Max() + 1
};
}
private void InitializeKigurumiTitles(ImmutableDictionary<string, WordListEntry> dict)
{
var costumeKigurumiMax = costumeFlagArraySizes[0];
@ -229,7 +230,7 @@ public class GameDataService : IGameDataService
kigurumiTitles[i] = costumeWordlistItem.JapaneseText;
}
}
private void InitializeHeadTitles(ImmutableDictionary<string, WordListEntry> dict)
{
var costumeHeadMax = costumeFlagArraySizes[1];
@ -242,7 +243,7 @@ public class GameDataService : IGameDataService
headTitles[i] = costumeWordlistItem.JapaneseText;
}
}
private void InitializeBodyTitles(ImmutableDictionary<string, WordListEntry> dict)
{
var costumeBodyMax = costumeFlagArraySizes[2];
@ -255,7 +256,7 @@ public class GameDataService : IGameDataService
bodyTitles[i] = costumeWordlistItem.JapaneseText;
}
}
private void InitializeFaceTitles(ImmutableDictionary<string, WordListEntry> dict)
{
var costumeFaceMax = costumeFlagArraySizes[3];

View File

@ -6,7 +6,7 @@ namespace TaikoWebUI.Services;
public interface IGameDataService
{
public Task InitializeAsync(string dataBaseUrl);
public string GetMusicNameBySongId(uint songId, string? language = null);
public string GetMusicArtistBySongId(uint songId, string? language = null);
@ -24,7 +24,7 @@ public interface IGameDataService
public string GetBodyTitle(uint index);
public string GetFaceTitle(uint index);
public string GetPuchiTitle(uint index);
public List<int> GetCostumeFlagArraySizes();
public ImmutableHashSet<Title> GetTitles();

View File

@ -53,7 +53,7 @@ public class LoginService
DashboardResponse response, HttpClient client)
{
if (OnlyAdmin) return 0;
foreach (var user in response.Users.Where(user => user.AccessCodes.Contains(inputCardNum)))
{
foreach (var userCredential in response.UserCredentials.Where(userCredential => userCredential.Baid == user.Baid))
@ -143,7 +143,7 @@ public class LoginService
{
return LoggedInUser;
}
public void ResetLoggedInUser(DashboardResponse? response)
{
if (response is null) return;

View File

@ -2,11 +2,11 @@
public class WebUiSettings
{
public bool LoginRequired { get; set; }
public bool OnlyAdmin { get; set; }
public int BoundAccessCodeUpperLimit { get; set; }
public bool RegisterWithLastPlayTime { get; set; }
public bool AllowUserDelete { get; set; }
public bool AllowFreeProfileEditing { get; set; }
public Language[] SupportedLanguages { get; set; } = Array.Empty<Language>();
public bool LoginRequired { get; set; }
public bool OnlyAdmin { get; set; }
public int BoundAccessCodeUpperLimit { get; set; }
public bool RegisterWithLastPlayTime { get; set; }
public bool AllowUserDelete { get; set; }
public bool AllowFreeProfileEditing { get; set; }
public Language[] SupportedLanguages { get; set; } = Array.Empty<Language>();
}

View File

@ -2,7 +2,7 @@
@using Microsoft.Extensions.Options
@using TaikoWebUI.Settings
@inject NavigationManager NavigationManager
@inject IJSRuntime JSRuntime
@inject IJSRuntime JSRuntime
@inject IOptions<WebUiSettings> Settings
<MudMenu Icon="@Icons.Material.Filled.Language" Color="Color.Inherit">
@ -12,8 +12,7 @@
}
</MudMenu>
@code{
@code {
public Dictionary<CultureInfo, string> SupportedCultures = new();
protected override void OnInitialized()
@ -43,4 +42,3 @@
}
}

View File

@ -5,8 +5,8 @@ public static class Constants
public const int COSTUME_COLOR_MAX = 63;
public const string MUSIC_INFO_BASE_NAME = "musicinfo";
public const string WORDLIST_BASE_NAME = "wordlist";
public const string MUSIC_ORDER_BASE_NAME = "music_order";
public const string DON_COS_REWARD_BASE_NAME = "don_cos_reward";
public const string SHOUGOU_BASE_NAME = "shougou";
public const string WORDLIST_BASE_NAME = "wordlist";
public const string MUSIC_ORDER_BASE_NAME = "music_order";
public const string DON_COS_REWARD_BASE_NAME = "don_cos_reward";
public const string SHOUGOU_BASE_NAME = "shougou";
}

View File

@ -1,20 +1,20 @@
@inherits LayoutComponentBase
<MudThemeProvider/>
<MudDialogProvider/>
<MudSnackbarProvider/>
<MudThemeProvider />
<MudDialogProvider />
<MudSnackbarProvider />
<MudLayout>
<MudAppBar Elevation="0">
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())"/>
<MudSpacer/>
<ChooseLanguage/>
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" />
<MudSpacer />
<ChooseLanguage />
</MudAppBar>
<MudDrawer @bind-Open="_drawerOpen" Elevation="1">
<MudDrawerHeader>
<MudText Typo="Typo.h6">TaikoWebUI</MudText>
</MudDrawerHeader>
<NavMenu/>
<NavMenu />
</MudDrawer>
<MudMainContent>
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="my-8">

View File

@ -4,9 +4,9 @@ namespace TaikoWebUI.Shared.Models;
public class DonCosRewardEntry
{
[JsonPropertyName("cosType")]
public string CosType { get; set; } = null!;
[JsonPropertyName("cosType")]
public string CosType { get; set; } = null!;
[JsonPropertyName("uniqueId")]
public uint UniqueId { get; set; }
[JsonPropertyName("uniqueId")]
public uint UniqueId { get; set; }
}

View File

@ -4,6 +4,6 @@ namespace TaikoWebUI.Shared.Models;
public class DonCosRewards
{
[JsonPropertyName("items")]
public List<DonCosRewardEntry> DonCosRewardEntries { get; set; } = new();
[JsonPropertyName("items")]
public List<DonCosRewardEntry> DonCosRewardEntries { get; set; } = new();
}

View File

@ -3,28 +3,28 @@
public class MusicDetail
{
public uint SongId { get; set; }
public int Index { get; set; }
public string SongName { get; set; } = string.Empty;
public string SongNameEN { get; set; } = string.Empty;
public string SongNameCN { get; set; } = string.Empty;
public string SongNameKO { get; set; } = string.Empty;
public string ArtistName { get; set; } = string.Empty;
public string ArtistNameEN { get; set; } = string.Empty;
public string ArtistNameCN { get; set; } = string.Empty;
public string ArtistNameKO { get; set; } = string.Empty;
public SongGenre Genre { get; set; }
public int StarEasy { get; set; }
public int StarNormal { get; set; }
public int StarHard { get; set; }
public int StarOni { get; set; }
public int StarUra { get; set; }
}

View File

@ -4,6 +4,6 @@ namespace TaikoWebUI.Shared.Models;
public class MusicInfo
{
[JsonPropertyName("items")]
[JsonPropertyName("items")]
public List<MusicInfoEntry> Items { get; set; } = new();
}

View File

@ -9,22 +9,22 @@ public class MusicInfoEntry
[JsonPropertyName("uniqueId")]
public uint SongId { get; set; }
[JsonPropertyName("genreNo")]
public SongGenre Genre { get; set; }
[JsonPropertyName("starEasy")]
public int StarEasy { get; set; }
[JsonPropertyName("starNormal")]
public int StarNormal { get; set; }
[JsonPropertyName("starHard")]
public int StarHard { get; set; }
[JsonPropertyName("starMania")]
public int StarOni { get; set; }
[JsonPropertyName("starUra")]
public int StarUra { get; set; }
}

View File

@ -4,6 +4,6 @@ namespace TaikoWebUI.Shared.Models;
public class NeiroEntry
{
[JsonPropertyName("uniqueId")]
public uint UniqueId { get; set; }
[JsonPropertyName("uniqueId")]
public uint UniqueId { get; set; }
}

View File

@ -4,6 +4,6 @@ namespace TaikoWebUI.Shared.Models;
public class Neiros
{
[JsonPropertyName("items")]
public List<NeiroEntry> NeiroEntries { get; set; } = new();
[JsonPropertyName("items")]
public List<NeiroEntry> NeiroEntries { get; set; } = new();
}

View File

@ -4,9 +4,9 @@ namespace TaikoWebUI.Shared.Models;
public class ShougouEntry
{
[JsonPropertyName("uniqueId")]
public uint UniqueId { get; set; }
[JsonPropertyName("rarity")]
public uint Rarity { get; set; }
[JsonPropertyName("uniqueId")]
public uint UniqueId { get; set; }
[JsonPropertyName("rarity")]
public uint Rarity { get; set; }
}

View File

@ -4,6 +4,6 @@ namespace TaikoWebUI.Shared.Models;
public class Shougous
{
[JsonPropertyName("items")]
public List<ShougouEntry> ShougouEntries { get; set; } = new();
[JsonPropertyName("items")]
public List<ShougouEntry> ShougouEntries { get; set; } = new();
}

View File

@ -3,9 +3,9 @@
public class Title
{
public int TitleId { get; set; }
public string TitleName { get; init; } = string.Empty;
public uint TitleRarity { get; init; }
public override bool Equals(object? obj)

View File

@ -6,16 +6,16 @@ public class WordListEntry
{
[JsonPropertyName("key")]
public string Key { get; set; } = string.Empty;
[JsonPropertyName("japaneseText")]
public string JapaneseText { get; set; } = string.Empty;
[JsonPropertyName("englishUsText")]
public string EnglishUsText { get; set; } = string.Empty;
[JsonPropertyName("chineseTText")]
public string ChineseTText { get; set; } = string.Empty;
[JsonPropertyName("koreanText")]
public string KoreanText { get; set; } = string.Empty;
}