Skip to content

Commit

Permalink
Fix page title rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonkey85 committed Oct 30, 2024
1 parent 6cbb264 commit 2aa2f98
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Pkmds.Web/Components/SaveFileComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
else
{
<PageTitle>
PKMDS Save Editor - <SaveFileNameDisplay />
@SaveFileNameDisplayString()
</PageTitle>

<MudText Typo="@Typo.h5">
Expand Down
28 changes: 28 additions & 0 deletions Pkmds.Web/Components/SaveFileComponent.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,32 @@ public partial class SaveFileComponent : IDisposable
protected override void OnInitialized() => RefreshService.OnAppStateChanged += StateHasChanged;

public void Dispose() => RefreshService.OnAppStateChanged -= StateHasChanged;

private string SaveFileNameDisplayString()
{
const string baseTitle = "PKMDS Save Editor";

if (AppState.SaveFile is not { } saveFile)
{
return baseTitle;
}

var sbTitle = new StringBuilder(baseTitle).Append(" - ");

sbTitle.Append($"{saveFile.OT} ");

if (saveFile.Context is not EntityContext.Gen1)
{
var genderDisplay = saveFile.Gender == (byte)Gender.Male ? Constants.MaleGenderUnicode : Constants.FemaleGenderUnicode;
sbTitle.Append($"{genderDisplay} ");
}

sbTitle.Append($"({saveFile.DisplayTID.ToString(AppService.GetIdFormatString())}, ");

sbTitle.Append($"{SaveFileNameDisplay.FriendlyGameName(saveFile.Version)}, ");

sbTitle.Append($"{saveFile.PlayTimeString})");

return sbTitle.ToString();
}
}
5 changes: 2 additions & 3 deletions Pkmds.Web/Components/SaveFileNameDisplay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

@if (AppState.SaveFile is { Gender: 0 or 1 } saveFile)
{
var gender = saveFile.Gender;
@Display(saveFile, gender)
@Display(saveFile, saveFile.Gender)
}

@code {
Expand All @@ -13,7 +12,7 @@
<span>@saveFile.OT </span>
<GenderDisplayComponent Gender="@((Gender)gender)" />
<span>(@saveFile.DisplayTID.ToString(AppService.GetIdFormatString())</span>
<span>, @FriendlyGameName(saveFile.Version.GetSingleVersion())</span>
<span>, @FriendlyGameName(saveFile.Version)</span>
<span>, @saveFile.PlayTimeString)</span>
</MudStack>;

Expand Down
4 changes: 4 additions & 0 deletions Pkmds.Web/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ public static class Constants
public const string SelectedSlotStyle = "border: 4px solid orange; border-radius: 6px;";

public const long MaxFileSize = 67_108_864L; // 64 bytes in binary

public const string MaleGenderUnicode = "♂";

public const string FemaleGenderUnicode = "♀";
}

0 comments on commit 2aa2f98

Please sign in to comment.