static void EnableMenuClientButtons(bool bChecked) { // Disable/enable menu selections const int isEnabled = bChecked ? GFUI_DISABLE : GFUI_ENABLE; GfuiEnable(racemanMenuHdle, g_CarSetupButtonId, isEnabled); GfuiEnable(racemanMenuHdle, g_DisconnectButtonId, isEnabled); }
void * JoyCalMenuInit(void *prevMenu, void *nextMenu, tCmdInfo *cmd, int maxcmd) { int i; char pszBuf[64]; Cmd = cmd; MaxCmd = maxcmd; PrevMenuHandle = prevMenu; NextMenuHandle = nextMenu; if (ScrHandle) { return ScrHandle; } // Create screen, load menu XML descriptor and create static controls. ScrHandle = GfuiScreenCreate(NULL, NULL, onActivate, NULL, NULL, 1); void *menuXMLDescHdle = GfuiMenuLoad("joystickconfigmenu.xml"); GfuiMenuCreateStaticControls(ScrHandle, menuXMLDescHdle); // Create joystick axis label controls (axis name, axis Id, axis min value, axis max value) for (i = 0; i < NbMaxCalAxis; i++) { sprintf(pszBuf, "%saxislabel", LabName[i]); LabAxisId[i] = GfuiMenuCreateLabelControl(ScrHandle, menuXMLDescHdle, pszBuf); sprintf(pszBuf, "%sminlabel", LabName[i]); LabMinId[i] = GfuiMenuCreateLabelControl(ScrHandle, menuXMLDescHdle, pszBuf); sprintf(pszBuf, "%smaxlabel", LabName[i]); LabMaxId[i] = GfuiMenuCreateLabelControl(ScrHandle, menuXMLDescHdle, pszBuf); } // Create instruction variable label. InstId = GfuiMenuCreateLabelControl(ScrHandle, menuXMLDescHdle, "instructionlabel"); // Create Cancel and Reset buttons. GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "resetbutton", NULL, onActivate); if (nextMenu != NULL) { NextBut = GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "nextbutton", NULL, onNext); GfuiEnable(ScrHandle, NextBut, GFUI_DISABLE); } else { DoneBut = GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "donebutton", NULL, onNext); GfuiEnable(ScrHandle, DoneBut, GFUI_DISABLE); } CancelBut = GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "cancelbutton", NULL, onNext); // Close menu XML descriptor. GfParmReleaseHandle(menuXMLDescHdle); // Register keyboard shortcuts. GfuiMenuDefaultKeysAdd(ScrHandle); GfuiAddKey(ScrHandle, GFUIK_ESCAPE, "Next", NULL, onNext, NULL); GfuiAddKey(ScrHandle, GFUIK_RETURN, "Next", NULL, onNext, NULL); return ScrHandle; }
static void EnableMenuHostButtons(bool bChecked) { // Disable/enable menu selections const int isEnabled = bChecked ? GFUI_DISABLE : GFUI_ENABLE; GfuiEnable(racemanMenuHdle, g_CarSetupButtonId, isEnabled); //GfuiEnable(racemanMenuHdle, g_HostSettingsButtonId, isEnabled); GfuiEnable(racemanMenuHdle, g_CancelButtonId, isEnabled); GfuiEnable(racemanMenuHdle, g_RaceSetupId, isEnabled); }
static void MouseCalAutomaton(void) { float axv; switch (CalState) { case 0: case 1: GfctrlMouseGetCurrentState(&MouseInfo); axv = MouseInfo.ax[Cmd[CmdOffset + CalState].ref.index]; if (fabs(axv) < 0.01) { return; /* ignore no move input */ } Cmd[CmdOffset + CalState].max = axv; Cmd[CmdOffset + CalState].pow = 1.0 / axv; break; case 2: case 3: GfctrlMouseGetCurrentState(&MouseInfo); axv = MouseInfo.ax[Cmd[CmdOffset + CalState].ref.index]; if (fabs(axv) < 0.01) { return; /* ignore no move input */ } Cmd[CmdOffset + CalState].max = axv; Cmd[CmdOffset + CalState].pow = 1.0 / axv; break; } CalState++; CalState = GetNextAxis(); GfuiLabelSetText(ScrHandle, InstId, Instructions[CalState]); if (CalState < 4) { GfuiApp().eventLoop().setRecomputeCB(Idle2); } else { GfuiApp().eventLoop().setRecomputeCB(0); GfuiApp().eventLoop().postRedisplay(); } /* Change button appearance when done */ if (CalState == 4) { GfuiEnable(ScrHandle, CancelBut, GFUI_DISABLE); if (DoneBut) GfuiEnable(ScrHandle, DoneBut, GFUI_ENABLE); else GfuiEnable(ScrHandle, NextBut, GFUI_ENABLE); } }
void * Joy2butCalMenuInit(void *prevMenu, void *nextMenu, tCmdInfo *cmd, int maxcmd) { Cmd = cmd; MaxCmd = maxcmd; PrevMenuHandle = prevMenu; NextMenuHandle = nextMenu; if (ScrHandle) { return ScrHandle; } // Create screen, load menu XML descriptor and create static controls. ScrHandle = GfuiScreenCreate(NULL, NULL, onActivate, NULL, NULL, 1); void *menuXMLDescHdle = GfuiMenuLoad("joy2butconfigmenu.xml"); GfuiMenuCreateStaticControls(ScrHandle, menuXMLDescHdle); AtobAxisID = GfuiMenuCreateLabelControl(ScrHandle, menuXMLDescHdle, "AtobAxisID"); AtobCommandID = GfuiMenuCreateLabelControl(ScrHandle, menuXMLDescHdle, "AtobCommandID"); // Create instruction variable label. InstId = GfuiMenuCreateLabelControl(ScrHandle, menuXMLDescHdle, "instructionlabel"); // Create Cancel and Reset buttons. GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "resetbutton", NULL, onActivate); if (nextMenu != NULL) { NextBut = GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "nextbutton", NULL, onNext); GfuiEnable(ScrHandle, NextBut, GFUI_DISABLE); } else { DoneBut = GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "donebutton", NULL, onNext); GfuiEnable(ScrHandle, DoneBut, GFUI_DISABLE); } CancelBut = GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "cancelbutton", NULL, onNext); // Close menu XML descriptor. GfParmReleaseHandle(menuXMLDescHdle); // Register keyboard shortcuts. GfuiMenuDefaultKeysAdd(ScrHandle); GfuiAddKey(ScrHandle, GFUIK_ESCAPE, "Next", NULL, onNext, NULL); GfuiAddKey(ScrHandle, GFUIK_RETURN, "Next", NULL, onNext, NULL); return ScrHandle; }
static void onActivate(void * /* dummy */) { int i; int index; // Create and test joysticks ; only keep the up and running ones. for (index = 0; index < GFCTRL_JOY_NUMBER; index++) { Joystick[index] = new jsJoystick(index); if (Joystick[index]->notWorking()) { /* don't configure the joystick */ delete Joystick[index]; Joystick[index] = 0; } } CalState = 0; AtobAxis = GFCTRL_JOY_NUMBER * GFCTRL_JOY_MAX_AXES;; /* Find commands which are ATOB */ for (i = 0; i <= CMD_END_OF_LIST; i++) { if (Cmd[i].ref.type == GFCTRL_TYPE_JOY_ATOB) { if (AtobAxis > Cmd[i].ref.index) AtobAxis = Cmd[i].ref.index; } } for (AtobCount = 0; AtobCount <= CMD_END_OF_LIST; AtobCount++) { if (Cmd[AtobCount].ref.index == AtobAxis) break; } /* Set label titles */ GfuiLabelSetText(ScrHandle, AtobAxisID, GfctrlGetNameByRef(GFCTRL_TYPE_JOY_ATOB, AtobAxis)); GfuiLabelSetText(ScrHandle, AtobCommandID, "---"); GfuiLabelSetText(ScrHandle, InstId, Instructions[CalState]); GfuiApp().eventLoop().setRecomputeCB(Idle2); GfuiApp().eventLoop().postRedisplay(); for (index = 0; index < GFCTRL_JOY_NUMBER; index++) { if (Joystick[index]) { Joystick[index]->read(&JoyButtons[index], &JoyAxis[index * GFCTRL_JOY_MAX_AXES]); /* initial value */ } } GfuiEnable(ScrHandle, CancelBut, GFUI_ENABLE); if (DoneBut) GfuiEnable(ScrHandle, DoneBut, GFUI_DISABLE); else GfuiEnable(ScrHandle, NextBut, GFUI_DISABLE); }
static void onActivate(void * /* dummy */) { int i; int index; int step; // Create and test joysticks ; only keep the up and running ones. for (index = 0; index < GFCTRL_JOY_NUMBER; index++) { Joystick[index] = new jsJoystick(index); if (Joystick[index]->notWorking()) { /* don't configure the joystick */ delete Joystick[index]; Joystick[index] = 0; } } CalState = 0; GfuiLabelSetText(ScrHandle, InstId, Instructions[CalState]); GfuiApp().eventLoop().setRecomputeCB(Idle2); GfuiApp().eventLoop().postRedisplay(); for (index = 0; index < GFCTRL_JOY_NUMBER; index++) { if (Joystick[index]) { Joystick[index]->read(&JoyButtons[index], &JoyAxis[index * GFCTRL_JOY_MAX_AXES]); /* initial value */ } } for (i = 0; i < NbMaxCalAxis; i++) { if (i > 0) { step = i + 2; } else { step = i + 1; } if (Cmd[step + CmdOffset].ref.type == GFCTRL_TYPE_JOY_AXIS) { GfuiLabelSetText(ScrHandle, LabAxisId[i], GfctrlGetNameByRef(GFCTRL_TYPE_JOY_AXIS, Cmd[step + CmdOffset].ref.index)); } else { GfuiLabelSetText(ScrHandle, LabAxisId[i], "---"); } GfuiLabelSetText(ScrHandle, LabMinId[i], ""); GfuiLabelSetText(ScrHandle, LabMaxId[i], ""); } GfuiEnable(ScrHandle, CancelBut, GFUI_ENABLE); if (DoneBut) GfuiEnable(ScrHandle, DoneBut, GFUI_DISABLE); else GfuiEnable(ScrHandle, NextBut, GFUI_DISABLE); }
static void onActivate(void * /* dummy */) { CalState = 0; GetNextAxis(); GfuiLabelSetText(ScrHandle, InstId, Instructions[CalState]); if (CalState < 4) { GfuiApp().eventLoop().setRecomputeCB(IdleMouseInit); GfctrlMouseCenter(); } GfuiEnable(ScrHandle, CancelBut, GFUI_ENABLE); if (DoneBut) GfuiEnable(ScrHandle, DoneBut, GFUI_DISABLE); else GfuiEnable(ScrHandle, NextBut, GFUI_DISABLE); }
/* Select next/previous track category */ static void rmtsTrackCatPrevNext(void *vsel) { const int nSearchDir = (long)vsel > 0 ? +1 : -1; // Select first usable track in the next catergory in the requested direction. PCurTrack = GfTracks::self()->getFirstUsableTrack(PCurTrack->getCategoryId(), nSearchDir, true); // Update GUI rmtsUpdateTrackInfo(); // Disable track combo-box arrows if only one track available in this category. if (PCurTrack) { const int nEnableTrkChange = GfTracks::self()->getTracksInCategory(PCurTrack->getCategoryId()).size() > 1 ? GFUI_ENABLE : GFUI_DISABLE; GfuiEnable(ScrHandle, PrevTrackArrowId, nEnableTrkChange); GfuiEnable(ScrHandle, NextTrackArrowId, nEnableTrkChange); } }
static void rmtsActivate(void * /* dummy */) { GfLogTrace("Entering Track Select menu\n"); // Disable track category combo-box arrows if only one category available // (Note: "Available" does not mean "usable", but this should be enough for releases // where everything installed is supposed to be usable). if (GfTracks::self()->getCategoryIds().size() <= 1) { GfuiEnable(ScrHandle, PrevCategoryArrowId, GFUI_DISABLE); GfuiEnable(ScrHandle, NextCategoryArrowId, GFUI_DISABLE); } // Disable track combo-box arrows if only one track available in the current category. if (GfTracks::self()->getTracksInCategory(PCurTrack->getCategoryId()).size() <= 1) { GfuiEnable(ScrHandle, PrevTrackArrowId, GFUI_DISABLE); GfuiEnable(ScrHandle, NextTrackArrowId, GFUI_DISABLE); } // Update GUI (current track). rmtsUpdateTrackInfo(); }
/** * RmShowStandings * * Shows a results page, with optional prev/next results page buttons * * @param prevHdle handle for previous results page * @param info race results information * @param start page number */ void RmShowStandings(void *prevHdle, tRmInfo *info, int start) { int i; static char buf[256]; static char path[512]; void *results = info->results; GfLogTrace("Entering Standings menu\n"); // Create screen, load menu XML descriptor and create static controls. rmScrHdle = GfuiScreenCreate(); void *hmenu = GfuiMenuLoad("standingsmenu.xml"); GfuiMenuCreateStaticControls(rmScrHdle, hmenu); // Create variable title label (with group info for the Career mode). const int titleId = GfuiMenuCreateLabelControl(rmScrHdle, hmenu, "Title"); GfRaceManager* pRaceMan = LmRaceEngine().race()->getManager(); if (pRaceMan->hasSubFiles()) { const char* pszGroup = GfParmGetStr(info->params, RM_SECT_HEADER, RM_ATTR_NAME, "<no group>"); snprintf(buf, sizeof(buf), "%s - %s", info->_reName, pszGroup); } else snprintf(buf, sizeof(buf), "%s", info->_reName); GfuiLabelSetText(rmScrHdle, titleId, buf); // Create variable subtitle label. const char* pszSessionName; const char* pszTrackName; if (pRaceMan->hasSubFiles()) { // Career mode : Can't rely on GfRaceManager/GfRace, they don't support Career mode yet. pszSessionName = info->_reRaceName; const int curTrackIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_TRACK, NULL, 1) - 1; snprintf(path, sizeof(path), "%s/%d", RM_SECT_TRACKS, curTrackIdx); pszTrackName = GfParmGetStr(info->params, path, RM_ATTR_NAME, "<unkown track>"); } else { // Non-Career mode : The session is the _last_ one ; the track is the _previous_ one. const unsigned nCurrEventIndex = (unsigned)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_TRACK, NULL, 1); pszSessionName = pRaceMan->getSessionName(pRaceMan->getSessionCount() - 1).c_str(); pszTrackName = pRaceMan->getPreviousEventTrack(nCurrEventIndex - 1)->getName().c_str(); } snprintf(buf, sizeof(buf), "%s at %s", pszSessionName, pszTrackName); const int subTitleId = GfuiMenuCreateLabelControl(rmScrHdle, hmenu, "SubTitle"); GfuiLabelSetText(rmScrHdle, subTitleId, buf); // Get layout properties. const int nMaxLines = (int)GfuiMenuGetNumProperty(hmenu, "nMaxResultLines", 15); const int yTopLine = (int)GfuiMenuGetNumProperty(hmenu, "yTopLine", 400); const int yLineShift = (int)GfuiMenuGetNumProperty(hmenu, "yLineShift", 20); // List results line by line, paginated int y = yTopLine; const int nbCars = (int)GfParmGetEltNb(results, RE_SECT_STANDINGS); for (i = start; i < MIN(start + nMaxLines, nbCars); i++) { snprintf(path, sizeof(path), "%s/%d", RE_SECT_STANDINGS, i + 1); //Rank snprintf(buf, sizeof(buf), "%d", i+1); GfuiMenuCreateLabelControl(rmScrHdle, hmenu, "Rank", true, // From template. buf, GFUI_TPL_X, y); //Driver short name GfuiMenuCreateLabelControl(rmScrHdle, hmenu, "DriverName", true, // From template. GfParmGetStr(results, path, RE_ATTR_SNAME, ""), GFUI_TPL_X, y); //Driver type const std::string strModName = GfParmGetStr(results, path, RE_ATTR_MODULE, ""); GfuiMenuCreateLabelControl(rmScrHdle, hmenu, "DriverType", true, // From template. GfDriver::getType(strModName).c_str(), GFUI_TPL_X, y); //Car GfuiMenuCreateLabelControl(rmScrHdle, hmenu, "CarModel", true, // From template. GfParmGetStr(results, path, RE_ATTR_CAR, ""), GFUI_TPL_X, y); //Points snprintf(buf, sizeof(buf), "%d", (int)GfParmGetNum(results, path, RE_ATTR_POINTS, NULL, 0)); GfuiMenuCreateLabelControl(rmScrHdle, hmenu, "Points", true, // From template. buf, GFUI_TPL_X, y); // Next line. y -= yLineShift; //Next line }//for i // If not on first page, show 'previous results' button on the bottom left if (start > 0) { RmPrevRace.prevHdle = prevHdle; RmPrevRace.info = info; RmPrevRace.start = start - nMaxLines; GfuiMenuCreateButtonControl(rmScrHdle, hmenu, "PreviousPageArrow", (void*)&RmPrevRace, rmChgStandingScreen); GfuiAddKey(rmScrHdle, GFUIK_PAGEUP, "Previous Results", (void*)&RmPrevRace, rmChgStandingScreen, NULL); }//if start // Add "Continue" button in the bottom left GfuiMenuCreateButtonControl(rmScrHdle, hmenu, "ContinueButton", prevHdle, GfuiScreenReplace); // Add "save" button in the bottom right, but disable it when Career mode. rmSaveButtonId = GfuiMenuCreateButtonControl(rmScrHdle, hmenu, "SaveButton", info, rmSaveRes); if (LmRaceEngine().race()->getManager()->hasSubFiles()) GfuiEnable(rmScrHdle, rmSaveButtonId, GFUI_DISABLE); // If there is a next page, show 'next results' button on the bottom extreme right if (i < nbCars) { RmNextRace.prevHdle = prevHdle; RmNextRace.info = info; RmNextRace.start = start + nMaxLines; GfuiMenuCreateButtonControl(rmScrHdle, hmenu, "NextPageArrow", (void*)&RmNextRace, rmChgStandingScreen); GfuiAddKey(rmScrHdle, GFUIK_PAGEDOWN, "Next Results", (void*)&RmNextRace, rmChgStandingScreen, NULL); }//if i GfuiAddKey(rmScrHdle, GFUIK_ESCAPE, "Continue", prevHdle, GfuiScreenReplace, NULL); GfuiAddKey(rmScrHdle, GFUIK_RETURN, "Continue", prevHdle, GfuiScreenReplace, NULL); GfuiAddKey(rmScrHdle, GFUIK_F1, "Help", rmScrHdle, GfuiHelpScreen, NULL); GfuiAddKey(rmScrHdle, GFUIK_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL); GfuiScreenActivate(rmScrHdle); }//RmShowStandings
static void JoyCalAutomaton(void) { linked_item_t * item_in_list; linked_item_t * new_in_list; float last_max; switch (CalState) { case 0: /* Grab snapshot of 'NULL' position */ memcpy(JoyAxisCenter, JoyAxis, sizeof(JoyAxisCenter)); advanceStep(); break; case 1: /* Start linked list with Null Position */ AtobList = (linked_item_t*)malloc(sizeof(linked_item_t)); AtobList->next = NULL; AtobList->command = -1; AtobList->value = JoyAxisCenter[AtobAxis]; CalState = 2; /* fall through */ case 2: /* Insert each ATOB into list */ item_in_list = AtobList; new_in_list = (linked_item_t*)malloc(sizeof(linked_item_t)); new_in_list->command = AtobCount; new_in_list->value = JoyAxis[AtobAxis]; if (new_in_list->value < item_in_list->value) { /* insert first position*/ new_in_list->next = item_in_list; AtobList = new_in_list; } else { /* walk list */ while (item_in_list->next != NULL) { if (new_in_list->value < item_in_list->next->value) { /* insert after current */ new_in_list->next = item_in_list->next; item_in_list->next = new_in_list; break; } /* step to next item */ item_in_list = item_in_list->next; } if (item_in_list->next == NULL) { /* insert at end */ new_in_list->next = NULL; item_in_list->next = new_in_list; } } advanceStep(); if (CalState == 3) { /* Walk list to compute min/max thresholds */ last_max=-1.0; while (AtobList != NULL) { item_in_list = AtobList; if (item_in_list->command != -1) Cmd[item_in_list->command].min = last_max; /* Split difference between current and next */ if (item_in_list->next != NULL) last_max = (item_in_list->value + item_in_list->next->value)/2; else last_max = 1.0; if (item_in_list->command != -1) Cmd[item_in_list->command].max = last_max; AtobList = item_in_list->next; free(item_in_list); } advanceStep(); } break; } GfuiLabelSetText(ScrHandle, InstId, Instructions[CalState]); /* Change button appearance when done */ if (CalState == 3) { GfuiEnable(ScrHandle, CancelBut, GFUI_DISABLE); if (DoneBut) GfuiEnable(ScrHandle, DoneBut, GFUI_ENABLE); else GfuiEnable(ScrHandle, NextBut, GFUI_ENABLE); } }
// Host on-line race menu. void RmNetworkHostMenu(void * /* dummy */) { GfLogTrace("Entering Network Host menu.\n"); if (!NetGetNetwork()) { NetSetServer(true); NetSetClient(false); if (!NetGetServer()->Start(SPEEDDREAMSPORT)) { NetSetServer(false); return; } } if (racemanMenuHdle) GfuiScreenRelease(racemanMenuHdle); racemanMenuHdle = GfuiScreenCreate(NULL, NULL, (tfuiCallback)OnActivateNetworkHost, NULL, (tfuiCallback)NULL, 1); void *mparam = GfuiMenuLoad("networkhostmenu.xml"); GfuiMenuCreateStaticControls(racemanMenuHdle, mparam); RmSetRacemanMenuHandle(racemanMenuHdle); NetworkRaceInfo(); g_trackHd = GfuiMenuCreateLabelControl(racemanMenuHdle,mparam,"trackname"); g_lapsHd = GfuiMenuCreateLabelControl(racemanMenuHdle,mparam,"lapcountname"); g_catHd = GfuiMenuCreateLabelControl(racemanMenuHdle,mparam,"carcatname"); g_OutlineId = GfuiMenuCreateStaticImageControl(racemanMenuHdle,mparam,"outlineimage"); //Show players for (int i = 0; i < MAXNETWORKPLAYERS; i++) { char buf[1024]; sprintf(buf,"ready%i",i); g_readystatus[i] = GfuiMenuCreateStaticImageControl(racemanMenuHdle,mparam,buf); GfuiVisibilitySet(racemanMenuHdle,g_readystatus[i],false); sprintf(buf,"driver%i",i); g_playerNames[i] = GfuiMenuCreateLabelControl(racemanMenuHdle,mparam,buf); GfuiLabelSetText(racemanMenuHdle,g_playerNames[i],""); sprintf(buf,"car%i",i); g_carNames[i] = GfuiMenuCreateLabelControl(racemanMenuHdle,mparam,buf); GfuiLabelSetText(racemanMenuHdle,g_carNames[i],""); } g_ReadyCheckboxId = GfuiMenuCreateCheckboxControl(racemanMenuHdle, mparam, "playerreadycheckbox", NULL, onHostPlayerReady); g_HostSettingsButtonId = GfuiMenuCreateButtonControl(racemanMenuHdle, mparam, "networkhostsettings", racemanMenuHdle, rmNetworkHostSettingsMenu); GfuiEnable(racemanMenuHdle, g_HostSettingsButtonId, GFUI_DISABLE); g_RaceSetupId = GfuiMenuCreateButtonControl(racemanMenuHdle, mparam, "racesetup", racemanMenuHdle, RmConfigureRace); GfuiMenuCreateButtonControl(racemanMenuHdle, mparam, "start race", NULL, ServerPrepareStartNetworkRace); g_CancelButtonId = GfuiMenuCreateButtonControl(racemanMenuHdle, mparam, "cancel", NULL, rmNetworkServerDisconnect); GfParmReleaseHandle(mparam); GfuiMenuDefaultKeysAdd(racemanMenuHdle); GfuiAddKey(racemanMenuHdle, GFUIK_ESCAPE, "Back to previous menu", 0, 0, rmNetworkServerDisconnect); UpdateNetworkPlayers(); GfuiScreenActivate(racemanMenuHdle); }
static void Idle2(void) { int index; #if SDL_JOYSTICK /* Check for activity on Joystick buttons */ GfctrlJoyGetCurrentStates(&joyInfo); for (index = 0; index < GFCTRL_JOY_NUMBER * GFCTRL_JOY_MAX_BUTTONS; index++) { if (joyInfo.edgedn[index]) { /* Check whether to ignore */ if(Cmd[CalState + CmdOffset].butIgnore == index) break; /* Button fired */ JoyCalAutomaton(); if (CalState >= NbCalSteps) { GfuiApp().eventLoop().setRecomputeCB(0); } GfuiApp().eventLoop().postRedisplay(); return; } #else int mask; int b, i; for (index = 0; index < GFCTRL_JOY_NUMBER; index++) { if (Joystick[index]) { Joystick[index]->read(&b, &JoyAxis[index * GFCTRL_JOY_MAX_AXES]); /* Joystick buttons */ for (i = 0, mask = 1; i < 32; i++, mask *= 2) { if (((b & mask) != 0) && ((JoyButtons[index] & mask) == 0)) { /* Check whether to ignore */ if(Cmd[CalState + CmdOffset].butIgnore == i + 32 * index) break; /* Button fired */ JoyCalAutomaton(); if (CalState >= NbCalSteps) { GfuiApp().eventLoop().setRecomputeCB(0); } GfuiApp().eventLoop().postRedisplay(); JoyButtons[index] = b; return; } } JoyButtons[index] = b; } #endif } /* Let CPU take breath (and fans stay at low and quite speed) */ GfSleep(0.001); } static void onActivate(void * /* dummy */) { int i; int step; #if SDL_JOYSTICK //joyInfo = GfctrlJoyCreate(); GfctrlJoyGetCurrentStates(&joyInfo); #else int index; // Create and test joysticks ; only keep the up and running ones. for (index = 0; index < GFCTRL_JOY_NUMBER; index++) { Joystick[index] = new jsJoystick(index); if (Joystick[index]->notWorking()) { /* don't configure the joystick */ delete Joystick[index]; Joystick[index] = 0; } } #endif CalState = 0; GfuiLabelSetText(ScrHandle, InstId, Instructions[CalState]); GfuiApp().eventLoop().setRecomputeCB(Idle2); GfuiApp().eventLoop().postRedisplay(); #ifndef SDL_JOYSTICK for (index = 0; index < GFCTRL_JOY_NUMBER; index++) { if (Joystick[index]) { Joystick[index]->read(&JoyButtons[index], &JoyAxis[index * GFCTRL_JOY_MAX_AXES]); /* initial value */ } } #endif for (i = 0; i < NbMaxCalAxis; i++) { if (i > 0) { step = i + 2; } else { step = i + 1; } if (Cmd[step + CmdOffset].ref.type == GFCTRL_TYPE_JOY_AXIS) { GfuiLabelSetText(ScrHandle, LabAxisId[i], GfctrlGetNameByRef(GFCTRL_TYPE_JOY_AXIS, Cmd[step + CmdOffset].ref.index)); } else { GfuiLabelSetText(ScrHandle, LabAxisId[i], "---"); } GfuiLabelSetText(ScrHandle, LabMinId[i], ""); GfuiLabelSetText(ScrHandle, LabMaxId[i], ""); } GfuiEnable(ScrHandle, CancelBut, GFUI_ENABLE); if (DoneBut) GfuiEnable(ScrHandle, DoneBut, GFUI_DISABLE); else GfuiEnable(ScrHandle, NextBut, GFUI_DISABLE); }
static void JoyCalAutomaton(void) { static char buf[64]; int axis; switch (CalState) { case 0: #if SDL_JOYSTICK memcpy(&joyCenter, &joyInfo, sizeof(joyCenter)); #else memcpy(JoyAxisCenter, JoyAxis, sizeof(JoyAxisCenter)); #endif advanceStep(); break; case 1: axis = Cmd[CalState + CmdOffset].ref.index; #if SDL_JOYSTICK Cmd[CalState + CmdOffset].min = joyCenter.ax[axis]; Cmd[CalState + CmdOffset].max = joyInfo.ax[axis]; #else Cmd[CalState + CmdOffset].min = JoyAxisCenter[axis]; Cmd[CalState + CmdOffset].max = JoyAxis[axis]; #endif // record the polarity of the turn action if (Cmd[CalState + CmdOffset].max >= Cmd[CalState + CmdOffset].min) Cmd[CalState + CmdOffset].pow = 1.0; else Cmd[CalState + CmdOffset].pow = -1.0; #if SDL_JOYSTICK sprintf(buf, "%.2f", joyInfo.ax[axis]); #else sprintf(buf, "%.2f", JoyAxis[axis]); #endif GfuiLabelSetText(ScrHandle, LabMinId[0], buf); advanceStep(); break; case 2: axis = Cmd[CalState + CmdOffset].ref.index; #if SDL_JOYSTICK Cmd[CalState + CmdOffset].min = joyCenter.ax[axis]; Cmd[CalState + CmdOffset].max = joyInfo.ax[axis]; #else Cmd[CalState + CmdOffset].min = JoyAxisCenter[axis]; Cmd[CalState + CmdOffset].max = JoyAxis[axis]; #endif // record the polarity of the turn action if (Cmd[CalState + CmdOffset].max >= Cmd[CalState + CmdOffset].min) Cmd[CalState + CmdOffset].pow = 1.0; else Cmd[CalState + CmdOffset].pow = -1.0; #if SDL_JOYSTICK sprintf(buf, "%.2f", joyInfo.ax[axis]); #else sprintf(buf, "%.2f", JoyAxis[axis]); #endif GfuiLabelSetText(ScrHandle, LabMaxId[0], buf); advanceStep(); break; case 3: case 4: case 5: axis = Cmd[CalState + CmdOffset].ref.index; #if SDL_JOYSTICK Cmd[CalState + CmdOffset].min = joyCenter.ax[axis]; Cmd[CalState + CmdOffset].max = joyInfo.ax[axis]; #else Cmd[CalState + CmdOffset].min = JoyAxisCenter[axis]; Cmd[CalState + CmdOffset].max = JoyAxis[axis]; #endif Cmd[CalState + CmdOffset].pow = 1.0; #if SDL_JOYSTICK sprintf(buf, "%.2f", joyCenter.ax[axis]); #else sprintf(buf, "%.2f", JoyAxisCenter[axis]); #endif GfuiLabelSetText(ScrHandle, LabMinId[CalState - 2], buf); #if SDL_JOYSTICK sprintf(buf, "%.2f", joyInfo.ax[axis]); #else sprintf(buf, "%.2f", JoyAxis[axis]); #endif GfuiLabelSetText(ScrHandle, LabMaxId[CalState - 2], buf); advanceStep(); break; } GfuiLabelSetText(ScrHandle, InstId, Instructions[CalState]); /* Change button appearance when done */ if (CalState == NbCalSteps) { GfuiEnable(ScrHandle, CancelBut, GFUI_DISABLE); if (DoneBut) GfuiEnable(ScrHandle, DoneBut, GFUI_ENABLE); else GfuiEnable(ScrHandle, NextBut, GFUI_ENABLE); } }
static void onActivate(void * /* dummy */) { int i; char valuebuf[10]; // Initialize current state and GUI from the GL features layer. // 1) Texture compression. if (GfglFeatures::self().isSupported(GfglFeatures::TextureCompression)) { const char *pszTexComp = GfglFeatures::self().isSelected(GfglFeatures::TextureCompression) ? GFSCR_ATT_TEXTURECOMPRESSION_ENABLED : GFSCR_ATT_TEXTURECOMPRESSION_DISABLED; for (i = 0; i < NTextureComps; i++) { if (!strcmp(pszTexComp, ATextureCompTexts[i])) { NCurTextureCompIndex = i; break; } } GfuiLabelSetText(ScrHandle, TextureCompLabelId, ATextureCompTexts[NCurTextureCompIndex]); } else { GfuiEnable(ScrHandle, TextureCompLeftButtonId, GFUI_DISABLE); GfuiEnable(ScrHandle, TextureCompRightButtonId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, TextureCompLabelId, "Not supported"); } // 2) Max texture size. int sizelimit = GfglFeatures::self().getSupported(GfglFeatures::TextureMaxSize); int tsize = GfglFeatures::self().getSelected(GfglFeatures::TextureMaxSize); int maxsizenb = 0; for (i = 0; i < NMaxTextureSizes; i++) { if (AMaxTextureSizeTexts[i] <= sizelimit) { maxsizenb = i; } else { break; } } // Limit to available sizes. NMaxTextureSizes = maxsizenb + 1; bool found = false; for (i = 0; i < NMaxTextureSizes; i++) { if (AMaxTextureSizeTexts[i] == tsize) { NCurMaxTextureSizeIndex = i; found = true; break; } } if (!found) { // Should never come here if there is no bug in OpenGL. tsize = NDefaultTextureSize; for (i = 0; i < NMaxTextureSizes; i++) { if (AMaxTextureSizeTexts[i] == tsize) { NCurMaxTextureSizeIndex = i; break; } } } snprintf(valuebuf, sizeof(valuebuf), "%d", AMaxTextureSizeTexts[NCurMaxTextureSizeIndex]); GfuiLabelSetText(ScrHandle, MaxTextureSizeLabelId, valuebuf); // 3) Multi-texturing. if (GfglFeatures::self().isSupported(GfglFeatures::MultiTexturing)) { const char *pszMultiTex = GfglFeatures::self().isSelected(GfglFeatures::MultiTexturing) ? GFSCR_ATT_MULTITEXTURING_ENABLED : GFSCR_ATT_MULTITEXTURING_DISABLED; for (i = 0; i < NMultiTextures; i++) { if (!strcmp(pszMultiTex, AMultiTextureTexts[i])) { NCurMultiTextureIndex = i; break; } } GfuiLabelSetText(ScrHandle, MultiTextureLabelId, AMultiTextureTexts[NCurMultiTextureIndex]); } else { GfuiEnable(ScrHandle, MultiTextureLeftButtonId, GFUI_DISABLE); GfuiEnable(ScrHandle, MultiTextureRightButtonId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, MultiTextureLabelId, "Not supported"); } // 4) Multi-sampling (anti-aliasing). if (GfglFeatures::self().isSupported(GfglFeatures::MultiSampling)) { BMultiSamplingWasSelected = GfglFeatures::self().isSelected(GfglFeatures::MultiSampling); BPrevMultiSamplingSamples = GfglFeatures::self().getSelected(GfglFeatures::MultiSamplingSamples); if (!BMultiSamplingWasSelected) NCurMultiSampleIndex = 0; else { NCurMultiSampleIndex = 0; int nSamples = 1; while (nSamples < BPrevMultiSamplingSamples) { NCurMultiSampleIndex++; nSamples *= 2; } } GfuiLabelSetText(ScrHandle, MultiSampleLabelId, VecMultiSampleTexts[NCurMultiSampleIndex].c_str()); } else { GfuiEnable(ScrHandle, MultiSampleLeftButtonId, GFUI_DISABLE); GfuiEnable(ScrHandle, MultiSampleRightButtonId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, MultiSampleLabelId, "Not supported"); } // Initialize current state and GUI from the GL features layer. // 6) Bump Mapping. if (GfglFeatures::self().isSupported(GfglFeatures::BumpMapping)) { const char *pszBumpMapping = GfglFeatures::self().isSelected(GfglFeatures::BumpMapping) ? GFSCR_ATT_BUMPMAPPING_ENABLED : GFSCR_ATT_BUMPMAPPING_DISABLED; for (i = 0; i < NBumpMapping; i++) { if (!strcmp(pszBumpMapping, ABumpMappingTexts[i])) { NCurBumpMappingIndex = i; break; } } GfuiLabelSetText(ScrHandle, BumpMappingLabelId, ABumpMappingTexts[NCurBumpMappingIndex]); } else { GfuiEnable(ScrHandle, BumpMappingLeftButtonId, GFUI_DISABLE); GfuiEnable(ScrHandle, BumpMappingRightButtonId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, BumpMappingLabelId, "Not supported"); } // Initialize current state and GUI from the GL features layer. // 7) Anisotropic Filtering. int ani_sup= GfglFeatures::self().getSupported(GfglFeatures::AnisotropicFiltering); if (ani_sup!=GfglFeatures::InvalidInt) { NCurAnisotropicFilteringIndex = GfglFeatures::self().getSelected(GfglFeatures::AnisotropicFiltering); GfuiLabelSetText(ScrHandle, AnisotropicFilteringLabelId, AAnisotropicFilteringTexts[NCurAnisotropicFilteringIndex]); } else { GfuiEnable(ScrHandle, AnisotropicFilteringLeftButtonId, GFUI_DISABLE); GfuiEnable(ScrHandle, AnisotropicFilteringRightButtonId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, AnisotropicFilteringLabelId, "Not supported"); } }
/* Load screen editable fields with relevant values : - all empty if no player selected, - from selected player current settings otherwise */ static void refreshEditVal(void) { int autoRevVisible = GFUI_INVISIBLE; if (CurrPlayer == PlayersInfo.end()) { GfuiEditboxSetString(ScrHandle, NameEditId, ""); GfuiEnable(ScrHandle, NameEditId, GFUI_DISABLE); GfuiEditboxSetString(ScrHandle, RaceNumEditId, ""); GfuiEnable(ScrHandle, RaceNumEditId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, GearChangeEditId, ""); GfuiEnable(ScrHandle, GearChangeEditId, GFUI_DISABLE); GfuiEditboxSetString(ScrHandle, PitsEditId, ""); GfuiEnable(ScrHandle, PitsEditId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, SkillEditId, ""); GfuiEnable(ScrHandle, SkillEditId, GFUI_DISABLE); GfuiLabelSetText(ScrHandle, AutoReverseEditId, ""); GfuiEnable(ScrHandle, AutoReverseEditId, GFUI_DISABLE); } else { if (strcmp((*CurrPlayer)->dispName(), NoPlayer)) { GfuiEditboxSetString(ScrHandle, NameEditId, (*CurrPlayer)->dispName()); } else { GfuiEditboxSetString(ScrHandle, NameEditId, PlayerNamePrompt); } GfuiEnable(ScrHandle, NameEditId, GFUI_ENABLE); snprintf(buf, sizeof(buf), "%d", (*CurrPlayer)->raceNumber()); GfuiEditboxSetString(ScrHandle, RaceNumEditId, buf); GfuiEnable(ScrHandle, RaceNumEditId, GFUI_ENABLE); GfuiLabelSetText(ScrHandle, GearChangeEditId, (*CurrPlayer)->gearChangeModeString()); GfuiEnable(ScrHandle, GearChangeEditId, GFUI_ENABLE); snprintf(buf, sizeof(buf), "%d", (*CurrPlayer)->nbPitStops()); GfuiEditboxSetString(ScrHandle, PitsEditId, buf); GfuiEnable(ScrHandle, PitsEditId, GFUI_ENABLE); GfuiLabelSetText(ScrHandle, SkillEditId, SkillLevelString[(*CurrPlayer)->skillLevel()]); GfuiEnable(ScrHandle, SkillEditId, GFUI_ENABLE); GfuiLabelSetText(ScrHandle, AutoReverseEditId, Yn[(*CurrPlayer)->autoReverse()]); GfuiEnable(ScrHandle, AutoReverseEditId, GFUI_ENABLE); if ((*CurrPlayer)->gearChangeMode() == GEAR_MODE_AUTO) autoRevVisible = GFUI_VISIBLE; } GfuiVisibilitySet(ScrHandle, AutoReverseLabelId, autoRevVisible); GfuiVisibilitySet(ScrHandle, AutoReverseLeftId, autoRevVisible); GfuiVisibilitySet(ScrHandle, AutoReverseEditId, autoRevVisible); GfuiVisibilitySet(ScrHandle, AutoReverseRightId, autoRevVisible); }