TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
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-2026 by Eric Espie, Bernhard Wymann
6 email : berniw@bluewin.ch
7
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#include <stdio.h>
20#include <stdlib.h>
21#include <tgfclient.h>
22#include <track.h>
23#include <robot.h>
24#include <playerpref.h>
25#include <controlconfig.h>
26#include <portability.h>
27
28#include "driverconfig.h"
29
30#define NO_DRV "--- empty ---"
31#define dllname "human"
32
34static const int nbLevels = sizeof(level_str) / sizeof(level_str[0]);
35
36static float LabelColor[] = {1.0, 0.0, 1.0, 1.0};
37
38static int scrollList;
39static void *scrHandle = NULL;
40static void *prevHandle = NULL;
41
42static int NameEditId;
43static int CarEditId;
44static int CatEditId;
45static int RaceNumEditId;
46static int TransEditId;
47static int PitsEditId;
48static int SkillId;
49static int AutoReverseId;
50
51#define NB_DRV 10
52
53typedef struct tInfo
54{
55 char *name;
56 char *dispname;
58
59struct tCarInfo;
60struct tCatInfo;
61
62GF_TAILQ_HEAD(CarsInfoHead, struct tCarInfo);
63GF_TAILQ_HEAD(CatsInfoHead, struct tCatInfo);
64
65typedef struct tCatInfo
66{
67 struct tCatInfo *next;
68 struct tCatInfo *prev;
70 tCarsInfoHead CarsInfoList;
73
82
94
95#define _Name info.name
96#define _DispName info.dispname
97
99
100static tCatsInfoHead CatsInfoList;
101
103
104static const char *Yn[] = {HM_VAL_YES, HM_VAL_NO};
105
106static void
108{
109 const int BUFSIZE = 1024;
110 char buf[BUFSIZE];
111
112 if (curPlayer == NULL) {
115
118
121
123
126
128
131
133
135 } else {
138
139 snprintf(buf, BUFSIZE, "%d", curPlayer->racenumber);
142
143 GfuiLabelSetText(scrHandle, CarEditId, curPlayer->carinfo->_DispName);
145
146 GfuiLabelSetText(scrHandle, CatEditId, curPlayer->carinfo->cat->_DispName);
147
148 snprintf(buf, BUFSIZE, "%d", curPlayer->racenumber);
151
153
154 snprintf(buf, BUFSIZE, "%d", curPlayer->nbpitstops);
157
159
161 }
162}
163
164static void
165onSelect(void * /* Dummy */)
166{
169}
170
171static void
173{
174 tCarInfo *curCar;
175 tCatInfo *curCat;
176 tCatInfo *tmpCat;
177 tFList *files;
178 tFList *curFile;
179 void *carparam;
180 void *hdle;
181 const int BUFSIZE = 1024;
182 char buf[BUFSIZE];
183
184 /* Empty the lists */
185 while ((curCat = GF_TAILQ_FIRST(&CatsInfoList)) != NULL) {
186 GF_TAILQ_REMOVE(&CatsInfoList, curCat, link);
187 while ((curCar = GF_TAILQ_FIRST(&(curCat->CarsInfoList))) != NULL) {
188 GF_TAILQ_REMOVE(&(curCat->CarsInfoList), curCar, link);
189 free(curCar->_Name);
190 free(curCar->_DispName);
191 free(curCar);
192 }
193 free(curCat->_Name);
194 free(curCat->_DispName);
195 free(curCat);
196 }
197
198 files = GfDirGetList("categories");
199 curFile = files;
200 if ((curFile != NULL) && (curFile->name[0] != '.')) {
201 do {
202 curFile = curFile->next;
203 curCat = (tCatInfo*)calloc(1, sizeof(tCatInfo));
204 GF_TAILQ_INIT(&(curCat->CarsInfoList));
205 char* str = strchr(curFile->name, '.');
206 *str = '\0';
207 curCat->_Name = strdup(curFile->name);
208 snprintf(buf, BUFSIZE, "categories/%s.xml", curFile->name);
209 hdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
210 if (!hdle) {
211 continue;
212 }
213 curCat->_DispName = strdup(GfParmGetName(hdle));
215 GF_TAILQ_INSERT_TAIL(&CatsInfoList, curCat, link);
216 } while (curFile != files);
217 }
218 GfDirFreeList(files, NULL, true, false);
219
220 files = GfDirGetList("cars");
221 curFile = files;
222 if ((curFile != NULL) && (curFile->name[0] != '.')) {
223 do {
224 curFile = curFile->next;
225 curCar = (tCarInfo*)calloc(1, sizeof(tCarInfo));
226 curCar->_Name = strdup(curFile->name);
227 snprintf(buf, BUFSIZE, "cars/%s/%s.xml", curFile->name, curFile->name);
228 carparam = GfParmReadFile(buf, GFPARM_RMODE_STD);
229 if (!carparam) {
230 continue;
231 }
232
233 curCar->_DispName = strdup(GfParmGetName(carparam));
234 /* search for the category */
235 const char* str = GfParmGetStr(carparam, SECT_CAR, PRM_CATEGORY, "");
236 curCat = GF_TAILQ_FIRST(&CatsInfoList);
237 if (curCat != NULL) {
238 do {
239 if (strcmp(curCat->_Name, str) == 0) {
240 break;
241 }
242 } while ((curCat = GF_TAILQ_NEXT(curCat, link)) != NULL);
243 }
244 curCar->cat = curCat;
245 GF_TAILQ_INSERT_TAIL(&(curCat->CarsInfoList), curCar, link);
246 GfParmReleaseHandle(carparam);
247 } while (curFile != files);
248 }
249 GfDirFreeList(files, NULL, true, false);
250
251 /* Remove the empty categories */
252 curCat = GF_TAILQ_FIRST(&CatsInfoList);
253 do {
254 curCar = GF_TAILQ_FIRST(&(curCat->CarsInfoList));
255 tmpCat = curCat;
256 curCat = GF_TAILQ_NEXT(curCat, link);
257 if (curCar == NULL) {
258 GfOut("Removing empty category %s\n", tmpCat->_DispName);
259 GF_TAILQ_REMOVE(&CatsInfoList, tmpCat, link);
260 free(tmpCat->_Name);
261 free(tmpCat->_DispName);
262 free(tmpCat);
263 }
264 } while (curCat != NULL);
265
266}
267
268static void
270{
271 char *str;
272 int i;
273 void *tmp;
274
275 /* free the previous scrollist elements */
276 while((str = GfuiScrollListExtractElement(scrHandle, scrollList, 0, (void**)&tmp)) != NULL) {
277 }
278
279 for (i = 0; i < NB_DRV; i++) {
281 }
282}
283
284static void
285DeletePlayer(void * /* dummy */)
286{
287 if (curPlayer) {
288 curPlayer->_DispName = strdup(NO_DRV);
291 }
292}
293
294static void
295ConfControls(void * /* dummy */ )
296{
297 int index;
298
299 if (curPlayer) {
300 index = curPlayer - PlayersInfo + 1;
302 }
303}
304
305static int
307{
308 void *drvinfo;
309 const int SSTRINGSIZE = 256;
310 char sstring[SSTRINGSIZE];
311 int i;
312 int j;
313 const char *driver;
314 tCarInfo *car;
315 tCatInfo *cat;
316 const char *str;
317 int found;
318 const int BUFSIZE = 1024;
319 char buf[BUFSIZE];
320
321 snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_DRV_FILE);
322 drvinfo = GfParmReadFile(buf, GFPARM_RMODE_REREAD);
323 if (drvinfo == NULL) {
324 return -1;
325 }
326
327 for (i = 0; i < NB_DRV; i++) {
328 snprintf(sstring, SSTRINGSIZE, "%s/%s/%d", ROB_SECT_ROBOTS, ROB_LIST_INDEX, i+1);
329 driver = GfParmGetStr(drvinfo, sstring, ROB_ATTR_NAME, "");
330 if (strlen(driver) == 0) {
331 PlayersInfo[i]._DispName = strdup(NO_DRV);
332 PlayersInfo[i]._Name = strdup(dllname);
333 PlayersInfo[i].carinfo = GF_TAILQ_FIRST(&((GF_TAILQ_FIRST(&CatsInfoList))->CarsInfoList));
334 PlayersInfo[i].racenumber = 0;
335 PlayersInfo[i].color[0] = 1.0;
336 PlayersInfo[i].color[1] = 1.0;
337 PlayersInfo[i].color[2] = 0.5;
338 PlayersInfo[i].color[3] = 1.0;
339 } else {
340 PlayersInfo[i]._DispName = strdup(driver);
341 PlayersInfo[i]._Name = strdup(dllname);
342 PlayersInfo[i].skilllevel = 0;
343 str = GfParmGetStr(drvinfo, sstring, ROB_ATTR_LEVEL, level_str[0]);
344 for(j = 0; j < nbLevels; j++) {
345 if (strcmp(level_str[j], str) == 0) {
346 PlayersInfo[i].skilllevel = j;
347 break;
348 }
349 }
350 str = GfParmGetStr(drvinfo, sstring, ROB_ATTR_CAR, "");
351 found = 0;
353 PlayersInfo[i].carinfo = GF_TAILQ_FIRST(&(cat->CarsInfoList));
354 do {
355 car = GF_TAILQ_FIRST(&(cat->CarsInfoList));
356 if (car != NULL) {
357 do {
358 if (strcmp(car->_Name, str) == 0) {
359 found = 1;
360 PlayersInfo[i].carinfo = car;
361 }
362 } while (!found && ((car = GF_TAILQ_NEXT(car, link)) != NULL));
363 }
364 } while (!found && ((cat = GF_TAILQ_NEXT(cat, link)) != NULL));
365 PlayersInfo[i].racenumber = (int)GfParmGetNum(drvinfo, sstring, ROB_ATTR_RACENUM, (char*)NULL, 0);
366 PlayersInfo[i].color[0] = (float)GfParmGetNum(drvinfo, sstring, ROB_ATTR_RED, (char*)NULL, 1.0);
367 PlayersInfo[i].color[1] = (float)GfParmGetNum(drvinfo, sstring, ROB_ATTR_GREEN, (char*)NULL, 1.0);;
368 PlayersInfo[i].color[2] = (float)GfParmGetNum(drvinfo, sstring, ROB_ATTR_BLUE, (char*)NULL, 0.5);;
369 PlayersInfo[i].color[3] = 1.0;
370 }
371 }
373
374 snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_PREF_FILE);
376 if (PrefHdle == NULL) {
377 GfParmReleaseHandle(drvinfo);
378 return -1;
379 }
380
381 for (i = 0; i < NB_DRV; i++) {
382 snprintf(sstring, SSTRINGSIZE, "%s/%s/%d", HM_SECT_PREF, HM_LIST_DRV, i+1);
384 if (strcmp(str, HM_VAL_AUTO) == 0) {
385 PlayersInfo[i].transmission = HM_VAL_AUTO;
386 } else {
387 PlayersInfo[i].transmission = HM_VAL_MANUAL;
388 }
389 PlayersInfo[i].nbpitstops = (int)GfParmGetNum(PrefHdle, sstring, HM_ATT_NBPITS, (char*)NULL, 0);
390 if (!strcmp(GfParmGetStr(PrefHdle, sstring, HM_ATT_AUTOREVERSE, Yn[0]), Yn[0])) {
391 PlayersInfo[i].autoreverse = 0;
392 } else {
393 PlayersInfo[i].autoreverse = 1;
394 }
395 }
396
398 GfParmReleaseHandle(drvinfo);
399
400 return 0;
401}
402
403static void
404SaveDrvList(void * /* dummy */)
405{
406 void *drvinfo;
407 int i;
408 const int BUFSIZE = 1024;
409 char buf[BUFSIZE];
410
411 snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_DRV_FILE);
412 drvinfo = GfParmReadFile(buf, GFPARM_RMODE_STD);
413 if (drvinfo == NULL) {
414 return;
415 }
416
417 for (i = 0; i < NB_DRV; i++) {
418 snprintf(buf, BUFSIZE, "%s/%s/%d", ROB_SECT_ROBOTS, ROB_LIST_INDEX, i+1);
419 if (strcmp(PlayersInfo[i]._DispName, NO_DRV) == 0) {
420 GfParmSetStr(drvinfo, buf, ROB_ATTR_NAME, "");
421 } else {
423 GfParmSetStr(drvinfo, buf, ROB_ATTR_CAR, PlayersInfo[i].carinfo->_Name);
424 GfParmSetNum(drvinfo, buf, ROB_ATTR_RACENUM, (char*)NULL, PlayersInfo[i].racenumber);
425 GfParmSetNum(drvinfo, buf, ROB_ATTR_RED, (char*)NULL, PlayersInfo[i].color[0]);
426 GfParmSetNum(drvinfo, buf, ROB_ATTR_GREEN, (char*)NULL, PlayersInfo[i].color[1]);
427 GfParmSetNum(drvinfo, buf, ROB_ATTR_BLUE, (char*)NULL, PlayersInfo[i].color[2]);
429 GfParmSetStr(drvinfo, buf, ROB_ATTR_LEVEL, level_str[PlayersInfo[i].skilllevel]);
430 }
431 }
432 GfParmWriteFile(NULL, drvinfo, dllname);
433 GfParmReleaseHandle(drvinfo);
434
435 snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_PREF_FILE);
437 for (i = 0; i < NB_DRV; i++) {
438 snprintf(buf, BUFSIZE, "%s/%s/%d", HM_SECT_PREF, HM_LIST_DRV, i+1);
439 GfParmSetStr(PrefHdle, buf, HM_ATT_TRANS, PlayersInfo[i].transmission);
440 GfParmSetNum(PrefHdle, buf, HM_ATT_NBPITS, (char*)NULL, (tdble)PlayersInfo[i].nbpitstops);
441 GfParmSetStr(PrefHdle, buf, HM_ATT_AUTOREVERSE, Yn[PlayersInfo[i].autoreverse]);
442 }
443
444 GfParmWriteFile(NULL, PrefHdle, "preferences");
447 return;
448}
449
450
451static void
452ChangeName(void * /* dummy */)
453{
454 char *val;
455
457 if (curPlayer != NULL) {
458 if (curPlayer->_DispName) {
459 free(curPlayer->_DispName);
460 }
461
462 if (strlen(val)) {
463 curPlayer->_DispName = strdup(val);
464 } else {
465 curPlayer->_DispName = strdup(NO_DRV);
466 }
467 }
469}
470
471static void
472ChangeNum(void * /* dummy */)
473{
474 char *val;
475 const int BUFSIZE = 1024;
476 char buf[BUFSIZE];
477
479 if (curPlayer != NULL) {
480 curPlayer->racenumber = (int)strtol(val, (char **)NULL, 0);
481 snprintf(buf, BUFSIZE, "%d", curPlayer->racenumber);
483 }
484}
485
486static void
487ChangePits(void * /* dummy */)
488{
489 char *val;
490 const int BUFSIZE = 1024;
491 char buf[BUFSIZE];
492
494 if (curPlayer != NULL) {
495 curPlayer->nbpitstops = (int)strtol(val, (char **)NULL, 0);
496 snprintf(buf, BUFSIZE, "%d", curPlayer->nbpitstops);
498 }
499}
500
501static void
502ChangeCar(int delta)
503{
504 tCarInfo *car;
505 tCatInfo *cat;
506
507 if (curPlayer == NULL) {
508 return;
509 }
510
511 cat = curPlayer->carinfo->cat;
512 if (delta < 0) {
513 car = GF_TAILQ_PREV(curPlayer->carinfo, CarsInfoHead, link);
514 if (car == NULL) {
515 car = GF_TAILQ_LAST(&(cat->CarsInfoList), CarsInfoHead);
516 }
517 } else {
518 car = GF_TAILQ_NEXT(curPlayer->carinfo, link);
519 if (car == NULL) {
520 car = GF_TAILQ_FIRST(&(cat->CarsInfoList));
521 }
522 }
523 curPlayer->carinfo = car;
525}
526
527static void
528ChangeCat(int delta)
529{
530 tCarInfo *car;
531 tCatInfo *cat;
532
533 if (curPlayer == NULL) {
534 return;
535 }
536
537 cat = curPlayer->carinfo->cat;
538 if (delta < 0) {
539 do {
540 cat = GF_TAILQ_PREV(cat, CatsInfoHead, link);
541 if (cat == NULL) {
542 cat = GF_TAILQ_LAST(&CatsInfoList, CatsInfoHead);
543 }
544 car = GF_TAILQ_FIRST(&(cat->CarsInfoList));
545 } while (car == NULL); /* skip empty categories */
546 } else {
547 do {
548 cat = GF_TAILQ_NEXT(cat, link);
549 if (cat == NULL) {
551 }
552 car = GF_TAILQ_FIRST(&(cat->CarsInfoList));
553 } while (car == NULL); /* skip empty categories */
554 }
555
556 curPlayer->carinfo = car;
558}
559
560static void
561ChangeLevel(int delta)
562{
563 if (curPlayer == NULL) {
564 return;
565 }
566
567 if (delta < 0) {
568 curPlayer->skilllevel--;
569 if (curPlayer->skilllevel < 0) {
570 curPlayer->skilllevel = nbLevels - 1;
571 }
572 } else {
573 curPlayer->skilllevel++;
574 if (curPlayer->skilllevel == nbLevels) {
575 curPlayer->skilllevel = 0;
576 }
577 }
579}
580
581static void
583{
584 if (curPlayer == NULL) {
585 return;
586 }
587
588 curPlayer->autoreverse += (int)delta;
589 if (curPlayer->autoreverse < 0) {
590 curPlayer->autoreverse = 1;
591 } else if (curPlayer->autoreverse > 1) {
592 curPlayer->autoreverse = 0;
593 }
594
596}
597
598static void
599ChangeTrans(void * /* dummy */)
600{
601 if (curPlayer == NULL) {
602 return;
603 }
604
605 if (strcmp(curPlayer->transmission,HM_VAL_AUTO) != 0) {
606 curPlayer->transmission = HM_VAL_AUTO;
607 } else {
608 curPlayer->transmission = HM_VAL_MANUAL;
609 }
611}
612
613void *
614TorcsDriverMenuInit(void *prevMenu)
615{
616 int x, y, x2, x3, x4, dy;
617 static int firstTime = 1;
618
619 if (firstTime) {
620 firstTime = 0;
622 }
623
624 /* screen already created */
625 if (scrHandle) {
626 GenCarsInfo();
627 GenDrvList();
628 return scrHandle;
629 }
630 prevHandle = prevMenu;
631
633 GfuiTitleCreate(scrHandle, "Player Configuration", 0);
634
635 GfuiScreenAddBgImg(scrHandle, "data/img/splash-qrdrv.png");
636
638
642 [] { onSelect(NULL); });
643
646 [] { DeletePlayer(NULL); }, tGfuiAction(), tGfuiAction());
647
650 [] { ConfControls(NULL); }, tGfuiAction(), tGfuiAction());
651
652 GenCarsInfo();
653 if (GenDrvList()) {
655 return NULL;
656 }
657
658 x = 20;
659 x2 = 170;
660 x3 = x2 + 100;
661 x4 = x2 + 200;
662 y = 370;
663 dy = 30;
664
667 x2+10, y, 180, 16, tGfuiAction(), [] { ChangeName(NULL); });
668
669 y -= dy;
671 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
672 "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
673 x2, y, GFUI_ALIGN_HL_VB, 1,
674 [] { ChangeCat(-1); },
676 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
677 "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
678 x4, y, GFUI_ALIGN_HR_VB, 1,
679 [] { ChangeCat(1); },
683
684 y -= dy;
686 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
687 "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
688 x2, y, GFUI_ALIGN_HL_VB, 1,
689 [] { ChangeCar(-1); },
691 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
692 "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
693 x4, y, GFUI_ALIGN_HR_VB, 1,
694 [] { ChangeCar(1); },
698
699 y -= dy;
702 x2+10, y, 0, 2, tGfuiAction(), [] { ChangeNum(NULL); });
703 y -= dy;
705 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
706 "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
707 x2, y, GFUI_ALIGN_HL_VB, 1,
708 [] { ChangeTrans(NULL); },
710 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
711 "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
712 x4, y, GFUI_ALIGN_HR_VB, 1,
713 [] { ChangeTrans(NULL); },
717
718 y -= dy;
721 x2+10, y, 0, 2, tGfuiAction(), [] { ChangePits(NULL); });
722 y -= dy;
724 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
725 "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
726 x2, y, GFUI_ALIGN_HL_VB, 1,
727 [] { ChangeLevel(-1); },
729 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
730 "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
731 x4, y, GFUI_ALIGN_HR_VB, 1,
732 [] { ChangeLevel(1); },
736
737 y -= dy;
739 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png",
740 "data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
741 x2, y, GFUI_ALIGN_HL_VB, 1,
742 [] { ChangeReverse(-1); },
744 GfuiGrButtonCreateAction(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png",
745 "data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
746 x4, y, GFUI_ALIGN_HR_VB, 1,
747 [] { ChangeReverse(1); },
751
753 [] { SaveDrvList(NULL); }, tGfuiAction(), tGfuiAction());
754
756 [prevMenu] { GfuiScreenActivate(prevMenu); }, tGfuiAction(), tGfuiAction());
757
758 GfuiAddKeyAction(scrHandle, 13, "Save Drivers", [] { SaveDrvList(NULL); }, tGfuiAction());
759 GfuiAddKeyAction(scrHandle, 27, "Cancel Selection", [prevMenu] { GfuiScreenActivate(prevMenu); }, tGfuiAction());
760 GfuiAddSKeyAction(scrHandle, GLUT_KEY_F12, "Screen-Shot", [] { GfuiScreenShot(NULL); }, tGfuiAction());
761 GfuiAddSKeyAction(scrHandle, GLUT_KEY_LEFT, "Previous Car", [] { ChangeCar(-1); }, tGfuiAction());
762 GfuiAddSKeyAction(scrHandle, GLUT_KEY_RIGHT, "Next Car", [] { ChangeCar(1); }, tGfuiAction());
763 GfuiAddSKeyAction(scrHandle, GLUT_KEY_UP, "Previous Car Category", [] { ChangeCat(-1); }, tGfuiAction());
764 GfuiAddSKeyAction(scrHandle, GLUT_KEY_DOWN, "Next Car Category", [] { ChangeCat(1); }, tGfuiAction());
765
767 return scrHandle;
768}
769
static Vector y[4]
Definition Convex.cpp:56
#define SECT_CAR
Definition car.h:477
#define PRM_CATEGORY
Definition car.h:515
static void * prevHandle
void * TorcsControlMenuInit(void *prevMenu, int idx)
static void * scrHandle
static void * PrefHdle
static int CarEditId
static int NameEditId
static void SaveDrvList(void *)
static void ChangeReverse(int delta)
static int RaceNumEditId
static void onSelect(void *)
static void ConfControls(void *)
void * TorcsDriverMenuInit(void *prevMenu)
static void UpdtScrollList(void)
static int TransEditId
static void DeletePlayer(void *)
static void ChangeCat(int delta)
static int AutoReverseId
static void refreshEditVal(void)
static tPlayerInfo PlayersInfo[NB_DRV]
static void ChangePits(void *)
static const char * level_str[]
static void GenCarsInfo(void)
static tCatsInfoHead CatsInfoList
static void ChangeCar(int delta)
static int scrollList
#define _DispName
#define NB_DRV
static tPlayerInfo * curPlayer
static int PitsEditId
static const char * Yn[]
static void ChangeTrans(void *)
static void ChangeName(void *)
static const int nbLevels
static int CatEditId
#define dllname
#define NO_DRV
static int GenDrvList(void)
static int SkillId
static void ChangeLevel(int delta)
static void ChangeNum(void *)
struct PlayerInfo tPlayerInfo
static float LabelColor[]
float tdble
Floating point type used in TORCS.
Definition tgf.h:47
void GfDirFreeList(tFList *list, tfDirfreeUserData freeUserData, bool freename, bool freedispname)
Free a directory list.
Definition directory.cpp:75
tFList * GfDirGetList(const char *dir)
Get the list of files of a given directory.
Definition directory.cpp:43
void GfuiLabelSetText(void *scr, int id, const char *text)
Change the text of a label.
Definition guilabel.cpp:193
int GfuiFontHeight(int font)
Get the height of an initialized GUI font.
Definition guiobject.cpp:65
void GfuiScreenRelease(void *scr)
Release the given screen.
Definition gui.cpp:670
int GfuiScrollListCreateAction(void *scr, int font, int x, int y, int align, int width, int height, int scrollBarPos, const tGfuiAction &onSelect)
Create a new scroll list.
int GfuiTitleCreate(void *scr, const char *text, int maxlen)
Add a Title to the screen.
Definition guilabel.cpp:150
void GfuiAddKeyAction(void *scr, unsigned char key, const char *descr, const tGfuiAction &onKeyPressed, const tGfuiAction &onKeyReleased)
Add a Keyboard callback to a screen.
Definition gui.cpp:809
void GfuiScreenAddBgImg(void *scr, const char *filename)
Add an image background to a screen.
Definition gui.cpp:1058
int GfuiEditboxCreateAction(void *scr, const char *text, int font, int x, int y, int width, int maxlen, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost, int margin)
Add an edit box to a screen.
Definition guiedit.cpp:53
int GfuiScrollListInsertElement(void *scr, int Id, char *element, int index, void *userData)
Insert an element in a scroll list.
void GfuiAddSKeyAction(void *scr, int key, const char *descr, const tGfuiAction &onKeyPressed, const tGfuiAction &onKeyReleased)
Add a Special Keyboard shortcut to the screen.
Definition gui.cpp:895
char * GfuiScrollListExtractElement(void *scr, int Id, int index, void **userData)
Extract the specified element from the scroll list.
int GfuiEnable(void *scr, int id, int flag)
Enable / Disable an object.
void GfuiEditboxSetString(void *scr, int id, const char *text)
Set a new string.
Definition guiedit.cpp:390
char * GfuiScrollListGetSelectedElement(void *scr, int Id, void **userData)
Get the selected element from the scroll list.
char * GfuiEditboxGetString(void *scr, int id)
Get the current text of an edit box.
Definition guiedit.cpp:364
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:121
void GfuiLabelSetColor(void *scr, int id, float *color)
Change the color of a label.
Definition guilabel.cpp:221
int GfuiGrButtonCreateAction(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed, int x, int y, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Add a graphical button to a screen.
Definition guibutton.cpp:58
void * GfuiScreenCreate(void)
Create a new screen.
Definition gui.cpp:588
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
Definition gui.cpp:508
int GfuiButtonCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Add a button to a screen.
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:2453
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:2623
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:2534
char * GfParmGetName(void *handle)
Get the name property of the parameter set handle.
Definition params.cpp:2192
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:2737
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
Definition params.cpp:1963
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
Definition params.cpp:1732
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
Definition params.cpp:1173
void GfuiScreenShot(void *)
Save a screen shot in png format.
Definition gui.cpp:998
#define GF_TAILQ_INSERT_TAIL(head, elm, field)
Insert an element at the tail.
Definition tgf.h:510
#define GF_TAILQ_LAST(head, headname)
Last element of a TAILQ.
Definition tgf.h:472
#define GF_TAILQ_INIT(head)
Head initialization (Mandatory)
Definition tgf.h:484
#define GF_TAILQ_HEAD(name, type)
Head type definition.
Definition tgf.h:447
#define GF_TAILQ_PREV(elm, headname, field)
Previous element of a TAILQ.
Definition tgf.h:476
#define GF_TAILQ_NEXT(elm, field)
Next element of a TAILQ.
Definition tgf.h:466
#define GF_TAILQ_REMOVE(head, elm, field)
Remove an element.
Definition tgf.h:540
#define GF_TAILQ_FIRST(head)
First element of a TAILQ.
Definition tgf.h:463
#define HM_ATT_TRANS
Definition playerpref.h:106
#define HM_VAL_YES
Definition playerpref.h:116
#define HM_VAL_AUTO
Definition playerpref.h:113
#define HM_LIST_DRV
Definition playerpref.h:104
#define HM_VAL_NO
Definition playerpref.h:117
#define HM_ATT_NBPITS
Definition playerpref.h:109
#define HM_VAL_MANUAL
Definition playerpref.h:114
#define HM_PREF_FILE
Definition playerpref.h:28
#define HM_DRV_FILE
Definition playerpref.h:27
#define HM_SECT_PREF
Definition playerpref.h:102
#define HM_ATT_AUTOREVERSE
Definition playerpref.h:47
#define ROB_ATTR_CAR
Definition robot.h:128
#define ROB_ATTR_RACENUM
Definition robot.h:130
#define ROB_VAL_SEMI_PRO
Definition robot.h:144
#define ROB_ATTR_NAME
Definition robot.h:124
#define ROB_ATTR_GREEN
Definition robot.h:132
#define ROB_VAL_HUMAN
Definition robot.h:137
#define ROB_ATTR_TYPE
Definition robot.h:135
#define ROB_VAL_AMATEUR
Definition robot.h:143
#define ROB_ATTR_BLUE
Definition robot.h:133
#define ROB_ATTR_RED
Definition robot.h:131
#define ROB_VAL_PRO
Definition robot.h:145
#define ROB_SECT_ROBOTS
Definition robot.h:120
#define ROB_VAL_ROOKIE
Definition robot.h:142
#define ROB_ATTR_LEVEL
Definition robot.h:140
#define ROB_LIST_INDEX
Definition robot.h:122
struct FList * next
Next entry.
Definition tgf.h:230
char * name
File name.
Definition tgf.h:232
const char * transmission
float color[4]
tCarInfo * carinfo
tCatInfo * cat
struct tCarInfo * prev
GF_TAILQ_ENTRY(struct tCarInfo) link
struct tCarInfo * next
struct tCatInfo * prev
tCarsInfoHead CarsInfoList
GF_TAILQ_ENTRY(struct tCatInfo) link
struct tCatInfo * next
char * name
char * dispname
char * GetLocalDir(void)
Definition tgf.cpp:230
#define GfOut
Definition tgf.h:372
#define GFPARM_RMODE_CREAT
Allow an empty in-memory set on file-open failure; does not write a file.
Definition tgf.h:266
#define GFPARM_RMODE_STD
Return a new handle sharing cached data for this filename, if available.
Definition tgf.h:264
#define GFPARM_RMODE_REREAD
Clear shared cached data and reread the file.
Definition tgf.h:265
struct FList tFList
List of (DLL) files for a Directory.
#define GFUI_FONT_LARGE
Definition tgfclient.h:248
#define GFUI_ENABLE
Definition tgfclient.h:242
#define GFUI_FONT_MEDIUM
Definition tgfclient.h:249
#define GFUI_SB_NONE
Definition tgfclient.h:90
#define GFUI_FONT_MEDIUM_C
Definition tgfclient.h:253
#define GFUI_ALIGN_HL_VB
Definition tgfclient.h:71
#define GFUI_MOUSE_UP
Definition tgfclient.h:82
std::function< void()> tGfuiAction
Definition tgfclient.h:107
#define GFUI_ALIGN_HR_VB
Definition tgfclient.h:77
#define GFUI_ALIGN_HC_VB
Definition tgfclient.h:74
#define GFUI_DISABLE
Definition tgfclient.h:241