From 984361dcbb6f88f959dd10a20a8443bee5f2969f Mon Sep 17 00:00:00 2001 From: ptmaster Date: Mon, 16 Sep 2024 23:47:48 +0800 Subject: [PATCH] Add Challenge/Competition Localization Resources --- SharedProject/Models/SongInfo.cs | 2 + TaikoWebUI/Components/ChallengeCompe.razor | 23 +- .../Components/ChallengeCompeteGrid.razor | 6 +- TaikoWebUI/Components/UserCard.razor | 8 +- .../LocalizationResource.Designer.cs | 198 ++++++++++++++++++ .../LocalizationResource.en-US.resx | 66 ++++++ .../LocalizationResource.fr-FR.resx | 66 ++++++ .../Localization/LocalizationResource.ja.resx | 66 ++++++ .../Localization/LocalizationResource.resx | 66 ++++++ .../LocalizationResource.zh-Hans.resx | 66 ++++++ .../LocalizationResource.zh-Hant.resx | 66 ++++++ .../AddChallengeCompetitionDialog.razor | 23 +- 12 files changed, 638 insertions(+), 18 deletions(-) diff --git a/SharedProject/Models/SongInfo.cs b/SharedProject/Models/SongInfo.cs index a3d64bb..b85e411 100644 --- a/SharedProject/Models/SongInfo.cs +++ b/SharedProject/Models/SongInfo.cs @@ -8,4 +8,6 @@ public class SongInfo public Difficulty Difficulty { get; set; } = new(); + public int Level { get; set; } = 0; + } diff --git a/TaikoWebUI/Components/ChallengeCompe.razor b/TaikoWebUI/Components/ChallengeCompe.razor index f9cba13..4781731 100644 --- a/TaikoWebUI/Components/ChallengeCompe.razor +++ b/TaikoWebUI/Components/ChallengeCompe.razor @@ -8,14 +8,17 @@ @if (ChallengeCompetition.CompeteMode == CompeteModeType.Chanllenge) { - @if (ChallengeCompetition?.Baid != Baid) + if (Baid == 0) { - @Localizer["From"] @ChallengeCompetition?.Holder?.MyDonName + @formatChallengeTitle(Localizer["FullChallengeTitle"]) + } + else if (ChallengeCompetition?.Baid != Baid) + { + @formatChallengeTitle(Localizer["ReceiverChallengeTitle"]) } else { - var participant = ChallengeCompetition?.Participants?.Find(p => p.Baid != Baid); - @Localizer["To"] @participant?.UserInfo?.MyDonName + @formatChallengeTitle(Localizer["CreatorChallengeTitle"]) } } else @@ -86,13 +89,16 @@ { if (ChallengeCompetition.MaxParticipant <= ChallengeCompetition.Participants.Count) { - @Localizer["Fullfilled"] + @Localizer["Fulfilled"] } else { @Localizer["Participate"] } } + } else + { + @ChallengeCompetition.Participants.Count / @ChallengeCompetition.MaxParticipant } } @@ -125,6 +131,13 @@ return ChallengeCompetition?.CreateTime < DateTime.Now && DateTime.Now < ChallengeCompetition?.ExpireTime && !ParticipatedChallengeCompetition(); } + private string formatChallengeTitle(string template) + { + return template + .Replace("{From}", ChallengeCompetition?.Holder?.MyDonName) + .Replace("{To}", ChallengeCompetition?.Participants?.Find(p => p.Baid != ChallengeCompetition?.Baid)?.UserInfo?.MyDonName); + } + private async Task AnswerChallenge(bool accept) { if (ChallengeCompetition == null || ChallengeCompetition.State != CompeteState.Waiting) return; diff --git a/TaikoWebUI/Components/ChallengeCompeteGrid.razor b/TaikoWebUI/Components/ChallengeCompeteGrid.razor index 8bcca74..960232a 100644 --- a/TaikoWebUI/Components/ChallengeCompeteGrid.razor +++ b/TaikoWebUI/Components/ChallengeCompeteGrid.razor @@ -33,7 +33,7 @@ } else if (Mode == 3 && Baid == 0) { - OpenDialogAsync(3, 3)) Style="width: 80px">@Localizer["Add"] + OpenDialogAsync(3, 5, 365, 100)) Style="width: 80px">@Localizer["Add"] } @@ -191,12 +191,14 @@ await Debounce(GetUsersData, 500); // 500 milliseconds delay } - private async Task OpenDialogAsync(int mode, int maxSongs) + private async Task OpenDialogAsync(int mode, int maxSongs, int maxDays = 30, int maxParticipant = 20) { var options = new DialogOptions { CloseOnEscapeKey = true }; var parameters = new DialogParameters(); parameters.Add("Mode", mode); parameters.Add("MaxSongs", maxSongs); + parameters.Add("MaxDays", maxDays); + parameters.Add("MaxParticipant", maxParticipant); parameters.Add("Baid", Baid); var dialogRet = await DialogService.ShowAsync(Localizer["Create"], parameters, options); diff --git a/TaikoWebUI/Components/UserCard.razor b/TaikoWebUI/Components/UserCard.razor index e1cb7fa..308946e 100644 --- a/TaikoWebUI/Components/UserCard.razor +++ b/TaikoWebUI/Components/UserCard.razor @@ -39,7 +39,7 @@ @Localizer["Access Codes"] @@ -73,15 +73,15 @@ } - + @Localizer["Challenge"] - + @Localizer["Competition"] - + @Localizer["Official Competition"] diff --git a/TaikoWebUI/Localization/LocalizationResource.Designer.cs b/TaikoWebUI/Localization/LocalizationResource.Designer.cs index f4a5355..627a655 100644 --- a/TaikoWebUI/Localization/LocalizationResource.Designer.cs +++ b/TaikoWebUI/Localization/LocalizationResource.Designer.cs @@ -177,6 +177,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Accepted { + get { + return ResourceManager.GetString("Accepted", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -348,6 +357,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Any { + get { + return ResourceManager.GetString("Any", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -429,6 +447,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Challenge_Target { + get { + return ResourceManager.GetString("Challenge Target", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -600,6 +627,51 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Create { + get { + return ResourceManager.GetString("Create", resourceCulture); + } + } + + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Create_Challenge { + get { + return ResourceManager.GetString("Create Challenge", resourceCulture); + } + } + + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Create_Competition { + get { + return ResourceManager.GetString("Create Competition", resourceCulture); + } + } + + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Create_Official_Competition { + get { + return ResourceManager.GetString("Create Official Competition", resourceCulture); + } + } + + /// + /// 查找类似 的本地化字符串。 + /// + internal static string CreatorChallengeTitle { + get { + return ResourceManager.GetString("CreatorChallengeTitle", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -924,6 +996,24 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Fulfilled { + get { + return ResourceManager.GetString("Fulfilled", resourceCulture); + } + } + + /// + /// 查找类似 的本地化字符串。 + /// + internal static string FullChallengeTitle { + get { + return ResourceManager.GetString("FullChallengeTitle", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1131,6 +1221,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Last_For__Days_ { + get { + return ResourceManager.GetString("Last For (Days)", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1257,6 +1356,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Max_Participant { + get { + return ResourceManager.GetString("Max Participant", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1338,6 +1446,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string No_Select { + get { + return ResourceManager.GetString("No Select", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1410,6 +1527,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Off { + get { + return ResourceManager.GetString("Off", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1437,6 +1563,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string On { + get { + return ResourceManager.GetString("On", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1446,6 +1581,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Only_Play_Once { + get { + return ResourceManager.GetString("Only Play Once", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1464,6 +1608,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Participated { + get { + return ResourceManager.GetString("Participated", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1599,6 +1752,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string ReceiverChallengeTitle { + get { + return ResourceManager.GetString("ReceiverChallengeTitle", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1689,6 +1851,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Rejected { + get { + return ResourceManager.GetString("Rejected", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1842,6 +2013,24 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Select_Song { + get { + return ResourceManager.GetString("Select Song", resourceCulture); + } + } + + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Select_User { + get { + return ResourceManager.GetString("Select User", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// @@ -1914,6 +2103,15 @@ namespace TaikoWebUI.Localization { } } + /// + /// 查找类似 的本地化字符串。 + /// + internal static string Song { + get { + return ResourceManager.GetString("Song", resourceCulture); + } + } + /// /// 查找类似 的本地化字符串。 /// diff --git a/TaikoWebUI/Localization/LocalizationResource.en-US.resx b/TaikoWebUI/Localization/LocalizationResource.en-US.resx index 3cc99fa..c79edb5 100644 --- a/TaikoWebUI/Localization/LocalizationResource.en-US.resx +++ b/TaikoWebUI/Localization/LocalizationResource.en-US.resx @@ -864,4 +864,70 @@ Challenge Competition Data + + Accepted + + + Rejected + + + Challenge User + + + Duration (days) + + + Song + + + Only Play Once + + + Limit Reached + + + Participated + + + Challenge from {From} to {To} + + + Challenge from {From} + + + Challenge to {To} + + + Create Challenge + + + Create Competition + + + Create Official Competition + + + Create + + + No Selected Song + + + Max Participant + + + Select a Song with Difficulty + + + Select Challenge Target User + + + Any + + + On + + + Off + \ No newline at end of file diff --git a/TaikoWebUI/Localization/LocalizationResource.fr-FR.resx b/TaikoWebUI/Localization/LocalizationResource.fr-FR.resx index 0d1af08..444c169 100644 --- a/TaikoWebUI/Localization/LocalizationResource.fr-FR.resx +++ b/TaikoWebUI/Localization/LocalizationResource.fr-FR.resx @@ -864,4 +864,70 @@ Données de compétition de défi + + Accepté + + + Rejeté + + + Objet de défi + + + Durée (jours) + + + Chanson + + + Jouer une seule fois + + + Limite atteinte + + + Déjà participé + + + Défi de {From} à {To} + + + Défi de {From} + + + Défi à {To} + + + Créer un défi + + + Créer une compétition + + + Créer une compétition officielle + + + Créer + + + Aucune chanson sélectionnée + + + Nombre maximal de participants + + + Sélectionnez une chanson avec difficulté + + + Sélectionnez l'utilisateur cible du défi + + + N'importe lequel + + + allumer + + + fermeture + \ No newline at end of file diff --git a/TaikoWebUI/Localization/LocalizationResource.ja.resx b/TaikoWebUI/Localization/LocalizationResource.ja.resx index 0f9255f..6e8fe1b 100644 --- a/TaikoWebUI/Localization/LocalizationResource.ja.resx +++ b/TaikoWebUI/Localization/LocalizationResource.ja.resx @@ -864,4 +864,70 @@ 挑戦と大会 + + 受け入れられました + + + 拒否されました + + + 挑戦対象 + + + 期間 (日) + + + + + + 一度だけプレイ + + + すでに満席 + + + 参加済み + + + {From} から {To} への挑戦状 + + + {From} からの挑戦状 + + + {To} への挑戦状 + + + 挑戦状を作成する + + + 大会を作成する + + + 公式大会を作成する + + + 作成する + + + 曲が選択されていません + + + 最大参加者数 + + + 難しいと曲を選ぶ + + + 挑戦対象を選択 + + + 指定しない + + + オン + + + オフ + \ No newline at end of file diff --git a/TaikoWebUI/Localization/LocalizationResource.resx b/TaikoWebUI/Localization/LocalizationResource.resx index 261ce54..c452a4b 100644 --- a/TaikoWebUI/Localization/LocalizationResource.resx +++ b/TaikoWebUI/Localization/LocalizationResource.resx @@ -864,4 +864,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TaikoWebUI/Localization/LocalizationResource.zh-Hans.resx b/TaikoWebUI/Localization/LocalizationResource.zh-Hans.resx index 279c073..252d2ff 100644 --- a/TaikoWebUI/Localization/LocalizationResource.zh-Hans.resx +++ b/TaikoWebUI/Localization/LocalizationResource.zh-Hans.resx @@ -864,4 +864,70 @@ 挑战与大赛 + + 已接受 + + + 已拒绝 + + + 挑战对象 + + + 持续时间(天) + + + 歌曲 + + + 单次挑战 + + + 已满员 + + + 已参加 + + + {From} 向 {To} 发起的挑战书 + + + 来自 {From} 的挑战书 + + + 向 {To} 发起的挑战书 + + + 发起挑战 + + + 创建大赛 + + + 创建官方大赛 + + + 创建 + + + 无歌曲 + + + 最大参与人数 + + + 请选择歌曲与难度 + + + 请选择挑战的对象 + + + 任意 + + + 开启 + + + 关闭 + \ No newline at end of file diff --git a/TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx b/TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx index e8a8b7f..4015c94 100644 --- a/TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx +++ b/TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx @@ -864,4 +864,70 @@ 挑戰與大赛 + + 已接受 + + + 已拒絕 + + + 挑戰對象 + + + 持續時間(天) + + + 歌曲 + + + 單次挑戰 + + + 已滿員 + + + 已參加 + + + {From} 向 {To} 發起的挑戰書 + + + 來自 {From} 的挑戰書 + + + 向 {To} 發起的挑戰書 + + + 發起挑戰 + + + 創建大賽 + + + 創建官方大賽 + + + 創建 + + + 未選擇歌曲 + + + 最大參與人數 + + + 請選擇歌曲與難度 + + + 請選擇挑戰的對象 + + + 任意 + + + 開啟 + + + 關閉 + \ No newline at end of file diff --git a/TaikoWebUI/Pages/Dialogs/AddChallengeCompetitionDialog.razor b/TaikoWebUI/Pages/Dialogs/AddChallengeCompetitionDialog.razor index 4fc5725..35cd2b7 100644 --- a/TaikoWebUI/Pages/Dialogs/AddChallengeCompetitionDialog.razor +++ b/TaikoWebUI/Pages/Dialogs/AddChallengeCompetitionDialog.razor @@ -34,13 +34,13 @@ @if (Mode == 2 || Mode == 3) { - + } @if (Mode == 1) { - + @Localizer["Select"] } @@ -60,6 +60,7 @@ } @(musicDetails[song_idx].SongId == 0 ? Localizer["No Select"] : musicDetails[song_idx].SongName) + @levels[song_idx] @@ -107,9 +108,9 @@ } @if (Mode != 1) { - + } - + @Localizer["Only Play Once"] @@ -158,9 +159,11 @@ private Difficulty[] difficulties = new Difficulty[0]; - private int LastFor = 1; + private int[] levels = new int[0]; - private int ParticipantCount = 1; + private int LastFor = 7; + + private int ParticipantCount = 5; private bool OnlyPlayOnce = false; @@ -170,10 +173,12 @@ _expandeds = new bool[MaxSongs]; musicDetails = new MusicDetail[MaxSongs]; difficulties = new Difficulty[MaxSongs]; + levels = new int[MaxSongs]; for (int i = 0; i < MaxSongs; i++) { musicDetails[i] = new(); difficulties[i] = Difficulty.None; + levels[i] = 0; } Info.challengeCompeteSongs.Add(new()); } @@ -189,7 +194,7 @@ var parameters = new DialogParameters(); parameters.Add("SelectedSong", musicDetails[i]); - var reference = await DialogService.ShowAsync(Localizer["Create"], parameters, options); + var reference = await DialogService.ShowAsync(Localizer["Select Song"], parameters, options); if (reference != null) { var songInfo = await reference.GetReturnValueAsync(); @@ -198,6 +203,7 @@ { musicDetails[i] = songInfo.MusicDetail; difficulties[i] = songInfo.Difficulty; + levels[i] = songInfo.Level; } } } @@ -212,12 +218,14 @@ _expandeds[ex] = _expandeds[ex + 1]; musicDetails[ex] = musicDetails[ex + 1]; difficulties[ex] = difficulties[ex + 1]; + levels[ex] = levels[ex + 1]; } else { _expandeds[ex] = false; musicDetails[ex] = new(); difficulties[ex] = Difficulty.None; + levels[ex] = 0; } } } @@ -262,6 +270,7 @@ if (Mode == 1) { + Info.MaxParticipant = 2; if (TargetBaid == 0) { await ShowError(Localizer["Must Select Challenge Target Error"]);