TORCS  1.3.9
The Open Racing Car Simulator
carsetupscreen.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : carsetupscreen.cpp
4  created : Wed Aug 21 13:27:34 CET 2013
5  copyright : (C) 2013-2017 Bernhard Wymann
6  email : berniw@bluewin.ch
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 #ifdef WIN32
28 #include <windows.h>
29 #endif
30 #include <tgfclient.h>
31 #include <car.h>
32 #include <portability.h>
33 #include <racescreens.h>
34 #include <robottools.h>
35 #include <vector>
36 
37 static void *scrHandle = NULL;
38 static void *prevHandle = NULL;
39 
40 static void* rmCarHandle = NULL;
41 static tCarPitSetup* rmSetup = NULL;
42 static char* rmModName = NULL;
43 static int rmIdx = 0;
44 static char* rmTrack = NULL;
45 static char* rmCarName = NULL;
47 
48 static void rmSet(void *vp);
49 static void rmUpdateMM(void *vp);
50 static void rmUpdateM(void *vp);
51 static void rmUpdateP(void *vp);
52 static void rmUpdatePP(void *vp);
53 static void enableLoadButtons();
54 
56  private:
57  void* scr; // screen
59  int id; // GUI widget id
64  const char* unit;
65  const char* format;
66 
67  void setValue(tdble value)
68  {
69  if (value > v->max) {
70  value = v->max;
71  } else if (value < v->min) {
72  value = v->min;
73  }
74  v->value = value;
75  value = GfParmSI2Unit(unit, value);
76  const int BUFSIZE = 32;
77  char buf[BUFSIZE];
78 
79  snprintf(buf, BUFSIZE, format, value);
80  GfuiEditboxSetString(scr, id, buf);
81  }
82 
83  public:
84  void set()
85  {
86  const char *val = GfuiEditboxGetString(scr, id);
87  tdble value = (tdble) atof(val);
88  value = GfParmUnit2SI(unit, value);
89  setValue(value);
90  }
91 
92  void updateMM() { update(steerdecb); }
93  void updateM() { update(steerdecs); }
94  void updateP() { update(steerincs); }
95  void updatePP() { update(steerincb); }
96 
97  void update(tdble delta)
98  {
99  if (fabs(v->min - v->max) >= 0.0001f) {
100  tdble value = v->value;
101  value += delta;
102  setValue(value);
103  }
104  }
105 
106  cGuiSetupValue(void* scr, tCarPitSetupValue* v, const char* unit, const char* format, int font, int x, int y, int w, int len):
107  scr(scr),
108  v(v),
109  unit(unit),
110  format(format)
111  {
112  const int BUFSIZE = 256;
113  char buf[BUFSIZE];
114  int enable = GFUI_ENABLE;
115 
116  steerincb = (v->max - v->min)/10.0f;
117  steerdecb = -steerincb;
118  steerincs = steerincb/10.0f;
119  steerdecs = -steerincs;
120 
121  // If min == max there is nothing to adjust, so we disable the fields
122  if (fabs(v->min - v->max) < 0.0001f) {
123  snprintf(buf, BUFSIZE, "%s", "N/A");
124  len = 3;
125  enable = GFUI_DISABLE;
126  } else {
127  snprintf(buf, BUFSIZE, format, GfParmSI2Unit(unit, v->value));
128  }
129 
130  const int sp = 3;
131  const int bw = 10;
132  const int minw = 30+4*(bw+sp);
133  if (w < minw) w = minw; // Minimal width;
134 
135  id = GfuiEditboxCreate(scr, buf, font, x + 2*(bw+sp) + 5, y, w - 4*(bw+sp) - 10, len, this, (tfuiCallback)NULL, rmSet, 5);
136  GfuiEnable(scr, id, enable);
137 
138  tdble bid;
139  bid = GfuiLeanButtonCreate(scr, "-", font, x+bw/2, y, bw, GFUI_ALIGN_HC_VB, 1,
140  this, rmUpdateMM, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
141  GfuiEnable(scr, bid, enable);
142 
143  bid = GfuiLeanButtonCreate(scr, "-", font, x+bw/2+bw+sp, y, bw, GFUI_ALIGN_HC_VB, 1,
144  this, rmUpdateM, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
145  GfuiEnable(scr, bid, enable);
146 
147  bid = GfuiLeanButtonCreate(scr, "+", font, x+w-(bw+sp+bw/2), y, bw, GFUI_ALIGN_HC_VB, 1,
148  this, rmUpdateP, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
149  GfuiEnable(scr, bid, enable);
150 
151  bid = GfuiLeanButtonCreate(scr, "+", font, x+w-bw/2, y, bw, GFUI_ALIGN_HC_VB, 1,
152  this, rmUpdatePP, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
153  GfuiEnable(scr, bid, enable);
154  }
155 
156 };
157 
158 
159 static void rmSet(void *vp)
160 {
161  cGuiSetupValue* c = static_cast<cGuiSetupValue*>(vp);
162  c->set();
163 }
164 
165 static void rmUpdateMM(void *vp)
166 {
167  cGuiSetupValue* c = static_cast<cGuiSetupValue*>(vp);
168  c->updateMM();
169 }
170 
171 static void rmUpdateM(void *vp)
172 {
173  cGuiSetupValue* c = static_cast<cGuiSetupValue*>(vp);
174  c->updateM();
175 }
176 
177 static void rmUpdateP(void *vp)
178 {
179  cGuiSetupValue* c = static_cast<cGuiSetupValue*>(vp);
180  c->updateP();
181 }
182 
183 static void rmUpdatePP(void *vp)
184 {
185  cGuiSetupValue* c = static_cast<cGuiSetupValue*>(vp);
186  c->updatePP();
187 }
188 
189 
190 static void onSave(void *vp)
191 {
193  void* carhandle = RtLoadOriginalCarSettings(rmCarName);
194  if (carhandle == 0) {
195  GfError("carhandle NULL in %s, line %d\n", __FILE__, __LINE__);
196  return;
197  }
198 
200  carhandle,
201  rmSetup,
202  *type,
203  rmModName,
204  rmIdx,
205  rmTrack,
206  rmCarName
207  );
208 
209  GfParmReleaseHandle(carhandle);
211 }
212 
213 
214 static void onSaveAndExit(void *vp)
215 {
217  void* carhandle = RtLoadOriginalCarSettings(rmCarName);
218  if (carhandle == 0) {
219  GfError("carhandle NULL in %s, line %d\n", __FILE__, __LINE__);
220  return;
221  }
222 
224  carhandle,
225  rmSetup,
226  type,
227  rmModName,
228  rmIdx,
229  rmTrack,
230  rmCarName
231  );
232 
233  GfParmReleaseHandle(carhandle);
234  if (vp != NULL) {
235  GfuiScreenActivate(vp);
236  }
237 }
238 
239 
240 static std::vector<cGuiSetupValue*> values;
241 
242 static const char* unitdeg = "deg";
243 static const char* unitkpa = "kPa";
244 static const char* unitlbfin = "lbf/in";
245 static const char* unitmm = "mm";
246 static const char* unitlbfins = "lbf/in/s";
247 static const char* unitNm = "N.m";
248 static const char* unitcms = "cm/s";
249 
250 static const char* f52 = "%5.2f";
251 static const char* f43 = "%4.3f";
252 static const char* d3 = "%3.0f";
253 static const char* d5 = "%5.0f";
254 
256 static const char* setuplabel[6] = { "Practice", "Qualifying", "Race", "Backup 1", "Backup 2", "Backup 3"};
257 static int loadbuttonid[6];
258 
259 
260 static void onLoad(void *vp)
261 {
264  rmCarHandle,
265  rmSetup,
266  *type,
267  rmModName,
268  rmIdx,
269  rmTrack,
270  rmCarName,
271  false
272  );
273 
274  // Update GUI
275  for (std::vector<cGuiSetupValue*>::iterator it = values.begin(); it != values.end(); ++it) {
276  (*it)->update(0.0f);
277  }
278 }
279 
280 
281 // Enable/disable load button depending on file existence
282 static void enableLoadButtons()
283 {
284  const int n = sizeof(loadbuttonid)/sizeof(loadbuttonid[0]);
285  int i;
286  for (i = 0; i < n; i++) {
289  } else {
291  }
292  }
293 }
294 
295 
296 static void onActivate(void *vp)
297 {
299 }
300 
301 
302 static void onLoadDefault(void* vp)
303 {
305  GfError("failed to init from default setup in %s, line %d\n", __FILE__, __LINE__);
306  return;
307  }
308 
309  // Update GUI
310  for (std::vector<cGuiSetupValue*>::iterator it = values.begin(); it != values.end(); ++it) {
311  (*it)->update(0.0f);
312  }
313 }
314 
315 
325 void *RmCarSetupScreenInit(void *prevMenu, tCarElt *car, tRmInfo* reInfo)
326 {
327  const int BUFSIZE = 1024;
328  char buf[BUFSIZE];
329 
330  prevHandle = prevMenu;
331 
332  rmCarHandle = car->_carHandle;
333  rmSetup = &(car->pitcmd.setup);
334  rmModName = car->_modName;
335  rmIdx = car->_driverIndex;
336  rmTrack = reInfo->track->internalname;
337  rmCarName = car->_carName;
338  rmRaceType = reInfo->s->raceInfo.type;
339 
340  if (scrHandle) {
342  for (std::vector<cGuiSetupValue*>::iterator it = values.begin(); it != values.end(); ++it) {
343  delete *it;
344  }
345  values.clear();
346  }
347 
348  scrHandle = GfuiScreenCreateEx(NULL, NULL, onActivate, NULL, NULL, 1);
349  snprintf(buf, BUFSIZE, "Car Setup - %s - %s - %d", rmCarName, rmTrack, rmIdx);
350  GfuiLabelCreate(scrHandle, buf, GFUI_FONT_MEDIUM, 320, 460, GFUI_ALIGN_HC_VB, strlen(buf));
352 
353  static const int x0 = 20;
354  static const int y0 = 428;
355  static const int dy = -12;
356  static const int xoff = 112;
357  static const int xoff2 = 40;
358 
359  int i;
360  static const int font = GFUI_FONT_SMALL_C;
361  int col = 0;
362 
363  // Suspension/Wheel settings
364  GfuiLabelCreate(scrHandle, "Ride height [mm]:", font, x0, y0 + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
365  GfuiLabelCreate(scrHandle, "Camber [deg]:", font, x0, y0 + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
366  GfuiLabelCreate(scrHandle, "Toe [deg]:", font, x0, y0 + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
367  GfuiLabelCreate(scrHandle, "Caster [deg]:", font, x0, y0 + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
368 
369  int y = y0 + (4.3f * dy);
370  col = 0;
371  GfuiLabelCreate(scrHandle, "Spring [lbf/in]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
372  GfuiLabelCreate(scrHandle, "Packers [mm]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
373  GfuiLabelCreate(scrHandle, "Slow bump [lbf/in/s]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
374  GfuiLabelCreate(scrHandle, "Slow rebound [lbf/in/s]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
375  GfuiLabelCreate(scrHandle, "Fast bump [lbf/in/s]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
376  GfuiLabelCreate(scrHandle, "Fast rebound [lbf/in/s]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
377  GfuiLabelCreate(scrHandle, "Bump threshold [cm/s]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
378  GfuiLabelCreate(scrHandle, "Rebound threshold [cm/s]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
379 
380  static const char* wheellabel[4] = {"Front right wheel", "Front left wheel", "Rear right wheel", "Rear left wheel"};
381 
382  for (i = 0; i < 4; i++) {
383  col = 0;
384  GfuiLabelCreate(scrHandle, wheellabel[i], font, x0 + xoff*(i+1) + xoff2, y0 - dy, GFUI_ALIGN_HL_VB, 0);
385  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->wheelrideheight[i]), unitmm, d3, font, x0 + xoff*(i+1) + xoff2, y0 + (col++ * dy), 102, 5));
386  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->wheelcamber[i]), unitdeg, f52, font, x0 + xoff*(i+1) + xoff2, y0 + (col++ * dy), 102, 5));
387  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->wheeltoe[i]), unitdeg, f52, font, x0 + xoff*(i+1) + xoff2, y0 + (col++ * dy), 102, 5));
388  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->wheelcaster[i]), unitdeg, f52, font, x0 + xoff*(i+1) + xoff2, y0 + (col++ * dy), 102, 5));
389 
390  y = y0 + (4.3f * dy);
391  col = 0;
392  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->suspspring[i]), unitlbfin, d5, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
393  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->susppackers[i]), unitmm, d3, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
394  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->suspslowbump[i]), unitlbfins, d5, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
395  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->suspslowrebound[i]), unitlbfins, d5, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
396  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->suspfastbump[i]), unitlbfins, d5, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
397  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->suspfastrebound[i]), unitlbfins, d5, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
398 
399  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->suspbumpthreshold[i]), unitcms, d3, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
400  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->suspreboundthreshold[i]), unitcms, d3, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
401 
402  }
403 
404  // Steer, brake and axle settings
405  y = y0 + 12.7f*dy;
406  col = 1;
407  GfuiLabelCreate(scrHandle, "Various settings", font, x0 + xoff + xoff2, y, GFUI_ALIGN_HL_VB, 0);
408 
409  GfuiLabelCreate(scrHandle, "Steer lock [deg]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
410  GfuiLabelCreate(scrHandle, "Brake front-rear [-]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
411  GfuiLabelCreate(scrHandle, "Brake pressure [kPa]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
412  GfuiLabelCreate(scrHandle, "Front wing [deg]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
413  GfuiLabelCreate(scrHandle, "Rear wing [deg]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
414 
415  col = 1;
416  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->steerLock), unitdeg, f52, font, x0 + xoff + xoff2, y + (col++ * dy), 102, 5));
417  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->brakeRepartition), NULL, f43, font, x0 + xoff + xoff2, y + (col++ * dy), 102, 5));
418  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->brakePressure), unitkpa, d5, font, x0 + xoff + xoff2, y + (col++ * dy), 102, 5));
419  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->wingangle[0]), unitdeg, f52, font, x0 + xoff + xoff2, y + (col++ * dy), 102, 5));
420  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->wingangle[1]), unitdeg, f52, font, x0 + xoff + xoff2, y + (col++ * dy), 102, 5));
421 
422  col = 1;
423  i = 2;
424  GfuiLabelCreate(scrHandle, "ARB spring [lbf/in]:", font, x0 + xoff*i + xoff2, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
425  GfuiLabelCreate(scrHandle, "3rd spring [lbf/in]:", font, x0 + xoff*i + xoff2, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
426  GfuiLabelCreate(scrHandle, "3rd bump [lbf/in/s]:", font, x0 + xoff*i + xoff2, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
427  GfuiLabelCreate(scrHandle, "3rd rebound [lbf/in/s]:", font, x0 + xoff*i + xoff2, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
428  GfuiLabelCreate(scrHandle, "3rd X0 [mm]:", font, x0 + xoff*i + xoff2, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
429 
430  static const char* axlelabel[2] = {"Front axle", "Rear axle"};
431 
432  int j;
433  for (j = 0; j < 2; j++) {
434  col = 1;
435  i = j + 3;
436 
437  GfuiLabelCreate(scrHandle, axlelabel[j], font, x0 + xoff*i + xoff2, y, GFUI_ALIGN_HL_VB, 0);
438  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->arbspring[j]), unitlbfin, d5, font, x0 + xoff*i + xoff2, y + (col++ * dy), 102, 5));
439  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->thirdspring[j]), unitlbfin, d5, font, x0 + xoff*i + xoff2, y + (col++ * dy), 102, 5));
440  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->thirdbump[j]), unitlbfins, d5, font, x0 + xoff*i + xoff2, y + (col++ * dy), 102, 5));
441  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->thirdrebound[j]), unitlbfins, d5, font, x0 + xoff*i + xoff2, y + (col++ * dy), 102, 5));
442  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->thirdX0[j]), unitmm, d3, font, x0 + xoff*i + xoff2, y + (col++ * dy), 102, 5));
443  }
444 
445  // Differential and gears
446  y = y + 6.5f*dy;
447  col = 1;
448  GfuiLabelCreate(scrHandle, "Type:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
449  GfuiLabelCreate(scrHandle, "Ratio [-]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
450  GfuiLabelCreate(scrHandle, "Front min bias [-]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
451  GfuiLabelCreate(scrHandle, "Front max bias [-]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
452  GfuiLabelCreate(scrHandle, "Slip bias [-]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
453  GfuiLabelCreate(scrHandle, "Accel locking torque [Nm]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
454  GfuiLabelCreate(scrHandle, "Brake locking torque [Nm]:", font, x0, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
455 
456  // enum TDiffType { NONE = 0, SPOOL = 1, FREE = 2, LIMITED_SLIP = 3, VISCOUS_COUPLER = 4};
457  static const char* diffPos[3] = {"Front differential", "Rear differential", "Center differential"};
458  static const char* diffType[5] = {"None", "Spool", "Free", "1.5 way LSD", "Viscous coupler"};
459 
460  for (i = 0; i < 3; i++) {
461  col = 0;
462 
463  GfuiLabelCreate(scrHandle, diffPos[i], font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
464  GfuiLabelCreate(scrHandle, diffType[rmSetup->diffType[i]], font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
465  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->diffratio[i]), NULL, f43, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
466  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->diffmintqbias[i]), NULL, f43, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
467  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->diffmaxtqbias[i]), NULL, f43, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
468  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->diffslipbias[i]), NULL, f43, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
469  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->difflockinginputtq[i]), unitNm, d5, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
470  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->difflockinginputbraketq[i]), unitNm, d5, font, x0 + xoff*(i+1) + xoff2, y + (col++ * dy), 102, 5));
471  }
472 
473  col = 0;
474  GfuiLabelCreate(scrHandle, "Gearbox ratios", font, x0 + xoff*4 + xoff2, y + (col++ * dy), GFUI_ALIGN_HL_VB, 0);
475 
476  for (i = 0; i < 8; i++) {
477  snprintf(buf, BUFSIZE, "%d:", i + 1);
478  GfuiLabelCreate(scrHandle, buf, font, x0 + xoff*4 + xoff2, y + (col * dy), GFUI_ALIGN_HL_VB, 0);
479  values.push_back(new cGuiSetupValue(scrHandle, &(rmSetup->gearsratio[i]), NULL, f43, font, x0 + xoff*4 + xoff2 + 12, y + (col++ * dy), 90, 5));
480  }
481 
482  // Save buttons
483  y = y0 + 27.8f*dy;
484  const int buttonwidth = 102;
485  int x = buttonwidth/2 + x0;
486 
487  GfuiLabelCreate(scrHandle, "Save setup:", font, x0, y, GFUI_ALIGN_HL_VB, 0);
488 
489  for (j = 0; j < 6; j++) {
490  GfuiLeanButtonCreate(scrHandle, setuplabel[j], font, x, y + (dy*(j+1)), buttonwidth, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
491  (void*) &setuptype[j], onSave, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
492  }
493 
494  // Load buttons
495  GfuiLabelCreate(scrHandle, "Load setup:", font, x0 + xoff + xoff2, y, GFUI_ALIGN_HL_VB, 0);
496  for (j = 0; j < 6; j++) {
497  loadbuttonid[j] = GfuiLeanButtonCreate(scrHandle, setuplabel[j], font, x + xoff + xoff2, y + (dy*(j+1)), buttonwidth, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
498  (void*) &setuptype[j], onLoad, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
499  }
500 
501  // Reload original car setup
502  GfuiLeanButtonCreate(scrHandle, "Car default", font, x + xoff + xoff2, y + (dy*7), buttonwidth, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
503  NULL, onLoadDefault, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
504 
505 
506  // Exit/Exit and save buttons
507  //GfuiButtonCreate(scrHandle, "Leave without saving", GFUI_FONT_MEDIUM, 447, 52, 306, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
508  // prevMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
509 
510  const char* savebuttontext;
511  if (rmRaceType == RM_TYPE_PRACTICE) {
512  savebuttontext = "Save practice setup and leave";
513  } else {
514  savebuttontext = "Save qualifying setup and leave";
515  }
517  prevMenu, onSaveAndExit, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
518 
519  return scrHandle;
520 }
static void onSave(void *vp)
#define GfError
Definition: tgf.h:351
Race Manager General Info.
Definition: raceman.h:218
char * GfuiEditboxGetString(void *scr, int id)
Get the string.
Definition: guiedit.cpp:358
tdble GfParmUnit2SI(const char *unit, tdble val)
Convert a value given in unit to SI.
Definition: params.cpp:1944
#define GFUI_MOUSE_UP
Definition: tgfclient.h:80
tdble max
Definition: car.h:377
cGuiSetupValue(void *scr, tCarPitSetupValue *v, const char *unit, const char *format, int font, int x, int y, int w, int len)
tCarPitSetupValue gearsratio[MAX_GEARS - 2]
Definition: car.h:417
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
tCarPitSetupValue suspslowrebound[4]
Definition: car.h:401
#define RM_TYPE_PRACTICE
Definition: raceman.h:71
static char * rmModName
void * RmCarSetupScreenInit(void *prevMenu, tCarElt *car, tRmInfo *reInfo)
Display car setup screen, for loading, saving and changing car setups.
bool RtCarPitSetupExists(rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname)
Checks if a specific car setup is available.
Definition: rttrack.cpp:988
static void * rmCarHandle
tCarPitSetupValue thirdX0[2]
Definition: car.h:414
Car structure (tCarElt).
Definition: car.h:455
void RtSaveCarPitSetup(void *hdlecar, tCarPitSetup *s, rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname)
Save a custom car setup for a given robot, car, track and session (race, practice, qualifying, ...) type.
Definition: rttrack.cpp:952
static std::vector< cGuiSetupValue * > values
tCarPitSetupValue diffmaxtqbias[3]
Definition: car.h:425
static void * prevHandle
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
Definition: params.cpp:1834
tCarPitCmd pitcmd
private
Definition: car.h:463
Robots Tools.
tCarPitSetupValue suspslowbump[4]
Definition: car.h:400
rtCarPitSetupType
Definition: robottools.h:180
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
void setValue(tdble value)
static char * rmTrack
tCarPitSetupValue brakePressure
Definition: car.h:394
static void rmUpdatePP(void *vp)
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
tSituation * s
Situation during race.
Definition: raceman.h:221
static void onLoadDefault(void *vp)
#define GFUI_FONT_SMALL_C
Definition: tgfclient.h:174
static void * scrHandle
tdble GfParmSI2Unit(const char *unit, tdble val)
Convert a value from SI to given unit.
Definition: params.cpp:1998
static int loadbuttonid[6]
tCarPitSetupValue diffratio[3]
Definition: car.h:423
static void rmUpdateP(void *vp)
The Gaming Framework API (client part).
tCarPitSetupValue brakeRepartition
Definition: car.h:395
void * RtLoadOriginalCarSettings(const char *carname)
Gets a handle to a parameter file containing the original TORCS car setup, that means the car setup m...
Definition: rttrack.cpp:1080
tCarPitSetupValue steerLock
Definition: car.h:385
static void rmUpdateMM(void *vp)
tCarPitSetupValue suspbumpthreshold[4]
Definition: car.h:404
tCarPitSetupValue arbspring[2]
Definition: car.h:408
tCarPitSetupValue difflockinginputtq[3]
Definition: car.h:427
static const char * unitNm
char * internalname
Internal name of the track.
Definition: track.h:508
void * GfuiScreenCreateEx(float *bgColor, void *userDataOnActivate, tfuiCallback onActivate, void *userDataOnDeactivate, tfuiCallback onDeactivate, int mouseAllowed)
Create a screen.
Definition: gui.cpp:578
static const char * d3
#define GFUI_ENABLE
Definition: tgfclient.h:162
tCarPitSetupValue thirdspring[2]
Definition: car.h:411
static void onSaveAndExit(void *vp)
void GfuiEditboxSetString(void *scr, int id, const char *text)
Set a new string.
Definition: guiedit.cpp:383
static const char * d5
static const char * unitcms
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
static void rmUpdateM(void *vp)
static int rmRaceType
static void onActivate(void *vp)
static const char * f43
tdble value
Definition: car.h:375
tCarPitSetupValue susppackers[4]
Definition: car.h:399
tCarPitSetupValue wheelrideheight[4]
Definition: car.h:390
static const char * unitdeg
static tCarPitSetup * rmSetup
tCarPitSetup setup
Definition: car.h:441
tTrack * track
Current track.
Definition: raceman.h:222
void GfuiMenuDefaultKeysAdd(void *scr)
Add the default menu keyboard callback to a screen.
Definition: guimenu.cpp:55
tCarPitSetupValue thirdrebound[2]
Definition: car.h:413
tCarPitSetupValue thirdbump[2]
Definition: car.h:412
static int rmIdx
const char * unit
tCarPitSetupValue suspfastbump[4]
Definition: car.h:402
TDiffType diffType[3]
Definition: car.h:430
void(* tfuiCallback)(void *)
Definition: tgfclient.h:105
This is the car structure.
tCarPitSetupValue wheelcamber[4]
Definition: car.h:388
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
Definition: gui.cpp:467
int GfuiEnable(void *scr, int id, int flag)
Enable / Disable an object.
Definition: guiobject.cpp:434
int GfuiLeanButtonCreate(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)
Definition: guibutton.cpp:332
tCarPitSetupValue wingangle[2]
Definition: car.h:420
#define GFUI_DISABLE
Definition: tgfclient.h:161
tCarPitSetupValue diffmintqbias[3]
Definition: car.h:424
#define GFUI_ALIGN_HC_VB
Definition: tgfclient.h:72
tCarPitSetupValue suspreboundthreshold[4]
Definition: car.h:405
static void rmSet(void *vp)
#define GFUI_ALIGN_HL_VB
Definition: tgfclient.h:69
int type
Race type.
Definition: raceman.h:70
Scalar min(Scalar x, Scalar y)
Definition: Basic.h:49
void update(tdble delta)
tRaceAdmInfo raceInfo
Definition: raceman.h:86
static Vector y[4]
Definition: Convex.cpp:56
static const char * unitkpa
bool RtInitCarPitSetupFromDefault(tCarPitSetup *s, const char *carname)
Initialize the given tCarPitSetup with the original TORCS setup, that means the car setup merged with...
Definition: rttrack.cpp:1125
static void onLoad(void *vp)
static const char * setuplabel[6]
bool RtLoadCarPitSetup(void *hdlecar, tCarPitSetup *s, rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname, bool minmaxonly)
Load a custom car setup for a given robot, car, track and session (race, practice, qualifying, ...) type.
Definition: rttrack.cpp:1051
const char * format
static const char * f52
static const char * unitlbfins
tCarPitSetupValue suspfastrebound[4]
Definition: car.h:403
static void enableLoadButtons()
static const char * unitmm
#define GFUI_FONT_MEDIUM
Definition: tgfclient.h:169
tdble min
Definition: car.h:376
tCarPitSetupValue suspspring[4]
Definition: car.h:398
static char * rmCarName
tCarPitSetupValue wheelcaster[4]
Definition: car.h:391
tCarPitSetupValue diffslipbias[3]
Definition: car.h:426
static rtCarPitSetupType setuptype[6]
tCarPitSetupValue wheeltoe[4]
Definition: car.h:389
tCarPitSetupValue difflockinginputbraketq[3]
Definition: car.h:428
tCarPitSetupValue * v
static const char * unitlbfin