diff --git a/client/src/components/charts/ITGDensityChart.tsx b/client/src/components/charts/ITGDensityChart.tsx new file mode 100644 index 000000000..ef661effe --- /dev/null +++ b/client/src/components/charts/ITGDensityChart.tsx @@ -0,0 +1,78 @@ +import { ResponsiveLine, Serie } from "@nivo/line"; +import React from "react"; +import { COLOUR_SET } from "tachi-common"; +import ChartTooltip from "./ChartTooltip"; + +export default function ITGDensityChart({ + width = "100%", + height = "100%", + mobileHeight = "100%", + mobileWidth = width, + data, +}: { + mobileHeight?: number | string; + mobileWidth?: number | string; + width?: number | string; + height?: number | string; + data: Serie[]; +} & ResponsiveLine["props"]) { + const component = ( + `${npsToBPM(y)}BPM` }} + enablePoints={false} + useMesh={true} + enableGridX={false} + colors={COLOUR_SET.purple} + theme={{ + background: "none", + textColor: "#ffffff", + grid: { + line: { + stroke: "#1c1c1c", + strokeWidth: 1, + }, + }, + }} + curve="linear" + tooltip={d => ( + ( +
+ Measure {p.data.xFormatted}:{" "} + {npsToBPM(Number(p.data.yFormatted)).toFixed()}BPM +
+ )} + /> + )} + legends={[]} + enableArea + /> + ); + + return ( + <> +
+ {component} +
+
+ {component} +
+ + ); +} + +// Always assume 4/4 time. I know it sucks, but stepmania does the same. +function npsToBPM(nps: number) { + return (nps * 60) / 4; +} + +function bpmToNPS(bpm: number) { + return (bpm * 4) / 60; +} diff --git a/client/src/components/tables/cells/ITGDifficultyCell.tsx b/client/src/components/tables/cells/ITGDifficultyCell.tsx index e8f2f0eac..141dea326 100644 --- a/client/src/components/tables/cells/ITGDifficultyCell.tsx +++ b/client/src/components/tables/cells/ITGDifficultyCell.tsx @@ -40,7 +40,8 @@ export default function ITGDifficultyCell({ chart }: { chart: ChartDocument<"itg >
- {chart.data.difficultyTag}: {chart.level} + {chart.data.difficultyTag}: {chart.level} [{chart.data.displayBPM.toFixed()} + ]
{chart.data.charter} diff --git a/client/src/components/tables/dropdowns/GPTDropdownSettings.tsx b/client/src/components/tables/dropdowns/GPTDropdownSettings.tsx index 461de1a30..ea9a32037 100644 --- a/client/src/components/tables/dropdowns/GPTDropdownSettings.tsx +++ b/client/src/components/tables/dropdowns/GPTDropdownSettings.tsx @@ -2,6 +2,7 @@ import { Game } from "tachi-common"; import { Playtype } from "types/tachi"; import { BMSGraphsComponent } from "./components/BMSScoreDropdownParts"; import { IIDXGraphsComponent } from "./components/IIDXScoreDropdownParts"; +import { ITGGraphsComponent } from "./components/ITGScoreDropdownParts"; export function GPTDropdownSettings(game: Game, playtype: Playtype): any { if (game === "iidx") { @@ -16,6 +17,11 @@ export function GPTDropdownSettings(game: Game, playtype: Playtype): any { renderScoreInfo: true, GraphComponent: BMSGraphsComponent as any, }; + } else if (game === "itg") { + return { + renderScoreInfo: true, + GraphComponent: ITGGraphsComponent as any, + }; } return {}; diff --git a/client/src/components/tables/dropdowns/components/ITGScoreDropdownParts.tsx b/client/src/components/tables/dropdowns/components/ITGScoreDropdownParts.tsx new file mode 100644 index 000000000..624b5059f --- /dev/null +++ b/client/src/components/tables/dropdowns/components/ITGScoreDropdownParts.tsx @@ -0,0 +1,54 @@ +import ITGDensityChart from "components/charts/ITGDensityChart"; +import SelectNav from "components/util/SelectNav"; +import React, { useState } from "react"; +import { Nav } from "react-bootstrap"; +import { ChartDocument, PBScoreDocument, ScoreDocument } from "tachi-common"; + +export function ITGGraphsComponent({ + score, + chart, +}: { + score: ScoreDocument<"itg:Stamina"> | PBScoreDocument<"itg:Stamina">; + chart: ChartDocument<"itg:Stamina">; +}) { + const [graph, setGraph] = useState("DENSITY"); + + return ( + <> +
+ +
+
+ {chart.data.breakdown.npsPerMeasure ? ( + ({ + x: i, + y: e, + })), + }, + ]} + /> + ) : ( +
+ No chart graph :( +
+ )} +
+ + ); +} diff --git a/client/src/components/tables/headers/ChartHeader.tsx b/client/src/components/tables/headers/ChartHeader.tsx index c33ffaa5a..1530bf16f 100644 --- a/client/src/components/tables/headers/ChartHeader.tsx +++ b/client/src/components/tables/headers/ChartHeader.tsx @@ -29,6 +29,21 @@ export default function ChartHeader CascadingTierlistValue(chartGetter(k), "kt-HC", "kt-NC"); } else if (game === "bms" || game === "pms") { sortFn = k => CascadingTierlistValue(chartGetter(k), "sgl-HC", "sgl-EC"); + } else if (game === "itg") { + return [ + "Chart", + "Chart", + (a, b) => { + const ac = chartGetter(a) as ChartDocument<"itg:Stamina">; + const bc = chartGetter(b) as ChartDocument<"itg:Stamina">; + + if (ac.levelNum === bc.levelNum) { + return ac.data.displayBPM - bc.data.displayBPM; + } + + return ac.levelNum - bc.levelNum; + }, + ]; } return ["Chart", "Chart", NumericSOV(sortFn)];