Skip to content

Commit

Permalink
Properly describe the thing being inserted or selected by SocketDetai…
Browse files Browse the repository at this point in the history
…ls popup
  • Loading branch information
robojumper committed Dec 28, 2021
1 parent fe688e1 commit b14ba26
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 27 deletions.
22 changes: 16 additions & 6 deletions config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,22 @@
"Sockets": {
"ApplyPerks": "Apply Perks",
"SelectWishlistPerks": "Preview Wishlist Perks",
"InsertModButton": "Insert Mod",
"SelectModButton": "Select Mod",
"InsertShaderButton": "Apply Shader",
"SelectShaderButton": "Select Shader",
"InsertOrnamentButton": "Apply Ornament",
"SelectOrnamentButton": "Select Ornament",
"InsertMod": "Insert Mod",
"SelectMod": "Select Mod",
"InsertShader": "Apply Shader",
"SelectShader": "Select Shader",
"InsertOrnament": "Apply Ornament",
"SelectOrnament": "Select Ornament",
"InsertAbility": "Equip Ability",
"SelectAbility": "Select Ability",
"InsertFragment": "Insert Fragment",
"SelectFragment": "Select Fragment",
"InsertAspect": "Insert Aspect",
"SelectAspect": "Select Aspect",
"InsertTransmat": "Apply Transmat Effect",
"SelectTransmat": "Select Transmat Effect",
"InsertProjection": "Apply Ghost Projection",
"SelectProjection": "Select Ghost Projection",
"ListStyle": "Display perks as a list",
"GridStyle": "Display perks as a grid"
},
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Removed notification when loading/updating a wish list. Go to the wish list section of the settings menu if you want to see details.
* The progress notification for applying a loadout now shows each item and mod as it's being applied.
* Mod picker now correctly names inserted thing (e.g Fragment, Shader).

## 6.97.1 <span class="changelog-date">(2021-12-26)</span>

Expand Down
14 changes: 14 additions & 0 deletions i18next-scanner.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ module.exports = {
fallback: false,
separator: false,
},
sockets: {
list: [
'Mod',
'Ability',
'Shader',
'Ornament',
'Fragment',
'Aspect',
'Projection',
'Transmat',
],
fallback: false,
separator: false,
},
},
},
};
62 changes: 47 additions & 15 deletions src/app/item-popup/SocketDetailsSelectedPlug.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { D2ManifestDefinitions } from 'app/destiny2/d2-definitions';
import BungieImage from 'app/dim-ui/BungieImage';
import { t } from 'app/i18next-t';
import { canInsertPlug, insertPlug } from 'app/inventory/advanced-write-actions';
Expand All @@ -11,7 +12,14 @@ import {
import { interpolateStatValue } from 'app/inventory/store/stats';
import { destiny2CoreSettingsSelector, useD2Definitions } from 'app/manifest/selectors';
import { showNotification } from 'app/notifications/notifications';
import { DEFAULT_ORNAMENTS, DEFAULT_SHADER } from 'app/search/d2-known-values';
import {
DEFAULT_ASPECTS,
DEFAULT_FRAGMENT,
DEFAULT_ORNAMENTS,
DEFAULT_PROJECTION,
DEFAULT_SHADER,
DEFAULT_TRANSMAT,
} from 'app/search/d2-known-values';
import { refreshIcon } from 'app/shell/icons';
import AppIcon from 'app/shell/icons/AppIcon';
import { useThunkDispatch } from 'app/store/thunk-dispatch';
Expand All @@ -20,7 +28,8 @@ import {
isPlugStatActive,
itemIsInstanced,
} from 'app/utils/item-utils';
import { StatHashes } from 'data/d2/generated-enums';
import { DestinyItemSocketEntryDefinition } from 'bungie-api-ts/destiny2';
import { SocketCategoryHashes, StatHashes } from 'data/d2/generated-enums';
import { motion } from 'framer-motion';
import _ from 'lodash';
import React, { useState } from 'react';
Expand All @@ -37,6 +46,36 @@ const costStatHashes = [
StatHashes.ArcCost,
];

/** Figures out what kind of socket this is so that the "Apply" button can name the correct thing
* instead of generically saying "Select/Insert Mod".
* Note that these are used as part of the localization key.
*/
function uiCategorizeSocket(defs: D2ManifestDefinitions, socket: DestinyItemSocketEntryDefinition) {
const socketTypeDef = socket.socketTypeHash && defs.SocketType.get(socket.socketTypeHash);
if (socketTypeDef && socketTypeDef.socketCategoryHash === SocketCategoryHashes.Abilities) {
return 'Ability';
}

const initialPlugHash = socket.singleInitialItemHash;
if (initialPlugHash) {
if (initialPlugHash === DEFAULT_SHADER) {
return 'Shader';
} else if (DEFAULT_ORNAMENTS.includes(initialPlugHash)) {
return 'Ornament';
} else if (initialPlugHash === DEFAULT_FRAGMENT) {
return 'Fragment';
} else if (DEFAULT_ASPECTS.includes(initialPlugHash)) {
return 'Aspect';
} else if (initialPlugHash === DEFAULT_PROJECTION) {
return 'Projection';
} else if (initialPlugHash === DEFAULT_TRANSMAT) {
return 'Transmat';
}
}

return 'Mod';
}

export default function SocketDetailsSelectedPlug({
plug,
socket,
Expand Down Expand Up @@ -113,19 +152,12 @@ export default function SocketDetailsSelectedPlug({
const canDoAWA =
itemIsInstanced(item) && canInsertPlug(socket, plug.hash, destiny2CoreSettings, defs);

const initialPlugHash = socket.socketDefinition.singleInitialItemHash;
let insertName;
if (initialPlugHash) {
if (initialPlugHash === DEFAULT_SHADER) {
insertName = canDoAWA ? t('Sockets.InsertShaderButton') : t('Sockets.SelectShaderButton');
} else if (DEFAULT_ORNAMENTS.includes(initialPlugHash)) {
insertName = canDoAWA ? t('Sockets.InsertOrnamentButton') : t('Sockets.SelectOrnamentButton');
} else {
insertName = canDoAWA ? t('Sockets.InsertModButton') : t('Sockets.SelectModButton');
}
} else {
insertName = canDoAWA ? t('Sockets.InsertModButton') : t('Sockets.SelectModButton');
}
// t(`Sockets.Insert`, { contextList: 'sockets' })
// t(`Sockets.Select`, { contextList: 'sockets' })
const kind = uiCategorizeSocket(defs, socket.socketDefinition);
const insertName = canDoAWA
? t(`Sockets.Insert${kind}`, { contextList: 'sockets' })
: t(`Sockets.Select${kind}`, { contextList: 'sockets' });

const [insertInProgress, setInsertInProgress] = useState(false);
const onInsertPlug = async () => {
Expand Down
17 changes: 17 additions & 0 deletions src/app/search/d2-known-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,30 @@ export const DEFAULT_SHADER = 4248210736; // InventoryItem "Default Shader"
/** the default glow InventoryItem in every empty glow slot */
export const DEFAULT_GLOW = 3807544519; // InventoryItem "Remove Armor Glow"

/** the default empty ghost projection in ghost projection slots */
export const DEFAULT_PROJECTION = 2426387438;

/** the default transmat effect in ship transmat effect slots */
export const DEFAULT_TRANSMAT = 1390587439;

/** An array of default ornament hashes */
export const DEFAULT_ORNAMENTS: number[] = [
2931483505, // InventoryItem "Default Ornament"
1959648454, // InventoryItem "Default Ornament"
702981643, // InventoryItem "Default Ornament"
];

/** the default empty fragment for Subclasses 2.0 */
export const DEFAULT_FRAGMENT = 3251563851;

// TODO: Is there a way to recognize these without hardcoding every 2.0 subclass?
/** the default empty aspects for Subclasses 2.0 */
export const DEFAULT_ASPECTS: number[] = [
321296654, // Stasis Titan
3819991001, // Stasis Warlock
1715180370, // Stasis Hunter
];

/** if a socket contains these, consider it empty */
export const emptySocketHashes = [
2323986101, // InventoryItem "Empty Mod Socket"
Expand Down
22 changes: 16 additions & 6 deletions src/locale/dim.json
Original file line number Diff line number Diff line change
Expand Up @@ -842,13 +842,23 @@
"Sockets": {
"ApplyPerks": "Apply Perks",
"GridStyle": "Display perks as a grid",
"InsertModButton": "Insert Mod",
"InsertOrnamentButton": "Apply Ornament",
"InsertShaderButton": "Apply Shader",
"InsertAbility": "Equip Ability",
"InsertAspect": "Insert Aspect",
"InsertFragment": "Insert Fragment",
"InsertMod": "Insert Mod",
"InsertOrnament": "Apply Ornament",
"InsertProjection": "Apply Ghost Projection",
"InsertShader": "Apply Shader",
"InsertTransmat": "Apply Transmat Effect",
"ListStyle": "Display perks as a list",
"SelectModButton": "Select Mod",
"SelectOrnamentButton": "Select Ornament",
"SelectShaderButton": "Select Shader",
"SelectAbility": "Select Ability",
"SelectAspect": "Select Aspect",
"SelectFragment": "Select Fragment",
"SelectMod": "Select Mod",
"SelectOrnament": "Select Ornament",
"SelectProjection": "Select Ghost Projection",
"SelectShader": "Select Shader",
"SelectTransmat": "Select Transmat Effect",
"SelectWishlistPerks": "Preview Wishlist Perks"
},
"Stats": {
Expand Down

0 comments on commit b14ba26

Please sign in to comment.