TORCS  1.3.9
The Open Racing Car Simulator
driverconfig.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : driverconfig.cpp
4  created : Wed Apr 26 20:05:12 CEST 2000
5  copyright : (C) 2000 by Eric Espie
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 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <tgfclient.h>
23 #include <track.h>
24 #include <robot.h>
25 #include <playerpref.h>
26 #include <controlconfig.h>
27 #include <portability.h>
28 
29 #include "driverconfig.h"
30 
31 #define NO_DRV "--- empty ---"
32 #define dllname "human"
33 
35 static const int nbLevels = sizeof(level_str) / sizeof(level_str[0]);
36 
37 static float LabelColor[] = {1.0, 0.0, 1.0, 1.0};
38 
39 static int scrollList;
40 static void *scrHandle = NULL;
41 static void *prevHandle = NULL;
42 
43 static int NameEditId;
44 static int CarEditId;
45 static int CatEditId;
46 static int RaceNumEditId;
47 static int TransEditId;
48 static int PitsEditId;
49 static int SkillId;
50 static int AutoReverseId;
51 
52 #define NB_DRV 10
53 
54 typedef struct tInfo
55 {
56  char *name;
57  char *dispname;
58 } tInfo;
59 
60 struct tCarInfo;
61 struct tCatInfo;
62 
63 GF_TAILQ_HEAD(CarsInfoHead, struct tCarInfo);
64 GF_TAILQ_HEAD(CatsInfoHead, struct tCatInfo);
65 
66 typedef struct tCatInfo
67 {
68  struct tCatInfo *next;
69  struct tCatInfo *prev;
71  tCarsInfoHead CarsInfoList;
72  GF_TAILQ_ENTRY(struct tCatInfo) link;
73 } tCatInfo;
74 
75 typedef struct tCarInfo
76 {
77  struct tCarInfo *next;
78  struct tCarInfo *prev;
81  GF_TAILQ_ENTRY(struct tCarInfo) link;
82 } tCarInfo;
83 
84 typedef struct PlayerInfo
85 {
89  const char *transmission;
91  float color[4];
94 } tPlayerInfo;
95 
96 #define _Name info.name
97 #define _DispName info.dispname
98 
100 
101 static tCatsInfoHead CatsInfoList;
102 
104 
105 static const char *Yn[] = {HM_VAL_YES, HM_VAL_NO};
106 
107 static void
109 {
110  const int BUFSIZE = 1024;
111  char buf[BUFSIZE];
112 
113  if (curPlayer == NULL) {
116 
119 
122 
124 
127 
129 
132 
134 
136  } else {
139 
140  snprintf(buf, BUFSIZE, "%d", curPlayer->racenumber);
143 
146 
148 
149  snprintf(buf, BUFSIZE, "%d", curPlayer->racenumber);
152 
154 
155  snprintf(buf, BUFSIZE, "%d", curPlayer->nbpitstops);
158 
160 
162  }
163 }
164 
165 static void
166 onSelect(void * /* Dummy */)
167 {
169  refreshEditVal();
170 }
171 
172 static void
174 {
175  tCarInfo *curCar;
176  tCatInfo *curCat;
177  tCatInfo *tmpCat;
178  tFList *files;
179  tFList *curFile;
180  void *carparam;
181  void *hdle;
182  const int BUFSIZE = 1024;
183  char buf[BUFSIZE];
184 
185  /* Empty the lists */
186  while ((curCat = GF_TAILQ_FIRST(&CatsInfoList)) != NULL) {
187  GF_TAILQ_REMOVE(&CatsInfoList, curCat, link);
188  while ((curCar = GF_TAILQ_FIRST(&(curCat->CarsInfoList))) != NULL) {
189  GF_TAILQ_REMOVE(&(curCat->CarsInfoList), curCar, link);
190  free(curCar->_Name);
191  free(curCar->_DispName);
192  free(curCar);
193  }
194  free(curCat->_Name);
195  free(curCat->_DispName);
196  free(curCat);
197  }
198 
199  files = GfDirGetList("categories");
200  curFile = files;
201  if ((curFile != NULL) && (curFile->name[0] != '.')) {
202  do {
203  curFile = curFile->next;
204  curCat = (tCatInfo*)calloc(1, sizeof(tCatInfo));
205  GF_TAILQ_INIT(&(curCat->CarsInfoList));
206  char* str = strchr(curFile->name, '.');
207  *str = '\0';
208  curCat->_Name = strdup(curFile->name);
209  snprintf(buf, BUFSIZE, "categories/%s.xml", curFile->name);
210  hdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
211  if (!hdle) {
212  continue;
213  }
214  curCat->_DispName = strdup(GfParmGetName(hdle));
215  GfParmReleaseHandle(hdle);
216  GF_TAILQ_INSERT_TAIL(&CatsInfoList, curCat, link);
217  } while (curFile != files);
218  }
219  GfDirFreeList(files, NULL, true, false);
220 
221  files = GfDirGetList("cars");
222  curFile = files;
223  if ((curFile != NULL) && (curFile->name[0] != '.')) {
224  do {
225  curFile = curFile->next;
226  curCar = (tCarInfo*)calloc(1, sizeof(tCarInfo));
227  curCar->_Name = strdup(curFile->name);
228  snprintf(buf, BUFSIZE, "cars/%s/%s.xml", curFile->name, curFile->name);
229  carparam = GfParmReadFile(buf, GFPARM_RMODE_STD);
230  if (!carparam) {
231  continue;
232  }
233 
234  curCar->_DispName = strdup(GfParmGetName(carparam));
235  /* search for the category */
236  const char* str = GfParmGetStr(carparam, SECT_CAR, PRM_CATEGORY, "");
237  curCat = GF_TAILQ_FIRST(&CatsInfoList);
238  if (curCat != NULL) {
239  do {
240  if (strcmp(curCat->_Name, str) == 0) {
241  break;
242  }
243  } while ((curCat = GF_TAILQ_NEXT(curCat, link)) != NULL);
244  }
245  curCar->cat = curCat;
246  GF_TAILQ_INSERT_TAIL(&(curCat->CarsInfoList), curCar, link);
247  GfParmReleaseHandle(carparam);
248  } while (curFile != files);
249  }
250  GfDirFreeList(files, NULL, true, false);
251 
252  /* Remove the empty categories */
253  curCat = GF_TAILQ_FIRST(&CatsInfoList);
254  do {
255  curCar = GF_TAILQ_FIRST(&(curCat->CarsInfoList));
256  tmpCat = curCat;
257  curCat = GF_TAILQ_NEXT(curCat, link);
258  if (curCar == NULL) {
259  GfOut("Removing empty category %s\n", tmpCat->_DispName);
260  GF_TAILQ_REMOVE(&CatsInfoList, tmpCat, link);
261  free(tmpCat->_Name);
262  free(tmpCat->_DispName);
263  free(tmpCat);
264  }
265  } while (curCat != NULL);
266 
267 }
268 
269 static void
271 {
272  char *str;
273  int i;
274  void *tmp;
275 
276  /* free the previous scrollist elements */
277  while((str = GfuiScrollListExtractElement(scrHandle, scrollList, 0, (void**)&tmp)) != NULL) {
278  }
279 
280  for (i = 0; i < NB_DRV; i++) {
282  }
283 }
284 
285 static void
286 DeletePlayer(void * /* dummy */)
287 {
288  if (curPlayer) {
289  curPlayer->_DispName = strdup(NO_DRV);
290  refreshEditVal();
291  UpdtScrollList();
292  }
293 }
294 
295 static void
296 ConfControls(void * /* dummy */ )
297 {
298  int index;
299 
300  if (curPlayer) {
301  index = curPlayer - PlayersInfo + 1;
303  }
304 }
305 
306 static int
308 {
309  void *drvinfo;
310  const int SSTRINGSIZE = 256;
311  char sstring[SSTRINGSIZE];
312  int i;
313  int j;
314  const char *driver;
315  tCarInfo *car;
316  tCatInfo *cat;
317  const char *str;
318  int found;
319  const int BUFSIZE = 1024;
320  char buf[BUFSIZE];
321 
322  snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_DRV_FILE);
323  drvinfo = GfParmReadFile(buf, GFPARM_RMODE_REREAD);
324  if (drvinfo == NULL) {
325  return -1;
326  }
327 
328  for (i = 0; i < NB_DRV; i++) {
329  snprintf(sstring, SSTRINGSIZE, "%s/%s/%d", ROB_SECT_ROBOTS, ROB_LIST_INDEX, i+1);
330  driver = GfParmGetStr(drvinfo, sstring, ROB_ATTR_NAME, "");
331  if (strlen(driver) == 0) {
332  PlayersInfo[i]._DispName = strdup(NO_DRV);
333  PlayersInfo[i]._Name = strdup(dllname);
334  PlayersInfo[i].carinfo = GF_TAILQ_FIRST(&((GF_TAILQ_FIRST(&CatsInfoList))->CarsInfoList));
335  PlayersInfo[i].racenumber = 0;
336  PlayersInfo[i].color[0] = 1.0;
337  PlayersInfo[i].color[1] = 1.0;
338  PlayersInfo[i].color[2] = 0.5;
339  PlayersInfo[i].color[3] = 1.0;
340  } else {
341  PlayersInfo[i]._DispName = strdup(driver);
342  PlayersInfo[i]._Name = strdup(dllname);
343  PlayersInfo[i].skilllevel = 0;
344  str = GfParmGetStr(drvinfo, sstring, ROB_ATTR_LEVEL, level_str[0]);
345  for(j = 0; j < nbLevels; j++) {
346  if (strcmp(level_str[j], str) == 0) {
347  PlayersInfo[i].skilllevel = j;
348  break;
349  }
350  }
351  str = GfParmGetStr(drvinfo, sstring, ROB_ATTR_CAR, "");
352  found = 0;
355  do {
356  car = GF_TAILQ_FIRST(&(cat->CarsInfoList));
357  if (car != NULL) {
358  do {
359  if (strcmp(car->_Name, str) == 0) {
360  found = 1;
361  PlayersInfo[i].carinfo = car;
362  }
363  } while (!found && ((car = GF_TAILQ_NEXT(car, link)) != NULL));
364  }
365  } while (!found && ((cat = GF_TAILQ_NEXT(cat, link)) != NULL));
366  PlayersInfo[i].racenumber = (int)GfParmGetNum(drvinfo, sstring, ROB_ATTR_RACENUM, (char*)NULL, 0);
367  PlayersInfo[i].color[0] = (float)GfParmGetNum(drvinfo, sstring, ROB_ATTR_RED, (char*)NULL, 1.0);
368  PlayersInfo[i].color[1] = (float)GfParmGetNum(drvinfo, sstring, ROB_ATTR_GREEN, (char*)NULL, 1.0);;
369  PlayersInfo[i].color[2] = (float)GfParmGetNum(drvinfo, sstring, ROB_ATTR_BLUE, (char*)NULL, 0.5);;
370  PlayersInfo[i].color[3] = 1.0;
371  }
372  }
373  UpdtScrollList();
374 
375  snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_PREF_FILE);
377  if (PrefHdle == NULL) {
378  GfParmReleaseHandle(drvinfo);
379  return -1;
380  }
381 
382  for (i = 0; i < NB_DRV; i++) {
383  snprintf(sstring, SSTRINGSIZE, "%s/%s/%d", HM_SECT_PREF, HM_LIST_DRV, i+1);
384  str = GfParmGetStr(PrefHdle, sstring, HM_ATT_TRANS, HM_VAL_AUTO);
385  if (strcmp(str, HM_VAL_AUTO) == 0) {
387  } else {
389  }
390  PlayersInfo[i].nbpitstops = (int)GfParmGetNum(PrefHdle, sstring, HM_ATT_NBPITS, (char*)NULL, 0);
391  if (!strcmp(GfParmGetStr(PrefHdle, sstring, HM_ATT_AUTOREVERSE, Yn[0]), Yn[0])) {
392  PlayersInfo[i].autoreverse = 0;
393  } else {
394  PlayersInfo[i].autoreverse = 1;
395  }
396  }
397 
399  GfParmReleaseHandle(drvinfo);
400 
401  return 0;
402 }
403 
404 static void
405 SaveDrvList(void * /* dummy */)
406 {
407  void *drvinfo;
408  int i;
409  const int BUFSIZE = 1024;
410  char buf[BUFSIZE];
411 
412  snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_DRV_FILE);
413  drvinfo = GfParmReadFile(buf, GFPARM_RMODE_STD);
414  if (drvinfo == NULL) {
415  return;
416  }
417 
418  for (i = 0; i < NB_DRV; i++) {
419  snprintf(buf, BUFSIZE, "%s/%s/%d", ROB_SECT_ROBOTS, ROB_LIST_INDEX, i+1);
420  if (strcmp(PlayersInfo[i]._DispName, NO_DRV) == 0) {
421  GfParmSetStr(drvinfo, buf, ROB_ATTR_NAME, "");
422  } else {
423  GfParmSetStr(drvinfo, buf, ROB_ATTR_NAME, PlayersInfo[i]._DispName);
424  GfParmSetStr(drvinfo, buf, ROB_ATTR_CAR, PlayersInfo[i].carinfo->_Name);
425  GfParmSetNum(drvinfo, buf, ROB_ATTR_RACENUM, (char*)NULL, PlayersInfo[i].racenumber);
426  GfParmSetNum(drvinfo, buf, ROB_ATTR_RED, (char*)NULL, PlayersInfo[i].color[0]);
427  GfParmSetNum(drvinfo, buf, ROB_ATTR_GREEN, (char*)NULL, PlayersInfo[i].color[1]);
428  GfParmSetNum(drvinfo, buf, ROB_ATTR_BLUE, (char*)NULL, PlayersInfo[i].color[2]);
429  GfParmSetStr(drvinfo, buf, ROB_ATTR_TYPE, ROB_VAL_HUMAN);
430  GfParmSetStr(drvinfo, buf, ROB_ATTR_LEVEL, level_str[PlayersInfo[i].skilllevel]);
431  }
432  }
433  GfParmWriteFile(NULL, drvinfo, dllname);
434  GfParmReleaseHandle(drvinfo);
435 
436  snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_PREF_FILE);
438  for (i = 0; i < NB_DRV; i++) {
439  snprintf(buf, BUFSIZE, "%s/%s/%d", HM_SECT_PREF, HM_LIST_DRV, i+1);
440  GfParmSetStr(PrefHdle, buf, HM_ATT_TRANS, PlayersInfo[i].transmission);
441  GfParmSetNum(PrefHdle, buf, HM_ATT_NBPITS, (char*)NULL, (tdble)PlayersInfo[i].nbpitstops);
442  GfParmSetStr(PrefHdle, buf, HM_ATT_AUTOREVERSE, Yn[PlayersInfo[i].autoreverse]);
443  }
444 
445  GfParmWriteFile(NULL, PrefHdle, "preferences");
448  return;
449 }
450 
451 
452 static void
453 ChangeName(void * /* dummy */)
454 {
455  char *val;
456 
458  if (curPlayer != NULL) {
459  if (curPlayer->_DispName) {
460  free(curPlayer->_DispName);
461  }
462 
463  if (strlen(val)) {
464  curPlayer->_DispName = strdup(val);
465  } else {
466  curPlayer->_DispName = strdup(NO_DRV);
467  }
468  }
469  UpdtScrollList();
470 }
471 
472 static void
473 ChangeNum(void * /* dummy */)
474 {
475  char *val;
476  const int BUFSIZE = 1024;
477  char buf[BUFSIZE];
478 
480  if (curPlayer != NULL) {
481  curPlayer->racenumber = (int)strtol(val, (char **)NULL, 0);
482  snprintf(buf, BUFSIZE, "%d", curPlayer->racenumber);
484  }
485 }
486 
487 static void
488 ChangePits(void * /* dummy */)
489 {
490  char *val;
491  const int BUFSIZE = 1024;
492  char buf[BUFSIZE];
493 
495  if (curPlayer != NULL) {
496  curPlayer->nbpitstops = (int)strtol(val, (char **)NULL, 0);
497  snprintf(buf, BUFSIZE, "%d", curPlayer->nbpitstops);
499  }
500 }
501 
502 static void
503 ChangeCar(void *vp)
504 {
505  tCarInfo *car;
506  tCatInfo *cat;
507 
508  if (curPlayer == NULL) {
509  return;
510  }
511 
512  cat = curPlayer->carinfo->cat;
513  if (vp == 0) {
514  car = GF_TAILQ_PREV(curPlayer->carinfo, CarsInfoHead, link);
515  if (car == NULL) {
516  car = GF_TAILQ_LAST(&(cat->CarsInfoList), CarsInfoHead);
517  }
518  } else {
519  car = GF_TAILQ_NEXT(curPlayer->carinfo, link);
520  if (car == NULL) {
521  car = GF_TAILQ_FIRST(&(cat->CarsInfoList));
522  }
523  }
524  curPlayer->carinfo = car;
525  refreshEditVal();
526 }
527 
528 static void
529 ChangeCat(void *vp)
530 {
531  tCarInfo *car;
532  tCatInfo *cat;
533 
534  if (curPlayer == NULL) {
535  return;
536  }
537 
538  cat = curPlayer->carinfo->cat;
539  if (vp == 0) {
540  do {
541  cat = GF_TAILQ_PREV(cat, CatsInfoHead, link);
542  if (cat == NULL) {
543  cat = GF_TAILQ_LAST(&CatsInfoList, CatsInfoHead);
544  }
545  car = GF_TAILQ_FIRST(&(cat->CarsInfoList));
546  } while (car == NULL); /* skip empty categories */
547  } else {
548  do {
549  cat = GF_TAILQ_NEXT(cat, link);
550  if (cat == NULL) {
552  }
553  car = GF_TAILQ_FIRST(&(cat->CarsInfoList));
554  } while (car == NULL); /* skip empty categories */
555  }
556 
557  curPlayer->carinfo = car;
558  refreshEditVal();
559 }
560 
561 static void
562 ChangeLevel(void *vp)
563 {
564  if (curPlayer == NULL) {
565  return;
566  }
567 
568  if (vp == 0) {
570  if (curPlayer->skilllevel < 0) {
572  }
573  } else {
575  if (curPlayer->skilllevel == nbLevels) {
576  curPlayer->skilllevel = 0;
577  }
578  }
579  refreshEditVal();
580 }
581 
582 static void
583 ChangeReverse(void *vdelta)
584 {
585  long delta = (long)vdelta;
586 
587  if (curPlayer == NULL) {
588  return;
589  }
590 
591  curPlayer->autoreverse += (int)delta;
592  if (curPlayer->autoreverse < 0) {
593  curPlayer->autoreverse = 1;
594  } else if (curPlayer->autoreverse > 1) {
595  curPlayer->autoreverse = 0;
596  }
597 
598  refreshEditVal();
599 }
600 
601 static void
602 ChangeTrans(void * /* dummy */)
603 {
604  if (curPlayer == NULL) {
605  return;
606  }
607 
608  if (strcmp(curPlayer->transmission,HM_VAL_AUTO) != 0) {
610  } else {
612  }
613  refreshEditVal();
614 }
615 
616 void *
617 TorcsDriverMenuInit(void *prevMenu)
618 {
619  int x, y, x2, x3, x4, dy;
620  static int firstTime = 1;
621 
622  if (firstTime) {
623  firstTime = 0;
625  }
626 
627  /* screen already created */
628  if (scrHandle) {
629  GenCarsInfo();
630  GenDrvList();
631  return scrHandle;
632  }
633  prevHandle = prevMenu;
634 
636  GfuiTitleCreate(scrHandle, "Player Configuration", 0);
637 
638  GfuiScreenAddBgImg(scrHandle, "data/img/splash-qrdrv.png");
639 
640  GfuiLabelCreate(scrHandle, "Players", GFUI_FONT_LARGE, 496, 400, GFUI_ALIGN_HC_VB, 0);
641 
645  NULL, onSelect);
646 
649  NULL, DeletePlayer, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
650 
653  NULL, ConfControls, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
654 
655  GenCarsInfo();
656  if (GenDrvList()) {
658  return NULL;
659  }
660 
661  x = 20;
662  x2 = 170;
663  x3 = x2 + 100;
664  x4 = x2 + 200;
665  y = 370;
666  dy = 30;
667 
670  x2+10, y, 180, 16, NULL, (tfuiCallback)NULL, ChangeName);
671 
672  y -= dy;
674  GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
675  "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
676  x2, y, GFUI_ALIGN_HL_VB, 1,
677  (void*)0, ChangeCat,
678  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
679  GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
680  "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
681  x4, y, GFUI_ALIGN_HR_VB, 1,
682  (void*)1, ChangeCat,
683  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
686 
687  y -= dy;
689  GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
690  "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
691  x2, y, GFUI_ALIGN_HL_VB, 1,
692  (void*)0, ChangeCar,
693  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
694  GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
695  "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
696  x4, y, GFUI_ALIGN_HR_VB, 1,
697  (void*)1, ChangeCar,
698  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
701 
702  y -= dy;
703  GfuiLabelCreate(scrHandle, "Race Number:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0);
705  x2+10, y, 0, 2, NULL, (tfuiCallback)NULL, ChangeNum);
706  y -= dy;
707  GfuiLabelCreate(scrHandle, "Transmission:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0);
708  GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
709  "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
710  x2, y, GFUI_ALIGN_HL_VB, 1,
711  (void*)0, ChangeTrans,
712  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
713  GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
714  "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
715  x4, y, GFUI_ALIGN_HR_VB, 1,
716  (void*)1, ChangeTrans,
717  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
720 
721  y -= dy;
724  x2+10, y, 0, 2, NULL, (tfuiCallback)NULL, ChangePits);
725  y -= dy;
727  GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
728  "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
729  x2, y, GFUI_ALIGN_HL_VB, 1,
730  (void*)0, ChangeLevel,
731  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
732  GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
733  "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
734  x4, y, GFUI_ALIGN_HR_VB, 1,
735  (void*)1, ChangeLevel,
736  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
739 
740  y -= dy;
741  GfuiLabelCreate(scrHandle, "Auto Reverse:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0);
742  GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
743  "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
744  x2, y, GFUI_ALIGN_HL_VB, 1,
745  (void*)-1, ChangeReverse,
746  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
747  GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
748  "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
749  x4, y, GFUI_ALIGN_HR_VB, 1,
750  (void*)1, ChangeReverse,
751  NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
754 
756  NULL, SaveDrvList, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
757 
759  prevMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
760 
761  GfuiAddKey(scrHandle, 13, "Save Drivers", NULL, SaveDrvList, NULL);
762  GfuiAddKey(scrHandle, 27, "Cancel Selection", prevMenu, GfuiScreenActivate, NULL);
763  GfuiAddSKey(scrHandle, GLUT_KEY_F12, "Screen-Shot", NULL, GfuiScreenShot, NULL);
764  GfuiAddSKey(scrHandle, GLUT_KEY_LEFT, "Previous Car", (void*)0, ChangeCar, NULL);
765  GfuiAddSKey(scrHandle, GLUT_KEY_RIGHT, "Next Car", (void*)1, ChangeCar, NULL);
766  GfuiAddSKey(scrHandle, GLUT_KEY_UP, "Previous Car Category", (void*)0, ChangeCat, NULL);
767  GfuiAddSKey(scrHandle, GLUT_KEY_DOWN, "Next Car Category", (void*)1, ChangeCat, NULL);
768 
769  refreshEditVal();
770  return scrHandle;
771 }
772 
static int GenDrvList(void)
static void ChangeTrans(void *)
int GfParmSetStr(void *handle, const char *path, const char *key, const char *val)
Set a string parameter in the parameter set handle.
Definition: params.cpp:2477
char * GfuiEditboxGetString(void *scr, int id)
Get the string.
Definition: guiedit.cpp:358
struct tCarInfo tCarInfo
tInfo info
#define GFUI_MOUSE_UP
Definition: tgfclient.h:80
static void GenCarsInfo(void)
#define PRM_CATEGORY
Definition: car.h:511
#define ROB_ATTR_RED
Definition: robot.h:133
static void ChangeName(void *)
#define ROB_ATTR_LEVEL
Definition: robot.h:142
char * name
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
Definition: params.cpp:1157
static int RaceNumEditId
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 ROB_ATTR_TYPE
Definition: robot.h:137
static const int nbLevels
#define GFPARM_RMODE_STD
if handle already openned return it
Definition: tgf.h:265
struct PlayerInfo tPlayerInfo
static void * PrefHdle
#define GF_TAILQ_INSERT_TAIL(head, elm, field)
Insert an element at the tail.
Definition: tgf.h:511
#define ROB_ATTR_GREEN
Definition: robot.h:134
struct tCarInfo * prev
static tPlayerInfo * curPlayer
static void onSelect(void *)
#define _DispName
static void DeletePlayer(void *)
int GfuiScrollListInsertElement(void *scr, int Id, char *element, int index, void *userData)
Insert an element in a scroll list.
struct tInfo tInfo
char * GetLocalDir(void)
Definition: tgf.cpp:231
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
Definition: params.cpp:1834
static tCatsInfoHead CatsInfoList
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
static float LabelColor[]
char * GfuiScrollListGetSelectedElement(void *scr, int Id, void **userData)
Get the selected element from the scroll list.
#define ROB_ATTR_RACENUM
Definition: robot.h:132
static void ChangeLevel(void *vp)
Robot Module Interface Definition.
struct tCatInfo tCatInfo
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
float color[4]
static void * scrHandle
struct tCarInfo * next
tCarsInfoHead CarsInfoList
#define HM_VAL_NO
Definition: playerpref.h:117
int GfuiEditboxCreate(void *scr, const char *text, int font, int x, int y, int width, int maxlen, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost, int margin)
Add a editbox to a screen.
Definition: guiedit.cpp:57
void GfuiScreenAddBgImg(void *scr, const char *filename)
Add an image background to a screen.
Definition: gui.cpp:961
List of (DLL) files for a Directory.
Definition: tgf.h:229
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
Definition: params.cpp:1610
#define HM_VAL_AUTO
Definition: playerpref.h:113
static int AutoReverseId
#define HM_VAL_MANUAL
Definition: playerpref.h:114
#define GFUI_ALIGN_HR_VB
Definition: tgfclient.h:75
GF_TAILQ_ENTRY(struct tCarInfo) link
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
The Gaming Framework API (client part).
static void ChangeCat(void *vp)
#define dllname
static tPlayerInfo PlayersInfo[NB_DRV]
#define HM_VAL_YES
Definition: playerpref.h:116
#define GFUI_FONT_LARGE
Definition: tgfclient.h:168
char * GfuiScrollListExtractElement(void *scr, int Id, int index, void **userData)
Extract the specified element from the scroll list.
tCarInfo * carinfo
#define ROB_LIST_INDEX
Definition: robot.h:124
#define GFUI_ENABLE
Definition: tgfclient.h:162
#define HM_DRV_FILE
Definition: playerpref.h:27
static void ConfControls(void *)
static int PitsEditId
void GfuiEditboxSetString(void *scr, int id, const char *text)
Set a new string.
Definition: guiedit.cpp:383
struct FList * next
Next entry.
Definition: tgf.h:231
void GfuiLabelSetText(void *scr, int id, const char *text)
Change the text of a label.
Definition: guilabel.cpp:212
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
static int scrollList
const char * transmission
#define NB_DRV
int GfuiFontHeight(int font)
Definition: guiobject.cpp:65
#define ROB_ATTR_NAME
Definition: robot.h:126
struct tCatInfo * prev
#define GfOut
Definition: tgf.h:373
#define ROB_ATTR_BLUE
Definition: robot.h:135
#define GFPARM_RMODE_REREAD
reread the parameters from file and release the previous ones
Definition: tgf.h:266
#define GF_TAILQ_INIT(head)
Head initialization (Mandatory)
Definition: tgf.h:485
void GfuiLabelSetColor(void *scr, int id, float *color)
Change the color of a label.
Definition: guilabel.cpp:239
static const char * level_str[]
static void refreshEditVal(void)
#define ROB_VAL_AMATEUR
Definition: robot.h:145
static void SaveDrvList(void *)
#define ROB_VAL_ROOKIE
Definition: robot.h:144
static void * prevHandle
static const char * Yn[]
void * TorcsDriverMenuInit(void *prevMenu)
void(* tfuiCallback)(void *)
Definition: tgfclient.h:105
#define ROB_VAL_PRO
Definition: robot.h:147
#define HM_ATT_TRANS
Definition: playerpref.h:106
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
Definition: gui.cpp:467
#define NO_DRV
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
void GfDirFreeList(tFList *list, tfDirfreeUserData freeUserData, bool freename, bool freedispname)
Free a directory list.
Definition: directory.cpp:76
static int SkillId
int GfuiEnable(void *scr, int id, int flag)
Enable / Disable an object.
Definition: guiobject.cpp:434
#define HM_ATT_NBPITS
Definition: playerpref.h:109
static void ChangeReverse(void *vdelta)
#define GF_TAILQ_FIRST(head)
First element of a TAILQ.
Definition: tgf.h:464
#define GF_TAILQ_PREV(elm, headname, field)
Previous element of a TAILQ.
Definition: tgf.h:477
GF_TAILQ_ENTRY(struct tCatInfo) link
#define HM_SECT_PREF
Definition: playerpref.h:102
#define GFUI_DISABLE
Definition: tgfclient.h:161
int GfParmSetNum(void *handle, const char *path, const char *key, const char *unit, tdble val)
Set a numerical parameter in the parameter set handle.
Definition: params.cpp:2586
#define GFUI_ALIGN_HC_VB
Definition: tgfclient.h:72
#define ROB_SECT_ROBOTS
Definition: robot.h:122
static void ChangeNum(void *)
#define SECT_CAR
Definition: car.h:473
#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
#define GF_TAILQ_REMOVE(head, elm, field)
Remove an element.
Definition: tgf.h:541
void GfuiScreenShot(void *)
Save a screen shot in png format.
Definition: gui.cpp:913
static Vector y[4]
Definition: Convex.cpp:56
int GfuiTitleCreate(void *scr, const char *text, int maxlen)
Add a Title to the screen.
Definition: guilabel.cpp:170
#define ROB_ATTR_CAR
Definition: robot.h:130
int GfuiScrollListCreate(void *scr, int font, int x, int y, int align, int width, int height, int scrollBarPos, void *userDataOnSelect, tfuiCallback onSelect)
Create a new scroll list.
tInfo info
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
tCatInfo * cat
#define GF_TAILQ_NEXT(elm, field)
Next element of a TAILQ.
Definition: tgf.h:467
#define ROB_VAL_HUMAN
Definition: robot.h:139
void * TorcsControlMenuInit(void *prevMenu, int idx)
static void UpdtScrollList(void)
#define ROB_VAL_SEMI_PRO
Definition: robot.h:146
#define GFUI_FONT_MEDIUM_C
Definition: tgfclient.h:173
struct tCatInfo * next
static int CarEditId
#define HM_PREF_FILE
Definition: playerpref.h:28
static int CatEditId
#define GFUI_SB_NONE
Definition: tgfclient.h:88
#define GFUI_FONT_MEDIUM
Definition: tgfclient.h:169
char * name
File name.
Definition: tgf.h:233
static int TransEditId
char * dispname
#define HM_LIST_DRV
Definition: playerpref.h:104
Track Structure and Track Loader Module Definition.
#define GF_TAILQ_LAST(head, headname)
Last element of a TAILQ.
Definition: tgf.h:473
char * GfParmGetName(void *handle)
Get the name property of the parameter set handle.
Definition: params.cpp:2057
static void ChangePits(void *)
tFList * GfDirGetList(const char *dir)
Get the list of files of a given directory.
Definition: directory.cpp:43
#define GFPARM_RMODE_CREAT
Create the file if doesn&#39;t exist.
Definition: tgf.h:267
static int NameEditId
GF_TAILQ_HEAD(CarsInfoHead, struct tCarInfo)
#define HM_ATT_AUTOREVERSE
Definition: playerpref.h:47
static void ChangeCar(void *vp)