diff --git a/app/Http/Controllers/Ranking/MatchmakingController.php b/app/Http/Controllers/Ranking/MatchmakingController.php index a32973dce93..1036237db30 100644 --- a/app/Http/Controllers/Ranking/MatchmakingController.php +++ b/app/Http/Controllers/Ranking/MatchmakingController.php @@ -18,17 +18,26 @@ class MatchmakingController extends Controller 'rating' => [['rating', 'DESC'], ['total_points', 'DESC']], ]; - public function show(?string $rulesetName = null, ?string $poolId = null) + public function show(?string $poolType = null, ?string $rulesetName = null, ?string $poolId = null) { + $poolType ??= MatchmakingPool::TYPES[0]; + $rulesetName ??= default_mode(); $rulesetId = Beatmap::MODES[$rulesetName] ?? abort(422, 'invalid ruleset parameter'); - $poolsQuery = MatchmakingPool::where(['ruleset_id' => $rulesetId])->orderByDesc('active')->orderByDesc('id'); + $poolsQuery = MatchmakingPool::where([ + 'type' => $poolType, + 'ruleset_id' => $rulesetId, + ])->orderByDesc('active')->orderByDesc('id'); if ($poolId === null) { $pool = $poolsQuery->firstOrFail(); - return ujs_redirect(route('rankings.matchmaking', ['mode' => $rulesetName, 'pool' => $pool->getKey()])); + return ujs_redirect(route('rankings.matchmaking', [ + 'poolType' => $poolType, + 'mode' => $rulesetName, + 'pool' => $pool->getKey(), + ])); } $pools = $poolsQuery->get(); @@ -37,7 +46,7 @@ public function show(?string $rulesetName = null, ?string $poolId = null) $query = $pool->allUserStats()->with('user.team')->default(); $sort = get_string(request('sort')); - if (!array_key_exists($sort, static::SORTS)) { + if (!array_key_exists($sort, static::SORTS) || !$pool->hasPoints()) { $sort = 'rating'; } foreach (static::SORTS[$sort] as $dbSort) { diff --git a/app/Http/Controllers/RankingController.php b/app/Http/Controllers/RankingController.php index 6d7ed518356..f17261c1849 100644 --- a/app/Http/Controllers/RankingController.php +++ b/app/Http/Controllers/RankingController.php @@ -8,6 +8,7 @@ use App\Models\Beatmap; use App\Models\Country; use App\Models\CountryStatistics; +use App\Models\MatchmakingPool; use App\Models\Model; use App\Models\Spotlight; use App\Models\TeamStatistics; @@ -64,7 +65,10 @@ public static function url( 'type' => $params['type'], ]), 'kudosu' => route('rankings.kudosu'), - 'matchmaking' => route('rankings.matchmaking', ['mode' => $params['mode'] ?? default_mode()]), + 'matchmaking' => route('rankings.matchmaking', [ + 'poolType' => $params['poolType'] ?? MatchmakingPool::TYPES[0], + 'mode' => $params['mode'] ?? default_mode(), + ]), 'playlists' => match ($params['list'] ?? 'seasons') { 'charts' => route('rankings', [ 'mode' => $params['mode'] ?? default_mode(), diff --git a/app/Models/MatchmakingPool.php b/app/Models/MatchmakingPool.php index 51eba55723e..4acff44203d 100644 --- a/app/Models/MatchmakingPool.php +++ b/app/Models/MatchmakingPool.php @@ -24,6 +24,8 @@ */ class MatchmakingPool extends Model { + const array TYPES = ['ranked_play', 'quick_play']; + protected $casts = [ 'active' => 'bool', ]; @@ -44,4 +46,9 @@ public function getDisplayName(): string return $prefix.$name; } + + public function hasPoints(): bool + { + return $this->type === 'quick_play'; + } } diff --git a/resources/css/bem/ranking-page-grid.less b/resources/css/bem/ranking-page-grid.less index bbcc9e8e997..766233b4e7c 100644 --- a/resources/css/bem/ranking-page-grid.less +++ b/resources/css/bem/ranking-page-grid.less @@ -11,4 +11,14 @@ --item-padding: 6px 20px; grid-template-columns: auto 10fr 1fr 1fr 1fr 1fr; } + + &--quick_play { + --item-padding: 6px 20px; + grid-template-columns: auto 10fr 1fr 1fr 1fr 1fr; + } + + &--ranked_play { + --item-padding: 6px 20px; + grid-template-columns: auto 10fr 1fr 1fr 1fr; + } } diff --git a/resources/js/components/basic-select-options.tsx b/resources/js/components/basic-select-options.tsx index 3b0e61188b4..a3357716204 100644 --- a/resources/js/components/basic-select-options.tsx +++ b/resources/js/components/basic-select-options.tsx @@ -19,6 +19,7 @@ interface PropsBase { type Props = PropsBase & ({ type: 'daily_challenge' | 'download' | 'multiplayer' | 'seasons' | 'spotlight'; } | { + poolType: 'ranked_play' | 'quick_play'; ruleset: Ruleset; type: 'matchmaking'; }); @@ -52,7 +53,7 @@ export default class BasicSelectOptions extends React.PureComponent { case 'download': return route('download', { platform: id }); case 'matchmaking': - return route('rankings.matchmaking', { mode: this.props.ruleset, pool: id }); + return route('rankings.matchmaking', { mode: this.props.ruleset, pool: id, poolType: this.props.poolType }); case 'multiplayer': return route('multiplayer.rooms.show', { room: id ?? 'latest' }); case 'seasons': diff --git a/resources/lang/en/rankings.php b/resources/lang/en/rankings.php index e0520194e83..4af8a62bc4f 100644 --- a/resources/lang/en/rankings.php +++ b/resources/lang/en/rankings.php @@ -34,6 +34,10 @@ ], 'matchmaking' => [ + 'pool_types' => [ + 'quick_play' => 'quick play', + 'ranked_play' => 'ranked play', + ], 'plays' => 'Plays', 'points' => 'Points', 'provisional' => 'Not enough matches played to accurately determine rating', @@ -66,7 +70,7 @@ 'daily_challenge' => 'daily challenge', 'global' => 'global', 'kudosu' => 'kudosu', - 'matchmaking' => 'quick play', + 'matchmaking' => 'matchmaking', 'playlists' => 'playlists', 'team' => 'team', 'top_plays' => 'top plays', diff --git a/resources/views/rankings/_pool_type_selector.blade.php b/resources/views/rankings/_pool_type_selector.blade.php new file mode 100644 index 00000000000..11146a6f2ca --- /dev/null +++ b/resources/views/rankings/_pool_type_selector.blade.php @@ -0,0 +1,20 @@ +{{-- + Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. + See the LICENCE file in the repository root for full licence text. +--}} +@php + use App\Models\MatchmakingPool; +@endphp +
+ @foreach(MatchmakingPool::TYPES as $tab) + + {{ osu_trans("rankings.matchmaking.pool_types.{$tab}") }} + + @endforeach +
diff --git a/resources/views/rankings/matchmaking.blade.php b/resources/views/rankings/matchmaking.blade.php index 1866a11b5af..87816ccca4b 100644 --- a/resources/views/rankings/matchmaking.blade.php +++ b/resources/views/rankings/matchmaking.blade.php @@ -5,50 +5,57 @@ @php use App\Http\Controllers\Ranking\MatchmakingController; - $params = ['mode' => $rulesetName]; + $params = ['poolType' => $pool->type, 'mode' => $rulesetName]; @endphp @extends('rankings.index', [ 'hasPager' => $scores !== null, 'params' => [...$params, 'type' => 'matchmaking'], 'rulesetSelectorUrlFn' => fn (string $r): string => route('rankings.matchmaking', [...$params, 'mode' => $r, 'sort' => $sort]), - 'titlePrepend' => osu_trans('rankings.type.matchmaking').': '.$pool->getDisplayName(), + 'titlePrepend' => osu_trans("rankings.matchmaking.pool_types.{$pool->type}").': '.$pool->getDisplayName(), ]) -@if (count($pools) > 1) - @section('ranking-header') -
+@section('ranking-header') +
+ @include('rankings._pool_type_selector', compact('params')) +
+ + @if (count($pools) > 1) +
@include('objects._basic_select_options', ['selectOptions' => [ ...json_options($pool, $pools, fn ($pool) => [ 'id' => $pool->getKey(), 'text' => $pool->getDisplayName(), ]), + 'poolType' => $pool->type, 'ruleset' => $rulesetName, 'type' => 'matchmaking', ]])
- @endsection -@endif + @endif +@endsection @section('scores-header') -
-
-
- {{ osu_trans('sort._') }} + @if ($pool->hasPoints()) +
+
+
+ {{ osu_trans('sort._') }} +
+ @foreach (MatchmakingController::SORTS as $newSort => $_dbColumns) + + {{ osu_trans("rankings.matchmaking.{$newSort}") }} + + @endforeach
- @foreach (MatchmakingController::SORTS as $newSort => $_dbColumns) - - {{ osu_trans("rankings.matchmaking.{$newSort}") }} - - @endforeach
-
+ @endif @endsection @section('scores') -
+
@@ -61,9 +68,11 @@ class="{{ class_with_modifiers('sort__item', 'button', ['active' => $newSort ===
{{ osu_trans('rankings.matchmaking.plays') }}
-
- {{ osu_trans('rankings.matchmaking.points') }} -
+ @if ($pool->hasPoints()) +
+ {{ osu_trans('rankings.matchmaking.points') }} +
+ @endif
{{ osu_trans('rankings.matchmaking.rating') }}
@@ -87,12 +96,14 @@ class="{{ class_with_modifiers('sort__item', 'button', ['active' => $newSort ===
{{ i18n_number_format($score->elo_data['contest_count']) }}
-
- {{ i18n_number_format($score->total_points) }} -
+ @if ($pool->hasPoints()) +
+ {{ i18n_number_format($score->total_points) }} +
+ @endif