Skip to content

Commit

Permalink
Merge pull request #9848 from guise/harmonizable-status-by-pattern-pr…
Browse files Browse the repository at this point in the history
…ogress
  • Loading branch information
bhollis authored Sep 15, 2023
2 parents 461d7ba + dff74f8 commit f4ea8a0
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 25 deletions.
1 change: 1 addition & 0 deletions config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
"Event": "Shows items from which event in Destiny 2 they appeared in.",
"ExtraPerk": "Shows random-rolled Legendary weapons with an additional selectable perk.",
"Filter": "Filter",
"FilterWith": "Filter with:",
"Focusable": "Shows items that can be focused at a vendor",
"Foundry": "Shows items by which foundry created them.",
"Glimmer": "Shows items that are consumables that are related to gaining glimmer.",
Expand Down
29 changes: 17 additions & 12 deletions src/app/dim-ui/DestinyTooltipText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ export function DestinyTooltipText({ item }: { item: DimItem }) {
}
return (
<>
{item.tooltipNotifications.map((tip) => (
<div
key={tip.displayString}
className={clsx('quest-expiration item-details', {
[styles.seasonalExpiration]: isExpirationTooltip(tip),
})}
>
{isExpirationTooltip(tip) && <AppIcon icon={faClock} />}
{isPatternTooltip(tip) && <AppIcon className={styles.shapedIcon} icon={shapedIcon} />}
<RichDestinyText text={tip.displayString} ownerId={item.owner} />
</div>
))}
{!isDeepsightTooltip &&
item.tooltipNotifications.map((tip) => (
<div
key={tip.displayString}
className={clsx('quest-expiration item-details', {
[styles.seasonalExpiration]: isExpirationTooltip(tip),
})}
>
{isExpirationTooltip(tip) && <AppIcon icon={faClock} />}
{isPatternTooltip(tip) && <AppIcon className={styles.shapedIcon} icon={shapedIcon} />}
<RichDestinyText text={tip.displayString} ownerId={item.owner} />
</div>
))}
</>
);
}
Expand All @@ -34,3 +35,7 @@ function isExpirationTooltip(tip: DestinyItemTooltipNotification) {
function isPatternTooltip(tip: DestinyItemTooltipNotification) {
return tip.displayStyle === 'ui_display_style_deepsight';
}

function isDeepsightTooltip(tip: DestinyItemTooltipNotification) {
return tip.displayStyle === 'ui_display_style_info';
}
4 changes: 4 additions & 0 deletions src/app/dim-ui/PressTip.m.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ $horizontal-padding: 11px;

p {
margin-bottom: 0;

&:first-of-type {
margin: 0;
}
}

.header {
Expand Down
2 changes: 0 additions & 2 deletions src/app/inventory/store/d2-item-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ export function makeItem(
// why the optional chain? well, somehow, an item can return tooltipNotificationIndexes,
// but have no tooltipNotifications in its def
.map((i) => itemDef.tooltipNotifications?.[i])
// a temporary filter because as of witch queen, all tooltips are set to "on"
.filter((t) => t && t.displayStyle !== 'ui_display_style_info')
: emptyArray<DestinyItemTooltipNotification>();

// null out falsy values like a blank string for a url
Expand Down
10 changes: 10 additions & 0 deletions src/app/inventory/store/deepsight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ export function isDeepsightResonanceSocket(socket: DimSocket): boolean {
socketContainsPlugWithCategory(socket, PlugCategoryHashes.CraftingPlugsWeaponsModsMemories)
);
}

export function isHarmonizable(item: DimItem): boolean | undefined {
const isItemHarmonizable = item.sockets?.allSockets.some(
(s) =>
s.plugged?.plugDef.plug.plugCategoryHash ===
PlugCategoryHashes.CraftingPlugsWeaponsModsExtractors && s.visibleInGame
);

return isItemHarmonizable;
}
11 changes: 11 additions & 0 deletions src/app/inventory/store/objectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ export function isBooleanObjective(
);
}

export function isPatternObjective(
objectiveDef: DestinyObjectiveDefinition | D1ObjectiveDefinition
) {
const isD2Def = 'allowOvercompletion' in objectiveDef;
// Check if objective is for weapon pattern progress
const isPatternProgress =
isD2Def && objectiveDef.valueStyle === DestinyUnlockValueUIStyle.Automatic;

return isPatternProgress;
}

export function isTrialsPassage(itemHash: number) {
return trialsHashes.passages.includes(itemHash);
}
Expand Down
14 changes: 14 additions & 0 deletions src/app/item-popup/DeepSightHarmonizerIcon.m.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@use '../variables.scss' as *;

.deepsightHarmonizerIcon {
flex-grow: 1;
max-width: fit-content;

img {
display: block;
width: 15px;
height: 15px;
border: 1px solid #999;
margin-right: 4px;
}
}
7 changes: 7 additions & 0 deletions src/app/item-popup/DeepSightHarmonizerIcon.m.scss.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions src/app/item-popup/DeepsightHarmonizerIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import BungieImage from 'app/dim-ui/BungieImage';
import { PressTip } from 'app/dim-ui/PressTip';
import { t } from 'app/i18next-t';
import { DimItem } from 'app/inventory/item-types';
import { useD2Definitions } from 'app/manifest/selectors';
import { DEEPSIGHT_HARMONIZER } from 'app/search/d2-known-values';
import styles from './DeepSightHarmonizerIcon.m.scss';

export function DeepsightHarmonizerIcon({ item }: { item: DimItem }) {
const defs = useD2Definitions()!;
const harmonizerIcon = defs.InventoryItem.get(DEEPSIGHT_HARMONIZER)?.displayProperties.icon;

return (
<PressTip
tooltip={<HarmonizableTooltipContent item={item} />}
className={styles.deepsightHarmonizerIcon}
>
<BungieImage src={harmonizerIcon} />
</PressTip>
);
}

function HarmonizableTooltipContent({ item }: { item: DimItem }) {
const harmonizableTooltipText = item.tooltipNotifications?.map((t) => t.displayString);
const harmonizableTooltip = (
<>
<p>{harmonizableTooltipText}</p>
<p>
{t('Filter.FilterWith')} <code>deepsight:harmonizable</code>
</p>
</>
);

return harmonizableTooltip;
}
9 changes: 6 additions & 3 deletions src/app/item-popup/WeaponDeepsightInfo.m.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

.deepsightProgress {
display: flex;
padding: 4px 10px;
gap: 4px;
background: var(--theme-item-popup-panel-bg);
justify-content: center;
align-items: center;
align-content: stretch;

:global(.objective-progress) {
background: var(--theme-item-popup-progress-bar-bg);
}
}

.deepsightProgressSection {
padding: 4px 10px 4px;
background: var(--theme-item-popup-panel-bg);
.deepsightProgressBar {
flex-grow: 1;
}
2 changes: 1 addition & 1 deletion src/app/item-popup/WeaponDeepsightInfo.m.scss.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions src/app/item-popup/WeaponDeepsightInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { DimItem } from 'app/inventory/item-types';
import { isHarmonizable } from 'app/inventory/store/deepsight';
import Objective from 'app/progress/Objective';
import { DeepsightHarmonizerIcon } from './DeepsightHarmonizerIcon';
import styles from './WeaponDeepsightInfo.m.scss';

/**
* A progress bar that shows a weapon's crafting pattern progress.
*/
Expand All @@ -16,11 +17,18 @@ export function WeaponDeepsightInfo({ item }: { item: DimItem }) {
return (
<div className={styles.deepsightProgress}>
{relevantObjectives && relevantObjectives.length > 0 && (
<div className={styles.deepsightProgressSection}>
{relevantObjectives.map((objective) => (
<Objective key={objective.objectiveHash} objective={objective} showHidden />
))}
</div>
<>
{isHarmonizable(item) ? (
<DeepsightHarmonizerIcon item={item} />
) : (
<div className="objective-checkbox" />
)}
<div className={styles.deepsightProgressBar}>
{relevantObjectives.map((objective) => (
<Objective key={objective.objectiveHash} objective={objective} showHidden />
))}
</div>
</>
)}
</div>
);
Expand Down
9 changes: 9 additions & 0 deletions src/app/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ select {
}
}

code {
position: relative;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 3px;
padding: 0 4px;
bottom: 1px;
}

.horizontal-swipable {
touch-action: pan-y;
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/progress/Objective.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getValueStyle,
isBooleanObjective,
isFlawlessObjective,
isPatternObjective,
isRoundsWonObjective,
} from 'app/inventory/store/objectives';
import { useDefinitions } from 'app/manifest/selectors';
Expand Down Expand Up @@ -81,6 +82,7 @@ export default function Objective({
}

const isBoolean = isBooleanObjective(objectiveDef, progress, completionValue);
const showPatternProgress = isPatternObjective(objectiveDef);
const showAsCounter = isTrialsPassage && isRoundsWonObjective(objective.objectiveHash);
const passageFlawed =
isTrialsPassage && isFlawlessObjective(objective.objectiveHash) && !complete;
Expand All @@ -100,7 +102,7 @@ export default function Objective({

return (
<div className={classes}>
{!showAsCounter && !isDate && <div className="objective-checkbox" />}
{!showPatternProgress && !showAsCounter && !isDate && <div className="objective-checkbox" />}
<div className="objective-progress">
{!isBoolean && !isDate && (
<div className="objective-progress-bar" style={progressBarStyle} />
Expand Down
3 changes: 3 additions & 0 deletions src/app/search/d2-known-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ export const pinnacleSources = [
/** The premium Eververse currency */
export const silverItemHash = 3147280338; // InventoryItem "Silver"

// Deepsight harmonizer currency for extracting weapon patterns
export const DEEPSIGHT_HARMONIZER = 2228452164;

// For loadout mods obliterated from the defs, we instead return this def
export const deprecatedPlaceholderArmorModHash = 3947616002; // InventoryItem "Deprecated Armor Mod"

Expand Down
1 change: 1 addition & 0 deletions src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
"Event": "Shows items from which event in Destiny 2 they appeared in.",
"ExtraPerk": "Shows random-rolled Legendary weapons with an additional selectable perk.",
"Filter": "Filter",
"FilterWith": "Filter with:",
"Focusable": "Shows items that can be focused at a vendor",
"Foundry": "Shows items by which foundry created them.",
"Glimmer": "Shows items that are consumables that are related to gaining glimmer.",
Expand Down

0 comments on commit f4ea8a0

Please sign in to comment.