Beispiel #1
0
 private static void Load(string fileName)
 {
     if (File.Exists(fileName))
     {
         try
         {
             var newLap = new CompletedLap(fileName);
             if (newLap.lap == null || newLap.lap.lapTime == 0)
             {
                 // Ignored invalid lap
             }
             else
             {
                 Laps.Add(
                     new LapInfo()
                 {
                     CarNumber   = newLap.playerInfo.raceNumber.ToString(),
                     CircuitName = Constants.TrackList.First(t => t.id == newLap.circuitInfo.trackId).name,
                     FileName    = newLap.FileName(),
                     LapTime     = newLap.lap.lapTime,
                     PlayerName  = PacketHelper.GetString(newLap.playerInfo.name, 48),
                     SessionType = Constants.SessionTypeList.First(t => t.id == newLap.circuitInfo.sessionType).name,
                     TeamName    = Constants.TeamList.First(t => t.id == newLap.playerInfo.teamId)?.name,
                     Tyre        = "?", // Packet type Car Status not handled yet
                     Details     = newLap
                 });
             }
         }
         catch // (Exception e)
         {
             //lama
             // MessageDialog.Show(e);
         }
     }
 }
Beispiel #2
0
 public static void Add(CompletedLap completedLap)
 {
     if (Laps.FirstOrDefault(l => l.FileName == completedLap.Pathname()) == null)
     {
         // New Lap. Save to disk
         Directory.CreateDirectory(BS(baseDir) + completedLap.Dirname());
         if (!File.Exists(BS(baseDir) + completedLap.Pathname()))
         {
             completedLap.Save(baseDir);
             Laps.Add(
                 new LapInfo()
             {
                 CarNumber   = completedLap.playerInfo.raceNumber.ToString(),
                 CircuitName = Constants.TrackList.First(t => t.id == completedLap.circuitInfo.trackId)?.name,
                 FileName    = completedLap.FileName(),
                 LapTime     = completedLap.lap.lapTime,
                 PlayerName  = PacketHelper.GetString(completedLap.playerInfo.name, 48),
                 SessionType = Constants.SessionTypeList.First(t => t.id == completedLap.circuitInfo.sessionType)?.name,
                 TeamName    = Constants.TeamList.First(t => t.id == completedLap.playerInfo.teamId)?.name,
                 Tyre        = "?", // Packet type Car Status not handled yet
                 Details     = completedLap
             });
             SaveDictionary();
         }
     }
 }