Skip to content

Commit

Permalink
fencing graphics
Browse files Browse the repository at this point in the history
  • Loading branch information
probablybenallen committed May 4, 2024
1 parent 170f2fb commit 7f3a001
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 1 deletion.
30 changes: 30 additions & 0 deletions bundle-src/schemas/control-rosesFencing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"type": "object",
"additionalProperties": false,
"properties": {
"scoreboard": {
"type": "object",
"additionalProperties": false,
"properties": {
"visible": {
"type": "boolean",
"default": false
}
},
"required": ["visible"]
},
"matchStatusPopup": {
"type": "object",
"additionalProperties": false,
"properties": {
"visible": {
"type": "boolean",
"default": false
}
},
"required": ["visible"]
}
},
"required": ["scoreboard", "matchStatusPopup"]
}
15 changes: 15 additions & 0 deletions bundle-src/src/common/types/control-rosesFencing.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* tslint:disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

export interface ControlRosesFencing {
scoreboard: {
visible: boolean;
};
matchStatusPopup: {
visible: boolean;
};
}
49 changes: 49 additions & 0 deletions bundle-src/src/dashboard/events/rosesFencing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { useOnlyReplicantValue, useReplicantValue } from "common/useReplicant";
import produce from "immer";

import type { State } from "@ystv/scores/src/common/sports/hockey";
import { Container, Title } from "@mantine/core";
import { LiveKillButtons } from "../components/liveKill";
import { ControlRosesFencing } from "common/types/control-rosesFencing";

export function RosesFencingDashboard() {
const state = useOnlyReplicantValue<State>("eventState");
const [control, setControl] = useReplicantValue<ControlRosesFencing>(
"control-rosesFencing"
);
console.log(control);
if (!state) {
return <b>No state...?!</b>;
}
if (!control) {
return <b>No control...?!</b>;
}

return (
<Container fluid>
<Title order={3}>Bout {state.segment}</Title>
<LiveKillButtons
name="Scoreboard"
live={control.scoreboard.visible}
callback={(live) =>
setControl(
produce(control, (val) => {
val.scoreboard.visible = live;
})
)
}
/>
<LiveKillButtons
name="Match Status Popup"
live={control.matchStatusPopup.visible}
callback={(live) =>
setControl(
produce(control, (val) => {
val.matchStatusPopup.visible = live;
})
)
}
/>
</Container>
);
}
2 changes: 2 additions & 0 deletions bundle-src/src/dashboard/index.dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { HockeyDashboard } from "./events/hockey";
import { SwimmingDashboard } from "./events/swimming";
import { KorfballDashboard } from "./events/korfball";
import { OctopushDashboard } from "./events/octopush";
import { RosesFencingDashboard } from "./events/rosesFencing";

const SportControllers: Record<string, React.ComponentType> = {
netball: NetballDashboard,
Expand All @@ -44,6 +45,7 @@ const SportControllers: Record<string, React.ComponentType> = {
swimming: SwimmingDashboard,
korfball: KorfballDashboard,
octopush: OctopushDashboard,
rosesFencing: RosesFencingDashboard,
};

function Dashboard() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ScoreboardProps {
isTimerShown: boolean;
quarter: number;
time: number;
quarterTitle?: string;
}

export function Scoreboard({
Expand All @@ -39,6 +40,7 @@ export function Scoreboard({
isTimerShown = false,
time = 0,
quarter = 1,
quarterTitle = "Q",
}: ScoreboardProps) {
const now = useTime();

Expand Down Expand Up @@ -77,7 +79,7 @@ export function Scoreboard({
score={awayScore}
/>
<NameBox
name={"Q" + quarter}
name={quarterTitle + quarter}
primaryColor="var(--ystv-dark)"
sheen={false}
/>
Expand Down
2 changes: 2 additions & 0 deletions bundle-src/src/graphics/index.graphics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { AllHockeyGraphics } from "./hockey";
import { AllSwimmingGraphics } from "./swimming";
import { AllKorfballGraphics } from "./korfball";
import { AllOctopushGraphics } from "./octopush";
import { AllRosesFencingGraphics } from "./rosesFencing";

const SportGraphics: Record<string, React.ComponentType> = {
netball: AllNetballGraphics,
Expand All @@ -43,6 +44,7 @@ const SportGraphics: Record<string, React.ComponentType> = {
swimming: AllSwimmingGraphics,
korfball: AllKorfballGraphics,
octopush: AllOctopushGraphics,
rosesFencing: AllRosesFencingGraphics,
};

function AllGraphics() {
Expand Down
62 changes: 62 additions & 0 deletions bundle-src/src/graphics/rosesFencing/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { useOnlyReplicantValue } from "common/useReplicant";
import type { State } from "@ystv/scores/src/common/sports/hockey";
import { ControlRosesFencing } from "../../common/types/control-rosesFencing";
import { GraphicContainer } from "../common/container";
import { Scoreboard } from "../americanFootball/Scoreboard/Scoreboard";
import { useTime } from "../hooks";
import { MatchStatusPopup } from "../common/matchStatusPopup";
import { EventMeta } from "@ystv/scores/src/common/types";

function bannerMsg(round: number) {
return `Bout ${round}`;
}

export function AllRosesFencingGraphics() {
const state = useOnlyReplicantValue<State & EventMeta>("eventState");
const control = useOnlyReplicantValue<ControlRosesFencing>("control-fencing");

const now = useTime();

if (!state || !control) {
return null;
}

return (
<>
<GraphicContainer>
<Scoreboard
homeName={state.homeTeam.abbreviation}
homePrimaryColor={state.homeTeam.primaryColour}
homeCrestAttachmentID={state.homeTeam.crestAttachmentID}
homeScore={state.scoreHome}
awayName={state.awayTeam.abbreviation}
awayPrimaryColor={state.awayTeam.primaryColour}
awaySecondaryColor={state.awayTeam.secondaryColour}
awayCrestAttachmentID={state.awayTeam.crestAttachmentID}
awayScore={state.scoreAway}
time={0}
isTimerShown={false}
isVisible={control.scoreboard.visible}
quarter={state.segment}
quarterTitle={"Bout"}
/>
</GraphicContainer>
<GraphicContainer>
{control.matchStatusPopup.visible && (
<MatchStatusPopup
homeName={state.homeTeam.abbreviation}
homePrimaryColor={state.homeTeam.primaryColour}
homeCrestAttachmentID={state.homeTeam.crestAttachmentID}
homeScore={state.scoreHome}
awayName={state.awayTeam.abbreviation}
awayPrimaryColor={state.awayTeam.primaryColour}
awaySecondaryColor={state.awayTeam.secondaryColour}
awayCrestAttachmentID={state.awayTeam.crestAttachmentID}
awayScore={state.scoreAway}
banner={bannerMsg(state.segment)}
/>
)}
</GraphicContainer>
</>
);
}

0 comments on commit 7f3a001

Please sign in to comment.