-
Notifications
You must be signed in to change notification settings - Fork 0
/
chronoJres.pde
166 lines (128 loc) · 4.05 KB
/
chronoJres.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Timer timer;
PFont font,font2,font3,font4;
import controlP5.*;
ControlP5 controlP5;
//nom des boutons
String start = "DEMARRER";
String raz = "REINITIALISER";
String pause = "PAUSE";
String config = "CONFIGURER";
String cancel = "ANNULER";
String ok = "VALIDER";
String minuts = "Min";
String seconds = "Sec";
String qMinuts = " Min";
String qSeconds = " Sec";
String labelTime="Temps de la session";
String labelQuestion="Temps des questions";
//temps par defaut
String defaultMin="35";
String defaultSec="00";
String defaultQuestionMin="10";
String defaultQuestionSec="00";
Textfield minutsTf;
Textfield secondsTf;
Textfield qMinutsTf;
Textfield qSecondsTf;
Textlabel timeLabel;
Textlabel questionLabel;
Button startBut;
Button pauseBut;
Button razBut;
Button configBut;
Button okBut;
Button cancelBut;
int butColor = color(80);
int activeColor = color(120);
int bgColor = color(0);
boolean firstStart=true;
PImage logo;
void setup() {
PImage b;
// Images must be in the "data" directory to load correctly
logo = loadImage("logo.jpg");
font = loadFont("LcdD-200.vlw");
font2 = loadFont("NimbusSanL-BoldCondItal-150.vlw");
font3 = loadFont("NimbusSanL-Bold-80.vlw");
font4 = loadFont("LcdD-100.vlw");
textFont(font);
size(1024,768);
background(0);
timer = new Timer(2100000,600000);
//controls
controlP5 = new ControlP5(this);
initBut();
initConfig();
hideConfig();
}
void draw(){
if (firstStart)
{
startup();
}
else if (timer.theEnd)
{
background(255,0,0);
textFont(font4);
text("Temps dépassé",200, 200);
int Minutes = ((int)timer.getCurrentTimeMs() % (1000*60*60)) / (1000*60);
int Seconds = (((int)timer.getCurrentTimeMs() % (1000*60*60)) % (1000*60)) / 1000;
textFont(font);
text(String.format("%02d", Minutes)+":"+ String.format("%02d", Seconds),270, height/2);
textFont(font3);
fill(255,70);
int s = second();
int m = minute();
int h = hour();
text(String.format("%02d", h)+":"+ String.format("%02d", m)+":"+ String.format("%02d", s),680, 750);
}
else if(timer.running && !timer.paused && timer.session){
//session
background(0);
rectMode(CORNER);
fill(0,200,0);
rect(0, map(timer.getSessionTimeLeft() , 0, timer.sessionTime, height,0), width,height );
//Ajout de 1 min ( +60000) pour l'affichage
int Minutes = ((int)timer.getSessionTimeLeft()+60000 % (1000*60*60)) / (1000*60);
int Seconds = (((int)timer.getSessionTimeLeft() % (1000*60*60)) % (1000*60)) / 1000;
// println ( timer.getSessionTimeLeft() +":"+ Minutes+":"+ Seconds);
// noFill();
rectMode(CENTER);
fill(255);
//text(String.format("%02d", Minutes)+":"+ String.format("%02d", Seconds),270, height/2);
text(String.format("%02d", Minutes)+" min",270, height/2);
}
else if (!timer.session && timer.running) {
//questions
textFont(font);
background(255,165,0);
rectMode(CENTER);
// text("Questions", 50 , height/2);
rectMode(CORNER);
fill(255,0,0);
rect(0, map((timer.getQuestionsTimeLeft()), 0, timer.questionsTime, 0,height), width,height);
//Ajout de 1 min ( +60000) pour l'affichage
int Minutes = ((int)timer.getQuestionsTimeLeft()+60000 % (1000*60*60)) / (1000*60);
int Seconds = (((int)timer.getQuestionsTimeLeft() % (1000*60*60)) % (1000*60)) / 1000;
fill(255);
//text(String.format("%02d", Minutes)+":"+ String.format("%02d", Seconds), 270 , height/2);
text(String.format("%02d", Minutes)+" min",270, height/2);
textFont(font3);
fill(255,70);
int s = second();
int m = minute();
int h = hour();
text(String.format("%02d", h)+":"+ String.format("%02d", m)+":"+ String.format("%02d", s),680, 750);
}
}
void startup(){
background(0);
firstStart=true;
image(logo, 20, 380);
textFont(font);
//text("JRES 2011",120, 200);
int s = second();
int m = minute();
int h = hour();
text(String.format("%02d", h)+":"+ String.format("%02d", m)+":"+ String.format("%02d", s),180, 250);
}