Beispiel #1
0
            public webtimingDriver(Sessions.SessionInfo.StandingsItem driver, Sessions.SessionInfo session)
            {
                position = driver.Position.ToString();
                name = driver.Driver.Name;
                number = driver.Driver.NumberPlate;
                lap = driver.CurrentLap.LapNum.ToString();
                fastestlap = iRTVO.Overlay.floatTime2String(driver.FastestLap, 3, false);
                previouslap = iRTVO.Overlay.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;

                Sessions.SessionInfo.StandingsItem leader = SharedData.Sessions.CurrentSession.FindPosition(1, dataorder.position);
                Sessions.SessionInfo.StandingsItem infront;

                if(driver.Position <= 1) {
                    infront = new Sessions.SessionInfo.StandingsItem();
                }
                else {
                    infront = SharedData.Sessions.CurrentSession.FindPosition(driver.Position - 1, dataorder.position);
                }

                if (SharedData.Sessions.CurrentSession.Type == Sessions.SessionInfo.sessionType.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 = iRTVO.Overlay.floatTime2String((driver.PreviousLap.Gap - infront.FindLap(driver.PreviousLap.LapNum).Gap), 3, false);
                    }

                    if (driver.PreviousLap.GapLaps > 0)
                    {
                        gap = driver.PreviousLap.GapLaps +" L";
                    }
                    else
                    {
                        gap = iRTVO.Overlay.floatTime2String(driver.PreviousLap.Gap, 3, false);
                    }
                }
                else
                {
                    interval = iRTVO.Overlay.floatTime2String((driver.FastestLap - infront.FastestLap), 3, false);
                    gap = iRTVO.Overlay.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)
                            {
                                iRTVO.LapInfo.Sector sector = driver.PreviousLap.SectorTimes.Find(s => s.Num.Equals(i));
                                if(sector != null)
                                {
                                    sectors[i] = iRTVO.Overlay.floatTime2String(sector.Time, 1, false);
                                }
                                else
                                {
                                    sectors[i] = "-.--";
                                }
                            }
                            else
                            {
                                sectors[i] = "-.--";
                            }
                        }
                        else
                        {
                            if (i < driver.CurrentLap.SectorTimes.Count)
                            {
                                iRTVO.LapInfo.Sector sector = driver.CurrentLap.SectorTimes.Find(s => s.Num.Equals(i));
                                if(sector != null)
                                {
                                    sectors[i] = iRTVO.Overlay.floatTime2String(sector.Time, 1, false);
                                }
                                else
                                {
                                    sectors[i] = "-.--";
                                }
                            }
                            else
                            {
                                sectors[i] = "-.--";
                            }
                        }
                    }
                }

                if (SharedData.Sessions.CurrentSession.Type == Sessions.SessionInfo.sessionType.race &&
                    driver.TrackSurface == Sessions.SessionInfo.StandingsItem.SurfaceType.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 = iRTVO.Overlay.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 = iRTVO.Overlay.floatTime2String(driver.PreviousLap.Gap, 3, false);
                    }
                }
                else
                {
                    retired = false;
                }
            }
Beispiel #2
0
        // *-name *-info
        public string[] getFollowedFormats(Sessions.SessionInfo.StandingsItem standing, Sessions.SessionInfo session, Int32 rounding)
        {
            Double laptime = SharedData.currentSessionTime - standing.Begin;

            string[] output = new string[68] {
                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(),
                iRTVO.Overlay.floatTime2String(standing.FastestLap, rounding, false),
                iRTVO.Overlay.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
                iRTVO.Overlay.floatTime2String(standing.PitStopTime, rounding, false),
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "", // 40
                "",
                "",
                "",
                "",
                "",
                standing.ClassLapsLed.ToString(),
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                standing.PositionLive.ToString(),
                ordinate(standing.PositionLive),
                "",
                "",
                standing.Driver.iRating.ToString(),
                ""
            };

            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] = iRTVO.Overlay.floatTime2String(standing.PreviousLap.LapTime, rounding, false);
            }
            //else if (standing.OnTrack == false)
            else if (standing.TrackSurface == Sessions.SessionInfo.StandingsItem.SurfaceType.NotInWorld)
            {
                output[10] = iRTVO.Overlay.floatTime2String(standing.FastestLap, rounding, false);
            }
            else {
                output[10] = iRTVO.Overlay.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 == Sessions.SessionInfo.StandingsItem.SurfaceType.NotInWorld &&
                SharedData.allowRetire &&
                (SharedData.Sessions.CurrentSession.Time - standing.OffTrackSince) > 1)
            {
                output[18] = translation["out"];
            }
            else
            {
                if (standing.Position == 1)
                {
                    if (session.Type == Sessions.SessionInfo.sessionType.race)
                        output[18] = "";//iRTVO.Overlay.floatTime2String((float)standing.CurrentLap.SessionTime, rounding, true); //translation["leader"];
                    else
                        output[18] = iRTVO.Overlay.floatTime2String(standing.FastestLap, rounding, false);
                }
                else if (standing.PreviousLap.GapLaps > 0 && session.Type == Sessions.SessionInfo.sessionType.race)
                {
                    /*
                    if (session.State == Sessions.SessionInfo.sessionState.cooldown ||
                        (session.State == Sessions.SessionInfo.sessionState.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 == Sessions.SessionInfo.sessionType.race)
                    {
                        /*
                        if (session.State == Sessions.SessionInfo.sessionState.cooldown ||
                        (session.State == Sessions.SessionInfo.sessionState.checkered && standing.CurrentTrackPct > session.LapsComplete))
                        {
                            output[18] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.FindLap(session.LapsComplete).Gap), rounding, false);
                        }
                        else
                        {
                            output[18] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.PreviousLap.Gap), rounding, false);
                        }
                         * */
                        output[18] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.PreviousLap.Gap), rounding, false);
                    }
                    else if (standing.FastestLap <= 1)
                        output[18] = translation["invalid"];
                    else
                        output[18] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.FastestLap - session.FastestLap), rounding, false);
                }
            }

            // interval
            if (standing.Position > 1) // not leader
            {
                Sessions.SessionInfo.StandingsItem infront = new Sessions.SessionInfo.StandingsItem();
                infront = session.FindPosition(standing.Position - 1, dataorder.position);

                if (session.Type == Sessions.SessionInfo.sessionType.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"] + iRTVO.Overlay.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"] + iRTVO.Overlay.floatTime2String((standing.FastestLap - infront.FastestLap), rounding, false);
                    }
                }

                output[22] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.PreviousLap.Gap - infront.PreviousLap.Gap), rounding, false);
            }
            else // leader
            {

                if (session.Type == Sessions.SessionInfo.sessionType.race)
                {
                    output[21] = ""; //iRTVO.Overlay.floatTime2String((float)standing.CurrentLap.SessionTime, rounding, true); //translation["leader"];
                    output[22] = output[21];
                }
                else // qualify and practice
                {
                    output[21] = iRTVO.Overlay.floatTime2String(standing.FastestLap, rounding, false);
                    output[22] = output[21];
                }
            }

            if (session.Type == Sessions.SessionInfo.sessionType.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)
                        {
                            LapInfo.Sector sector = standing.PreviousLap.SectorTimes.Find(s => s.Num.Equals(i));
                            if(sector != null)
                            {

                                output[27 + i] = iRTVO.Overlay.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)
                        {
                            LapInfo.Sector sector = standing.CurrentLap.SectorTimes.Find(s => s.Num.Equals(i));
                            if(sector != null)
                            {
                                output[27 + i] = iRTVO.Overlay.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
            Sessions.SessionInfo qualifySession = SharedData.Sessions.findSessionType(Sessions.SessionInfo.sessionType.qualify);
            if (qualifySession.Type != Sessions.SessionInfo.sessionType.invalid)
            {
                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] = iRTVO.Overlay.floatTime2String(standing.PitStopTime, rounding, false);
            else
            {
                output[31] = iRTVO.Overlay.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);
            Sessions.SessionInfo.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 != Sessions.SessionInfo.sessionType.invalid)
            {
                IEnumerable<Sessions.SessionInfo.StandingsItem> query = qualifySession.Standings.Where(s => s.Driver.CarClassName == standing.Driver.CarClassName).OrderBy(s => s.Position);
                Int32 position = 1;
                Int32 qualifyPos = 0;
                foreach (Sessions.SessionInfo.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 == Sessions.SessionInfo.StandingsItem.SurfaceType.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 == Sessions.SessionInfo.sessionType.race)
                        output[42] = ""; //iRTVO.Overlay.floatTime2String((float)standing.CurrentLap.SessionTime, rounding, true); //translation["leader"];
                    else
                        output[42] = iRTVO.Overlay.floatTime2String(standing.FastestLap, rounding, false);
                }
                else if (gaplaps > 0 && session.Type == Sessions.SessionInfo.sessionType.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 == Sessions.SessionInfo.sessionType.race)
                    {
                        if (session.State == Sessions.SessionInfo.sessionState.cooldown ||
                        (session.State == Sessions.SessionInfo.sessionState.checkered && standing.CurrentTrackPct > session.LapsComplete))
                        {
                            output[42] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.FindLap(session.LapsComplete).Gap), rounding, false);
                        }
                        else
                        {
                            output[42] = translation["behind"] + iRTVO.Overlay.floatTime2String(gap, rounding, false);
                        }
                    }
                    else if (standing.FastestLap <= 1)
                        output[42] = translation["invalid"];
                    else
                        output[42] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.FastestLap - classLeader.FastestLap), rounding, false);

                }
            }

            // interval
            if (standing.PreviousLap.Position > 1)
            {
                Sessions.SessionInfo.StandingsItem infront = new Sessions.SessionInfo.StandingsItem();
                infront = session.FindPosition(standing.Position - 1, dataorder.position, standing.Driver.CarClassName);

                if (session.Type == Sessions.SessionInfo.sessionType.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"] + iRTVO.Overlay.floatTime2String((standing.PreviousLap.Gap - infront.PreviousLap.Gap), rounding, false);
                    }
                }
                else
                {
                    if (standing.FastestLap <= 1)
                    {
                        output[44] = translation["invalid"];
                    }
                    else
                    {
                        output[44] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.FastestLap - infront.FastestLap), rounding, false);
                    }
                }

                output[44] = translation["behind"] + iRTVO.Overlay.floatTime2String((standing.PreviousLap.Gap - infront.PreviousLap.Gap), rounding, false);
            }
            else
            {

                if (session.Type == Sessions.SessionInfo.sessionType.race)
                {
                    output[44] = ""; // iRTVO.Overlay.floatTime2String((float)standing.CurrentLap.SessionTime, rounding, true); //translation["leader"];
                }
                else
                {
                    output[44] = iRTVO.Overlay.floatTime2String(standing.FastestLap, rounding, false);
                }
            }

            if (session.Type == Sessions.SessionInfo.sessionType.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;
        }