1
0
mirror of synced 2024-11-28 00:20:53 +01:00

Refactor costume related functions

This commit is contained in:
asesidaa 2022-09-15 13:18:50 +08:00
parent 17f89fde88
commit f8ef701b86
6 changed files with 346 additions and 281 deletions

View File

@ -6,6 +6,7 @@ global using Microsoft.AspNetCore.Components.Web;
global using MudBlazor;
global using TaikoWebUI;
global using TaikoWebUI.Services;
global using TaikoWebUI.Shared;
global using SharedProject.Models;
global using SharedProject.Models.Requests;
global using SharedProject.Models.Responses;

View File

@ -1,5 +1,6 @@
@page "/Cards/{baid:int}/Profile"
@inject HttpClient Client
@inject IGameDataService GameDataService
<MudBreadcrumbs Items="breadcrumbs" Class="px-0"></MudBreadcrumbs>
@ -9,213 +10,212 @@
@if (response is not null)
{
<MudGrid Class="my-4 pb-10">
<MudItem xs="12" md="8">
<MudPaper Elevation="0" Outlined="true">
<MudTabs Rounded="true" Border="true" PanelClass="pa-8">
<MudTabPanel Text="Profile">
<MudStack Spacing="4">
<h2>Profile Options</h2>
<MudItem xs="12" md="8">
<MudPaper Elevation="0" Outlined="true">
<MudTabs Rounded="true" Border="true" PanelClass="pa-8">
<MudTabPanel Text="Profile">
<MudStack Spacing="4">
<h2>Profile Options</h2>
<MudTextField @bind-Value="@response.MyDonName" Label="Name"></MudTextField>
<MudTextField @bind-Value="@response.MyDonName" Label="Name"></MudTextField>
<MudGrid>
<MudItem xs="12" md="8">
@if (EnterTextDirectly)
<MudGrid>
<MudItem xs="12" md="8">
@if (enterTextDirectly)
{
<MudTextField @bind-Value="@response.Title" Label="Title"></MudTextField>
}
else
{
<MudAutocomplete @bind-Value="@response.Title" Label="Title"
Dense="true" Clearable="true" Immediate="true"
SearchFunc="@SearchForTitle" CoerceValue="true" CoerceText="true"
MaxItems="@Constants.PLAYER_TITLE_MAX"/>
}
<MudSwitch @bind-Checked="enterTextDirectly" Class="mud-width-full" Color="Color.Primary">Enter Text Directly</MudSwitch>
</MudItem>
<MudItem xs="12" md="4">
<MudSelect @bind-Value="@response.TitlePlateId" Label="Title Plate">
@for (uint i = 0; i < 8; i++)
{
<MudTextField @bind-Value="@response.Title" Label ="Title"></MudTextField>
var index = i;
<MudSelectItem Value="@i">@TitlePlateStrings[index]</MudSelectItem>
}
else
{
<MudAutocomplete @bind-Value="@response.Title" Label="Title" Dense="true" Clearable="true" Immediate="true" SearchFunc="@SearchForTitle" CoerceValue="true" MaxItems="@GameDataService.PLAYER_TITLE_MAX" />
}
<MudSwitch @bind-Checked="EnterTextDirectly" Color="Color.Primary" Class="mt-1">Enter Text Directly</MudSwitch>
</MudItem>
<MudItem xs="12" md="4">
<MudSelect @bind-Value="@response.TitlePlateId" Label="Title Plate">
@for (uint i = 0; i < 8; i++)
</MudSelect>
</MudItem>
</MudGrid>
<MudSelect @bind-Value="@response.AchievementDisplayDifficulty"
Label="Achievement Panel Difficulty">
@foreach (var item in Enum.GetValues<Difficulty>())
{
<MudSelectItem Value="@item"/>
}
</MudSelect>
<MudSwitch @bind-Checked="@response.IsDisplayAchievement" Label="Display Achievement Panel" Color="Color.Primary"/>
<MudSwitch @bind-Checked="@response.IsDisplayDanOnNamePlate" Label="Display Dan Rank on Name Plate" Color="Color.Primary"/>
</MudStack>
</MudTabPanel>
<MudTabPanel Text="Costume">
<MudStack Spacing="4">
<h2>Costume Options</h2>
<MudGrid>
<MudItem xs="12">
<MudStack Spacing="4" Class="mb-8">
<MudSelect @bind-Value="@response.Head" Label="Head">
@for (var i = 0; i < Constants.COSTUME_HEAD_MAX; i++)
{
var index = i;
<MudSelectItem Value="@i">@titlePlateStrings[index]</MudSelectItem>
var index = (uint)i;
var costumeTitle = GameDataService.GetHeadTitle(index);
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
</MudItem>
</MudGrid>
<MudSelect @bind-Value="@response.AchievementDisplayDifficulty"
Label="Achievement Panel Difficulty">
@foreach (var item in Enum.GetValues<Difficulty>())
{
<MudSelectItem Value="@item"/>
}
</MudSelect>
<MudSelect @bind-Value="@response.Body" Label="Body">
@for (var i = 0; i < Constants.COSTUME_BODY_MAX; i++)
{
var index = (uint)i;
var costumeTitle = GameDataService.GetBodyTitle(index);
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudSwitch @bind-Checked="@response.IsDisplayAchievement" Label="Display Achievement Panel" Color="Color.Primary"/>
<MudSwitch @bind-Checked="@response.IsDisplayDanOnNamePlate" Label="Display Dan Rank on Name Plate" Color="Color.Primary"/>
</MudStack>
</MudTabPanel>
<MudSelect @bind-Value="@response.Face" Label="Face">
@for (var i = 0; i < Constants.COSTUME_FACE_MAX; i++)
{
var index = (uint)i;
var costumeTitle = GameDataService.GetFaceTitle(index);
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudTabPanel Text="Costume">
<MudStack Spacing="4">
<h2>Costume Options</h2>
<MudGrid>
<MudItem xs="12">
<MudStack Spacing="4" Class="mb-8">
<MudSelect @bind-Value="@response.Head" Label="Head">
@for (uint i = 0; i < GameDataService.COSTUME_HEAD_MAX; i++)
{
var index = i;
var costumeTitle = GameDataService.headMap[index];
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.Kigurumi" Label="Kigurumi">
@for (var i = 0; i < Constants.COSTUME_KIGURUMI_MAX; i++)
{
var index = (uint)i;
var costumeTitle = GameDataService.GetKigurumiTitle(index);
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.Body" Label="Body">
@for (uint i = 0; i < GameDataService.COSTUME_BODY_MAX; i++)
{
var index = i;
var costumeTitle = GameDataService.bodyMap[index];
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.Puchi" Label="Puchi">
@for (var i = 0; i < Constants.COSTUME_PUCHI_MAX; i++)
{
var index = (uint)i;
var costumeTitle = GameDataService.GetPuchiTitle(index);
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
</MudStack>
<MudSelect @bind-Value="@response.Face" Label="Face">
@for (uint i = 0; i < GameDataService.COSTUME_FACE_MAX; i++)
{
var index = i;
var costumeTitle = GameDataService.faceMap[index];
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudStack Row="true">
<MudSelect @bind-Value="@response.BodyColor" Label="Body Color">
@for (uint i = 0; i < Constants.COSTUME_COLOR_MAX; i++)
{
var index = i;
<MudSelectItem Value="@index">
<div class="color-box" style=@($"background: {CostumeColors[index]}")></div>
@index
</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.FaceColor" Label="Face Color">
@for (uint i = 0; i < Constants.COSTUME_COLOR_MAX; i++)
{
var index = i;
<MudSelectItem Value="@index">
<div class="color-box" style=@($"background: {CostumeColors[index]}")></div>
@index
</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.LimbColor" Label="Limb Color">
@for (uint i = 0; i < Constants.COSTUME_COLOR_MAX; i++)
{
var index = i;
<MudSelectItem Value="@index">
<div class="color-box" style=@($"background: {CostumeColors[index]}")></div>
@index
</MudSelectItem>
}
</MudSelect>
</MudStack>
</MudItem>
</MudGrid>
</MudStack>
</MudTabPanel>
<MudSelect @bind-Value="@response.Kigurumi" Label="Kigurumi">
@for (uint i = 0; i < GameDataService.COSTUME_KIGURUMI_MAX; i++)
{
var index = i;
var costumeTitle = GameDataService.kigurumiMap[index];
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudTabPanel Text="Song Options">
<MudStack Spacing="4">
<h2>Song Options</h2>
<MudGrid>
<MudItem xs="12" md="4">
<MudStack Spacing="4">
<MudSwitch @bind-Checked="@response.PlaySetting.IsVanishOn" Label="Vanish" Color="Color.Primary"/>
<MudSwitch @bind-Checked="@response.PlaySetting.IsInverseOn" Label="Inverse" Color="Color.Primary"/>
<MudSwitch @bind-Checked="@response.IsSkipOn" Label="Give Up" Color="Color.Primary"/>
<MudSwitch @bind-Checked="@response.IsVoiceOn" Label="Voice" Color="Color.Primary"/>
</MudStack>
</MudItem>
<MudItem xs="12" md="8">
<MudStack Spacing="4">
<MudSelect @bind-Value="@response.PlaySetting.Speed" Label="Speed">
@for (uint i = 0; i < 15; i++)
{
var index = i;
<MudSelectItem Value="@i">@SpeedStrings[index]</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.Puchi" Label="Puchi">
@for (uint i = 0; i < GameDataService.COSTUME_PUCHI_MAX; i++)
{
var index = i;
var costumeTitle = GameDataService.puchiMap[index];
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
</MudStack>
<MudSelect @bind-Value="@response.PlaySetting.RandomType"
Label="Random">
@foreach (var item in Enum.GetValues<RandomType>())
{
<MudSelectItem Value="@item"/>
}
</MudSelect>
<MudStack Row="true">
<MudSelect @bind-Value="@response.BodyColor" Label="Body Color">
@for (uint i = 0; i < GameDataService.COSTUME_COLOR_MAX; i++)
{
var index = i;
<MudSelectItem Value="@index">
<div class="color-box" style=@($"background: {costumeColors[index]}")></div>
@index
</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.FaceColor" Label="Face Color">
@for (uint i = 0; i < GameDataService.COSTUME_COLOR_MAX; i++)
{
var index = i;
<MudSelectItem Value="@index">
<div class="color-box" style=@($"background: {costumeColors[index]}")></div>
@index
</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.LimbColor" Label="Limb Color">
@for (uint i = 0; i < GameDataService.COSTUME_COLOR_MAX; i++)
{
var index = i;
<MudSelectItem Value="@index">
<div class="color-box" style=@($"background: {costumeColors[index]}")></div>
@index
</MudSelectItem>
}
</MudSelect>
</MudStack>
</MudItem>
</MudGrid>
</MudStack>
</MudTabPanel>
<MudSelect @bind-Value="@response.ToneId" Label="Tone">
@for (uint i = 0; i < 19; i++)
{
var index = i;
<MudSelectItem Value="@i">@ToneStrings[index]</MudSelectItem>
}
</MudSelect>
<MudTabPanel Text="Song Options">
<MudStack Spacing="4">
<h2>Song Options</h2>
<MudGrid>
<MudItem xs="12" md="4">
<MudStack Spacing="4">
<MudSwitch @bind-Checked="@response.PlaySetting.IsVanishOn" Label="Vanish" Color="Color.Primary"/>
<MudSwitch @bind-Checked="@response.PlaySetting.IsInverseOn" Label="Inverse" Color="Color.Primary"/>
<MudSwitch @bind-Checked="@response.IsSkipOn" Label="Give Up" Color="Color.Primary"/>
<MudSwitch @bind-Checked="@response.IsVoiceOn" Label="Voice" Color="Color.Primary"/>
</MudStack>
</MudItem>
<MudItem xs="12" md="8">
<MudStack Spacing="4">
<MudSelect @bind-Value="@response.PlaySetting.Speed" Label="Speed">
@for (uint i = 0; i < 15; i++)
{
var index = i;
<MudSelectItem Value="@i">@speedStrings[index]</MudSelectItem>
}
</MudSelect>
<MudSlider Class="mb-8" @bind-Value="@response.NotesPosition" Size="Size.Medium" Min="-5" Max="5" Step="1" TickMarks="true" TickMarkLabels="@NotePositionStrings">
<MudText Typo="Typo.caption">Notes Position</MudText>
</MudSlider>
</MudStack>
</MudItem>
</MudGrid>
</MudStack>
</MudTabPanel>
</MudTabs>
</MudPaper>
</MudItem>
<MudSelect @bind-Value="@response.PlaySetting.RandomType"
Label="Random">
@foreach (var item in Enum.GetValues<RandomType>())
{
<MudSelectItem Value="@item"/>
}
</MudSelect>
<MudItem md="4" xs="12" Class="py-4 px-8">
<MudStack Style="top:100px" Class="sticky">
<MudButton Disabled="@isSavingOptions"
OnClick="SaveOptions"
Variant="Variant.Filled"
Color="Color.Primary">
@if (isSavingOptions)
{
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true"/>
<MudText Class="ms-2">Saving...</MudText>
}
else
{
<MudIcon Icon="@Icons.Filled.Save" Class="mx-2"></MudIcon>
<MudText>Save</MudText>
}
</MudButton>
</MudStack>
<MudSelect @bind-Value="@response.ToneId" Label="Tone">
@for (uint i = 0; i < 19; i++)
{
var index = i;
<MudSelectItem Value="@i">@toneStrings[index]</MudSelectItem>
}
</MudSelect>
<MudSlider Class="mb-8" @bind-Value="@response.NotesPosition" Size="Size.Medium" Min="-5" Max="5" Step="1" TickMarks="true" TickMarkLabels="@notePositionStrings">
<MudText Typo="Typo.caption">Notes Position</MudText>
</MudSlider>
</MudStack>
</MudItem>
</MudGrid>
</MudStack>
</MudTabPanel>
</MudTabs>
</MudPaper>
</MudItem>
<MudItem md="4" xs="12" Class="py-4 px-8">
<MudStack Style="top:100px" Class="sticky">
<MudButton Disabled="@isSavingOptions"
OnClick="SaveOptions"
Variant="Variant.Filled"
Color="Color.Primary">
@if (isSavingOptions)
{
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true"/>
<MudText Class="ms-2">Saving...</MudText>
}
else
{
<MudIcon Icon="@Icons.Filled.Save" Class="mx-2"></MudIcon>
<MudText>Save</MudText>
}
</MudButton>
</MudStack>
</MudItem>
</MudItem>
</MudGrid>
@code {
private bool EnterTextDirectly;
}
}

View File

@ -12,7 +12,9 @@ public partial class Profile
private bool isSavingOptions;
public string[] costumeColors =
private bool enterTextDirectly;
private static readonly string[] CostumeColors =
{
"#F84828", "#68C0C0", "#DC1500", "#F8F0E0", "#009687", "#00BF87",
"#00FF9A", "#66FFC2", "#FFFFFF", "#690000", "#FF0000", "#FF6666",
@ -27,16 +29,16 @@ public partial class Profile
"#FF66BF", "#FFB3DF", "#000000"
};
private readonly string[] speedStrings =
private static readonly string[] SpeedStrings =
{
"1.0", "1.1", "1.2", "1.3", "1.4",
"1.5", "1.6", "1.7", "1.8", "1.9",
"2.0", "2.5", "3.0", "3.5", "4.0"
};
private readonly string[] notePositionStrings = { "-5", "-4", "-3", "-2", "-1", "0", "+1", "+2", "+3", "+4", "+5" };
private static readonly string[] NotePositionStrings = { "-5", "-4", "-3", "-2", "-1", "0", "+1", "+2", "+3", "+4", "+5" };
private readonly string[] toneStrings =
private static readonly string[] ToneStrings =
{
"Taiko", "Festival", "Dogs & Cats", "Deluxe",
"Drumset", "Tambourine", "Don Wada", "Clapping",
@ -45,13 +47,13 @@ public partial class Profile
"Synth Drum", "Shuriken", "Bubble Pop", "Electric Guitar"
};
private readonly string[] titlePlateStrings =
private static readonly string[] TitlePlateStrings =
{
"Wood", "Rainbow", "Gold", "Purple",
"AI 1", "AI 2", "AI 3", "AI 4"
};
private List<BreadcrumbItem> breadcrumbs = new()
private readonly List<BreadcrumbItem> breadcrumbs = new()
{
new BreadcrumbItem("Cards", href: "/Cards"),
};
@ -73,15 +75,12 @@ public partial class Profile
isSavingOptions = false;
}
#pragma warning disable CS1998
private async Task<IEnumerable<string>> SearchForTitle(string value)
#pragma warning restore CS1998
{
var titles = GameDataService.titleMap;
var titles = GameDataService.GetTitles();
if (string.IsNullOrWhiteSpace(value))
{
return titles.Values;
}
return titles.Values.Where(x => x.Contains(value, StringComparison.OrdinalIgnoreCase));
return string.IsNullOrWhiteSpace(value) ? titles : titles.Where(x => x.Contains(value, StringComparison.OrdinalIgnoreCase));
}
}

View File

@ -11,23 +11,15 @@ public class GameDataService : IGameDataService
private readonly Dictionary<uint, MusicDetail> musicMap = new();
private ImmutableDictionary<uint, DanData> danMap = null!;
private ImmutableDictionary<uint, DanData> danMap = ImmutableDictionary<uint, DanData>.Empty;
public const int COSTUME_HEAD_MAX = 140;
public const int COSTUME_FACE_MAX = 58;
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 = 750;
private ImmutableHashSet<string> titles = ImmutableHashSet<string>.Empty;
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();
private readonly string[] headTitles = new string[Constants.COSTUME_HEAD_MAX];
private readonly string[] faceTitles = new string[Constants.COSTUME_FACE_MAX];
private readonly string[] bodyTitles = new string[Constants.COSTUME_BODY_MAX];
private readonly string[] kigurumiMTitles = new string[Constants.COSTUME_KIGURUMI_MAX];
private readonly string[] puchiTitles = new string[Constants.COSTUME_PUCHI_MAX];
public GameDataService(HttpClient client)
{
@ -51,6 +43,88 @@ public class GameDataService : IGameDataService
// To prevent duplicate entries in wordlist
var dict = wordList.WordListEntries.GroupBy(entry => entry.Key)
.ToImmutableDictionary(group => group.Key, group => group.First());
await Task.Run(()=>InitializeMusicMap(musicInfo, dict, musicOrder));
await Task.Run(() => InitializeHeadTitles(dict));
await Task.Run(() => InitializeFaceTitles(dict));
await Task.Run(() => InitializeBodyTitles(dict));
await Task.Run(() => InitializePuchiTitles(dict));
await Task.Run(() => InitializeKigurumiTitles(dict));
await Task.Run(() => InitializeTitles(dict));
}
private void InitializeTitles(ImmutableDictionary<string, WordListEntry> dict)
{
var set = ImmutableHashSet.CreateBuilder<string>();
for (var i = 1; i < Constants.PLAYER_TITLE_MAX; i++)
{
var key = $"syougou_{i}";
var titleWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
set.Add(titleWordlistItem.JapaneseText);
}
titles = set.ToImmutable();
}
private void InitializePuchiTitles(ImmutableDictionary<string, WordListEntry> dict)
{
for (var i = 0; i < Constants.COSTUME_PUCHI_MAX; i++)
{
var key = $"costume_puchi_{i}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
puchiTitles[i] = costumeWordlistItem.JapaneseText;
}
}
private void InitializeKigurumiTitles(ImmutableDictionary<string, WordListEntry> dict)
{
for (var i = 0; i < Constants.COSTUME_KIGURUMI_MAX; i++)
{
var key = $"costume_kigurumi_{i}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
kigurumiMTitles[i] = costumeWordlistItem.JapaneseText;
}
}
private void InitializeBodyTitles(ImmutableDictionary<string, WordListEntry> dict)
{
for (var i = 0; i < Constants.COSTUME_BODY_MAX; i++)
{
var key = $"costume_body_{i}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
bodyTitles[i] = costumeWordlistItem.JapaneseText;
}
}
private void InitializeFaceTitles(ImmutableDictionary<string, WordListEntry> dict)
{
for (var i = 0; i < Constants.COSTUME_FACE_MAX; i++)
{
var key = $"costume_face_{i}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
faceTitles[i] = costumeWordlistItem.JapaneseText;
}
}
private void InitializeHeadTitles(ImmutableDictionary<string, WordListEntry> dict)
{
for (var i = 0; i < Constants.COSTUME_HEAD_MAX; i++)
{
var key = $"costume_head_{i}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
headTitles[i] = costumeWordlistItem.JapaneseText;
}
}
private void InitializeMusicMap(MusicInfo musicInfo, ImmutableDictionary<string, WordListEntry> dict, MusicOrder musicOrder)
{
foreach (var music in musicInfo.Items)
{
var songNameKey = $"song_{music.Id}";
@ -76,67 +150,6 @@ public class GameDataService : IGameDataService
musicMap[songId].Index = index;
}
}
for (var i = 0; i < COSTUME_HEAD_MAX; i++)
{
var index = i;
var key = $"costume_head_{index}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
headMap[index] = costumeWordlistItem.JapaneseText;
}
for (var i = 0; i < COSTUME_FACE_MAX; i++)
{
var index = i;
var key = $"costume_face_{index}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
faceMap[index] = costumeWordlistItem.JapaneseText;
}
for (var i = 0; i < COSTUME_BODY_MAX; i++)
{
var index = i;
var key = $"costume_body_{index}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
bodyMap[index] = costumeWordlistItem.JapaneseText;
}
for (var i = 0; i < COSTUME_KIGURUMI_MAX; i++)
{
var index = i;
var key = $"costume_kigurumi_{index}";
var costumeWordlistItem = dict.GetValueOrDefault(key, new WordListEntry());
kigurumiMap[index] = costumeWordlistItem.JapaneseText;
}
for (var i = 0; i < COSTUME_PUCHI_MAX; i++)
{
var index = i;
var key = $"costume_puchi_{index}";
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)
@ -176,4 +189,34 @@ public class GameDataService : IGameDataService
_ => throw new ArgumentOutOfRangeException(nameof(difficulty), difficulty, null)
};
}
public string GetHeadTitle(uint index)
{
return index < headTitles.Length ? headTitles[index] : string.Empty;
}
public string GetKigurumiTitle(uint index)
{
return index < kigurumiMTitles.Length ? kigurumiMTitles[index] : string.Empty;
}
public string GetBodyTitle(uint index)
{
return index < bodyTitles.Length ? bodyTitles[index] : string.Empty;
}
public string GetFaceTitle(uint index)
{
return index < faceTitles.Length ? faceTitles[index] : string.Empty;
}
public string GetPuchiTitle(uint index)
{
return index < puchiTitles.Length ? puchiTitles[index] : string.Empty;
}
public IEnumerable<string> GetTitles()
{
return titles.ToArray();
}
}

View File

@ -1,4 +1,6 @@
namespace TaikoWebUI.Services;
using System.Collections.Immutable;
namespace TaikoWebUI.Services;
public interface IGameDataService
{
@ -15,4 +17,12 @@ public interface IGameDataService
public DanData GetDanDataById(uint danId);
public int GetMusicStarLevel(uint songId, Difficulty difficulty);
public string GetHeadTitle(uint index);
public string GetKigurumiTitle(uint index);
public string GetBodyTitle(uint index);
public string GetFaceTitle(uint index);
public string GetPuchiTitle(uint index);
public IEnumerable<string> GetTitles();
}

View File

@ -0,0 +1,12 @@
namespace TaikoWebUI.Shared;
public static class Constants
{
public const int COSTUME_HEAD_MAX = 140;
public const int COSTUME_FACE_MAX = 58;
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 = 750;
}