Skip to content

Commit

Permalink
Add trainer card Pokémon to FRLG
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonkey85 committed Nov 25, 2024
1 parent 7c17691 commit 4c14c9a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
25 changes: 21 additions & 4 deletions Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@
</div>
}

@if (saveFile is SAV3FRLG sav3Rival)
@if (saveFile is SAV3FRLG sav3FrLgRival)
{
<div class="form-field">
<MudTextField Label="Rival Name"
Variant="@Variant.Outlined"
MaxLength="@sav3Rival.MaxStringLengthTrainer"
@bind-Value="@sav3Rival.RivalName"
For="@(() => sav3Rival.RivalName)" />
MaxLength="@sav3FrLgRival.MaxStringLengthTrainer"
@bind-Value="@sav3FrLgRival.RivalName"
For="@(() => sav3FrLgRival.RivalName)" />
</div>
}

Expand Down Expand Up @@ -196,6 +196,23 @@
For="@(() => saveFile.PlayedSeconds)" />
</div>

@if (saveFile is SAV3FRLG sav3FrLgTrainerCard)
{
@for (int i = 0; i < 6; i++)
{
var localIndex = i;
<div class="form-field">
<MudAutocomplete T="@ComboItem"
Label="@($"Trainer Card {localIndex + 1}")"
Variant="@Variant.Outlined"
@bind-Value:get="@GetTrainerCardPokemon(sav3FrLgTrainerCard, localIndex)"
@bind-Value:set="@((ComboItem species) => { SetTrainerCardPokemon(sav3FrLgTrainerCard, localIndex, species); })"
SearchFunc="@SearchPokemonNames"
ToStringFunc="@(species => species?.Text)" />
</div>
}
}

@if (saveFile is SAV1 sav1Options)
{
<div class="form-field">
Expand Down
14 changes: 14 additions & 0 deletions Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,18 @@ private void SetCoins(uint value)

private Task<IEnumerable<ComboItem>> SearchPokemonNames(string searchString, CancellationToken token) =>
Task.FromResult(AppService.SearchPokemonNames(searchString));

private ComboItem GetTrainerCardPokemon(SAV3FRLG sav, int index)
{
var g3Species = sav.GetWork(0x43 + index);
var species = SpeciesConverter.GetNational3(g3Species);
return AppService.GetSpeciesComboItem(species);
}

private static void SetTrainerCardPokemon(SAV3FRLG sav, int index, ComboItem speciesComboItem)
{
var species = (ushort)speciesComboItem.Value;
var g3Species = SpeciesConverter.GetInternal3(species);
sav.SetWork(0x43 + index, g3Species);
}
}

0 comments on commit 4c14c9a

Please sign in to comment.