diff --git a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx index 069a71842..11a64b0fe 100644 --- a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx +++ b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx @@ -1,13 +1,14 @@ -import { Construction, CheckBox, CheckBoxOutlineBlank } from "@mui/icons-material"; +import { CheckBox, CheckBoxOutlineBlank, Construction } from "@mui/icons-material"; import { Box, Button, Container, List, ListItemButton, Paper, Typography } from "@mui/material"; -import React, { useState, useEffect } from "react"; +import React, { useEffect, useState } from "react"; import { Augmentation } from "../../../Augmentation/Augmentation"; -import { StaticAugmentations } from "../../../Augmentation/StaticAugmentations"; import { AugmentationNames } from "../../../Augmentation/data/AugmentationNames"; +import { StaticAugmentations } from "../../../Augmentation/StaticAugmentations"; import { CONSTANTS } from "../../../Constants"; import { hasAugmentationPrereqs } from "../../../Faction/FactionHelpers"; import { LocationName } from "../../../Locations/data/LocationNames"; import { Locations } from "../../../Locations/Locations"; +import { PurchaseAugmentationsOrderSetting } from "../../../Settings/SettingEnums"; import { Settings } from "../../../Settings/Settings"; import { IMap } from "../../../types"; import { use } from "../../../ui/Context"; @@ -15,8 +16,8 @@ import { ConfirmationModal } from "../../../ui/React/ConfirmationModal"; import { Money } from "../../../ui/React/Money"; import { convertTimeMsToTimeElapsedString, formatNumber } from "../../../utils/StringHelperFunctions"; import { IPlayer } from "../../IPlayer"; -import { getGraftingAvailableAugs, calculateGraftingTimeWithBonus } from "../GraftingHelpers"; import { GraftableAugmentation } from "../GraftableAugmentation"; +import { calculateGraftingTimeWithBonus, getGraftingAvailableAugs } from "../GraftingHelpers"; const GraftableAugmentations: IMap = {}; @@ -69,6 +70,21 @@ export const GraftingRoot = (): React.ReactElement => { setRerender((old) => !old); } + const getAugsSorted = (): string[] => { + const augs = getGraftingAvailableAugs(player); + switch (Settings.PurchaseAugmentationsOrder) { + case PurchaseAugmentationsOrderSetting.Cost: + return augs.sort((a, b) => GraftableAugmentations[a].cost - GraftableAugmentations[b].cost); + default: + return augs; + } + }; + + const switchSortOrder = (newOrder: PurchaseAugmentationsOrderSetting): void => { + Settings.PurchaseAugmentationsOrder = newOrder; + rerender(); + }; + useEffect(() => { const id = setInterval(rerender, 200); return () => clearInterval(id); @@ -91,25 +107,33 @@ export const GraftingRoot = (): React.ReactElement => { - Graft Augmentations + + Graft Augmentations + + + + + {getGraftingAvailableAugs(player).length > 0 ? ( - + - {getGraftingAvailableAugs(player) - .sort((a, b) => GraftableAugmentations[a].cost - GraftableAugmentations[b].cost) - .map((k, i) => ( - setSelectedAug(k)} selected={selectedAug === k}> - - {k} - - - ))} + {getAugsSorted().map((k, i) => ( + setSelectedAug(k)} selected={selectedAug === k}> + + {k} + + + ))}