Skip to content

Commit

Permalink
small overlay ui fixes for ioi contests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kostya Bats committed Nov 30, 2023
1 parent 693c81d commit 7c45cce
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
11 changes: 6 additions & 5 deletions src/frontend/overlay/src/components/atoms/ContestLabels.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {memo} from "react";
import React, { memo } from "react";
import styled from "styled-components";
import c from "../../config";
import { isShouldUseDarkColor } from "../../utils/colors";
Expand All @@ -10,7 +10,7 @@ import {
getStatus,
getTeamTaskColor,
} from "../../utils/statusInfo";
import {formatScore} from "../../services/displayUtils";
import { formatScore } from "../../services/displayUtils";

const VerdictLabel = styled(ShrinkingBox)`
background-color: ${({ color }) => color};
Expand All @@ -36,18 +36,19 @@ const getIOIScoreText = (difference) => {
return ["=", c.VERDICT_UNKNOWN];
};

const IOIVerdictLabel = ({ runResult: { wrongVerdict, difference }}) => {
const IOIVerdictLabel = ({ runResult: { wrongVerdict, difference }, ...props }) => {
const [diffText, diffColor] = getIOIScoreText(difference);
return <>
{wrongVerdict !== undefined && <ShrinkingBox text={wrongVerdict ?? "??"} color={c.VERDICT_NOK}/>}
{wrongVerdict === undefined && <ShrinkingBox text={diffText ?? "??"} color={diffColor}/>}
{wrongVerdict !== undefined && <VerdictLabel text={wrongVerdict ?? "??"} color={c.VERDICT_NOK} align="center" {...props}/>}
{wrongVerdict === undefined && <VerdictLabel text={diffText ?? "??"} color={diffColor} align="center" {...props}/>}
</>;
};

const VerdictLabel2 = ({ runResult, ...props }) => {
return <>
{runResult.type === "ICPC" && <ICPCVerdictLabel runResult={runResult} {...props}/>}
{runResult.type === "IOI" && <IOIVerdictLabel runResult={runResult} {...props}/>}
{/*{runResult.type === "IOI" && <VerdictLabel text={"AA" ?? "??"} color="red" align="center" {...props}/>}*/}
</>;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, {useEffect, useLayoutEffect, useRef} from "react";
import React, { useEffect, useLayoutEffect, useRef } from "react";
import { ContestantViewCorner } from "../../molecules/info/ContestantViewCorner";
import styled from "styled-components";
import {useDispatch} from "react-redux";
import {pushLog} from "../../../redux/debug";
import {GrabberPlayerClient} from "../../../utils/grabber/grabber_player";
import { useDispatch } from "react-redux";
import { pushLog } from "../../../redux/debug";
import { GrabberPlayerClient } from "../../../utils/grabber/grabber_player";

export const TeamImageWrapper = styled.img`
border-radius: ${({ borderRadius }) => borderRadius};
Expand Down Expand Up @@ -132,7 +132,6 @@ const teamViewComponentRender = {
TaskStatus: ({ onLoadStatus, hasPInP, ...props }) => {
useLayoutEffect(() => onLoadStatus(true),
[]);
console.log(props.teamId);
return <ContestantViewHolderCorner hasPInP={hasPInP} {...props}/>;
},
Photo: ({ onLoadStatus, url, className }) => {
Expand Down Expand Up @@ -180,8 +179,7 @@ export const AchievementWrapper = styled.div`
height: 100%;
`;

export const Achievement = ({src, onLoadStatus, className}) => {
console.log(src)
export const Achievement = ({ src, onLoadStatus, className }) => {
return <AchievementWrapper className={className}>
<TeamImageWrapper src={src} onLoad={() => onLoadStatus(true)}/>
</AchievementWrapper>;
Expand All @@ -195,7 +193,7 @@ export const ContestantViewHolder = ({ onLoadStatus, media, isSmall, hasPInP, cl
return null;
}
if (!media.isMedia && media.type === "Photo") {
return <Achievement src={media.url} onLoadStatus={onLoadStatus} className={className}/>
return <Achievement src={media.url} onLoadStatus={onLoadStatus} className={className}/>;
}
return <Component onLoadStatus={onLoadStatus} isSmall={isSmall} hasPInP={hasPInP} {...media} className={className}/>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useSelector } from "react-redux";
import styled from "styled-components";
import c from "../../../config";
import { ProblemLabel } from "../../atoms/ProblemLabel";
// import { extractScoreboardRows, useScroller } from "./Scoreboard";
import { TaskResultLabel, RankLabel } from "../../atoms/ContestLabels";
import { ShrinkingBox } from "../../atoms/ShrinkingBox";

Expand Down Expand Up @@ -67,7 +66,7 @@ const ScoreboardTableRowWrap = styled.div`
${c.SCOREBOARD_CELL_PLACE_SIZE}
${c.SCOREBOARD_CELL_TEAMNAME_SIZE}
${c.SCOREBOARD_CELL_POINTS_SIZE}
${c.SCOREBOARD_CELL_PENALTY_SIZE}
${({ needPenalty }) => needPenalty ? c.SCOREBOARD_CELL_PENALTY_SIZE : ""}
repeat(${props => props.nProblems}, 1fr);
`;

Expand Down Expand Up @@ -111,7 +110,7 @@ export const ScoreboardRow = ({ teamId, hideTasks, optimismLevel }) => {
const teamData = useSelector((state) => state.contestInfo.info?.teamsId[teamId]);
const needPenalty = useNeedPenalty();
const formatPenalty = useFormatPenalty();
return <ScoreboardRowWrap medal={scoreboardData?.medalType} nProblems={contestData?.problems?.length ?? 1}>
return <ScoreboardRowWrap medal={scoreboardData?.medalType} nProblems={contestData?.problems?.length ?? 1} needPenalty={needPenalty}>
<ScoreboardRankLabel rank={scoreboardData?.rank} medal={scoreboardData?.medalType}/>
<ScoreboardRowName align={c.SCOREBOARD_CELL_TEAMNANE_ALIGN} text={teamData?.shortName ?? "??"}/>
<ShrinkingBox align={c.SCOREBOARD_CELL_POINTS_ALIGN}
Expand Down Expand Up @@ -231,7 +230,7 @@ const ScoreboardProblemLabel = styled(ProblemLabel)`
const ScoreboardTableHeader = () => {
const problems = useSelector((state) => state.contestInfo.info?.problems);
const needPenalty = useNeedPenalty();
return <ScoreboardTableHeaderWrap nProblems={problems?.length ?? 1}>
return <ScoreboardTableHeaderWrap nProblems={problems?.length ?? 1} needPenalty={needPenalty}>
<ScoreboardTableHeaderCell>#</ScoreboardTableHeaderCell>
<ScoreboardTableHeaderNameCell>Name</ScoreboardTableHeaderNameCell>
<ScoreboardTableHeaderCell>Σ</ScoreboardTableHeaderCell>
Expand Down
8 changes: 4 additions & 4 deletions src/frontend/overlay/src/services/displayUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import c from "../config";
import {useSelector} from "react-redux";
import {useCallback} from "react";
import { useSelector } from "react-redux";
import { useCallback } from "react";

export const formatScore = (score, digits = 2) => {
if (score === undefined) {
Expand All @@ -23,7 +23,7 @@ export const useFormatPenalty = () => {
return Math.floor(penalty / 60);
}
}, [mode]);
}
};
export const useNeedPenalty = () => {
return usePenaltyRoundingMode() !== "zero";
};
};
2 changes: 1 addition & 1 deletion src/frontend/overlay/src/utils/statusInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const TeamTaskColor = Object.freeze({

export const getTeamTaskColor = (score, minScore, maxScore) => {
if (score === undefined) {
return c.CELL_BG_COLOR;
return undefined;
}
if (minScore !== undefined && maxScore !== undefined) {
const [minRed, minGreen, minBlue] = [203, 46, 40];
Expand Down

0 comments on commit 7c45cce

Please sign in to comment.