TORCS  1.3.9
The Open Racing Car Simulator
results.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : results.cpp
4  created : Fri Apr 14 22:36:36 CEST 2000
5  copyright : (C) 2000-2014 by Eric Espie, Bernhard Wymann
6  email : torcs@free.fr
7  version : $Id$
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
26 #include <stdlib.h>
27 #include <stdio.h>
28 #ifdef WIN32
29 #include <windows.h>
30 #endif
31 #include <tgfclient.h>
32 #include <osspec.h>
33 #include <racescreens.h>
34 #include <robottools.h>
35 #include <robot.h>
36 #include <portability.h>
37 
38 static int rmSaveId;
39 static void *rmScrHdle = NULL;
40 
41 static void rmPracticeResults(void *prevHdle, tRmInfo *info, int start);
42 static void rmRaceResults(void *prevHdle, tRmInfo *info, int start);
43 static void rmQualifResults(void *prevHdle, tRmInfo *info, int start);
44 static void rmShowStandings(void *prevHdle, tRmInfo *info, int start);
45 
46 #define MAX_LINES 20
47 
48 typedef struct
49 {
50  void *prevHdle;
52  int start;
53 } tRaceCall;
54 
57 
58 
59 static void rmSaveRes(void *vInfo)
60 {
61  tRmInfo *info = (tRmInfo *)vInfo;
63  GfParmWriteFile(0, info->results, "Results");
65 }
66 
67 
68 static void rmChgPracticeScreen(void *vprc)
69 {
70  void *prevScr = rmScrHdle;
71  tRaceCall *prc = (tRaceCall*)vprc;
72 
73  rmPracticeResults(prc->prevHdle, prc->info, prc->start);
74  GfuiScreenRelease(prevScr);
75 }
76 
77 
78 static void rmPracticeResults(void *prevHdle, tRmInfo *info, int start)
79 {
80  void *results = info->results;
81  const char *race = info->_reRaceName;
82  int i;
83  int x1, x2, x3, x4, x5, x6;
84  int offset;
85  int y;
86  const int BUFSIZE = 1024;
87  char buf[BUFSIZE];
88  char path[BUFSIZE];
89  const int TIMEFMTSIZE = 256;
90  char timefmt[TIMEFMTSIZE];
91  float fgcolor[4] = {1.0, 0.0, 1.0, 1.0};
92  int totLaps;
93 
95  snprintf(buf, BUFSIZE, "Practice Results");
96  GfuiTitleCreate(rmScrHdle, buf, strlen(buf));
97  snprintf(path, BUFSIZE, "%s/%s/%s", info->track->name, RE_SECT_RESULTS, race);
98  snprintf(buf, BUFSIZE, "%s on track %s", GfParmGetStr(results, path, RM_ATTR_DRVNAME, ""), info->track->name);
100  320, 420, GFUI_ALIGN_HC_VB, 0);
101  GfuiScreenAddBgImg(rmScrHdle, "data/img/splash-result.png");
102 
103  offset = 90;
104 
105  x1 = offset + 30;
106  x2 = offset + 50;
107  x3 = offset + 130;
108  x4 = offset + 240;
109  x5 = offset + 310;
110  x6 = offset + 400;
111 
112  y = 400;
114  GfuiLabelCreateEx(rmScrHdle, "Time", fgcolor, GFUI_FONT_MEDIUM_C, x2+20, y, GFUI_ALIGN_HL_VB, 0);
115  GfuiLabelCreateEx(rmScrHdle, "Best", fgcolor, GFUI_FONT_MEDIUM_C, x3+20, y, GFUI_ALIGN_HL_VB, 0);
116  GfuiLabelCreateEx(rmScrHdle, "Top Spd", fgcolor, GFUI_FONT_MEDIUM_C, x4, y, GFUI_ALIGN_HC_VB, 0);
117  GfuiLabelCreateEx(rmScrHdle, "Min Spd", fgcolor, GFUI_FONT_MEDIUM_C, x5, y, GFUI_ALIGN_HC_VB, 0);
118  GfuiLabelCreateEx(rmScrHdle, "Damages", fgcolor, GFUI_FONT_MEDIUM_C, x6, y, GFUI_ALIGN_HC_VB, 0);
119  y -= 20;
120 
121  snprintf(path, BUFSIZE, "%s/%s/%s", info->track->name, RE_SECT_RESULTS, race);
122  totLaps = (int)GfParmGetEltNb(results, path);
123  for (i = 0 + start; i < MIN(start + MAX_LINES, totLaps); i++) {
124  snprintf(path, BUFSIZE, "%s/%s/%s/%d", info->track->name, RE_SECT_RESULTS, race, i + 1);
125 
126  /* Lap */
127  snprintf(buf, BUFSIZE, "%d", i+1);
129 
130  /* Time */
131  GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_TIME, NULL, 0), 0);
133 
134  /* Best Lap Time */
135  GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_BEST_LAP_TIME, NULL, 0), 0);
137 
138  /* Top Spd */
139  snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_TOP_SPEED, NULL, 0) * 3.6));
141 
142  /* Min Spd */
143  snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_BOT_SPEED, NULL, 0) * 3.6));
145 
146  /* Damages */
147  snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_DAMMAGES, NULL, 0)));
149 
150  y -= 15;
151  }
152 
153  if (start > 0) {
154  RmPrevRace.prevHdle = prevHdle;
155  RmPrevRace.info = info;
156  RmPrevRace.start = start - MAX_LINES;
157  GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-up.png", "data/img/arrow-up.png",
158  "data/img/arrow-up.png", "data/img/arrow-up-pushed.png",
159  80, 40, GFUI_ALIGN_HL_VB, 1,
161  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
162  GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_UP, "Previous Results", (void*)&RmPrevRace, rmChgPracticeScreen, NULL);
163  }
164 
166  "Continue",
168  320,
169  40,
170  150,
172  0,
173  prevHdle,
175  NULL,
176  (tfuiCallback)NULL,
177  (tfuiCallback)NULL);
178 
179  if (i < totLaps) {
180  RmNextRace.prevHdle = prevHdle;
181  RmNextRace.info = info;
182  RmNextRace.start = start + MAX_LINES;
183  GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-down.png", "data/img/arrow-down.png",
184  "data/img/arrow-down.png", "data/img/arrow-down-pushed.png",
185  540, 40, GFUI_ALIGN_HL_VB, 1,
187  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
188  GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_DOWN, "Next Results", (void*)&RmNextRace, rmChgPracticeScreen, NULL);
189  }
190 
191  GfuiAddKey(rmScrHdle, (unsigned char)27, "", prevHdle, GfuiScreenReplace, NULL);
192  GfuiAddKey(rmScrHdle, (unsigned char)13, "", prevHdle, GfuiScreenReplace, NULL);
193  GfuiAddSKey(rmScrHdle, GLUT_KEY_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL);
194 
196 }
197 
198 
199 static void rmChgRaceScreen(void *vprc)
200 {
201  void *prevScr = rmScrHdle;
202  tRaceCall *prc = (tRaceCall*)vprc;
203 
204  rmRaceResults(prc->prevHdle, prc->info, prc->start);
205  GfuiScreenRelease(prevScr);
206 }
207 
208 
209 static void rmRaceResults(void *prevHdle, tRmInfo *info, int start)
210 {
211  void *results = info->results;
212  const char *race = info->_reRaceName;
213  int i;
214  int x1, x2, x3, x4, x5, x6, x7, x8, x9;
215  int dlap;
216  int y;
217  const int BUFSIZE = 1024;
218  char buf[BUFSIZE];
219  char path[BUFSIZE];
220  const int TIMEFMTSIZE = 256;
221  char timefmt[TIMEFMTSIZE];
222  float fgcolor[4] = {1.0, 0.0, 1.0, 1.0};
223  int laps, totLaps;
224  tdble refTime;
225  int nbCars;
226 
228  snprintf(buf, BUFSIZE, "Race Results");
229  GfuiTitleCreate(rmScrHdle, buf, strlen(buf));
230  snprintf(buf, BUFSIZE, "%s", info->track->name);
232  320, 420, GFUI_ALIGN_HC_VB, 0);
233  GfuiScreenAddBgImg(rmScrHdle, "data/img/splash-result.png");
234 
235  x1 = 30;
236  x2 = 60;
237  x3 = 260;
238  x4 = 330;
239  x5 = 360;
240  x6 = 420;
241  x7 = 490;
242  x8 = 545;
243  x9 = 630;
244 
245  y = 400;
247  GfuiLabelCreateEx(rmScrHdle, "Driver", fgcolor, GFUI_FONT_MEDIUM_C, x2+10, y, GFUI_ALIGN_HL_VB, 0);
248  GfuiLabelCreateEx(rmScrHdle, "Total", fgcolor, GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HR_VB, 0);
251  GfuiLabelCreateEx(rmScrHdle, "Top Spd", fgcolor, GFUI_FONT_MEDIUM_C, x6, y, GFUI_ALIGN_HC_VB, 0);
252  GfuiLabelCreateEx(rmScrHdle, "Damage", fgcolor, GFUI_FONT_MEDIUM_C, x7, y, GFUI_ALIGN_HC_VB, 0);
254  GfuiLabelCreateEx(rmScrHdle, "Penalty", fgcolor, GFUI_FONT_MEDIUM_C, x9, y, GFUI_ALIGN_HR_VB, 0);
255  y -= 20;
256 
257  snprintf(path, BUFSIZE, "%s/%s/%s", info->track->name, RE_SECT_RESULTS, race);
258  totLaps = (int)GfParmGetNum(results, path, RE_ATTR_LAPS, NULL, 0);
259  snprintf(path, BUFSIZE, "%s/%s/%s/%s/%d", info->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK, 1);
260  refTime = GfParmGetNum(results, path, RE_ATTR_TIME, NULL, 0);
261  snprintf(path, BUFSIZE, "%s/%s/%s/%s", info->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK);
262  nbCars = (int)GfParmGetEltNb(results, path);
263  for (i = start; i < MIN(start + MAX_LINES, nbCars); i++) {
264  snprintf(path, BUFSIZE, "%s/%s/%s/%s/%d", info->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK, i + 1);
265  laps = (int)GfParmGetNum(results, path, RE_ATTR_LAPS, NULL, 0);
266 
267  snprintf(buf, BUFSIZE, "%d", i+1);
269  x1, y, GFUI_ALIGN_HC_VB, 0);
270 
272  x2, y, GFUI_ALIGN_HL_VB, 0);
273 
274  if (laps == totLaps) {
275  if (i == 0) {
276  GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_TIME, NULL, 0), 0);
277  } else {
278  GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_TIME, NULL, 0) - refTime, 1);
279  }
281  } else {
282  dlap = totLaps - laps;
283  if (dlap == 1) {
284  snprintf(buf, BUFSIZE, "+1 Lap");
285  } else {
286  snprintf(buf, BUFSIZE, "+%d Laps", dlap);
287  }
289 
290  }
291 
292  GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_BEST_LAP_TIME, NULL, 0), 0);
294  x4, y, GFUI_ALIGN_HR_VB, 0);
295 
296  snprintf(buf, BUFSIZE, "%d", laps);
298  x5, y, GFUI_ALIGN_HC_VB, 0);
299 
300  snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_TOP_SPEED, NULL, 0) * 3.6));
302  x6, y, GFUI_ALIGN_HC_VB, 0);
303 
304  snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_DAMMAGES, NULL, 0)));
306  x7, y, GFUI_ALIGN_HC_VB, 0);
307 
308  snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_NB_PIT_STOPS, NULL, 0)));
310  x8, y, GFUI_ALIGN_HC_VB, 0);
311 
312  GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_PENALTYTIME, NULL, 0), 0);
314 
315  y -= 15;
316  }
317 
318  if (start > 0) {
319  RmPrevRace.prevHdle = prevHdle;
320  RmPrevRace.info = info;
321  RmPrevRace.start = start - MAX_LINES;
322  GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-up.png", "data/img/arrow-up.png",
323  "data/img/arrow-up.png", "data/img/arrow-up-pushed.png",
324  80, 40, GFUI_ALIGN_HL_VB, 1,
325  (void*)&RmPrevRace, rmChgRaceScreen,
326  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
327  GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_UP, "Previous Results", (void*)&RmPrevRace, rmChgRaceScreen, NULL);
328  }
329 
331  "Continue",
333  /* 210, */
334  320,
335  40,
336  150,
338  0,
339  prevHdle,
341  NULL,
342  (tfuiCallback)NULL,
343  (tfuiCallback)NULL);
344 
345  if (i < nbCars) {
346  RmNextRace.prevHdle = prevHdle;
347  RmNextRace.info = info;
348  RmNextRace.start = start + MAX_LINES;
349  GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-down.png", "data/img/arrow-down.png",
350  "data/img/arrow-down.png", "data/img/arrow-down-pushed.png",
351  540, 40, GFUI_ALIGN_HL_VB, 1,
352  (void*)&RmNextRace, rmChgRaceScreen,
353  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
354  GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_DOWN, "Next Results", (void*)&RmNextRace, rmChgRaceScreen, NULL);
355  }
356 
357  GfuiAddKey(rmScrHdle, (unsigned char)27, "", prevHdle, GfuiScreenReplace, NULL);
358  GfuiAddKey(rmScrHdle, (unsigned char)13, "", prevHdle, GfuiScreenReplace, NULL);
359  GfuiAddSKey(rmScrHdle, GLUT_KEY_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL);
360 
362 }
363 
364 
365 static void rmChgQualifScreen(void *vprc)
366 {
367  void *prevScr = rmScrHdle;
368  tRaceCall *prc = (tRaceCall*)vprc;
369 
370  rmQualifResults(prc->prevHdle, prc->info, prc->start);
371  GfuiScreenRelease(prevScr);
372 }
373 
374 
375 static void rmQualifResults(void *prevHdle, tRmInfo *info, int start)
376 {
377  void *results = info->results;
378  const char *race = info->_reRaceName;
379  int i;
380  int x1, x2, x3;
381  int y;
382  const int BUFSIZE = 1024;
383  char buf[BUFSIZE];
384  char path[BUFSIZE];
385  const int TIMEFMTSIZE = 256;
386  char timefmt[TIMEFMTSIZE];
387  float fgcolor[4] = {1.0, 0.0, 1.0, 1.0};
388  int nbCars;
389  int offset;
390 
392  snprintf(buf, BUFSIZE, "Qualification Results");
393  GfuiTitleCreate(rmScrHdle, buf, strlen(buf));
394  snprintf(buf, BUFSIZE, "%s", info->track->name);
396  320, 420, GFUI_ALIGN_HC_VB, 0);
397  GfuiScreenAddBgImg(rmScrHdle, "data/img/splash-result.png");
398 
399  offset = 200;
400  x1 = offset + 30;
401  x2 = offset + 60;
402  x3 = offset + 240;
403 
404  y = 400;
406  GfuiLabelCreateEx(rmScrHdle, "Driver", fgcolor, GFUI_FONT_MEDIUM_C, x2+10, y, GFUI_ALIGN_HL_VB, 0);
408  y -= 20;
409 
410  snprintf(path, BUFSIZE, "%s/%s/%s/%s", info->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK);
411  nbCars = (int)GfParmGetEltNb(results, path);
412 
413  for (i = start; i < MIN(start + MAX_LINES, nbCars); i++) {
414  snprintf(path, BUFSIZE, "%s/%s/%s/%s/%d", info->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK, i + 1);
415 
416  snprintf(buf, BUFSIZE, "%d", i+1);
418  x1, y, GFUI_ALIGN_HC_VB, 0);
419 
421  x2, y, GFUI_ALIGN_HL_VB, 0);
422 
423  GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_BEST_LAP_TIME, NULL, 0), 0);
425  x3, y, GFUI_ALIGN_HR_VB, 0);
426  y -= 15;
427  }
428 
429 
430  if (start > 0) {
431  RmPrevRace.prevHdle = prevHdle;
432  RmPrevRace.info = info;
433  RmPrevRace.start = start - MAX_LINES;
434  GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-up.png", "data/img/arrow-up.png",
435  "data/img/arrow-up.png", "data/img/arrow-up-pushed.png",
436  80, 40, GFUI_ALIGN_HL_VB, 1,
437  (void*)&RmPrevRace, rmChgQualifScreen,
438  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
439  GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_UP, "Previous Results", (void*)&RmPrevRace, rmChgQualifScreen, NULL);
440  }
441 
443  "Continue",
445  320,
446  40,
447  150,
449  0,
450  prevHdle,
452  NULL,
453  (tfuiCallback)NULL,
454  (tfuiCallback)NULL);
455 
456  if (i < nbCars) {
457  RmNextRace.prevHdle = prevHdle;
458  RmNextRace.info = info;
459  RmNextRace.start = start + MAX_LINES;
460  GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-down.png", "data/img/arrow-down.png",
461  "data/img/arrow-down.png", "data/img/arrow-down-pushed.png",
462  540, 40, GFUI_ALIGN_HL_VB, 1,
463  (void*)&RmNextRace, rmChgQualifScreen,
464  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
465  GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_DOWN, "Next Results", (void*)&RmNextRace, rmChgQualifScreen, NULL);
466  }
467 
468  GfuiAddKey(rmScrHdle, (unsigned char)27, "", prevHdle, GfuiScreenReplace, NULL);
469  GfuiAddKey(rmScrHdle, (unsigned char)13, "", prevHdle, GfuiScreenReplace, NULL);
470  GfuiAddSKey(rmScrHdle, GLUT_KEY_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL);
471 
473 }
474 
475 
476 static void rmChgStandingScreen(void *vprc)
477 {
478  void *prevScr = rmScrHdle;
479  tRaceCall *prc = (tRaceCall*)vprc;
480 
481  rmShowStandings(prc->prevHdle, prc->info, prc->start);
482  GfuiScreenRelease(prevScr);
483 }
484 
485 
486 static void rmShowStandings(void *prevHdle, tRmInfo *info, int start)
487 {
488  int i;
489  int x1, x2, x3;
490  int y;
491  const int BUFSIZE = 1024;
492  char buf[BUFSIZE];
493  char path[BUFSIZE];
494  float fgcolor[4] = {1.0, 0.0, 1.0, 1.0};
495  int nbCars;
496  int offset;
497  void *results = info->results;
498  const char *race = info->_reRaceName;
499 
501  snprintf(buf, BUFSIZE, "%s Results", race);
502  GfuiTitleCreate(rmScrHdle, buf, strlen(buf));
503 
504  GfuiScreenAddBgImg(rmScrHdle, "data/img/splash-result.png");
505 
506  offset = 200;
507  x1 = offset + 30;
508  x2 = offset + 60;
509  x3 = offset + 240;
510 
511  y = 400;
513  GfuiLabelCreateEx(rmScrHdle, "Driver", fgcolor, GFUI_FONT_MEDIUM_C, x2+10, y, GFUI_ALIGN_HL_VB, 0);
514  GfuiLabelCreateEx(rmScrHdle, "Points", fgcolor, GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HR_VB, 0);
515  y -= 20;
516 
517  nbCars = (int)GfParmGetEltNb(results, RE_SECT_STANDINGS);
518  for (i = start; i < MIN(start + MAX_LINES, nbCars); i++) {
519  snprintf(path, BUFSIZE, "%s/%d", RE_SECT_STANDINGS, i + 1);
520 
521  snprintf(buf, BUFSIZE, "%d", i+1);
523  x1, y, GFUI_ALIGN_HC_VB, 0);
524 
526  x2, y, GFUI_ALIGN_HL_VB, 0);
527 
528  snprintf(buf, BUFSIZE, "%d", (int)GfParmGetNum(results, path, RE_ATTR_POINTS, NULL, 0));
530  x3, y, GFUI_ALIGN_HR_VB, 0);
531  y -= 15;
532  }
533 
534 
535  if (start > 0) {
536  RmPrevRace.prevHdle = prevHdle;
537  RmPrevRace.info = info;
538  RmPrevRace.start = start - MAX_LINES;
539  GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-up.png", "data/img/arrow-up.png",
540  "data/img/arrow-up.png", "data/img/arrow-up-pushed.png",
541  80, 40, GFUI_ALIGN_HL_VB, 1,
543  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
544  GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_UP, "Previous Results", (void*)&RmPrevRace, rmChgStandingScreen, NULL);
545  }
546 
548  "Continue",
550  210,
551  40,
552  150,
554  0,
555  prevHdle,
557  NULL,
558  (tfuiCallback)NULL,
559  (tfuiCallback)NULL);
560 
562  "Save",
564  430,
565  40,
566  150,
568  0,
569  info,
570  rmSaveRes,
571  NULL,
572  (tfuiCallback)NULL,
573  (tfuiCallback)NULL);
574 
575  if (i < nbCars) {
576  RmNextRace.prevHdle = prevHdle;
577  RmNextRace.info = info;
578  RmNextRace.start = start + MAX_LINES;
579  GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-down.png", "data/img/arrow-down.png",
580  "data/img/arrow-down.png", "data/img/arrow-down-pushed.png",
581  540, 40, GFUI_ALIGN_HL_VB, 1,
583  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
584  GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_DOWN, "Next Results", (void*)&RmNextRace, rmChgStandingScreen, NULL);
585  }
586 
587  GfuiAddKey(rmScrHdle, (unsigned char)27, "", prevHdle, GfuiScreenReplace, NULL);
588  GfuiAddKey(rmScrHdle, (unsigned char)13, "", prevHdle, GfuiScreenReplace, NULL);
589  GfuiAddSKey(rmScrHdle, GLUT_KEY_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL);
590 
592 }
593 
594 
600 void RmShowResults(void *prevHdle, tRmInfo *info)
601 {
602  switch (info->s->_raceType) {
603  case RM_TYPE_PRACTICE:
604  rmPracticeResults(prevHdle, info, 0);
605  return;
606 
607  case RM_TYPE_RACE:
608  rmRaceResults(prevHdle, info, 0);
609  return;
610 
611  case RM_TYPE_QUALIF:
612  rmQualifResults(prevHdle, info, 0);
613  return;
614  }
615 }
616 
617 
623 void RmShowStandings(void *prevHdle, tRmInfo *info)
624 {
625  rmShowStandings(prevHdle, info, 0);
626 }
Race Manager General Info.
Definition: raceman.h:218
static void rmSaveRes(void *vInfo)
Definition: results.cpp:59
void GfuiScreenReplace(void *screen)
Activate a screen and make it current plus release the current screen.
Definition: gui.cpp:506
int GfuiButtonCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a button to a screen.
Definition: guibutton.cpp:248
#define RE_SECT_STANDINGS
Definition: raceman.h:340
#define RM_TYPE_PRACTICE
Definition: raceman.h:71
int start
Definition: results.cpp:52
static void rmChgPracticeScreen(void *vprc)
Definition: results.cpp:68
#define RE_ATTR_NB_PIT_STOPS
Definition: raceman.h:354
static void rmQualifResults(void *prevHdle, tRmInfo *info, int start)
Definition: results.cpp:375
#define RE_ATTR_NAME
Definition: raceman.h:344
#define RM_ATTR_DRVNAME
Definition: raceman.h:258
#define MAX_LINES
Definition: results.cpp:46
void * results
Race results.
Definition: raceman.h:224
#define RE_ATTR_BOT_SPEED
Definition: raceman.h:352
void GfuiAddKey(void *scr, unsigned char key, const char *descr, void *userData, tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
Add a Keyboard callback to a screen.
Definition: gui.cpp:742
Robots Tools.
Robot Module Interface Definition.
void GfuiScreenRelease(void *scr)
Release the given screen.
Definition: gui.cpp:618
int GfuiLabelCreate(void *scr, const char *text, int font, int x, int y, int align, int maxlen)
Add a label to a screen.
Definition: guilabel.cpp:142
static void rmChgQualifScreen(void *vprc)
Definition: results.cpp:365
#define RE_ATTR_DAMMAGES
Definition: raceman.h:353
#define RE_ATTR_BEST_LAP_TIME
Definition: raceman.h:349
void GfuiScreenAddBgImg(void *scr, const char *filename)
Add an image background to a screen.
Definition: gui.cpp:961
#define RE_SECT_RESULTS
Definition: raceman.h:341
tSituation * s
Situation during race.
Definition: raceman.h:221
tRaceCall RmPrevRace
Definition: results.cpp:56
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
Definition: params.cpp:1610
#define GFUI_ALIGN_HR_VB
Definition: tgfclient.h:75
#define RE_SECT_RANK
Definition: raceman.h:342
int GfParmCreateDirectory(const char *file, void *parmHandle)
Create directory for parameter set handle if it does not yet exist.
Definition: params.cpp:1665
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
Definition: params.cpp:2311
#define GFUI_FONT_LARGE_C
Definition: tgfclient.h:172
The Gaming Framework API (client part).
static void rmRaceResults(void *prevHdle, tRmInfo *info, int start)
Definition: results.cpp:209
#define RE_ATTR_PENALTYTIME
Definition: raceman.h:356
#define GFUI_FONT_LARGE
Definition: tgfclient.h:168
#define RE_ATTR_TIME
Definition: raceman.h:350
#define RM_TYPE_QUALIF
Definition: raceman.h:72
#define RE_ATTR_LAPS
Definition: raceman.h:348
#define RE_ATTR_POINTS
Definition: raceman.h:355
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
const char * name
Name of the track.
Definition: track.h:504
tTrack * track
Current track.
Definition: raceman.h:222
static int rmSaveId
Definition: results.cpp:38
static void * rmScrHdle
Definition: results.cpp:39
tRaceCall RmNextRace
Definition: results.cpp:55
void * prevHdle
Definition: results.cpp:50
static void rmShowStandings(void *prevHdle, tRmInfo *info, int start)
Definition: results.cpp:486
#define RM_TYPE_RACE
Definition: raceman.h:73
void(* tfuiCallback)(void *)
Definition: tgfclient.h:105
tRmInfo * info
Definition: results.cpp:51
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
Definition: gui.cpp:467
void GfuiAddSKey(void *scr, int key, const char *descr, void *userData, tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
Add a Special Keyboard shortcut to the screen.
Definition: gui.cpp:816
#define GFUI_INVISIBLE
Object invisibility flag.
Definition: tgfclient.h:159
void RmShowStandings(void *prevHdle, tRmInfo *info)
Display standings.
Definition: results.cpp:623
#define GFUI_ALIGN_HC_VB
Definition: tgfclient.h:72
#define GFUI_ALIGN_HL_VB
Definition: tgfclient.h:69
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
Definition: params.cpp:2392
void GfuiScreenShot(void *)
Save a screen shot in png format.
Definition: gui.cpp:913
static Vector y[4]
Definition: Convex.cpp:56
int GfuiLabelCreateEx(void *scr, const char *text, float *fgColor, int font, int x, int y, int align, int maxlen)
Create a new label (extended version).
Definition: guilabel.cpp:63
int GfuiTitleCreate(void *scr, const char *text, int maxlen)
Add a Title to the screen.
Definition: guilabel.cpp:170
static void rmChgRaceScreen(void *vprc)
Definition: results.cpp:199
int GfuiGrButtonCreate(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed, int x, int y, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a graphical button to a screen.
Definition: guibutton.cpp:62
void * GfuiScreenCreate(void)
Create a new screen.
Definition: gui.cpp:543
#define GFUI_FONT_MEDIUM_C
Definition: tgfclient.h:173
int GfParmGetEltNb(void *handle, const char *path)
Count the number of subsections in a section in the parameter set handle.
Definition: params.cpp:2106
static void rmChgStandingScreen(void *vprc)
Definition: results.cpp:476
void GfTime2Str(char *result, int resultSize, tdble sec, int sgn)
Convert a time in seconds (float) to an ascii string.
Definition: tgf.cpp:193
Definition: Endpoint.h:36
void RmShowResults(void *prevHdle, tRmInfo *info)
Display results.
Definition: results.cpp:600
int GfuiVisibilitySet(void *scr, int id, int visible)
Set/unset the visibility attribute of an object.
Definition: guiobject.cpp:404
#define RE_ATTR_TOP_SPEED
Definition: raceman.h:351
static void rmPracticeResults(void *prevHdle, tRmInfo *info, int start)
Definition: results.cpp:78