Ejemplo n.º 1
0
 internal void Save()
 {
     if (CircuitLayoutData != null && CircuitID != -1)
     {
         File.WriteAllText(LapDatabase.GetCircuitFileName(CircuitID), JsonSerializer.Serialize(CircuitLayoutData));
     }
 }
Ejemplo n.º 2
0
 public void LoadDetails()
 {
     try
     {
         Details = new CompletedLap(LapDatabase.GetFileName(this));
     }
     catch (Exception e)
     {
         Details   = null;
         LastError = e.Message;
     }
 }
Ejemplo n.º 3
0
        public void Update(PacketHeader context, PacketLapData data, AsyncUI callback)
        {
            if (circuit != null)
            {
                circuit.Update(data);

                for (int i = 0; i < participantsData.numActiveCars; i++)
                {
                    if (data.lapData[i].currentLapNum >= 0)
                    {
                        lock (playerInfo)
                        {
                            var playerData = GetPlayerByIndex(i);
                            currentLapNum[i] = data.lapData[i].currentLapNum;
                            if (playerData != null)
                            {
                                var lapInfo = playerData.AddLapData(context, data.lapData[i]);
                                if (lapInfo != null)
                                {
                                    circuit.AddLapInfo(lapInfo);
                                    callback.LogLine($"{playerData.CarNumber}:{playerData.Name} - lap {data.lapData[i].currentLapNum} : {lapInfo.lapTime.ToString()}");
                                    LapDatabase.Add(
                                        new CompletedLap()
                                    {
                                        circuitInfo = this.circuit.CircuitData,
                                        playerInfo  = participantsData.participants[i],
                                        lap         = lapInfo
                                    });
                                }
                            }
                        }
                    }
                    else
                    {
                        currentLapNum[i] = data.lapData[i].currentLapNum;
                    }
                }
                circuit.CheckMyApex(context.frameIdentifier, data.lapData[context.playerCarIndex]);
            }
            else
            {
                for (int i = 0; i < currentLapNum.Length; i++)
                {
                    currentLapNum[i] = -1;
                }
            }
        }
Ejemplo n.º 4
0
        public CircuitInfo(PacketSessionData data)
        {
            if (CircuitID != data.trackId)
            {
                Save();
                CircuitID = data.trackId;

                if (CircuitID != -1)
                {
                    if (File.Exists(LapDatabase.GetCircuitFileName(CircuitID)))
                    {
                        CircuitLayoutData = JsonSerializer.Deserialize<CircuitLayoutData>(File.ReadAllText(LapDatabase.GetCircuitFileName(CircuitID)));
                    }
                    else
                    {
                        CircuitLayoutData = new CircuitLayoutData();
                    }
                }
            }
            CircuitData = data;
        }
Ejemplo n.º 5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (ignoreClicks)
     {
         return;
     }
     using (new HourGlass())
     {
         ignoreClicks = true;
         lvSelected.BeginUpdate();
         lapList.BeginUpdate();
         try
         {
             foreach (ListViewItem item in lapList.CheckedItems)
             {
                 LapDatabase.RemoveLap(LapDatabase.Laps.FirstOrDefault(la =>
                                                                       la.CircuitName == item.SubItems[0].Text &&
                                                                       la.SessionType == item.SubItems[1].Text &&
                                                                       la.CarNumber == item.SubItems[2].Text &&
                                                                       la.PlayerName == item.SubItems[3].Text &&
                                                                       la.TeamName == item.SubItems[4].Text &&
                                                                       la.LapTime.ToString("0.000") == item.SubItems[5].Text));
                 lapList.Items.Remove(item);
             }
             while (lvSelected.Items.Count > 0)
             {
                 lvSelected.Items.RemoveAt(0);
             }
         }
         finally
         {
             Application.UseWaitCursor = false;
             lvSelected.EndUpdate();
             lapList.EndUpdate();
             ignoreClicks = false;
         }
     }
 }