From 801bd7dc3c4f4aa90ffc8b92ae447e07821a3386 Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Tue, 10 Dec 2024 17:33:32 -0500 Subject: [PATCH 1/9] Remove unneeded quotes --- .github/workflows/buildandtest.yml | 6 +++--- .github/workflows/main.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/buildandtest.yml b/.github/workflows/buildandtest.yml index 13d173fe..c973c440 100644 --- a/.github/workflows/buildandtest.yml +++ b/.github/workflows/buildandtest.yml @@ -2,7 +2,7 @@ name: Build and Test on: push: - branches: [ "dev" ] + branches: [ dev ] paths-ignore: - "**.md" - "**.ps1" @@ -12,11 +12,11 @@ on: - '**/*.gitattributes' - '**/*.yml' pull_request: - branches: [ "dev", "main" ] + branches: [ dev, main ] jobs: build: - name: "Build and Test" + name: Build and Test # use ubuntu-latest image to run steps on runs-on: ubuntu-latest diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1856e8dc..b5b0e37d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Deploy to GitHub Pages on: push: - branches: [ "main" ] + branches: [ main ] paths-ignore: - "**.md" - "**.ps1" @@ -14,7 +14,7 @@ on: jobs: deploy: - name: "Deploy to GitHub Pages" + name: Deploy to GitHub Pages # use ubuntu-latest image to run steps on runs-on: ubuntu-latest steps: From 3b61d68aee89cf93906e10b3a8c8551e794de5d3 Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Mon, 16 Dec 2024 14:37:02 -0500 Subject: [PATCH 2/9] Slight improvement to failed save error message --- Pkmds.Web/Components/Layout/MainLayout.razor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Pkmds.Web/Components/Layout/MainLayout.razor.cs b/Pkmds.Web/Components/Layout/MainLayout.razor.cs index e8544638..b499aa30 100644 --- a/Pkmds.Web/Components/Layout/MainLayout.razor.cs +++ b/Pkmds.Web/Components/Layout/MainLayout.razor.cs @@ -80,7 +80,8 @@ private async Task LoadSaveFile(IBrowserFile selectedFile) if (AppState.SaveFile is null) { - await DialogService.ShowMessageBox("Error", "The file is not a supported save file."); + const string message = "The selected save file is invalid. If this save file came from a ROM hack, it is not supported. Otherwise, try saving in-game and re-exporting / re-uploading the save file."; + await DialogService.ShowMessageBox("Error", message); return; } } From 7622c07fc17659495efd7096fcd972a989df6a75 Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Tue, 17 Dec 2024 16:47:53 -0500 Subject: [PATCH 3/9] Rename PKMExtensions -> PkmExtensions --- .../{PKMExtensions.cs => PkmExtensions.cs} | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) rename Pkmds.Web/Extensions/{PKMExtensions.cs => PkmExtensions.cs} (90%) diff --git a/Pkmds.Web/Extensions/PKMExtensions.cs b/Pkmds.Web/Extensions/PkmExtensions.cs similarity index 90% rename from Pkmds.Web/Extensions/PKMExtensions.cs rename to Pkmds.Web/Extensions/PkmExtensions.cs index 9ff4c29c..becde61c 100644 --- a/Pkmds.Web/Extensions/PKMExtensions.cs +++ b/Pkmds.Web/Extensions/PkmExtensions.cs @@ -1,6 +1,6 @@ namespace Pkmds.Web.Extensions; -public static class PKMExtensions +public static class PkmExtensions { public static uint? GetFormArgument(this PKM pkm, uint? valueIfNull = null) => (pkm as IFormArgument)?.FormArgument ?? valueIfNull; @@ -38,6 +38,7 @@ public static int GetMarking(this PKM pokemon, int index) }; } + // ReSharper disable once InconsistentNaming public static ReadOnlyCollection GetPP(this PKM pokemon) => new( [ pokemon.Move1_PP, @@ -46,6 +47,7 @@ public static int GetMarking(this PKM pokemon, int index) pokemon.Move4_PP ]); + // ReSharper disable once InconsistentNaming public static ReadOnlyCollection GetPPUps(this PKM pokemon) => new( [ pokemon.Move1_PPUps, @@ -54,13 +56,9 @@ public static int GetMarking(this PKM pokemon, int index) pokemon.Move4_PPUps ]); + // ReSharper disable once InconsistentNaming public static void SetPP(this PKM pokemon, int moveIndex, int pp) { - if (pokemon is null) - { - return; - } - if(pp < 0) { pp = 0; @@ -83,13 +81,9 @@ public static void SetPP(this PKM pokemon, int moveIndex, int pp) } } + // ReSharper disable once InconsistentNaming public static void SetPPUps(this PKM pokemon, int moveIndex, int ppUps) { - if (pokemon is null) - { - return; - } - if (ppUps < 0) { ppUps = 0; @@ -112,9 +106,11 @@ public static void SetPPUps(this PKM pokemon, int moveIndex, int ppUps) } } + // ReSharper disable once InconsistentNaming public static int GetMaxPP(this PKM pokemon, int moveIndex) { var move = pokemon.GetMove(moveIndex); + // ReSharper disable once InconsistentNaming var moveBasePP = MoveInfo.GetPP(pokemon.Context, move); var ppUps = pokemon.GetPPUps()[moveIndex]; From 0fe4512f082db5972a14f9d6a117c81c8a6ff3cb Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Tue, 17 Dec 2024 17:19:15 -0500 Subject: [PATCH 4/9] Code adjustments --- .../Components/EditForms/Tabs/MainTab.razor | 90 ++++++++++++------- .../EditForms/Tabs/MainTab.razor.cs | 12 +-- Pkmds.Web/Extensions/PkmExtensions.cs | 31 +++---- 3 files changed, 77 insertions(+), 56 deletions(-) diff --git a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor index 901d93f9..678b9b5b 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor @@ -1,12 +1,15 @@ @inherits BasePkmdsComponent @if (Pokemon is not null && -AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } saveFile && -saveFileEntityContext is not -EntityContext.None or -EntityContext.SplitInvalid or -EntityContext.MaxInvalid && -AppState.SelectedSlotsAreValid) + AppState.SaveFile is + { + Context: not + (EntityContext.None or + EntityContext.SplitInvalid or + EntityContext.MaxInvalid), + Generation: var saveGeneration + } saveFile && + AppState.SelectedSlotsAreValid) { @if (saveGeneration >= 3) { @@ -16,23 +19,30 @@ AppState.SelectedSlotsAreValid) Max="@uint.MaxValue" @bind-Value:get="@Pokemon.PID" @bind-Value:set="@(newPid => SetPokemonPid(newPid))" - For="@(() => Pokemon.PID)" /> + For="@(() => Pokemon.PID)"/> + @bind-Value:set="@((string newPidHex) => SetPokemonPid(newPidHex))"/> } + @* ReSharper disable once CSharpWarnings::CS8603 *@ + @* ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract *@ + ToStringFunc="@(species => species?.Text)"/> if (Pokemon != saveFile.BlankPKM && Pokemon.Species != (ushort)Species.None) { @@ -43,7 +53,7 @@ AppState.SelectedSlotsAreValid) + For="@(() => Pokemon.IsNicknamed)"/> + For="@(() => Pokemon.Nickname)"/> @if (saveGeneration >= 2) { @@ -71,7 +81,7 @@ AppState.SelectedSlotsAreValid) + Disabled="@(!Pokemon.PersonalInfo.IsDualGender)"/> @if (!Pokemon.PersonalInfo.IsDualGender) { @@ -87,13 +97,13 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" @bind-Value="@Pokemon.EXP" @bind-Value:after="@(() => AppService.LoadPokemonStats(Pokemon))" - For="@(() => Pokemon.EXP)" /> + For="@(() => Pokemon.EXP)"/> + For="@(() => Pokemon.CurrentLevel)"/> @if (saveGeneration >= 3) { @@ -167,20 +177,26 @@ AppState.SelectedSlotsAreValid) @if (Pokemon is IFormArgument && FormArgumentUtil.GetFormArgumentMax(Pokemon.Species, Pokemon.Form, Pokemon.Context) > 0 && FormConverter.GetFormArgumentIsNamedIndex(Pokemon.Species)) { + + @bind-Value:set="@(formArg => + { + Pokemon.ChangeFormArgument(formArg ?? 0); + AppService.LoadPokemonStats(Pokemon); + RefreshService.Refresh(); + })"> @{ var formArgs = FormConverter.GetFormArgumentStrings(Pokemon.Species); } - @for (uint? i = 0; i < formArgs.Length; i++) + @for (uint i = 0; i < formArgs.Length; i++) { var formArg = i; - @formArgs[formArg ?? 0] + @key="@formArg"> + @formArgs[formArg] } @@ -194,12 +210,19 @@ AppState.SelectedSlotsAreValid) Spacing="1" AlignItems="@AlignItems.Center"> + @* ReSharper disable once CSharpWarnings::CS8603 *@ @@ -211,7 +234,7 @@ AppState.SelectedSlotsAreValid) ObjectFit="@ObjectFit.Contain" ObjectPosition="@ObjectPosition.Center" Width="22" - Height="22" /> + Height="22"/> } @item.Text @@ -229,7 +252,7 @@ AppState.SelectedSlotsAreValid) ObjectFit="@ObjectFit.Contain" ObjectPosition="@ObjectPosition.Center" Width="22" - Height="22" /> + Height="22"/> } } @@ -238,7 +261,7 @@ AppState.SelectedSlotsAreValid) { @foreach (var ability in GameInfo.FilteredSources.GetAbilityList(Pokemon).DistinctBy(ability => ability.Value)) @@ -252,13 +275,15 @@ AppState.SelectedSlotsAreValid) } else if (saveGeneration >= 4) { + @* ReSharper disable once CSharpWarnings::CS8603 *@ + @* ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract *@ + ToStringFunc="@(ability => ability?.Text)"/> } @if (saveGeneration >= 3) @@ -283,11 +308,10 @@ AppState.SelectedSlotsAreValid) { + For="@(() => Pokemon.CurrentFriendship)"/> } + For="@(() => Pokemon.IsEgg)"/> - + } @if (Pokemon is PK5 pk5) @@ -308,13 +332,13 @@ AppState.SelectedSlotsAreValid) + For="@(() => pk5.NSparkle)"/> } + For="@(() => Pokemon.IsShiny)"/> } diff --git a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor.cs b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor.cs index 3f4fd3c8..640572ba 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor.cs +++ b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.EditForms.Tabs; public partial class MainTab : IDisposable { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } private MudSelect? FormSelect { get; set; } @@ -13,7 +12,7 @@ protected override void OnInitialized() => public void Dispose() => RefreshService.OnAppStateChanged -= Refresh; - public void Refresh() + private void Refresh() { FormSelect?.ForceRender(true); StateHasChanged(); @@ -68,7 +67,7 @@ private Task> SearchAbilityNames(string searchString, Can private void OnGenderToggle(Gender newGender) { - if (Pokemon is not { PersonalInfo.IsDualGender: true, Gender: var gender } pkm) + if (Pokemon is not { PersonalInfo.IsDualGender: true } pkm) { return; } @@ -124,8 +123,5 @@ private void SetPokemonPid(string newPidHex) RefreshService.Refresh(); } - private readonly PatternMask HexMask = new("########") - { - MaskChars = [new MaskChar('#', @"[0-9a-fA-F]")] - }; + private readonly PatternMask hexMask = new("########") { MaskChars = [new('#', "[0-9a-fA-F]")] }; } diff --git a/Pkmds.Web/Extensions/PkmExtensions.cs b/Pkmds.Web/Extensions/PkmExtensions.cs index becde61c..987f984b 100644 --- a/Pkmds.Web/Extensions/PkmExtensions.cs +++ b/Pkmds.Web/Extensions/PkmExtensions.cs @@ -15,7 +15,8 @@ public static (byte Type1, byte Type2) GetGenerationTypes(this PKM pkm) ? (ConvertGenerationType(type1, generation), ConvertGenerationType(type2, generation)) : (type1, type2); - static byte ConvertGenerationType(byte type, byte generation) => (byte)((MoveType)type).GetMoveTypeGeneration(generation); + static byte ConvertGenerationType(byte type, byte generation) => + (byte)((MoveType)type).GetMoveTypeGeneration(generation); } public static int GetMarking(this PKM pokemon, int index) @@ -40,26 +41,26 @@ public static int GetMarking(this PKM pokemon, int index) // ReSharper disable once InconsistentNaming public static ReadOnlyCollection GetPP(this PKM pokemon) => new( - [ - pokemon.Move1_PP, - pokemon.Move2_PP, - pokemon.Move3_PP, - pokemon.Move4_PP - ]); + [ + pokemon.Move1_PP, + pokemon.Move2_PP, + pokemon.Move3_PP, + pokemon.Move4_PP + ]); // ReSharper disable once InconsistentNaming public static ReadOnlyCollection GetPPUps(this PKM pokemon) => new( - [ - pokemon.Move1_PPUps, - pokemon.Move2_PPUps, - pokemon.Move3_PPUps, - pokemon.Move4_PPUps - ]); + [ + pokemon.Move1_PPUps, + pokemon.Move2_PPUps, + pokemon.Move3_PPUps, + pokemon.Move4_PPUps + ]); // ReSharper disable once InconsistentNaming public static void SetPP(this PKM pokemon, int moveIndex, int pp) { - if(pp < 0) + if (pp < 0) { pp = 0; } @@ -107,7 +108,7 @@ public static void SetPPUps(this PKM pokemon, int moveIndex, int ppUps) } // ReSharper disable once InconsistentNaming - public static int GetMaxPP(this PKM pokemon, int moveIndex) + public static int GetMaxPP(this PKM pokemon, int moveIndex) { var move = pokemon.GetMove(moveIndex); // ReSharper disable once InconsistentNaming From 25aef8f712c0491efdc63053a764443ce1cdd484 Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Tue, 17 Dec 2024 17:57:58 -0500 Subject: [PATCH 5/9] A bunch of code tweaks --- Pkmds.Web/Components/BasePkmdsComponent.razor | 73 +++---- .../EditForms/PokemonEditForm.razor | 27 +-- .../EditForms/Tabs/CosmeticTab.razor | 12 +- .../Components/EditForms/Tabs/MainTab.razor | 55 +++-- .../Components/EditForms/Tabs/MetTab.razor | 85 ++++---- .../Components/EditForms/Tabs/MovesTab.razor | 29 ++- .../Components/EditForms/Tabs/OtMiscTab.razor | 83 ++++---- .../EditForms/Tabs/PokerusComponent.razor | 4 +- .../Components/EditForms/Tabs/StatsTab.razor | 201 ++++++++++-------- .../Components/FileUploadDialog.razor.cs | 8 +- Pkmds.Web/Components/Layout/MainLayout.razor | 44 ++-- Pkmds.Web/Components/LetsGoBoxComponent.razor | 2 +- Pkmds.Web/Components/LetsGoBoxGrid.razor | 2 +- .../MainTabPages/BadgesComponent.razor | 5 - .../MainTabPages/BadgesComponent.razor.cs | 24 ++- .../Components/MainTabPages/BagTab.razor | 22 +- .../MainTabPages/MysteryGiftDatabaseTab.razor | 4 +- .../Components/MainTabPages/RecordsTab.razor | 17 +- .../MainTabPages/RecordsTab.razor.cs | 7 +- .../MainTabPages/TrainerInfoTab.razor | 129 +++++------ Pkmds.Web/Components/MarkingsContainer.razor | 14 +- Pkmds.Web/Components/PartyGrid.razor | 4 +- .../Components/PokemonSlotComponent.razor | 7 +- .../Components/PokemonSlotComponent.razor.cs | 12 +- .../Components/PokemonStorageComponent.razor | 13 +- Pkmds.Web/Components/SaveFileComponent.razor | 20 +- Pkmds.Web/Constants.cs | 20 +- 27 files changed, 481 insertions(+), 442 deletions(-) diff --git a/Pkmds.Web/Components/BasePkmdsComponent.razor b/Pkmds.Web/Components/BasePkmdsComponent.razor index 691bf574..64dc5f1e 100644 --- a/Pkmds.Web/Components/BasePkmdsComponent.razor +++ b/Pkmds.Web/Components/BasePkmdsComponent.razor @@ -1,44 +1,45 @@ @code { - public const string ColumnClass = "d-flex align-center justify-center"; + protected const string ColumnClass = "d-flex align-center justify-center"; - public static RenderFragment TypeSummary(byte type1, byte type2) => - @ - - Type: - - - @if (type1 != type2) - { - - } - ; + private static RenderFragment TypeSummary(byte type1, byte type2) => + @ + + Type: + + + @if (type1 != type2) + { + + } + ; - public static RenderFragment TypeSummary((byte Type1, byte Type2) types) => + protected static RenderFragment TypeSummary((byte Type1, byte Type2) types) => TypeSummary(types.Type1, types.Type2); - public static RenderFragment MoveTypeSummary(byte type) => - @; + protected static RenderFragment MoveTypeSummary(byte type) => + @; public static RenderFragment MoveCategorySummary(int categoryId) => - @; + @; + } diff --git a/Pkmds.Web/Components/EditForms/PokemonEditForm.razor b/Pkmds.Web/Components/EditForms/PokemonEditForm.razor index a1d257f0..76e69c80 100644 --- a/Pkmds.Web/Components/EditForms/PokemonEditForm.razor +++ b/Pkmds.Web/Components/EditForms/PokemonEditForm.razor @@ -1,12 +1,15 @@ @inherits BasePkmdsComponent @if (Pokemon is not null && -AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } saveFile && -saveFileEntityContext is not -EntityContext.None or -EntityContext.SplitInvalid or -EntityContext.MaxInvalid && -AppState.SelectedSlotsAreValid) + AppState.SaveFile is + { + Context: not + (EntityContext.None or + EntityContext.SplitInvalid or + EntityContext.MaxInvalid), + Generation: var saveGeneration + } && + AppState.SelectedSlotsAreValid) { @@ -80,33 +83,33 @@ AppState.SelectedSlotsAreValid) Border> - + @if (saveGeneration >= 2) { - + } - + - + @if (saveGeneration >= 3) { - + } - + diff --git a/Pkmds.Web/Components/EditForms/Tabs/CosmeticTab.razor b/Pkmds.Web/Components/EditForms/Tabs/CosmeticTab.razor index ccb2d6ef..730a45a0 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/CosmeticTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/CosmeticTab.razor @@ -1,12 +1,12 @@ @inherits BasePkmdsComponent @if (Pokemon is not null && -AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } && -saveFileEntityContext is not -EntityContext.None or -EntityContext.SplitInvalid or -EntityContext.MaxInvalid && -AppState.SelectedSlotsAreValid) + AppState.SaveFile is { Context: not + (EntityContext.None or + EntityContext.SplitInvalid or + EntityContext.MaxInvalid) + } && + AppState.SelectedSlotsAreValid) { } diff --git a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor index 678b9b5b..f3e65c8a 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor @@ -41,7 +41,6 @@ RefreshService.Refresh(); })" SearchFunc="@SearchPokemonNames" - @* ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract *@ ToStringFunc="@(species => species?.Text)"/> if (Pokemon != saveFile.BlankPKM && Pokemon.Species != (ushort)Species.None) @@ -177,7 +176,6 @@ @if (Pokemon is IFormArgument && FormArgumentUtil.GetFormArgumentMax(Pokemon.Species, Pokemon.Form, Pokemon.Context) > 0 && FormConverter.GetFormArgumentIsNamedIndex(Pokemon.Species)) { - @@ -257,33 +254,33 @@ } - @if (saveGeneration == 3) + @switch (saveGeneration) { - - @foreach (var ability in GameInfo.FilteredSources.GetAbilityList(Pokemon).DistinctBy(ability => ability.Value)) - { - - @ability.Text - - } - - } - else if (saveGeneration >= 4) - { - @* ReSharper disable once CSharpWarnings::CS8603 *@ - + case 3: + + @foreach (var ability in GameInfo.FilteredSources.GetAbilityList(Pokemon).DistinctBy(ability => ability.Value)) + { + + @ability.Text + + } + + break; + case >= 4: + @* ReSharper disable once CSharpWarnings::CS8603 *@ + + break; } @if (saveGeneration >= 3) diff --git a/Pkmds.Web/Components/EditForms/Tabs/MetTab.razor b/Pkmds.Web/Components/EditForms/Tabs/MetTab.razor index 9f2e9923..e27e615e 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MetTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/MetTab.razor @@ -1,12 +1,15 @@ @inherits BasePkmdsComponent @if (Pokemon is not null && -AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } && -saveFileEntityContext is not -EntityContext.None or -EntityContext.SplitInvalid or -EntityContext.MaxInvalid && -AppState.SelectedSlotsAreValid) + AppState.SaveFile is + { + Context: not + (EntityContext.None or + EntityContext.SplitInvalid or + EntityContext.MaxInvalid), + Generation: var saveGeneration + } && + AppState.SelectedSlotsAreValid) { @foreach (var gameVersion in GameInfo.FilteredSources.Games) { - if (gameVersion is not null) - { - - } + } + @* ReSharper disable once CSharpWarnings::CS8603 *@ + ToStringFunc="@(metLocation => metLocation?.Text)"/> @if (saveGeneration >= 3) { @@ -39,7 +40,7 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" @bind-Value="@Pokemon.Ball" For="@(() => Pokemon.Ball)"> - @foreach (ComboItem ball in GameInfo.FilteredSources.Balls.DistinctBy(ball => ball.Value)) + @foreach (var ball in GameInfo.FilteredSources.Balls.DistinctBy(ball => ball.Value)) { @@ -50,7 +51,7 @@ AppState.SelectedSlotsAreValid) ObjectFit="@ObjectFit.Contain" ObjectPosition="@ObjectPosition.Center" Width="22" - Height="22" /> + Height="22"/> @ball.Text @@ -65,31 +66,32 @@ AppState.SelectedSlotsAreValid) + For="@(() => Pokemon.MetLevel)"/> } - @if (saveGeneration == 2 && Pokemon is PK2 pk2) - { - - @foreach (var timeOfDay in Enum.GetValues()) - { - - @timeOfDay.ToString() - - } - - } - else if (saveGeneration >= 4) + @switch (saveGeneration) { - + case 2 when Pokemon is PK2: + + @foreach (var timeOfDay in Enum.GetValues()) + { + + @timeOfDay.ToString() + + } + + break; + case >= 4: + + break; } @if (saveGeneration >= 4) @@ -98,11 +100,12 @@ AppState.SelectedSlotsAreValid) T="@bool" Value="@PokemonMetAsEgg" ValueChanged="@MetAsEggChanged" - For="@(() => Pokemon.FatefulEncounter)" /> + For="@(() => Pokemon.FatefulEncounter)"/> } @if (saveGeneration >= 4 && PokemonMetAsEgg) { + @* ReSharper disable once CSharpWarnings::CS8603 *@ + ToStringFunc="@(metLocation => metLocation?.Text)"/> + Color="@Color.Default"/> } + For="@(() => Pokemon.IsEgg)"/> @if (saveGeneration >= 3) { + For="@(() => Pokemon.FatefulEncounter)"/> } } diff --git a/Pkmds.Web/Components/EditForms/Tabs/MovesTab.razor b/Pkmds.Web/Components/EditForms/Tabs/MovesTab.razor index 4bb5bff9..c3be9cb2 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MovesTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/MovesTab.razor @@ -1,20 +1,18 @@ @inherits BasePkmdsComponent @if (Pokemon is not null && -AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } && -saveFileEntityContext is not -EntityContext.None or -EntityContext.SplitInvalid or -EntityContext.MaxInvalid && -AppState.SelectedSlotsAreValid) + AppState.SaveFile is + { + Context: var saveFileEntityContext and not + (EntityContext.None or + EntityContext.SplitInvalid or + EntityContext.MaxInvalid) + } && + AppState.SelectedSlotsAreValid) { - @{ - var pp = Pokemon.GetPP(); - var ppUps = Pokemon.GetPPUps(); - } @for (var counter = 0; counter < Pokemon.Moves.Length; counter++) { var i = counter; @@ -30,7 +28,7 @@ AppState.SelectedSlotsAreValid) } else { - + } @@ -46,6 +44,7 @@ AppState.SelectedSlotsAreValid) + @* ReSharper disable once CSharpWarnings::CS8603 *@ + @bind-Value:set="@(newValue => SetPokemonPP(i, newValue))"/> @@ -88,7 +87,7 @@ AppState.SelectedSlotsAreValid) Min="0" Margin="@Margin.Dense" @bind-Value:get="@GetPokemonPPUps(i)" - @bind-Value:set="@(newValue => SetPokemonPPUps(i, newValue))" /> + @bind-Value:set="@(newValue => SetPokemonPPUps(i, newValue))"/> + HideSpinButtons/> } @@ -107,7 +106,7 @@ AppState.SelectedSlotsAreValid) @if (GameInfo.FilteredSources.Moves.Any(m => m.Value == (int)Move.HiddenPower) && Pokemon is not { Context: EntityContext.Gen8 or EntityContext.Gen9 }) { - + } diff --git a/Pkmds.Web/Components/EditForms/Tabs/OtMiscTab.razor b/Pkmds.Web/Components/EditForms/Tabs/OtMiscTab.razor index 2ff432f3..18e92426 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/OtMiscTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/OtMiscTab.razor @@ -1,65 +1,68 @@ @inherits BasePkmdsComponent @if (Pokemon is not null && -AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } saveFile && -saveFileEntityContext is not -EntityContext.None or -EntityContext.SplitInvalid or -EntityContext.MaxInvalid && -AppState.SelectedSlotsAreValid) + AppState.SaveFile is + { + Context: not + (EntityContext.None or + EntityContext.SplitInvalid or + EntityContext.MaxInvalid), + Generation: var saveGeneration + } saveFile && + AppState.SelectedSlotsAreValid) { @switch (saveFile.GetTrainerIDFormat()) { case TrainerIDFormat.SixteenBit: + { + + + + + @if (saveGeneration >= 3) { - + @bind-Value="@Pokemon.SID16" + Format="@AppService.GetIdFormatString(true)" + For="@(() => Pokemon.SID16)"/> - - @if (saveGeneration >= 3) - { - - - - } } + } break; case TrainerIDFormat.SixDigit: + { + + + + + @if (saveGeneration >= 3) { - + @bind-Value="@Pokemon.TrainerSID7" + Format="@AppService.GetIdFormatString(true)" + For="@(() => Pokemon.TrainerSID7)"/> - - @if (saveGeneration >= 3) - { - - - - } } + } break; } @@ -69,7 +72,7 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" @bind-Value="@Pokemon.OriginalTrainerName" MaxLength="@saveFile.MaxStringLengthTrainer" - For="@(() => Pokemon.OriginalTrainerName)" /> + For="@(() => Pokemon.OriginalTrainerName)"/> @if (saveGeneration >= 2) @@ -77,7 +80,7 @@ AppState.SelectedSlotsAreValid) + OnChange="@OnGenderToggle"/> } diff --git a/Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor b/Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor index c390d728..f165a0f0 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor @@ -3,12 +3,12 @@ + For="@(() => pokemon.IsPokerusInfected)"/> + For="@(() => pokemon.IsPokerusCured)"/> @if (pokemon.IsPokerusInfected) { diff --git a/Pkmds.Web/Components/EditForms/Tabs/StatsTab.razor b/Pkmds.Web/Components/EditForms/Tabs/StatsTab.razor index 56a1f194..a6f6a03e 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/StatsTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/StatsTab.razor @@ -1,12 +1,15 @@ @inherits BasePkmdsComponent @if (Pokemon is not null && -AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } saveFile && -saveFileEntityContext is not -EntityContext.None or -EntityContext.SplitInvalid or -EntityContext.MaxInvalid && -AppState.SelectedSlotsAreValid) + AppState.SaveFile is + { + Context: not + (EntityContext.None or + EntityContext.SplitInvalid or + EntityContext.MaxInvalid), + Generation: var saveGeneration + } && + AppState.SelectedSlotsAreValid) { @@ -21,7 +24,7 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" Value="@Pokemon.PersonalInfo.HP" ReadOnly - HideSpinButtons /> + HideSpinButtons/> + HideSpinButtons/> + HideSpinButtons/> @if (saveGeneration == 1 && Pokemon is PK1 pk1) { @@ -46,14 +49,14 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" Value="@pk1.PersonalInfo.SPE" ReadOnly - HideSpinButtons /> + HideSpinButtons/> + HideSpinButtons/> } else { @@ -63,7 +66,7 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" Value="@Pokemon.PersonalInfo.SPA" ReadOnly - HideSpinButtons /> + HideSpinButtons/> + HideSpinButtons/> + HideSpinButtons/> + HideSpinButtons/> } @@ -101,33 +104,33 @@ AppState.SelectedSlotsAreValid) + HideSpinButtons="@(saveGeneration == 1 && Pokemon is PK1)"/> + For="@(() => Pokemon.IV_ATK)"/> + For="@(() => Pokemon.IV_DEF)"/> @if (saveGeneration == 1 && Pokemon is PK1 pk1) @@ -135,16 +138,20 @@ AppState.SelectedSlotsAreValid) + For="@(() => pk1.IV_SPE)"/> + For="@(() => pk1.IV_SPC)"/> } else { @@ -152,31 +159,31 @@ AppState.SelectedSlotsAreValid) Class="@GetStatClass(Stats.SpecialAttack)" title="Special Attack IV" Variant="@Variant.Outlined" - Min="0" + Min="@int.MinValue" Max="31" @bind-Value="@Pokemon.IV_SPA" @bind-Value:after="@(() => AppService.LoadPokemonStats(Pokemon))" - For="@(() => Pokemon.IV_SPA)" /> + For="@(() => Pokemon.IV_SPA)"/> + For="@(() => Pokemon.IV_SPD)"/> + For="@(() => Pokemon.IV_SPE)"/> + HideSpinButtons/> } @@ -202,73 +209,73 @@ AppState.SelectedSlotsAreValid) T="@byte" title="HP AV" Variant="@Variant.Outlined" - Min="0" + Min="@byte.MinValue" Max="@AwakeningUtil.AwakeningMax" @bind-Value="@aPkm.AV_HP" @bind-Value:after="@(() => AppService.LoadPokemonStats(Pokemon))" - For="@(() => aPkm.AV_HP)" /> + For="@(() => aPkm.AV_HP)"/> + For="@(() => aPkm.AV_ATK)"/> + For="@(() => aPkm.AV_DEF)"/> + For="@(() => aPkm.AV_SPA)"/> + For="@(() => aPkm.AV_SPD)"/> + For="@(() => aPkm.AV_SPE)"/> + HideSpinButtons/> @@ -285,66 +292,66 @@ AppState.SelectedSlotsAreValid) T="@byte" title="HP GV" Variant="@Variant.Outlined" - Min="0" + Min="@byte.MinValue" Max="@Pokemon.GetMaxGanbaru(0)" @bind-Value="@gPkm.GV_HP" @bind-Value:after="@(() => AppService.LoadPokemonStats(Pokemon))" - For="@(() => gPkm.GV_HP)" /> + For="@(() => gPkm.GV_HP)"/> + For="@(() => gPkm.GV_ATK)"/> + For="@(() => gPkm.GV_DEF)"/> + For="@(() => gPkm.GV_SPA)"/> + For="@(() => gPkm.GV_SPD)"/> + For="@(() => gPkm.GV_SPE)"/> @@ -360,47 +367,51 @@ AppState.SelectedSlotsAreValid) + For="@(() => Pokemon.EV_HP)"/> + For="@(() => Pokemon.EV_ATK)"/> + For="@(() => Pokemon.EV_DEF)"/> @if (saveGeneration == 1 && Pokemon is PK1 pk1) { + For="@(() => pk1.EV_SPE)"/> + For="@(() => pk1.EV_SPC)"/> } else { @@ -408,38 +419,38 @@ AppState.SelectedSlotsAreValid) Class="@GetStatClass(Stats.SpecialAttack)" title="Special Attack EV" Variant="@Variant.Outlined" - Min="0" + Min="@int.MinValue" Max="@GetEvMax(saveGeneration)" @bind-Value="@Pokemon.EV_SPA" @bind-Value:after="@(() => AppService.LoadPokemonStats(Pokemon))" - For="@(() => Pokemon.EV_SPA)" /> + For="@(() => Pokemon.EV_SPA)"/> + For="@(() => Pokemon.EV_SPD)"/> + For="@(() => Pokemon.EV_SPE)"/> + HideSpinButtons/> } @@ -457,7 +468,7 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" Value="@Pokemon.Stat_HPMax" ReadOnly - HideSpinButtons /> + HideSpinButtons/> + HideSpinButtons/> + HideSpinButtons/> @if (saveGeneration == 1 && Pokemon is PK1 pk1) { @@ -482,14 +493,14 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" Value="@pk1.Stat_SPE" ReadOnly - HideSpinButtons /> + HideSpinButtons/> + HideSpinButtons/> } else { @@ -499,7 +510,7 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" Value="@Pokemon.Stat_SPA" ReadOnly - HideSpinButtons /> + HideSpinButtons/> + HideSpinButtons/> + HideSpinButtons/> } @if (saveGeneration >= 3) @@ -536,7 +547,7 @@ AppState.SelectedSlotsAreValid) Variant="@Variant.Outlined" @bind-Value="@Pokemon.CurrentLevel" @bind-Value:after="@(() => AppService.LoadPokemonStats(Pokemon))" - For="@(() => Pokemon.CurrentLevel)" /> + For="@(() => Pokemon.CurrentLevel)"/> @if (Pokemon is ICombatPower pb) { @@ -545,7 +556,7 @@ AppState.SelectedSlotsAreValid) ReadOnly HideSpinButtons Value="@pb.Stat_CP" - For="@(() => pb.Stat_CP)" /> + For="@(() => pb.Stat_CP)"/> } @if (saveGeneration >= 3) @@ -598,7 +609,7 @@ AppState.SelectedSlotsAreValid) @if (GameInfo.FilteredSources.Moves.Any(m => m.Value == (int)Move.HiddenPower) && Pokemon is not { Context: EntityContext.Gen8 or EntityContext.Gen9 }) { - + } @if (saveGeneration >= 4) @@ -618,16 +629,16 @@ AppState.SelectedSlotsAreValid) + Min="@byte.MinValue" + Max="@Constants.MaxDynamaxLevel" + @bind-Value="@d.DynamaxLevel"/> @if (Pokemon is IGigantamax c) { + For="@(() => c.CanGigantamax)"/> } } @@ -638,7 +649,7 @@ AppState.SelectedSlotsAreValid) + For="@(() => noble.IsNoble)"/> } @@ -647,7 +658,7 @@ AppState.SelectedSlotsAreValid) + Readonly/> } @@ -656,7 +667,7 @@ AppState.SelectedSlotsAreValid) + For="@(() => alpha.IsAlpha)"/> } @@ -753,11 +764,13 @@ AppState.SelectedSlotsAreValid) @code { + private RenderFragment RenderTeraTypeImage(byte teraTypeid, int width = 30) => - @; + @; + } diff --git a/Pkmds.Web/Components/FileUploadDialog.razor.cs b/Pkmds.Web/Components/FileUploadDialog.razor.cs index 3e5b0f51..abfa961c 100644 --- a/Pkmds.Web/Components/FileUploadDialog.razor.cs +++ b/Pkmds.Web/Components/FileUploadDialog.razor.cs @@ -2,15 +2,13 @@ namespace Pkmds.Web.Components; public partial class FileUploadDialog { - [CascadingParameter] - private MudDialogInstance MudDialog { get; set; } = default!; + [CascadingParameter] private MudDialogInstance MudDialog { get; set; } = null!; - [Parameter] - public string Message { get; set; } = "Choose a file to upload."; + [Parameter] public string Message { get; set; } = "Choose a file to upload."; private IBrowserFile? browserFile; - private void HandleFile(IBrowserFile file) => browserFile = file; + private void HandleFile(IBrowserFile? file) => browserFile = file; private void Cancel() => MudDialog.Close(DialogResult.Cancel()); diff --git a/Pkmds.Web/Components/Layout/MainLayout.razor b/Pkmds.Web/Components/Layout/MainLayout.razor index 9a59b24e..3ef27342 100644 --- a/Pkmds.Web/Components/Layout/MainLayout.razor +++ b/Pkmds.Web/Components/Layout/MainLayout.razor @@ -1,17 +1,17 @@ @inherits LayoutComponentBase - - - + @bind-IsDarkMode="@isDarkMode"/> + + + + OnClick="@DrawerToggle"/> @Constants.AppTitle @@ -21,11 +21,11 @@ @Constants.AppShortTitle - + + Label="@(isDarkMode ? "Dark" : "Light")"/> + Variant="@Variant.Outlined"/> @@ -88,30 +88,38 @@ Export Selected Pokémon - + Version @IAppState.AppVersion - Created by + Created by + codemonkey85 - Based on + Based on + PKHeX.Core - by + + by + Kaphotics - (version @IAppState.PkhexVersion) + + (version @IAppState.PkhexVersion) - Special thanks to Kaphotics, as well as all the contributors to PKHeX and PKHeX.Core. + Special thanks to Kaphotics, as well as + all the contributors to PKHeX and PKHeX.Core + + . diff --git a/Pkmds.Web/Components/LetsGoBoxComponent.razor b/Pkmds.Web/Components/LetsGoBoxComponent.razor index 38d449d8..dc800e4c 100644 --- a/Pkmds.Web/Components/LetsGoBoxComponent.razor +++ b/Pkmds.Web/Components/LetsGoBoxComponent.razor @@ -1,6 +1,6 @@ @inherits BasePkmdsComponent -@if (AppState.SaveFile is SAV7b { } saveFile) +@if (AppState.SaveFile is SAV7b) {
diff --git a/Pkmds.Web/Components/LetsGoBoxGrid.razor b/Pkmds.Web/Components/LetsGoBoxGrid.razor index fa2301af..4b95da0c 100644 --- a/Pkmds.Web/Components/LetsGoBoxGrid.razor +++ b/Pkmds.Web/Components/LetsGoBoxGrid.razor @@ -1,6 +1,6 @@ @inherits BasePkmdsComponent -@if (AppState.SaveFile is SAV7b { } saveFile) +@if (AppState.SaveFile is SAV7b saveFile) { Note: The box grid is scrollable. diff --git a/Pkmds.Web/Components/MainTabPages/BadgesComponent.razor b/Pkmds.Web/Components/MainTabPages/BadgesComponent.razor index 6eec0855..7ce1695c 100644 --- a/Pkmds.Web/Components/MainTabPages/BadgesComponent.razor +++ b/Pkmds.Web/Components/MainTabPages/BadgesComponent.razor @@ -43,9 +43,4 @@ } break; - case SAV1Stadium { Context: EntityContext.Gen1 }: - case SAV1StadiumJ { Context: EntityContext.Gen1 }: - case SAV2Stadium { Context: EntityContext.Gen2 }: - default: - break; } diff --git a/Pkmds.Web/Components/MainTabPages/BadgesComponent.razor.cs b/Pkmds.Web/Components/MainTabPages/BadgesComponent.razor.cs index 4b038691..cac9ac6c 100644 --- a/Pkmds.Web/Components/MainTabPages/BadgesComponent.razor.cs +++ b/Pkmds.Web/Components/MainTabPages/BadgesComponent.razor.cs @@ -1,8 +1,10 @@ +using System.Diagnostics.CodeAnalysis; + namespace Pkmds.Web.Components.MainTabPages; public partial class BadgesComponent : IDisposable { - private const int badgesFlagStart = 124; + private const int BadgesFlagStart = 124; protected override void OnInitialized() => RefreshService.OnAppStateChanged += StateHasChanged; @@ -10,6 +12,7 @@ protected override void OnInitialized() => public void Dispose() => RefreshService.OnAppStateChanged -= StateHasChanged; + [SuppressMessage("ReSharper", "InconsistentNaming")] private List GetSaveFileBadgesValue() { List badgeFlags = []; @@ -23,8 +26,9 @@ private List GetSaveFileBadgesValue() { for (var i = 0; i < 8; i++) { - badgeFlags.Add(sav8bs.FlagWork.GetSystemFlag(badgesFlagStart + i)); + badgeFlags.Add(sav8bs.FlagWork.GetSystemFlag(BadgesFlagStart + i)); } + return badgeFlags; } @@ -74,7 +78,7 @@ private List GetSaveFileBadgesValue() badgeFlagInt = sav6ao.Badges; break; - case EntityContext.Gen7b when saveFile is SAV7b sav7b: + case EntityContext.Gen7b when saveFile is SAV7b: // TODO: Figure out why this isn't available //badgeFlagInt = sav7b.Badges; break; @@ -83,7 +87,7 @@ private List GetSaveFileBadgesValue() badgeFlagInt = sav8swsh.Badges; break; - case EntityContext.Gen9 when saveFile is SAV9SV sav9sv: + case EntityContext.Gen9 when saveFile is SAV9SV: // TODO: Figure out why this isn't available //badgeFlagInt = sav9sv.Badges; break; @@ -97,6 +101,7 @@ private List GetSaveFileBadgesValue() return badgeFlags; } + [SuppressMessage("ReSharper", "InconsistentNaming")] private void OnBadgeToggle(int badgeIndex) { if (AppState.SaveFile is not { } saveFile) @@ -146,7 +151,7 @@ private void OnBadgeToggle(int badgeIndex) sav6ao.Badges = ToggleBadge(sav6ao.Badges, badgeIndex); break; - case EntityContext.Gen7b when saveFile is SAV7b sav7b: + case EntityContext.Gen7b when saveFile is SAV7b: // TODO: Figure out why this isn't available //sav7b.Badges = ToggleBadge(sav7b.Badges, badgeIndex); break; @@ -156,16 +161,17 @@ private void OnBadgeToggle(int badgeIndex) break; case EntityContext.Gen8b when saveFile is SAV8BS sav8bs: - sav8bs.FlagWork.SetSystemFlag(badgesFlagStart + badgeIndex, !sav8bs.FlagWork.GetSystemFlag(badgesFlagStart + badgeIndex)); + sav8bs.FlagWork.SetSystemFlag(BadgesFlagStart + badgeIndex, + !sav8bs.FlagWork.GetSystemFlag(BadgesFlagStart + badgeIndex)); break; - case EntityContext.Gen9 when saveFile is SAV9SV sav9sv: + case EntityContext.Gen9 when saveFile is SAV9SV: // TODO: Figure out why this isn't available //sav9sv.Badges = ToggleBadge(sav9sv.Badges, badgeIndex); break; - }; + } static int ToggleBadge(int badges, int badgeIndex) => - badges ^= (byte)(1 << badgeIndex); + badges ^ (byte)(1 << badgeIndex); } } diff --git a/Pkmds.Web/Components/MainTabPages/BagTab.razor b/Pkmds.Web/Components/MainTabPages/BagTab.razor index c8135455..5d9a9c1a 100644 --- a/Pkmds.Web/Components/MainTabPages/BagTab.razor +++ b/Pkmds.Web/Components/MainTabPages/BagTab.razor @@ -16,7 +16,7 @@ + title="@tabText"/> @if (string.Equals(PouchTabs?.ActivePanel?.ID?.ToString(), pouch.Type.ToString())) { @GetPouchName(pouch) @@ -75,7 +75,7 @@ Value="@GetItem(context)" ValueChanged="@(newItem => SetItem(context, newItem))" SearchFunc="@((string searchString, CancellationToken _) => SearchItemNames(pouch, searchString))" - ToStringFunc="@(item => { return ItemList[context.Item.Index]; })"> + ToStringFunc="@(_ => ItemList[context.Item.Index])"> @if (item.Value != 0) @@ -87,7 +87,8 @@ title="@item.Text"> + title="@item.Text" + alt="@item.Text"> } @@ -106,7 +107,8 @@ title="@itemText"> + title="@itemText" + alt="@itemText"> } @@ -118,7 +120,7 @@ + @bind-Value="@context.Item.Count"/> @if (HasFreeSpace) @@ -129,7 +131,7 @@ { + ValueChanged="@((bool value) => freeSpaceItem.IsFreeSpace = value)"/> } @@ -142,7 +144,7 @@ { + @bind-Value="@freeSpaceIndexItem.FreeSpaceIndex"/> } @@ -155,7 +157,7 @@ { + ValueChanged="@((bool value) => favoriteItem.IsFavorite = value)"/> } @@ -168,7 +170,7 @@ { + ValueChanged="@((bool value) => newFlagItem.IsNew = value)"/> } @@ -179,7 +181,7 @@ ButtonType="@ButtonType.Button" Color="@Color.Error" Variant="@Variant.Filled" - Icon="@Icons.Material.Filled.Delete" /> + Icon="@Icons.Material.Filled.Delete"/> diff --git a/Pkmds.Web/Components/MainTabPages/MysteryGiftDatabaseTab.razor b/Pkmds.Web/Components/MainTabPages/MysteryGiftDatabaseTab.razor index db97aa94..dd9acb6b 100644 --- a/Pkmds.Web/Components/MainTabPages/MysteryGiftDatabaseTab.razor +++ b/Pkmds.Web/Components/MainTabPages/MysteryGiftDatabaseTab.razor @@ -1,11 +1,11 @@ @inherits BasePkmdsComponent -@if (AppState is { SaveFile: { } saveFile } && MysteryGiftsList.Count > 0) +@if (AppState is { SaveFile: not null } && MysteryGiftsList.Count > 0) { + ShowNextButton/> + @bind-Value:set="@SetCurrentRecordValue"/> @if (HallOfFameIndexSelected) { @@ -33,25 +34,25 @@ Min="0" Max="9999" @bind-Value="@HallOfFameHours" - @bind-Value:after="@ChangeFame" /> + @bind-Value:after="@ChangeFame"/>
+ @bind-Value:after="@ChangeFame"/>
+ @bind-Value:after="@ChangeFame"/>
} diff --git a/Pkmds.Web/Components/MainTabPages/RecordsTab.razor.cs b/Pkmds.Web/Components/MainTabPages/RecordsTab.razor.cs index 98dc0111..56bcfc98 100644 --- a/Pkmds.Web/Components/MainTabPages/RecordsTab.razor.cs +++ b/Pkmds.Web/Components/MainTabPages/RecordsTab.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.MainTabPages; public partial class RecordsTab { - [Parameter, EditorRequired] - public SAV3? SaveFile { get; set; } + [Parameter, EditorRequired] public SAV3? SaveFile { get; set; } private int CurrentRecordIndex { get; set; } @@ -86,7 +85,7 @@ private void ChangeFame() Records.SetRecord(1, (uint)(CurrentRecordValue = GetFameTime())); } - public uint GetFameTime() + private uint GetFameTime() { if (!HallOfFameIndexSelected || Records is null) { @@ -100,7 +99,7 @@ public uint GetFameTime() return (hrs << 16) | ((uint)min << 8) | sec; } - public void SetFameTime(uint time) + private void SetFameTime(uint time) { if (!HallOfFameIndexSelected || Records is null) { diff --git a/Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor b/Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor index a5cf8d8b..174195fe 100644 --- a/Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor +++ b/Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor @@ -2,68 +2,69 @@
- @if (AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } saveFile && - saveFileEntityContext is not - EntityContext.None or - EntityContext.SplitInvalid or - EntityContext.MaxInvalid) + @if (AppState.SaveFile is + { + Context: not + (EntityContext.None or + EntityContext.SplitInvalid or + EntityContext.MaxInvalid), + Generation: var saveGeneration + } saveFile) {
+ For="@(() => saveFile.OT)"/>
@switch (saveFile.GetTrainerIDFormat()) { case TrainerIDFormat.SixteenBit: + { +
+ +
+ + @if (saveGeneration >= 3) {
- + @bind-Value="@saveFile.SID16" + Format="@AppService.GetIdFormatString(true)" + For="@(() => saveFile.SID16)"/>
- - @if (saveGeneration >= 3) - { -
- -
- } - } + } break; case TrainerIDFormat.SixDigit: + { +
+ +
+ + @if (saveGeneration >= 3) {
- + @bind-Value="@saveFile.TrainerSID7" + Format="@AppService.GetIdFormatString(true)" + For="@(() => saveFile.TrainerSID7)"/>
- - @if (saveGeneration >= 3) - { -
- -
- } - } + } break; } @@ -71,7 +72,7 @@ {
+ OnChange="@OnGenderToggle"/>
} @@ -115,7 +116,7 @@ Min="0" Max="@ushort.MaxValue" @bind-Value="@saveFile.PlayedHours" - For="@(() => saveFile.PlayedHours)" /> + For="@(() => saveFile.PlayedHours)"/>
@@ -125,7 +126,7 @@ Min="0" Max="59" @bind-Value="@saveFile.PlayedMinutes" - For="@(() => saveFile.PlayedMinutes)" /> + For="@(() => saveFile.PlayedMinutes)"/>
@@ -135,7 +136,7 @@ Min="0" Max="59" @bind-Value="@saveFile.PlayedSeconds" - For="@(() => saveFile.PlayedSeconds)" /> + For="@(() => saveFile.PlayedSeconds)"/>
@if (saveGeneration >= 4) @@ -145,7 +146,7 @@ @bind-Date="@GameStartedDate" @bind-Date:after="@UpdateGameStarted" Variant="@Variant.Outlined" - PickerVariant="@PickerVariant.Inline" /> + PickerVariant="@PickerVariant.Inline"/>
@@ -154,7 +155,7 @@ @bind-Time:after="@UpdateGameStarted" TimeFormat="HH:mm:ss" Variant="@Variant.Outlined" - PickerVariant="@PickerVariant.Inline" /> + PickerVariant="@PickerVariant.Inline"/>
@if (saveGeneration <= 7) @@ -164,7 +165,7 @@ @bind-Date="@HallOfFameDate" @bind-Date:after="@UpdateHallOfFame" Variant="@Variant.Outlined" - PickerVariant="@PickerVariant.Inline" /> + PickerVariant="@PickerVariant.Inline"/>
@@ -173,7 +174,7 @@ @bind-Time:after="@UpdateHallOfFame" TimeFormat="HH:mm:ss" Variant="@Variant.Outlined" - PickerVariant="@PickerVariant.Inline" /> + PickerVariant="@PickerVariant.Inline"/>
} } @@ -185,17 +186,18 @@ Variant="@Variant.Outlined" MaxLength="@sav1Rival.MaxStringLengthTrainer" @bind-Value="@sav1Rival.Rival" - For="@(() => sav1Rival.Rival)" /> + For="@(() => sav1Rival.Rival)"/>
+ @* ReSharper disable once CSharpWarnings::CS8603 *@ + ToStringFunc="@(species => species?.Text)"/>
} @@ -206,7 +208,7 @@ Variant="@Variant.Outlined" MaxLength="@sav2Rival.MaxStringLengthTrainer" @bind-Value="@sav2Rival.Rival" - For="@(() => sav2Rival.Rival)" /> + For="@(() => sav2Rival.Rival)"/> } @@ -217,7 +219,7 @@ Variant="@Variant.Outlined" MaxLength="@sav3FrLgRival.MaxStringLengthTrainer" @bind-Value="@sav3FrLgRival.RivalName" - For="@(() => sav3FrLgRival.RivalName)" /> + For="@(() => sav3FrLgRival.RivalName)"/> } @@ -230,7 +232,7 @@ Min="0" Max="@((uint)saveFile.MaxMoney)" @bind-Value="@saveFile.Money" - For="@(() => saveFile.Money)" /> + For="@(() => saveFile.Money)"/> @if (saveGeneration <= 4) @@ -242,7 +244,7 @@ ValueChanged="@SetCoins" Variant="@Variant.Outlined" Min="0" - Max="@((uint)saveFile.MaxCoins)" /> + Max="@((uint)saveFile.MaxCoins)"/> } @@ -255,7 +257,7 @@ Min="0" Max="9999" @bind-Value="@sav3.BP" - For="@(() => sav3.BP)" /> + For="@(() => sav3.BP)"/>
@@ -265,23 +267,24 @@ Min="0" Max="@uint.MaxValue" @bind-Value="@sav3.BPEarned" - For="@(() => sav3.BPEarned)" /> + For="@(() => sav3.BPEarned)"/>
} @if (saveFile is SAV3FRLG sav3FrLgTrainerCard) { - @for (int i = 0; i < 6; i++) + @for (var i = 0; i < 6; i++) { var localIndex = i;
+ @* ReSharper disable once CSharpWarnings::CS8603 *@ + ToStringFunc="@(species => species?.Text)"/>
} } @@ -292,25 +295,25 @@ + For="@(() => sav4Map.M)"/>
+ For="@(() => sav4Map.X)"/>
+ For="@(() => sav4Map.Z)"/>
+ For="@(() => sav4Map.Y)"/>
} @@ -375,7 +378,7 @@
+ For="@(() => sav1Options.BattleEffects)"/>
} @@ -456,10 +459,10 @@
+ For="@(() => sav2.BattleEffects)"/>
} } - + diff --git a/Pkmds.Web/Components/MarkingsContainer.razor b/Pkmds.Web/Components/MarkingsContainer.razor index 297d593f..0b7a0184 100644 --- a/Pkmds.Web/Components/MarkingsContainer.razor +++ b/Pkmds.Web/Components/MarkingsContainer.razor @@ -1,25 +1,25 @@ -@if (Pokemon is { Generation: { } pokemonGeneration } && pokemonGeneration >= 3) +@if (Pokemon is { Generation: var pokemonGeneration and >= 3 }) {
+ Shape="@MarkingsHelper.Markings.Circle"/> + Shape="@MarkingsHelper.Markings.Triangle"/> + Shape="@MarkingsHelper.Markings.Square"/> + Shape="@MarkingsHelper.Markings.Heart"/> @if (pokemonGeneration >= 4) { + Shape="@MarkingsHelper.Markings.Star"/> + Shape="@MarkingsHelper.Markings.Diamond"/> }
} diff --git a/Pkmds.Web/Components/PartyGrid.razor b/Pkmds.Web/Components/PartyGrid.razor index 6f1ba3bd..7e8b7759 100644 --- a/Pkmds.Web/Components/PartyGrid.razor +++ b/Pkmds.Web/Components/PartyGrid.razor @@ -8,12 +8,12 @@ @for (var i = 0; i < 6; i++) { var slotNum = i; - PKM? pkm = i < saveFile.PartyCount ? saveFile.PartyData[slotNum] : null; + var pkm = i < saveFile.PartyCount ? saveFile.PartyData[slotNum] : null; + GetStyleFunction="@(() => GetStyle(slotNum))"/> } diff --git a/Pkmds.Web/Components/PokemonSlotComponent.razor b/Pkmds.Web/Components/PokemonSlotComponent.razor index db9c695a..993b226b 100644 --- a/Pkmds.Web/Components/PokemonSlotComponent.razor +++ b/Pkmds.Web/Components/PokemonSlotComponent.razor @@ -1,5 +1,4 @@ @inherits BasePkmdsComponent -@implements IDisposable + @{ var title = Pokemon is { Species: > 0 } ? AppService.GetPokemonSpeciesName(Pokemon.Species) : "Unknown"; } + title="@title"> + title="@title" + alt="@title"> diff --git a/Pkmds.Web/Components/PokemonSlotComponent.razor.cs b/Pkmds.Web/Components/PokemonSlotComponent.razor.cs index d6b6c06c..4ae34592 100644 --- a/Pkmds.Web/Components/PokemonSlotComponent.razor.cs +++ b/Pkmds.Web/Components/PokemonSlotComponent.razor.cs @@ -2,17 +2,13 @@ namespace Pkmds.Web.Components; public partial class PokemonSlotComponent : IDisposable { - [Parameter, EditorRequired] - public int SlotNumber { get; set; } + [Parameter, EditorRequired] public int SlotNumber { get; set; } - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } - [Parameter, EditorRequired] - public EventCallback OnSlotClick { get; set; } + [Parameter, EditorRequired] public EventCallback OnSlotClick { get; set; } - [Parameter, EditorRequired] - public Func? GetStyleFunction { get; set; } + [Parameter, EditorRequired] public Func? GetStyleFunction { get; set; } private async Task HandleClick() => await OnSlotClick.InvokeAsync(); diff --git a/Pkmds.Web/Components/PokemonStorageComponent.razor b/Pkmds.Web/Components/PokemonStorageComponent.razor index 467194f2..fb453577 100644 --- a/Pkmds.Web/Components/PokemonStorageComponent.razor +++ b/Pkmds.Web/Components/PokemonStorageComponent.razor @@ -2,11 +2,11 @@ @if (AppState.SaveFile is { } saveFile) { - + @if (saveFile.Version is GameVersion.LG or GameVersion.GP or GameVersion.GE) { - + } else { @@ -25,9 +25,10 @@ Class="box-select"> @for (var boxId = 0; boxId < saveFile.BoxCount; boxId++) { - var boxName = saveFile is IBoxDetailNameRead boxDetailNameRead ? boxDetailNameRead.GetBoxName(boxId) : string.Empty; - + var localBoxId = boxId; + var boxName = saveFile is IBoxDetailNameRead boxDetailNameRead ? boxDetailNameRead.GetBoxName(localBoxId) : string.Empty; + @boxName } @@ -43,6 +44,6 @@ - + } } diff --git a/Pkmds.Web/Components/SaveFileComponent.razor b/Pkmds.Web/Components/SaveFileComponent.razor index 1d671d37..edf02a12 100644 --- a/Pkmds.Web/Components/SaveFileComponent.razor +++ b/Pkmds.Web/Components/SaveFileComponent.razor @@ -6,15 +6,15 @@ { -
+ Height="50px"/> +
-
+ Height="50px"/> +
+ Height="350px"/> } } else @@ -33,19 +33,19 @@ else
- +
- +
- +
@@ -53,7 +53,7 @@ else {
- +
} @@ -61,7 +61,7 @@ else @if (saveFile.Generation == 3 && saveFile is SAV3 sav3) { - + } diff --git a/Pkmds.Web/Constants.cs b/Pkmds.Web/Constants.cs index f4e571e5..c0bbef67 100644 --- a/Pkmds.Web/Constants.cs +++ b/Pkmds.Web/Constants.cs @@ -15,11 +15,21 @@ public static class Constants public const string FemaleGenderUnicode = "♀"; public const string PokeDollarSvg = """ - - - - """; + + + + """; public const string EmptyIndex = "---"; + + public const byte MaxDynamaxLevel = 10; + + public const byte MinMinutes = 0; + + public const byte MaxMinutes = 59; + + public const byte MinSeconds = 0; + + public const byte MaxSeconds = 59; } From 6bd1dc285f86e4ad42107b03f1b9a99c24ff93b7 Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Tue, 17 Dec 2024 18:15:38 -0500 Subject: [PATCH 6/9] Even more code tweaks --- Pkmds.Web/Components/BoxComponent.razor.cs | 6 +- Pkmds.Web/Components/BoxGrid.razor.cs | 6 +- Pkmds.Web/Components/BoxSlotComponent.cs | 3 +- Pkmds.Web/Components/DateOnlyPicker.razor.cs | 42 ++++----- .../Dialogs/ConfirmActionDialog.razor.cs | 30 +++---- .../Dialogs/ShowdownExportDialog.razor.cs | 10 +-- .../EditForms/PokemonEditForm.razor.cs | 35 +++----- .../EditForms/Tabs/CosmeticTab.razor.cs | 3 +- .../Components/EditForms/Tabs/MetTab.razor.cs | 17 ++-- .../EditForms/Tabs/MovesTab.razor.cs | 7 +- .../EditForms/Tabs/OtMiscTab.razor.cs | 5 +- .../EditForms/Tabs/PokerusComponent.razor.cs | 47 +++++----- .../EditForms/Tabs/StatsTab.razor.cs | 10 +-- .../GenderDisplayComponent.razor.cs | 21 ++--- .../Components/Layout/MainLayout.razor.cs | 60 +++---------- .../Components/LetsGoBoxComponent.razor.cs | 3 +- .../Components/MainTabPages/BagTab.razor.cs | 19 ++-- .../MainTabPages/MysteryGiftDatabaseTab.razor | 10 +-- .../MysteryGiftDatabaseTab.razor.cs | 39 ++++---- .../MainTabPages/RecordsTab.razor.cs | 2 +- .../MainTabPages/TrainerInfoTab.razor.cs | 32 ++++--- .../Components/MarkingComponent.razor.cs | 6 +- .../Components/MarkingsContainer.razor.cs | 3 +- Pkmds.Web/Components/Pages/Home.razor.cs | 5 +- Pkmds.Web/Components/PartyGrid.razor.cs | 5 +- .../Components/SaveFileComponent.razor.cs | 1 - Pkmds.Web/Components/SaveFileNameDisplay.cs | 4 +- Pkmds.Web/Extensions/MoveExtension.cs | 8 -- Pkmds.Web/Program.cs | 4 +- Pkmds.Web/Services/AppService.cs | 89 ++++++++++--------- Pkmds.Web/Services/BlazorAesProvider.cs | 3 +- Pkmds.Web/Services/IAppService.cs | 8 +- Pkmds.Web/Services/IRefreshService.cs | 1 + Pkmds.Web/Services/JsService.cs | 4 +- Pkmds.Web/Services/RefreshService.cs | 2 +- Pkmds.Web/SpriteHelper.cs | 62 +++++++------ 36 files changed, 283 insertions(+), 329 deletions(-) delete mode 100644 Pkmds.Web/Extensions/MoveExtension.cs diff --git a/Pkmds.Web/Components/BoxComponent.razor.cs b/Pkmds.Web/Components/BoxComponent.razor.cs index 8d4e46ad..14a4d7e5 100644 --- a/Pkmds.Web/Components/BoxComponent.razor.cs +++ b/Pkmds.Web/Components/BoxComponent.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components; public partial class BoxComponent : IDisposable { - [Parameter] - public int BoxNumber { get; set; } + [Parameter] public int BoxNumber { get; set; } private BoxEdit? BoxEdit { get; set; } @@ -38,9 +37,8 @@ private void ReloadBox() return; } - BoxEdit = new BoxEdit(AppState.SaveFile); + BoxEdit = new(AppState.SaveFile); BoxEdit.LoadBox(BoxNumber); RefreshService.Refresh(); } } - diff --git a/Pkmds.Web/Components/BoxGrid.razor.cs b/Pkmds.Web/Components/BoxGrid.razor.cs index 092dd6e7..ffc55603 100644 --- a/Pkmds.Web/Components/BoxGrid.razor.cs +++ b/Pkmds.Web/Components/BoxGrid.razor.cs @@ -2,11 +2,9 @@ namespace Pkmds.Web.Components; public partial class BoxGrid : IDisposable { - [Parameter, EditorRequired] - public BoxEdit? BoxEdit { get; set; } + [Parameter, EditorRequired] public BoxEdit? BoxEdit { get; set; } - [Parameter, EditorRequired] - public int BoxNumber { get; set; } + [Parameter, EditorRequired] public int BoxNumber { get; set; } private string BoxGridClass => AppState.SaveFile?.BoxSlotCount == 20 ? "box-grid-20" : "box-grid-30"; diff --git a/Pkmds.Web/Components/BoxSlotComponent.cs b/Pkmds.Web/Components/BoxSlotComponent.cs index b46d67b7..91b3c819 100644 --- a/Pkmds.Web/Components/BoxSlotComponent.cs +++ b/Pkmds.Web/Components/BoxSlotComponent.cs @@ -2,6 +2,5 @@ namespace Pkmds.Web.Components; public class BoxSlotComponent : PokemonSlotComponent { - [Parameter, EditorRequired] - public int BoxNumber { get; set; } + [Parameter, EditorRequired] public int BoxNumber { get; set; } } diff --git a/Pkmds.Web/Components/DateOnlyPicker.razor.cs b/Pkmds.Web/Components/DateOnlyPicker.razor.cs index 5b5d7edc..6416d33b 100644 --- a/Pkmds.Web/Components/DateOnlyPicker.razor.cs +++ b/Pkmds.Web/Components/DateOnlyPicker.razor.cs @@ -2,32 +2,23 @@ namespace Pkmds.Web.Components; public partial class DateOnlyPicker { - [CascadingParameter] - public EditContext? EditContext { get; set; } + [CascadingParameter] public EditContext? EditContext { get; set; } - [Parameter, EditorRequired] - public DateOnly? Date { get; set; } + [Parameter, EditorRequired] public DateOnly? Date { get; set; } - [Parameter] - public EventCallback DateChanged { get; set; } + [Parameter] public EventCallback DateChanged { get; set; } - [Parameter, EditorRequired] - public string? Label { get; set; } + [Parameter, EditorRequired] public string? Label { get; set; } - [Parameter] - public Expression>? For { get; set; } + [Parameter] public Expression>? For { get; set; } - [Parameter] - public bool ReadOnly { get; set; } + [Parameter] public bool ReadOnly { get; set; } - [Parameter] - public string? HelperText { get; set; } + [Parameter] public string? HelperText { get; set; } - [Parameter] - public Variant Variant { get; set; } = Variant.Outlined; + [Parameter] public Variant Variant { get; set; } = Variant.Outlined; - [Parameter] - public Color Color { get; set; } = Color.Default; + [Parameter] public Color Color { get; set; } = Color.Default; private MudDatePicker? datePickerRef; @@ -36,11 +27,13 @@ private DateTime? DateBindTarget get => Date?.ToDateTime(TimeOnly.MinValue); set { - if (value is not null) + if (value is null) { - Date = DateOnly.FromDateTime((DateTime)value); - DateChanged.InvokeAsync(Date); + return; } + + Date = DateOnly.FromDateTime((DateTime)value); + DateChanged.InvokeAsync(Date); } } @@ -53,11 +46,14 @@ protected override void OnAfterRender(bool firstRender) if (EditContext is null) { - throw new Exception("Using 'For' without an 'EditContext' is not supported. Are you missing an 'EditForm'?"); + throw new( + "Using 'For' without an 'EditContext' is not supported. Are you missing an 'EditForm'?"); } // Get the private field _fieldidentifier by reflection. - var fieldIdentifierField = typeof(MudFormComponent).GetField("_fieldIdentifier", BindingFlags.Instance | BindingFlags.NonPublic); + var fieldIdentifierField = + typeof(MudFormComponent).GetField("_fieldIdentifier", + BindingFlags.Instance | BindingFlags.NonPublic); // Set the field identifier with our DateOnly? expression, avoiding the type issue between DateOnly vs DateTime fieldIdentifierField?.SetValue(datePickerRef, FieldIdentifier.Create(For)); diff --git a/Pkmds.Web/Components/Dialogs/ConfirmActionDialog.razor.cs b/Pkmds.Web/Components/Dialogs/ConfirmActionDialog.razor.cs index c53f342b..cc0abf34 100644 --- a/Pkmds.Web/Components/Dialogs/ConfirmActionDialog.razor.cs +++ b/Pkmds.Web/Components/Dialogs/ConfirmActionDialog.razor.cs @@ -2,35 +2,25 @@ namespace Pkmds.Web.Components.Dialogs; public partial class ConfirmActionDialog { - [CascadingParameter] - private MudDialogInstance? MudDialog { get; set; } + [CascadingParameter] private MudDialogInstance? MudDialog { get; set; } - [Parameter] - public string Title { get; set; } = "Confirm Action"; + [Parameter] public string Title { get; set; } = "Confirm Action"; - [Parameter] - public string Message { get; set; } = "Are you sure you want to perform this action?"; + [Parameter] public string Message { get; set; } = "Are you sure you want to perform this action?"; - [Parameter] - public string ConfirmText { get; set; } = "Confirm"; + [Parameter] public string ConfirmText { get; set; } = "Confirm"; - [Parameter] - public string ConfirmIcon { get; set; } = Icons.Material.Filled.Check; + [Parameter] public string ConfirmIcon { get; set; } = Icons.Material.Filled.Check; - [Parameter] - public Color ConfirmColor { get; set; } = Color.Primary; + [Parameter] public Color ConfirmColor { get; set; } = Color.Primary; - [Parameter] - public string CancelText { get; set; } = "Cancel"; + [Parameter] public string CancelText { get; set; } = "Cancel"; - [Parameter] - public string CancelIcon { get; set; } = Icons.Material.Filled.Clear; + [Parameter] public string CancelIcon { get; set; } = Icons.Material.Filled.Clear; - [Parameter] - public Color CancelColor { get; set; } = Color.Secondary; + [Parameter] public Color CancelColor { get; set; } = Color.Secondary; - [Parameter] - public EventCallback OnConfirm { get; set; } + [Parameter] public EventCallback OnConfirm { get; set; } private void Confirm() { diff --git a/Pkmds.Web/Components/Dialogs/ShowdownExportDialog.razor.cs b/Pkmds.Web/Components/Dialogs/ShowdownExportDialog.razor.cs index a26d2b1d..3ab6420f 100644 --- a/Pkmds.Web/Components/Dialogs/ShowdownExportDialog.razor.cs +++ b/Pkmds.Web/Components/Dialogs/ShowdownExportDialog.razor.cs @@ -2,13 +2,13 @@ namespace Pkmds.Web.Components.Dialogs; public partial class ShowdownExportDialog { - [Parameter] - public PKM? Pokemon { get; set; } + [Parameter] public PKM? Pokemon { get; set; } - [CascadingParameter] - private MudDialogInstance? MudDialog { get; set; } + [CascadingParameter] private MudDialogInstance? MudDialog { get; set; } - private string ShowdownExport => Pokemon is not null ? AppService.ExportPokemonAsShowdown(Pokemon) : AppService.ExportPartyAsShowdown(); + private string ShowdownExport => Pokemon is not null + ? AppService.ExportPokemonAsShowdown(Pokemon) + : AppService.ExportPartyAsShowdown(); private void Close() => MudDialog?.Close(); } diff --git a/Pkmds.Web/Components/EditForms/PokemonEditForm.razor.cs b/Pkmds.Web/Components/EditForms/PokemonEditForm.razor.cs index d41a2ea7..c0e6ea24 100644 --- a/Pkmds.Web/Components/EditForms/PokemonEditForm.razor.cs +++ b/Pkmds.Web/Components/EditForms/PokemonEditForm.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.EditForms; public partial class PokemonEditForm : IDisposable { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } protected override void OnInitialized() => RefreshService.OnAppStateChanged += StateHasChanged; @@ -14,14 +13,8 @@ public void Dispose() => private void ExportAsShowdown() => DialogService.Show( "Showdown Export", - new DialogParameters - { - { nameof(ShowdownExportDialog.Pokemon), Pokemon } - }, - new DialogOptions - { - CloseOnEscapeKey = true, - }); + new() { { nameof(ShowdownExportDialog.Pokemon), Pokemon } }, + new() { CloseOnEscapeKey = true, }); private void DeletePokemon() { @@ -34,22 +27,17 @@ private void DeletePokemon() { nameof(ConfirmActionDialog.ConfirmColor), Color.Default }, { nameof(ConfirmActionDialog.CancelText), "Cancel" }, { nameof(ConfirmActionDialog.CancelIcon), Icons.Material.Filled.Clear }, - { nameof(ConfirmActionDialog.CancelColor), Color.Error}, + { nameof(ConfirmActionDialog.CancelColor), Color.Error }, { nameof(ConfirmActionDialog.OnConfirm), EventCallback.Factory.Create(this, OnDeleteConfirm) } }; DialogService.Show( "Confirm Action", parameters, - new DialogOptions - { - CloseOnEscapeKey = true, - MaxWidth = MaxWidth.Small, - }); + new() { CloseOnEscapeKey = true, MaxWidth = MaxWidth.Small, }); void OnDeleteConfirm(bool confirmed) { - if (!confirmed) { return; @@ -99,24 +87,23 @@ void ShowPasteConfirmation() var parameters = new DialogParameters { { nameof(ConfirmActionDialog.Title), "Paste Pokémon" }, - { nameof(ConfirmActionDialog.Message), "Are you sure you want to paste the copied Pokémon? The Pokémon in the selected slot will be replaced." }, + { + nameof(ConfirmActionDialog.Message), + "Are you sure you want to paste the copied Pokémon? The Pokémon in the selected slot will be replaced." + }, { nameof(ConfirmActionDialog.ConfirmText), "Paste" }, { nameof(ConfirmActionDialog.ConfirmIcon), Icons.Material.Filled.Delete }, { nameof(ConfirmActionDialog.ConfirmColor), Color.Default }, { nameof(ConfirmActionDialog.CancelText), "Cancel" }, { nameof(ConfirmActionDialog.CancelIcon), Icons.Material.Filled.Clear }, - { nameof(ConfirmActionDialog.CancelColor), Color.Primary}, + { nameof(ConfirmActionDialog.CancelColor), Color.Primary }, { nameof(ConfirmActionDialog.OnConfirm), EventCallback.Factory.Create(this, OnPasteConfirm) } }; DialogService.Show( "Confirm Action", parameters, - new DialogOptions - { - CloseOnEscapeKey = true, - MaxWidth = MaxWidth.Small, - }); + new() { CloseOnEscapeKey = true, MaxWidth = MaxWidth.Small, }); } void OnPasteConfirm(bool confirmed) diff --git a/Pkmds.Web/Components/EditForms/Tabs/CosmeticTab.razor.cs b/Pkmds.Web/Components/EditForms/Tabs/CosmeticTab.razor.cs index aeacdcff..fbe1f8ee 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/CosmeticTab.razor.cs +++ b/Pkmds.Web/Components/EditForms/Tabs/CosmeticTab.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.EditForms.Tabs; public partial class CosmeticTab : IDisposable { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } protected override void OnInitialized() => RefreshService.OnAppStateChanged += StateHasChanged; diff --git a/Pkmds.Web/Components/EditForms/Tabs/MetTab.razor.cs b/Pkmds.Web/Components/EditForms/Tabs/MetTab.razor.cs index cbdc5601..48257b2f 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MetTab.razor.cs +++ b/Pkmds.Web/Components/EditForms/Tabs/MetTab.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.EditForms.Tabs; public partial class MetTab : IDisposable { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } /// /// Currently loaded met location group that is populating Met and Egg location comboboxes @@ -51,6 +50,7 @@ private void CheckMetLocationChange(GameVersion version, EntityContext context) version = group = context.GetSingleGameVersion(); } } + if (group != origintrack || context != originFormat) { currentLocationSearchVersion = version; @@ -70,7 +70,8 @@ private ComboItem GetMetLocation() CheckMetLocationChange(pkm.Version, pkm.Context); - return AppService.GetMetLocationComboItem(Pokemon.MetLocation, currentLocationSearchVersion, currentLocationSearchContext); + return AppService.GetMetLocationComboItem(Pokemon.MetLocation, currentLocationSearchVersion, + currentLocationSearchContext); } private ComboItem GetEggMetLocation() @@ -81,7 +82,8 @@ private ComboItem GetEggMetLocation() } CheckMetLocationChange(pkm.Version, pkm.Context); - return AppService.GetMetLocationComboItem(Pokemon.EggLocation, currentLocationSearchVersion, currentLocationSearchContext, true); + return AppService.GetMetLocationComboItem(Pokemon.EggLocation, currentLocationSearchVersion, + currentLocationSearchContext, true); } private void OriginGameChanged() @@ -95,10 +97,12 @@ private void OriginGameChanged() } private Task> SearchMetLocations(string searchString, CancellationToken token) => - Task.FromResult(AppService.SearchMetLocations(searchString, currentLocationSearchVersion, currentLocationSearchContext)); + Task.FromResult(AppService.SearchMetLocations(searchString, currentLocationSearchVersion, + currentLocationSearchContext)); private Task> SearchEggMetLocations(string searchString, CancellationToken token) => - Task.FromResult(AppService.SearchMetLocations(searchString, currentLocationSearchVersion, currentLocationSearchContext, isEggLocation: true)); + Task.FromResult(AppService.SearchMetLocations(searchString, currentLocationSearchVersion, + currentLocationSearchContext, isEggLocation: true)); private MetTimeOfDay GetMetTimeOfDay => Pokemon is not (PK2 and ICaughtData2 c2) ? MetTimeOfDay.None @@ -139,6 +143,7 @@ private void MetAsEggChanged(bool newValue) { Pokemon.IsEgg = false; } + Pokemon.EggDay = Pokemon.EggMonth = Pokemon.EggYear = 0; Pokemon.EggLocation = 0; break; diff --git a/Pkmds.Web/Components/EditForms/Tabs/MovesTab.razor.cs b/Pkmds.Web/Components/EditForms/Tabs/MovesTab.razor.cs index cd3dd6ed..3761f637 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MovesTab.razor.cs +++ b/Pkmds.Web/Components/EditForms/Tabs/MovesTab.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.EditForms.Tabs; public partial class MovesTab : IDisposable { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } protected override void OnInitialized() => RefreshService.OnAppStateChanged += StateHasChanged; @@ -26,9 +25,11 @@ private void SetPokemonMove(int moveIndex, ComboItem moveComboItem) RefreshService.Refresh(); } + // ReSharper disable once InconsistentNaming private int GetPokemonPP(int moveIndex) => Pokemon?.GetPP()[moveIndex] ?? 0; + // ReSharper disable once InconsistentNaming private void SetPokemonPP(int moveIndex, int pp) { if (Pokemon is null) @@ -41,9 +42,11 @@ private void SetPokemonPP(int moveIndex, int pp) RefreshService.Refresh(); } + // ReSharper disable once InconsistentNaming private int GetPokemonPPUps(int moveIndex) => Pokemon?.GetPPUps()[moveIndex] ?? 0; + // ReSharper disable once InconsistentNaming private void SetPokemonPPUps(int moveIndex, int ppUps) { if (Pokemon is null) diff --git a/Pkmds.Web/Components/EditForms/Tabs/OtMiscTab.razor.cs b/Pkmds.Web/Components/EditForms/Tabs/OtMiscTab.razor.cs index e6915b77..8697f3c4 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/OtMiscTab.razor.cs +++ b/Pkmds.Web/Components/EditForms/Tabs/OtMiscTab.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.EditForms.Tabs; public partial class OtMiscTab : IDisposable { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } protected override void OnInitialized() => RefreshService.OnAppStateChanged += StateHasChanged; @@ -35,8 +34,6 @@ private void FillFromGame() Pokemon.SetTrainerTID7(saveFile.TrainerTID7); Pokemon.SetTrainerSID7(saveFile.TrainerSID7); break; - default: - break; } } diff --git a/Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor.cs b/Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor.cs index ae372863..fb13b397 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor.cs +++ b/Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.EditForms.Tabs; public partial class PokerusComponent { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } private List PokerusDays { get; set; } = []; @@ -29,28 +28,28 @@ private void SetPokerusInfected(bool infected) Pokemon.IsPokerusInfected = infected; - if (!infected && Pokemon.IsPokerusCured) - { - Pokemon.IsPokerusCured = false; - return; - } - - if (infected) - { - if (Pokemon.PokerusStrain == 0) - { - Pokemon.PokerusStrain = 1; - } - - if (Pokemon.PokerusDays == 0) - { - Pokemon.PokerusDays = 1; - } - } - - if (!infected) - { - Pokemon.PokerusStrain = Pokemon.PokerusDays = 0; + switch (infected) + { + case false when Pokemon.IsPokerusCured: + Pokemon.IsPokerusCured = false; + return; + case true: + { + if (Pokemon.PokerusStrain == 0) + { + Pokemon.PokerusStrain = 1; + } + + if (Pokemon.PokerusDays == 0) + { + Pokemon.PokerusDays = 1; + } + + break; + } + case false: + Pokemon.PokerusStrain = Pokemon.PokerusDays = 0; + break; } } diff --git a/Pkmds.Web/Components/EditForms/Tabs/StatsTab.razor.cs b/Pkmds.Web/Components/EditForms/Tabs/StatsTab.razor.cs index d796c3ae..1e827a8d 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/StatsTab.razor.cs +++ b/Pkmds.Web/Components/EditForms/Tabs/StatsTab.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.EditForms.Tabs; public partial class StatsTab : IDisposable { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } protected override void OnInitialized() => RefreshService.OnAppStateChanged += StateHasChanged; @@ -11,9 +10,8 @@ protected override void OnInitialized() => public void Dispose() => RefreshService.OnAppStateChanged -= StateHasChanged; - public static string GetCharacteristic(PKM? pokemon) => - pokemon?.Characteristic is int characteristicIndex && - characteristicIndex > -1 && + private static string GetCharacteristic(PKM? pokemon) => + pokemon?.Characteristic is { } characteristicIndex and > -1 && GameInfo.Strings.characteristics is { Length: > 0 } characteristics && characteristicIndex < characteristics.Length ? characteristics[characteristicIndex] @@ -64,7 +62,7 @@ private void OnStatNatureSet(Nature statNature) private string GetStatClass(Stats stat) { - if (Pokemon is not INature) + if (Pokemon is null) { return string.Empty; } diff --git a/Pkmds.Web/Components/GenderDisplayComponent.razor.cs b/Pkmds.Web/Components/GenderDisplayComponent.razor.cs index ea4d51df..cc01de73 100644 --- a/Pkmds.Web/Components/GenderDisplayComponent.razor.cs +++ b/Pkmds.Web/Components/GenderDisplayComponent.razor.cs @@ -1,17 +1,14 @@ namespace Pkmds.Web.Components; + public partial class GenderDisplayComponent { - [Parameter] - public Gender Gender { get; set; } + [Parameter] public Gender Gender { get; set; } - [Parameter] - public EventCallback OnChange { get; set; } + [Parameter] public EventCallback OnChange { get; set; } - [Parameter] - public bool Disabled { get; set; } + [Parameter] public bool Disabled { get; set; } - [Parameter] - public bool IncludeGenderless { get; set; } + [Parameter] public bool IncludeGenderless { get; set; } private static string GetGenderIcon(Gender gender) => gender switch { @@ -28,10 +25,10 @@ public partial class GenderDisplayComponent _ => string.Empty, }; - public RenderFragment GenderDisplayIcon(Gender gender) => !Disabled && OnChange.HasDelegate - ? GenderButton(gender, IncludeGenderless) - : GenderIconOnly(gender); + private RenderFragment GenderDisplayIcon(Gender gender) => !Disabled && OnChange.HasDelegate + ? GenderButton(gender, IncludeGenderless) + : GenderIconOnly(gender); - public static RenderFragment GenderDisplayAscii(Gender gender) => + private static RenderFragment GenderDisplayAscii(Gender gender) => GenderText(gender.ToString(), GetGenderColor(gender)); } diff --git a/Pkmds.Web/Components/Layout/MainLayout.razor.cs b/Pkmds.Web/Components/Layout/MainLayout.razor.cs index b499aa30..b244c605 100644 --- a/Pkmds.Web/Components/Layout/MainLayout.razor.cs +++ b/Pkmds.Web/Components/Layout/MainLayout.razor.cs @@ -36,18 +36,11 @@ private async Task ShowLoadSaveFileDialog() { const string message = "Choose a save file"; - var dialogParameters = new DialogParameters - { - { nameof(FileUploadDialog.Message), message } - }; + var dialogParameters = new DialogParameters { { nameof(FileUploadDialog.Message), message } }; var dialog = await DialogService.ShowAsync("Load Save File", parameters: dialogParameters, - options: new DialogOptions - { - CloseOnEscapeKey = true, - BackdropClick = false, - }); + options: new() { CloseOnEscapeKey = true, BackdropClick = false, }); var result = await dialog.Result; if (result is { Data: IBrowserFile selectedFile }) @@ -80,7 +73,8 @@ private async Task LoadSaveFile(IBrowserFile selectedFile) if (AppState.SaveFile is null) { - const string message = "The selected save file is invalid. If this save file came from a ROM hack, it is not supported. Otherwise, try saving in-game and re-exporting / re-uploading the save file."; + const string message = + "The selected save file is invalid. If this save file came from a ROM hack, it is not supported. Otherwise, try saving in-game and re-exporting / re-uploading the save file."; await DialogService.ShowMessageBox("Error", message); return; } @@ -119,25 +113,17 @@ private async Task ShowLoadPokemonFileDialog() const string title = "Load Pokémon File"; const string message = "Choose a Pokémon file"; - var dialogParameters = new DialogParameters - { - { nameof(FileUploadDialog.Message), message } - }; + var dialogParameters = new DialogParameters { { nameof(FileUploadDialog.Message), message } }; var dialog = await DialogService.ShowAsync( title, parameters: dialogParameters, - options: new DialogOptions - { - CloseOnEscapeKey = true, - BackdropClick = false, - }); + options: new() { CloseOnEscapeKey = true, BackdropClick = false, }); var result = await dialog.Result; if (result is { Data: IBrowserFile selectedFile }) { - var browserLoadPokemonFile = selectedFile; - await LoadPokemonFile(browserLoadPokemonFile, title); + await LoadPokemonFile(selectedFile, title); } } @@ -146,25 +132,17 @@ private async Task ShowLoadMysteryGiftFileDialog() const string title = "Load Mystery Gift file"; const string message = "Choose a Mystery Gift file"; - var dialogParameters = new DialogParameters - { - { nameof(FileUploadDialog.Message), message } - }; + var dialogParameters = new DialogParameters { { nameof(FileUploadDialog.Message), message } }; var dialog = await DialogService.ShowAsync( title, parameters: dialogParameters, - options: new DialogOptions - { - CloseOnEscapeKey = true, - BackdropClick = false, - }); + options: new() { CloseOnEscapeKey = true, BackdropClick = false, }); var result = await dialog.Result; if (result is { Data: IBrowserFile selectedFile }) { - var browserLoadPokemonFile = selectedFile; - await LoadMysteryGiftFile(browserLoadPokemonFile, title); + await LoadMysteryGiftFile(selectedFile, title); } } @@ -175,12 +153,6 @@ private async Task LoadPokemonFile(IBrowserFile browserLoadPokemonFile, string t return; } - if (browserLoadPokemonFile is null) - { - await DialogService.ShowMessageBox("No file selected", "Please select a file to load."); - return; - } - AppState.ShowProgressIndicator = true; try @@ -248,12 +220,6 @@ private async Task LoadMysteryGiftFile(IBrowserFile browserLoadMysteryGiftFile, return; } - if (browserLoadMysteryGiftFile is null) - { - await DialogService.ShowMessageBox("No file selected", "Please select a file to load."); - return; - } - AppState.ShowProgressIndicator = true; try @@ -263,7 +229,8 @@ private async Task LoadMysteryGiftFile(IBrowserFile browserLoadMysteryGiftFile, await fileStream.CopyToAsync(memoryStream); var data = memoryStream.ToArray(); - if (!FileUtil.TryGetMysteryGift(data, out var mysteryGift, Path.GetExtension(browserLoadMysteryGiftFile.Name))) + if (!FileUtil.TryGetMysteryGift(data, out var mysteryGift, + Path.GetExtension(browserLoadMysteryGiftFile.Name))) { await DialogService.ShowMessageBox("Error", "The file is not a supported Mystery Gift file."); return; @@ -350,7 +317,8 @@ private async Task WriteFile(byte[] data, string fileName, string fileTypeExtens try { // Ensure that the FilePicker API is invoked correctly within a user gesture context - await JSRuntime.InvokeVoidAsync("showFilePickerAndWrite", fileName, data, fileTypeExtension, fileTypeDescription); + await JSRuntime.InvokeVoidAsync("showFilePickerAndWrite", fileName, data, fileTypeExtension, + fileTypeDescription); } catch (JSException ex) { diff --git a/Pkmds.Web/Components/LetsGoBoxComponent.razor.cs b/Pkmds.Web/Components/LetsGoBoxComponent.razor.cs index 6dfc7857..d322fb5b 100644 --- a/Pkmds.Web/Components/LetsGoBoxComponent.razor.cs +++ b/Pkmds.Web/Components/LetsGoBoxComponent.razor.cs @@ -2,6 +2,7 @@ namespace Pkmds.Web.Components; public partial class LetsGoBoxComponent : IDisposable { + // ReSharper disable once UnusedAutoPropertyAccessor.Global public BoxEdit? BoxEdit { get; set; } protected override void OnInitialized() @@ -33,7 +34,7 @@ private void ReloadBox() return; } - BoxEdit = new BoxEdit(AppState.SaveFile); + BoxEdit = new(AppState.SaveFile); RefreshService.Refresh(); } } diff --git a/Pkmds.Web/Components/MainTabPages/BagTab.razor.cs b/Pkmds.Web/Components/MainTabPages/BagTab.razor.cs index b9639c38..bf03c1f2 100644 --- a/Pkmds.Web/Components/MainTabPages/BagTab.razor.cs +++ b/Pkmds.Web/Components/MainTabPages/BagTab.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components.MainTabPages; public partial class BagTab { - [Parameter, EditorRequired] - public IReadOnlyList? Inventory { get; set; } + [Parameter, EditorRequired] public IReadOnlyList? Inventory { get; set; } private MudTabs? PouchTabs { get; set; } @@ -104,16 +103,23 @@ private void DeleteItem(CellContext context, InventoryPouch pouch private string[] GetStringsForPouch(ReadOnlySpan items, bool sort = true) { - string[] res = new string[items.Length + 1]; - for (int i = 0; i < res.Length - 1; i++) + var res = new string[items.Length + 1]; + for (var i = 0; i < res.Length - 1; i++) + { res[i] = ItemList[items[i]]; + } + res[items.Length] = ItemList[0]; if (sort) + { Array.Sort(res); + } + return res; } - private void SortByName(InventoryPouch pouch) => pouch.SortByName(ItemList, reverse: IsSortedByName = !IsSortedByName); + private void SortByName(InventoryPouch pouch) => + pouch.SortByName(ItemList, reverse: IsSortedByName = !IsSortedByName); private void SortByCount(InventoryPouch pouch) => pouch.SortByCount(reverse: IsSortedByCount = !IsSortedByCount); @@ -125,6 +131,7 @@ private Task> SearchItemNames(InventoryPouch pouch, strin return Task.FromResult(ItemList .Select((name, index) => new ComboItem(name, index)) - .Where(x => itemsToSearch.Contains(x.Text) && x.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase))); + .Where(x => itemsToSearch.Contains(x.Text) && + x.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase))); } } diff --git a/Pkmds.Web/Components/MainTabPages/MysteryGiftDatabaseTab.razor b/Pkmds.Web/Components/MainTabPages/MysteryGiftDatabaseTab.razor index dd9acb6b..c26dbb26 100644 --- a/Pkmds.Web/Components/MainTabPages/MysteryGiftDatabaseTab.razor +++ b/Pkmds.Web/Components/MainTabPages/MysteryGiftDatabaseTab.razor @@ -1,17 +1,17 @@ @inherits BasePkmdsComponent -@if (AppState is { SaveFile: not null } && MysteryGiftsList.Count > 0) +@if (AppState is { SaveFile: not null } && mysteryGiftsList.Count > 0) { - - @foreach (var pageSize in PagesSizes) + @foreach (var pageSize in pagesSizes) { @pageSize @@ -22,7 +22,7 @@
- @foreach (var mysteryGift in PaginatedItems) + @foreach (var mysteryGift in paginatedItems) { MysteryGiftsList = []; + private List mysteryGiftsList = []; - private List PaginatedItems = []; - private int CurrentPage = 1; - private int PageSize = 20; // Number of items per page - private readonly int[] PagesSizes = [10, 20, 50, 100]; + private List paginatedItems = []; + private int currentPage = 1; + private int pageSize = 20; // Number of items per page + private readonly int[] pagesSizes = [10, 20, 50, 100]; - private int TotalPages => (int)Math.Ceiling((double)MysteryGiftsList.Count / PageSize); + private int TotalPages => (int)Math.Ceiling((double)mysteryGiftsList.Count / pageSize); protected override void OnInitialized() { @@ -43,28 +42,29 @@ private void LoadData() }; } - MysteryGiftsList = [.. encounterDatabase]; + mysteryGiftsList = [.. encounterDatabase]; - foreach (var mysteryGift in MysteryGiftsList) + foreach (var mysteryGift in mysteryGiftsList) { mysteryGift.GiftUsed = false; } UpdatePaginatedItems(); - static Func IsPresent(TTable pt) where TTable : IPersonalTable => z => pt.IsPresentInGame(z.Species, z.Form); + static Func IsPresent(TTable pt) where TTable : IPersonalTable => + z => pt.IsPresentInGame(z.Species, z.Form); } - private void UpdatePaginatedItems() => PaginatedItems = MysteryGiftsList - .Skip((CurrentPage - 1) * PageSize) - .Take(PageSize) - .ToList(); + private void UpdatePaginatedItems() => paginatedItems = mysteryGiftsList + .Skip((currentPage - 1) * pageSize) + .Take(pageSize) + .ToList(); private void GoToPage() => UpdatePaginatedItems(); private void OnPageSizeChange() { - CurrentPage = 1; // Reset to the first page + currentPage = 1; // Reset to the first page UpdatePaginatedItems(); } @@ -92,12 +92,12 @@ private async Task OnClickCopy(MysteryGift gift) saveFile.AdaptPKM(pokemon); AppState.CopiedPokemon = pokemon.Clone(); - Snackbar.Add("The selected Pokémon has been copied."); + Snackbar.Add("The selected Pokémon has been copied."); } private static string RenderListAsHtml(IReadOnlyList items, string tag = "p") { - if (items == null || items.Count == 0) + if (items.Count == 0) { return string.Empty; } @@ -107,6 +107,7 @@ private static string RenderListAsHtml(IReadOnlyList items, string tag = { builder.AppendFormat("<{0}>{1}", tag, WebUtility.HtmlEncode(item)); } + return builder.ToString(); } } diff --git a/Pkmds.Web/Components/MainTabPages/RecordsTab.razor.cs b/Pkmds.Web/Components/MainTabPages/RecordsTab.razor.cs index 56bcfc98..cd2949c5 100644 --- a/Pkmds.Web/Components/MainTabPages/RecordsTab.razor.cs +++ b/Pkmds.Web/Components/MainTabPages/RecordsTab.razor.cs @@ -39,7 +39,7 @@ private void LoadRecords() return; } - Records = new Record3(SaveFile); + Records = new(SaveFile); RecordComboItems = Record3.GetItems(SaveFile); GetRecord(); } diff --git a/Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor.cs b/Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor.cs index b1d25327..be097291 100644 --- a/Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor.cs +++ b/Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor.cs @@ -174,7 +174,7 @@ private static void SetTrainerCardPokemon(SAV3FRLG sav, int index, ComboItem spe break; default: return (null, null); - }; + } return (date, time.TimeOfDay); } @@ -192,20 +192,24 @@ private void UpdateGameStarted() switch (saveFile) { case SAV4 sav: - sav.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(date, new DateTime(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); + sav.SecondsToStart = + (uint)DateUtil.GetSecondsFrom2000(date, new(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); break; case SAV5 sav: - sav.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(date, new DateTime(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); + sav.SecondsToStart = + (uint)DateUtil.GetSecondsFrom2000(date, new(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); break; case SAV6 sav: - sav.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(date, new DateTime(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); + sav.SecondsToStart = + (uint)DateUtil.GetSecondsFrom2000(date, new(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); break; case SAV7 sav: - sav.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(date, new DateTime(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); + sav.SecondsToStart = + (uint)DateUtil.GetSecondsFrom2000(date, new(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); break; default: return; - }; + } } private (DateTime? Date, TimeSpan? Time) GetHallOfFame() @@ -234,7 +238,7 @@ private void UpdateGameStarted() break; default: return (null, null); - }; + } return (date, time.TimeOfDay); } @@ -252,20 +256,24 @@ private void UpdateHallOfFame() switch (saveFile) { case SAV4 sav: - sav.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(date, new DateTime(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); + sav.SecondsToFame = + (uint)DateUtil.GetSecondsFrom2000(date, new(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); break; case SAV5 sav: - sav.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(date, new DateTime(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); + sav.SecondsToFame = + (uint)DateUtil.GetSecondsFrom2000(date, new(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); break; case SAV6 sav: - sav.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(date, new DateTime(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); + sav.SecondsToFame = + (uint)DateUtil.GetSecondsFrom2000(date, new(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); break; case SAV7 sav: - sav.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(date, new DateTime(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); + sav.SecondsToFame = + (uint)DateUtil.GetSecondsFrom2000(date, new(2000, 1, 1, time.Hours, time.Minutes, time.Seconds)); break; default: return; - }; + } } private ComboItem GetGen1RivalStarter(SAV1 sav1) diff --git a/Pkmds.Web/Components/MarkingComponent.razor.cs b/Pkmds.Web/Components/MarkingComponent.razor.cs index 50fb2fcf..83617349 100644 --- a/Pkmds.Web/Components/MarkingComponent.razor.cs +++ b/Pkmds.Web/Components/MarkingComponent.razor.cs @@ -4,11 +4,9 @@ namespace Pkmds.Web.Components; public partial class MarkingComponent { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } - [Parameter, EditorRequired] - public Markings Shape { get; set; } + [Parameter, EditorRequired] public Markings Shape { get; set; } private string DisplayString => Shape switch { diff --git a/Pkmds.Web/Components/MarkingsContainer.razor.cs b/Pkmds.Web/Components/MarkingsContainer.razor.cs index 72ce4e37..d65116b2 100644 --- a/Pkmds.Web/Components/MarkingsContainer.razor.cs +++ b/Pkmds.Web/Components/MarkingsContainer.razor.cs @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components; public partial class MarkingsContainer : IDisposable { - [Parameter, EditorRequired] - public PKM? Pokemon { get; set; } + [Parameter, EditorRequired] public PKM? Pokemon { get; set; } private string ContainerClass => $"markings-container{(Pokemon is { Generation: 3 } ? " gen-3" : string.Empty)}"; diff --git a/Pkmds.Web/Components/Pages/Home.razor.cs b/Pkmds.Web/Components/Pages/Home.razor.cs index ad0eec0b..e20f7bc8 100644 --- a/Pkmds.Web/Components/Pages/Home.razor.cs +++ b/Pkmds.Web/Components/Pages/Home.razor.cs @@ -1,8 +1,9 @@ namespace Pkmds.Web.Components.Pages; +// ReSharper disable once UnusedType.Global public partial class Home : IDisposable { - private bool IsUpdateAvailable { get; set; } = false; + private bool IsUpdateAvailable { get; set; } protected override void OnInitialized() { @@ -16,7 +17,7 @@ public void Dispose() RefreshService.OnUpdateAvailable -= ShowUpdateMessage; } - public void ShowUpdateMessage() + private void ShowUpdateMessage() { // Display the alert when an update is available IsUpdateAvailable = true; diff --git a/Pkmds.Web/Components/PartyGrid.razor.cs b/Pkmds.Web/Components/PartyGrid.razor.cs index c9cc2bbd..74b5ea2f 100644 --- a/Pkmds.Web/Components/PartyGrid.razor.cs +++ b/Pkmds.Web/Components/PartyGrid.razor.cs @@ -24,8 +24,5 @@ public void Dispose() private void ExportAsShowdown() => DialogService.Show( "Showdown Export", - new DialogOptions - { - CloseOnEscapeKey = true - }); + new DialogOptions { CloseOnEscapeKey = true }); } diff --git a/Pkmds.Web/Components/SaveFileComponent.razor.cs b/Pkmds.Web/Components/SaveFileComponent.razor.cs index a51a3151..dd1253fd 100644 --- a/Pkmds.Web/Components/SaveFileComponent.razor.cs +++ b/Pkmds.Web/Components/SaveFileComponent.razor.cs @@ -5,5 +5,4 @@ public partial class SaveFileComponent : IDisposable protected override void OnInitialized() => RefreshService.OnAppStateChanged += StateHasChanged; public void Dispose() => RefreshService.OnAppStateChanged -= StateHasChanged; - } diff --git a/Pkmds.Web/Components/SaveFileNameDisplay.cs b/Pkmds.Web/Components/SaveFileNameDisplay.cs index 54458e56..0ce54161 100644 --- a/Pkmds.Web/Components/SaveFileNameDisplay.cs +++ b/Pkmds.Web/Components/SaveFileNameDisplay.cs @@ -21,7 +21,9 @@ public static string SaveFileNameDisplayString(IAppState appState, IAppService a if (saveFile.Context is not EntityContext.Gen1) { - var genderDisplay = saveFile.Gender == (byte)Gender.Male ? Constants.MaleGenderUnicode : Constants.FemaleGenderUnicode; + var genderDisplay = saveFile.Gender == (byte)Gender.Male + ? Constants.MaleGenderUnicode + : Constants.FemaleGenderUnicode; sbTitle.Append($"{genderDisplay} "); } diff --git a/Pkmds.Web/Extensions/MoveExtension.cs b/Pkmds.Web/Extensions/MoveExtension.cs deleted file mode 100644 index d7bebe34..00000000 --- a/Pkmds.Web/Extensions/MoveExtension.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Pkmds.Web.Extensions; - -public static class MoveExtension -{ - public static bool IsValidMove(this Move move) => move is > Move.None and < Move.MAX_COUNT; - - public static bool IsValidMove(this ushort move) => IsValidMove((Move)move); -} diff --git a/Pkmds.Web/Program.cs b/Pkmds.Web/Program.cs index 986c15b9..223e39e8 100644 --- a/Pkmds.Web/Program.cs +++ b/Pkmds.Web/Program.cs @@ -5,14 +5,14 @@ builder.RootComponents.Add("head::after"); services - .AddMudServices(config => + .AddMudServices(config => { config.SnackbarConfiguration.PreventDuplicates = false; config.SnackbarConfiguration.ClearAfterNavigation = true; }); services - .AddSingleton(_ => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }) + .AddSingleton(_ => new HttpClient { BaseAddress = new(builder.HostEnvironment.BaseAddress) }) .AddFileSystemAccessService() .AddSingleton() .AddSingleton() diff --git a/Pkmds.Web/Services/AppService.cs b/Pkmds.Web/Services/AppService.cs index af93cfd2..9b535588 100644 --- a/Pkmds.Web/Services/AppService.cs +++ b/Pkmds.Web/Services/AppService.cs @@ -47,38 +47,41 @@ public void ClearSelection() public string GetPokemonSpeciesName(ushort speciesId) => GetSpeciesComboItem(speciesId).Text; - public IEnumerable SearchPokemonNames(string searchString) => AppState.SaveFile is null || searchString is not { Length: > 0 } - ? [] - : GameInfo.FilteredSources.Species - .DistinctBy(species => species.Value) - .Where(species => species.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) - .OrderBy(species => species.Text); + public IEnumerable SearchPokemonNames(string searchString) => + AppState.SaveFile is null || searchString is not { Length: > 0 } + ? [] + : GameInfo.FilteredSources.Species + .DistinctBy(species => species.Value) + .Where(species => species.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) + .OrderBy(species => species.Text); public ComboItem GetSpeciesComboItem(ushort speciesId) => GameInfo.FilteredSources.Species .DistinctBy(species => species.Value) - .FirstOrDefault(species => species.Value == speciesId) ?? default!; + .FirstOrDefault(species => species.Value == speciesId) ?? null!; - public IEnumerable SearchItemNames(string searchString) => AppState.SaveFile is null || searchString is not { Length: > 0 } - ? [] - : GameInfo.FilteredSources.Items - .DistinctBy(item => item.Value) - .Where(item => item.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) - .OrderBy(item => item.Text); + public IEnumerable SearchItemNames(string searchString) => + AppState.SaveFile is null || searchString is not { Length: > 0 } + ? [] + : GameInfo.FilteredSources.Items + .DistinctBy(item => item.Value) + .Where(item => item.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) + .OrderBy(item => item.Text); public ComboItem GetItemComboItem(int itemId) => GameInfo.FilteredSources.Items .DistinctBy(item => item.Value) - .FirstOrDefault(item => item.Value == itemId) ?? default!; + .FirstOrDefault(item => item.Value == itemId) ?? null!; public ComboItem GetAbilityComboItem(int abilityId) => GameInfo.FilteredSources.Abilities .DistinctBy(ability => ability.Value) - .FirstOrDefault(ability => ability.Value == abilityId) ?? default!; + .FirstOrDefault(ability => ability.Value == abilityId) ?? null!; - public IEnumerable SearchAbilityNames(string searchString) => AppState.SaveFile is null || searchString is not { Length: > 0 } - ? [] - : GameInfo.FilteredSources.Abilities - .DistinctBy(ability => ability.Value) - .Where(ability => ability.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) - .OrderBy(ability => ability.Text); + public IEnumerable SearchAbilityNames(string searchString) => + AppState.SaveFile is null || searchString is not { Length: > 0 } + ? [] + : GameInfo.FilteredSources.Abilities + .DistinctBy(ability => ability.Value) + .Where(ability => ability.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) + .OrderBy(ability => ability.Text); public string GetStatModifierString(Nature nature) { @@ -100,29 +103,33 @@ public void LoadPokemonStats(PKM? pokemon) pokemon.SetStats(stats); } - public IEnumerable SearchMetLocations(string searchString, GameVersion gameVersion, EntityContext entityContext, bool isEggLocation = false) => AppState.SaveFile is null || searchString is not { Length: > 0 } - ? [] - : GameInfo.GetLocationList(gameVersion, entityContext, isEggLocation) - .DistinctBy(l => l.Value) - .Where(metLocation => metLocation.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) - .OrderBy(metLocation => metLocation.Text); - - public ComboItem GetMetLocationComboItem(ushort metLocationId, GameVersion gameVersion, EntityContext entityContext, bool isEggLocation = false) => AppState.SaveFile is null - ? default! + public IEnumerable SearchMetLocations(string searchString, GameVersion gameVersion, + EntityContext entityContext, bool isEggLocation = false) => + AppState.SaveFile is null || searchString is not { Length: > 0 } + ? [] + : GameInfo.GetLocationList(gameVersion, entityContext, isEggLocation) + .DistinctBy(l => l.Value) + .Where(metLocation => metLocation.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) + .OrderBy(metLocation => metLocation.Text); + + public ComboItem GetMetLocationComboItem(ushort metLocationId, GameVersion gameVersion, EntityContext entityContext, + bool isEggLocation = false) => AppState.SaveFile is null + ? null! : GameInfo.GetLocationList(gameVersion, entityContext, isEggLocation) .DistinctBy(l => l.Value) - .FirstOrDefault(metLocation => metLocation.Value == metLocationId) ?? default!; + .FirstOrDefault(metLocation => metLocation.Value == metLocationId) ?? null!; - public IEnumerable SearchMoves(string searchString) => AppState.SaveFile is null || searchString is not { Length: > 0 } - ? [] - : GameInfo.FilteredSources.Moves - .DistinctBy(move => move.Value) - .Where(move => move.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) - .OrderBy(move => move.Text); + public IEnumerable SearchMoves(string searchString) => + AppState.SaveFile is null || searchString is not { Length: > 0 } + ? [] + : GameInfo.FilteredSources.Moves + .DistinctBy(move => move.Value) + .Where(move => move.Text.Contains(searchString, StringComparison.OrdinalIgnoreCase)) + .OrderBy(move => move.Text); public ComboItem GetMoveComboItem(int moveId) => GameInfo.FilteredSources.Moves .DistinctBy(move => move.Value) - .FirstOrDefault(metLocation => metLocation.Value == moveId) ?? default!; + .FirstOrDefault(metLocation => metLocation.Value == moveId) ?? null!; public void SavePokemon(PKM? pokemon) { @@ -146,10 +153,12 @@ public void SavePokemon(PKM? pokemon) } else if (AppState.SelectedBoxNumber is not null && AppState.SelectedBoxSlotNumber is not null) { - AppState.SaveFile.SetBoxSlotAtIndex(pokemon, AppState.SelectedBoxNumber.Value, AppState.SelectedBoxSlotNumber.Value); + AppState.SaveFile.SetBoxSlotAtIndex(pokemon, AppState.SelectedBoxNumber.Value, + AppState.SelectedBoxSlotNumber.Value); RefreshService.RefreshBoxState(); } - else if (AppState.SelectedBoxNumber is null && AppState.SelectedBoxSlotNumber is not null && AppState.SaveFile is SAV7b) + else if (AppState.SelectedBoxNumber is null && AppState.SelectedBoxSlotNumber is not null && + AppState.SaveFile is SAV7b) { AppState.SaveFile.SetBoxSlotAtIndex(pokemon, AppState.SelectedBoxSlotNumber.Value); RefreshService.RefreshBoxAndPartyState(); diff --git a/Pkmds.Web/Services/BlazorAesProvider.cs b/Pkmds.Web/Services/BlazorAesProvider.cs index dbcfb543..13953f93 100644 --- a/Pkmds.Web/Services/BlazorAesProvider.cs +++ b/Pkmds.Web/Services/BlazorAesProvider.cs @@ -8,7 +8,7 @@ public IAesCryptographyProvider.IAes Create(byte[] key, CipherMode mode, Padding #pragma warning disable CS9113 // Parameter is unread. private class CryptoJsAes(JsService jsService, byte[] key, CipherMode mode, PaddingMode padding, byte[]? iv = null) #pragma warning restore CS9113 // Parameter is unread. - : IAesCryptographyProvider.IAes, IDisposable + : IAesCryptographyProvider.IAes { public void EncryptEcb(ReadOnlySpan plaintext, Span destination) => jsService.EncryptAes(plaintext, destination, key, CipherMode.ECB); @@ -25,4 +25,3 @@ public void DecryptCbc(ReadOnlySpan ciphertext, Span destination) => public void Dispose() { } } } - diff --git a/Pkmds.Web/Services/IAppService.cs b/Pkmds.Web/Services/IAppService.cs index 126c739a..941d47a4 100644 --- a/Pkmds.Web/Services/IAppService.cs +++ b/Pkmds.Web/Services/IAppService.cs @@ -2,8 +2,6 @@ public interface IAppService { - string[] NatureStatShortNames { get; } - PKM? EditFormPokemon { get; set; } bool IsDrawerOpen { get; set; } @@ -34,9 +32,11 @@ public interface IAppService IEnumerable SearchAbilityNames(string searchString); - IEnumerable SearchMetLocations(string searchString, GameVersion gameVersion, EntityContext entityContext, bool isEggLocation = false); + IEnumerable SearchMetLocations(string searchString, GameVersion gameVersion, EntityContext entityContext, + bool isEggLocation = false); - ComboItem GetMetLocationComboItem(ushort metLocationId, GameVersion gameVersion, EntityContext entityContext, bool isEggLocation = false); + ComboItem GetMetLocationComboItem(ushort metLocationId, GameVersion gameVersion, EntityContext entityContext, + bool isEggLocation = false); IEnumerable SearchMoves(string searchString); diff --git a/Pkmds.Web/Services/IRefreshService.cs b/Pkmds.Web/Services/IRefreshService.cs index 43dbd164..e27f9c79 100644 --- a/Pkmds.Web/Services/IRefreshService.cs +++ b/Pkmds.Web/Services/IRefreshService.cs @@ -18,5 +18,6 @@ public interface IRefreshService void RefreshBoxAndPartyState(); + // ReSharper disable once UnusedMember.Global void ShowUpdateMessage(); } diff --git a/Pkmds.Web/Services/JsService.cs b/Pkmds.Web/Services/JsService.cs index a40942be..81e2ddf0 100644 --- a/Pkmds.Web/Services/JsService.cs +++ b/Pkmds.Web/Services/JsService.cs @@ -3,8 +3,8 @@ public class JsService(IJSRuntime js) { private IJSInProcessRuntime SyncJs => js as IJSInProcessRuntime ?? - throw new NotSupportedException( - "Requested an in process javascript interop, but none was found"); + throw new NotSupportedException( + "Requested an in process javascript interop, but none was found"); public void EncryptAes(ReadOnlySpan origin, Span destination, ReadOnlySpan key, CipherMode mode) { diff --git a/Pkmds.Web/Services/RefreshService.cs b/Pkmds.Web/Services/RefreshService.cs index a7e22800..abd49850 100644 --- a/Pkmds.Web/Services/RefreshService.cs +++ b/Pkmds.Web/Services/RefreshService.cs @@ -2,7 +2,7 @@ public class RefreshService : IRefreshService { - public static RefreshService? Instance { get; private set; } + private static RefreshService? Instance { get; set; } public event Action? OnAppStateChanged; public event Action? OnBoxStateChanged; diff --git a/Pkmds.Web/SpriteHelper.cs b/Pkmds.Web/SpriteHelper.cs index 5184bdb0..9e9f97d9 100644 --- a/Pkmds.Web/SpriteHelper.cs +++ b/Pkmds.Web/SpriteHelper.cs @@ -10,39 +10,44 @@ public static class SpriteHelper public const string PokemonFallbackImageFileName = $"{SpritesRoot}a/a_unknown.png"; public static string GetMysteryGiftSpriteFileName(MysteryGift gift) => gift.IsItem - ? GetItemSpriteFilename(gift.ItemID, gift.Context) - : GetPokemonSpriteFilename(gift.Species, gift.Context, gift.IsEgg, gift.Form, 0, gift.Gender); + ? GetItemSpriteFilename(gift.ItemID, gift.Context) + : GetPokemonSpriteFilename(gift.Species, gift.Context, gift.IsEgg, gift.Form, 0, gift.Gender); public static string GetPokemonSpriteFilename(PKM? pokemon) => pokemon is null - ? PokemonFallbackImageFileName - : GetPokemonSpriteFilename(pokemon.Species, pokemon.Context, pokemon.IsEgg, pokemon.Form, pokemon.GetFormArgument(0), pokemon.Gender); + ? PokemonFallbackImageFileName + : GetPokemonSpriteFilename(pokemon.Species, pokemon.Context, pokemon.IsEgg, pokemon.Form, + pokemon.GetFormArgument(0), pokemon.Gender); - public static string GetPokemonSpriteFilename(ushort species, EntityContext context, bool isEgg, byte form, uint? formArg1, byte gender) => + private static string GetPokemonSpriteFilename(ushort species, EntityContext context, bool isEgg, byte form, + uint? formArg1, byte gender) => new StringBuilder($"{SpritesRoot}a/a_") - .Append((species, context, isEgg, form, formArg1, gender) switch - { - { context: EntityContext.Gen7b } and ({ species: (ushort)Species.Pikachu, form: PikachuStarterForm } - or { species: (ushort)Species.Eevee, form: EeveeStarterForm }) => $"{species}-{form}p", - { species: (ushort)Species.Manaphy, isEgg: true } => "490-e", - { isEgg: true } => "egg", - { species: (ushort)Species.Frillish or (ushort)Species.Jellicent, gender: (byte)Gender.Female } => $"{species}f", - { species: (ushort)Species.Alcremie } => $"{species}-{form}-{formArg1}", - _ when form > 0 && FormInfo.HasTotemForm(species) && FormInfo.IsTotemForm(species, form) => $"{species}-{FormInfo.GetTotemBaseForm(species, form)}", - { form: > 0 } => species switch + .Append((species, context, isEgg, form, formArg1, gender) switch { - (ushort)Species.Rockruff => species.ToString(), - (ushort)Species.Sinistea or (ushort)Species.Polteageist => species.ToString(), - (ushort)Species.Scatterbug or (ushort)Species.Spewpa => species.ToString(), - (ushort)Species.Urshifu => species.ToString(), - (ushort)Species.Dudunsparce => species.ToString(), - _ => $"{species}-{form}", - }, - { species: > (ushort)Species.None and < (ushort)Species.MAX_COUNT } => - species.ToString(), - _ => "unknown", - }) - .Append(".png") - .ToString(); + { context: EntityContext.Gen7b } and ({ species: (ushort)Species.Pikachu, form: PikachuStarterForm } + or { species: (ushort)Species.Eevee, form: EeveeStarterForm }) => $"{species}-{form}p", + { species: (ushort)Species.Manaphy, isEgg: true } => "490-e", + { isEgg: true } => "egg", + { + species: (ushort)Species.Frillish or (ushort)Species.Jellicent, gender: (byte)Gender.Female + } => $"{species}f", + { species: (ushort)Species.Alcremie } => $"{species}-{form}-{formArg1}", + (_, _, _, > 0, _, _) when FormInfo.HasTotemForm(species) && FormInfo.IsTotemForm(species, form) => + $"{species}-{FormInfo.GetTotemBaseForm(species, form)}", + { form: > 0 } => species switch + { + (ushort)Species.Rockruff => species.ToString(), + (ushort)Species.Sinistea or (ushort)Species.Polteageist => species.ToString(), + (ushort)Species.Scatterbug or (ushort)Species.Spewpa => species.ToString(), + (ushort)Species.Urshifu => species.ToString(), + (ushort)Species.Dudunsparce => species.ToString(), + _ => $"{species}-{form}", + }, + { species: > (ushort)Species.None and < (ushort)Species.MAX_COUNT } => + species.ToString(), + _ => "unknown", + }) + .Append(".png") + .ToString(); public static string GetBallSpriteFilename(int ball) => $"{SpritesRoot}b/_ball{ball}.png"; @@ -96,6 +101,7 @@ public static string GetBagPouchSpriteFileName(InventoryType type) => }; // TODO: Implement + // ReSharper disable once UnusedParameter.Global public static string GetMoveCategorySpriteFileName(int categoryId) => string.Empty; From 62539a838da936e528622c0f1dccddcb2322e7a4 Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Tue, 17 Dec 2024 18:19:44 -0500 Subject: [PATCH 7/9] Final bit of tweaks --- .../Components/Layout/MainLayout.razor.css | 12 +++--- .../Components/MarkingsContainer.razor.css | 2 +- Pkmds.Web/wwwroot/css/app.css | 39 +++++++++---------- Pkmds.Web/wwwroot/js/fileSave.js | 4 +- Pkmds.Web/wwwroot/service-worker.published.js | 6 +-- 5 files changed, 30 insertions(+), 33 deletions(-) diff --git a/Pkmds.Web/Components/Layout/MainLayout.razor.css b/Pkmds.Web/Components/Layout/MainLayout.razor.css index df8c10ff..0d26cfc2 100644 --- a/Pkmds.Web/Components/Layout/MainLayout.razor.css +++ b/Pkmds.Web/Components/Layout/MainLayout.razor.css @@ -10,9 +10,9 @@ z-index: 1000; } - #blazor-error-ui .dismiss { - cursor: pointer; - position: absolute; - right: 0.75rem; - top: 0.5rem; - } +#blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; +} diff --git a/Pkmds.Web/Components/MarkingsContainer.razor.css b/Pkmds.Web/Components/MarkingsContainer.razor.css index 296950fa..472e192f 100644 --- a/Pkmds.Web/Components/MarkingsContainer.razor.css +++ b/Pkmds.Web/Components/MarkingsContainer.razor.css @@ -10,5 +10,5 @@ .gen-3 { grid-template-columns: repeat(4, 1fr); - grid-gap: 0px; + grid-gap: 0; } diff --git a/Pkmds.Web/wwwroot/css/app.css b/Pkmds.Web/wwwroot/css/app.css index 4f785507..fc20f362 100644 --- a/Pkmds.Web/wwwroot/css/app.css +++ b/Pkmds.Web/wwwroot/css/app.css @@ -1,8 +1,5 @@ body, html { - padding-bottom: env(safe-area-inset-bottom, 16px); - padding-top: env(safe-area-inset-top); - padding-left: env(safe-area-inset-left, 8px); - padding-right: env(safe-area-inset-right); + padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 8px); box-sizing: border-box; } @@ -12,12 +9,12 @@ body, html { box-sizing: border-box; } -pkm-sprite { +.pkm-sprite { object-fit: contain; align-self: center; } -item-sprite { +.item-sprite { object-fit: contain; align-self: center; } @@ -74,19 +71,19 @@ item-sprite { margin: 20vh auto 1rem auto; } - .loading-progress circle { - fill: none; - stroke: #e0e0e0; - stroke-width: 0.6rem; - transform-origin: 50% 50%; - transform: rotate(-90deg); - } +.loading-progress circle { + fill: none; + stroke: #e0e0e0; + stroke-width: 0.6rem; + transform-origin: 50% 50%; + transform: rotate(-90deg); +} - .loading-progress circle:last-child { - stroke: #1b6ec2; - stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; - transition: stroke-dasharray 0.05s ease-in-out; - } +.loading-progress circle:last-child { + stroke: #1b6ec2; + stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; + transition: stroke-dasharray 0.05s ease-in-out; +} .loading-progress-text { position: absolute; @@ -95,6 +92,6 @@ item-sprite { inset: calc(20vh + 3.25rem) 0 auto 0.2rem; } - .loading-progress-text:after { - content: var(--blazor-load-percentage-text, "Loading"); - } +.loading-progress-text:after { + content: var(--blazor-load-percentage-text, "Loading"); +} diff --git a/Pkmds.Web/wwwroot/js/fileSave.js b/Pkmds.Web/wwwroot/js/fileSave.js index d106bef8..2f852ede 100644 --- a/Pkmds.Web/wwwroot/js/fileSave.js +++ b/Pkmds.Web/wwwroot/js/fileSave.js @@ -4,13 +4,13 @@ suggestedName: fileName, types: [{ description: description, - accept: { 'application/octet-stream': [extension] } + accept: {'application/octet-stream': [extension]} }] }; const handle = await window.showSaveFilePicker(opts); const writable = await handle.createWritable(); - await writable.write(new Blob([new Uint8Array(byteArray)], { type: "application/octet-stream" })); + await writable.write(new Blob([new Uint8Array(byteArray)], {type: "application/octet-stream"})); await writable.close(); } catch (ex) { console.error(ex); diff --git a/Pkmds.Web/wwwroot/service-worker.published.js b/Pkmds.Web/wwwroot/service-worker.published.js index db328429..a8c294a4 100644 --- a/Pkmds.Web/wwwroot/service-worker.published.js +++ b/Pkmds.Web/wwwroot/service-worker.published.js @@ -17,8 +17,8 @@ const cacheNamePrefix = 'offline-cache-'; const CACHE_VERSION = '%%CACHE_VERSION%%' const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}${CACHE_VERSION}`; -const offlineAssetsInclude = [ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ]; -const offlineAssetsExclude = [ /^service-worker\.js$/ ]; +const offlineAssetsInclude = [/\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/]; +const offlineAssetsExclude = [/^service-worker\.js$/]; // Replace with your base path if you are hosting on a subfolder. Ensure there is a trailing '/'. const base = "/"; @@ -32,7 +32,7 @@ async function onInstall(event) { const assetsRequests = self.assetsManifest.assets .filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url))) .filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url))) - .map(asset => new Request(asset.url, { integrity: asset.hash, cache: 'no-cache' })); + .map(asset => new Request(asset.url, {integrity: asset.hash, cache: 'no-cache'})); await caches.open(cacheName).then(cache => cache.addAll(assetsRequests)); } From e8ba5ec57469e3624ef2c08b9e5775625c6084dd Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Tue, 17 Dec 2024 18:57:19 -0500 Subject: [PATCH 8/9] Add EXP to next level --- .../Components/EditForms/Tabs/MainTab.razor | 23 +++++++++++++++---- .../EditForms/Tabs/MainTab.razor.cs | 13 +++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor index f3e65c8a..4ea9d983 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor @@ -92,17 +92,30 @@ } + + - + + + @{ + var levelProgress = Experience.GetEXPToLevelUpPercentage(Pokemon.CurrentLevel, Pokemon.EXP, Pokemon.PersonalInfo.EXPGrowth); + + } @if (saveGeneration >= 3) { diff --git a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor.cs b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor.cs index 640572ba..27b53680 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor.cs +++ b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor.cs @@ -124,4 +124,17 @@ private void SetPokemonPid(string newPidHex) } private readonly PatternMask hexMask = new("########") { MaskChars = [new('#', "[0-9a-fA-F]")] }; + + // ReSharper disable once InconsistentNaming + private double GetEXPToLevelUp() + { + if (Pokemon is not { CurrentLevel: var level and < 100, EXP: var exp, PersonalInfo.EXPGrowth: var growth }) + { + return 0; + } + + var table = Experience.GetTable(growth); + var next = Experience.GetEXP(++level, table); + return next - exp; + } } From c225b9158fc9b8cdd2863ffeb50341ee194386f3 Mon Sep 17 00:00:00 2001 From: Michael Bond Date: Tue, 17 Dec 2024 19:05:33 -0500 Subject: [PATCH 9/9] Slight tweaks to EXP to next level --- .../Components/EditForms/Tabs/MainTab.razor | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor index 4ea9d983..346e99dc 100644 --- a/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor +++ b/Pkmds.Web/Components/EditForms/Tabs/MainTab.razor @@ -105,17 +105,19 @@ For="@(() => Pokemon.EXP)"/> - - @{ - var levelProgress = Experience.GetEXPToLevelUpPercentage(Pokemon.CurrentLevel, Pokemon.EXP, Pokemon.PersonalInfo.EXPGrowth); - - } + Variant="@Variant.Outlined" + Value="@GetEXPToLevelUp()" + ReadOnly + HideSpinButtons/> + + var levelProgress = Experience.GetEXPToLevelUpPercentage(Pokemon.CurrentLevel, Pokemon.EXP, Pokemon.PersonalInfo.EXPGrowth); + @if (saveGeneration >= 3) {