|
|
|
|
@ -3,7 +3,7 @@ class Scoreboard {
|
|
|
|
|
String dataSource; // nom du fichier csv
|
|
|
|
|
Table table;
|
|
|
|
|
boolean autoload = true; // chargement et rechargement automatique
|
|
|
|
|
boolean display = true;
|
|
|
|
|
boolean display = false;
|
|
|
|
|
float posX, posY, width, height; // position et dimensions de l'afficheur
|
|
|
|
|
|
|
|
|
|
Scoreboard() {
|
|
|
|
|
@ -41,6 +41,7 @@ class Scoreboard {
|
|
|
|
|
|
|
|
|
|
// typage forcé pour que .sort() fonctionne sur la colonne score
|
|
|
|
|
this.table.setColumnType("score", "int");
|
|
|
|
|
this.dataIntegrityCheck();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// écrit le tableau des scores dans un .csv
|
|
|
|
|
@ -98,17 +99,35 @@ class Scoreboard {
|
|
|
|
|
this.display = !this.display;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// vérifier si les données chargées correspondent à ce qui est attendu
|
|
|
|
|
void dataIntegrityCheck() {
|
|
|
|
|
// vérification du nombre de lignes // équipes
|
|
|
|
|
int rowCount = this.table.getRowCount();
|
|
|
|
|
|
|
|
|
|
if (rowCount!=nombreEquipes) {
|
|
|
|
|
// on gère seulement le cas où on a chargé plus de lignes que d'équipes voulues
|
|
|
|
|
// le cas inverse n'est pas bloquant et se résoud tout seul
|
|
|
|
|
if (rowCount>nombreEquipes) {
|
|
|
|
|
// calcul de la différence
|
|
|
|
|
int diff = rowCount - nombreEquipes;
|
|
|
|
|
// suppression des dernières lignes jusqu'à revenir à l'équilibre
|
|
|
|
|
for (int i = rowCount; i>rowCount-diff; i--) {
|
|
|
|
|
this.table.removeRow(i-1);
|
|
|
|
|
//println("Socreboard.removeRow", i-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw() {
|
|
|
|
|
if (!this.display) return;
|
|
|
|
|
//int count = 1;
|
|
|
|
|
int podium = 3;
|
|
|
|
|
int count = 0;
|
|
|
|
|
//int podium = 3;
|
|
|
|
|
int margin = 60;
|
|
|
|
|
float offsetX = this.posX+this.width;
|
|
|
|
|
float offsetX = this.posX+this.width+10;
|
|
|
|
|
float offsetY = this.posY;
|
|
|
|
|
float lastX = 0;
|
|
|
|
|
rectMode(CORNER);
|
|
|
|
|
noStroke();
|
|
|
|
|
fill(color(250, 150, 50));
|
|
|
|
|
rect(this.posX, this.posY, this.width, this.height);
|
|
|
|
|
|
|
|
|
|
// pour chaque score de 50 à 1
|
|
|
|
|
for (int i=50; i>0; i--) {
|
|
|
|
|
@ -118,33 +137,45 @@ class Scoreboard {
|
|
|
|
|
for (TableRow row : rowsIterable) { teams.add(row.getString("equipe")); }
|
|
|
|
|
|
|
|
|
|
// arrêter la boucle si on est hors du cadre d'affichage
|
|
|
|
|
if (offsetX<=this.posX-margin) break;
|
|
|
|
|
if (offsetX-margin<=this.posX) break;
|
|
|
|
|
// passer cette itération si aucune équipe à afficher
|
|
|
|
|
if (teams.size()==0) continue;
|
|
|
|
|
|
|
|
|
|
//println(i, teams);
|
|
|
|
|
|
|
|
|
|
// affichage du score
|
|
|
|
|
fill(color(0, 0, 0));
|
|
|
|
|
stroke(color(0, 0, 0));
|
|
|
|
|
strokeWeight(1);
|
|
|
|
|
textFont(quicksandFont, 40);
|
|
|
|
|
text(i, offsetX-margin, offsetY+margin);
|
|
|
|
|
|
|
|
|
|
// correction de positionnement horizontal
|
|
|
|
|
float localMarginX = (i<=9)? margin-14: (i>=40)? margin+8: margin;
|
|
|
|
|
localMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX;
|
|
|
|
|
//text(i, offsetX-margin, offsetY+margin);
|
|
|
|
|
//fill(color(0, 250, 0));
|
|
|
|
|
text(i, offsetX-localMarginX, offsetY+margin);
|
|
|
|
|
|
|
|
|
|
// affichage des équipes
|
|
|
|
|
for(int j=0; j<teams.size(); j++) {
|
|
|
|
|
float subLocalMarginX = (int(teams.get(j))<=9)? margin-10: (int(teams.get(j))>=40)? margin+4: margin;
|
|
|
|
|
subLocalMarginX -=4;
|
|
|
|
|
fill(color(0, 0, 0));
|
|
|
|
|
circle(offsetX-(margin*(j+1))+20, offsetY+(margin*2)-12, 50);
|
|
|
|
|
fill(color(255, 255,255));
|
|
|
|
|
textFont(quicksandFont, 40);
|
|
|
|
|
text(teams.get(j), offsetX-(margin*(j+1)), offsetY+(margin*2));
|
|
|
|
|
textFont(quicksandFont, 32);
|
|
|
|
|
//text(teams.get(j), offsetX-(margin*(j+1)), offsetY+(margin*2));
|
|
|
|
|
//fill(color(0, 250, 0));
|
|
|
|
|
text(teams.get(j), offsetX-(subLocalMarginX*(j+1)), offsetY+(margin*2));
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
line(offsetX-(margin*teams.size())-10, offsetY, offsetX-(margin*teams.size())-10, offsetY+this.height);
|
|
|
|
|
lastX = offsetX-(margin*teams.size())-10;
|
|
|
|
|
|
|
|
|
|
//count += teams.size();
|
|
|
|
|
offsetX -= margin*teams.size();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
noFill();
|
|
|
|
|
stroke(color(0, 0, 0));
|
|
|
|
|
rect(lastX, this.posY, margin*count, this.height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|