本文整理汇总了C++中GfParmReadFile函数的典型用法代码示例。如果您正苦于以下问题:C++ GfParmReadFile函数的具体用法?C++ GfParmReadFile怎么用?C++ GfParmReadFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GfParmReadFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTrack
/*
* Function
*
*
* Description
* search under drivers/human/tracks/<trackname>/car-<model>-<index>.xml
* drivers/human/car-<model>-<index>.xml
* drivers/human/tracks/<trackname>/car-<model>.xml
* drivers/human/car-<model>.xml
*
* Parameters
*
*
* Return
*
*
* Remarks
*
*/
static void initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSituation *s)
{
const char *carname;
const int BUFSIZE = 1024;
char buf[BUFSIZE];
char sstring[BUFSIZE];
tdble fuel;
int idx = index - 1;
curTrack = track;
snprintf(sstring, BUFSIZE, "Robots/index/%d", index);
snprintf(buf, BUFSIZE, "%sdrivers/human/human.xml", GetLocalDir());
void *DrvInfo = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
carname = "";
if (DrvInfo != NULL) {
carname = GfParmGetStr(DrvInfo, sstring, "car name", "");
}
*carParmHandle = NULL;
// If session type is "race" and we have a race setup use it
if (s->_raceType == RM_TYPE_RACE) {
*carParmHandle = RtParmReadSetup(RACE, "human", index, track->internalname, carname);
}
// If session type is "qualifying" and we have a qualifying setup use it, use qualifying setup as
// fallback if not race setup is available
if (s->_raceType == RM_TYPE_QUALIF || (*carParmHandle == NULL && s->_raceType == RM_TYPE_RACE)) {
*carParmHandle = RtParmReadSetup(QUALIFYING, "human", index, track->internalname, carname);
}
// If we have not yet loaded a setup we have not found a fitting one or want to use the practice setup,
// so try to load this
if (*carParmHandle == NULL) {
*carParmHandle = RtParmReadSetup(PRACTICE, "human", index, track->internalname, carname);
}
// Absolute fallback, nothing found
if (*carParmHandle == NULL) {
snprintf(sstring, BUFSIZE, "%sdrivers/human/car.xml", GetLocalDir ());
*carParmHandle = GfParmReadFile(sstring, GFPARM_RMODE_REREAD);
}
if (curTrack->pits.type != TR_PIT_NONE) {
snprintf(sstring, BUFSIZE, "%s/%s/%d", HM_SECT_PREF, HM_LIST_DRV, index);
HCtx[idx]->NbPitStopProg = (int)GfParmGetNum(PrefHdle, sstring, HM_ATT_NBPITS, (char*)NULL, 0);
GfOut("Player: index %d , Pits stops %d\n", index, HCtx[idx]->NbPitStopProg);
} else {
HCtx[idx]->NbPitStopProg = 0;
}
fuel = 0.0008 * curTrack->length * (s->_totLaps + 1) / (1.0 + ((tdble)HCtx[idx]->NbPitStopProg)) + 20.0;
if (*carParmHandle) {
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, (char*)NULL, fuel);
}
Vtarget = curTrack->pits.speedLimit;
if (DrvInfo != NULL) {
GfParmReleaseHandle(DrvInfo);
}
}
示例2: strrchr
/* Called for every track change or new race. */
void Driver::initTrack(tTrack* t, void *carHandle, void **carParmHandle, tSituation *s)
{
track = t;
char buffer[256];
/* get a pointer to the first char of the track filename */
char* trackname = strrchr(track->filename, '/') + 1;
switch (s->_raceType) {
case RM_TYPE_PRACTICE:
sprintf(buffer, "drivers/sparkle/%d/practice/%s", INDEX, trackname);
break;
case RM_TYPE_QUALIF:
sprintf(buffer, "drivers/sparkle/%d/qualifying/%s", INDEX, trackname);
break;
case RM_TYPE_RACE:
sprintf(buffer, "drivers/sparkle/%d/race/%s", INDEX, trackname);
break;
default:
break;
}
*carParmHandle = GfParmReadFile(buffer, GFPARM_RMODE_STD);
if (*carParmHandle == NULL) {
sprintf(buffer, "drivers/sparkle/%d/default.xml", INDEX);
*carParmHandle = GfParmReadFile(buffer, GFPARM_RMODE_STD);
}
float fuel = GfParmGetNum(*carParmHandle, BT_SECT_PRIV, BT_ATT_FUELPERLAP, (char*)NULL, 5.0);
fuel *= (s->_totLaps + 1.0);
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, (char*)NULL, MIN(fuel, 100.0));
MU_FACTOR = GfParmGetNum(*carParmHandle, BT_SECT_PRIV, BT_ATT_MUFACTOR, (char*)NULL, 0.69);
}
示例3: rmdsClickOnDriver
static void
rmdsClickOnDriver(void * /* dummy */)
{
char *name;
tDrvElt *curDrv;
void *robhdle;
name = GfuiScrollListGetSelectedElement(scrHandle, selectedScrollList, (void**)&curDrv);
if (!name) {
name = GfuiScrollListGetSelectedElement(scrHandle, unselectedScrollList, (void**)&curDrv);
}
if (name) {
GfuiLabelSetText(scrHandle, PickDrvNameLabelId, curDrv->name);
/* search driver infos */
sprintf(buf, "%sdrivers/%s/%s.xml", GetLocalDir(), curDrv->dname, curDrv->dname);
robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
if (!robhdle) {
sprintf(buf, "drivers/%s/%s.xml", curDrv->dname, curDrv->dname);
robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
}
if (robhdle != NULL) {
sprintf(buf, "%s/%s/%d", ROB_SECT_ROBOTS, ROB_LIST_INDEX, curDrv->index);
GfuiLabelSetText(scrHandle, PickDrvCarLabelId, GfParmGetName(curDrv->car));
GfuiLabelSetText(scrHandle, PickDrvCategoryLabelId, GfParmGetStr(curDrv->car, SECT_CAR, PRM_CATEGORY, ""));
GfParmReleaseHandle(robhdle);
}
}
}
示例4: saveSoundOption
// Save the choosen values in the corresponding parameter file.
static void saveSoundOption(void *)
{
const int BUFSIZE = 1024;
char buf[BUFSIZE];
snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), GR_SOUND_PARM_CFG);
void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
GfParmSetStr(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_STATE, soundOptionList[curOption]);
GfParmSetNum(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_VOLUME, "%", VolumeValue);
GfParmWriteFile(NULL, paramHandle, "sound");
GfParmReleaseHandle(paramHandle);
// Write Menu music optons
snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), MM_SOUND_PARM_CFG);
paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
GfParmSetStr(paramHandle, MM_SCT_SOUND, MM_ATT_SOUND_ENABLE, menuMusicList[curOptionMenuMusic]);
GfParmWriteFile(NULL, paramHandle, "sound");
GfParmReleaseHandle(paramHandle);
if (curOptionMenuMusic == 1) {
startMenuMusic();
} else {
stopMenuMusic();
}
// Return to previous screen.
GfuiScreenActivate(prevHandle);
return;
}
示例5: GetFileHandle
//==========================================================================*
// Get filehandle for robot's xml-file
//--------------------------------------------------------------------------*
void* GetFileHandle(const char* RobotName)
{
void* RobotSettings = NULL;
strncpy(BufName, RobotName, BUFSIZE); // Save robot's name
snprintf(BufPathDirRel, BUFSIZE, // Robot's directory
"drivers/%s",RobotName); // relative to installation
snprintf(BufPathXMLRel, BUFSIZE, // Robot's xml-filename
"drivers/%s/%s.xml",RobotName,RobotName);// relative to installation
// Test local installation path
snprintf(BufPathXML, BUFSIZE, "%s%s",
GetLocalDir(), RobPathXMLRel);
snprintf(BufPathDir, BUFSIZE, "%s%s",
GetLocalDir(), RobPathDirRel);
RobotSettings = GfParmReadFile
(RobPathXML, GFPARM_RMODE_STD );
if (!RobotSettings)
{
// If not found, use global installation path
snprintf(BufPathXML, BUFSIZE, "%s%s",
GetDataDir(), RobPathXMLRel);
snprintf(BufPathDir, BUFSIZE, "%s%s",
GetDataDir(), RobPathDirRel);
RobotSettings = GfParmReadFile
(RobPathXML, GFPARM_RMODE_STD );
}
return RobotSettings;
}
示例6: ReRaceEventInit
int
ReRaceEventInit(void)
{
void *mainParams = ReInfo->mainParams;
void *params = ReInfo->params;
const bool careerMode = strcmp(GfParmGetStr(ReInfo->mainParams, RM_SECT_SUBFILES, RM_ATTR_HASSUBFILES, RM_VAL_NO), RM_VAL_YES) == 0;
/* Career mode : Look if it is necessary to open another file */
if (strcmp(GfParmGetStr(mainParams, RM_SECT_SUBFILES, RM_ATTR_HASSUBFILES, RM_VAL_NO), RM_VAL_YES) == 0)
{
/* Close previous params */
if (params != mainParams)
GfParmReleaseHandle(params);
/* Read the new params */
ReInfo->params = GfParmReadFile( GfParmGetStr( ReInfo->mainResults, RE_SECT_CURRENT, RE_ATTR_CUR_FILE, "" ), GFPARM_RMODE_STD );
GfLogTrace("Career : New params file is %s (from main results file)\n",
GfParmGetStr( ReInfo->mainResults, RE_SECT_CURRENT, RE_ATTR_CUR_FILE, ""));
if (!ReInfo->params)
GfLogWarning( "Career : MainResults params weren't read correctly\n" );
/* Close previous results */
if (ReInfo->results != ReInfo->mainResults)
{
GfParmWriteFile(NULL, ReInfo->results, NULL);
GfParmReleaseHandle(ReInfo->results);
}
/* Read the new results */
ReInfo->results = GfParmReadFile( GfParmGetStr( ReInfo->params, RM_SECT_SUBFILES, RM_ATTR_RESULTSUBFILE, ""), GFPARM_RMODE_STD );
if (!ReInfo->results)
GfLogWarning( "Career : New results weren't read correctly\n" );
}
// Initialize the race session name.
ReInfo->_reRaceName = ReGetCurrentRaceName();
GfLogInfo("Starting new event (%s session)\n", ReInfo->_reRaceName);
ReUI().onRaceEventInitializing();
ReInfo->s->_features = RmGetFeaturesList(ReInfo->params);
ReTrackInit();
ReEventInitResults();
NoCleanupNeeded = false;
const bool bGoOnLooping = ReUI().onRaceEventStarting(careerMode && !ReHumanInGroup());
return (bGoOnLooping ? RM_SYNC : RM_ASYNC) | RM_NEXT_STEP;
}
示例7: GfuiScreenAddBgImg
/** Add an image background to a screen.
@ingroup gui
@param scr Screen
@param filename file name of the bg image
@return None.
*/
void
GfuiScreenAddBgImg(void *scr, const char *filename)
{
tGfuiScreen *screen = (tGfuiScreen*)scr;
void *handle;
float screen_gamma;
GLbyte *tex;
int w,h;
const int BUFSIZE = 1024;
char buf[BUFSIZE];
if (glIsTexture(screen->bgImage) == GL_TRUE) {
glDeleteTextures(1, &screen->bgImage);
}
snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), GFSCR_CONF_FILE);
handle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
screen_gamma = (float)GfParmGetNum(handle, GFSCR_SECT_PROP, GFSCR_ATT_GAMMA, (char*)NULL, 2.0);
tex = (GLbyte*)GfImgReadPng(filename, &w, &h, screen_gamma);
if (!tex) {
GfParmReleaseHandle(handle);
return;
}
glGenTextures(1, &screen->bgImage);
glBindTexture(GL_TEXTURE_2D, screen->bgImage);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)(tex));
free(tex);
GfParmReleaseHandle(handle);
}
示例8: gfuiColorInit
static void
gfuiColorInit(void)
{
void *hdle;
int i, j;
char *rgba[4] = {GFSCR_ATTR_RED, GFSCR_ATTR_GREEN, GFSCR_ATTR_BLUE, GFSCR_ATTR_ALPHA};
char *clr[GFUI_COLORNB] = {
GFSCR_ELT_BGCOLOR, GFSCR_ELT_TITLECOLOR, GFSCR_ELT_BGBTNFOCUS, GFSCR_ELT_BGBTNCLICK,
GFSCR_ELT_BGBTNENABLED, GFSCR_ELT_BGBTNDISABLED, GFSCR_ELT_BTNFOCUS, GFSCR_ELT_BTNCLICK,
GFSCR_ELT_BTNENABLED, GFSCR_ELT_BTNDISABLED, GFSCR_ELT_LABELCOLOR, GFSCR_ELT_TIPCOLOR,
GFSCR_ELT_MOUSECOLOR1, GFSCR_ELT_MOUSECOLOR2, GFSCR_ELT_HELPCOLOR1, GFSCR_ELT_HELPCOLOR2,
GFSCR_ELT_BGSCROLLIST, GFSCR_ELT_SCROLLIST, GFSCR_ELT_BGSELSCROLLIST, GFSCR_ELT_SELSCROLLIST,
GFSCR_ELT_EDITCURSORCLR
};
sprintf(buf, "%s%s", GetLocalDir(), GFSCR_CONF_FILE);
hdle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
for (i = 0; i < GFUI_COLORNB; i++) {
for (j = 0; j < 4; j++) {
sprintf(buf, "%s/%s/%s", GFSCR_SECT_MENUCOL, GFSCR_LIST_COLORS, clr[i]);
GfuiColor[i][j] = GfParmGetNum(hdle, buf, rgba[j], (char*)NULL, 1.0);
}
}
GfParmReleaseHandle(hdle);
/* Remove the X11/Windows cursor */
if (!GfuiMouseHW) {
glutSetCursor(GLUT_CURSOR_NONE);
}
GfuiMouseVisible = 1;
}
示例9: reRegisterRaceman
/* Register a race manager */
static void
reRegisterRaceman(tFList *racemanCur)
{
sprintf(buf, "%sconfig/raceman/%s", GetLocalDir(), racemanCur->name);
racemanCur->userData = GfParmReadFile(buf, GFPARM_RMODE_STD);
racemanCur->dispName = GfParmGetStr(racemanCur->userData, RM_SECT_HEADER, RM_ATTR_NAME, 0);
}
示例10: TrackBuildEx
tTrack *
TrackBuildEx(const char *trackfile)
{
void *TrackHandle;
theTrack = (tTrack*)calloc(1, sizeof(tTrack));
theCamList = (tRoadCam*)NULL;
theTrack->params = TrackHandle = GfParmReadFile (trackfile, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT | GFPARM_RMODE_PRIVATE);
theTrack->filename = strdup(trackfile);
GetTrackHeader(TrackHandle);
switch(theTrack->version)
{
case 0:
case 1:
case 2:
case 3:
ReadTrack3(theTrack, TrackHandle, &theCamList, 1);
break;
case 4:
ReadTrack4(theTrack, TrackHandle, &theCamList, 1);
break;
case 5:
ReadTrack5(theTrack, TrackHandle, &theCamList, 1);
break;
}
return theTrack;
}
示例11: saveSoundOption
// Save the choosen values in the corresponding parameter file.
static void saveSoundOption(void *)
{
// Force current edit to loose focus (if one has it) and update associated variable.
GfuiUnSelectCurrent();
char buf[1024];
sprintf(buf, "%s%s", GfLocalDir(), SND_PARAM_FILE);
void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
GfParmSetStr(paramHandle, SND_SCT_SOUND, SND_ATT_SOUND_STATE, soundOptionList[curOption]);
GfParmSetNum(paramHandle, SND_SCT_SOUND, SND_ATT_SOUND_VOLUME, "%", VolumeValue);
GfParmSetStr(paramHandle, SND_SCT_MUSIC, SND_ATT_MUSIC_STATE, musicStateList[curMusicState]);
GfParmSetNum(paramHandle, SND_SCT_MUSIC, SND_ATT_MUSIC_VOLUME, "%", MusicVolumeValue);
GfParmWriteFile(NULL, paramHandle, "sound");
GfParmReleaseHandle(paramHandle);
// Shutdown the user interface.
LegacyMenu::self().shutdown();
// Restart the game.
GfuiApp().restart();
// Return to previous screen.
GfuiScreenActivate(prevHandle);
}
示例12: GfLocalDir
// Config file management.
void* GfglFeatures::openConfigFile()
{
std::ostringstream ossParm;
ossParm << GfLocalDir() << GFSCR_CONF_FILE;
return GfParmReadFile(ossParm.str().c_str(), GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
}
示例13: readSoundCfg
// Read sound configuration.
static void readSoundCfg(void)
{
const char *optionName;
int i;
char buf[1024];
sprintf(buf, "%s%s", GetLocalDir(), GR_SOUND_PARM_CFG);
void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
optionName = GfParmGetStr(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_STATE, soundOptionList[0]);
for (i = 0; i < nbOptions; i++) {
if (strcmp(optionName, soundOptionList[i]) == 0) {
curOption = i;
break;
}
}
VolumeValue = GfParmGetNum(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_VOLUME, "%", 100.0f);
if (VolumeValue>100.0f) {
VolumeValue = 100.0f;
}
if (VolumeValue < 0.0f) {
VolumeValue = 0.0f;
}
GfParmReleaseHandle(paramHandle);
GfuiLabelSetText(scrHandle, SoundOptionId, soundOptionList[curOption]);
}
示例14: ReInitResults
void
ReInitResults(void)
{
struct tm *stm;
time_t t;
void *results;
const int BUFSIZE = 1024;
char buf[BUFSIZE];
t = time(NULL);
stm = localtime(&t);
snprintf(buf, BUFSIZE, "%sresults/%s/results-%4d-%02d-%02d-%02d-%02d-%02d.xml",
GetLocalDir(),
ReInfo->_reFilename,
stm->tm_year+1900,
stm->tm_mon+1,
stm->tm_mday,
stm->tm_hour,
stm->tm_min,
stm->tm_sec
);
ReInfo->results = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
results = ReInfo->results;
GfParmSetNum(results, RE_SECT_HEADER, RE_ATTR_DATE, NULL, (tdble)t);
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_TRACK, NULL, 1);
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_DRIVER, NULL, 1);
}
示例15: human
extern "C" int
human(tModInfo *modInfo)
{
int i;
const char *driver;
const int BUFSIZE = 1024;
char buf[BUFSIZE];
char sstring[BUFSIZE];
memset(modInfo, 0, 10*sizeof(tModInfo));
snprintf(buf, BUFSIZE, "%sdrivers/human/human.xml", GetLocalDir());
void *DrvInfo = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
if (DrvInfo != NULL) {
for (i = 0; i < 10; i++) {
snprintf(sstring, BUFSIZE, "Robots/index/%d", i+1);
driver = GfParmGetStr(DrvInfo, sstring, "name", "");
if (strlen(driver) == 0) {
break;
}
modInfo->name = strdup(driver); /* name of the module (short) */
modInfo->desc = strdup("Joystick controlable driver"); /* description of the module (can be long) */
modInfo->fctInit = InitFuncPt; /* init function */
modInfo->gfId = ROB_IDENT; /* supported framework version */
modInfo->index = i+1;
modInfo++;
}
// Just release in case we got it.
GfParmReleaseHandle(DrvInfo);
}
return 0;
}