diff --git a/RaceOverlay/Data/Mapper.cs b/RaceOverlay/Data/Mapper.cs index 16bd390..f1c8b8f 100644 --- a/RaceOverlay/Data/Mapper.cs +++ b/RaceOverlay/Data/Mapper.cs @@ -170,6 +170,17 @@ public static iRacingData MapData(IRacingSdk irsdkSharper) // ignored } + // P2P (Indycar Only) + try + { + data.LocalCarTelemetry.P2PLeft = irsdkSharper.Data.GetFloat("P2P_Count"); + data.LocalCarTelemetry.P2POn = irsdkSharper.Data.GetBool("P2P_Status"); + } + catch (Exception e) + { + // ignored + } + // Lap Data data.LocalCarTelemetry.Lap = irsdkSharper.Data.GetInt("Lap"); diff --git a/RaceOverlay/Data/Models/LocalCarTelemetry.cs b/RaceOverlay/Data/Models/LocalCarTelemetry.cs index 06664e7..2ca119e 100644 --- a/RaceOverlay/Data/Models/LocalCarTelemetry.cs +++ b/RaceOverlay/Data/Models/LocalCarTelemetry.cs @@ -41,6 +41,10 @@ public LocalCarTelemetry() // Battery (GPT Only) public float EngeryLevelPct { get; set; } = 0; + // Indy car Series Only + public float P2PLeft { get; set; } = 0; // P2P = Push to Pass, only available in Indy car series + public bool P2POn { get; set; } = false; // P2P = Push to Pass, only available in Indy car series + // Lap data public int Lap { get; set; } diff --git a/RaceOverlay/MainWindow.xaml.cs b/RaceOverlay/MainWindow.xaml.cs index 6e6aeec..da99c33 100644 --- a/RaceOverlay/MainWindow.xaml.cs +++ b/RaceOverlay/MainWindow.xaml.cs @@ -15,6 +15,7 @@ using RaceOverlay.Overlays.FuelCalculator; using RaceOverlay.Overlays.LaptimeDelta; using RaceOverlay.Overlays.Leaderboard; +using RaceOverlay.Overlays.P2PInfo; using RaceOverlay.Overlays.PitstopInfo; using RaceOverlay.Overlays.Relative; using RaceOverlay.Overlays.WeatherInfo; @@ -70,6 +71,7 @@ private void _initOverlays() Overlays.Add(new Inputs()); Overlays.Add(new LaptimeDelta()); Overlays.Add(new Standings()); + Overlays.Add(new P2PInfo()); Overlays.Add(new PitstopInfo()); Overlays.Add(new Relative()); //Overlays.Add(new SessionInfo()); diff --git a/RaceOverlay/Overlays/P2PInfo/P2PInfo.xaml b/RaceOverlay/Overlays/P2PInfo/P2PInfo.xaml new file mode 100644 index 0000000..7c576cb --- /dev/null +++ b/RaceOverlay/Overlays/P2PInfo/P2PInfo.xaml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RaceOverlay/Overlays/P2PInfo/P2PInfo.xaml.cs b/RaceOverlay/Overlays/P2PInfo/P2PInfo.xaml.cs new file mode 100644 index 0000000..de97b25 --- /dev/null +++ b/RaceOverlay/Overlays/P2PInfo/P2PInfo.xaml.cs @@ -0,0 +1,73 @@ +using System.Diagnostics; +using System.Windows; +using RaceOverlay.Internals; + +namespace RaceOverlay.Overlays.P2PInfo; + +public partial class P2PInfo : Overlay +{ + private float _p2pLeft; + private bool _p2pOn; + + public P2PInfo(): base("P2P Info", "Displays the current P2P status and remaining time.") + { + InitializeComponent(); + _setWindowSize(200, 35); + Thread updateThread = new Thread(UpdateThreadMethod); + updateThread.IsBackground = true; + updateThread.Start(); + } + + public override void _updateWindow() + { + if (_p2pLeft > 200) + { + P2PBar.Width = 200; + } + else + { + P2PBar.Width = _p2pLeft; + } + + P2PText.Text = _p2pLeft.ToString("f0"); + if (_p2pOn) + { + P2PActive.Visibility = Visibility.Visible; + P2PInactive.Visibility = Visibility.Collapsed; + } + { + P2PActive.Visibility = Visibility.Collapsed; + P2PInactive.Visibility = Visibility.Visible; + } + + + } + + public override void _getData() + { + if (_devMode) + { + InCar = true; + } + else + { + InCar = MainWindow.IRacingData.InCar; + } + + _p2pLeft = MainWindow.IRacingData.LocalCarTelemetry.P2PLeft; + _p2pOn = MainWindow.IRacingData.LocalCarTelemetry.P2POn; + } + + protected override void _scaleWindow(double scale) + { + try + { + ContentScaleTransform.ScaleX = scale; + ContentScaleTransform.ScaleY = scale; + } + catch (Exception e) + { + Debug.WriteLine(e); + } + } +} \ No newline at end of file