void PCreateSetLengthMenu(void* ts) { handle = GfuiScreenCreate(); fManager = PFileManager::Get(); // Create Title GfuiTitleCreate(handle, "Set Length", std::string("Set Length").length()); // Set up background image GfuiScreenAddBgImg(handle, "data/img/splash-filesel.png"); // Create Edit Box GfuiLabelCreate(handle, "Track Length (km):", GFUI_FONT_MEDIUM, 310, 260, GFUI_ALIGN_HC_VC, std::string("Track Length (km):").length()); editBoxID = GfuiEditboxCreate(handle, "1000", GFUI_FONT_MEDIUM, 265, 240, 100, 20, nullptr, nullptr, PUpdateEditBox); // Create error label errLabelID = GfuiLabelCreate(handle, " ", GFUI_FONT_MEDIUM, 30, 0, GFUI_ALIGN_HL_VB, 256); float col[4] = { 1.f, 0.f, 0.f, 1.f }; GfuiLabelSetColor(handle, errLabelID, col); // Create buttons GfuiButtonCreate(handle, "Accept", GFUI_FONT_MEDIUM, 365, 200, 50, GFUI_ALIGN_HC_VC, 0, ts, PAcceptCallback, nullptr, nullptr, nullptr); GfuiButtonCreate(handle, "Cancel", GFUI_FONT_MEDIUM, 245, 200, 50, GFUI_ALIGN_HC_VC, 0, ts, PAcceptCallback, nullptr, nullptr, nullptr); GfuiScreenActivate(handle); }
/* Menu creation */ void * SimuMenuInit(void *prevMenu) { int x, y, x2, x3, x4, dy; /* screen already created */ if (scrHandle) { return scrHandle; } prevHandle = prevMenu; scrHandle = GfuiScreenCreateEx((float*)NULL, NULL, onActivate, NULL, (tfuiCallback)NULL, 1); GfuiTitleCreate(scrHandle, "Simulation Configuration", 0); GfuiScreenAddBgImg(scrHandle, "data/img/splash-simucfg.png"); x = 20; x2 = 240; x3 = x2 + 100; x4 = x2 + 200; y = 370; dy = 30; y -= dy; GfuiLabelCreate(scrHandle, "Simulation version:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0); GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left-pushed.png", x2, y, GFUI_ALIGN_HL_VB, 1, (void*)-1, ChangeSimuVersion, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right-pushed.png", x4, y, GFUI_ALIGN_HR_VB, 1, (void*)1, ChangeSimuVersion, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); SimuVersionId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HC_VB, 32); GfuiLabelSetColor(scrHandle, SimuVersionId, LabelColor); GfuiButtonCreate(scrHandle, "Accept", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, SaveSimuVersion, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Cancel", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, prevMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddKey(scrHandle, 13, "Save", NULL, SaveSimuVersion, NULL); GfuiAddKey(scrHandle, 27, "Cancel Selection", prevMenu, GfuiScreenActivate, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_F12, "Screen-Shot", NULL, GfuiScreenShot, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_LEFT, "Previous Version in list", (void*)0, ChangeSimuVersion, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_RIGHT, "Next Version in list", (void*)1, ChangeSimuVersion, NULL); ReadSimuCfg(); return scrHandle; }
void * JoyCalMenuInit(void *prevMenu, tCmdInfo *cmd, int maxcmd) { int x, y, dy, i, index; Cmd = cmd; maxCmd = maxcmd; if (scrHandle2) { return scrHandle2; } scrHandle2 = GfuiScreenCreateEx(NULL, NULL, onActivate, NULL, NULL, 1); GfuiTitleCreate(scrHandle2, "Joystick Calibration", 0); GfuiMenuDefaultKeysAdd(scrHandle2); GfuiScreenAddBgImg(scrHandle2, "data/img/splash-joycal.png"); x = 128; y = 300; dy = 50; for (i = 0; i < 4; i++) { GfuiLabelCreate(scrHandle2, LabName[i], GFUI_FONT_LARGE, x, y, GFUI_ALIGN_HC_VC, 0); LabAxisId[i] = GfuiLabelCreate(scrHandle2, " ", GFUI_FONT_MEDIUM, 2 * x, y, GFUI_ALIGN_HC_VC, 0); LabMinId[i] = GfuiLabelCreate(scrHandle2, " ", GFUI_FONT_MEDIUM, 3 * x, y, GFUI_ALIGN_HC_VC, 0); LabMaxId[i] = GfuiLabelCreate(scrHandle2, " ", GFUI_FONT_MEDIUM, 4 * x, y, GFUI_ALIGN_HC_VC, 0); y -= dy; } for (index = 0; index < NUM_JOY; index++) { if (js[index] == NULL) { js[index] = new jsJoystick(index); } if (js[index]->notWorking()) { /* don't configure the joystick */ js[index] = NULL; } } InstId = GfuiLabelCreate(scrHandle2, Instructions[0], GFUI_FONT_MEDIUM, 320, 80, GFUI_ALIGN_HC_VB, 60); GfuiButtonCreate(scrHandle2, "Back", GFUI_FONT_LARGE, 160, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, prevMenu, onBack, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle2, "Reset", GFUI_FONT_LARGE, 480, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, onActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); return scrHandle2; }
void * MouseCalMenuInit(void *prevMenu, tCmdInfo *cmd, int maxcmd) { //int x, y, dy; Cmd = cmd; maxCmd = maxcmd; if (scrHandle2) { return scrHandle2; } scrHandle2 = GfuiScreenCreateEx(NULL, NULL, onActivate2, NULL, NULL, 1); GfuiTitleCreate(scrHandle2, "Mouse Calibration", 0); GfuiMenuDefaultKeysAdd(scrHandle2); GfuiScreenAddBgImg(scrHandle2, "data/img/splash-mousecal.png"); //x = 128; //y = 300; //dy = 50; InstId = GfuiLabelCreate(scrHandle2, "", GFUI_FONT_MEDIUM, 320, 80, GFUI_ALIGN_HC_VB, 60); GfuiButtonCreate(scrHandle2, "Back", GFUI_FONT_LARGE, 160, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, prevMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle2, "Reset", GFUI_FONT_LARGE, 480, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, onActivate2, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); return scrHandle2; }
/* * Function * TorcsMainMenuInit * * Description * init the main menus * * Parameters * none * * Return * 0 ok -1 nok * * Remarks * */ int TorcsMainMenuInit(void) { if (getTextOnly()) ReSinglePlayerInit(NULL); else { menuHandle = GfuiScreenCreateEx((float*)NULL, NULL, TorcsMainMenuActivate, NULL, (tfuiCallback)NULL, 1); GfuiScreenAddBgImg(menuHandle, "data/img/splash-main.png"); GfuiTitleCreate(menuHandle, "TORCS", 0); GfuiLabelCreate(menuHandle, "The Open Racing Car Simulator", GFUI_FONT_LARGE, 320, 420, GFUI_ALIGN_HC_VB, 0); GfuiMenuButtonCreate(menuHandle, "Race", "Races Menu", ReSinglePlayerInit(menuHandle), GfuiScreenActivate); GfuiMenuButtonCreate(menuHandle, "Configure Players", "Players configuration menu", TorcsDriverMenuInit(menuHandle), GfuiScreenActivate); GfuiMenuButtonCreate(menuHandle, "Options", "Configure", TorcsOptionOptionInit(menuHandle), GfuiScreenActivate); GfuiMenuDefaultKeysAdd(menuHandle); GfuiMenuBackQuitButtonCreate(menuHandle, "Quit", "Quit TORCS", TorcsMainExitMenuInit(menuHandle), GfuiScreenActivate); } return 0; }
/* * Function * TorcsMainMenuInit * * Description * init the main menus * * Parameters * none * * Return * 0 ok -1 nok * * Remarks * */ int TorcsMainMenuInit(void) { menuHandle = GfuiScreenCreateEx((float*)NULL, NULL, TorcsMainMenuActivate, NULL, (tfuiCallback)NULL, 1); GfuiScreenAddBgImg(menuHandle, "data/img/splash-main.png"); GfuiTitleCreate(menuHandle, "TORCS Adaptive", 0); GfuiLabelCreate(menuHandle, "A TORCS Modification with procedural tracks", GFUI_FONT_LARGE, 320, 420, GFUI_ALIGN_HC_VB, 0); GfuiMenuButtonCreate(menuHandle, "Race", "Races Menu", ReSinglePlayerInit(menuHandle), GfuiScreenActivate); GfuiMenuButtonCreate(menuHandle, "Configure Players", "Players configuration menu", TorcsDriverMenuInit(menuHandle), GfuiScreenActivate); GfuiMenuButtonCreate(menuHandle, "Options", "Configure", TorcsOptionOptionInit(menuHandle), GfuiScreenActivate); GfuiMenuDefaultKeysAdd(menuHandle); GfuiMenuBackQuitButtonCreate(menuHandle, "Quit", "Quit TORCS", TorcsMainExitMenuInit(menuHandle), GfuiScreenActivate); return 0; }
/** Add a Tip (generally associated with a button). @param scr Screen where to add the label @param text Text of the label @param maxlen Maximum length of the button string (used when the label is changed) @return label Id @see GfuiSetLabelText */ int GfuiTipCreate(void *scr, const char *text, int maxlen) { return GfuiLabelCreate(scr, text, NTipFontId, NTipX, NTipY, NTipWidth, NTipAlign, maxlen, gfuiColors[GFUI_TIPCOLOR]); }
/** Interactive Drivers list selection @param vs Pointer on tRmDrvSelect structure (cast to void) @warning The race manager params are modified but not saved. */ void RmDriversSelect(void *vs) { tModList *list; tModList *curmod; char dname[256]; char *sp; char *cardllname; int i, index; tDrvElt *curDrv; int nCars, robotIdx; void *robhdle; struct stat st; char *carName; void *carhdle; int human; #define B_BASE 380 #define B_HT 30 ds = (tRmDrvSelect*)vs; GF_TAILQ_INIT(&DrvList); scrHandle = GfuiScreenCreateEx((float*)NULL, NULL, rmdsActivate, NULL, (tfuiCallback)NULL, 1); GfuiScreenAddBgImg(scrHandle, "data/img/splash-qrdrv.png"); GfuiTitleCreate(scrHandle, "Select Drivers", sizeof("Select Drivers")); GfuiLabelCreate(scrHandle, "Selected", GFUI_FONT_LARGE, 120, 400, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreate(scrHandle, "Not Selected", GFUI_FONT_LARGE, 496, 400, GFUI_ALIGN_HC_VB, 0); selectedScrollList = GfuiScrollListCreate(scrHandle, GFUI_FONT_MEDIUM_C, 20, 80, GFUI_ALIGN_HL_VB, 200, 310, GFUI_SB_RIGHT, NULL, rmdsClickOnDriver); unselectedScrollList = GfuiScrollListCreate(scrHandle, GFUI_FONT_MEDIUM_C, 396, 80, GFUI_ALIGN_HL_VB, 200, 310, GFUI_SB_RIGHT, NULL, rmdsClickOnDriver); GfuiButtonCreate(scrHandle, "Accept", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, rmdsSelect, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Cancel", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, ds->prevScreen, rmdsDeactivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Move Up", GFUI_FONT_MEDIUM, 320, B_BASE, 100, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, (void*)-1, rmMove, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Move Down", GFUI_FONT_MEDIUM, 320, B_BASE - B_HT, 100, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, (void*)1, rmMove, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "(De)Select", GFUI_FONT_MEDIUM, 320, B_BASE - 2 * B_HT, 100, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, (void*)0, rmSelectDeselect, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Set Focus", GFUI_FONT_MEDIUM, 320, B_BASE - 3 * B_HT, 100, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, rmdsSetFocus, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); list = (tModList *)NULL; sprintf(buf, "%sdrivers", GetLibDir ()); GfModInfoDir(CAR_IDENT, buf, 1, &list); curmod = list; if (curmod != NULL) { do { curmod = curmod->next; for (i = 0; i < MAX_MOD_ITF; i++) { if (curmod->modInfo[i].name) { sp = strrchr(curmod->sopath, '/'); if (sp == NULL) { sp = curmod->sopath; } else { sp++; } strcpy(dname, sp); dname[strlen(dname) - strlen(DLLEXT) - 1] = 0; /* cut .so or .dll */ sprintf(buf, "%sdrivers/%s/%s.xml", GetLocalDir(), dname, dname); robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD); if (!robhdle) { sprintf(buf, "drivers/%s/%s.xml", dname, dname); robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD); } sprintf(path, "%s/%s/%d", ROB_SECT_ROBOTS, ROB_LIST_INDEX, curmod->modInfo[i].index); carName = GfParmGetStr(robhdle, path, ROB_ATTR_CAR, ""); if (strcmp(GfParmGetStr(robhdle, path, ROB_ATTR_TYPE, ROB_VAL_ROBOT), ROB_VAL_ROBOT)) { human = 1; } else { human = 0; } sprintf(path, "cars/%s/%s.xml", carName, carName); if (!stat(path, &st)) { carhdle = GfParmReadFile(path, GFPARM_RMODE_STD); if (carhdle) { curDrv = (tDrvElt*)calloc(1, sizeof(tDrvElt)); curDrv->index = curmod->modInfo[i].index; curDrv->dname = strdup(dname); curDrv->name = strdup(curmod->modInfo[i].name); curDrv->car = carhdle; if (human) { curDrv->human = 1; GF_TAILQ_INSERT_HEAD(&DrvList, curDrv, link); } else { curDrv->human = 0; GF_TAILQ_INSERT_TAIL(&DrvList, curDrv, link); } } else { GfOut("Driver %s not selected because car %s is not readable\n", curmod->modInfo[i].name, carName); } } else { GfOut("Driver %s not selected because car %s is not present\n", curmod->modInfo[i].name, carName); } GfParmReleaseHandle(robhdle); } } } while (curmod != list); } nbSelectedDrivers = 0; nbMaxSelectedDrivers = (int)GfParmGetNum(ds->param, RM_SECT_DRIVERS, RM_ATTR_MAXNUM, NULL, 0); nCars = GfParmGetEltNb(ds->param, RM_SECT_DRIVERS); index = 1; for (i = 1; i < nCars+1; i++) { sprintf(dname, "%s/%d", RM_SECT_DRIVERS, i); cardllname = GfParmGetStr(ds->param, dname, RM_ATTR_MODULE, ""); robotIdx = (int)GfParmGetNum(ds->param, dname, RM_ATTR_IDX, (char*)NULL, 0); curDrv = GF_TAILQ_FIRST(&DrvList); if (curDrv != NULL) { do { if ((curDrv->index == robotIdx) && (strcmp(curDrv->dname, cardllname) == 0)) { if (nbSelectedDrivers < nbMaxSelectedDrivers) { GfuiScrollListInsertElement(scrHandle, selectedScrollList, curDrv->name, index, (void*)curDrv); curDrv->sel = index++; nbSelectedDrivers++; } break; } } while ((curDrv = GF_TAILQ_NEXT(curDrv, link)) != NULL); } } curDrv = GF_TAILQ_FIRST(&DrvList); if (curDrv != NULL) { do { if (curDrv->sel == 0) { GfuiScrollListInsertElement(scrHandle, unselectedScrollList, curDrv->name, 1000, (void*)curDrv); } } while ((curDrv = GF_TAILQ_NEXT(curDrv, link)) != NULL); } GfuiLabelCreate(scrHandle, "Focused:", GFUI_FONT_MEDIUM, 320, B_BASE - 5 * B_HT, GFUI_ALIGN_HC_VB, 0); cardllname = GfParmGetStr(ds->param, RM_SECT_DRIVERS, RM_ATTR_FOCUSED, ""); robotIdx = (int)GfParmGetNum(ds->param, RM_SECT_DRIVERS, RM_ATTR_FOCUSEDIDX, (char*)NULL, 0); curDrv = GF_TAILQ_FIRST(&DrvList); if (curDrv != NULL) { do { if ((curDrv->index == robotIdx) && (strcmp(curDrv->dname, cardllname) == 0)) { break; } } while ((curDrv = GF_TAILQ_NEXT(curDrv, link)) != NULL); } if (curDrv == NULL) { curDrv = GF_TAILQ_FIRST(&DrvList); } if (curDrv == NULL) { FocDrvLabelId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, 320, B_BASE - 5 * B_HT - GfuiFontHeight(GFUI_FONT_MEDIUM), GFUI_ALIGN_HC_VB, 256); } else { FocDrvLabelId = GfuiLabelCreate(scrHandle, curDrv->name, GFUI_FONT_MEDIUM_C, 320, B_BASE - 5 * B_HT - GfuiFontHeight(GFUI_FONT_MEDIUM), GFUI_ALIGN_HC_VB, 256); } /* Picked Driver Info */ GfuiLabelCreate(scrHandle, "Driver:", GFUI_FONT_MEDIUM, 320, B_BASE - 7 * B_HT, GFUI_ALIGN_HC_VB, 0); PickDrvNameLabelId = GfuiLabelCreateEx(scrHandle, "", aColor, GFUI_FONT_MEDIUM_C, 320, B_BASE - 7 * B_HT - GfuiFontHeight(GFUI_FONT_MEDIUM), GFUI_ALIGN_HC_VB, 256); GfuiLabelCreate(scrHandle, "Car:", GFUI_FONT_MEDIUM, 320, B_BASE - 8 * B_HT, GFUI_ALIGN_HC_VB, 0); PickDrvCarLabelId = GfuiLabelCreateEx(scrHandle, "", aColor, GFUI_FONT_MEDIUM_C, 320, B_BASE - 8 * B_HT - GfuiFontHeight(GFUI_FONT_MEDIUM), GFUI_ALIGN_HC_VB, 256); GfuiLabelCreate(scrHandle, "Category:", GFUI_FONT_MEDIUM, 320, B_BASE - 9 * B_HT, GFUI_ALIGN_HC_VB, 0); PickDrvCategoryLabelId = GfuiLabelCreateEx(scrHandle, "", aColor, GFUI_FONT_MEDIUM_C, 320, B_BASE - 9 * B_HT - GfuiFontHeight(GFUI_FONT_MEDIUM), GFUI_ALIGN_HC_VB, 256); GfuiMenuDefaultKeysAdd(scrHandle); rmdsAddKeys(); GfuiScreenActivate(scrHandle); }
void * GraphMenuInit(void *prevMenu) { int x, y, x2, dy; /* screen already created */ if (scrHandle) { return scrHandle; } scrHandle = GfuiMenuScreenCreate("Graphic Configuration"); GfuiScreenAddBgImg(scrHandle, "data/img/splash-graphconf.png"); sprintf(buf, "%s%s", GetLocalDir(), GR_PARAM_FILE); void * grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT); x = 50; x2 = 200; y = 370; dy = 30; GfuiLabelCreate(scrHandle, "Visibility (%):", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0); FovFactorValue = (int)GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_FOVFACT, "%", 100.0); sprintf(buf, "%d", FovFactorValue); FovEditId = GfuiEditboxCreate(scrHandle, buf, GFUI_FONT_MEDIUM_C, x2+10, y, 100, 16, NULL, (tfuiCallback)NULL, ChangeFov); y -= dy; GfuiLabelCreate(scrHandle, "Smoke:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0); SmokeValue = (int)GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_SMOKENB, NULL, 300.0); sprintf(buf, "%d", SmokeValue); SmokeEditId = GfuiEditboxCreate(scrHandle, buf, GFUI_FONT_MEDIUM_C, x2+10, y, 100, 16, NULL, (tfuiCallback)NULL, ChangeSmoke); y -= dy; GfuiLabelCreate(scrHandle, "Skid Marks:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0); SkidValue = (int)GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_MAXSTRIPBYWHEEL, NULL, 20.0); sprintf(buf, "%d", SkidValue); SkidEditId = GfuiEditboxCreate(scrHandle, buf, GFUI_FONT_MEDIUM_C, x2+10, y, 100, 16, NULL, (tfuiCallback)NULL, ChangeSkid); y -= dy; GfuiLabelCreate(scrHandle, "LOD factor:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0); LodFactorValue = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_LODFACTOR, NULL, 1.0); sprintf(buf, "%g", LodFactorValue); LodFactorEditId = GfuiEditboxCreate(scrHandle, buf, GFUI_FONT_MEDIUM_C, x2+10, y, 100, 16, NULL, (tfuiCallback)NULL, ChangeLodFactor); GfuiButtonCreate(scrHandle, "Accept", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, prevMenu, SaveGraphicOptions, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Cancel", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, prevMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddKey(scrHandle, 27, "Cancel", prevMenu, GfuiScreenActivate, NULL); GfParmReleaseHandle(grHandle); return scrHandle; }
// Sound menu void * SoundMenuInit(void *prevMenu) { int x, y, x2, x3, x4, dy; // char buf[1024]; // Has screen already been created? if (scrHandle) { return scrHandle; } prevHandle = prevMenu; scrHandle = GfuiScreenCreateEx((float*)NULL, NULL, onActivate, NULL, (tfuiCallback)NULL, 1); GfuiTitleCreate(scrHandle, "Sound Configuration", 0); GfuiScreenAddBgImg(scrHandle, "data/img/splash-qrdrv.png"); x = 20; x2 = 200; x3 = 340; x4 = (x2+x3)/2; y = 400; dy = 30; y -= dy; GfuiLabelCreate(scrHandle, "Sound System:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0); GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left-pushed.png", x2, y-5, GFUI_ALIGN_HL_VB, 1, (void*)-1, changeSoundState, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right-pushed.png", x3, y-5, GFUI_ALIGN_HR_VB, 1, (void*)1, changeSoundState, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); SoundOptionId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, x4, y, GFUI_ALIGN_HC_VB, 32); GfuiLabelSetColor(scrHandle, SoundOptionId, LabelColor); /* y -= dy; GfuiLabelCreate(scrHandle, "Volume:", GFUI_FONT_MEDIUM, x, y, GFUI_ALIGN_HL_VB, 0); sprintf(buf, "%f", VolumeValue); VolumeValueId = GfuiEditboxCreate(scrHandle, buf, GFUI_FONT_MEDIUM_C, x2+10, y+2, x4-x2+20, 16, NULL, (tfuiCallback)NULL, changeVolume); */ GfuiButtonCreate(scrHandle, "Accept", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, saveSoundOption, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Cancel", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, prevMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddKey(scrHandle, 13, "Save", NULL, saveSoundOption, NULL); GfuiAddKey(scrHandle, 27, "Cancel Selection", prevMenu, GfuiScreenActivate, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_F12, "Screen-Shot", NULL, GfuiScreenShot, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_LEFT, "Previous Option in list", (void*)0, changeSoundState, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_RIGHT, "Next Option in list", (void*)1, changeSoundState, NULL); readSoundCfg(); return scrHandle; }
static int createLabel(void* hscr, void* hparm, const char* pszPath, bool bFromTemplate = false, const char* text = GFUI_TPL_TEXT, int x = GFUI_TPL_X, int y = GFUI_TPL_Y, int font = GFUI_TPL_FONTID, int width = GFUI_TPL_WIDTH, int hAlign = GFUI_TPL_ALIGN, int maxlen = GFUI_TPL_MAXLEN, const float* aFgColor = GFUI_TPL_COLOR, const float* aFgFocusColor = GFUI_TPL_FOCUSCOLOR) { if (strcmp(GfParmGetStr(hparm, pszPath, GFMNU_ATTR_TYPE, ""), GFMNU_TYPE_LABEL)) { GfLogError("Failed to create label control '%s' : section not found or not a '%s'\n", pszPath, GFMNU_TYPE_LABEL); return -1; } const char* pszText = bFromTemplate && text != GFUI_TPL_TEXT ? text : GfParmGetStr(hparm, pszPath, GFMNU_ATTR_TEXT, ""); const int nX = bFromTemplate && x != GFUI_TPL_X ? x : (int)GfParmGetNum(hparm, pszPath, GFMNU_ATTR_X, NULL, 0); const int nY = bFromTemplate && y != GFUI_TPL_Y ? y : (int)GfParmGetNum(hparm, pszPath, GFMNU_ATTR_Y, NULL, 0); const int nWidth = bFromTemplate && width != GFUI_TPL_WIDTH ? width : (int)GfParmGetNum(hparm, pszPath, GFMNU_ATTR_WIDTH, NULL, 0); const int nFontId = bFromTemplate && font != GFUI_TPL_FONTID ? font : gfuiMenuGetFontId(GfParmGetStr(hparm, pszPath, GFMNU_ATTR_FONT, "")); const char* pszAlignH = GfParmGetStr(hparm, pszPath, GFMNU_ATTR_H_ALIGN, ""); //const char* pszAlignV = GfParmGetStr(hparm, pszPath, GFMNU_ATTR_V_ALIGN, ""); const int nAlign = bFromTemplate && hAlign != GFUI_TPL_ALIGN ? hAlign : gfuiMenuGetAlignment(pszAlignH); //, pszAlignV); int nMaxLen = bFromTemplate && maxlen != GFUI_TPL_MAXLEN ? maxlen : (int)GfParmGetNum(hparm, pszPath, GFMNU_ATTR_MAX_LEN, NULL, 0); GfuiColor color; const float* aColor = 0; if (bFromTemplate && aFgColor != GFUI_TPL_COLOR) aColor = aFgColor; else { color = getControlColor(hparm, pszPath, GFMNU_ATTR_COLOR); if (color.alpha) aColor = color.toFloatRGBA(); } GfuiColor focusColor; const float* aFocusColor = 0; if (bFromTemplate && aFgFocusColor != GFUI_TPL_FOCUSCOLOR) aFocusColor = aFgFocusColor; else { focusColor = getControlColor(hparm, pszPath, GFMNU_ATTR_COLOR_FOCUSED); if (focusColor.alpha) aFocusColor = focusColor.toFloatRGBA(); } void* userDataOnFocus = 0; tfuiCallback onFocus = 0; tfuiCallback onFocusLost = 0; const char* pszTip = GfParmGetStr(hparm, pszPath, GFMNU_ATTR_TIP, 0); if (pszTip && strlen(pszTip) > 0) { tMenuCallbackInfo * cbinfo = (tMenuCallbackInfo*)calloc(1, sizeof(tMenuCallbackInfo)); cbinfo->screen = hscr; cbinfo->labelId = GfuiTipCreate(hscr, pszTip, strlen(pszTip)); GfuiVisibilitySet(hscr, cbinfo->labelId, GFUI_INVISIBLE); userDataOnFocus = (void*)cbinfo; onFocus = onFocusShowTip; onFocusLost = onFocusLostHideTip; } int labelId = GfuiLabelCreate(hscr, pszText, nFontId, nX, nY, nWidth, nAlign, nMaxLen, aColor, aFocusColor, userDataOnFocus, onFocus, onFocusLost); return labelId; }
// OpenGL menu void * OpenGLMenuInit(void *prevMenu) { int y, dy; // Has screen already been created? if (scrHandle) { return scrHandle; } prevHandle = prevMenu; scrHandle = GfuiScreenCreateEx((float*)NULL, NULL, onActivate, NULL, (tfuiCallback)NULL, 1); GfuiTitleCreate(scrHandle, "OpenGL Options", 0); GfuiScreenAddBgImg(scrHandle, "data/img/splash-simucfg.png"); y = 400; dy = 30; const int xleft = 160; // Center of left elements. const int xright = 480; // Center of right elements. const int width = 240; // Width of elements. y -= dy; // Texture compression. GfuiLabelCreate(scrHandle, "Texture Compression", GFUI_FONT_LARGE, xleft, 400, GFUI_ALIGN_HC_VB, 0); if (isCompressARBAvailable()) { GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left-pushed.png", xleft-width/2, y, GFUI_ALIGN_HC_VB, 1, (void*)-1, changeTextureCompressState, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right-pushed.png", xleft+width/2, y, GFUI_ALIGN_HC_VB, 1, (void*)1, changeTextureCompressState, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); TextureCompressOptionId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_LARGE_C, xleft, y, GFUI_ALIGN_HC_VB, 32); GfuiLabelSetColor(scrHandle, TextureCompressOptionId, LabelColor); } else { GfuiLabelCreate(scrHandle, "not available", GFUI_FONT_LARGE_C, xleft, y, GFUI_ALIGN_HC_VB, 0); } // Texture sizing. GfuiLabelCreate(scrHandle, "Texture Size Limit", GFUI_FONT_LARGE, xright, 400, GFUI_ALIGN_HC_VB, 0); GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left-pushed.png", xright-width/2, y, GFUI_ALIGN_HC_VB, 0, (void*)-1, changeTextureSizeState, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right-pushed.png", xright+width/2, y, GFUI_ALIGN_HC_VB, 0, (void*)1, changeTextureSizeState, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); TextureSizeOptionId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_LARGE_C, xright, y, GFUI_ALIGN_HC_VB, 32); GfuiLabelSetColor(scrHandle, TextureSizeOptionId, LabelColor); GfuiButtonCreate(scrHandle, "Accept", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, saveOpenGLOption, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Cancel", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, prevMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddKey(scrHandle, 13, "Save", NULL, saveOpenGLOption, NULL); GfuiAddKey(scrHandle, 27, "Cancel Selection", prevMenu, GfuiScreenActivate, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_F12, "Screen-Shot", NULL, GfuiScreenShot, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_LEFT, "Previous Option in list", (void*)0, changeTextureCompressState, NULL); GfuiAddSKey(scrHandle, GLUT_KEY_RIGHT, "Next Option in list", (void*)1, changeTextureCompressState, NULL); readOpenGLCfg(); return scrHandle; }
static void rmPracticeResults(void *prevHdle, tRmInfo *info, int start) { void *results = info->results; const char *race = info->_reRaceName; int i; int x1, x2, x3, x4, x5, x6; int offset; int y; const int BUFSIZE = 1024; char buf[BUFSIZE]; char path[BUFSIZE]; const int TIMEFMTSIZE = 256; char timefmt[TIMEFMTSIZE]; float fgcolor[4] = {1.0, 0.0, 1.0, 1.0}; int totLaps; rmScrHdle = GfuiScreenCreate(); snprintf(buf, BUFSIZE, "Practice Results"); GfuiTitleCreate(rmScrHdle, buf, strlen(buf)); snprintf(path, BUFSIZE, "%s/%s/%s", info->track->name, RE_SECT_RESULTS, race); snprintf(buf, BUFSIZE, "%s on track %s", GfParmGetStr(results, path, RM_ATTR_DRVNAME, ""), info->track->name); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_LARGE_C, 320, 420, GFUI_ALIGN_HC_VB, 0); GfuiScreenAddBgImg(rmScrHdle, "data/img/splash-result.png"); offset = 90; x1 = offset + 30; x2 = offset + 50; x3 = offset + 130; x4 = offset + 240; x5 = offset + 310; x6 = offset + 400; y = 400; GfuiLabelCreateEx(rmScrHdle, "Lap", fgcolor, GFUI_FONT_MEDIUM_C, x1, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Time", fgcolor, GFUI_FONT_MEDIUM_C, x2+20, y, GFUI_ALIGN_HL_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Best", fgcolor, GFUI_FONT_MEDIUM_C, x3+20, y, GFUI_ALIGN_HL_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Top Spd", fgcolor, GFUI_FONT_MEDIUM_C, x4, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Min Spd", fgcolor, GFUI_FONT_MEDIUM_C, x5, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Damages", fgcolor, GFUI_FONT_MEDIUM_C, x6, y, GFUI_ALIGN_HC_VB, 0); y -= 20; snprintf(path, BUFSIZE, "%s/%s/%s", info->track->name, RE_SECT_RESULTS, race); totLaps = (int)GfParmGetEltNb(results, path); for (i = 0 + start; i < MIN(start + MAX_LINES, totLaps); i++) { snprintf(path, BUFSIZE, "%s/%s/%s/%d", info->track->name, RE_SECT_RESULTS, race, i + 1); /* Lap */ snprintf(buf, BUFSIZE, "%d", i+1); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x1, y, GFUI_ALIGN_HC_VB, 0); /* Time */ GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_TIME, NULL, 0), 0); GfuiLabelCreate(rmScrHdle, timefmt, GFUI_FONT_MEDIUM_C, x2, y, GFUI_ALIGN_HL_VB, 0); /* Best Lap Time */ GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_BEST_LAP_TIME, NULL, 0), 0); GfuiLabelCreate(rmScrHdle, timefmt, GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HL_VB, 0); /* Top Spd */ snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_TOP_SPEED, NULL, 0) * 3.6)); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x4, y, GFUI_ALIGN_HC_VB, 0); /* Min Spd */ snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_BOT_SPEED, NULL, 0) * 3.6)); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x5, y, GFUI_ALIGN_HC_VB, 0); /* Damages */ snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_DAMMAGES, NULL, 0))); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x6, y, GFUI_ALIGN_HC_VB, 0); y -= 15; } if (start > 0) { RmPrevRace.prevHdle = prevHdle; RmPrevRace.info = info; RmPrevRace.start = start - MAX_LINES; GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-up.png", "data/img/arrow-up.png", "data/img/arrow-up.png", "data/img/arrow-up-pushed.png", 80, 40, GFUI_ALIGN_HL_VB, 1, (void*)&RmPrevRace, rmChgPracticeScreen, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_UP, "Previous Results", (void*)&RmPrevRace, rmChgPracticeScreen, NULL); } GfuiButtonCreate(rmScrHdle, "Continue", GFUI_FONT_LARGE, 320, 40, 150, GFUI_ALIGN_HC_VB, 0, prevHdle, GfuiScreenReplace, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); if (i < totLaps) { RmNextRace.prevHdle = prevHdle; RmNextRace.info = info; RmNextRace.start = start + MAX_LINES; GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-down.png", "data/img/arrow-down.png", "data/img/arrow-down.png", "data/img/arrow-down-pushed.png", 540, 40, GFUI_ALIGN_HL_VB, 1, (void*)&RmNextRace, rmChgPracticeScreen, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_DOWN, "Next Results", (void*)&RmNextRace, rmChgPracticeScreen, NULL); } GfuiAddKey(rmScrHdle, (unsigned char)27, "", prevHdle, GfuiScreenReplace, NULL); GfuiAddKey(rmScrHdle, (unsigned char)13, "", prevHdle, GfuiScreenReplace, NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL); GfuiScreenActivate(rmScrHdle); }
static void rmShowStandings(void *prevHdle, tRmInfo *info, int start) { int i; int x1, x2, x3; int y; const int BUFSIZE = 1024; char buf[BUFSIZE]; char path[BUFSIZE]; float fgcolor[4] = {1.0, 0.0, 1.0, 1.0}; int nbCars; int offset; void *results = info->results; const char *race = info->_reRaceName; rmScrHdle = GfuiScreenCreate(); snprintf(buf, BUFSIZE, "%s Results", race); GfuiTitleCreate(rmScrHdle, buf, strlen(buf)); GfuiScreenAddBgImg(rmScrHdle, "data/img/splash-result.png"); offset = 200; x1 = offset + 30; x2 = offset + 60; x3 = offset + 240; y = 400; GfuiLabelCreateEx(rmScrHdle, "Rank", fgcolor, GFUI_FONT_MEDIUM_C, x1, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Driver", fgcolor, GFUI_FONT_MEDIUM_C, x2+10, y, GFUI_ALIGN_HL_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Points", fgcolor, GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HR_VB, 0); y -= 20; nbCars = (int)GfParmGetEltNb(results, RE_SECT_STANDINGS); for (i = start; i < MIN(start + MAX_LINES, nbCars); i++) { snprintf(path, BUFSIZE, "%s/%d", RE_SECT_STANDINGS, i + 1); snprintf(buf, BUFSIZE, "%d", i+1); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x1, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreate(rmScrHdle, GfParmGetStr(results, path, RE_ATTR_NAME, ""), GFUI_FONT_MEDIUM_C, x2, y, GFUI_ALIGN_HL_VB, 0); snprintf(buf, BUFSIZE, "%d", (int)GfParmGetNum(results, path, RE_ATTR_POINTS, NULL, 0)); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HR_VB, 0); y -= 15; } if (start > 0) { RmPrevRace.prevHdle = prevHdle; RmPrevRace.info = info; RmPrevRace.start = start - MAX_LINES; GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-up.png", "data/img/arrow-up.png", "data/img/arrow-up.png", "data/img/arrow-up-pushed.png", 80, 40, GFUI_ALIGN_HL_VB, 1, (void*)&RmPrevRace, rmChgStandingScreen, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_UP, "Previous Results", (void*)&RmPrevRace, rmChgStandingScreen, NULL); } GfuiButtonCreate(rmScrHdle, "Continue", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, 0, prevHdle, GfuiScreenReplace, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); rmSaveId = GfuiButtonCreate(rmScrHdle, "Save", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, 0, info, rmSaveRes, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); if (i < nbCars) { RmNextRace.prevHdle = prevHdle; RmNextRace.info = info; RmNextRace.start = start + MAX_LINES; GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-down.png", "data/img/arrow-down.png", "data/img/arrow-down.png", "data/img/arrow-down-pushed.png", 540, 40, GFUI_ALIGN_HL_VB, 1, (void*)&RmNextRace, rmChgStandingScreen, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_DOWN, "Next Results", (void*)&RmNextRace, rmChgStandingScreen, NULL); } GfuiAddKey(rmScrHdle, (unsigned char)27, "", prevHdle, GfuiScreenReplace, NULL); GfuiAddKey(rmScrHdle, (unsigned char)13, "", prevHdle, GfuiScreenReplace, NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL); GfuiScreenActivate(rmScrHdle); }
static void rmRaceResults(void *prevHdle, tRmInfo *info, int start) { void *results = info->results; const char *race = info->_reRaceName; int i; int x1, x2, x3, x4, x5, x6, x7, x8, x9; int dlap; int y; const int BUFSIZE = 1024; char buf[BUFSIZE]; char path[BUFSIZE]; const int TIMEFMTSIZE = 256; char timefmt[TIMEFMTSIZE]; float fgcolor[4] = {1.0, 0.0, 1.0, 1.0}; int laps, totLaps; tdble refTime; int nbCars; rmScrHdle = GfuiScreenCreate(); snprintf(buf, BUFSIZE, "Race Results"); GfuiTitleCreate(rmScrHdle, buf, strlen(buf)); snprintf(buf, BUFSIZE, "%s", info->track->name); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_LARGE_C, 320, 420, GFUI_ALIGN_HC_VB, 0); GfuiScreenAddBgImg(rmScrHdle, "data/img/splash-result.png"); x1 = 30; x2 = 60; x3 = 260; x4 = 330; x5 = 360; x6 = 420; x7 = 490; x8 = 545; x9 = 630; y = 400; GfuiLabelCreateEx(rmScrHdle, "Rank", fgcolor, GFUI_FONT_MEDIUM_C, x1, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Driver", fgcolor, GFUI_FONT_MEDIUM_C, x2+10, y, GFUI_ALIGN_HL_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Total", fgcolor, GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HR_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Best", fgcolor, GFUI_FONT_MEDIUM_C, x4, y, GFUI_ALIGN_HR_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Laps", fgcolor, GFUI_FONT_MEDIUM_C, x5, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Top Spd", fgcolor, GFUI_FONT_MEDIUM_C, x6, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Damage", fgcolor, GFUI_FONT_MEDIUM_C, x7, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Pit", fgcolor, GFUI_FONT_MEDIUM_C, x8, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreateEx(rmScrHdle, "Penalty", fgcolor, GFUI_FONT_MEDIUM_C, x9, y, GFUI_ALIGN_HR_VB, 0); y -= 20; snprintf(path, BUFSIZE, "%s/%s/%s", info->track->name, RE_SECT_RESULTS, race); totLaps = (int)GfParmGetNum(results, path, RE_ATTR_LAPS, NULL, 0); snprintf(path, BUFSIZE, "%s/%s/%s/%s/%d", info->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK, 1); refTime = GfParmGetNum(results, path, RE_ATTR_TIME, NULL, 0); snprintf(path, BUFSIZE, "%s/%s/%s/%s", info->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK); nbCars = (int)GfParmGetEltNb(results, path); for (i = start; i < MIN(start + MAX_LINES, nbCars); i++) { snprintf(path, BUFSIZE, "%s/%s/%s/%s/%d", info->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK, i + 1); laps = (int)GfParmGetNum(results, path, RE_ATTR_LAPS, NULL, 0); snprintf(buf, BUFSIZE, "%d", i+1); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x1, y, GFUI_ALIGN_HC_VB, 0); GfuiLabelCreate(rmScrHdle, GfParmGetStr(results, path, RE_ATTR_NAME, ""), GFUI_FONT_MEDIUM_C, x2, y, GFUI_ALIGN_HL_VB, 0); if (laps == totLaps) { if (i == 0) { GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_TIME, NULL, 0), 0); } else { GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_TIME, NULL, 0) - refTime, 1); } GfuiLabelCreate(rmScrHdle, timefmt, GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HR_VB, 0); } else { dlap = totLaps - laps; if (dlap == 1) { snprintf(buf, BUFSIZE, "+1 Lap"); } else { snprintf(buf, BUFSIZE, "+%d Laps", dlap); } GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x3, y, GFUI_ALIGN_HR_VB, 0); } GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_BEST_LAP_TIME, NULL, 0), 0); GfuiLabelCreate(rmScrHdle, timefmt, GFUI_FONT_MEDIUM_C, x4, y, GFUI_ALIGN_HR_VB, 0); snprintf(buf, BUFSIZE, "%d", laps); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x5, y, GFUI_ALIGN_HC_VB, 0); snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_TOP_SPEED, NULL, 0) * 3.6)); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x6, y, GFUI_ALIGN_HC_VB, 0); snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_DAMMAGES, NULL, 0))); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x7, y, GFUI_ALIGN_HC_VB, 0); snprintf(buf, BUFSIZE, "%d", (int)(GfParmGetNum(results, path, RE_ATTR_NB_PIT_STOPS, NULL, 0))); GfuiLabelCreate(rmScrHdle, buf, GFUI_FONT_MEDIUM_C, x8, y, GFUI_ALIGN_HC_VB, 0); GfTime2Str(timefmt, TIMEFMTSIZE, GfParmGetNum(results, path, RE_ATTR_PENALTYTIME, NULL, 0), 0); GfuiLabelCreate(rmScrHdle, timefmt, GFUI_FONT_MEDIUM_C, x9, y, GFUI_ALIGN_HR_VB, 0); y -= 15; } if (start > 0) { RmPrevRace.prevHdle = prevHdle; RmPrevRace.info = info; RmPrevRace.start = start - MAX_LINES; GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-up.png", "data/img/arrow-up.png", "data/img/arrow-up.png", "data/img/arrow-up-pushed.png", 80, 40, GFUI_ALIGN_HL_VB, 1, (void*)&RmPrevRace, rmChgRaceScreen, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_UP, "Previous Results", (void*)&RmPrevRace, rmChgRaceScreen, NULL); } GfuiButtonCreate(rmScrHdle, "Continue", GFUI_FONT_LARGE, /* 210, */ 320, 40, 150, GFUI_ALIGN_HC_VB, 0, prevHdle, GfuiScreenReplace, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); if (i < nbCars) { RmNextRace.prevHdle = prevHdle; RmNextRace.info = info; RmNextRace.start = start + MAX_LINES; GfuiGrButtonCreate(rmScrHdle, "data/img/arrow-down.png", "data/img/arrow-down.png", "data/img/arrow-down.png", "data/img/arrow-down-pushed.png", 540, 40, GFUI_ALIGN_HL_VB, 1, (void*)&RmNextRace, rmChgRaceScreen, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_PAGE_DOWN, "Next Results", (void*)&RmNextRace, rmChgRaceScreen, NULL); } GfuiAddKey(rmScrHdle, (unsigned char)27, "", prevHdle, GfuiScreenReplace, NULL); GfuiAddKey(rmScrHdle, (unsigned char)13, "", prevHdle, GfuiScreenReplace, NULL); GfuiAddSKey(rmScrHdle, GLUT_KEY_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL); GfuiScreenActivate(rmScrHdle); }
void RmRaceParamMenu(void *vrp) { int y, x, x2, dy, dx; const int BUFSIZE = 1024; char buf[BUFSIZE]; rp = (tRmRaceParam*)vrp; snprintf(buf, BUFSIZE, "%s Options", rp->title); scrHandle = GfuiMenuScreenCreate(buf); GfuiScreenAddBgImg(scrHandle, "data/img/splash-raceopt.png"); x = 80; x2 = 240; y = 380; dx = 200; dy = GfuiFontHeight(GFUI_FONT_LARGE) + 5; if (rp->confMask & RM_CONF_RACE_LEN) { GfuiLabelCreate(scrHandle, "Race Distance (km):", GFUI_FONT_MEDIUM_C, x, y, GFUI_ALIGN_HL_VB, 0); rmrpDistance = (int)GfParmGetNum(rp->param, rp->title, RM_ATTR_DISTANCE, "km", 0); if (rmrpDistance == 0) { strcpy(buf, "---"); rmrpLaps = (int)GfParmGetNum(rp->param, rp->title, RM_ATTR_LAPS, NULL, 25); } else { snprintf(buf, BUFSIZE, "%d", rmrpDistance); rmrpLaps = 0; } rmrpDistId = GfuiEditboxCreate(scrHandle, buf, GFUI_FONT_MEDIUM_C, x + dx, y, 0, 8, NULL, (tfuiCallback)NULL, rmrpUpdDist); y -= dy; GfuiLabelCreate(scrHandle, "Laps:", GFUI_FONT_MEDIUM_C, x, y, GFUI_ALIGN_HL_VB, 0); if (rmrpLaps == 0) { strcpy(buf, "---"); } else { snprintf(buf, BUFSIZE, "%d", rmrpLaps); } rmrpLapsId = GfuiEditboxCreate(scrHandle, buf, GFUI_FONT_MEDIUM_C, x + dx, y, 0, 8, NULL, (tfuiCallback)NULL, rmrpUpdLaps); y -= dy; } if (rp->confMask & RM_CONF_DISP_MODE) { GfuiLabelCreate(scrHandle, "Display:", GFUI_FONT_MEDIUM_C, x, y, GFUI_ALIGN_HL_VB, 0); GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left-pushed.png", x2, y, GFUI_ALIGN_HL_VB, 1, (void*)0, rmChangeDisplayMode, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right-pushed.png", x2 + 150, y, GFUI_ALIGN_HL_VB, 1, (void*)1, rmChangeDisplayMode, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); if (!strcmp(GfParmGetStr(rp->param, rp->title, RM_ATTR_DISPMODE, RM_VAL_VISIBLE), RM_VAL_INVISIBLE)) { rmCurDispMode = 1; } else { rmCurDispMode = 0; } rmDispModeEditId = GfuiLabelCreate(scrHandle, rmCurDispModeList[rmCurDispMode], GFUI_FONT_MEDIUM_C, x2 + 35, y, GFUI_ALIGN_HL_VB, 20); y -= dy; } GfuiButtonCreate(scrHandle, "Accept", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, rmrpValidate, NULL, NULL, NULL); GfuiButtonCreate(scrHandle, "Cancel", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, rp->prevScreen, rmrpDeactivate, NULL, NULL, NULL); rmrpAddKeys(); GfuiScreenActivate(scrHandle); }
/** Interactive track selection @param vs Pointer on a tRmTrackSelect structure (cast to void *) @warning The race manager's parameters are updated but not saved. @ingroup racemantools */ void RmTrackSelect(void *vs) { const char *defaultTrack; const char *defaultCategory; tFList *CatCur; tFList *TrList, *TrCur; int Xpos, Ypos, DX, DY; int curTrkIdx; const int BUFSIZE = 1024; char buf[BUFSIZE]; char path[BUFSIZE]; ts = (tRmTrackSelect*)vs; /* Get the list of categories directories */ CategoryList = GfDirGetList("tracks"); if (CategoryList == NULL) { GfTrace("RmTrackSelect: No track category available\n"); return; } CatCur = CategoryList; do { CatCur->dispName = RmGetCategoryName(CatCur->name); if (strlen(CatCur->dispName) == 0) { GfTrace("RmTrackSelect: No definition for track category %s\n", CatCur->name); return; } /* get the tracks in the category directory */ snprintf(buf, BUFSIZE, "tracks/%s", CatCur->name); TrList = GfDirGetList(buf); if (TrList == NULL) { GfTrace("RmTrackSelect: No track for category %s available\n", CatCur->name); return; } TrList = TrList->next; /* get the first one */ CatCur->userData = (void*)TrList; TrCur = TrList; do { TrCur->dispName = RmGetTrackName(CatCur->name, TrCur->name); if (strlen(TrCur->dispName) == 0) { GfTrace("RmTrackSelect: No definition for track %s\n", TrCur->name); return; } TrCur = TrCur->next; } while (TrCur != TrList); CatCur = CatCur->next; } while (CatCur != CategoryList); curTrkIdx = (int)GfParmGetNum(ts->param, RM_SECT_TRACKS, RE_ATTR_CUR_TRACK, NULL, 1); snprintf(path, BUFSIZE, "%s/%d", RM_SECT_TRACKS, curTrkIdx); defaultCategory = GfParmGetStr(ts->param, path, RM_ATTR_CATEGORY, CategoryList->name); /* XXX coherency check */ defaultTrack = GfParmGetStr(ts->param, path, RM_ATTR_NAME, ((tFList*)CategoryList->userData)->name); CatCur = CategoryList; do { if (strcmp(CatCur->name, defaultCategory) == 0) { CategoryList = CatCur; TrCur = (tFList*)(CatCur->userData); do { if (strcmp(TrCur->name, defaultTrack) == 0) { CatCur->userData = (void*)TrCur; break; } TrCur = TrCur->next; } while (TrCur != TrList); break; } CatCur = CatCur->next; } while (CatCur != CategoryList); scrHandle = GfuiScreenCreateEx((float*)NULL, NULL, rmtsActivate, NULL, (tfuiCallback)NULL, 1); GfuiScreenAddBgImg(scrHandle, "data/img/splash-qrtrk.png"); rmtsAddKeys(); GfuiTitleCreate(scrHandle, "Select Track", 0); GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left-pushed.png", 80, 400, GFUI_ALIGN_HC_VB, 0, (void*)0, rmCatPrevNext, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); CatLabelId = GfuiLabelCreate(scrHandle, CategoryList->dispName, GFUI_FONT_LARGE_C, 320, 400, GFUI_ALIGN_HC_VB, 30); GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right-pushed.png", 540, 400, GFUI_ALIGN_HC_VB, 0, (void*)1, rmCatPrevNext, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiGrButtonCreate(scrHandle, "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left-pushed.png", 80, 370, GFUI_ALIGN_HC_VB, 0, (void*)0, rmtsPrevNext, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); TrackLabelId = GfuiLabelCreate(scrHandle, ((tFList*)CategoryList->userData)->dispName, GFUI_FONT_LARGE_C, 320, 370, GFUI_ALIGN_HC_VB, 30); GfuiGrButtonCreate(scrHandle, "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right-pushed.png", 540, 370, GFUI_ALIGN_HC_VB, 0, (void*)1, rmtsPrevNext, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); MapId = GfuiStaticImageCreate(scrHandle, 320, 100, 260, 195, rmGetMapName(buf, BUFSIZE)); GfuiButtonCreate(scrHandle, "Accept", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, NULL, rmtsSelect, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); GfuiButtonCreate(scrHandle, "Back", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP, ts->prevScreen, rmtsDeactivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); Xpos = 20; Ypos = 320; DX = 110; DY = 30; GfuiLabelCreate(scrHandle, "Description:", GFUI_FONT_MEDIUM, Xpos, Ypos, GFUI_ALIGN_HL_VB, 0); DescId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, Xpos + DX, Ypos, GFUI_ALIGN_HL_VB, 50); Ypos -= DY; GfuiLabelCreate(scrHandle, "Author:", GFUI_FONT_MEDIUM, Xpos, Ypos, GFUI_ALIGN_HL_VB, 0); AuthorId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, Xpos + DX, Ypos, GFUI_ALIGN_HL_VB, 20); Ypos -= DY; GfuiLabelCreate(scrHandle, "Length:", GFUI_FONT_MEDIUM, Xpos, Ypos, GFUI_ALIGN_HL_VB, 0); LengthId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, Xpos + DX, Ypos, GFUI_ALIGN_HL_VB, 20); Ypos -= DY; GfuiLabelCreate(scrHandle, "Width:", GFUI_FONT_MEDIUM, Xpos, Ypos, GFUI_ALIGN_HL_VB, 0); WidthId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, Xpos + DX, Ypos, GFUI_ALIGN_HL_VB, 20); Ypos -= DY; GfuiLabelCreate(scrHandle, "Pits:", GFUI_FONT_MEDIUM, Xpos, Ypos, GFUI_ALIGN_HL_VB, 0); PitsId = GfuiLabelCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, Xpos + DX, Ypos, GFUI_ALIGN_HL_VB, 20); rmUpdateTrackInfo(); GfuiScreenActivate(scrHandle); }