// *-name *-info public string[] getFollowedFormats(StandingsItem standing, SessionInfo session, Int32 rounding) { Double laptime = SharedData.currentSessionTime - standing.Begin; string[] output = new string[71] { standing.Driver.Name, standing.Driver.Shortname, standing.Driver.Initials, standing.Driver.SR, standing.Driver.Club, getCar(standing.Driver.CarId), getCarClass(standing.Driver.CarId), //driver.carclass.ToString(), (standing.Driver.NumberPlate).ToString(), Utils.floatTime2String(standing.FastestLap, rounding, false), Utils.floatTime2String(standing.PreviousLap.LapTime, rounding, false), "", // currentlap (live) // 10 standing.CurrentLap.LapNum.ToString(), "", // fastlap speed mph "", // prev lap speed mph "", // fastlap speed kph "", // prev lap speed kph standing.Position.ToString(), ordinate(standing.Position), // ordinal "", standing.LapsLed.ToString(), standing.Driver.UserId.ToString(), //20 "", "", "", "", (standing.Speed * 3.6).ToString("0"), (standing.Speed * 2.237).ToString("0"), "", "", "", standing.PitStops.ToString(), //30 Utils.floatTime2String(standing.PitStopTime, rounding, false), "", "", "", "", "", "", "", "", "", // 40 "", "", "", "", "", standing.ClassLapsLed.ToString(), "", "", "", "", // 50 "", "", "", "", "", "", "", "", "", "", // 60 "", standing.PositionLive.ToString(), ordinate(standing.PositionLive), "", "", standing.Driver.iRating.ToString(), "", standing.TrackSurface == SurfaceTypes.InPitStall ? "1" : "0", standing.Driver.TeamId.ToString(), // KJ: new text property teamid standing.Driver.TeamName, // 70 // KJ: new text property teamname }; if (standing.FastestLap < 5) output[8] = translation["invalid"]; if (standing.PreviousLap.LapTime < 5) output[9] = translation["invalid"]; if (laptime/60 > 60) output[10] = translation["invalid"]; else if (((SharedData.currentSessionTime - standing.Begin) < 5)) { if (standing.PreviousLap.LapTime < 5) output[10] = translation["invalid"]; else output[10] =Utils.floatTime2String(standing.PreviousLap.LapTime, rounding, false); } //else if (standing.OnTrack == false) else if (standing.TrackSurface == SurfaceTypes.NotInWorld) { output[10] =Utils.floatTime2String(standing.FastestLap, rounding, false); } else { output[10] =Utils.floatTime2String((float)(SharedData.currentSessionTime - standing.Begin), rounding, false); } if (standing.FastestLap > 0) { output[12] = ((3600 * SharedData.Track.Length / (1609.344 * standing.FastestLap))).ToString("0.00"); output[14] = (3.6 * SharedData.Track.Length / standing.FastestLap).ToString("0.00"); } else { output[12] = "-"; output[14] = "-"; } if (standing.PreviousLap.LapTime > 0) { output[13] = ((3600 * SharedData.Track.Length / (1609.344 * standing.PreviousLap.LapTime))).ToString("0.00"); output[15] = (3.6 * SharedData.Track.Length / standing.PreviousLap.LapTime).ToString("0.00"); } else { output[13] = "-"; output[15] = "-"; } /*if ((DateTime.Now - standing.OffTrackSince).TotalMilliseconds > 1000 && standing.OnTrack == false && SharedData.allowRetire)*/ if (standing.TrackSurface == SurfaceTypes.NotInWorld && SharedData.allowRetire && (SharedData.Sessions.CurrentSession.Time - standing.OffTrackSince) > 1) { output[18] = translation["out"]; } else { if (standing.Position == 1) { if (session.Type == SessionTypes.race) output[18] = "";//iRTVO.Overlay.floatTime2String((float)standing.CurrentLap.SessionTime, rounding, true); //translation["leader"]; else output[18] =Utils.floatTime2String(standing.FastestLap, rounding, false); } else if (standing.PreviousLap.GapLaps > 0 && session.Type == SessionTypes.race) { /* if (session.State == SessionStates.cooldown || (session.State == SessionStates.checkered && standing.CurrentTrackPct > session.LapsComplete)) { output[18] = translation["behind"] + standing.FindLap(session.LapsComplete).GapLaps + " "; if (standing.FindLap(session.LapsComplete).GapLaps > 1) output[18] += translation["laps"]; else output[18] += translation["lap"]; } else { */ output[18] = translation["behind"] + standing.PreviousLap.GapLaps + " "; if (standing.PreviousLap.GapLaps > 1) output[18] += translation["laps"]; else output[18] += translation["lap"]; //} } else/* if (SharedData.standing[SharedData.overlaySession].Length > 0 && SharedData.standing[SharedData.overlaySession][0].fastLap > 0)*/ { if (session.Type == SessionTypes.race) { /* if (session.State == SessionStates.cooldown || (session.State == SessionStates.checkered && standing.CurrentTrackPct > session.LapsComplete)) { output[18] = translation["behind"] +Utils.floatTime2String((standing.FindLap(session.LapsComplete).Gap), rounding, false); } else { output[18] = translation["behind"] +Utils.floatTime2String((standing.PreviousLap.Gap), rounding, false); } * */ output[18] = translation["behind"] +Utils.floatTime2String((standing.PreviousLap.Gap), rounding, false); } else if (standing.FastestLap <= 1) output[18] = translation["invalid"]; else output[18] = translation["behind"] +Utils.floatTime2String((standing.FastestLap - session.FastestLap), rounding, false); } } // interval if (standing.Position > 1) // not leader { StandingsItem infront = new StandingsItem(); infront = session.FindPosition(standing.Position - 1, DataOrders.position); if (session.Type == SessionTypes.race) { if ((infront.CurrentTrackPct - standing.CurrentTrackPct) > 1) { output[21] = translation["behind"] + standing.PreviousLap.GapLaps + " "; if (standing.PreviousLap.GapLaps > 1) output[21] += translation["laps"]; else output[21] += translation["lap"]; } else { output[21] = translation["behind"] +Utils.floatTime2String((standing.PreviousLap.Gap - infront.PreviousLap.Gap), rounding, false); } } else // qualify and practice { if (standing.FastestLap <= 1) { output[21] = translation["invalid"]; } else { output[21] = translation["behind"] +Utils.floatTime2String((standing.FastestLap - infront.FastestLap), rounding, false); } } output[22] = translation["behind"] +Utils.floatTime2String((standing.PreviousLap.Gap - infront.PreviousLap.Gap), rounding, false); } else // leader { if (session.Type == SessionTypes.race) { output[21] = ""; //iRTVO.Overlay.floatTime2String((float)standing.CurrentLap.SessionTime, rounding, true); //translation["leader"]; output[22] = output[21]; } else // qualify and practice { output[21] =Utils.floatTime2String(standing.FastestLap, rounding, false); output[22] = output[21]; } } if (session.Type == SessionTypes.race) { output[23] = translation["behind"] + standing.GapLive_HR(rounding); output[24] = translation["behind"] + standing.IntervalLive_HR(rounding); } else { output[23] = output[18]; output[24] = output[22]; } // sectors if (SharedData.SelectedSectors.Count > 0) { for(int i = 0; i <= 2; i++) { if (standing.Sector <= 0) // first sector, show previous lap times { if (i < standing.PreviousLap.SectorTimes.Count) { Sector sector = standing.PreviousLap.SectorTimes.Find(s => s.Num.Equals(i)); if(sector != null) { output[27 + i] =Utils.floatTime2String(sector.Time, rounding, false); output[32 + i] = (sector.Speed * 3.6).ToString("0.0"); output[35 + i] = (sector.Speed * 2.237).ToString("0.0"); } else { output[27 + i] = ""; output[32 + i] = ""; output[35 + i] = ""; } } else { output[27 + i] = ""; output[32 + i] = ""; output[35 + i] = ""; } } else { if (i < standing.CurrentLap.SectorTimes.Count) { Sector sector = standing.CurrentLap.SectorTimes.Find(s => s.Num.Equals(i)); if(sector != null) { output[27 + i] =Utils.floatTime2String(sector.Time, rounding, false); output[32 + i] = (sector.Speed * 3.6).ToString("0.0"); output[35 + i] = (sector.Speed * 2.237).ToString("0.0"); } else { output[27 + i] = ""; output[32 + i] = ""; output[35 + i] = ""; } } else { output[27 + i] = ""; output[32 + i] = ""; output[35 + i] = ""; } } } } // position gain SessionInfo qualifySession = SharedData.Sessions.findSessionByType(SessionTypes.qualify); if (qualifySession.Type != SessionTypes.none) { int qualifyPos = qualifySession.FindDriver(standing.Driver.CarIdx).Position; if((qualifyPos - standing.Position) > 0) output[38] = "+" + (qualifyPos - standing.Position).ToString(); else output[38] = (qualifyPos - standing.Position).ToString(); output[47] = qualifyPos.ToString(); output[50] = ordinate(qualifyPos); Int32 classqpos = qualifySession.getClassPosition(standing.Driver); output[48] = classqpos.ToString(); output[49] = ordinate(classqpos); } // highest/lowest position output[51] = standing.HighestPosition.ToString(); output[52] = ordinate(standing.HighestPosition); output[53] = standing.LowestPosition.ToString(); output[54] = ordinate(standing.LowestPosition); output[55] = standing.HighestClassPosition.ToString(); output[56] = ordinate(standing.HighestClassPosition); output[57] = standing.LowestClassPosition.ToString(); output[58] = ordinate(standing.LowestClassPosition); /* // pititemr if ((DateTime.Now - standing.PitStopBegin).TotalSeconds > 1) output[31] =Utils.floatTime2String(standing.PitStopTime, rounding, false); else { output[31] =Utils.floatTime2String((float)(DateTime.Now - standing.PitStopBegin).TotalSeconds, rounding, false); } */ // multiclass /* {"classposition", 39}, {"classposition_ord", 40}, {"classpositiongain", 41}, {"classgap", 42}, {"classlivegap", 43}, {"classinterval", 44}, {"classliveinterval", 45}, */ int classpos = session.getClassPosition(standing.Driver); StandingsItem classLeader = session.getClassLeader(standing.Driver.CarClassName); output[39] = classpos.ToString(); output[40] = ordinate(classpos); output[43] = standing.ClassGapLive_HR; output[45] = standing.ClassIntervalLive_HR; if (qualifySession.Type != SessionTypes.none) { IEnumerable<StandingsItem> query = qualifySession.Standings.Where(s => s.Driver.CarClassName == standing.Driver.CarClassName).OrderBy(s => s.Position); Int32 position = 1; Int32 qualifyPos = 0; foreach (StandingsItem si in query) { if (si.Driver.CarIdx == standing.Driver.CarIdx) { qualifyPos = position; break; } else position++; } if ((qualifyPos - classpos) > 0) output[41] = "+" + (qualifyPos - classpos).ToString(); else output[41] = (qualifyPos - classpos).ToString(); } if (standing.TrackSurface == SurfaceTypes.NotInWorld && SharedData.allowRetire && (SharedData.Sessions.CurrentSession.Time - standing.OffTrackSince) > 1) { output[42] = translation["out"]; } else { float gap = classLeader.PreviousLap.Gap - standing.PreviousLap.Gap; int gaplaps = classLeader.PreviousLap.LapNum - standing.PreviousLap.LapNum; if (classpos == 1) { if (session.Type == SessionTypes.race) output[42] = ""; //iRTVO.Overlay.floatTime2String((float)standing.CurrentLap.SessionTime, rounding, true); //translation["leader"]; else output[42] =Utils.floatTime2String(standing.FastestLap, rounding, false); } else if (gaplaps > 0 && session.Type == SessionTypes.race) { output[42] = translation["behind"] + gaplaps + " "; if (gaplaps > 1) output[42] += translation["laps"]; else output[42] += translation["lap"]; //} } else/* if (SharedData.standing[SharedData.overlaySession].Length > 0 && SharedData.standing[SharedData.overlaySession][0].fastLap > 0)*/ { if (session.Type == SessionTypes.race) { if (session.State == SessionStates.cooldown || (session.State == SessionStates.checkered && standing.CurrentTrackPct > session.LapsComplete)) { output[42] = translation["behind"] +Utils.floatTime2String((standing.FindLap(session.LapsComplete).Gap), rounding, false); } else { output[42] = translation["behind"] +Utils.floatTime2String(gap, rounding, false); } } else if (standing.FastestLap <= 1) output[42] = translation["invalid"]; else output[42] = translation["behind"] +Utils.floatTime2String((standing.FastestLap - classLeader.FastestLap), rounding, false); } } // interval if (standing.PreviousLap.Position > 1) { StandingsItem infront = new StandingsItem(); infront = session.FindPosition(standing.Position - 1, DataOrders.position, standing.Driver.CarClassName); if (session.Type == SessionTypes.race) { if ((infront.CurrentTrackPct - standing.CurrentTrackPct) > 1) { output[44] = translation["behind"] + standing.PreviousLap.GapLaps + " "; if (standing.PreviousLap.GapLaps > 1) output[44] += translation["laps"]; else output[44] += translation["lap"]; } else { output[44] = translation["behind"] +Utils.floatTime2String((standing.PreviousLap.Gap - infront.PreviousLap.Gap), rounding, false); } } else { if (standing.FastestLap <= 1) { output[44] = translation["invalid"]; } else { output[44] = translation["behind"] +Utils.floatTime2String((standing.FastestLap - infront.FastestLap), rounding, false); } } output[44] = translation["behind"] +Utils.floatTime2String((standing.PreviousLap.Gap - infront.PreviousLap.Gap), rounding, false); } else { if (session.Type == SessionTypes.race) { output[44] = ""; //Utils.floatTime2String((float)standing.CurrentLap.SessionTime, rounding, true); //translation["leader"]; } else { output[44] =Utils.floatTime2String(standing.FastestLap, rounding, false); } } if (session.Type == SessionTypes.race) { output[23] = translation["behind"] + standing.GapLive_HR(rounding); output[24] = translation["behind"] + standing.IntervalLive_HR(rounding); } else { output[23] = output[18]; output[24] = output[22]; } // points if (SharedData.externalCurrentPoints.ContainsKey(standing.Driver.UserId)) { output[59] = SharedData.externalCurrentPoints[standing.Driver.UserId].ToString(); int pos = 0; foreach (KeyValuePair<int, int> item in SharedData.externalCurrentPoints.OrderByDescending(key => key.Value)) { pos++; if (item.Key == standing.Driver.UserId) { output[60] = pos.ToString(); output[61] = ordinate(pos); break; } } } else { output[59] = "0"; output[60] = SharedData.externalCurrentPoints.Count().ToString(); output[61] = ordinate(SharedData.externalCurrentPoints.Count()); } int classlivepos = session.getClassLivePosition(standing.Driver); output[64] = classlivepos.ToString(); output[65] = ordinate(classlivepos); // interval followed if(standing.DistanceToFollowed < 0) output[67] = translation["behind"] + Theme.round(standing.IntervalToFollowedLive, rounding); else output[67] = translation["ahead"] + Theme.round(standing.IntervalToFollowedLive, rounding); string[] extrenal; if (SharedData.externalData.ContainsKey(standing.Driver.UserId)) { extrenal = SharedData.externalData[standing.Driver.UserId]; } else extrenal = new string[0]; string[] merged = new string[output.Length + extrenal.Length]; Array.Copy(output, 0, merged, 0, output.Length); Array.Copy(extrenal, 0, merged, output.Length, extrenal.Length); return merged; }
public webtimingDriver(StandingsItem driver, SessionInfo session) { position = driver.PositionLive.ToString(); name = driver.Driver.Name; // KJ: for multi-car/multi-class races and pitting status car = ""; pitting = false; // KJ: set name for team events if ( driver.Driver.TeamId > 0 ) { name = driver.Driver.TeamName + " (" + driver.Driver.Shortname + ")"; } number = driver.Driver.NumberPlate; car = SharedData.theme.getCar(driver.Driver.CarId); // KJ: set car lap = driver.CurrentLap.LapNum.ToString(); fastestlap =Utils.floatTime2String(driver.FastestLap, 3, false); previouslap =Utils.floatTime2String(driver.PreviousLap.LapTime, 3, false); pit = driver.PitStops.ToString(); lapsled = driver.LapsLed.ToString(); sectors = new string[0]; classid = driver.Driver.CarClass.ToString(); classname = driver.Driver.CarClassName; classposition = session.getClassPosition(driver.Driver).ToString(); classgap = driver.ClassGapLive_HR; classinterval = driver.ClassIntervalLive_HR; StandingsItem leader = SharedData.Sessions.CurrentSession.FindPosition(1, DataOrders.liveposition); StandingsItem infront; if(driver.PositionLive <= 1) { infront = new StandingsItem(); } else { infront = SharedData.Sessions.CurrentSession.FindPosition(driver.Position - 1, DataOrders.liveposition); } if (SharedData.Sessions.CurrentSession.Type == SessionTypes.race /* && (driver.Finished == true || driver.Sector == 0) */) { if (infront.PreviousLap.GapLaps > driver.PreviousLap.GapLaps) { interval = (infront.FindLap(driver.PreviousLap.LapNum).LapNum - driver.PreviousLap.LapNum) + " L"; } else { interval =Utils.floatTime2String((driver.PreviousLap.Gap - infront.FindLap(driver.PreviousLap.LapNum).Gap), 3, false); } if (driver.PreviousLap.GapLaps > 0) { gap = driver.PreviousLap.GapLaps +" L"; } else { gap =Utils.floatTime2String(driver.PreviousLap.Gap, 3, false); } } else { interval =Utils.floatTime2String((driver.FastestLap - infront.FastestLap), 3, false); gap =Utils.floatTime2String((driver.FastestLap - leader.FastestLap), 3, false); } if (SharedData.SelectedSectors.Count > 0) { sectors = new string[SharedData.SelectedSectors.Count]; for (int i = 0; i < SharedData.SelectedSectors.Count; i++) { if (driver.Sector <= 0) // first sector, show previous lap times { if (i < driver.PreviousLap.SectorTimes.Count) { Sector sector = driver.PreviousLap.SectorTimes.Find(s => s.Num.Equals(i)); if(sector != null) { sectors[i] =Utils.floatTime2String(sector.Time, 1, false); } else { sectors[i] = "-.--"; } } else { sectors[i] = "-.--"; } } else { if (i < driver.CurrentLap.SectorTimes.Count) { Sector sector = driver.CurrentLap.SectorTimes.Find(s => s.Num.Equals(i)); if(sector != null) { sectors[i] =Utils.floatTime2String(sector.Time, 1, false); } else { sectors[i] = "-.--"; } } else { sectors[i] = "-.--"; } } } } if (SharedData.Sessions.CurrentSession.Type == SessionTypes.race && driver.TrackSurface == SurfaceTypes.NotInWorld && SharedData.allowRetire && (SharedData.Sessions.CurrentSession.Time - driver.OffTrackSince) > 1) { retired = true; if (infront.CurrentLap.LapNum > driver.CurrentLap.LapNum) { interval = (infront.CurrentLap.LapNum - driver.CurrentLap.LapNum) + " L"; } else { interval =Utils.floatTime2String((driver.PreviousLap.Gap - infront.PreviousLap.Gap), 3, false); } if ((leader.CurrentLap.LapNum - driver.CurrentLap.LapNum) > 0) { gap = leader.CurrentLap.LapNum - driver.CurrentLap.LapNum + " L"; } else { gap =Utils.floatTime2String(driver.PreviousLap.Gap, 3, false); } } else { retired = false; } // KJ: set pitting status if (driver.TrackSurface == SurfaceTypes.InPitStall) { pitting = true; } else { pitting = false; } }