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

feat: showcase spd stat customization & main/sub dps selector #862

Merged
merged 11 commits into from
Jan 21, 2025
Prev Previous commit
Next Next commit
feat: sidebar dps role selector, fix tests
  • Loading branch information
fribbels committed Jan 21, 2025
commit 0b42cedeeeeefcaac6150d8a097252c4fd276f98
29 changes: 20 additions & 9 deletions src/lib/characterPreview/ShowcaseCustomizationSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CameraOutlined, DownloadOutlined, MoonOutlined, SettingOutlined, SunOut
import { Button, ColorPicker, Flex, Segmented, ThemeConfig } from 'antd'
import { AggregationColor } from 'antd/es/color-picker/color'
import { GlobalToken } from 'antd/lib/theme/interface'
import { usePublish } from 'hooks/usePublish'
import { DEFAULT_SHOWCASE_COLOR, editShowcasePreferences } from 'lib/characterPreview/showcaseCustomizationController'
import { ShowcaseColorMode, Stats } from 'lib/constants/constants'
import { SavedSessionKeys } from 'lib/constants/constantsSession'
Expand Down Expand Up @@ -50,13 +51,14 @@ export const ShowcaseCustomizationSidebar = forwardRef<ShowcaseCustomizationSide
} = props

const { t } = useTranslation('charactersTab', { keyPrefix: 'CharacterPreview.CustomizationSidebar' })
const pubRefreshRelicsScore = usePublish()
const [colors, setColors] = useState<string[]>([])
const globalShowcasePreferences = window.store((s) => s.showcasePreferences)
const setGlobalShowcasePreferences = window.store((s) => s.setShowcasePreferences)
const [loading, setLoading] = useState<boolean>(false)
const showcaseDarkMode = window.store((s) => s.savedSession.showcaseDarkMode)
const showcasePreciseSpd = window.store((s) => s.savedSession.showcasePreciseSpd)
const spdValue = window.store((s) => s.scoringMetadataOverrides[characterId].stats[Stats.SPD])
const spdValue = window.store((s) => DB.getScoringMetadata(characterId).stats[Stats.SPD])

useImperativeHandle(ref, () => ({
onPortraitLoad: (img: string, characterId: string) => {
Expand Down Expand Up @@ -127,18 +129,27 @@ export const ShowcaseCustomizationSidebar = forwardRef<ShowcaseCustomizationSide
console.log('Set spd value to', spdValue)

const scoringMetadata = TsUtils.clone(DB.getScoringMetadata(characterId))
const defaultScoringMetadata = TsUtils.clone(DB.getMetadata().characters[characterId].scoringMetadata)

scoringMetadata.stats[Stats.SPD] = spdValue

DB.updateCharacterScoreOverrides(characterId, scoringMetadata)
pubRefreshRelicsScore('refreshRelicsScore', 'null')
}

function onTraceClick() {
window.store.getState().setStatTracesDrawerFocusCharacter(characterId)
window.store.getState().setStatTracesDrawerOpen(true)
}

function onShowcasePrimaryDpsChange(primary: boolean) {
console.log('Set primary dps to', primary)

const scoringMetadata = TsUtils.clone(DB.getScoringMetadata(characterId))
if (scoringMetadata.simulation) {
scoringMetadata.simulation.subDps = !primary
DB.updateCharacterScoreOverrides(characterId, scoringMetadata)
}
}

const presets = [
{
label: t('PaletteLabel'),
Expand Down Expand Up @@ -200,7 +211,7 @@ export const ShowcaseCustomizationSidebar = forwardRef<ShowcaseCustomizationSide
<HorizontalDivider/>

<HeaderText style={{ textAlign: 'center', marginBottom: 2 }}>
SPD value
SPD weight
</HeaderText>

<Segmented
Expand All @@ -216,17 +227,17 @@ export const ShowcaseCustomizationSidebar = forwardRef<ShowcaseCustomizationSide
<HorizontalDivider/>

<HeaderText style={{ textAlign: 'center', marginBottom: 2 }}>
Targeted buffs
DPS role
</HeaderText>

<Segmented
options={[
{ value: false, label: 'Yes' },
{ value: true, label: 'No' },
{ value: false, label: 'Main' },
{ value: true, label: 'Sub' },
]}
block
value={showcasePreciseSpd}
onChange={onShowcasePreciseSpdChange}
onChange={onShowcasePrimaryDpsChange}
/>
</Flex>

Expand Down Expand Up @@ -319,7 +330,7 @@ function clipboardClicked(elementId: string, action: string, setLoading: (b: boo

const shadow = 'rgba(0, 0, 0, 0.25) 0px 0.0625em 0.0625em, rgba(0, 0, 0, 0.25) 0px 0.125em 0.5em, rgba(255, 255, 255, 0.15) 0px 0px 0px 1px inset'

const STANDARD_COLOR = '#2d58b6'
const STANDARD_COLOR = '#628ae9'

export function standardShowcasePreferences() {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ body,
}

#relicGrid .ag-header {
height: 36px !important;
min-height: 36px !important;
height: 48px !important;
min-height: 48px !important;
}

.ag-header-cell-label .ag-header-cell-text {
Expand Down
1 change: 1 addition & 0 deletions src/types/metadata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type SimulationMetadata = {
}
substats: string[]
errRopeEidolon?: number
subDps?: boolean
comboAbilities: string[]
comboDot: number
comboBreak: number
Expand Down