Compare commits

..

No commits in common. 'cd5252d5bea8339dd3517947515765f4764609bc' and 'a4a4caebdf6f95bbe2f93c9c08e56406b1f29c4d' have entirely different histories.

@ -1,4 +0,0 @@
color C_WHITE = color(255,255,255);
color C_BLACK = color(0,0,0);
color C_RED = color(250, 40, 40);
color C_YELLOW = color(177, 255, 51);

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

@ -3,13 +3,11 @@ class Pion extends Position {
boolean lazored, animated = false; boolean lazored, animated = false;
int timer; int timer;
float savedRadius; float savedRadius;
color bgColorHover;
Pion(int id) { Pion(int id) {
super(id); super(id);
this.bgColor = C_RED; this.bgColor = color(0, 0, 0);
this.bgColorHover = C_YELLOW; this.textColor = color(240, 240, 80);
this.textColor = color(0, 0, 0);
this.posX = floor((displayWidth-margin*2)/nombreEquipes)*id+radius/2+margin; this.posX = floor((displayWidth-margin*2)/nombreEquipes)*id+radius/2+margin;
this.posY = displayHeight-46; this.posY = displayHeight-46;
this.radius = 30; this.radius = 30;
@ -37,13 +35,12 @@ class Pion extends Position {
} }
color getBgColor() { color getBgColor() {
if (this.animated && this.lazored) return color(random(200, 255), random(0, 100), random(0, 100)); if (this.animated && this.lazored) return color(random(200, 255), random(50, 150), random(50, 150));
if (((frameCount-id) % 10)==0) return C_WHITE; return this.dragged? color(177, 255, 51): this.hovered? this.textColor: this.bgColor;
return this.dragged? C_YELLOW: this.hovered? this.bgColorHover: this.bgColor;
} }
color getTextColor() { color getTextColor() {
return this.dragged? C_BLACK: this.hovered? this.textColor: this.textColor; return this.dragged? color(0): this.hovered? this.bgColor: this.textColor;
} }
void hoverStop() { void hoverStop() {
@ -85,8 +82,7 @@ class Pion extends Position {
if (!this.lazored) return; if (!this.lazored) return;
PVector target = new PVector(p.posX, p.posY); PVector target = new PVector(p.posX, p.posY);
//LAZOR(new PVector(245, 158), target); LAZOR(new PVector(245, 158), target);
//LAZOR(new PVector(displayWidth-245, 158), target); LAZOR(new PVector(displayWidth-245, 158), target);
LAZOR(new PVector(mouseX, mouseY), target);
} }
} }

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

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 KiB

After

Width:  |  Height:  |  Size: 994 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

After

Width:  |  Height:  |  Size: 216 KiB

Loading…
Cancel
Save