mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: length sorting
This commit is contained in:
1 parent
fdbfd0bc10
commit
c12cc9b8c5
2 files changed
+38
No files matched your search
@@ -178,6 +178,33 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
|
||||
});
|
||||
break;
|
||||
|
||||
case 'survivability.length':
|
||||
sorted = filtered.sort((a, b) => {
|
||||
const aTankModelDefinition = awaitedModelDefinitions[a.id];
|
||||
const bTankModelDefinition = awaitedModelDefinitions[b.id];
|
||||
const aTurretModelDefinition =
|
||||
aTankModelDefinition.turrets[a.turrets.at(-1)!.id];
|
||||
const bTurretModelDefinition =
|
||||
bTankModelDefinition.turrets[b.turrets.at(-1)!.id];
|
||||
const aSize = normalizeBoundingBox(
|
||||
unionBoundingBox(
|
||||
aTankModelDefinition.boundingBox,
|
||||
aTurretModelDefinition.boundingBox,
|
||||
),
|
||||
);
|
||||
const bSize = normalizeBoundingBox(
|
||||
unionBoundingBox(
|
||||
bTankModelDefinition.boundingBox,
|
||||
bTurretModelDefinition.boundingBox,
|
||||
),
|
||||
);
|
||||
const aLength = Math.max(aSize[0], aSize[1], aSize[2]);
|
||||
const bLength = Math.max(bSize[0], bSize[1], bSize[2]);
|
||||
|
||||
return aLength - bLength;
|
||||
});
|
||||
break;
|
||||
|
||||
case 'fire.dpm':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
@@ -707,6 +734,16 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
|
||||
>
|
||||
Volume
|
||||
</DropdownMenu.CheckboxItem>
|
||||
<DropdownMenu.CheckboxItem
|
||||
checked={sort.by === 'survivability.length'}
|
||||
onClick={() => {
|
||||
mutateTankopediaPersistent((draft) => {
|
||||
draft.sort.by = 'survivability.length';
|
||||
});
|
||||
}}
|
||||
>
|
||||
Length
|
||||
</DropdownMenu.CheckboxItem>
|
||||
</DropdownMenu.SubContent>
|
||||
</DropdownMenu.Sub>
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ export const SORT_NAMES = {
|
||||
'survivability.camouflageMoving': 'camouflage moving',
|
||||
'survivability.camouflageShooting': 'camouflage shooting',
|
||||
'survivability.volume': 'volume',
|
||||
'survivability.length': 'length',
|
||||
'fire.dpm': 'DPM',
|
||||
'fire.reload': 'reload',
|
||||
'fire.caliber': 'caliber',
|
||||
|
||||
Reference in new issue
Block a user