Skip to content

Commit

Permalink
feat: relabel the button 'Clear field overlays'
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeg committed Feb 5, 2024
1 parent 3b3410c commit 86dd95b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion domains/MatchRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ class MatchRoom extends Room {
case 'focusPlayer':
case 'setHideProfileCardOnNextGame':
case 'startCountDown':
case 'removeCompMessage': {
case 'clearFieldOverlays': {
update_admin = false;
break; // simple passthrough
}
Expand Down
14 changes: 11 additions & 3 deletions public/views/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,25 +574,33 @@ export default class Player {
}
}

hideCompMessage() {
_hideCompMessage() {
if (this.count_down_timer) {
this.count_down_timer = clearTimeout(this.count_down_timer);
}
this.comp_messages.style.display = 'none';
}

clearFieldOverlays() {
this._hideCompMessage();
this._hideCurtain();
this.showProfileCard(false);
}

setReady(ready) {
if (this.count_down_timer) return; // player ready state has less priority than count down

if (ready) {
this.showCompMessage('READY');
} else {
this.hideCompMessage();
this._hideCompMessage();
}
}

startCountDown(seconds = 5) {
this.count_down_timer = clearTimeout(this.count_down_timer);
this.only_show_admin_started_game = true;
this.admin_only_pending_game = true;

const showRemainingTime = () => {
this.showCompMessage(seconds || '', true, 1000);
Expand Down Expand Up @@ -868,7 +876,7 @@ export default class Player {
}
this.hide_profile_card_on_next_game = false;

this.hideCompMessage();
this._hideCompMessage();
}

_renderValidFrame(frame) {
Expand Down
4 changes: 2 additions & 2 deletions public/views/competition.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ class TetrisCompetitionAPI {
players.forEach(player => player.startCountDown(seconds));
}

removeCompMessage() {
players.forEach(player => player.hideCompMessage());
clearFieldOverlays() {
players.forEach(player => player.clearFieldOverlays());
}

_repaintVictories(player_idx) {
Expand Down
6 changes: 3 additions & 3 deletions public/views/competition_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dom = {
'#setHideProfileCardOnNextGame'
),
count_down: document.querySelector('#count_down'),
remove_count_down: document.querySelector('#remove_count_down'),
clear_field_overlays: document.querySelector('#clear_field_overlays'),
clear_victories: document.querySelector('#clear_victories'),
show_runways: document.querySelector('#show_runways'),
hide_runways: document.querySelector('#hide_runways'),
Expand Down Expand Up @@ -336,8 +336,8 @@ function bootstrap() {
remoteAPI.startCountDown(5);
});

dom.remove_count_down.addEventListener('click', () => {
remoteAPI.removeCompMessage();
dom.clear_field_overlays.addEventListener('click', () => {
remoteAPI.clearFieldOverlays();
});

dom.clear_victories.addEventListener('click', () => {
Expand Down
2 changes: 1 addition & 1 deletion views/admin.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
</div>
<div class="buttons">
<button id="count_down" title="Show a 5s timer for ALL players">Count Down 5s</button>
<button id="remove_count_down" title="Hide overlay">Remove Ready / Count Down</button>
<button id="clear_field_overlays" title="Hide overlay">Clear field overlays</button>
<button id="setHideProfileCardOnNextGame" style="display: none;" title="Profile card will auto-hide when the next game starts">Auto-Hide profile cards</button>
</div>
<div class="buttons">
Expand Down

0 comments on commit 86dd95b

Please sign in to comment.