Skip to content

Commit

Permalink
Simplify VS/Scoreboard hide/show logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Readek committed Feb 13, 2024
1 parent bc575d2 commit b6b95b9
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 68 deletions.
14 changes: 0 additions & 14 deletions Stream Tool/Resources/Scripts/RoA Scoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ async function updateData(data) {
// update intro data just in case we end up playing it
scoreboardIntro.updateData(data);

// this will only happen on view load
if (current.startup) {

// before anything else, check if the Intro wants to come out
if (data.allowIntro) {

// run that intro!
scoreboardIntro.play();

}

}

// determine startup delay
if (data.allowIntro) {
current.delay = introDelaySc + 2;
Expand Down Expand Up @@ -91,7 +78,6 @@ function hideElements() {
scoreboardIntro.reset();

// hide some stuff so we save on some resources
players.hide();
teams.hide();
round.hide();

Expand Down
3 changes: 3 additions & 0 deletions Stream Tool/Resources/Scripts/Scoreboard/Intro.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ScoreboardIntro {

// set all things visible
introDiv.style.opacity = 1;
introDiv.style.display = "block";

// move the white bars because it looks cool
introWhiteBarTop.style.animation = `introWhiteBarTop .5s ${introDelaySc}s cubic-bezier(0, 0, .2, 1) both`;
Expand Down Expand Up @@ -166,6 +167,8 @@ class ScoreboardIntro {

introDiv.style.animation = "";

introDiv.style.display = "none";

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,9 @@ export class PlayerCharacter {

}

/** Hides the character's image */
hide() {
this.#charEl.parentElement.style.display = "none";
}

/** Displays hidden image, fading it in */
show() {
this.fadeInChar(current.delay+.15);
this.#charEl.parentElement.style.display = "block";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,13 @@ export class PlayerName {

}

/** Hides the text wrapper */
hide() {
this.#wrapperEl.style.display = "none";
}

/** Displays the text wrapper, fading it in */
show() {
if (gamemode.getGm() == 2) {
fadeIn(this.#wrapperEl, fadeInTimeSc, current.delay)
} else {
fadeInMove(this.#wrapperEl, null, this.#side, current.delay);
}
this.#wrapperEl.style.display = "block";
}

}
6 changes: 0 additions & 6 deletions Stream Tool/Resources/Scripts/Scoreboard/Player/Player.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ export class Player {
this.#pChar.changeGm(gamemode);
}

/** Hides some stuff when browser goes out of view */
hide() {
this.#pName.hide();
this.#pChar.hide();
}

/** Display elements and animations when user comes back to the browser */
show() {
this.#pName.show();
Expand Down
9 changes: 0 additions & 9 deletions Stream Tool/Resources/Scripts/Scoreboard/Player/Players.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ class Players {

}

/** Hides some elements when browser goes out of view */
hide() {

for (let i = 0; i < this.#players.length; i++) {
this.#players[i].hide();
}

}

/** Returns some elements back to view, animating them */
show() {

Expand Down
10 changes: 0 additions & 10 deletions Stream Tool/Resources/Scripts/Scoreboard/Team/Team Logo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,9 @@ export class TeamLogo {

}

/** Hides the logo image */
hide() {

this.#logoImg.style.display = "none";

}

/** Shows the logo image */
show() {

fadeIn(this.#logoImg, fadeInTimeSc, current.delay + .35);
this.#logoImg.style.display = "block";

}

}
6 changes: 0 additions & 6 deletions Stream Tool/Resources/Scripts/Scoreboard/Team/Team Name.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,10 @@ export class TeamName {
this.#nameBg.src = `Resources/Overlay/Scoreboard/Name BG ${gamemode}.png`;
}

/** Hides the text element */
hide() {
this.#nameEl.style.display = "none";
}

/** Displays the text wrapper, fading it in */
show() {
if (gamemode.getGm() == 2) {
fadeInMove(this.#nameEl, null, this.#side, current.delay);
this.#nameEl.style.display = "block";
}
}

Expand Down
15 changes: 7 additions & 8 deletions Stream Tool/Resources/Scripts/Scoreboard/Team/Team.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,24 @@ export class Team {
/** Hides some stuff when browser goes out of view */
hide() {

// this will reset the scoreboard fade in animation
this.#scoreboardEl.style.animation = "";
// this will reset all scoreboard animations
this.#scoreboardEl.style.display = "none";

this.#tName.hide();
this.#tTopBar.hide();
this.#tLogo.hide();

}

/** Display elements and animations when user comes back to the browser */
show() {

fadeInMove(this.#scoreboardEl, null, this.#side, current.delay-.1);
this.#scoreboardEl.style.display = "block";
show() {

// this will update animation values when they become visible
this.#tName.show();
this.#tTopBar.show(current.delay+.6);
this.#tLogo.show();

fadeInMove(this.#scoreboardEl, null, this.#side, current.delay-.1);
this.#scoreboardEl.style.display = "block";

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function initOnBrowserActive(hide, show) {
window.addEventListener('obsSourceActiveChanged', (event) => {

if (event.detail.active) { // when its show time
hide(); // this is a workaraound for an startup issue :(
show();
} else { // when browser goes to the backstage
hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ export class PlayerCharacter {
/** Hides the character's images */
hide() {
this.#charDiv.style.display = "none";
this.#bgEl.pause();
this.#bgEl.style.display = "none";
}

/** Displays hidden images, fading them in */
show() {
charaFadeIn(this.#charDiv, this.#trailEl, fadeInTimeVs, introDelayVs);
this.#bgEl.play();
this.#charDiv.style.display = "block";
this.#bgEl.style.display = "block";
}

}

0 comments on commit b6b95b9

Please sign in to comment.