Skip to content

Commit 275efe9

Browse files
committed
feat: Show multiple optimize-for values in table
1 parent 20ea351 commit 275efe9

File tree

6 files changed

+102
-8
lines changed

6 files changed

+102
-8
lines changed

locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
"Share settings.": "Share settings.",
188188
"Shared Build": "Shared Build",
189189
"Shared character links do not currently support exotic gear.": "Shared character links do not currently support exotic gear.",
190+
"Show Additional Indicators": "Show Additional Indicators",
190191
"Show Attributes": "Show Attributes",
191192
"Show all implemented modifier effects": "Show all implemented modifier effects",
192193
"Show bonuses": "Show bonuses",

src/components/sections/controls/ResultTableSettings.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ import type { FilterMode } from '../../../state/slices/controlsSlice';
2222
import {
2323
changeCompareByPercent,
2424
changeDisplayAttributes,
25+
changeDisplayIndicators,
2526
changeFilterMode,
2627
changeHighlightDiffering,
2728
changeSavedHeader,
2829
changeTallTable,
2930
getCompareByPercent,
3031
getDisplayAttributes,
32+
getDisplayIndicators,
3133
getFilterMode,
3234
getHighlightDiffering,
3335
getSavedHeader,
3436
getTallTable,
3537
} from '../../../state/slices/controlsSlice';
38+
import { indicatorAttributes } from '../../../utils/gw2-data';
3639
import Settings from '../../baseComponents/Settings';
3740

3841
const useStyles = makeStyles()((theme) => ({
@@ -56,9 +59,10 @@ export default function ResultTableSettings() {
5659
const savedHeader = useSelector(getSavedHeader);
5760
const filterMode = useSelector(getFilterMode);
5861
const displayAttributes = useSelector(getDisplayAttributes);
62+
const displayIndicators = useSelector(getDisplayIndicators);
5963

6064
return (
61-
<Settings maxWidth={360}>
65+
<Settings maxWidth={380}>
6266
<Typography sx={{ fontWeight: 700 }}>
6367
<Trans>Result Display Settings:</Trans>
6468
</Typography>
@@ -132,6 +136,36 @@ export default function ResultTableSettings() {
132136
/>
133137
</Box>
134138

139+
<Box>
140+
<Autocomplete
141+
multiple
142+
disableCloseOnSelect
143+
value={displayIndicators}
144+
options={indicatorAttributes}
145+
onChange={(event, value) => dispatch(changeDisplayIndicators(value))}
146+
renderInput={(params) => (
147+
<TextField
148+
{...params}
149+
variant="standard"
150+
label={t('Show Additional Indicators')}
151+
margin="dense"
152+
/>
153+
)}
154+
renderOption={(props, option, { selected }) => (
155+
<li {...props} key={option}>
156+
<Box sx={{ width: 28 }}>{selected && <CheckIcon sx={{ fontSize: '1rem' }} />}</Box>
157+
{option}
158+
</li>
159+
)}
160+
renderTags={(value, getTagProps) =>
161+
value.map((option, index) => {
162+
const { key, ...props } = getTagProps({ index });
163+
return <Chip key={key} variant="outlined" label={option.slice(0, 4)} {...props} />;
164+
})
165+
}
166+
/>
167+
</Box>
168+
135169
<Box>
136170
<Autocomplete
137171
multiple

src/components/sections/results/table/ResultTable.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { Character } from '../../../../state/optimizer/types/optimizerTypes
1212
import {
1313
getCompareByPercent,
1414
getDisplayAttributes,
15+
getDisplayIndicators,
1516
getFilterMode,
1617
getFilteredLists,
1718
getHighlightDiffering,
@@ -114,7 +115,7 @@ const StickyHeadTable = () => {
114115
const infusions = firstCharacter?.infusions;
115116
const rankBy = firstCharacter?.settings?.rankby;
116117

117-
const selectedValue = selectedCharacter?.results?.value;
118+
const selectedValue = selectedCharacter?.attributes?.[rankBy];
118119

119120
const shouldDisplay = (type: ExtrasType) => {
120121
// display extras in a column if any displayed character was run in multiselect mode
@@ -160,6 +161,7 @@ const StickyHeadTable = () => {
160161
);
161162

162163
const displayAttributes = useSelector(getDisplayAttributes);
164+
const displayIndicators = useSelector(getDisplayIndicators);
163165

164166
return (
165167
<>
@@ -175,6 +177,7 @@ const StickyHeadTable = () => {
175177
rankBy={rankBy}
176178
displayExtras={displayExtras}
177179
displayAttributes={displayAttributes}
180+
displayIndicators={displayIndicators}
178181
/>
179182
</TableHead>
180183
<TableBody
@@ -202,6 +205,8 @@ const StickyHeadTable = () => {
202205
compareByPercent={compareByPercent}
203206
displayExtras={displayExtras}
204207
displayAttributes={displayAttributes}
208+
displayIndicators={displayIndicators}
209+
rankBy={rankBy}
205210
/>
206211
);
207212
})}
@@ -229,6 +234,7 @@ const StickyHeadTable = () => {
229234
rankBy={rankBy}
230235
displayExtras={displayExtras}
231236
displayAttributes={displayAttributes}
237+
displayIndicators={displayIndicators}
232238
/>
233239
</TableHead>
234240
<TableBody
@@ -249,6 +255,8 @@ const StickyHeadTable = () => {
249255
compareByPercent={compareByPercent}
250256
displayExtras={displayExtras}
251257
displayAttributes={displayAttributes}
258+
displayIndicators={displayIndicators}
259+
rankBy={rankBy}
252260
/>
253261
);
254262
})}

src/components/sections/results/table/ResultTableHeaderRow.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ const useStyles = makeStyles()((theme: any) => ({
4545
attributesColumnWide: {
4646
minWidth: '3.2em',
4747
},
48+
indicatorsColumn: {
49+
minWidth: '3.1em',
50+
},
51+
indicatorsColumnWide: {
52+
minWidth: '3.8em',
53+
},
4854
}));
4955

5056
interface ResultTableHeaderRowProps {
@@ -53,6 +59,7 @@ interface ResultTableHeaderRowProps {
5359
rankBy: IndicatorName;
5460
displayExtras: Record<ExtrasType, boolean>;
5561
displayAttributes: DisplayAttributes;
62+
displayIndicators: IndicatorName[];
5663
}
5764

5865
const ResultTableHeaderRow = ({
@@ -61,6 +68,7 @@ const ResultTableHeaderRow = ({
6168
rankBy = 'Damage',
6269
displayExtras,
6370
displayAttributes,
71+
displayIndicators,
6472
}: ResultTableHeaderRowProps) => {
6573
const { t } = useTranslation();
6674
const { classes, cx } = useStyles();
@@ -90,11 +98,28 @@ const ResultTableHeaderRow = ({
9098
fontSize="1rem"
9199
/>
92100
</TableCell>
93-
<TableCell className={classes.tablehead}>
101+
<TableCell className={classes.tablehead} sx={{ paddingRight: '0.3em' }}>
94102
{t('priorityGoal', {
95103
context: rankBy,
96104
})}
97105
</TableCell>
106+
107+
{displayIndicators
108+
.filter((attribute) => rankBy !== attribute)
109+
.map((attribute) => (
110+
<TableCell
111+
className={cx(
112+
classes.tablehead,
113+
classes.indicatorsColumn,
114+
attribute !== 'Healing' && classes.indicatorsColumnWide,
115+
)}
116+
padding="none"
117+
key={attribute}
118+
>
119+
{t('priorityGoal', { context: attribute }).slice(0, 4)}
120+
</TableCell>
121+
))}
122+
98123
{padCellArray(
99124
maxSlotsLength,
100125
allSlotData[weaponType].map((slot) => (

src/components/sections/results/table/ResultTableRow.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { DisplayAttributes } from '../../../../state/slices/controlsSlice';
1313
import { changeSelectedCharacter, toggleSaved } from '../../../../state/slices/controlsSlice';
1414
import type { ExtrasType } from '../../../../state/slices/extras';
1515
import { extrasTypes } from '../../../../state/slices/extras';
16-
import type { AffixName } from '../../../../utils/gw2-data';
16+
import type { AffixName, IndicatorName } from '../../../../utils/gw2-data';
1717
import { maxSlotsLength } from '../../../../utils/gw2-data';
1818

1919
const roundTwo = (num: number) => Math.round(num * 100) / 100;
@@ -29,6 +29,8 @@ interface ResultTableRowProps {
2929
compareByPercent: boolean;
3030
displayExtras: Record<ExtrasType, boolean>;
3131
displayAttributes: DisplayAttributes;
32+
displayIndicators: IndicatorName[];
33+
rankBy: IndicatorName;
3234
}
3335

3436
const ResultTableRow = ({
@@ -42,10 +44,12 @@ const ResultTableRow = ({
4244
compareByPercent,
4345
displayExtras,
4446
displayAttributes,
47+
displayIndicators,
48+
rankBy = 'Damage',
4549
}: ResultTableRowProps) => {
4650
const dispatch = useDispatch();
4751

48-
const { value } = character.results;
52+
const value = character.attributes[rankBy] ?? 0;
4953
const comparisonValue = selectedValue ? value - selectedValue : 0;
5054

5155
const comparisonText = comparisonValue
@@ -104,14 +108,25 @@ const ResultTableRow = ({
104108
}}
105109
/>
106110
</TableCell>
107-
<TableCell scope="row" sx={{ whiteSpace: 'nowrap' }}>
111+
<TableCell scope="row" sx={{ whiteSpace: 'nowrap', paddingRight: '0.3em' }}>
108112
{value?.toFixed(0)}
109113
{comparisonText ? (
110114
<Typography variant="caption" sx={{ color: 'text.secondary' }}>
111115
{comparisonText}
112116
</Typography>
113117
) : null}
114118
</TableCell>
119+
120+
{displayIndicators
121+
.filter((attribute) => rankBy !== attribute)
122+
.map((attribute) => (
123+
<TableCell key={attribute} align="left" padding="none">
124+
<Typography variant="caption">
125+
{(character.attributes[attribute] ?? 0).toFixed(0)}
126+
</Typography>
127+
</TableCell>
128+
))}
129+
115130
{character.gearDescription ? (
116131
<TableCell align="center" padding="none" colSpan={maxSlotsLength}>
117132
<Typography
@@ -148,7 +163,7 @@ const ResultTableRow = ({
148163
.join('');
149164

150165
return (
151-
<TableCell align="center" padding="none">
166+
<TableCell align="center" padding="none" sx={{ paddingBlock: '8px' }}>
152167
<Typography
153168
style={{
154169
fontWeight: 300,

src/state/slices/controlsSlice.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
import type { PayloadAction } from '@reduxjs/toolkit';
33
import { createSelector, createSlice, original } from '@reduxjs/toolkit';
44
import type { getBuildTemplateData } from '../../assets/presetdata/templateTransform';
5-
import type { ProfessionName, ProfessionOrSpecializationName } from '../../utils/gw2-data';
5+
import type {
6+
IndicatorName,
7+
ProfessionName,
8+
ProfessionOrSpecializationName,
9+
} from '../../utils/gw2-data';
610
import type { ParseFunction } from '../../utils/usefulFunctions';
711
import { objectKeys, parseNumber } from '../../utils/usefulFunctions';
812
import type { Character } from '../optimizer/types/optimizerTypes';
@@ -110,6 +114,7 @@ const initialState: {
110114
savedHeader: boolean;
111115
filterMode: FilterMode;
112116
displayAttributes: DisplayAttributes;
117+
displayIndicators: IndicatorName[];
113118
progress: number;
114119
heuristicsProgress: number | undefined;
115120
selectedCharacter: Character | null;
@@ -133,6 +138,7 @@ const initialState: {
133138
savedHeader: false,
134139
filterMode: 'None',
135140
displayAttributes: [],
141+
displayIndicators: [],
136142
progress: 0,
137143
heuristicsProgress: undefined,
138144
selectedCharacter: null,
@@ -225,6 +231,9 @@ export const controlSlice = createSlice({
225231
changeDisplayAttributes: (state, action: PayloadAction<DisplayAttributes>) => {
226232
state.displayAttributes = action.payload;
227233
},
234+
changeDisplayIndicators: (state, action: PayloadAction<IndicatorName[]>) => {
235+
state.displayIndicators = action.payload;
236+
},
228237
changeTallTable: (state, action: PayloadAction<boolean>) => {
229238
state.tallTable = action.payload;
230239
},
@@ -277,6 +286,7 @@ export const getHighlightDiffering = (state: RootState) =>
277286
state.optimizer.control.highlightDiffering;
278287
export const getFilterMode = (state: RootState) => state.optimizer.control.filterMode;
279288
export const getDisplayAttributes = (state: RootState) => state.optimizer.control.displayAttributes;
289+
export const getDisplayIndicators = (state: RootState) => state.optimizer.control.displayIndicators;
280290
export const getTallTable = (state: RootState) => state.optimizer.control.tallTable;
281291
export const getSavedHeader = (state: RootState) => state.optimizer.control.savedHeader;
282292
export const getSelectedCharacter = (state: RootState) => state.optimizer.control.selectedCharacter;
@@ -326,6 +336,7 @@ export const {
326336
updateResults,
327337
changeFilterMode,
328338
changeDisplayAttributes,
339+
changeDisplayIndicators,
329340
changeTallTable,
330341
changeSavedHeader,
331342
toggleSaved,

0 commit comments

Comments
 (0)