From 0802bcd30ff47d2ce474d657923e0242ac0f7dc6 Mon Sep 17 00:00:00 2001
From: Simon Wood <simon@mungewell.org>
Date: Fri, 8 Oct 2010 00:34:26 -0600
Subject: [PATCH 3/3] 166_aspect_ratio
Refactored grboard to allow for dynamic changes in the size of the
screen (assumes fixed height of 600, but width can be anything).
Boards will automagically anchor to the left/right of screen, or
optionally slightly closer in if the 'board width' paramater is
set in the graph.xml for each view. The value is a % of screen
width.
ie:
--
<attnum name="board width" val="100"/>
--
This allows for placing the boards in the center screen for a very
wide screen or a triple monitor setup.
If the individual split screen has less than 1.3 ratio (can be down
to 1), then the graphics will be deliberately squashed a bit.
Note: At present the following does not work:
- Map, always anchored to the right screen. grtrackmap.cpp needs
some loving.
- Speedo, not placed properly as there does not seem to be a
method to reposition it dynamically.
---
src/interfaces/graphic.h | 1 +
src/modules/graphic/ssggraph/grboard.cpp | 288 +++++++++++++++++------------
src/modules/graphic/ssggraph/grboard.h | 5 +
src/modules/graphic/ssggraph/grscreen.cpp | 16 +-
4 files changed, 180 insertions(+), 130 deletions(-)
diff --git a/src/interfaces/graphic.h b/src/interfaces/graphic.h
index b616ce0..0efebd0 100755
|
a
|
b
|
|
| 55 | 55 | #define GR_ATT_DEBUG "debug info" |
| 56 | 56 | #define GR_ATT_GGRAPH "G graph" |
| 57 | 57 | #define GR_ATT_ARCADE "arcade" |
| | 58 | #define GR_ATT_BOARDWIDTH "board width" |
| 58 | 59 | #define GR_ATT_NBLEADER "Max leaders entries" |
| 59 | 60 | |
| 60 | 61 | #define GR_SCT_TVDIR "TV Director View" |
diff --git a/src/modules/graphic/ssggraph/grboard.cpp b/src/modules/graphic/ssggraph/grboard.cpp
index 7f99a66..96c133e 100644
|
a
|
b
|
|
| 47 | 47 | #define NB_LBOARDS 5 //# of leaderboard states |
| 48 | 48 | #define NB_DEBUG 3 |
| 49 | 49 | |
| 50 | | static const int Winx = 0; |
| 51 | | static const int Winw = 800; |
| 52 | | static const int Winy = 0; |
| 53 | | static const int Winh = 600; |
| | 50 | // Boards work on a OrthoCam with fixed height of 600, width flows |
| | 51 | // with split screen(s) and can be limited to 'board width' % of screen |
| | 52 | #define TOP_ANCHOR 600 |
| | 53 | #define BOTTOM_ANCHOR 0 |
| | 54 | #define DEFAULT_WIDTH 800 |
| 54 | 55 | |
| 55 | 56 | static char path[1024]; |
| 56 | 57 | |
| … |
… |
|
| 77 | 78 | void |
| 78 | 79 | cGrBoard::loadDefaults(tCarElt *curCar) |
| 79 | 80 | { |
| 80 | | sprintf (path, "%s/%d", GR_SCT_DISPMODE, id); |
| | 81 | snprintf (path, sizeof(path), "%s/%d", GR_SCT_DISPMODE, id); |
| 81 | 82 | |
| 82 | 83 | debugFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_DEBUG, NULL, 1); |
| 83 | 84 | boardFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_BOARD, NULL, 2); |
| … |
… |
|
| 86 | 87 | counterFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_COUNTER, NULL, 1); |
| 87 | 88 | GFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_GGRAPH, NULL, 1); |
| 88 | 89 | arcadeFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_ARCADE, NULL, 0); |
| | 90 | boardWidth = (int)GfParmGetNum(grHandle, path, GR_ATT_BOARDWIDTH, NULL, 100); |
| 89 | 91 | |
| 90 | 92 | trackMap->setViewMode((int) GfParmGetNum(grHandle, path, GR_ATT_MAP, NULL, trackMap->getDefaultViewMode())); |
| 91 | 93 | |
| 92 | 94 | if (curCar->_driverType == RM_DRV_HUMAN) { |
| 93 | | sprintf(path, "%s/%s", GR_SCT_DISPMODE, curCar->_name); |
| | 95 | snprintf(path, sizeof(path), "%s/%s", GR_SCT_DISPMODE, curCar->_name); |
| 94 | 96 | debugFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_DEBUG, NULL, debugFlag); |
| 95 | 97 | boardFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_BOARD, NULL, boardFlag); |
| 96 | 98 | leaderFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_LEADER, NULL, leaderFlag); |
| … |
… |
|
| 98 | 100 | counterFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_COUNTER, NULL, counterFlag); |
| 99 | 101 | GFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_GGRAPH, NULL, GFlag); |
| 100 | 102 | arcadeFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_ARCADE, NULL, arcadeFlag); |
| | 103 | boardWidth = (int)GfParmGetNum(grHandle, path, GR_ATT_BOARDWIDTH, NULL, boardWidth); |
| 101 | 104 | trackMap->setViewMode((int) GfParmGetNum(grHandle, path, GR_ATT_MAP, NULL, trackMap->getViewMode())); |
| 102 | 105 | } |
| | 106 | |
| | 107 | if (boardWidth < 0 || boardWidth > 100) boardWidth = 100; |
| | 108 | this->setWidth(DEFAULT_WIDTH); |
| 103 | 109 | } |
| 104 | 110 | |
| | 111 | void |
| | 112 | cGrBoard::setWidth(int val) |
| | 113 | { |
| | 114 | // Setup the margins according to percentage of screen width |
| | 115 | centerAnchor = (val / 2); |
| | 116 | leftAnchor = (val / 2) - val * boardWidth / 200; |
| | 117 | rightAnchor = (val / 2) + val * boardWidth / 200; |
| | 118 | } |
| 105 | 119 | |
| 106 | 120 | void |
| 107 | 121 | cGrBoard::selectBoard(int val) |
| 108 | 122 | { |
| 109 | | sprintf (path, "%s/%d", GR_SCT_DISPMODE, id); |
| | 123 | snprintf (path, sizeof(path), "%s/%d", GR_SCT_DISPMODE, id); |
| 110 | 124 | |
| 111 | 125 | switch (val) { |
| 112 | 126 | case 0: |
| … |
… |
|
| 155 | 169 | cGrBoard::grDispDebug(float instFps, float avgFps, tCarElt *car) |
| 156 | 170 | { |
| 157 | 171 | char buf[256]; |
| 158 | | int x = Winx + Winw - 100; |
| 159 | | int y = Winy + Winh - 15; |
| | 172 | int x, y, dy; |
| | 173 | |
| | 174 | x = rightAnchor - 100; |
| | 175 | y = TOP_ANCHOR - 15; |
| 160 | 176 | |
| | 177 | dy = GfuiFontHeight(GFUI_FONT_SMALL_C); |
| | 178 | |
| 161 | 179 | //Display frame rates (instant and average) |
| 162 | | sprintf(buf, "FPS: %.1f(%.1f)", instFps, avgFps); |
| | 180 | snprintf(buf, sizeof(buf), "FPS: %.1f(%.1f)", instFps, avgFps); |
| 163 | 181 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 164 | 182 | |
| 165 | 183 | if(debugFlag == 2) { //Only display detailed information in Debug Mode 2 |
| 166 | 184 | //Display segment name |
| 167 | | y -= 10; |
| 168 | | sprintf(buf, "Seg: %s", car->_trkPos.seg->name); |
| | 185 | y -= dy; |
| | 186 | snprintf(buf, sizeof(buf), "Seg: %s", car->_trkPos.seg->name); |
| 169 | 187 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 170 | 188 | |
| 171 | 189 | //Display distance from start |
| 172 | | y -= 10; |
| 173 | | sprintf(buf, "DfS: %5.0f", car->_distFromStartLine); |
| | 190 | y -= dy; |
| | 191 | snprintf(buf, sizeof(buf), "DfS: %5.0f", car->_distFromStartLine); |
| 174 | 192 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 175 | 193 | |
| 176 | 194 | //Display current camera |
| 177 | | y -= 10; |
| | 195 | y -= dy; |
| 178 | 196 | tRoadCam *curCam = car->_trkPos.seg->cam; |
| 179 | 197 | if (curCam) { |
| 180 | | sprintf(buf, "Cam: %s", curCam->name); |
| | 198 | snprintf(buf, sizeof(buf), "Cam: %s", curCam->name); |
| 181 | 199 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 182 | | }//if curCam |
| 183 | | }//if debugFlag |
| 184 | | }//grDispDebug |
| | 200 | } |
| | 201 | } |
| | 202 | } |
| 185 | 203 | |
| 186 | 204 | |
| 187 | 205 | void |
| 188 | 206 | cGrBoard::grDispGGraph(tCarElt *car) |
| 189 | 207 | { |
| 190 | | // Draw the static blue thin cross and vertical segment. |
| 191 | | static const tdble X1 = (tdble)(Winx + Winw - 100); |
| 192 | | static const tdble Y1 = (tdble)(Winy + 100); |
| 193 | | static const tdble XC = (tdble)(Winx + Winw - 30); |
| 194 | | static const tdble YC = (tdble)(Y1 - 50); |
| | 208 | // Position the graph |
| | 209 | tdble X1 = (tdble)(rightAnchor - 100); |
| | 210 | tdble Y1 = (tdble)(BOTTOM_ANCHOR + 70); |
| | 211 | tdble XC = (tdble)(rightAnchor - 30); |
| | 212 | tdble YC = (tdble)(Y1 - 50); |
| 195 | 213 | |
| | 214 | // Draw the static blue thin cross and vertical segment. |
| 196 | 215 | glBegin(GL_LINES); |
| 197 | 216 | glColor4f(1.0, 1.0, 1.0, 1.0); |
| 198 | 217 | glVertex2f(X1-50, Y1); |
| … |
… |
|
| 205 | 224 | |
| 206 | 225 | // Draw the throttle gauge (vertical thick segment, starting in X1,Y1, |
| 207 | 226 | // going upwards, length proportional to the throttle command). |
| 208 | | static const tdble THNSS = 2.0f; |
| | 227 | tdble THNSS = 2.0f; |
| 209 | 228 | |
| 210 | 229 | glBegin(GL_QUADS); |
| 211 | 230 | glColor4f(0.0, 0.0, 1.0, 1.0); |
| … |
… |
|
| 307 | 326 | // Draw the current screen indicator (only in split screen mode) |
| 308 | 327 | // (a green-filled square on the bottom right corner of the screen). |
| 309 | 328 | static const float h = 10.0f; |
| 310 | | const float w = h; // * Winh / Winw; |
| 311 | | const float x = Winx + Winw - w - 5; // * Winh / Winw; |
| 312 | | const float y = Winy + 5; |
| | 329 | const float w = h; |
| | 330 | |
| | 331 | const float x = rightAnchor - w - 5; |
| | 332 | const float y = BOTTOM_ANCHOR + 5; |
| 313 | 333 | |
| 314 | 334 | glBegin(GL_QUADS); |
| 315 | 335 | glColor4f(0.0, 1.0, 0.0, 1.0); |
| … |
… |
|
| 330 | 350 | float *clr; |
| 331 | 351 | int dy, dy2, dx; |
| 332 | 352 | |
| 333 | | x = 10; |
| 334 | | x2 = 110; |
| | 353 | snprintf(buf, sizeof(buf), "%d/%d - %s", car->_pos, s->_ncars, car->_name); |
| | 354 | |
| 335 | 355 | dy = GfuiFontHeight(GFUI_FONT_MEDIUM_C); |
| 336 | 356 | dy2 = GfuiFontHeight(GFUI_FONT_SMALL_C); |
| 337 | | y = Winy + Winh - dy - 5; |
| 338 | | sprintf(buf, "%d/%d - %s", car->_pos, s->_ncars, car->_name); |
| 339 | 357 | dx = GfuiFontWidth(GFUI_FONT_MEDIUM_C, buf); |
| | 358 | |
| | 359 | x = leftAnchor + 10; |
| | 360 | y = TOP_ANCHOR - dy - 5; |
| | 361 | |
| | 362 | x2 = x + 100; |
| 340 | 363 | dx = MAX(dx, (x2-x)); |
| 341 | | |
| | 364 | |
| 342 | 365 | glEnable(GL_BLEND); |
| 343 | 366 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; |
| 344 | 367 | glBegin(GL_QUADS); |
| … |
… |
|
| 361 | 384 | } else { |
| 362 | 385 | clr = grWhite; |
| 363 | 386 | } |
| 364 | | sprintf(buf, "%.1f l", car->_fuel); |
| | 387 | snprintf(buf, sizeof(buf), "%.1f l", car->_fuel); |
| 365 | 388 | GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 366 | 389 | y -= dy; |
| 367 | 390 | |
| … |
… |
|
| 372 | 395 | } |
| 373 | 396 | |
| 374 | 397 | GfuiPrintString("Damage:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 375 | | sprintf(buf, "%d", car->_dammage); |
| | 398 | snprintf(buf, sizeof(buf), "%d", car->_dammage); |
| 376 | 399 | GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 377 | 400 | y -= dy; |
| 378 | 401 | clr = grWhite; |
| … |
… |
|
| 399 | 422 | y -= dy; |
| 400 | 423 | |
| 401 | 424 | GfuiPrintString("Top Speed:", clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 402 | | sprintf(buf, "%d", (int)(car->_topSpeed * 3.6)); |
| | 425 | snprintf(buf, sizeof(buf), "%d", (int)(car->_topSpeed * 3.6)); |
| 403 | 426 | GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 404 | 427 | y -= dy; |
| 405 | 428 | } |
| … |
… |
|
| 415 | 438 | int dy, dy2, dx; |
| 416 | 439 | int lines, i; |
| 417 | 440 | |
| 418 | | x = 10; |
| 419 | | x2 = 110; |
| 420 | | x3 = 170; |
| | 441 | snprintf(buf, sizeof(buf), "%d/%d - %s", car->_pos, s->_ncars, car->_name); |
| | 442 | |
| 421 | 443 | dy = GfuiFontHeight(GFUI_FONT_MEDIUM_C); |
| 422 | 444 | dy2 = GfuiFontHeight(GFUI_FONT_SMALL_C); |
| | 445 | dx = GfuiFontWidth(GFUI_FONT_MEDIUM_C, buf); |
| 423 | 446 | |
| 424 | | y = Winy + Winh - dy - 5; |
| | 447 | x = leftAnchor + 10; |
| | 448 | x2 = x + 100; |
| | 449 | x3 = x + 160; |
| | 450 | y = TOP_ANCHOR - dy - 5; |
| 425 | 451 | |
| 426 | | sprintf(buf, "%d/%d - %s", car->_pos, s->_ncars, car->_name); |
| 427 | | dx = GfuiFontWidth(GFUI_FONT_MEDIUM_C, buf); |
| 428 | 452 | dx = MAX(dx, (x3-x)); |
| | 453 | |
| 429 | 454 | lines = 6; |
| 430 | 455 | for (i = 0; i < 4; i++) { |
| 431 | 456 | if (car->ctrl.msg[i]) { |
| … |
… |
|
| 437 | 462 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; |
| 438 | 463 | glBegin(GL_QUADS); |
| 439 | 464 | glColor4f(0.1, 0.1, 0.1, 0.8); |
| 440 | | glVertex2f(x-5, y + dy); |
| 441 | | glVertex2f(x+dx+5, y + dy); |
| 442 | | glVertex2f(x+dx+5, y-5 - dy2 * lines); |
| 443 | | glVertex2f(x-5, y-5 - dy2 * lines); |
| | 465 | glVertex2f(x - 5, y + dy); |
| | 466 | glVertex2f(x + dx + 5, y + dy); |
| | 467 | glVertex2f(x + dx + 5, y - 5 - dy2 * lines); |
| | 468 | glVertex2f(x - 5, y - 5 - dy2 * lines); |
| 444 | 469 | glEnd(); |
| 445 | 470 | glDisable(GL_BLEND); |
| 446 | 471 | |
| … |
… |
|
| 455 | 480 | } else { |
| 456 | 481 | clr = grWhite; |
| 457 | 482 | } |
| 458 | | sprintf(buf, "%.1f l", car->_fuel); |
| | 483 | snprintf(buf, sizeof(buf), "%.1f l", car->_fuel); |
| 459 | 484 | GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 460 | 485 | y -= dy; |
| 461 | 486 | |
| … |
… |
|
| 479 | 504 | y -= dy; |
| 480 | 505 | |
| 481 | 506 | if (car->_pos != 1) { |
| 482 | | sprintf(buf, "<- %s", s->cars[car->_pos - 2]->_name); |
| | 507 | snprintf(buf, sizeof(buf), "<- %s", s->cars[car->_pos - 2]->_name); |
| 483 | 508 | GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 484 | 509 | if (s->_raceType == RM_TYPE_RACE) |
| 485 | 510 | { |
| … |
… |
|
| 503 | 528 | y -= dy; |
| 504 | 529 | |
| 505 | 530 | if (car->_pos != s->_ncars) { |
| 506 | | sprintf(buf, "-> %s", s->cars[car->_pos]->_name); |
| | 531 | snprintf(buf, sizeof(buf), "-> %s", s->cars[car->_pos]->_name); |
| 507 | 532 | GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 508 | 533 | if (s->_raceType == RM_TYPE_RACE) |
| 509 | 534 | { |
| … |
… |
|
| 599 | 624 | glColor3f(0.1, 0.1, 0.1); |
| 600 | 625 | glVertex2f(x - ledSpace, y + ledHeight + ledSpace); |
| 601 | 626 | glVertex2f(x + ledNb * (ledWidth+ ledSpace), y + ledHeight + ledSpace); |
| 602 | | glVertex2f(x + ledNb * (ledWidth+ ledSpace), Winy); |
| 603 | | glVertex2f(x - ledSpace, Winy); |
| | 627 | glVertex2f(x + ledNb * (ledWidth+ ledSpace), BOTTOM_ANCHOR); |
| | 628 | glVertex2f(x - ledSpace, BOTTOM_ANCHOR); |
| 604 | 629 | } |
| 605 | 630 | |
| 606 | 631 | xref = x; |
| … |
… |
|
| 647 | 672 | int x, y; |
| 648 | 673 | char buf[256]; |
| 649 | 674 | |
| 650 | | grDispEngineLeds (car, Winx + Winw / 2, Winy + MAX(GfuiFontHeight(GFUI_FONT_BIG_C), GfuiFontHeight(GFUI_FONT_DIGIT)), ALIGN_CENTER, 1); |
| | 675 | grDispEngineLeds (car, centerAnchor, BOTTOM_ANCHOR + MAX(GfuiFontHeight(GFUI_FONT_BIG_C), GfuiFontHeight(GFUI_FONT_DIGIT)), ALIGN_CENTER, 1); |
| 651 | 676 | |
| 652 | | x = Winx + Winw/2; |
| 653 | | y = Winy; |
| | 677 | x = centerAnchor; |
| | 678 | y = BOTTOM_ANCHOR; |
| | 679 | |
| 654 | 680 | if (car->_gear <= 0) |
| 655 | | sprintf(buf, " kph %s", car->_gear == 0 ? "N" : "R"); |
| | 681 | snprintf(buf, sizeof(buf), " kph %s", car->_gear == 0 ? "N" : "R"); |
| 656 | 682 | else |
| 657 | | sprintf(buf, " kph %d", car->_gear); |
| | 683 | snprintf(buf, sizeof(buf), " kph %d", car->_gear); |
| 658 | 684 | GfuiPrintString(buf, grBlue, GFUI_FONT_BIG_C, x, y, GFUI_ALIGN_HL_VB); |
| 659 | 685 | |
| 660 | | x = Winx + Winw/2; |
| 661 | | sprintf(buf, "%3d", abs((int)(car->_speed_x * 3.6))); |
| | 686 | x = centerAnchor; |
| | 687 | snprintf(buf, sizeof(buf), "%3d", abs((int)(car->_speed_x * 3.6))); |
| 662 | 688 | GfuiPrintString(buf, grBlue, GFUI_FONT_BIG_C, x, y, GFUI_ALIGN_HR_VB); |
| 663 | 689 | } |
| 664 | 690 | |
| … |
… |
|
| 699 | 725 | }//for i |
| 700 | 726 | |
| 701 | 727 | //Coords, limits |
| 702 | | int x = Winx + 5; |
| 703 | | int x2 = Winx + 170; |
| 704 | | int y = Winy + 10; |
| | 728 | int x = leftAnchor + 5; |
| | 729 | int x2 = x + 165; |
| | 730 | int y = BOTTOM_ANCHOR + 10; |
| | 731 | |
| 705 | 732 | int dy = GfuiFontHeight(GFUI_FONT_SMALL_C); |
| 706 | 733 | int maxLines = MIN(leaderNb, s->_ncars); //Max # of lines to display (# of cars in race or max 10 by default) |
| 707 | 734 | int drawLaps = MIN(1, leaderFlag - 1); //Display # of laps on top of the list? |
| … |
… |
|
| 711 | 738 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; |
| 712 | 739 | glBegin(GL_QUADS); |
| 713 | 740 | glColor4f(0.1, 0.1, 0.1, 0.8); |
| 714 | | glVertex2f(x, Winy + 5); |
| 715 | | glVertex2f(Winx + 180, Winy + 5); |
| 716 | | glVertex2f(Winx + 180, y + dy * (maxLines + drawLaps)); |
| | 741 | glVertex2f(x, y - 5); |
| | 742 | glVertex2f(x + 175, y - 5); |
| | 743 | glVertex2f(x + 175, y + dy * (maxLines + drawLaps)); |
| 717 | 744 | glVertex2f(x, y + dy * (maxLines + drawLaps)); |
| 718 | 745 | glEnd(); |
| 719 | 746 | glDisable(GL_BLEND); |
| … |
… |
|
| 744 | 771 | }//if i |
| 745 | 772 | |
| 746 | 773 | //Driver position + name |
| 747 | | sprintf(buf, "%3d: %s", i + 1, s->cars[i]->_name); |
| | 774 | snprintf(buf, sizeof(buf), "%3d: %s", i + 1, s->cars[i]->_name); |
| 748 | 775 | GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 749 | 776 | |
| 750 | 777 | //Display driver time / time behind leader / laps behind leader |
| … |
… |
|
| 765 | 792 | if (s->_totTime > s->currentTime) |
| 766 | 793 | { |
| 767 | 794 | GfuiPrintString(" Laps:", grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 768 | | sprintf(buf, "%d", MAX(s->cars[0]->_laps-1,0)); |
| | 795 | snprintf(buf, sizeof(buf), "%d", MAX(s->cars[0]->_laps-1,0)); |
| 769 | 796 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 770 | 797 | } else { |
| 771 | 798 | GfuiPrintString(" Lap:", grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 772 | | sprintf(buf, "%d / %d", s->cars[0]->_laps, s->_totLaps); |
| | 799 | snprintf(buf, sizeof(buf), "%d / %d", s->cars[0]->_laps, s->_totLaps); |
| 773 | 800 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 774 | 801 | } |
| 775 | 802 | } else { |
| … |
… |
|
| 777 | 804 | { |
| 778 | 805 | time_left = MAX(MIN(s->_totTime,s->_totTime - s->currentTime),0); |
| 779 | 806 | GfuiPrintString(" Time left:", grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 780 | | sprintf(buf, "%d:%02d:%02d", (int)floor(time_left / 3600.0f), (int)floor(time_left/60.0f) % 60, (int)floor(time_left) % 60); |
| | 807 | snprintf(buf, sizeof(buf), "%d:%02d:%02d", (int)floor(time_left / 3600.0f), (int)floor(time_left/60.0f) % 60, (int)floor(time_left) % 60); |
| 781 | 808 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 782 | 809 | } else { |
| 783 | 810 | GfuiPrintString(" Lap:", grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 784 | | sprintf(buf, "%d / %d", s->cars[0]->_laps, s->_totLaps); |
| | 811 | snprintf(buf, sizeof(buf), "%d / %d", s->cars[0]->_laps, s->_totLaps); |
| 785 | 812 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 786 | 813 | } |
| 787 | 814 | } |
| … |
… |
|
| 827 | 854 | glPopMatrix(); |
| 828 | 855 | |
| 829 | 856 | if (car->_gear <= 0) |
| 830 | | strcpy(buf, car->_gear == 0 ? "N" : "R"); |
| | 857 | snprintf(buf, sizeof(buf), "%s", car->_gear == 0 ? "N" : "R"); |
| 831 | 858 | else |
| 832 | | sprintf(buf, "%d", car->_gear); |
| | 859 | snprintf(buf, sizeof(buf), "%d", car->_gear); |
| 833 | 860 | GfuiPrintString(buf, grRed, GFUI_FONT_LARGE_C, |
| 834 | 861 | (int)curInst->digitXCenter, (int)curInst->digitYCenter, GFUI_ALIGN_HC_VB); |
| 835 | 862 | |
| … |
… |
|
| 862 | 889 | |
| 863 | 890 | if (curInst->digital) { |
| 864 | 891 | // Do not add "%3d" or something, because the digital font DOES NOT SUPPORT BLANKS!!!! |
| 865 | | sprintf(buf, "%d", abs((int)(car->_speed_x * 3.6))); |
| | 892 | snprintf(buf, sizeof(buf), "%d", abs((int)(car->_speed_x * 3.6))); |
| 866 | 893 | GfuiPrintString(buf, grRed, GFUI_FONT_LARGE_C, |
| 867 | 894 | (int)curInst->digitXCenter, (int)curInst->digitYCenter, GFUI_ALIGN_HC_VB); |
| 868 | 895 | } |
| … |
… |
|
| 875 | 902 | clr = grWhite; |
| 876 | 903 | } |
| 877 | 904 | |
| 878 | | const tdble fw = Winw/800.0f; |
| | 905 | #if 0 |
| | 906 | //const tdble fw = winw/800.0f; |
| | 907 | tdble fw = (rightAnchor - leftAnchor)/800.0f; |
| 879 | 908 | |
| 880 | 909 | grDrawGauge(545.0f*fw, 20.0f*fw, 80.0f, clr, grBlack, car->_fuel / car->_tank, "F"); |
| 881 | 910 | grDrawGauge(560.0f*fw, 20.0f*fw, 80.0f, grRed, grGreen, (tdble)(car->_dammage) / grMaxDammage, "D"); |
| | 911 | #else |
| | 912 | grDrawGauge(centerAnchor + 140, BOTTOM_ANCHOR + 25, 100, clr, grBlack, car->_fuel / car->_tank, "F"); |
| | 913 | grDrawGauge(centerAnchor + 155, BOTTOM_ANCHOR + 25, 100, grRed, grGreen, (tdble)(car->_dammage) / grMaxDammage, "D"); |
| | 914 | #endif |
| 882 | 915 | } |
| 883 | 916 | } |
| 884 | 917 | |
| … |
… |
|
| 917 | 950 | #define XM 15 |
| 918 | 951 | #define YM 10 |
| 919 | 952 | |
| 920 | | x = XM; |
| 921 | 953 | dy = GfuiFontHeight(GFUI_FONT_BIG_C); |
| 922 | | y = Winy + Winh - YM - dy; |
| 923 | | sprintf(buf, "%d/%d", car->_pos, s->_ncars); |
| | 954 | |
| | 955 | x = leftAnchor + XM; |
| | 956 | y = TOP_ANCHOR - YM - dy; |
| | 957 | |
| | 958 | snprintf(buf, sizeof(buf), "%d/%d", car->_pos, s->_ncars); |
| 924 | 959 | GfuiPrintString(buf, grDefaultClr, GFUI_FONT_BIG_C, x, y, GFUI_ALIGN_HL_VB); |
| 925 | 960 | |
| 926 | 961 | dy = GfuiFontHeight(GFUI_FONT_LARGE_C); |
| … |
… |
|
| 932 | 967 | GfuiPrintString("Best:", grDefaultClr, GFUI_FONT_LARGE_C, x, y, GFUI_ALIGN_HL_VB); |
| 933 | 968 | grWriteTime(grDefaultClr, GFUI_FONT_LARGE_C, x + 150, y, car->_bestLapTime, 0); |
| 934 | 969 | |
| 935 | | x = Winx + Winw - XM; |
| 936 | | y = Winy + Winh - YM - dy; |
| | 970 | x = rightAnchor - XM; |
| | 971 | y = TOP_ANCHOR - YM - dy; |
| 937 | 972 | grGetLapsTime (s, car, buf, NULL); |
| 938 | 973 | GfuiPrintString(buf, grDefaultClr, GFUI_FONT_LARGE_C, x, y, GFUI_ALIGN_HR_VB); |
| 939 | 974 | |
| 940 | 975 | |
| 941 | | x = Winx + Winw / 2; |
| 942 | | sprintf(buf, "%s", car->_name); |
| | 976 | x = centerAnchor; |
| | 977 | snprintf(buf, sizeof(buf), "%s", car->_name); |
| 943 | 978 | GfuiPrintString(buf, grDefaultClr, GFUI_FONT_LARGE_C, x, y, GFUI_ALIGN_HC_VB); |
| 944 | 979 | |
| 945 | 980 | |
| … |
… |
|
| 948 | 983 | } else { |
| 949 | 984 | clr = grWhite; |
| 950 | 985 | } |
| 951 | | grDrawGauge(XM, 20.0, 80.0, clr, grBlack, car->_fuel / car->_tank, "F"); |
| 952 | | grDrawGauge(XM + 15, 20.0, 80.0, grRed, grGreen, (tdble)(car->_dammage) / grMaxDammage, "D"); |
| | 986 | grDrawGauge(leftAnchor + XM, BOTTOM_ANCHOR + 25, 100, clr, grBlack, car->_fuel / car->_tank, "F"); |
| | 987 | grDrawGauge(leftAnchor + XM + 15, BOTTOM_ANCHOR + 25, 100, grRed, grGreen, (tdble)(car->_dammage) / grMaxDammage, "D"); |
| 953 | 988 | |
| 954 | | x = Winx + Winw - XM; |
| | 989 | x = rightAnchor - XM; |
| 955 | 990 | dy = GfuiFontHeight(GFUI_FONT_LARGE_C); |
| 956 | 991 | y = YM + dy; |
| 957 | | sprintf(buf, "%3d km/h", abs((int)(car->_speed_x * 3.6))); |
| | 992 | snprintf(buf, sizeof(buf), "%3d km/h", abs((int)(car->_speed_x * 3.6))); |
| 958 | 993 | GfuiPrintString(buf, grDefaultClr, GFUI_FONT_BIG_C, x, y, GFUI_ALIGN_HR_VB); |
| 959 | 994 | y = YM; |
| 960 | 995 | if (car->_gear <= 0) |
| 961 | | sprintf(buf, "%s", car->_gear == 0 ? "N" : "R"); |
| | 996 | snprintf(buf, sizeof(buf), "%s", car->_gear == 0 ? "N" : "R"); |
| 962 | 997 | else |
| 963 | | sprintf(buf, "%d", car->_gear); |
| | 998 | snprintf(buf, sizeof(buf), "%d", car->_gear); |
| 964 | 999 | GfuiPrintString(buf, grDefaultClr, GFUI_FONT_LARGE_C, x, y, GFUI_ALIGN_HR_VB); |
| 965 | 1000 | |
| 966 | | grDispEngineLeds (car, Winx + Winw - XM, YM + dy + GfuiFontHeight (GFUI_FONT_BIG_C), ALIGN_RIGHT, 0); |
| | 1001 | grDispEngineLeds (car, rightAnchor - XM, YM + dy + GfuiFontHeight (GFUI_FONT_BIG_C), ALIGN_RIGHT, 0); |
| 967 | 1002 | } |
| 968 | 1003 | |
| 969 | 1004 | /** |
| … |
… |
|
| 1117 | 1152 | |
| 1118 | 1153 | if (!time) |
| 1119 | 1154 | { |
| 1120 | | sprintf(result, "%s%d/%d", loc_label, car->_laps, s->_totLaps ); |
| | 1155 | snprintf(result, sizeof(result), "%s%d/%d", loc_label, car->_laps, s->_totLaps ); |
| 1121 | 1156 | } |
| 1122 | 1157 | else |
| 1123 | 1158 | { |
| … |
… |
|
| 1127 | 1162 | if (cur_left < 0.0f) |
| 1128 | 1163 | cur_left = 0.0f; |
| 1129 | 1164 | |
| 1130 | | sprintf( result, "%s%d:%02d:%02d", loc_label, (int)floor( cur_left / 3600.0f ), (int)floor( cur_left / 60.0f ) % 60, (int)floor( cur_left ) % 60 ); |
| | 1165 | snprintf(result, sizeof(result), "%s%d:%02d:%02d", loc_label, (int)floor( cur_left / 3600.0f ), (int)floor( cur_left / 60.0f ) % 60, (int)floor( cur_left ) % 60 ); |
| 1131 | 1166 | } |
| 1132 | 1167 | } |
| 1133 | 1168 | |
| … |
… |
|
| 1151 | 1186 | grDispCounterBoard2(currCar); |
| 1152 | 1187 | } |
| 1153 | 1188 | |
| 1154 | | trackMap->display(currCar, s, Winx, Winy, Winw, Winh); |
| | 1189 | //trackMap->display(currCar, s, Winx, Winy, Winw, Winh); |
| | 1190 | trackMap->display(currCar, s, leftAnchor, BOTTOM_ANCHOR, rightAnchor, TOP_ANCHOR); |
| 1155 | 1191 | } |
| 1156 | 1192 | |
| 1157 | 1193 | |
| … |
… |
|
| 1188 | 1224 | param = GfParmGetStr(handle, SECT_GROBJECTS, PRM_TACHO_TEX, "rpm8000.png"); |
| 1189 | 1225 | grFilePath = (char*)malloc(4096); |
| 1190 | 1226 | lg = 0; |
| 1191 | | lg += sprintf(grFilePath + lg, "%sdrivers/%s/%s;", GetLocalDir(), car->_modName, car->_carName); |
| | 1227 | lg += snprintf(grFilePath + lg, 4096 - lg, "%sdrivers/%s/%s;", GetLocalDir(), car->_modName, car->_carName); |
| 1192 | 1228 | if (bTemplate) |
| 1193 | | lg += sprintf(grFilePath + lg, "%sdrivers/%s/%s;", GetLocalDir(), car->_modName, car->_carTemplate); |
| 1194 | | lg += sprintf(grFilePath + lg, "drivers/%s/%d/%s;", car->_modName, car->_driverIndex, car->_carName); |
| | 1229 | lg += snprintf(grFilePath + lg, 4096 - lg, "%sdrivers/%s/%s;", GetLocalDir(), car->_modName, car->_carTemplate); |
| | 1230 | lg += snprintf(grFilePath + lg, 4096 - lg, "drivers/%s/%d/%s;", car->_modName, car->_driverIndex, car->_carName); |
| 1195 | 1231 | if (bTemplate) |
| 1196 | | lg += sprintf(grFilePath + lg, "drivers/%s/%d/%s;", car->_modName, car->_driverIndex, car->_carTemplate); |
| 1197 | | lg += sprintf(grFilePath + lg, "drivers/%s/%d;", car->_modName, car->_driverIndex); |
| 1198 | | lg += sprintf(grFilePath + lg, "drivers/%s/%s;", car->_modName, car->_carName); |
| | 1232 | lg += snprintf(grFilePath + lg, 4096 - lg, "drivers/%s/%d/%s;", car->_modName, car->_driverIndex, car->_carTemplate); |
| | 1233 | lg += snprintf(grFilePath + lg, 4096 - lg, "drivers/%s/%d;", car->_modName, car->_driverIndex); |
| | 1234 | lg += snprintf(grFilePath + lg, 4096 - lg, "drivers/%s/%s;", car->_modName, car->_carName); |
| 1199 | 1235 | if (bTemplate) |
| 1200 | | lg += sprintf(grFilePath + lg, "drivers/%s/%s;", car->_modName, car->_carTemplate); |
| 1201 | | lg += sprintf(grFilePath + lg, "drivers/%s;", car->_modName); |
| 1202 | | lg += sprintf(grFilePath + lg, "cars/%s;", car->_carName); |
| | 1236 | lg += snprintf(grFilePath + lg, 4096 - lg, "drivers/%s/%s;", car->_modName, car->_carTemplate); |
| | 1237 | lg += snprintf(grFilePath + lg, 4096 - lg, "drivers/%s;", car->_modName); |
| | 1238 | lg += snprintf(grFilePath + lg, 4096 - lg, "cars/%s;", car->_carName); |
| 1203 | 1239 | if (bTemplate) |
| 1204 | | lg += sprintf(grFilePath + lg, "cars/%s;", car->_carTemplate); |
| 1205 | | lg += sprintf(grFilePath + lg, "data/textures"); |
| | 1240 | lg += snprintf(grFilePath + lg, 4096 - lg, "cars/%s;", car->_carTemplate); |
| | 1241 | lg += snprintf(grFilePath + lg, 4096 - lg, "data/textures"); |
| 1206 | 1242 | |
| 1207 | 1243 | /* Load the Tachometer texture */ |
| 1208 | 1244 | curInst->texture = (ssgSimpleState*)grSsgLoadTexState(param); |
| … |
… |
|
| 1215 | 1251 | /* Load the instrument placement */ |
| 1216 | 1252 | xSz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_XSZ, (char*)NULL, 128); |
| 1217 | 1253 | ySz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_YSZ, (char*)NULL, 128); |
| 1218 | | xpos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_XPOS, (char*)NULL, Winw / 2.0 - xSz); |
| | 1254 | |
| | 1255 | // don't know the screen diamensions yet!! |
| | 1256 | //xpos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_XPOS, (char*)NULL, centerAnchor- xSz); |
| | 1257 | xpos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_XPOS, (char*)NULL, (DEFAULT_WIDTH / 2) - xSz); |
| 1219 | 1258 | ypos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_YPOS, (char*)NULL, 0); |
| 1220 | 1259 | needlexSz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_NDLXSZ, (char*)NULL, 50); |
| 1221 | 1260 | needleySz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_NDLYSZ, (char*)NULL, 2); |
| … |
… |
|
| 1262 | 1301 | |
| 1263 | 1302 | /* Load the Speedometer texture */ |
| 1264 | 1303 | param = GfParmGetStr(handle, SECT_GROBJECTS, PRM_SPEEDO_TEX, "speed360.rgb"); |
| 1265 | | sprintf(buf, "drivers/%s/%d;drivers/%s;cars/%s;data/textures", car->_modName, car->_driverIndex, car->_modName, car->_carName); |
| | 1304 | snprintf(buf, sizeof(buf), "drivers/%s/%d;drivers/%s;cars/%s;data/textures", car->_modName, car->_driverIndex, car->_modName, car->_carName); |
| 1266 | 1305 | grFilePath = strdup(buf); |
| 1267 | 1306 | curInst->texture = (ssgSimpleState*)grSsgLoadTexState(param); |
| 1268 | 1307 | free(grFilePath); |
| … |
… |
|
| 1272 | 1311 | /* Load the intrument placement */ |
| 1273 | 1312 | xSz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_XSZ, (char*)NULL, 128); |
| 1274 | 1313 | ySz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_YSZ, (char*)NULL, 128); |
| 1275 | | xpos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_XPOS, (char*)NULL, Winw / 2.0); |
| | 1314 | |
| | 1315 | // Don't know the screen diamension yet!! |
| | 1316 | //xpos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_XPOS, (char*)NULL, centerAnchor); |
| | 1317 | xpos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_XPOS, (char*)NULL, DEFAULT_WIDTH/2); |
| 1276 | 1318 | ypos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_YPOS, (char*)NULL, 0); |
| 1277 | 1319 | needlexSz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_NDLXSZ, (char*)NULL, 50); |
| 1278 | 1320 | needleySz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_NDLYSZ, (char*)NULL, 2); |
| … |
… |
|
| 1365 | 1407 | }//for i |
| 1366 | 1408 | |
| 1367 | 1409 | //Coords, limits |
| 1368 | | int x = Winx + 5; |
| 1369 | | int x2 = Winx + 170; |
| 1370 | | int y = Winy + 10; |
| | 1410 | int x = leftAnchor + 5; |
| | 1411 | int x2 = x + 165; |
| | 1412 | int y = BOTTOM_ANCHOR + 10; |
| | 1413 | |
| 1371 | 1414 | int dy = GfuiFontHeight(GFUI_FONT_SMALL_C); |
| 1372 | 1415 | int maxLines = MIN(leaderNb, s->_ncars); //Max # of lines to display (# of cars in race or max 10 by default) |
| 1373 | 1416 | |
| … |
… |
|
| 1376 | 1419 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; |
| 1377 | 1420 | glBegin(GL_QUADS); |
| 1378 | 1421 | glColor4f(0.1, 0.1, 0.1, 0.8); |
| 1379 | | glVertex2f(x, Winy + 5); |
| 1380 | | glVertex2f(Winx + 180, Winy + 5); |
| 1381 | | glVertex2f(Winx + 180, y + dy * (maxLines + 1)); |
| | 1422 | glVertex2f(x, y + 5); |
| | 1423 | glVertex2f(x + 175, y - 5); |
| | 1424 | glVertex2f(x + 175, y + dy * (maxLines + 1)); |
| 1382 | 1425 | glVertex2f(x, y + dy * (maxLines + 1)); |
| 1383 | 1426 | glEnd(); |
| 1384 | 1427 | glDisable(GL_BLEND); |
| … |
… |
|
| 1402 | 1445 | ? grDefaultClr : grCarInfo[s->cars[i]->index].iconColor; |
| 1403 | 1446 | |
| 1404 | 1447 | //Driver position + name |
| 1405 | | sprintf(buf, "%3d: %s", i + 1, s->cars[i]->_name); |
| | 1448 | snprintf(buf, sizeof(buf), "%3d: %s", i + 1, s->cars[i]->_name); |
| 1406 | 1449 | GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 1407 | 1450 | |
| 1408 | 1451 | //Display driver time / time behind leader / laps behind leader |
| … |
… |
|
| 1420 | 1463 | if (s->currentTime < s->_totTime) |
| 1421 | 1464 | { |
| 1422 | 1465 | GfuiPrintString(" Laps:", grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 1423 | | sprintf(buf, "%d", s->cars[0]->_laps); |
| | 1466 | snprintf(buf, sizeof(buf), "%d", s->cars[0]->_laps); |
| 1424 | 1467 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 1425 | 1468 | } |
| 1426 | 1469 | else |
| 1427 | 1470 | { |
| 1428 | 1471 | GfuiPrintString(" Lap:", grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); |
| 1429 | | sprintf(buf, "%d / %d", s->cars[0]->_laps, s->_totLaps); |
| | 1472 | snprintf(buf, sizeof(buf), "%d / %d", s->cars[0]->_laps, s->_totLaps); |
| 1430 | 1473 | GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); |
| 1431 | 1474 | } |
| 1432 | 1475 | }//grDispLeaderBoardScroll |
| … |
… |
|
| 1464 | 1507 | }//if currentTime |
| 1465 | 1508 | |
| 1466 | 1509 | //Coords, limits |
| 1467 | | int x = Winx + 5; |
| 1468 | | int x2 = Winw - 5; |
| 1469 | | int y = Winy; |
| | 1510 | int x = leftAnchor + 5; |
| | 1511 | int x2 = rightAnchor - 5; |
| | 1512 | int y = BOTTOM_ANCHOR; |
| | 1513 | |
| 1470 | 1514 | int dy = GfuiFontHeight(GFUI_FONT_MEDIUM_C); |
| 1471 | 1515 | //int dx = GfuiFontWidth(GFUI_FONT_SMALL_C, "W"); |
| 1472 | 1516 | //int iLen = (x2 - x) / dx; //# of chars to display |
| … |
… |
|
| 1546 | 1590 | //Display driver time / time behind leader / laps behind leader |
| 1547 | 1591 | if(car->_state & RM_CAR_STATE_DNF) { |
| 1548 | 1592 | //driver DNF |
| 1549 | | sprintf(buf, " out"); |
| | 1593 | snprintf(buf, sizeof(buf), " out"); |
| 1550 | 1594 | } |
| 1551 | 1595 | else if(car->_state & RM_CAR_STATE_PIT) { |
| 1552 | 1596 | //driver in pit |
| 1553 | | sprintf(buf, " PIT"); |
| | 1597 | snprintf(buf, sizeof(buf), " PIT"); |
| 1554 | 1598 | } else { |
| 1555 | 1599 | //no DNF nor in pit |
| 1556 | 1600 | if(isLeader) { |
| … |
… |
|
| 1562 | 1606 | if (car->_bestLapTime > 0) |
| 1563 | 1607 | grWriteTimeBuf(buf, car->_bestLapTime, 0); |
| 1564 | 1608 | else |
| 1565 | | sprintf(buf, " --:--"); |
| | 1609 | snprintf(buf, sizeof(buf), " --:--"); |
| 1566 | 1610 | } |
| 1567 | 1611 | } else { |
| 1568 | 1612 | //This is not the leader |
| … |
… |
|
| 1570 | 1614 | case 0: //Driver in same lap as leader |
| 1571 | 1615 | if (car->_timeBehindLeader == 0 && (s->_raceType == RM_TYPE_RACE || car->_bestLapTime <= 0.0f)) { |
| 1572 | 1616 | //Cannot decide time behind, first lap or passed leader |
| 1573 | | sprintf(buf, " --:--"); |
| | 1617 | snprintf(buf, sizeof(buf), " --:--"); |
| 1574 | 1618 | } |
| 1575 | 1619 | else { |
| 1576 | 1620 | //Can decide time behind |
| … |
… |
|
| 1579 | 1623 | break; |
| 1580 | 1624 | |
| 1581 | 1625 | case 1: //1 lap behind leader |
| 1582 | | sprintf(buf, "+%3d Lap", car->_lapsBehindLeader); |
| | 1626 | snprintf(buf, sizeof(buf), "+%3d Lap", car->_lapsBehindLeader); |
| 1583 | 1627 | break; |
| 1584 | 1628 | |
| 1585 | 1629 | default: //N laps behind leader |
| 1586 | | sprintf(buf, "+%3d Laps", car->_lapsBehindLeader); |
| | 1630 | snprintf(buf, sizeof(buf), "+%3d Laps", car->_lapsBehindLeader); |
| 1587 | 1631 | break; |
| 1588 | 1632 | }//switch |
| 1589 | 1633 | }//not leader |
diff --git a/src/modules/graphic/ssggraph/grboard.h b/src/modules/graphic/ssggraph/grboard.h
index bcd97e2..44b554a 100644
|
a
|
b
|
|
| 40 | 40 | int counterFlag; |
| 41 | 41 | int GFlag; |
| 42 | 42 | int arcadeFlag; |
| | 43 | int boardWidth; |
| | 44 | int leftAnchor; |
| | 45 | int centerAnchor; |
| | 46 | int rightAnchor; |
| 43 | 47 | std::vector<std::string> sShortNames; |
| 44 | 48 | |
| 45 | 49 | private: |
| … |
… |
|
| 71 | 75 | void initBoard(void); |
| 72 | 76 | void shutdown(void); |
| 73 | 77 | void selectBoard(int brd); |
| | 78 | void setWidth(int width); |
| 74 | 79 | void initBoardCar(tCarElt *car); |
| 75 | 80 | inline cGrTrackMap *getTrackMap() { return trackMap; } |
| 76 | 81 | |
diff --git a/src/modules/graphic/ssggraph/grscreen.cpp b/src/modules/graphic/ssggraph/grscreen.cpp
index 4ffc368..7fc5518 100644
|
a
|
b
|
|
| 119 | 119 | scrh = h; |
| 120 | 120 | |
| 121 | 121 | if (boardCam) { |
| 122 | | // Boards assume a fixed geometry of 800x600 |
| 123 | | int overscan = (((float) scrw * 600 / (float) scrh) - 800) / 2; |
| | 122 | int fake_width = (float) scrw * 600 / (float) scrh; |
| 124 | 123 | |
| 125 | | if (overscan < 0) overscan = 0; |
| | 124 | if (fake_width < 800) fake_width = 800; |
| 126 | 125 | |
| 127 | 126 | delete boardCam; |
| 128 | | boardCam = new cGrOrthoCamera(this, -overscan, 800 + overscan, 0, 600); |
| | 127 | boardCam = new cGrOrthoCamera(this, 0, fake_width, 0, 600); |
| | 128 | board->setWidth(fake_width); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | if (mirrorCam) { |
| … |
… |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | if (boardCam == NULL) { |
| 446 | | // Boards assume a fixed geometry of 800x600 |
| 447 | | int overscan = (((float) scrw * 600 / (float) scrh) - 800) / 2; |
| | 446 | int fake_width = (float) scrw * 600 / (float) scrh; |
| 448 | 447 | |
| 449 | | if (overscan < 0) overscan = 0; |
| | 448 | if (fake_width < 800) fake_width = 800; |
| 450 | 449 | |
| 451 | | boardCam = new cGrOrthoCamera(this, -overscan, 800 + overscan, 0, 600); |
| | 450 | boardCam = new cGrOrthoCamera(this, 0, fake_width, 0, 600); |
| | 451 | board->setWidth(fake_width); |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | if (bgCam == NULL) { |