Skip to content

Commit

Permalink
Merge branch 'main' into display-no-buffs-2
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon committed Oct 18, 2024
2 parents 09e8cda + dafda79 commit ca404df
Show file tree
Hide file tree
Showing 16 changed files with 347 additions and 186 deletions.
7 changes: 4 additions & 3 deletions locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"Distribution Template": "Distribution Template",
"Dual wielded": "Dual wielded",
"Effective Power": "Effective Power",
"Enable experimental multicore processing": "Enable experimental multicore processing",
"Enable experimental Rust/WebAssembly mode": "Enable experimental Rust/WebAssembly mode",
"Enable free WvW stat infusions": "Enable free WvW stat infusions",
"Enable heuristics": "Enable heuristics",
"Enhancement": "Enhancement",
Expand Down Expand Up @@ -126,6 +126,7 @@
"No Filtering": "No Filtering",
"None": "None",
"Note: Not cost optimized for >1 weapon set.": "Note: Not cost optimized for >1 weapon set.",
"Note: Some large calculations may take longer in Firefox for reasons that are currently unclear.": "Note: Some large calculations may take longer in Firefox for reasons that are currently unclear.",
"Nourishment": "Nourishment",
"Number of threads to use for calculations": "Number of threads to use for calculations",
"Okay": "Okay",
Expand Down Expand Up @@ -419,7 +420,7 @@
"buildTemplateName_Quickness Condi Berserker": "Quickness Condi Berserker",
"buildTemplateName_Quickness Condi Deadeye Spear": "Quickness Condi Deadeye Spear",
"buildTemplateName_Quickness Condi Harbinger": "Quickness Condi Harbinger",
"buildTemplateName_Quickness Condi Herald": "Quickness Condi Herald",
"buildTemplateName_Quickness Condi Herald SB M/A": "Quickness Condi Herald SB M/A",
"buildTemplateName_Quickness Condi Scrapper": "Quickness Condi Scrapper",
"buildTemplateName_Quickness Condi Untamed": "Quickness Condi Untamed",
"buildTemplateName_Quickness Power Berserker GS A/A": "Quickness Power Berserker GS A/A",
Expand Down Expand Up @@ -586,7 +587,7 @@
"preset_distribution_Condi Mechanist J-Drive (approx.)": "Condi Mechanist J-Drive (approx.)",
"preset_distribution_Condi Mechanist Jade Dynamo Pistol (approx.)": "Condi Mechanist Jade Dynamo Pistol (approx.)",
"preset_distribution_Condi Quickness Bers": "Condi Quickness Bers",
"preset_distribution_Condi Quickness Herald": "Condi Quickness Herald",
"preset_distribution_Condi Quickness Herald SB M/A": "Condi Quickness Herald SB M/A",
"preset_distribution_Condi Quickness Untamed": "Condi Quickness Untamed",
"preset_distribution_Condi Reaper Scepter": "Condi Reaper Scepter",
"preset_distribution_Condi Reaper Spear": "Condi Reaper Spear",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/presetdata/preset-distribution.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ list:
url: https://www.youtube.com/watch?v=DJtoo1abq9U
log: https://dps.report/rW1Q-20221202-011416_golem

- name: Condi Quickness Herald
- name: Condi Quickness Herald SB M/A
profession: Herald
value:
{
Expand Down
4 changes: 2 additions & 2 deletions src/assets/presetdata/templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,12 @@ list:
weaponType: Two-handed
outdated: false

- name: Quickness Condi Herald
- name: Quickness Condi Herald SB M/A
id: cherald-quick
specialization: Herald
boonType: Condi
priority: Condi Quickness Herald 0%
distribution: Condi Quickness Herald
distribution: Condi Quickness Herald SB M/A
traits: Condi Quickness Herald
extras: Condi Quickness Herald
weaponType: Two-handed
Expand Down
61 changes: 33 additions & 28 deletions src/components/nav/NavSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ import {
import type { TFunction } from 'i18next';
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { useSelector } from 'react-redux';
import { makeStyles } from 'tss-react/mui';
import { stopCalculationParallel } from '../../state/optimizer-parallel/calculate';
import { useAppDispatch } from '../../state/redux-hooks';
import SagaTypes from '../../state/sagas/sagaTypes';
import {
changeHeuristics,
changeHwThreads,
changeMulticore,
getDefaultHwThreads,
getHeuristics,
getHwThreads,
getHwThreadsString,
getMulticore,
getSelectedTemplate,
parseHwThreads,
} from '../../state/slices/controlsSlice';
import type { GameMode } from '../../state/slices/userSettings';
import {
Expand Down Expand Up @@ -69,7 +72,7 @@ export default function NavSettings({
} = {},
}: NavSettingsProps) {
const { t } = useTranslation();
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const { classes } = useStyles();

const { i18n } = useTranslation();
Expand All @@ -78,7 +81,8 @@ export default function NavSettings({
const expertMode = useSelector(getExpertMode);
const gameMode = useSelector(getGameMode);
const selectedTemplate = useSelector(getSelectedTemplate);
const hwThreads = useSelector(getHwThreads);
const hwThreadsString = useSelector(getHwThreadsString);
const defaultHwThreads = useSelector(getDefaultHwThreads);
const enableMulticore = useSelector(getMulticore);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand All @@ -98,6 +102,8 @@ export default function NavSettings({
localStorage.setItem(SETTINGS_STORAGE_KEY, settings);
}, [expertMode, gameMode, language]);

const { error: hwThreadsError } = parseHwThreads(hwThreadsString);

return (
<Settings maxWidth={400}>
<Typography variant="h6" sx={{ width: 300 }}>
Expand Down Expand Up @@ -159,6 +165,27 @@ export default function NavSettings({
{!threadingDisabled && (
<>
<Divider className={classes.divider} />

<TextField
label={t('Threads')}
helperText={t('Number of threads to use for calculations')}
placeholder={String(defaultHwThreads)}
size="small"
value={hwThreadsString}
error={hwThreadsError}
onChange={(e) => dispatch(changeHwThreads(e.target.value))}
slotProps={{
htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },
input: {
// used to always display the placeholder value instead of the label
// eslint-disable-next-line react/jsx-no-useless-fragment
startAdornment: <></>,
},
}}
/>

<Divider className={classes.divider} />

<FormControlLabel
control={
<Checkbox
Expand All @@ -175,32 +202,10 @@ export default function NavSettings({
}}
/>
}
label={t('Enable experimental multicore processing')}
sx={{ mb: 3 }}
label={t('Enable experimental Rust/WebAssembly mode')}
checked={enableMulticore}
/>

<TextField
label={t('Threads')}
helperText={t('Number of threads to use for calculations')}
size="small"
value={hwThreads}
onChange={(e) => {
const newHwThreads = e.target.value;

// only allow numbers
if (!newHwThreads.match(/^[0-9]*$/)) {
return;
}
// parse to int
const newHwThreadsInt = parseInt(newHwThreads, 10);

dispatch(changeHwThreads(newHwThreadsInt));
}}
slotProps={{
htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },
}}
/>
<FormControlLabel
control={
<Checkbox
Expand All @@ -211,7 +216,7 @@ export default function NavSettings({
/>
}
label={t('Enable heuristics')}
sx={{ mb: 3, display: 'none' }}
sx={{ display: 'none' }}
checked={enableHeuristics}
/>
</>
Expand Down
5 changes: 3 additions & 2 deletions src/components/sections/controls/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ErrorIcon from '@mui/icons-material/Error';
import HourglassEmptyIcon from '@mui/icons-material/HourglassEmpty';
import { Box, Button, Chip, Typography } from '@mui/material';
import { Trans, useTranslation } from 'react-i18next';
import { useDispatch, useSelector, useStore } from 'react-redux';
import { useSelector, useStore } from 'react-redux';
import { makeStyles } from 'tss-react/mui';
import {
calculateParallel,
Expand All @@ -20,6 +20,7 @@ import {
SUCCESS,
WAITING,
} from '../../../state/optimizer/status';
import { useAppDispatch } from '../../../state/redux-hooks';
import SagaTypes from '../../../state/sagas/sagaTypes';
import {
changeError,
Expand Down Expand Up @@ -52,7 +53,7 @@ const useStyles = makeStyles()((theme) => ({

const ControlsBox = () => {
const { classes, cx } = useStyles();
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const { t } = useTranslation();
const store = useStore();

Expand Down
15 changes: 12 additions & 3 deletions src/pages/index/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import BackgroundImage from '../../components/baseComponents/BackgroundImage';
import ErrorBoundary from '../../components/baseComponents/ErrorBoundary';
import Layout from '../../components/baseComponents/Layout';
import URLStateImport from '../../components/url-state/URLStateImport';
import { isFirefox } from '../../state/optimizer/detectFirefox';
import SagaTypes from '../../state/sagas/sagaTypes';
import { getMulticore } from '../../state/slices/controlsSlice';
import { getGameMode } from '../../state/slices/userSettings';
Expand All @@ -22,7 +23,7 @@ const IndexPage = () => {
const gameMode = useSelector(getGameMode);
const multicore = useSelector(getMulticore);

const [alertOpen, setAlertOpen] = React.useState([true, true]);
const [alertOpen, setAlertOpen] = React.useState([true, true, true]);

const ALERTS = [
<Trans>
Expand Down Expand Up @@ -53,6 +54,14 @@ const IndexPage = () => {
</Link>
.
</Trans>,
...(isFirefox
? [
<Trans>
Note: Some large calculations may take longer in Firefox for reasons that are currently
unclear.
</Trans>,
]
: []),
];

return (
Expand Down Expand Up @@ -100,8 +109,8 @@ const IndexPage = () => {
{multicore && (
<Alert severity="error" sx={{ marginBottom: 2 }}>
<Typography variant="body2" sx={{ marginBottom: '16px' }}>
You have selected the experimental multicore mode. This mode is still in development
and may cause issues. Please report any issues in the Discretize{' '}
You have selected the experimental Rust/WebAssembly mode. This mode is still in
development and may cause issues. Please report any issues in the Discretize{' '}
<Link href="https://discord.gg/Qdt7nFY" target="_blank" rel="noopener">
Discord
</Link>
Expand Down
5 changes: 3 additions & 2 deletions src/state/optimizer-parallel/calculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
changeProgress,
changeStatus,
getHeuristics,
getHwThreads,
} from '../slices/controlsSlice';
import type { AppDispatch, RootState } from '../store';
import runCalcHeuristics from './modes/heuristics';
Expand All @@ -20,7 +21,7 @@ const createdWorkers: WorkerWrapper[] = [];

const createWorker = (): WorkerWrapper => ({
status: 'idle',
worker: new Worker(new URL('./worker/worker.ts', import.meta.url), { type: 'module' }),
worker: new Worker(new URL('./worker/worker.ts', import.meta.url)),
});

const terminateActiveWorkers = () => {
Expand All @@ -33,7 +34,7 @@ const terminateActiveWorkers = () => {
};

export function calculateParallel(reduxState: RootState, dispatch: AppDispatch): WorkerWrapper[] {
const selectedMaxThreads = reduxState.optimizer.control.hwThreads;
const selectedMaxThreads = getHwThreads(reduxState);

dispatch(changeList([]));
dispatch(
Expand Down
2 changes: 2 additions & 0 deletions src/state/optimizer/detectFirefox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* eslint-disable import/prefer-default-export */
export const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
Loading

0 comments on commit ca404df

Please sign in to comment.