diff --git a/SharedProject/Enums/RandomType.cs b/SharedProject/Enums/RandomType.cs
new file mode 100644
index 0000000..36d6361
--- /dev/null
+++ b/SharedProject/Enums/RandomType.cs
@@ -0,0 +1,8 @@
+namespace SharedProject.Enums;
+
+public enum RandomType
+{
+ None = 0,
+ Whimsical = 1,
+ Messy = 2
+}
\ No newline at end of file
diff --git a/SharedProject/Models/PlaySetting.cs b/SharedProject/Models/PlaySetting.cs
new file mode 100644
index 0000000..c554bf4
--- /dev/null
+++ b/SharedProject/Models/PlaySetting.cs
@@ -0,0 +1,14 @@
+using SharedProject.Enums;
+
+namespace SharedProject.Models;
+
+public class PlaySetting
+{
+ public uint Speed { get; set; }
+
+ public bool IsVanishOn { get; set; }
+
+ public bool IsInverseOn { get; set; }
+
+ public RandomType RandomType { get; set; }
+}
\ No newline at end of file
diff --git a/SharedProject/Models/Responses/UserSettingResponse.cs b/SharedProject/Models/Responses/UserSettingResponse.cs
deleted file mode 100644
index c6e484d..0000000
--- a/SharedProject/Models/Responses/UserSettingResponse.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace SharedProject.Models.Responses;
-
-public class UserSettingResponse
-{
- public uint Baid { get; set; }
-
-
-}
\ No newline at end of file
diff --git a/SharedProject/Models/UserSetting.cs b/SharedProject/Models/UserSetting.cs
new file mode 100644
index 0000000..3b5fa5f
--- /dev/null
+++ b/SharedProject/Models/UserSetting.cs
@@ -0,0 +1,22 @@
+using SharedProject.Enums;
+
+namespace SharedProject.Models;
+
+public class UserSetting
+{
+ public uint ToneId { get; set; }
+
+ public bool IsDisplayAchievement { get; set; }
+
+ public bool IsDisplayDanOnNamePlate { get; set; }
+
+ public bool IsVoiceOn { get; set; }
+
+ public bool IsSkipOn { get; set; }
+
+ public Difficulty AchievementDisplayDifficulty { get; set; }
+
+ public PlaySetting PlaySetting { get; set; } = new();
+
+ public int NotesPosition { get; set; }
+}
\ No newline at end of file
diff --git a/SharedProject/SharedProject.csproj b/SharedProject/SharedProject.csproj
index 4934f24..e3c7c83 100644
--- a/SharedProject/SharedProject.csproj
+++ b/SharedProject/SharedProject.csproj
@@ -10,4 +10,8 @@
+
+
+
+
diff --git a/SharedProject/Utils/PlaySettingConverter.cs b/SharedProject/Utils/PlaySettingConverter.cs
new file mode 100644
index 0000000..ec29632
--- /dev/null
+++ b/SharedProject/Utils/PlaySettingConverter.cs
@@ -0,0 +1,48 @@
+using System.Buffers.Binary;
+using System.Collections;
+using System.Collections.Specialized;
+using SharedProject.Enums;
+using SharedProject.Models;
+using Throw;
+
+namespace SharedProject.Utils;
+
+public static class PlaySettingConverter
+{
+ public static PlaySetting ShortToPlaySetting(short input)
+ {
+ var bits = new BitVector32(input);
+ var speedSection = BitVector32.CreateSection(15);
+ var vanishSection = BitVector32.CreateSection(1, speedSection);
+ var inverseSection = BitVector32.CreateSection(1, vanishSection);
+ var randomSection = BitVector32.CreateSection(2, inverseSection);
+
+ var randomType = (RandomType)bits[randomSection];
+ randomType.Throw().IfOutOfRange();
+ var result = new PlaySetting
+ {
+ Speed = (uint)bits[speedSection],
+ IsVanishOn = bits[vanishSection] == 1,
+ IsInverseOn = bits[inverseSection] == 1,
+ RandomType = randomType
+ };
+
+ return result;
+ }
+
+ public static short PlaySettingToShort(PlaySetting setting)
+ {
+ var bits = new BitVector32();
+ var speedSection = BitVector32.CreateSection(15);
+ var vanishSection = BitVector32.CreateSection(1, speedSection);
+ var inverseSection = BitVector32.CreateSection(1, vanishSection);
+ var randomSection = BitVector32.CreateSection(2, inverseSection);
+
+ bits[speedSection] = (int)setting.Speed;
+ bits[vanishSection] = setting.IsVanishOn ? 1 : 0;
+ bits[inverseSection] = setting.IsInverseOn ? 1 : 0;
+ bits[randomSection] = (int)setting.RandomType;
+
+ return (short)bits.Data;
+ }
+}
\ No newline at end of file
diff --git a/TaikoLocalServer/Controllers/Api/UserSettingsController.cs b/TaikoLocalServer/Controllers/Api/UserSettingsController.cs
index f7e6c15..4cde4c2 100644
--- a/TaikoLocalServer/Controllers/Api/UserSettingsController.cs
+++ b/TaikoLocalServer/Controllers/Api/UserSettingsController.cs
@@ -1,9 +1,12 @@
-using SharedProject.Models.Responses;
+using System.Buffers.Binary;
+using SharedProject.Models;
+using SharedProject.Models.Responses;
+using SharedProject.Utils;
namespace TaikoLocalServer.Controllers.Api;
[ApiController]
-[Route("/api/[controller]")]
+[Route("/api/[controller]/{baid}")]
public class UserSettingsController : BaseController
{
private readonly TaikoDbContext context;
@@ -13,8 +16,8 @@ public class UserSettingsController : BaseController
this.context = context;
}
- [HttpGet("{baid}")]
- public async Task> GetUserSettingResponse(uint baid)
+ [HttpGet]
+ public async Task> GetUserSetting(uint baid)
{
var user = await context.UserData.FirstOrDefaultAsync(datum => datum.Baid == baid);
@@ -23,11 +26,43 @@ public class UserSettingsController : BaseController
return NotFound();
}
- var response = new UserSettingResponse
+ var response = new UserSetting
{
-
+ AchievementDisplayDifficulty = user.AchievementDisplayDifficulty,
+ IsDisplayAchievement = user.DisplayAchievement,
+ IsDisplayDanOnNamePlate = user.DisplayDan,
+ IsVoiceOn = user.IsVoiceOn,
+ IsSkipOn = user.IsSkipOn,
+ NotesPosition = user.NotesPosition,
+ PlaySetting = PlaySettingConverter.ShortToPlaySetting(user.OptionSetting),
+ ToneId = user.SelectedToneId
};
return Ok(response);
}
-
+
+ [HttpPost]
+ public async Task SaveUserSetting(uint baid, UserSetting userSetting)
+ {
+ var user = await context.UserData.FirstOrDefaultAsync(datum => datum.Baid == baid);
+
+ if (user is null)
+ {
+ return NotFound();
+ }
+
+ user.IsSkipOn = userSetting.IsSkipOn;
+ user.IsVoiceOn = userSetting.IsVoiceOn;
+ user.DisplayAchievement = userSetting.IsDisplayAchievement;
+ user.DisplayDan = userSetting.IsDisplayDanOnNamePlate;
+ user.NotesPosition = userSetting.NotesPosition;
+ user.SelectedToneId = userSetting.ToneId;
+ user.AchievementDisplayDifficulty = userSetting.AchievementDisplayDifficulty;
+ user.OptionSetting = PlaySettingConverter.PlaySettingToShort(userSetting.PlaySetting);
+
+ context.Update(user);
+ await context.SaveChangesAsync();
+
+ return NoContent();
+ }
+
}
\ No newline at end of file
diff --git a/TaikoLocalServer/Controllers/Game/BaidController.cs b/TaikoLocalServer/Controllers/Game/BaidController.cs
index 0039832..7d53232 100644
--- a/TaikoLocalServer/Controllers/Game/BaidController.cs
+++ b/TaikoLocalServer/Controllers/Game/BaidController.cs
@@ -146,7 +146,7 @@ public class BaidController : BaseController
CostumeFlg4 = costumeFlag,
CostumeFlg5 = costumeFlag,
LastPlayDatetime = userData.LastPlayDatetime.ToString(Constants.DATE_TIME_FORMAT),
- IsDispDanOn = /*userData.DisplayDan*/ true,
+ IsDispDanOn = userData.DisplayDan,
GotDanMax = maxDan,
GotDanFlg = gotDanFlagArray,
GotDanextraFlg = new byte[20],
diff --git a/TaikoLocalServer/Controllers/Game/UserDataController.cs b/TaikoLocalServer/Controllers/Game/UserDataController.cs
index e7d1710..1f8c1ad 100644
--- a/TaikoLocalServer/Controllers/Game/UserDataController.cs
+++ b/TaikoLocalServer/Controllers/Game/UserDataController.cs
@@ -83,7 +83,7 @@ public class UserDataController : BaseController
// TitleFlg = GZipBytesUtil.GetGZipBytes(new byte[100]),
ReleaseSongFlg = releaseSongArray,
UraReleaseSongFlg = uraSongArray,
- DefaultOptionSetting = new byte[] {0},
+ DefaultOptionSetting = defaultOptions,
IsVoiceOn = userData.IsVoiceOn,
IsSkipOn = userData.IsSkipOn,
IsChallengecompe = false,
diff --git a/TaikoLocalServer/TaikoLocalServer.csproj b/TaikoLocalServer/TaikoLocalServer.csproj
index 3307e95..4ae4fdf 100644
--- a/TaikoLocalServer/TaikoLocalServer.csproj
+++ b/TaikoLocalServer/TaikoLocalServer.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/TaikoWebUI/Pages/Card.razor b/TaikoWebUI/Pages/Card.razor
index 98485c6..5e17edd 100644
--- a/TaikoWebUI/Pages/Card.razor
+++ b/TaikoWebUI/Pages/Card.razor
@@ -1,8 +1,115 @@
@page "/Card/{baid}"
+@using SharedProject.Models.Responses
+@using SharedProject.Enums
+@using SharedProject.Models
+@inject HttpClient Client
Card: @Baid
+@if (response is not null)
+{
+
+
+ On
+ Off
+
+
+ On
+ Off
+
+
+ On
+ Off
+
+
+ On
+ Off
+
+
+ @foreach (var item in Enum.GetValues())
+ {
+
+ }
+
+
+ @for (var i = -5; i <= 5; i++)
+ {
+
+ }
+
+
+ @foreach (var item in Enum.GetValues())
+ {
+
+ }
+
+
+ @for (uint i = 0; i < 15; i++)
+ {
+ var index= i;
+ @speedStrings[index]
+ }
+
+
+ On
+ Off
+
+
+ On
+ Off
+
+
+ @if (isSavingOptions)
+ {
+
+ Saving...
+ }
+ else
+ {
+
+ Save
+ }
+
+
+}
+
@code {
+
[Parameter]
public string? Baid { get; set; }
+
+ private UserSetting? response;
+
+ private bool isSavingOptions;
+
+ private 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"};
+
+ protected override async Task OnInitializedAsync()
+ {
+ await base.OnInitializedAsync();
+ isSavingOptions = false;
+ response = await Client.GetFromJsonAsync($"api/UserSettings/{Baid}");
+ }
+
+ private async Task SaveOptions()
+ {
+ isSavingOptions = true;
+ await Client.PostAsJsonAsync($"api/UserSettings/{Baid}", response);
+ isSavingOptions = false;
+ }
+
}
\ No newline at end of file
diff --git a/TaikoWebUI/Pages/Dashboard.razor b/TaikoWebUI/Pages/Dashboard.razor
index 93d802d..0d5e42d 100644
--- a/TaikoWebUI/Pages/Dashboard.razor
+++ b/TaikoWebUI/Pages/Dashboard.razor
@@ -45,7 +45,7 @@
}
- void NavigateToProfile(uint baid)
+ private void NavigateToProfile(uint baid)
{
UriHelper.NavigateTo($"/Card/{baid}");
}