1
0
mirror of synced 2024-11-27 16:10:53 +01:00

Add autocomplete for player title

This commit is contained in:
shiibe 2022-09-14 17:20:55 -04:00
parent 0e3a54eeef
commit 128f2834fe
3 changed files with 39 additions and 8 deletions

View File

@ -20,7 +20,7 @@
<MudGrid>
<MudItem xs="12" md="8">
<MudTextField @bind-Value="@response.Title" Label="Title"></MudTextField>
<MudAutocomplete @bind-Value="@response.Title" Label="Title" SearchFunc="@SearchForTitle" CoerceValue="true" MaxItems="@GameDataService.PLAYER_TITLE_MAX" />
</MudItem>
<MudItem xs="12" md="4">
<MudSelect @bind-Value="@response.TitlePlateId" Label="Title Plate">

View File

@ -1,4 +1,5 @@
using MudBlazor.Utilities;
using static MudBlazor.Colors;
namespace TaikoWebUI.Pages;
@ -72,4 +73,15 @@ public partial class Profile
isSavingOptions = false;
}
private async Task<IEnumerable<string>> SearchForTitle(string value)
{
var titles = GameDataService.titleMap;
if (string.IsNullOrWhiteSpace(value))
{
return titles.Values;
}
return titles.Values.Where(x => x.Contains(value, StringComparison.OrdinalIgnoreCase));
}
}

View File

@ -13,19 +13,22 @@ public class GameDataService : IGameDataService
private ImmutableDictionary<uint, DanData> danMap = null!;
public const uint COSTUME_HEAD_MAX = 140;
public const uint COSTUME_FACE_MAX = 59;
public const uint COSTUME_BODY_MAX = 156;
public const uint COSTUME_KIGURUMI_MAX = 154;
public const uint COSTUME_PUCHI_MAX = 129;
public const uint COSTUME_COLOR_MAX = 63;
public const int COSTUME_HEAD_MAX = 140;
public const int COSTUME_FACE_MAX = 59;
public const int COSTUME_BODY_MAX = 156;
public const int COSTUME_KIGURUMI_MAX = 154;
public const int COSTUME_PUCHI_MAX = 129;
public const int COSTUME_COLOR_MAX = 63;
public const int PLAYER_TITLE_MAX = 749;
public static string[] headMap = new string[COSTUME_HEAD_MAX];
public static string[] faceMap = new string[COSTUME_FACE_MAX];
public static string[] bodyMap = new string[COSTUME_BODY_MAX];
public static string[] kigurumiMap = new string[COSTUME_KIGURUMI_MAX];
public static string[] puchiMap = new string[COSTUME_PUCHI_MAX];
public static Dictionary<int, string> titleMap = new();
public GameDataService(HttpClient client)
{
this.client = client;
@ -118,6 +121,22 @@ public class GameDataService : IGameDataService
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
puchiMap[index] = costumeWordlistItem.JapaneseText;
}
for (var i = 1; i < PLAYER_TITLE_MAX; i++)
{
var index = i;
var key = $"syougou_{index}";
var titleWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
// prevent duplicate values with different keys
if (titleMap.ContainsValue(titleWordlistItem.JapaneseText))
{
continue;
}
titleMap.TryAdd(index, titleWordlistItem.JapaneseText);
}
}
public string GetMusicNameBySongId(uint songId)