1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Ticket #166: 0003-166_aspect_ratio.patch

File 0003-166_aspect_ratio.patch, 32.5 KB (added by mungewell, 3 years ago)
  • src/interfaces/graphic.h

    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  
    5555#define GR_ATT_DEBUG            "debug info" 
    5656#define GR_ATT_GGRAPH           "G graph" 
    5757#define GR_ATT_ARCADE           "arcade" 
     58#define GR_ATT_BOARDWIDTH       "board width" 
    5859#define GR_ATT_NBLEADER         "Max leaders entries" 
    5960 
    6061#define GR_SCT_TVDIR            "TV Director View" 
  • src/modules/graphic/ssggraph/grboard.cpp

    diff --git a/src/modules/graphic/ssggraph/grboard.cpp b/src/modules/graphic/ssggraph/grboard.cpp
    index 7f99a66..96c133e 100644
    a b  
    4747#define NB_LBOARDS  5 //# of leaderboard states 
    4848#define NB_DEBUG  3 
    4949 
    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 
    5455 
    5556static char path[1024]; 
    5657 
     
    7778void 
    7879cGrBoard::loadDefaults(tCarElt *curCar) 
    7980{ 
    80   sprintf (path, "%s/%d", GR_SCT_DISPMODE, id); 
     81  snprintf (path, sizeof(path), "%s/%d", GR_SCT_DISPMODE, id); 
    8182   
    8283  debugFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_DEBUG, NULL, 1); 
    8384  boardFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_BOARD, NULL, 2); 
     
    8687  counterFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_COUNTER, NULL, 1); 
    8788  GFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_GGRAPH, NULL, 1); 
    8889  arcadeFlag  = (int)GfParmGetNum(grHandle, path, GR_ATT_ARCADE, NULL, 0); 
     90  boardWidth  = (int)GfParmGetNum(grHandle, path, GR_ATT_BOARDWIDTH, NULL, 100); 
    8991   
    9092  trackMap->setViewMode((int) GfParmGetNum(grHandle, path, GR_ATT_MAP, NULL, trackMap->getDefaultViewMode())); 
    9193   
    9294  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); 
    9496    debugFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_DEBUG, NULL, debugFlag); 
    9597    boardFlag = (int)GfParmGetNum(grHandle, path, GR_ATT_BOARD, NULL, boardFlag); 
    9698    leaderFlag  = (int)GfParmGetNum(grHandle, path, GR_ATT_LEADER, NULL, leaderFlag); 
     
    98100    counterFlag   = (int)GfParmGetNum(grHandle, path, GR_ATT_COUNTER, NULL, counterFlag); 
    99101    GFlag   = (int)GfParmGetNum(grHandle, path, GR_ATT_GGRAPH, NULL, GFlag); 
    100102    arcadeFlag  = (int)GfParmGetNum(grHandle, path, GR_ATT_ARCADE, NULL, arcadeFlag); 
     103    boardWidth  = (int)GfParmGetNum(grHandle, path, GR_ATT_BOARDWIDTH, NULL, boardWidth); 
    101104    trackMap->setViewMode((int) GfParmGetNum(grHandle, path, GR_ATT_MAP, NULL, trackMap->getViewMode())); 
    102105  } 
     106 
     107  if (boardWidth < 0 || boardWidth > 100) boardWidth = 100; 
     108  this->setWidth(DEFAULT_WIDTH); 
    103109} 
    104110 
     111void 
     112cGrBoard::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} 
    105119 
    106120void 
    107121cGrBoard::selectBoard(int val) 
    108122{ 
    109   sprintf (path, "%s/%d", GR_SCT_DISPMODE, id); 
     123  snprintf (path, sizeof(path), "%s/%d", GR_SCT_DISPMODE, id); 
    110124   
    111125  switch (val) { 
    112126    case 0: 
     
    155169cGrBoard::grDispDebug(float instFps, float avgFps, tCarElt *car) 
    156170{ 
    157171  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; 
    160176   
     177  dy = GfuiFontHeight(GFUI_FONT_SMALL_C); 
     178 
    161179  //Display frame rates (instant and average) 
    162   sprintf(buf, "FPS: %.1f(%.1f)", instFps, avgFps); 
     180  snprintf(buf, sizeof(buf), "FPS: %.1f(%.1f)", instFps, avgFps); 
    163181  GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 
    164182 
    165183  if(debugFlag == 2) {  //Only display detailed information in Debug Mode 2 
    166184    //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); 
    169187    GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 
    170188 
    171189    //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); 
    174192    GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 
    175193 
    176194    //Display current camera 
    177     y -= 10; 
     195    y -= dy; 
    178196    tRoadCam *curCam = car->_trkPos.seg->cam; 
    179197    if (curCam) { 
    180       sprintf(buf, "Cam: %s", curCam->name); 
     198      snprintf(buf, sizeof(buf), "Cam: %s", curCam->name); 
    181199      GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 
    182     }//if curCam 
    183   }//if debugFlag 
    184 }//grDispDebug 
     200    } 
     201  } 
     202} 
    185203 
    186204 
    187205void 
    188206cGrBoard::grDispGGraph(tCarElt *car) 
    189207{ 
    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); 
    195213 
     214  // Draw the static blue thin cross and vertical segment. 
    196215  glBegin(GL_LINES); 
    197216  glColor4f(1.0, 1.0, 1.0, 1.0); 
    198217  glVertex2f(X1-50, Y1); 
     
    205224 
    206225  // Draw the throttle gauge (vertical thick segment, starting in X1,Y1, 
    207226  // going upwards, length proportional to the throttle command). 
    208   static const tdble THNSS = 2.0f; 
     227  tdble THNSS = 2.0f; 
    209228 
    210229  glBegin(GL_QUADS); 
    211230  glColor4f(0.0, 0.0, 1.0, 1.0); 
     
    307326    // Draw the current screen indicator (only in split screen mode) 
    308327    // (a green-filled square on the bottom right corner of the screen). 
    309328    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; 
    313333     
    314334    glBegin(GL_QUADS); 
    315335    glColor4f(0.0, 1.0, 0.0, 1.0); 
     
    330350  float *clr; 
    331351  int dy, dy2, dx; 
    332352   
    333   x = 10; 
    334   x2 = 110; 
     353  snprintf(buf, sizeof(buf), "%d/%d - %s", car->_pos, s->_ncars, car->_name); 
     354   
    335355  dy = GfuiFontHeight(GFUI_FONT_MEDIUM_C); 
    336356  dy2 = GfuiFontHeight(GFUI_FONT_SMALL_C); 
    337   y = Winy + Winh - dy - 5; 
    338   sprintf(buf, "%d/%d - %s", car->_pos, s->_ncars, car->_name); 
    339357  dx = GfuiFontWidth(GFUI_FONT_MEDIUM_C, buf); 
     358 
     359  x = leftAnchor + 10; 
     360  y = TOP_ANCHOR - dy - 5; 
     361 
     362  x2 = x + 100; 
    340363  dx = MAX(dx, (x2-x)); 
    341    
     364 
    342365  glEnable(GL_BLEND); 
    343366  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; 
    344367  glBegin(GL_QUADS); 
     
    361384  } else { 
    362385    clr = grWhite; 
    363386  } 
    364   sprintf(buf, "%.1f l", car->_fuel); 
     387  snprintf(buf, sizeof(buf), "%.1f l", car->_fuel); 
    365388  GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    366389  y -= dy; 
    367390   
     
    372395  } 
    373396   
    374397  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); 
    376399  GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    377400  y -= dy; 
    378401  clr = grWhite; 
     
    399422  y -= dy; 
    400423   
    401424  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)); 
    403426  GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    404427  y -= dy; 
    405428} 
     
    415438  int dy, dy2, dx; 
    416439  int lines, i; 
    417440   
    418   x = 10; 
    419   x2 = 110; 
    420   x3 = 170; 
     441  snprintf(buf, sizeof(buf),  "%d/%d - %s", car->_pos, s->_ncars, car->_name); 
     442 
    421443  dy = GfuiFontHeight(GFUI_FONT_MEDIUM_C); 
    422444  dy2 = GfuiFontHeight(GFUI_FONT_SMALL_C); 
     445  dx = GfuiFontWidth(GFUI_FONT_MEDIUM_C, buf); 
    423446   
    424   y = Winy + Winh - dy - 5; 
     447  x = leftAnchor + 10; 
     448  x2 = x + 100; 
     449  x3 = x + 160; 
     450  y = TOP_ANCHOR - dy - 5; 
    425451   
    426   sprintf(buf, "%d/%d - %s", car->_pos, s->_ncars, car->_name); 
    427   dx = GfuiFontWidth(GFUI_FONT_MEDIUM_C, buf); 
    428452  dx = MAX(dx, (x3-x)); 
     453 
    429454  lines = 6; 
    430455  for (i = 0; i < 4; i++) { 
    431456    if (car->ctrl.msg[i]) { 
     
    437462  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; 
    438463  glBegin(GL_QUADS); 
    439464  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); 
    444469  glEnd(); 
    445470  glDisable(GL_BLEND); 
    446471   
     
    455480  } else { 
    456481    clr = grWhite; 
    457482  } 
    458   sprintf(buf, "%.1f l", car->_fuel); 
     483  snprintf(buf, sizeof(buf), "%.1f l", car->_fuel); 
    459484  GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    460485  y -= dy; 
    461486   
     
    479504  y -= dy; 
    480505   
    481506  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); 
    483508    GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 
    484509    if (s->_raceType == RM_TYPE_RACE) 
    485510    { 
     
    503528  y -= dy; 
    504529   
    505530  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); 
    507532    GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 
    508533    if (s->_raceType == RM_TYPE_RACE) 
    509534    { 
     
    599624    glColor3f(0.1, 0.1, 0.1); 
    600625    glVertex2f(x - ledSpace, y + ledHeight + ledSpace); 
    601626    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); 
    604629  } 
    605630 
    606631  xref = x; 
     
    647672  int  x, y; 
    648673  char buf[256]; 
    649674   
    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); 
    651676   
    652   x = Winx + Winw/2; 
    653   y = Winy; 
     677  x = centerAnchor; 
     678  y = BOTTOM_ANCHOR; 
     679 
    654680  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"); 
    656682  else 
    657     sprintf(buf, " kph %d", car->_gear); 
     683    snprintf(buf, sizeof(buf), " kph %d", car->_gear); 
    658684  GfuiPrintString(buf, grBlue, GFUI_FONT_BIG_C, x, y, GFUI_ALIGN_HL_VB); 
    659685   
    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))); 
    662688  GfuiPrintString(buf, grBlue, GFUI_FONT_BIG_C, x, y, GFUI_ALIGN_HR_VB); 
    663689} 
    664690 
     
    699725    }//for i 
    700726     
    701727    //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 
    705732    int dy = GfuiFontHeight(GFUI_FONT_SMALL_C); 
    706733    int maxLines = MIN(leaderNb, s->_ncars);  //Max # of lines to display (# of cars in race or max 10 by default) 
    707734    int drawLaps = MIN(1, leaderFlag - 1);  //Display # of laps on top of the list? 
     
    711738    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; 
    712739    glBegin(GL_QUADS); 
    713740    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)); 
    717744    glVertex2f(x, y + dy * (maxLines + drawLaps)); 
    718745    glEnd(); 
    719746    glDisable(GL_BLEND); 
     
    744771      }//if i 
    745772 
    746773      //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); 
    748775      GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 
    749776 
    750777      //Display driver time / time behind leader / laps behind leader 
     
    765792        if (s->_totTime > s->currentTime) 
    766793  { 
    767794          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)); 
    769796          GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    770797  } else { 
    771798          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); 
    773800          GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    774801  } 
    775802      } else { 
     
    777804  { 
    778805    time_left = MAX(MIN(s->_totTime,s->_totTime - s->currentTime),0); 
    779806          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); 
    781808          GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    782809  } else { 
    783810          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); 
    785812          GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    786813  } 
    787814      } 
     
    827854  glPopMatrix(); 
    828855   
    829856  if (car->_gear <= 0) 
    830     strcpy(buf, car->_gear == 0 ? "N" : "R"); 
     857    snprintf(buf, sizeof(buf), "%s", car->_gear == 0 ? "N" : "R"); 
    831858  else 
    832     sprintf(buf, "%d", car->_gear); 
     859    snprintf(buf, sizeof(buf), "%d", car->_gear); 
    833860  GfuiPrintString(buf, grRed, GFUI_FONT_LARGE_C, 
    834861      (int)curInst->digitXCenter, (int)curInst->digitYCenter, GFUI_ALIGN_HC_VB); 
    835862   
     
    862889   
    863890  if (curInst->digital) { 
    864891    // 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))); 
    866893    GfuiPrintString(buf, grRed, GFUI_FONT_LARGE_C, 
    867894      (int)curInst->digitXCenter, (int)curInst->digitYCenter, GFUI_ALIGN_HC_VB); 
    868895  } 
     
    875902      clr = grWhite; 
    876903    } 
    877904     
    878     const tdble fw = Winw/800.0f; 
     905#if 0 
     906    //const tdble fw = winw/800.0f; 
     907    tdble fw = (rightAnchor - leftAnchor)/800.0f; 
    879908     
    880909    grDrawGauge(545.0f*fw, 20.0f*fw, 80.0f, clr, grBlack, car->_fuel / car->_tank, "F"); 
    881910    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 
    882915  } 
    883916} 
    884917 
     
    917950#define XM  15 
    918951#define YM  10 
    919952 
    920   x = XM; 
    921953  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); 
    924959  GfuiPrintString(buf, grDefaultClr, GFUI_FONT_BIG_C, x, y, GFUI_ALIGN_HL_VB); 
    925960 
    926961  dy = GfuiFontHeight(GFUI_FONT_LARGE_C); 
     
    932967  GfuiPrintString("Best:", grDefaultClr, GFUI_FONT_LARGE_C, x, y, GFUI_ALIGN_HL_VB); 
    933968  grWriteTime(grDefaultClr, GFUI_FONT_LARGE_C, x + 150, y, car->_bestLapTime, 0); 
    934969 
    935   x = Winx + Winw - XM; 
    936   y = Winy + Winh - YM - dy; 
     970  x = rightAnchor - XM; 
     971  y = TOP_ANCHOR - YM - dy; 
    937972  grGetLapsTime (s, car, buf, NULL); 
    938973  GfuiPrintString(buf, grDefaultClr, GFUI_FONT_LARGE_C, x, y, GFUI_ALIGN_HR_VB); 
    939974   
    940975 
    941   x = Winx + Winw / 2; 
    942   sprintf(buf, "%s", car->_name); 
     976  x = centerAnchor; 
     977  snprintf(buf, sizeof(buf), "%s", car->_name); 
    943978  GfuiPrintString(buf, grDefaultClr, GFUI_FONT_LARGE_C, x, y, GFUI_ALIGN_HC_VB); 
    944979 
    945980 
     
    948983  } else { 
    949984    clr = grWhite; 
    950985  } 
    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"); 
    953988 
    954   x = Winx + Winw - XM; 
     989  x = rightAnchor - XM; 
    955990  dy = GfuiFontHeight(GFUI_FONT_LARGE_C); 
    956991  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))); 
    958993  GfuiPrintString(buf, grDefaultClr, GFUI_FONT_BIG_C, x, y, GFUI_ALIGN_HR_VB); 
    959994  y = YM; 
    960995  if (car->_gear <= 0) 
    961     sprintf(buf, "%s", car->_gear == 0 ? "N" : "R"); 
     996    snprintf(buf, sizeof(buf), "%s", car->_gear == 0 ? "N" : "R"); 
    962997  else 
    963     sprintf(buf, "%d", car->_gear); 
     998    snprintf(buf, sizeof(buf), "%d", car->_gear); 
    964999  GfuiPrintString(buf, grDefaultClr, GFUI_FONT_LARGE_C, x, y, GFUI_ALIGN_HR_VB); 
    9651000 
    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); 
    9671002} 
    9681003 
    9691004/** 
     
    11171152 
    11181153  if (!time) 
    11191154  { 
    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 ); 
    11211156  } 
    11221157  else  
    11231158  { 
     
    11271162    if (cur_left < 0.0f) 
    11281163      cur_left = 0.0f; 
    11291164 
    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 ); 
    11311166  } 
    11321167} 
    11331168 
     
    11511186      grDispCounterBoard2(currCar); 
    11521187  } 
    11531188   
    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); 
    11551191} 
    11561192 
    11571193 
     
    11881224  param = GfParmGetStr(handle, SECT_GROBJECTS, PRM_TACHO_TEX, "rpm8000.png"); 
    11891225  grFilePath = (char*)malloc(4096); 
    11901226  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); 
    11921228  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); 
    11951231  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); 
    11991235  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); 
    12031239  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"); 
    12061242 
    12071243  /* Load the Tachometer texture */ 
    12081244  curInst->texture = (ssgSimpleState*)grSsgLoadTexState(param); 
     
    12151251  /* Load the instrument placement */ 
    12161252  xSz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_XSZ, (char*)NULL, 128); 
    12171253  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); 
    12191258  ypos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_YPOS, (char*)NULL, 0); 
    12201259  needlexSz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_NDLXSZ, (char*)NULL, 50); 
    12211260  needleySz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_TACHO_NDLYSZ, (char*)NULL, 2); 
     
    12621301   
    12631302  /* Load the Speedometer texture */ 
    12641303  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); 
    12661305  grFilePath = strdup(buf); 
    12671306  curInst->texture = (ssgSimpleState*)grSsgLoadTexState(param); 
    12681307  free(grFilePath); 
     
    12721311  /* Load the intrument placement */ 
    12731312  xSz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_XSZ, (char*)NULL, 128); 
    12741313  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); 
    12761318  ypos = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_YPOS, (char*)NULL, 0); 
    12771319  needlexSz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_NDLXSZ, (char*)NULL, 50); 
    12781320  needleySz = GfParmGetNum(handle, SECT_GROBJECTS, PRM_SPEEDO_NDLYSZ, (char*)NULL, 2); 
     
    13651407  }//for i 
    13661408 
    13671409  //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 
    13711414  int dy = GfuiFontHeight(GFUI_FONT_SMALL_C); 
    13721415  int maxLines = MIN(leaderNb, s->_ncars);  //Max # of lines to display (# of cars in race or max 10 by default) 
    13731416   
     
    13761419  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; 
    13771420  glBegin(GL_QUADS); 
    13781421  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)); 
    13821425  glVertex2f(x, y + dy * (maxLines + 1)); 
    13831426  glEnd(); 
    13841427  glDisable(GL_BLEND); 
     
    14021445        ? grDefaultClr : grCarInfo[s->cars[i]->index].iconColor; 
    14031446 
    14041447      //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); 
    14061449      GfuiPrintString(buf, clr, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB); 
    14071450       
    14081451      //Display driver time / time behind leader / laps behind leader 
     
    14201463  if (s->currentTime < s->_totTime) 
    14211464  { 
    14221465    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); 
    14241467    GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    14251468  } 
    14261469  else 
    14271470  { 
    14281471    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); 
    14301473    GfuiPrintString(buf, grWhite, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HR_VB); 
    14311474  } 
    14321475}//grDispLeaderBoardScroll 
     
    14641507  }//if currentTime 
    14651508     
    14661509  //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 
    14701514  int dy = GfuiFontHeight(GFUI_FONT_MEDIUM_C); 
    14711515  //int dx = GfuiFontWidth(GFUI_FONT_SMALL_C, "W"); 
    14721516  //int iLen = (x2 - x) / dx; //# of chars to display 
     
    15461590  //Display driver time / time behind leader / laps behind leader 
    15471591  if(car->_state & RM_CAR_STATE_DNF)  { 
    15481592    //driver DNF 
    1549     sprintf(buf, "       out"); 
     1593    snprintf(buf, sizeof(buf), "       out"); 
    15501594  } 
    15511595  else if(car->_state & RM_CAR_STATE_PIT) { 
    15521596    //driver in pit 
    1553     sprintf(buf, "       PIT"); 
     1597    snprintf(buf, sizeof(buf), "       PIT"); 
    15541598  } else { 
    15551599    //no DNF nor in pit 
    15561600    if(isLeader) { 
     
    15621606        if (car->_bestLapTime > 0) 
    15631607          grWriteTimeBuf(buf, car->_bestLapTime, 0); 
    15641608        else 
    1565           sprintf(buf, "       --:--"); 
     1609          snprintf(buf, sizeof(buf), "       --:--"); 
    15661610      } 
    15671611    } else { 
    15681612      //This is not the leader 
     
    15701614        case 0: //Driver in same lap as leader 
    15711615          if (car->_timeBehindLeader == 0 && (s->_raceType == RM_TYPE_RACE || car->_bestLapTime <= 0.0f)) { 
    15721616            //Cannot decide time behind, first lap or passed leader 
    1573             sprintf(buf, "       --:--"); 
     1617            snprintf(buf, sizeof(buf), "       --:--"); 
    15741618          } 
    15751619          else { 
    15761620            //Can decide time behind 
     
    15791623          break; 
    15801624           
    15811625        case 1: //1 lap behind leader 
    1582           sprintf(buf, "+%3d Lap", car->_lapsBehindLeader); 
     1626          snprintf(buf, sizeof(buf), "+%3d Lap", car->_lapsBehindLeader); 
    15831627          break; 
    15841628           
    15851629        default:  //N laps behind leader 
    1586           sprintf(buf, "+%3d Laps", car->_lapsBehindLeader); 
     1630          snprintf(buf, sizeof(buf), "+%3d Laps", car->_lapsBehindLeader); 
    15871631          break; 
    15881632      }//switch  
    15891633    }//not leader 
  • src/modules/graphic/ssggraph/grboard.h

    diff --git a/src/modules/graphic/ssggraph/grboard.h b/src/modules/graphic/ssggraph/grboard.h
    index bcd97e2..44b554a 100644
    a b  
    4040    int counterFlag; 
    4141    int GFlag; 
    4242    int arcadeFlag; 
     43    int boardWidth; 
     44    int leftAnchor; 
     45    int centerAnchor; 
     46    int rightAnchor; 
    4347    std::vector<std::string> sShortNames; 
    4448                 
    4549 private: 
     
    7175    void initBoard(void); 
    7276    void shutdown(void); 
    7377    void selectBoard(int brd); 
     78    void setWidth(int width); 
    7479    void initBoardCar(tCarElt *car); 
    7580    inline cGrTrackMap *getTrackMap() { return trackMap; } 
    7681 
  • src/modules/graphic/ssggraph/grscreen.cpp

    diff --git a/src/modules/graphic/ssggraph/grscreen.cpp b/src/modules/graphic/ssggraph/grscreen.cpp
    index 4ffc368..7fc5518 100644
    a b  
    119119        scrh = h; 
    120120         
    121121        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; 
    124123 
    125                 if (overscan < 0) overscan = 0; 
     124                if (fake_width < 800) fake_width = 800; 
    126125 
    127126                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); 
    129129        } 
    130130 
    131131        if (mirrorCam) { 
     
    443443        } 
    444444         
    445445        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; 
    448447 
    449                 if (overscan < 0) overscan = 0; 
     448                if (fake_width < 800) fake_width = 800; 
    450449 
    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); 
    452452        } 
    453453         
    454454        if (bgCam == NULL) {