Skip to content

Commit

Permalink
Add solo map wins
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Apr 29, 2023
1 parent b53f0db commit 1022e79
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 14 deletions.
5 changes: 3 additions & 2 deletions website/src/components/broadcast/SoloControlButton.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="control-button d-flex flex-column" v-bind:class="elClass" @click="() => click && click()" :style="css">
<div class="control-button d-flex flex-column" v-bind:class="elClass" @click="() => click && !noclick && click()" :style="css">
<span class="icon" v-if="icon"><i :class="icon"></i></span>
<span class="slot"><slot></slot></span>
</div>
Expand Down Expand Up @@ -75,7 +75,8 @@ export default {
background-color: white;
}
.control-button:not(.noclick):hover {
opacity: 1;
/* this fixes a bug for some reason */
opacity: 0.99;
}
.control-button.control-slice {
Expand Down
27 changes: 25 additions & 2 deletions website/src/components/broadcast/SoloMapButton.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<SoloControlButton class="map-button" :click="() => click()" :style="bg" :noclick="noclick">
<SoloControlButton class="map-button" :click="() => click()" :noclick="noclick" :class="{'has-gel': !!teamGel}">
<div class="bg" :style="bg"></div>
<div class="team-gel" v-if="teamGel" :style="teamGelBG"></div>
<div class="top flex-center" v-if="topText">
<div class="text top-text">{{ topText }}</div>
</div>
Expand All @@ -10,17 +12,21 @@
<script>
import SoloControlButton from "@/components/broadcast/SoloControlButton";
import { resizedImage } from "@/utils/images";
import { logoBackground } from "@/utils/theme-styles";
export default {
name: "SoloMapButton",
components: { SoloControlButton },
props: ["map", "click", "topText", "noclick"],
props: ["map", "click", "topText", "noclick", "teamGel"],
computed: {
bg() {
console.log("Map BG", this.map);
if (!this.map?.image) return {};
return resizedImage(this.map, ["image"], "h-200");
},
teamGelBG() {
return this.teamGel && logoBackground(this.teamGel);
},
text() {
return this.map?.short_name || "Choose map";
}
Expand Down Expand Up @@ -49,4 +55,21 @@ export default {
width: 100%;
padding-top: 15px;
}
.team-gel, .bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.bg {
z-index: -2;
}
.map-button.has-gel .bg {
filter: grayscale(1);
}
.team-gel {
z-index: -1;
opacity: 0.4;
}
</style>
99 changes: 99 additions & 0 deletions website/src/components/broadcast/SoloMapToggleButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<template>
<SoloControlButton class="map-button" :click="() => click()" :style="bg" :noclick="noclick">
<div class="top flex-center" v-if="topText">
<div class="text top-text">{{ topText }}</div>
</div>

<div class="selection-box" v-if="!noclick">
<div class="box empty" :class="{'active': !current}">
No winner
</div>
<div class="box team" v-for="(team, i) in teams" :key="team?.id" :class="{'active': current === `team-${i+1}`}">
<div class="team-code w-100" :style="themeBackground1(team)">{{ team?.code }}</div>
</div>
<div class="box draw" :class="{'active': current === 'draw'}">
<div class="draw-text">DRAW</div>
</div>
</div>
</SoloControlButton>
</template>

<script>
import SoloControlButton from "@/components/broadcast/SoloControlButton";
import { resizedImage } from "@/utils/images";
import { themeBackground1 } from "@/utils/theme-styles";
export default {
name: "SoloMapToggleButton",
methods: { themeBackground1 },
components: { SoloControlButton },
props: ["map", "click", "topText", "noclick", "current", "teams"],
computed: {
bg() {
console.log("Map BG", this.map);
if (!this.map?.image) return {};
return resizedImage(this.map, ["image"], "h-200");
},
text() {
return this.current;
}
}
};
</script>
<style scoped>
.map-button {
color: white !important;
background-size: cover;
background-position: center;
font-size: 2em;
justify-content: flex-end;
padding-bottom: 15px;
position: relative;
}
.map-button >>> div.text {
background-color: rgba(0,0,0,0.8);
padding: 3px 8px;
}
.top {
position: absolute;
top: 0;
left: 0;
width: 100%;
padding-top: 15px;
}
.selection-box {
display: flex;
background-color: rgba(0,0,0,0.8);
flex-direction: column;
}
.selection-box, .box {
border: 1px solid rgba(0,0,0,0.5);
}
.box {
width: 100%;
height: 26px;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
font-size: 20px;
opacity: 0.3;
}
.box.active {
border-color: white;
background-color: rgba(255,255,255,0.5);
opacity: 1;
}
.selection-box {
width: 160px;
}
.box.draw, .box.empty {
font-size: 13px;
}
</style>
75 changes: 65 additions & 10 deletions website/src/components/broadcast/SoloOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@


<div class="solo-part solo--controls">
<div class="solo-pixel-info">200px</div>
<div class="solo-pixel-info">200px / {{ controlMode }}</div>
<!-- <div class="solo-pixel-info d-flex">{{ controlMode }}</div>-->
<div class="control-group" v-if="controlMode === 'default'">
<SoloControlButton noclick left rotate>SLMN.GG</SoloControlButton>
<SoloControlButton icon="fas fa-exchange" color="#f22cf2" :click="() => flipTeams()">Flip teams</SoloControlButton>
<SoloControlButton icon="fas fa-users" :color="teams[0] && teams[0].id ? '#2cd1f2' : ''" :click="() => controlMode = 'set-team-1'">Set Team 1</SoloControlButton>
<SoloControlButton icon="far fa-users" :color="teams[1] && teams[1].id ? '#2cd1f2' : ''" :click="() => controlMode = 'set-team-2'">Set Team 2</SoloControlButton>
<SoloControlButton icon="fas fa-medal" color="#f22cf2" :click="() => controlMode = 'set-scores'">Set Scores</SoloControlButton>
<SoloControlButton icon="fas fa-align-center" :color="middle ? '#2cd1f2' : ''" :click="() => controlMode = 'set-middle'">Set Middle</SoloControlButton>
<SoloControlButton v-if="showModule('break')" icon="far fa-snooze" :click="() => controlMode = 'set-break'">Break</SoloControlButton>
<SoloControlButton icon="fas fa-align-center" :color="middle ? '#2cd1f2' : ''" :click="() => controlMode = 'set-middle'">Middle</SoloControlButton>
<SoloControlButton icon="fas fa-medal" color="#f22cf2" :click="() => controlMode = 'set-scores'">Scores</SoloControlButton>
<SoloControlButton icon="fas fa-map-marked-alt" color="#f22cf2" :click="() => controlMode = 'set-maps'" v-if="showModule('overview')">Maps & Winners</SoloControlButton>
<SoloControlButton v-if="showModule('break')" :color="!breakEnd ? '#f22cf2' : '#2cd1f2'" icon="far fa-snooze" :click="() => controlMode = 'set-break'">Break</SoloControlButton>

<SoloControlButton icon="fas fa-map-marked-alt" color="#f22cf2" :click="() => controlMode = 'set-maps'" v-if="showModule('overview')">Set Maps</SoloControlButton>

<div class="spacer"></div>
<!-- <SoloControlButton icon="fas fa-wrench" color="#f22cf2" :click="() => controlMode = 'set-options'">Match Options</SoloControlButton>-->
Expand Down Expand Up @@ -104,9 +104,23 @@
<div class="control-group" v-if="controlMode === 'set-maps'">
<SoloControlButton left rotate :click="() => controlMode = 'default'">Menu</SoloControlButton>

<SoloMapButton v-for="num in mapNums" :key="num" :click="() => chooseMap(num)" :noclick="num !== 0 && !maps[Math.max(0,num - 1)]?.name" :map="maps[num]" :top-text="`Map ${num + 1}`"></SoloMapButton>
<SoloMapButton v-for="num in mapNums" :key="num" :click="() => chooseMap(num)" :noclick="num !== 0 && !maps[Math.max(0,num - 1)]?.name"
:map="maps[num]" :top-text="`Map ${num + 1}`" :team-gel="mapWinners[num] === 'team-1' ? teams[0]?.theme : (mapWinners[num] === 'team-2'? teams[1]?.theme : null)"></SoloMapButton>

<div class="spacer"></div>
<SoloControlButton icon="fas fa-trophy" style="font-size: 2.5em" color="#f17a2c" :click="() => controlMode = 'set-map-winners'">Set Winners</SoloControlButton>
<SoloControlButton noclick right rotate>SLMN.GG</SoloControlButton>
</div>
<div class="control-group" v-if="controlMode === 'set-map-winners'">
<SoloControlButton left rotate :click="() => controlMode = 'default'">Menu</SoloControlButton>

<SoloMapToggleButton v-for="num in mapNums" :key="num" :click="() => toggleMapWinner(num)"
:teams="teams" :map="maps[num]" :noclick="num !== 0 && !maps[Math.max(0,num - 1)]?.name"
:top-text="maps[num]?.short_name || `Map ${num + 1}`" :current="mapWinners[num]">
</SoloMapToggleButton>

<div class="spacer"></div>
<SoloControlButton icon="fas fa-map-marked-alt" style="font-size: 2.5em" :click="() => controlMode = 'set-maps'">Set<br>Maps</SoloControlButton>
<SoloControlButton noclick right rotate>SLMN.GG</SoloControlButton>
</div>
<div class="control-group" v-if="controlMode === 'set-map'">
Expand All @@ -120,7 +134,7 @@
</div>

<div class="control-group" v-if="controlMode === 'choose-map'">
<SoloControlButton left rotate :click="() => controlMode = 'set-maps'" color="#f0802c">Maps</SoloControlButton>
<SoloControlButton left rotate :click="() => controlMode = 'set-maps'" color="#f0a02c">Maps</SoloControlButton>
<SoloControlButton noclick>Map {{ controllingMapNum + 1 }} <small>{{ maps[controllingMapNum]._type || maps[controllingMapNum].type || '' }}</small></SoloControlButton>

<SoloMapButton v-for="map in currentMapChunk" v-bind:key="map.id" :map="map"
Expand Down Expand Up @@ -182,11 +196,13 @@ import RosterOverlay from "@/components/broadcast/roots/RosterOverlay";
import BreakOverlay from "@/components/broadcast/break/BreakOverlay";
import OverviewOverlay from "@/components/broadcast/roots/OverviewOverlay";
import SoloMapButton from "@/components/broadcast/SoloMapButton";
import SoloMapToggleButton from "@/components/broadcast/SoloMapToggleButton.vue";
export default {
name: "SoloOverlay",
props: ["broadcast", "client", "title", "modules", "rosterOptions", "showMapVideos"],
components: {
SoloMapToggleButton,
SoloMapButton,
OverviewOverlay,
RosterOverlay,
Expand All @@ -205,12 +221,13 @@ export default {
controllingMapNum: null,
teams: [
{ name: "Team 1", has_theme: 0 },
{ name: "Team 2", has_theme: 0 }
{ name: "Team 1", code: "T1", has_theme: 0 },
{ name: "Team 2", code: "T2", has_theme: 0 }
],
scores: [0, 0],
breakEnd: null,
maps: [],
mapWinners: [],
showGuides: false,
firstTo: 3,
Expand Down Expand Up @@ -275,6 +292,28 @@ export default {
setFirstTo(num) {
this.firstTo = num;
this.controlMode = "set-scores";
},
toggleMapWinner(num) {
console.log("toggle winner", num);
const rotation = [null, "team-1", "team-2", "draw"];
let current = this.mapWinners[num];
if (current === undefined) {
this.$set(this.mapWinners, num, null);
current = null;
}
const index = rotation.indexOf(current);
if (index === -1) {
console.warn("Unsure what map winner to toggle to", { num, current });
this.$set(this.mapWinners, num, null);
return;
}
if (index >= rotation.length - 1) {
this.$set(this.mapWinners, num, rotation[0]);
} else {
this.$set(this.mapWinners, num, rotation[index + 1]);
}
console.log(this.mapWinners[num]);
}
},
watch: {
Expand Down Expand Up @@ -360,6 +399,22 @@ export default {
if (!this.chunkedMaps?.[this.controlPage]) return [];
return this.chunkedMaps[this.controlPage];
},
mapsWithWinners() {
return this.maps.map((_map, i) => {
const map = { ..._map };
const mapWinData = this.mapWinners[i];
if (mapWinData) {
if (mapWinData === "draw") {
map.draw = true;
} else if (mapWinData === "team-1") {
map.winner = this.teams[0];
} else if (mapWinData === "team-2") {
map.winner = this.teams[1];
}
}
return map;
});
},
virtualMatch() {
return {
teams: this.teams,
Expand All @@ -370,7 +425,7 @@ export default {
_virtual_match_category: this.matchCategory,
_virtual_break_end: this.breakEnd,
first_to: this.firstTo,
maps: this.maps
maps: this.mapsWithWinners
};
},
scoreArray() {
Expand Down

0 comments on commit 1022e79

Please sign in to comment.