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

Edit in-game identifiers for DIM loadouts #9760

Merged
merged 17 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
"HasShader": "Shows items that have a shader applied.",
"HasOrnament": "Shows items that have an ornament applied.",
"InLoadout": "is:inloadout shows items that are included in any loadout. Searching with inloadout: shows items that are included in loadouts with matching titles. When used with a hashtag, inloadout: shows items whose loadouts have the hashtag in the title or notes.",
"InInGameLoadout": "is:iningameloadout shows items that are included in any in-game loadout.",

Check warning on line 243 in config/i18n.json

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (iningameloadout)
"Infusable": "Shows items that can be infused.",
"IsAdept": "Shows weapons compatible with Adept mods.",
"IsCrafted": "Shows weapons that have been crafted.",
Expand Down Expand Up @@ -430,6 +430,7 @@
"DeletedBody": "Cleared the in-game loadout at slot {{index}}",
"DeleteFailed": "Failed to delete loadout",
"Save": "Update Loadout",
"SaveIdentifiers": "Update Identifiers",
"SaveToDimLoadout": "Save as DIM Loadout",
"Replace": "Replace Loadout {{index}}",
"SnapshotFailed": "Failed to snapshot equipped loadout"
Expand Down
2 changes: 1 addition & 1 deletion src/app/dim-ui/Sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const SheetDisabledContext = createContext<(shown: boolean) => void>(() => {
* takes an "onClose" function that can be used to close the sheet. Using onClose to close
* the sheet ensures that it will animate away rather than simply disappearing.
*/
type SheetContent = React.ReactNode | ((args: { onClose: () => void }) => React.ReactNode);
export type SheetContent = React.ReactNode | ((args: { onClose: () => void }) => React.ReactNode);

interface Props {
/** A static, non-scrollable header shown in line with the close button. */
Expand Down
19 changes: 19 additions & 0 deletions src/app/loadout-drawer/LoadoutDrawer.m.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,22 @@
align-items: center;
gap: 4px;
}

.header {
display: grid;
grid-template-columns: min-content 1fr;
grid-template-areas:
'identifiers title'
'identifiers notes';
gap: 0 12px;

> *:nth-child(1) {
grid-area: identifiers;
}
> *:nth-child(2) {
grid-area: title;
}
> *:nth-child(3) {
grid-area: notes;
}
}
1 change: 1 addition & 0 deletions src/app/loadout-drawer/LoadoutDrawer.m.scss.d.ts

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

6 changes: 4 additions & 2 deletions src/app/loadout-drawer/LoadoutDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { WithSymbolsPicker } from 'app/dim-ui/destiny-symbols/SymbolsPicker';
import { useAutocomplete } from 'app/dim-ui/text-complete/text-complete';
import { t } from 'app/i18next-t';
import { getStore } from 'app/inventory/stores-helpers';
import InGameLoadoutIdentifiersSelectButton from 'app/loadout/ingame/InGameLoadoutIdentifiersSelectButton';
import { useDefinitions } from 'app/manifest/selectors';
import { searchFilterSelector } from 'app/search/search-filter';
import { AppIcon, addIcon, faRandom } from 'app/shell/icons';
Expand Down Expand Up @@ -93,7 +94,7 @@ export default function LoadoutDrawer({
return (...args: T) => setLoadout(fn(...args));
}

const store = getStore(stores, storeId)!;
const store = getStore(stores, storeId);

const onAddItem = useCallback(
(item: DimItem, equip?: boolean) => setLoadout(addItem(defs, item, equip)),
Expand Down Expand Up @@ -181,7 +182,8 @@ export default function LoadoutDrawer({
setLoadout(setClassType(checked ? DestinyClass.Unknown : store.classType));

const header = (
<div>
<div className={styles.header}>
<InGameLoadoutIdentifiersSelectButton loadout={loadout} setLoadout={setLoadout} />
<LoadoutDrawerHeader loadout={loadout} onNameChanged={handleNameChanged} />
<details className={styles.notes} open={Boolean(loadout.notes?.length)}>
<summary>{t('MovePopup.Notes')}</summary>
Expand Down
5 changes: 3 additions & 2 deletions src/app/loadout-drawer/LoadoutDrawerHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ClassIcon from 'app/dim-ui/ClassIcon';
import { WithSymbolsPicker } from 'app/dim-ui/destiny-symbols/SymbolsPicker';
import { useAutocomplete } from 'app/dim-ui/text-complete/text-complete';
import { t } from 'app/i18next-t';
Expand All @@ -21,9 +20,11 @@ export default function LoadoutDrawerHeader({
const tags = useSelector(loadoutsHashtagsSelector);
useAutocomplete(inputRef, tags);

// TODO: Only show the ingame loadout icon when the loadout has some ingame-loadout-compatible items in it?
// TODO: preview/warn that an incomplete loadout will inherit the current items for any missing slots

return (
<div className={styles.loadoutName}>
<ClassIcon classType={loadout.classType} />
<WithSymbolsPicker className={styles.dimInput} input={inputRef} setValue={onNameChanged}>
<input
name="name"
Expand Down
9 changes: 8 additions & 1 deletion src/app/loadout-drawer/loadout-drawer-reducer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LoadoutParameters } from '@destinyitemmanager/dim-api-types';
import { InGameLoadoutIdentifiers, LoadoutParameters } from '@destinyitemmanager/dim-api-types';
import { D1Categories } from 'app/destiny1/d1-bucket-categories';
import { D1ManifestDefinitions } from 'app/destiny1/d1-definitions';
import { D2Categories } from 'app/destiny2/d2-bucket-categories';
Expand Down Expand Up @@ -865,3 +865,10 @@ export function randomizeLoadoutMods(
})(loadout);
});
}

/**
* Set the name/icon/color of this loadout.
*/
export function setInGameLoadoutIdentifiers(identifiers: InGameLoadoutIdentifiers | undefined) {
return setLoadoutParameters({ inGameIdentifiers: identifiers });
}
25 changes: 18 additions & 7 deletions src/app/loadout-drawer/loadout-type-converters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Loadout, LoadoutItem, LoadoutParameters } from '@destinyitemmanager/dim-api-types';
import {
InGameLoadoutIdentifiers,
Loadout,
LoadoutItem,
LoadoutParameters,
} from '@destinyitemmanager/dim-api-types';
import { D2ManifestDefinitions } from 'app/destiny2/d2-definitions';
import { DimItem } from 'app/inventory/item-types';
import { SocketOverrides } from 'app/inventory/store/override-sockets';
Expand Down Expand Up @@ -136,9 +141,7 @@ function convertDestinyLoadoutComponentToInGameLoadout(
characterId: string,
defs: D2ManifestDefinitions
): InGameLoadout | undefined {
const name = defs.LoadoutName.get(loadoutComponent.nameHash)?.name ?? 'Unknown';
const colorIcon = defs.LoadoutColor.get(loadoutComponent.colorHash)?.colorImagePath ?? '';
const icon = defs.LoadoutIcon.get(loadoutComponent.iconHash)?.iconImagePath ?? '';
const resolvedIdentifiers = resolveInGameLoadoutIdentifiers(defs, loadoutComponent);

if (
loadoutComponent.items === undefined ||
Expand All @@ -150,15 +153,23 @@ function convertDestinyLoadoutComponentToInGameLoadout(

return {
...loadoutComponent,
...resolvedIdentifiers,
characterId,
index,
name,
colorIcon,
icon,
id: `ingame-${characterId}-${index}`,
};
}

export function resolveInGameLoadoutIdentifiers(
defs: D2ManifestDefinitions,
{ nameHash, colorHash, iconHash }: InGameLoadoutIdentifiers
) {
const name = defs.LoadoutName.get(nameHash)?.name ?? 'Unknown';
const colorIcon = defs.LoadoutColor.get(colorHash)?.colorImagePath ?? '';
const icon = defs.LoadoutIcon.get(iconHash)?.iconImagePath ?? '';
return { name, colorIcon, icon };
}

export function convertInGameLoadoutToDimLoadout(
inGameLoadout: InGameLoadout,
classType: DestinyClass,
Expand Down
4 changes: 3 additions & 1 deletion src/app/loadout/LoadoutView.m.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
gap: 1em;

h2 {
display: block;
display: flex;
flex-direction: row;
gap: 8px;
margin: 0 !important;
font-size: 16px;
}
Expand Down
7 changes: 7 additions & 0 deletions src/app/loadout/LoadoutView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import _ from 'lodash';
import { ReactNode, useMemo } from 'react';
import { useSelector } from 'react-redux';
import styles from './LoadoutView.m.scss';
import { InGameLoadoutIconFromIdentifiers } from './ingame/InGameLoadoutIcon';
import LoadoutItemCategorySection from './loadout-ui/LoadoutItemCategorySection';
import { LoadoutArtifactUnlocks, LoadoutMods } from './loadout-ui/LoadoutMods';
import LoadoutSubclassSection from './loadout-ui/LoadoutSubclassSection';
Expand Down Expand Up @@ -110,6 +111,12 @@ export default function LoadoutView({
<div className={styles.loadout} id={loadout.id}>
<div className={styles.title}>
<h2>
{loadout.parameters?.inGameIdentifiers && (
<InGameLoadoutIconFromIdentifiers
size={24}
identifiers={loadout.parameters.inGameIdentifiers}
/>
)}
{loadout.classType === DestinyClass.Unknown && (
<ClassIcon className={styles.classIcon} classType={loadout.classType} />
)}
Expand Down
1 change: 0 additions & 1 deletion src/app/loadout/Loadouts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ function Loadouts({ account }: { account: DestinyAccount }) {
<AlertIcon /> {t('Storage.DimSyncNotEnabled')}
</p>
)}
<h2>{t('Loadouts.InGameLoadouts')}</h2>
<InGameLoadoutStrip
store={selectedStore}
onEdit={setEditingInGameLoadout}
Expand Down
50 changes: 1 addition & 49 deletions src/app/loadout/ingame/EditInGameLoadout.m.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,11 @@
margin: 0;
}

.preview {
display: flex;
flex-direction: row;
text-transform: uppercase;
letter-spacing: 2px;
font-size: 16px;
gap: 8px;
align-items: center;
margin-bottom: 8px;
}

.button {
composes: dim-button from global;
position: relative;
> img {
margin: 0 !important;
height: 48px;
width: 48px;
}
&:hover,
&:active,
&.checked {
background-color: var(--theme-accent-primary);
color: var(--theme-text-invert);
> img {
filter: none !important;
}
}
&.imageButton {
padding: 2px;
}
&.hasLoadout {
&:hover,
&:active,
&.checked {
color: var(--theme-text) !important;
}
}
}

.row {
.slots {
display: flex;
flex-flow: row wrap;
gap: 4px;
}

.slots {
composes: row;
margin-bottom: 8px;

> .button {
padding: 2px;
}
}

.emptySlot {
Expand Down
6 changes: 0 additions & 6 deletions src/app/loadout/ingame/EditInGameLoadout.m.scss.d.ts

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

Loading
Loading