Skip to content

Commit

Permalink
don't switch public board unless medals; closes #757
Browse files Browse the repository at this point in the history
  • Loading branch information
jflamy committed Oct 8, 2023
1 parent b462caf commit c1950ea
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import app.owlcms.displays.scoreboard.ResultsMedals;
import app.owlcms.displays.scoreboard.ResultsMultiRanks;
import app.owlcms.init.OwlcmsSession;
import app.owlcms.uievents.CeremonyType;
import app.owlcms.uievents.UIEvent;
import ch.qos.logback.classic.Logger;

Expand All @@ -25,7 +26,7 @@ public class PublicMultiRanksPage extends AbstractResultsDisplayPage {

Logger logger;
Logger uiEventLogger;

private ResultsMultiRanks resultsBoard;
private ResultsMedals medalsBoard;
protected UI ui;
Expand All @@ -35,10 +36,39 @@ public String getPageTitle() {
return getTranslation("ScoreboardMultiRanksTitle") + OwlcmsSession.getFopNameIfMultiple();
}

public final ResultsMultiRanks getResultsBoard() {
return this.resultsBoard;
}

@Subscribe
public void slaveCeremonyDone(UIEvent.CeremonyDone e) {
if (e.getCeremonyType() != CeremonyType.MEDALS) {
return;
}
this.ui.access(() -> {
getMedalsBoard().setVisible(false);
getResultsBoard().setVisible(true);
});
}

@Subscribe
public void slaveCeremonyStarted(UIEvent.CeremonyStarted e) {
if (e.getCeremonyType() != CeremonyType.MEDALS) {
return;
}
this.ui.access(() -> {
getMedalsBoard().setDarkMode(getResultsBoard().isDarkMode());
getMedalsBoard().setTeamWidth(getResultsBoard().getTeamWidth());
getMedalsBoard().setEmFontSize(getResultsBoard().getEmFontSize());
getMedalsBoard().setVisible(true);
getResultsBoard().setVisible(false);
});
}

@Override
protected void init() {
logger = (Logger) LoggerFactory.getLogger(PublicScoreboardPage.class);
uiEventLogger = (Logger) LoggerFactory.getLogger("UI" + this.logger.getName());
this.logger = (Logger) LoggerFactory.getLogger(PublicScoreboardPage.class);
this.uiEventLogger = (Logger) LoggerFactory.getLogger("UI" + this.logger.getName());

// each subclass must override this routine.
// otherwise we end up with multiple instances of the Results board.
Expand All @@ -53,25 +83,21 @@ protected void init() {
this.ui = UI.getCurrent();

setDefaultParameters(QueryParameters.simple(Map.of(
SoundParameters.SILENT, "true",
SoundParameters.DOWNSILENT, "true",
DisplayParameters.DARK, "true",
DisplayParameters.LEADERS, "true",
DisplayParameters.RECORDS, "true",
DisplayParameters.SINGLEREF, "false",
DisplayParameters.PUBLIC, "false",
DisplayParameters.ABBREVIATED,
Boolean.toString(Config.getCurrent().featureSwitch("shortScoreboardNames")))));
SoundParameters.SILENT, "true",
SoundParameters.DOWNSILENT, "true",
DisplayParameters.DARK, "true",
DisplayParameters.LEADERS, "true",
DisplayParameters.RECORDS, "true",
SoundParameters.SINGLEREF, "false",
DisplayParameters.PUBLIC, "false",
DisplayParameters.ABBREVIATED,
Boolean.toString(Config.getCurrent().featureSwitch("shortScoreboardNames")))));
}

@Subscribe
public void slaveCeremonyDone(UIEvent.CeremonyDone e) {
this.ui.access(() -> {
getMedalsBoard().setVisible(false);
getResultsBoard().setVisible(true);
});
private final ResultsMedals getMedalsBoard() {
return this.medalsBoard;
}

private void setMedalsBoard(ResultsMedals medalsBoard) {
this.medalsBoard = medalsBoard;
}
Expand All @@ -80,23 +106,4 @@ private void setResultsBoard(ResultsMultiRanks board) {
this.resultsBoard = board;
}

public final ResultsMultiRanks getResultsBoard() {
return resultsBoard;
}

private final ResultsMedals getMedalsBoard() {
return medalsBoard;
}

@Subscribe
public void slaveCeremonyStarted(UIEvent.CeremonyStarted e) {
this.ui.access(() -> {
getMedalsBoard().setDarkMode(getResultsBoard().isDarkMode());
getMedalsBoard().setTeamWidth(getResultsBoard().getTeamWidth());
getMedalsBoard().setEmFontSize(getResultsBoard().getEmFontSize());
getMedalsBoard().setVisible(true);
getResultsBoard().setVisible(false);
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import app.owlcms.displays.scoreboard.Results;
import app.owlcms.displays.scoreboard.ResultsMedals;
import app.owlcms.init.OwlcmsSession;
import app.owlcms.uievents.CeremonyType;
import app.owlcms.uievents.UIEvent;
import ch.qos.logback.classic.Logger;

Expand Down Expand Up @@ -47,6 +48,9 @@ public final Results getResultsBoard() {

@Subscribe
public void slaveCeremonyDone(UIEvent.CeremonyDone e) {
if (e.getCeremonyType() != CeremonyType.MEDALS) {
return;
}
this.ui.access(() -> {
getMedalsBoard().getStyle().set("display", "none");
getResultsBoard().getStyle().set("display", "block");
Expand All @@ -55,6 +59,9 @@ public void slaveCeremonyDone(UIEvent.CeremonyDone e) {

@Subscribe
public void slaveCeremonyStarted(UIEvent.CeremonyStarted e) {
if (e.getCeremonyType() != CeremonyType.MEDALS) {
return;
}
this.ui.access(() -> {
/* copy current parameters from results board to medals board */
medalsBoard.setDownSilenced(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import app.owlcms.displays.scoreboard.ResultsMedals;
import app.owlcms.displays.scoreboard.ResultsRankingOrder;
import app.owlcms.init.OwlcmsSession;
import app.owlcms.uievents.CeremonyType;
import app.owlcms.uievents.UIEvent;
import ch.qos.logback.classic.Logger;

Expand Down Expand Up @@ -49,6 +50,9 @@ public final Results getResultsBoard() {

@Subscribe
public void slaveCeremonyDone(UIEvent.CeremonyDone e) {
if (e.getCeremonyType() != CeremonyType.MEDALS) {
return;
}
this.ui.access(() -> {
getMedalsBoard().getStyle().set("display", "none");
getResultsBoard().getStyle().set("display", "block");
Expand All @@ -57,73 +61,72 @@ public void slaveCeremonyDone(UIEvent.CeremonyDone e) {

@Subscribe
public void slaveCeremonyStarted(UIEvent.CeremonyStarted e) {
if (e.getCeremonyType() != CeremonyType.MEDALS) {
return;
}
this.ui.access(() -> {
/* copy current parameters from results board to medals board */
medalsBoard.setDownSilenced(true);
medalsBoard.setDarkMode(((DisplayParameters) getBoard()).isDarkMode());
medalsBoard.setVideo(((DisplayParameters) getBoard()).isVideo());
medalsBoard.setPublicDisplay(((DisplayParameters) getBoard()).isPublicDisplay());
medalsBoard.setSingleReferee(((SoundParameters) getBoard()).isSingleReferee());
medalsBoard.setAbbreviatedName(((DisplayParameters) getBoard()).isAbbreviatedName());
medalsBoard.setTeamWidth(((DisplayParameters) getBoard()).getTeamWidth());
medalsBoard.setEmFontSize(((DisplayParameters) getBoard()).getEmFontSize());
checkVideo(Config.getCurrent().getParamStylesDir() + "/video/results.css", medalsBoard);
this.medalsBoard.setDownSilenced(true);
this.medalsBoard.setDarkMode(((DisplayParameters) getBoard()).isDarkMode());
this.medalsBoard.setVideo(((DisplayParameters) getBoard()).isVideo());
this.medalsBoard.setPublicDisplay(((DisplayParameters) getBoard()).isPublicDisplay());
this.medalsBoard.setSingleReferee(((SoundParameters) getBoard()).isSingleReferee());
this.medalsBoard.setAbbreviatedName(((DisplayParameters) getBoard()).isAbbreviatedName());
this.medalsBoard.setTeamWidth(((DisplayParameters) getBoard()).getTeamWidth());
this.medalsBoard.setEmFontSize(((DisplayParameters) getBoard()).getEmFontSize());
checkVideo(Config.getCurrent().getParamStylesDir() + "/video/results.css", this.medalsBoard);
getMedalsBoard().getStyle().set("display", "block");

getResultsBoard().getStyle().set("display", "none");
});
}

@Override
protected void init() {
this.logger = (Logger) LoggerFactory.getLogger(this.getClass());
this.uiEventLogger = (Logger) LoggerFactory.getLogger("UI" + this.logger.getName());
createComponents();
setDefaultParameters();
}

protected void setDefaultParameters() {
// when navigating to the page, Vaadin will call setParameter+readParameters
// these parameters will be applied.
setDefaultParameters(QueryParameters.simple(Map.of(
SoundParameters.SILENT, "true",
SoundParameters.DOWNSILENT, "true",
DisplayParameters.DARK, "true",
DisplayParameters.LEADERS, "true",
DisplayParameters.RECORDS, "true",
DisplayParameters.VIDEO, "false",
DisplayParameters.PUBLIC, "true",
SoundParameters.SINGLEREF, "false",
DisplayParameters.ABBREVIATED,
Boolean.toString(Config.getCurrent().featureSwitch("shortScoreboardNames")))));
}

protected void createComponents() {
var board = new ResultsRankingOrder();
var medalsBoard = new ResultsMedals();

this.setBoard(board);
this.setResultsBoard(board);
this.setMedalsBoard(medalsBoard);
this.addComponent(board);
this.addComponent(medalsBoard);

medalsBoard.setDownSilenced(true);
medalsBoard.setDarkMode(board.isDarkMode());
medalsBoard.setVideo(board.isVideo());
medalsBoard.setPublicDisplay(board.isPublicDisplay());
medalsBoard.setSingleReferee(board.isSingleReferee());
medalsBoard.setAbbreviatedName(board.isAbbreviatedName());
medalsBoard.setTeamWidth(board.getTeamWidth());
medalsBoard.setEmFontSize(board.getEmFontSize());
checkVideo(Config.getCurrent().getParamStylesDir() + "/video/results.css", medalsBoard);
medalsBoard.setEmFontSize(board.getEmFontSize());
checkVideo(Config.getCurrent().getParamStylesDir() + "/video/results.css", medalsBoard);

medalsBoard.getStyle().set("display", "none");
this.ui = UI.getCurrent();
}

private final ResultsMedals getMedalsBoard() {
return this.medalsBoard;
@Override
protected void init() {
this.logger = (Logger) LoggerFactory.getLogger(this.getClass());
this.uiEventLogger = (Logger) LoggerFactory.getLogger("UI" + this.logger.getName());
createComponents();
setDefaultParameters();
}

protected void setDefaultParameters() {
// when navigating to the page, Vaadin will call setParameter+readParameters
// these parameters will be applied.
setDefaultParameters(QueryParameters.simple(Map.of(
SoundParameters.SILENT, "true",
SoundParameters.DOWNSILENT, "true",
DisplayParameters.DARK, "true",
DisplayParameters.LEADERS, "true",
DisplayParameters.RECORDS, "true",
DisplayParameters.VIDEO, "false",
DisplayParameters.PUBLIC, "true",
SoundParameters.SINGLEREF, "false",
DisplayParameters.ABBREVIATED,
Boolean.toString(Config.getCurrent().featureSwitch("shortScoreboardNames")))));
}

protected void setMedalsBoard(ResultsMedals medalsBoard) {
Expand All @@ -133,4 +136,8 @@ protected void setMedalsBoard(ResultsMedals medalsBoard) {
protected void setResultsBoard(Results board) {
this.resultsBoard = board;
}

private final ResultsMedals getMedalsBoard() {
return this.medalsBoard;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import app.owlcms.displays.scoreboard.Results;
import app.owlcms.displays.scoreboard.ResultsMedals;
import app.owlcms.init.OwlcmsSession;
import app.owlcms.uievents.CeremonyType;
import app.owlcms.uievents.UIEvent;
import ch.qos.logback.classic.Logger;

Expand Down Expand Up @@ -47,6 +48,9 @@ public final Results getResultsBoard() {

@Subscribe
public void slaveCeremonyDone(UIEvent.CeremonyDone e) {
if (e.getCeremonyType() != CeremonyType.MEDALS) {
return;
}
this.ui.access(() -> {
getMedalsBoard().getStyle().set("display", "none");
getResultsBoard().getStyle().set("display", "block");
Expand All @@ -55,6 +59,9 @@ public void slaveCeremonyDone(UIEvent.CeremonyDone e) {

@Subscribe
public void slaveCeremonyStarted(UIEvent.CeremonyStarted e) {
if (e.getCeremonyType() != CeremonyType.MEDALS) {
return;
}
this.ui.access(() -> {
/* copy current parameters from results board to medals board */
medalsBoard.setDownSilenced(true);
Expand Down

0 comments on commit c1950ea

Please sign in to comment.