Skip to content

Commit

Permalink
Merge pull request #195 from DennisvHest/development
Browse files Browse the repository at this point in the history
1.5.2
  • Loading branch information
DennisvHest committed Jul 6, 2024
2 parents 461eba5 + 4ab719e commit 5b50bba
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 32 deletions.
9 changes: 9 additions & 0 deletions MapMaven.Core/Services/Leaderboards/BeatLeaderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ public BeatLeaderService(
profile.RankHistory = history ?? Enumerable.Empty<RankHistoryRecord>();
profile.RankHistory = profile.RankHistory.Concat([
new RankHistoryRecord() {
Date = DateOnly.FromDateTime(DateTime.Today.AddDays(1)),
Rank = profile.Rank,
CountryRank = profile.CountryRank,
Pp = profile.Pp
}
]);
return profile;
});

Expand Down
14 changes: 8 additions & 6 deletions MapMaven/Components/Maps/MapBrowserRow.razor
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@
@foreach (var playerScore in context.Item.AllPlayerScores.Where(s => s.Score.HasReplay))
{
var chipStyle = $"cursor: pointer; border: 1px solid {DifficultyDisplayUtils.GetColor(playerScore.Leaderboard?.Difficulty)}";
<MudButton Class="replay-button pa-0" OnClick="() => OpenReplay(context.Item, playerScore)" Style="min-width: 0; border-radius: 100%;">
<MudChip Size="Size.Small" Variant="Variant.Text" Style="@chipStyle">
@DifficultyDisplayUtils.GetShortName(playerScore.Leaderboard?.Difficulty)
<img src="images/replay-icon.png" class="ml-1" style="width: 18px" />
</MudChip>
</MudButton>
<MudTooltip Text="Open replay">
<MudButton Class="replay-button pa-0" OnClick="() => OpenReplay(context.Item, playerScore)" Style="min-width: 0; border-radius: 100%;">
<MudChip Size="Size.Small" Variant="Variant.Text" Style="@chipStyle">
@DifficultyDisplayUtils.GetShortName(playerScore.Leaderboard?.Difficulty)
<img src="images/replay-icon.png" class="ml-1" style="width: 18px" />
</MudChip>
</MudButton>
</MudTooltip>
}
</CellTemplate>
</SortableTemplateColumn>
Expand Down
29 changes: 29 additions & 0 deletions MapMaven/Components/Maps/MapDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@
<td colspan="2" style="border-bottom: 1px solid gray;">
<MudIcon Icon="@Icons.Material.Filled.Leaderboard" Size="Size.Small"></MudIcon>
<MudText Typo="Typo.overline">Score</MudText>
@if (playerScore.Score.HasReplay)
{
<MudTooltip Text="Open replay">
<MudButton Class="replay-button pa-0 ml-2" OnClick="() => OpenReplay(playerScore)" Style="min-width: 0; border-radius: 100%;">
<MudChip Size="Size.Small" Variant="Variant.Text" Style="@($"{chipStyle}; cursor: pointer;")">
<img src="images/replay-icon.png" style="width: 18px" />
</MudChip>
</MudButton>
</MudTooltip>
}
</td>
</tr>
<tr>
Expand Down Expand Up @@ -232,6 +242,9 @@
[Inject]
private IApplicationEventService ApplicationEventService { get; set; }

[Inject]
protected IDialogService DialogService { get; set; }

[Parameter]
public Map? Map { get; set; }

Expand Down Expand Up @@ -261,4 +274,20 @@
});
}
}

void OpenReplay(PlayerScore playerScore)
{
var parameters = new DialogParameters
{
{ nameof(Replay.MapId), Map.Id },
{ nameof(Replay.PlayerScore), playerScore },
};

DialogService.Show<Replay>(null, parameters, new DialogOptions
{
MaxWidth = MaxWidth.ExtraExtraLarge,
FullWidth = true,
CloseButton = true
});
}
}
6 changes: 3 additions & 3 deletions MapMaven/Components/Maps/MapList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
var difficulty = context.Item.Difficulty;
var chipStyle = $"border: 1px solid {DifficultyDisplayUtils.GetColor(difficulty?.Difficulty)}";
}
<MudChip Size="Size.Small" Variant="Variant.Outlined" Style="@chipStyle">
@DifficultyDisplayUtils.GetShortName(difficulty?.Difficulty)
<MudChip Size="Size.Small" Variant="Variant.Outlined" Class="ma-0" Style="@chipStyle">
@DifficultyDisplayUtils.GetShortName(difficulty?.Difficulty) | @difficulty?.Stars.ToString("#0.##") <MudIcon Icon="@Icons.Material.Filled.Star" />
</MudChip>
</CellTemplate>
</TemplateColumn>
<TemplateColumn T="Map" Hidden="@HiddenColumns.Contains(MapListColumn.Pp)" CellClass="pa-1">
<CellTemplate>
<MudChip Size="Size.Small">
<MudChip Size="Size.Small" Class="ma-0">
<span>@context.Item.HighestPlayerScore?.Score.Pp.ToString("#0.##") <b>pp</b></span>
</MudChip>
</CellTemplate>
Expand Down
58 changes: 49 additions & 9 deletions MapMaven/Pages/Dashboard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<MudProgressLinear Color="MudBlazor.Color.Primary" Class="fixed" Indeterminate="true" />
}

<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="full-height" Style="padding-top: 24px; padding-bottom: 24px;">
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="full-height" Style="padding-top: 24px; padding-bottom: 24px; height: 100vh;">
@if (Player is not null)
{
<div class="d-flex align-start">
<MudCard Style="width: 250px; min-width: 250px;">
<div class="d-flex align-start full-height">
<MudCard Style="width: 250px; min-width: 250px; max-height: 100%; overflow-y: auto;">
<MudCardHeader Class="card-header-highlight justify-space-between">
<div class="d-flex flex-column align-center">
<span>
Expand Down Expand Up @@ -62,14 +62,54 @@
</MudCardHeader>
<MudCardContent>
<MudList Dense="true" DisableGutters="true" DisablePadding="true">
<MudListItem>
<div class="d-flex align-center justify-space-between">
<MudListItem InitiallyExpanded="true">
<ChildContent>
<div class="d-flex align-center gap-2">
<MudIcon Size="MudBlazor.Size.Small" Icon="@Icons.Material.Filled.PlayCircle" />
<b>Plays</b>
</div>
</ChildContent>
<NestedList>
<MudListItem Class="pl-0">
<div class="d-flex align-center justify-space-between">
<MudText Typo="Typo.caption">Ranked play count</MudText>
<MudText Typo="Typo.caption"><b>@(TotalRankedPlays?.ToString("#0.##") ?? "-")</b></MudText>
</div>
</MudListItem>
<MudListItem Class="pl-0">
<div class="d-flex align-center justify-space-between">
<MudText Typo="Typo.caption">Unranked play count</MudText>
<MudText Typo="Typo.caption"><b>@(TotalUnrankedPlays?.ToString("#0.##") ?? "-")</b></MudText>
</div>
</MudListItem>
<MudListItem Class="pl-0">
<div class="d-flex align-center justify-space-between">
<MudText Typo="Typo.caption">Total play count</MudText>
<MudText Typo="Typo.caption"><b>@((TotalUnrankedPlays + TotalRankedPlays)?.ToString("#0.##") ?? "-")</b></MudText>
</div>
</MudListItem>
</NestedList>
</MudListItem>
<MudListItem InitiallyExpanded="true">
<ChildContent>
<div class="d-flex align-center gap-2">
<b>pp</b>
<MudText Typo="Typo.caption">Top PP</MudText>
</div>
<MudText Typo="Typo.caption"><b>@(TopPp?.ToString("#0.##") ?? "-")</b></MudText>
</div>
</ChildContent>
<NestedList>
<MudListItem Class="pl-0">
<div class="d-flex align-center justify-space-between">
<MudText Typo="Typo.caption">Average pp (top 30)</MudText>
<MudText Typo="Typo.caption"><b>@(AveragePp?.ToString("#0.##") ?? "-")</b></MudText>
</div>
</MudListItem>
<MudListItem Class="pl-0">
<div class="d-flex align-center justify-space-between">
<MudText Typo="Typo.caption">Top pp</MudText>
<MudText Typo="Typo.caption"><b>@(TopPp?.ToString("#0.##") ?? "-")</b></MudText>
</div>
</MudListItem>
</NestedList>
</MudListItem>
<MudListItem InitiallyExpanded="true">
<ChildContent>
Expand Down Expand Up @@ -103,7 +143,7 @@
<NestedList>
<MudListItem Class="pl-0">
<div class="d-flex align-center justify-space-between">
<MudText Typo="Typo.caption">Average star difficulty</MudText>
<MudText Typo="Typo.caption">Average star difficulty (top 30)</MudText>
<MudText Typo="Typo.caption"><b>@(AverageStarDifficulty?.ToString("#0.##") ?? "-")</b></MudText>
</div>
</MudListItem>
Expand Down
40 changes: 27 additions & 13 deletions MapMaven/Pages/Dashboard.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ public partial class Dashboard
double? CountryRankChange { get; set; }
double? PpChange { get; set; }

double? TotalUnrankedPlays { get; set; }
double? TotalRankedPlays { get; set; }
double? TopPp { get; set; }
double? AveragePp { get; set; }
double? AverageStarDifficulty { get; set; }
double? TopStarDifficulty { get; set; }
double? AverageRankedAccuracy { get; set; }
Expand All @@ -116,8 +119,8 @@ public partial class Dashboard

bool ShowHighPpGainAnnotations { get; set; } = false;

static readonly DateTime DashboardDateRangeMax = DateTime.Today.AddDays(1);
static readonly DateTime DashboardDateRangeMin = DateTime.Today.AddDays(-50);
static readonly DateTime DashboardDateRangeMax = DateTime.Today;

static readonly DateRange PastFiftyDays = new(DashboardDateRangeMin, DashboardDateRangeMax);
static readonly DateRange PastMonth = new(DateTime.Today.AddDays(-30), DashboardDateRangeMax);
Expand Down Expand Up @@ -194,23 +197,34 @@ protected override void OnInitialized()
var rankedScores = scores.Where(s => s.Leaderboard.Stars > 0);
if (!rankedScores.Any())
return;
if (rankedScores.Any())
{
TotalRankedPlays = rankedScores.Count();
TopPp = rankedScores.Max(s => s.Score.Pp);
TopPp = rankedScores.Max(s => s.Score.Pp);
AveragePp = rankedScores
.OrderByDescending(s => s.Score.Pp)
.Take(30)
.Average(s => s.Score.Pp);
AverageStarDifficulty = rankedScores
.OrderByDescending(s => s.Score.Pp)
.Take(30)
.Average(s => s.Leaderboard.Stars);
AverageStarDifficulty = rankedScores
.OrderByDescending(s => s.Score.Pp)
.Take(30)
.Average(s => s.Leaderboard.Stars);
TopStarDifficulty = rankedScores.Max(s => s.Leaderboard.Stars);
TopStarDifficulty = rankedScores.Max(s => s.Leaderboard.Stars);
AverageRankedAccuracy = rankedScores
.OrderByDescending(s => s.Score.Pp)
.Average(s => s.Score.Accuracy);
TopRankedAccuracy = rankedScores.Max(s => s.Score.Accuracy);
}
AverageRankedAccuracy = rankedScores
.OrderByDescending(s => s.Score.Pp)
.Average(s => s.Score.Accuracy);
var unrankedScores = scores.Where(x => x.Leaderboard.Stars == 0);
TopRankedAccuracy = rankedScores.Max(s => s.Score.Accuracy);
TotalUnrankedPlays = unrankedScores.Count();
});

var mapsAndHistory = Observable.CombineLatest(MapService.RankedMaps, LeaderboardService.PlayerProfile, _dashboardDateRange, (rankedMaps, playerProfile, dateRange) => (rankedMaps, playerProfile, dateRange));
Expand Down
2 changes: 1 addition & 1 deletion MapMaven/Services/ApplicationEventNotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ApplicationEventNotificationService(IApplicationEventService applicationE
{
snackbar.Add($"{error.Message} Error: {error.Exception.Message}", Severity.Error, config =>
{
config.VisibleStateDuration = int.MaxValue;
config.VisibleStateDuration = (int)TimeSpan.FromMinutes(5).TotalMilliseconds;
});
});

Expand Down

0 comments on commit 5b50bba

Please sign in to comment.