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); }
int GfuiMenuCreateEditControl(void* hscr, void* hparm, const char* pszName, void* userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost) { std::string strControlPath(GFMNU_SECT_DYNAMIC_CONTROLS"/"); strControlPath += pszName; const char* pszType = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_TYPE, ""); if (strcmp(pszType, GFMNU_TYPE_EDIT_BOX)) { GfLogError("Failed to create control '%s' : section not found or not an '%s' \n", pszName, GFMNU_TYPE_EDIT_BOX); return -1; } // TODO : Add real support for tips (the onFocus/onFocusLost system is already used // for user input management) // const char* pszTip = GfParmGetStr(hparm, pszName, GFMNU_ATTR_TIP, ""); // if (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); // // // TODO: In this case, we simply ignore onFocus/onFocusLost ! // userDataOnFocus = (void*)cbinfo; // onFocus = onFocusShowTip; // onFocusLost = onFocusLostHideTip; // } const char* pszText = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_TEXT, ""); const int x = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_X, NULL, 0.0); const int y = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_Y, NULL, 0.0); const char* pszFontName = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_FONT, ""); const int font = gfuiMenuGetFontId(pszFontName); const int width = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_WIDTH, NULL, 0.0); const int maxlen = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_MAX_LEN, NULL, 0.0); const char* pszAlignH = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_H_ALIGN, ""); const int align = gfuiMenuGetAlignment(pszAlignH); const GfuiColor c = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_COLOR); const GfuiColor fc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_COLOR_FOCUSED); const GfuiColor dc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_COLOR_DISABLED); const GfuiColor bc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_BG_COLOR); const GfuiColor bfc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_BG_COLOR_FOCUSED); const GfuiColor bdc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_BG_COLOR_DISABLED); int id = GfuiEditboxCreate(hscr, pszText, font, x, y, width, maxlen, align, userDataOnFocus, onFocus, onFocusLost); GfuiEditboxSetColors(hscr, id, c, fc, dc); GfuiEditboxSetBGColors(hscr, id, bc, bfc, bdc); return id; }
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); }
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; }