Exemple #1
0
        public static List <Entry> ParseEntryList(RawServerRaceData rawServerData)
        {
            List <Entry> drivers = new List <Entry>();

            foreach (RawServerCar car in rawServerData.Cars)
            {
                Entry curDriver = new Entry();

                curDriver.Name = car.Driver.Name;
                curDriver.Team = car.Driver.Team;
                curDriver.GUID = car.Driver.Guid;

                curDriver.CarModel      = car.Model;
                curDriver.CarSkin       = car.Skin;
                curDriver.Ballast       = car.BallastKG.ToString();
                curDriver.HadBallastTag = true;

                drivers.Add(curDriver);
            }

            for (int i = 0; i < rawServerData.Result.Count; i++)
            {
                RawServerResult res = rawServerData.Result[i];
                drivers[res.CarId].LapTime      = TimeSpan.FromMilliseconds(res.BestLap);
                drivers[res.CarId].RacePosition = i + 1;
            }

            return(drivers);
        }
Exemple #2
0
        private void btnOpenEntryList_Click(object sender, RoutedEventArgs e)
        {
            if (m_ofdEntryList.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            try
            {
                List <Entry> newEntries;

                if (m_ofdEntryList.FileName.EndsWith(".ini"))
                {
                    newEntries = Entry.ParseEntryList(File.ReadAllLines(m_ofdEntryList.FileName));
                }
                else
                {
                    RawServerRaceData rawServerData = JsonConvert.DeserializeObject <RawServerRaceData>(File.ReadAllText(m_ofdEntryList.FileName));

                    newEntries = Entry.ParseEntryList(rawServerData);
                }


                cbReverseList.SelectedIndex = -1;
                cbReverseList.Items.Clear();

                m_entryList.AddEntries(newEntries);
            } catch (Exception ex)
            {
                MessageBox.Show($"The following error ocurred while attempting to load the entry list:\n\n{ex.ToString()}", "Error Loading Entry List", MessageBoxButtons.OK);
            } finally
            {
                if (m_entryList.Entries.Count > 0)
                {
                    for (int i = 1; i <= m_entryList.Entries.Count; i++)
                    {
                        cbReverseList.Items.Add(i);
                    }

                    cbReverseList.SelectedIndex = 9;
                }
                else
                {
                    cbReverseList.SelectedIndex = -1;
                }
            }
        }