mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-27 20:49:52 +01: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;
|
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':
|
case 'fire.dpm':
|
||||||
sorted = filtered.sort(
|
sorted = filtered.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
@@ -707,6 +734,16 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
|
|||||||
>
|
>
|
||||||
Volume
|
Volume
|
||||||
</DropdownMenu.CheckboxItem>
|
</DropdownMenu.CheckboxItem>
|
||||||
|
<DropdownMenu.CheckboxItem
|
||||||
|
checked={sort.by === 'survivability.length'}
|
||||||
|
onClick={() => {
|
||||||
|
mutateTankopediaPersistent((draft) => {
|
||||||
|
draft.sort.by = 'survivability.length';
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Length
|
||||||
|
</DropdownMenu.CheckboxItem>
|
||||||
</DropdownMenu.SubContent>
|
</DropdownMenu.SubContent>
|
||||||
</DropdownMenu.Sub>
|
</DropdownMenu.Sub>
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ export const SORT_NAMES = {
|
|||||||
'survivability.camouflageMoving': 'camouflage moving',
|
'survivability.camouflageMoving': 'camouflage moving',
|
||||||
'survivability.camouflageShooting': 'camouflage shooting',
|
'survivability.camouflageShooting': 'camouflage shooting',
|
||||||
'survivability.volume': 'volume',
|
'survivability.volume': 'volume',
|
||||||
|
'survivability.length': 'length',
|
||||||
'fire.dpm': 'DPM',
|
'fire.dpm': 'DPM',
|
||||||
'fire.reload': 'reload',
|
'fire.reload': 'reload',
|
||||||
'fire.caliber': 'caliber',
|
'fire.caliber': 'caliber',
|
||||||
|
|||||||
Reference in new issue
Block a user