Skip to content

Commit

Permalink
Add confetti and champions overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
zusorio committed Sep 3, 2023
1 parent 30d1285 commit 7f8bbe3
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 4 deletions.
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"spacetime-informal": "^0.6.1",
"timesync": "^1.0.11",
"vue": "^2.7",
"vue-confetti": "^2.3.0",
"vue-cookies": "^1.8.1",
"vue-meta": "^2.4.0",
"vue-router": "^3.2.0",
Expand Down
7 changes: 5 additions & 2 deletions website/src/apps/BroadcastApp.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<StingerWrap :theme="broadcast.event && broadcast.event.theme" :active="active" :should-use="useBuiltInStingers" :text="stingerText">
<StingerWrap :theme="stingerThemeOverride && overrideTheme || broadcast.event && broadcast.event.theme" :active="active" :should-use="useBuiltInStingers" :text="stingerText">
<div class="broadcast-app" :class="broadcastClass">
<!-- <div style="font-size: 5em; color: black">{{ $root.activeScene }}</div>-->
<router-view id="overlay" :class="bodyClass" :broadcast="broadcast" :client="client" :title="title" :top="top" :active="active"
Expand Down Expand Up @@ -36,7 +36,7 @@ function getComponentName(route) {
export default {
name: "BroadcastApp",
props: ["id", "title", "top", "code", "client", "noAnimation", "noStinger", "bodyClass", "full", "clientName", "backgroundIndex", "stingerText"],
props: ["id", "title", "top", "code", "client", "noAnimation", "noStinger", "bodyClass", "full", "clientName", "backgroundIndex", "stingerText", "stingerThemeOverride"],
components: {
BroadcastBackground,
StingerWrap
Expand Down Expand Up @@ -81,6 +81,9 @@ export default {
}
return broadcast;
},
overrideTheme() {
return ReactiveRoot(this.stingerThemeOverride);
},
haltAnimations() {
return this.noAnimation || (this.broadcast?.broadcast_settings || []).includes("No animations");
},
Expand Down
4 changes: 2 additions & 2 deletions website/src/apps/ClientApp.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<BroadcastApp v-if="broadcastID" :id="broadcastID" :title="title" :client="_client" :no-animation="noAnimation"
:no-stinger="noStinger" :body-class="bodyClass" :full="full" :clientName="client" :background-index="backgroundIndex" :stinger-text="stingerText" />
:no-stinger="noStinger" :body-class="bodyClass" :full="full" :clientName="client" :background-index="backgroundIndex" :stinger-text="stingerText" :stingerThemeOverride="stingerThemeOverride" />
</template>

<script>
Expand All @@ -9,7 +9,7 @@ import { ReactiveRoot, ReactiveThing } from "@/utils/reactive";
export default {
name: "ClientApp",
components: { BroadcastApp },
props: ["client", "title", "noAnimation", "noStinger", "bodyClass", "full", "backgroundIndex", "stingerText"],
props: ["client", "title", "noAnimation", "noStinger", "bodyClass", "full", "backgroundIndex", "stingerText", "stingerThemeOverride"],
computed: {
_client() {
return ReactiveRoot(`client-${this.client}`, {
Expand Down
4 changes: 4 additions & 0 deletions website/src/components/broadcast/StingerWrap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export default {
updateTheme(theme) {
this.customTheme = theme;
console.log("custom stinger theme", theme);
},
updateText(text) {
this.customText = text;
console.log("custom stinger text", text);
}
}
};
Expand Down
54 changes: 54 additions & 0 deletions website/src/components/broadcast/roots/ChampionsOverlay.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<template>
<ConfettiOverlay v-if="winner" :theme="winner?.theme"/>
</template>

<script>
import ConfettiOverlay from "@/components/broadcast/roots/ConfettiOverlay.vue";
import { ReactiveArray, ReactiveRoot, ReactiveThing } from "@/utils/reactive";
export default {
components: { ConfettiOverlay },
props: ["broadcast", "stingerText"],
name: "ChampionsOverlay",
data: () => ({
confettiStarted: false,
prodData: {
minor: true
}
}),
mounted() {
console.log(this.stingerText);
this.$parent.updateText(this.stingerText || "Winners");
},
computed: {
match() {
if (!this.broadcast?.live_match?.length) return null;
return ReactiveRoot(this.broadcast?.live_match?.[0], {
teams: ReactiveArray("teams", {
theme: ReactiveThing("theme")
})
});
},
winner() {
if (!this.match) return null;
if (!(this.match.first_to && [this.match.score_1, this.match.score_2].some(s => s === this.match.first_to))) return null;
return this.match.teams[this.match.score_1 === this.match.first_to ? 0 : 1];
}
},
watch: {
winner: {
deep: true,
handler(winner) {
console.log("winner change", this.$parent);
this.$parent.updateTheme(winner?.theme);
}
}
},
metaInfo() {
return {
title: `Champions | ${this.broadcast?.code || this.broadcast?.name || ""}`
};
}
};
</script>
67 changes: 67 additions & 0 deletions website/src/components/broadcast/roots/ConfettiOverlay.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<script>
import VueConfetti from "vue-confetti";
import { ReactiveRoot } from "@/utils/reactive";
import Vue from "vue";
Vue.use(VueConfetti);
export default {
props: ["themeId", "theme"],
name: "ConfettiOverlay",
data: () => ({
confettiStarted: false,
noStinger: true,
prodData: {
minor: true
}
}),
watch: {
confettiColors: {
handler() {
if (this.confettiColors.length === 0) return;
if (!this.confettiStarted) {
this.$confetti.start({
particles: [
{
type: "circle"
}
],
defaultColors: this.confettiColors
});
this.confettiStarted = true;
} else {
this.$confetti.update({
particles: [
{
type: "circle"
}
],
defaultColors: this.confettiColors
});
}
},
immediate: true
}
},
computed: {
themeData() {
return this.theme || ReactiveRoot(this.themeId);
},
confettiColors() {
return Array.from(new Set(
[this.themeData?.color_theme, this.themeData?.color_logo_background, this.themeData?.color_logo_accent]
.filter(
Boolean
)));
}
},
metaInfo() {
return {
title: `Confetti | ${this.broadcast?.code || this.broadcast?.name || ""}`
};
}
};
</script>
<style scoped>
</style>
14 changes: 14 additions & 0 deletions website/src/router/broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,20 @@ export default [
index: parseInt(route.params.index) || parseInt(route.query.index ?? route.query.number) || 1
})
},
{
path: "confetti",
component: () => import("@/components/broadcast/roots/ConfettiOverlay.vue"),
props: route => ({
themeId: route.query.theme || route.query.themeId || route.query.themeid || route.query.themeID
})
},
{
path: "champions",
component: () => import("@/components/broadcast/roots/ChampionsOverlay.vue"),
props: route => ({
stingerText: route.query.stingerText
})
},

/* Production staff stuff */
{ path: "clock", component: () => import("@/components/broadcast/roots/MediaClock.vue") },
Expand Down
2 changes: 2 additions & 0 deletions website/src/router/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default [
code: route.params.broadcastCode,
title: route.query.title,
stingerText: route.query.stingerText,
stingerThemeOverride: route.query.stingerThemeOverride || route.query.stingerTheme,
top: route.query.top,
noAnimation: (route.query.noAnimate || route.query.dontAnimate || route.query.noAnimation),
noStinger: (route.query.noStinger || route.query.stinger === "false"),
Expand All @@ -88,6 +89,7 @@ export default [
client: route.params.clientID,
title: route.query.title,
stingerText: route.query.stingerText,
stingerThemeOverride: route.query.stingerThemeOverride || route.query.stingerTheme,
noAnimation: (route.query.noAnimate || route.query.dontAnimate || route.query.noAnimation),
noStinger: (route.query.noStinger || route.query.stinger === "false"),
bodyClass: route.query.class || route.query.bodyClass,
Expand Down

0 comments on commit 7f8bbe3

Please sign in to comment.