Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added costs to tooltip #10508 #10927

Merged
merged 8 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/app/dim-ui/EnergyIncrements.m.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,13 @@
}
}
}

.costs {
display: flex;
flex-direction: row;
gap: 6px;

.cost {
font-size: 12px !important;
}
}
2 changes: 2 additions & 0 deletions src/app/dim-ui/EnergyIncrements.m.scss.d.ts

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

24 changes: 24 additions & 0 deletions src/app/dim-ui/EnergyIncrements.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { t } from 'app/i18next-t';
import { DimItem } from 'app/inventory/item-types';
import { getEnergyUpgradeHashes, sumModCosts } from 'app/inventory/store/energy';
import { EnergySwap } from 'app/loadout-builder/generated-sets/GeneratedSetItem';
import { useD2Definitions } from 'app/manifest/selectors';
import { MAX_ARMOR_ENERGY_CAPACITY } from 'app/search/d2-known-values';
import { compareBy } from 'app/utils/comparators';
import Cost from 'app/vendors/Cost';
import clsx from 'clsx';
import styles from './EnergyIncrements.m.scss';
import { PressTip } from './PressTip';
Expand Down Expand Up @@ -66,16 +70,29 @@ export function EnergyMeterIncrements({
export function EnergyIncrementsWithPresstip({
energy,
wrapperClass,
item,
}: {
energy: {
energyCapacity: number;
energyUsed: number;
};
wrapperClass?: string | undefined;
item: DimItem;
}) {
const { energyCapacity, energyUsed } = energy;
const energyUnused = Math.max(energyCapacity - energyUsed, 0);

const defs = useD2Definitions()!;
if (!item.energy) {
return null;
}

const energyModHashes = getEnergyUpgradeHashes(item, energyUsed || 0);
const costs = sumModCosts(
defs,
energyModHashes.map((h) => defs.InventoryItem.get(h)),
).sort(compareBy((c) => c.quantity));

return (
<PressTip
tooltip={
Expand All @@ -91,6 +108,13 @@ export function EnergyIncrementsWithPresstip({
{t('EnergyMeter.UpgradeNeeded', energy)}
</>
)}
<hr />
<div className={styles.costs}>
<span>{t('Loadouts.ModPlacement.UpgradeCosts')}</span>
{costs.map((cost) => (
<Cost key={cost.itemHash} cost={cost} className={styles.cost} />
))}
</div>
</>
}
className={wrapperClass}
Expand Down
6 changes: 5 additions & 1 deletion src/app/loadout-builder/generated-sets/GeneratedSetItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ export default function GeneratedSetItem({
<div className={styles.item}>
<div className={styles.swapButtonContainer}>
<LoadoutBuilderItem item={item} onShiftClick={() => pinItem(item)} />
<EnergyIncrementsWithPresstip wrapperClass={styles.energyMeter} energy={energy} />
<EnergyIncrementsWithPresstip
wrapperClass={styles.energyMeter}
energy={energy}
item={item}
/>
{itemOptions.length > 1 ? (
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export default function ModAssignmentDrawer({

// TODO: button to apply mods
// TODO: consider existing mods in assignment

return (
<>
<Sheet
Expand All @@ -127,10 +126,10 @@ export default function ModAssignmentDrawer({
<EnergyIncrementsWithPresstip
energy={energy}
wrapperClass={styles.energyMeter}
item={item}
/>
)}
</div>

<Sockets
item={item}
lockedMods={itemModAssignments[item.id]}
Expand Down
Loading