forked from speed-dreams/speed-dreams-code
Fixed #227 : Car name in practice results (thanks Simon) + display car name in title of various relevant results menus + moved track name in main menu title for same ones
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3124 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 61b13198e29be99ceec3234344d262aa8daec562 Former-commit-id: 645fb1d83fead9c96b04b172bee9b5cdfea3c893
This commit is contained in:
parent
6a265c112d
commit
780c3d9eb8
5 changed files with 64 additions and 41 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include <portability.h>
|
||||
#include <tgfclient.h>
|
||||
#include <raceman.h>
|
||||
#include <robot.h>
|
||||
|
@ -47,7 +48,6 @@ static int reBigMsgId;
|
|||
|
||||
static float black[4] = {0.0, 0.0, 0.0, 0.0};
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Normal race screen (3D animated scene mode = non "blind" mode)
|
||||
*/
|
||||
|
@ -302,8 +302,11 @@ static float white[4] = {1.0, 1.0, 1.0, 1.0};
|
|||
static float red[4] = {1.0, 0.0, 0.0, 1.0};
|
||||
static float *reColor[] = {white, red};
|
||||
|
||||
static const char *aRaceTypeNames[3] = {"Practice", "Qualifications", "Race"};
|
||||
|
||||
static void *reResScreenHdle = 0;
|
||||
|
||||
static int reResMainTitleId;
|
||||
static int reResTitleId;
|
||||
static int reResMsgId[NMaxResultLines];
|
||||
|
||||
|
@ -365,7 +368,6 @@ ReResScreenInit(void)
|
|||
int i;
|
||||
int y, dy;
|
||||
const char *img;
|
||||
static const char *title[3] = {"Practice", "Qualifications", "Race"};
|
||||
|
||||
if (reResScreenHdle) {
|
||||
GfuiScreenRelease(reResScreenHdle);
|
||||
|
@ -377,8 +379,8 @@ ReResScreenInit(void)
|
|||
CreateStaticControls(menuXMLDescHdle, reResScreenHdle);
|
||||
|
||||
// Create variable main title (race type/stage) label.
|
||||
int mainTitleId = CreateLabelControl(reResScreenHdle, menuXMLDescHdle, "title");
|
||||
GfuiLabelSetText(reResScreenHdle, mainTitleId, title[ReInfo->s->_raceType]);
|
||||
reResMainTitleId = CreateLabelControl(reResScreenHdle, menuXMLDescHdle, "title");
|
||||
GfuiLabelSetText(reResScreenHdle, reResMainTitleId, aRaceTypeNames[ReInfo->s->_raceType]);
|
||||
|
||||
// Create background image if any specified.
|
||||
img = GfParmGetStr(ReInfo->params, RM_SECT_HEADER, RM_ATTR_RUNIMG, 0);
|
||||
|
@ -418,10 +420,21 @@ ReResScreenInit(void)
|
|||
}
|
||||
|
||||
void
|
||||
ReResScreenSetTitle(const char *title)
|
||||
ReResScreenSetTrackName(const char *pszTrackName)
|
||||
{
|
||||
if (reResScreenHdle) {
|
||||
GfuiLabelSetText(reResScreenHdle, reResTitleId, title);
|
||||
char pszTitle[128];
|
||||
snprintf(pszTitle, sizeof(pszTitle), "%s on %s",
|
||||
aRaceTypeNames[ReInfo->s->_raceType], pszTrackName);
|
||||
GfuiLabelSetText(reResScreenHdle, reResMainTitleId, pszTitle);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ReResScreenSetTitle(const char *pszTitle)
|
||||
{
|
||||
if (reResScreenHdle) {
|
||||
GfuiLabelSetText(reResScreenHdle, reResTitleId, pszTitle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ extern void ReSetRaceMsg(const char *msg);
|
|||
extern void ReSetRaceBigMsg(const char *msg);
|
||||
|
||||
extern void *ReResScreenInit(void);
|
||||
extern void ReResScreenSetTrackName(const char *trackName);
|
||||
extern void ReResScreenSetTitle(const char *title);
|
||||
extern void ReResScreenAddText(const char *text);
|
||||
extern void ReResScreenSetText(const char *text, int line, int clr);
|
||||
|
|
|
@ -417,7 +417,8 @@ reRaceRealStart(void)
|
|||
} else if (ReInfo->s->_raceType == RM_TYPE_PRACTICE && s->_ncars > 1) {
|
||||
ReUpdatePracticeCurRes(s->cars[0]);
|
||||
} else {
|
||||
snprintf(buf, 128, "%s on %s", s->cars[0]->_name, ReInfo->track->name);
|
||||
ReResScreenSetTrackName(ReInfo->track->name);
|
||||
snprintf(buf, sizeof(buf), "%s (%s)", s->cars[0]->_name, s->cars[0]->_carName);
|
||||
ReResScreenSetTitle(buf);
|
||||
}
|
||||
}//if displayMode != normal
|
||||
|
|
|
@ -310,6 +310,7 @@ ReStoreRaceResults(const char *race)
|
|||
car = s->cars[0];
|
||||
sprintf(path, "%s/%s/%s", ReInfo->track->name, RE_SECT_RESULTS, race);
|
||||
GfParmSetStr(results, path, RM_ATTR_DRVNAME, car->_name);
|
||||
GfParmSetStr(results, path, RE_ATTR_CAR, car->_carName);
|
||||
break;
|
||||
}
|
||||
/* Otherwise, fall through */
|
||||
|
@ -455,18 +456,23 @@ ReUpdateQualifCurRes(tCarElt *car)
|
|||
double time_left;
|
||||
|
||||
|
||||
ReResScreenSetTrackName(ReInfo->track->name);
|
||||
|
||||
if (ReInfo->s->_ncars == 1)
|
||||
{
|
||||
ReResEraseScreen();
|
||||
maxLines = ReResGetLines();
|
||||
|
||||
sprintf(buf, "%s on %s - Lap %d", car->_name, ReInfo->track->name, car->_laps);
|
||||
ReResScreenSetTitle(buf);
|
||||
|
||||
sprintf(buf, "cars/%s/%s.xml", car->_carName, car->_carName);
|
||||
snprintf(buf, sizeof(buf), "cars/%s/%s.xml", car->_carName, car->_carName);
|
||||
carparam = GfParmReadFile(buf, GFPARM_RMODE_STD);
|
||||
carName = GfParmGetName(carparam);
|
||||
|
||||
if (ReInfo->s->_raceType == RM_TYPE_PRACTICE)
|
||||
snprintf(buf, sizeof(buf), "%s (%s)", car->_name, carName);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%s (%s) - Lap %d", car->_name, carName, car->_laps);
|
||||
ReResScreenSetTitle(buf);
|
||||
|
||||
printed = 0;
|
||||
sprintf(path, "%s/%s/%s/%s", ReInfo->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK);
|
||||
nCars = GfParmGetEltNb(results, path);
|
||||
|
@ -507,12 +513,12 @@ ReUpdateQualifCurRes(tCarElt *car)
|
|||
if (ReInfo->s->_totTime > ReInfo->s->currentTime)
|
||||
{
|
||||
time_left = ReInfo->s->_totTime - ReInfo->s->currentTime;
|
||||
sprintf( buf, "%s - %d:%02d:%02d", ReInfo->track->name, (int)floor( time_left / 3600.0f ), (int)floor( time_left / 60.0f ) % 60,
|
||||
sprintf( buf, "%d:%02d:%02d", (int)floor( time_left / 3600.0f ), (int)floor( time_left / 60.0f ) % 60,
|
||||
(int)floor( time_left ) % 60 );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( buf, "%s - %d laps", ReInfo->track->name, ReInfo->s->_totLaps );
|
||||
sprintf( buf, "%d laps", ReInfo->s->_totLaps );
|
||||
}
|
||||
ReResScreenSetTitle(buf);
|
||||
|
||||
|
@ -556,17 +562,18 @@ ReUpdateRaceCurRes()
|
|||
char *tmp_str;
|
||||
double time_left;
|
||||
|
||||
ReResScreenSetTrackName(ReInfo->track->name);
|
||||
ncars = ReInfo->s->_ncars;
|
||||
if (ncars > ReResGetLines())
|
||||
ncars = ReResGetLines();
|
||||
if (ReInfo->s->_totTime > ReInfo->s->currentTime)
|
||||
{
|
||||
time_left = ReInfo->s->_totTime - ReInfo->s->currentTime;
|
||||
sprintf( buf, "%s - %d:%02d:%02d", ReInfo->track->name, (int)floor( time_left / 3600.0f ), (int)floor( time_left / 60.0f ) % 60, (int)floor( time_left ) % 60 );
|
||||
sprintf( buf, "%d:%02d:%02d", (int)floor( time_left / 3600.0f ), (int)floor( time_left / 60.0f ) % 60, (int)floor( time_left ) % 60 );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( buf, "%s - %d laps", ReInfo->track->name, ReInfo->s->_totLaps );
|
||||
sprintf( buf, "%d laps", ReInfo->s->_totLaps );
|
||||
}
|
||||
ReResScreenSetTitle(buf);
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <portability.h>
|
||||
#include <tgfclient.h>
|
||||
|
||||
#include "portability.h"
|
||||
#include "racescreens.h"
|
||||
#include "driver.h" //rmdGetDriverType
|
||||
|
||||
|
@ -82,8 +82,7 @@ rmPracticeResults(void *prevHdle, tRmInfo *info, int start)
|
|||
const char *race = info->_reRaceName;
|
||||
int i;
|
||||
int y;
|
||||
static const unsigned maxBufSize = 256;
|
||||
static char buf[maxBufSize];
|
||||
static char buf[256];
|
||||
static char path[1024];
|
||||
char *str;
|
||||
static float fgcolor[4] = {1.0, 0.0, 1.0, 1.0};
|
||||
|
@ -96,11 +95,16 @@ rmPracticeResults(void *prevHdle, tRmInfo *info, int start)
|
|||
void *menuXMLDescHdle = LoadMenuXML("practiceresultsmenu.xml");
|
||||
CreateStaticControls(menuXMLDescHdle,rmScrHdle);
|
||||
|
||||
sprintf(path, "%s/%s/%s", info->track->name, RE_SECT_RESULTS, race);
|
||||
sprintf(buf, "%s on %s", GfParmGetStr(results, path, RM_ATTR_DRVNAME, NULL), info->track->name);
|
||||
snprintf(buf, sizeof(buf), "Practice Results on %s", info->track->name);
|
||||
const int titleId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "title");
|
||||
GfuiLabelSetText(rmScrHdle, titleId, buf);
|
||||
|
||||
const int messId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "playertitle");
|
||||
GfuiLabelSetText(rmScrHdle, messId, buf);
|
||||
snprintf(path, sizeof(path), "%s/%s/%s", info->track->name, RE_SECT_RESULTS, race);
|
||||
snprintf(buf, sizeof(buf), "%s (%s)", GfParmGetStr(results, path, RM_ATTR_DRVNAME, NULL),
|
||||
GfParmGetStr(results, path, RM_ATTR_CAR, NULL));
|
||||
|
||||
const int subTitleId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "playertitle");
|
||||
GfuiLabelSetText(rmScrHdle, subTitleId, buf);
|
||||
|
||||
const int offset = 90;
|
||||
|
||||
|
@ -204,9 +208,8 @@ rmRaceResults(void *prevHdle, tRmInfo *info, int start)
|
|||
{
|
||||
void *results = info->results;
|
||||
const char *race = info->_reRaceName;
|
||||
static const unsigned maxBufSize = 256;
|
||||
static char buf[maxBufSize];
|
||||
static char path[1024];
|
||||
static char buf[256];
|
||||
static char path[512];
|
||||
char *str;
|
||||
static float fgcolor[4] = {1.0, 0.0, 1.0, 1.0};
|
||||
static float green[4] = {0.196, 0.804, 0.196, 1.0};//Lime green, #32CD32
|
||||
|
@ -219,8 +222,8 @@ rmRaceResults(void *prevHdle, tRmInfo *info, int start)
|
|||
CreateStaticControls(menuXMLDescHdle,rmScrHdle);
|
||||
|
||||
sprintf(buf, "%s", info->track->name);
|
||||
const int messId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "racetitle");
|
||||
GfuiLabelSetText(rmScrHdle, messId, buf);
|
||||
const int subTitleId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "racetitle");
|
||||
GfuiLabelSetText(rmScrHdle, subTitleId, buf);
|
||||
|
||||
|
||||
//Column positions
|
||||
|
@ -280,7 +283,7 @@ rmRaceResults(void *prevHdle, tRmInfo *info, int start)
|
|||
xDriver, y, GFUI_ALIGN_HL_VB, 0);
|
||||
|
||||
//Driver type
|
||||
rmdGetDriverType(GfParmGetStr(results, path, RE_ATTR_MODULE, ""), buf, maxBufSize);
|
||||
rmdGetDriverType(GfParmGetStr(results, path, RE_ATTR_MODULE, ""), buf, sizeof(buf));
|
||||
GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, xType, y, GFUI_ALIGN_HL_VB, 0);
|
||||
|
||||
//Car
|
||||
|
@ -288,7 +291,7 @@ rmRaceResults(void *prevHdle, tRmInfo *info, int start)
|
|||
xCar, y, GFUI_ALIGN_HL_VB, 0);
|
||||
|
||||
GfuiLabelCreate(rmScrHdle, GfParmGetStr(results, path, RE_ATTR_NAME, NULL), GFUI_FONT_MEDIUM_C, xDriver, y, GFUI_ALIGN_HL_VB, 0);
|
||||
rmdGetDriverType(GfParmGetStr(results, path, RE_ATTR_MODULE, NULL), buf, maxBufSize);
|
||||
rmdGetDriverType(GfParmGetStr(results, path, RE_ATTR_MODULE, NULL), buf, sizeof(buf));
|
||||
GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, xType, y, GFUI_ALIGN_HL_VB, 0);
|
||||
GfuiLabelCreate(rmScrHdle, GfParmGetStr(results, path, RE_ATTR_CAR, NULL), GFUI_FONT_MEDIUM_C,
|
||||
xCar, y, GFUI_ALIGN_HL_VB, 0);
|
||||
|
@ -375,9 +378,8 @@ rmQualifResults(void *prevHdle, tRmInfo *info, int start)
|
|||
const char *race = info->_reRaceName;
|
||||
int i;
|
||||
int y;
|
||||
static const unsigned maxBufSize = 256;
|
||||
static char buf[maxBufSize];
|
||||
static char path[1024];
|
||||
static char buf[256];
|
||||
static char path[512];
|
||||
char *str;
|
||||
static float fgcolor[4] = {1.0, 0.0, 1.0, 1.0};
|
||||
int laps, totLaps;
|
||||
|
@ -389,8 +391,8 @@ rmQualifResults(void *prevHdle, tRmInfo *info, int start)
|
|||
CreateStaticControls(menuXMLDescHdle,rmScrHdle);
|
||||
|
||||
sprintf(buf, "%s", info->track->name);
|
||||
const int messId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "racetitle");
|
||||
GfuiLabelSetText(rmScrHdle, messId, buf);
|
||||
const int subTitleId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "racetitle");
|
||||
GfuiLabelSetText(rmScrHdle, subTitleId, buf);
|
||||
|
||||
const int offset = 50;
|
||||
const int xRank = offset + 30;
|
||||
|
@ -423,7 +425,7 @@ rmQualifResults(void *prevHdle, tRmInfo *info, int start)
|
|||
|
||||
GfuiLabelCreate(rmScrHdle, GfParmGetStr(results, path, RE_ATTR_NAME, NULL), GFUI_FONT_MEDIUM_C,
|
||||
xDriver, y, GFUI_ALIGN_HL_VB, 0);
|
||||
rmdGetDriverType(GfParmGetStr(results, path, RE_ATTR_MODULE, NULL), buf, maxBufSize);
|
||||
rmdGetDriverType(GfParmGetStr(results, path, RE_ATTR_MODULE, NULL), buf, sizeof(buf));
|
||||
GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C,
|
||||
xType, y, GFUI_ALIGN_HL_VB, 0);
|
||||
GfuiLabelCreate(rmScrHdle, GfParmGetStr(results, path, RE_ATTR_CAR, NULL), GFUI_FONT_MEDIUM_C,
|
||||
|
@ -493,9 +495,8 @@ rmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
|||
{
|
||||
int i;
|
||||
int y;
|
||||
static const unsigned maxBufSize = 256;
|
||||
static char buf[maxBufSize];
|
||||
static char path[1024];
|
||||
static char buf[256];
|
||||
static char path[512];
|
||||
static float fgcolor[4] = {1.0, 0.0, 1.0, 1.0};
|
||||
int nbCars;
|
||||
void *results = info->results;
|
||||
|
@ -508,8 +509,8 @@ rmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
|||
|
||||
//Set title
|
||||
sprintf(buf, "%s Standings", race);
|
||||
const int messId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "racetitle");
|
||||
GfuiLabelSetText(rmScrHdle, messId, buf);
|
||||
const int subTitleId = CreateLabelControl(rmScrHdle, menuXMLDescHdle, "racetitle");
|
||||
GfuiLabelSetText(rmScrHdle, subTitleId, buf);
|
||||
|
||||
//Show header
|
||||
const int offset = 50;
|
||||
|
@ -541,7 +542,7 @@ rmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
|||
xDriver, y, GFUI_ALIGN_HL_VB, 0);
|
||||
|
||||
//Driver type
|
||||
rmdGetDriverType(GfParmGetStr(results, path, RE_ATTR_MODULE, NULL), buf, maxBufSize);
|
||||
rmdGetDriverType(GfParmGetStr(results, path, RE_ATTR_MODULE, NULL), buf, sizeof(buf));
|
||||
GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C,
|
||||
xType, y, GFUI_ALIGN_HL_VB, 0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue