Modification des images, correction d'un bug du compteur de tours et modification du tableau des scores

master
Adrien W 1 year ago
parent a4a4caebdf
commit 681f01ffa6

@ -65,6 +65,11 @@ class Equipe {
this.tour++;
}
void decTour() {
if (this.tour==0) return;
this.tour--;
}
void setTour(int tour) {
this.tour = tour;
}

@ -47,6 +47,7 @@ void setup() {
Scoreboard.applyScores();
}
// positionnement des pions sur une case, répartis en cercle si ils sont plusieurs
void drawAround(int score) {
//println("draw around", score);
for (int i=0; i<positionTable.getRowCount(); i++) {
@ -70,6 +71,7 @@ void drawAround(int score) {
}
}
// fonction appellée à chaque mouvement de souris
void mouseMoved() {
for (int i = 0 ; i < equipes.length; i++) {
Equipe e = equipes[i];
@ -114,6 +116,7 @@ void mouseMoved() {
}
}
// fonction appellée à chaque appui du clic
void mousePressed() {
for (int i = 0 ; i < equipes.length; i++) {
Pion p = equipes[i].pion;
@ -125,16 +128,25 @@ void mousePressed() {
}
}
if (Scoreboard.mouseHover()) {
Scoreboard.toggleDisplay();
}
//if (Scoreboard.mouseHover()) {
// Scoreboard.toggleDisplay();
//}
Equipe clicked = findClosestEquipeFromMouse();
//if (!clicked.pion.dragged) {
clicked.incTour();
Scoreboard.save();
println("Clicked on Equipe", clicked.id+1, "set tour to ", clicked.tour);
//}
float eD = dist(clicked.posX, clicked.posY, mouseX, mouseY);
if (eD<=clicked.radius/2) {
// désactiver l'incrémentation si le pion était encore à son emplacement d'origine
//if (!clicked.pion.dragged) {
if (mouseButton == LEFT) {
clicked.incTour();
} else if (mouseButton == RIGHT) {
clicked.decTour();
}
Scoreboard.save();
println("Clicked on Equipe", clicked.id+1, "set tour to", clicked.tour);
//}
}
if (!EDITING) return;
for (int i = 0 ; i < positions.length; i++) {
@ -148,6 +160,7 @@ void mousePressed() {
}
}
// fonction appellée à chaque déplacement appuyé (drag)
void mouseDragged() {
for (int i = 0 ; i < equipes.length; i++) {
Pion p = equipes[i].pion;
@ -170,6 +183,7 @@ void mouseDragged() {
}
}
// fonction appellée à chaque relâchement du clic
void mouseReleased() {
for (int i = 0 ; i < equipes.length; i++) {
Pion p = equipes[i].pion;
@ -190,6 +204,7 @@ void mouseReleased() {
}
}
// fonction appellée à chaque mouvement de molette
void mouseWheel(MouseEvent event) {
for (int i = 0 ; i < equipes.length; i++) {
Equipe e = equipes[i];
@ -263,11 +278,13 @@ Equipe findClosestEquipeFromMouse() {
return closest;
}
// test de présence du fichier en paramètre
boolean fileExists(String filename) {
File f = dataFile(filename);
return f.isFile();
}
// LAZOR !!!
void LAZOR(PVector source, PVector target, int noiseLevel) {
stroke(random(0, 255), random(0, 100), random(0, 100));
strokeWeight(random(0,3));
@ -278,6 +295,7 @@ void LAZOR(PVector source, PVector target) {
LAZOR(source, target, 0);
}
// RECTANGULAR LAZOR !!!
void LAZORECT(float posX, float posY, float width, float height) {
stroke(random(0, 255), random(0, 100), random(0, 100));
strokeWeight(random(0,3));
@ -289,23 +307,32 @@ void LAZORECT(float posX, float posY, float width, float height) {
//LAZOR(new PVector(posX, posY+height), new PVector(posX, posY));
}
// boucle d'affichage appellée plusieurs fois par seconde (~60)
void draw() {
// afficher l'image de fond
image(backgroundImage, 0, 0, displayWidth, displayHeight);
if (!Scoreboard.display) image(titleImage, 0, 0, displayWidth, displayHeight);
// afficher le titre si le scoreboard est masqué
// if (!Scoreboard.display)
image(titleImage, 0, 0, displayWidth, displayHeight);
// afficher le scoreboard
Scoreboard.draw();
// mettre à jour les équipes
for (int i = 0 ; i < equipes.length; i++) {
equipes[i].update();
}
// recharger les scores depuis le fichier csv
if (millis() > timer + 2000) {
Scoreboard.reloadFromDisk();
timer = millis();
}
// si on est pas en mode édition, arrêter là
if (!EDITING) return;
// afficher les positions à éditer
for (int i = 0 ; i < positions.length; i++) {
positions[i].draw();
}

@ -3,7 +3,7 @@ class Scoreboard {
String dataSource; // nom du fichier csv
Table table;
boolean autoload = true; // chargement et rechargement automatique
boolean display = false;
boolean display = true;
float posX, posY, width, height; // position et dimensions de l'afficheur
Scoreboard() {
@ -17,9 +17,9 @@ class Scoreboard {
void setup() {
if (autoload) this.load();
this.posX = 348;
this.posY = 59;
this.width = 1239;
this.posX = 948;
this.posY = 130;
this.width = 439;
this.height = 158;
}
@ -131,59 +131,71 @@ class Scoreboard {
}
void draw() {
if (!this.display) return;
//if (!this.display) return;
int count = 0;
//int podium = 3;
int margin = 60;
float offsetX = this.posX+this.width+10;
float offsetX = this.posX;
float offsetY = this.posY;
float lastX = 0;
rectMode(CORNER);
fill(color(120, 0, 0, 200));
stroke(color(255, 255, 255));
strokeWeight(2);
rect(this.posX, this.posY, this.width, this.height);
// pour chaque score de 50 à 1
for (int i=50; i>0; i--) {
// on limite aux 5 premières équipes
if (count==5) break;
// récupération des équipes à ce score
Iterable<TableRow> rowsIterable = this.findEquipesByScore(i);
ArrayList<String> teams = new ArrayList<String>();
for (TableRow row : rowsIterable) { teams.add(row.getString("equipe")); }
// arrêter la boucle si on est hors du cadre d'affichage
if (offsetX-margin<=this.posX) break;
//if (offsetX-margin<=this.posX) break;
// passer cette itération si aucune équipe à afficher
if (teams.size()==0) continue;
// affichage du score
fill(color(0,0,0));
rect(offsetX-66, offsetY+20, 55, 50);
rect(offsetX, offsetY+20, 55, 50);
fill(color(240, 240, 80));
stroke(color(0, 0, 0));
strokeWeight(1);
textFont(quicksandFont, 40);
String text = str(count);
text += count==1? " er": "ème";
// 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);
// selon largeur du texte
//float localMarginX = (i<=9)? margin+14: (i>=40)? margin-8: margin;
// selon nombre d'équipes à afficher pour ce score
//localMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX;
//fill(color(0, 250, 0));
text(i, offsetX-localMarginX, offsetY+margin);
text(text, offsetX+margin/2, 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;
// correction de positionnement horizontal
// selon largeur du texte
float subLocalMarginX = (int(teams.get(j))<=9)? margin-10: (int(teams.get(j))>=40)? margin-40: margin-30;
fill(color(240, 240, 80));
circle(offsetX-(margin*(j+1))+20, offsetY+(margin*2)-12, 50);
circle(offsetX+margin/2, offsetY+(margin*2)-12, 50);
fill(color(0, 0, 0));
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));
text(teams.get(j), offsetX+subLocalMarginX/2, 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;
lastX = offsetX+(margin*teams.size())-10;
offsetX -= margin*teams.size();
offsetX += margin*teams.size();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 994 KiB

After

Width:  |  Height:  |  Size: 506 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 191 KiB

Loading…
Cancel
Save