-
-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10566 from DestinyItemManager/pathfinder
Pathfinder
- Loading branch information
Showing
14 changed files
with
286 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
@use '../variables.scss' as *; | ||
|
||
.pathfinderTree { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 16px; | ||
margin: 16px 0; | ||
|
||
@include phone-portrait { | ||
flex-direction: column; | ||
margin: 16px 10px; | ||
gap: 12px; | ||
} | ||
} | ||
|
||
.pathfinderRow { | ||
composes: flexColumn from '../dim-ui/common.m.scss'; | ||
box-sizing: border-box; | ||
gap: 8px; | ||
flex: 1; | ||
justify-content: center; | ||
max-width: 250px; | ||
min-width: 120px; | ||
--item-size: 35px; | ||
|
||
:global(.milestone-quest) { | ||
align-items: center; | ||
background: rgba(255, 255, 255, 0.05); | ||
padding: 8px; | ||
width: 100%; | ||
} | ||
|
||
@media (min-width: 541px) { | ||
&:nth-child(n + 2) button::before { | ||
position: absolute; | ||
display: inline; | ||
content: '⧽'; | ||
font-size: 28px; | ||
margin-left: -23px; | ||
} | ||
} | ||
|
||
@media (max-width: 1270px) and (min-width: 541px) { | ||
min-width: 60px; | ||
|
||
:global(.milestone-quest) { | ||
align-items: flex-start; | ||
flex-direction: column; | ||
} | ||
:global(.milestone-icon) { | ||
flex-direction: row !important; | ||
--item-size: 25px; | ||
max-width: fit-content !important; | ||
margin-top: 6px; | ||
|
||
& > div { | ||
margin-right: 6px; | ||
} | ||
} | ||
:global(.milestone-info) { | ||
flex-direction: row !important; | ||
width: auto !important; | ||
} | ||
:global(.milestone-name) { | ||
font-size: 12px !important; | ||
} | ||
:global(.milestone-description) { | ||
display: none; | ||
} | ||
&:not(:first-child) button::before { | ||
transform: translateY(-8%); | ||
} | ||
} | ||
|
||
@include phone-portrait { | ||
flex-direction: row; | ||
gap: 14px; | ||
width: auto; | ||
max-width: unset; | ||
|
||
> * { | ||
flex: 0; | ||
width: calc(var(--item-size) + 16px) !important; | ||
min-width: calc(var(--item-size) + 16px) !important; | ||
} | ||
:global(.milestone-icon) { | ||
margin: 0; | ||
} | ||
:global(.milestone-info) { | ||
display: none !important; | ||
} | ||
} | ||
} | ||
|
||
.completed { | ||
:global(.milestone-icon) img { | ||
border-color: $xp; | ||
border-width: 2px; | ||
padding: 3px; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { trackedTriumphsSelector } from 'app/dim-api/selectors'; | ||
import CollapsibleTitle from 'app/dim-ui/CollapsibleTitle'; | ||
import { DimItem } from 'app/inventory/item-types'; | ||
import { createItemContextSelector } from 'app/inventory/selectors'; | ||
import { DimStore } from 'app/inventory/store-types'; | ||
import { toPresentationNodeTree } from 'app/records/presentation-nodes'; | ||
import { filterMap } from 'app/utils/collections'; | ||
import { DestinyPresentationNodeDefinition, DestinyRecordState } from 'bungie-api-ts/destiny2'; | ||
import { useSelector } from 'react-redux'; | ||
import styles from './Pathfinder.m.scss'; | ||
import Pursuit from './Pursuit'; | ||
import { recordToPursuitItem } from './milestone-items'; | ||
|
||
/** | ||
* List out all the seasonal challenges for the character, grouped out in a useful way. | ||
*/ | ||
export default function Pathfinder({ | ||
id, | ||
name, | ||
presentationNode, | ||
store, | ||
}: { | ||
id: string; | ||
name: string; | ||
presentationNode: DestinyPresentationNodeDefinition; | ||
store: DimStore; | ||
}) { | ||
const itemCreationContext = useSelector(createItemContextSelector); | ||
const nodeTree = toPresentationNodeTree(itemCreationContext, presentationNode.hash); | ||
|
||
const allRecords = nodeTree?.childPresentationNodes?.[0]?.records?.toReversed() ?? []; | ||
|
||
const trackedRecords = useSelector(trackedTriumphsSelector); | ||
|
||
const acquiredRecords = new Set<number>( | ||
filterMap(allRecords, (r) => { | ||
// Don't show records that have been redeemed | ||
const state = r.recordComponent.state; | ||
const acquired = Boolean(state & DestinyRecordState.RecordRedeemed); | ||
return acquired ? r.recordDef.hash : undefined; | ||
}), | ||
); | ||
|
||
const pursuits = allRecords.map((r) => | ||
recordToPursuitItem( | ||
r, | ||
itemCreationContext.buckets, | ||
store, | ||
presentationNode.displayProperties.name, | ||
trackedRecords.includes(r.recordDef.hash), | ||
), | ||
); | ||
|
||
const pursuitGroups: DimItem[][] = []; | ||
for (let i = 6; i > 0; i--) { | ||
pursuitGroups.push(pursuits.splice(0, i)); | ||
} | ||
|
||
return ( | ||
<section id={id} className="pathfinder"> | ||
<CollapsibleTitle title={name} sectionId={id}> | ||
<div className={styles.pathfinderTree}> | ||
{pursuitGroups.map((pursuits) => ( | ||
<div key={pursuits.length} className={styles.pathfinderRow}> | ||
{pursuits.map((item) => ( | ||
<Pursuit | ||
item={item} | ||
key={item.index} | ||
className={ | ||
acquiredRecords.has(item.pursuit?.recordHash ?? 0) | ||
? styles.completed | ||
: undefined | ||
} | ||
/> | ||
))} | ||
</div> | ||
))} | ||
</div> | ||
</CollapsibleTitle> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.