Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions RaceOverlay/Overlays/FuelCalculator/FuelCalculator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
Expand All @@ -37,8 +39,14 @@
<TextBlock Grid.Column="0" Grid.Row="1" Text="Fuel in tank: "></TextBlock>
<TextBlock Name="FuelInTank" Grid.Column="1" Grid.Row="1"></TextBlock>

<TextBlock Grid.Column="0" Grid.Row="2" Text="Laps: "></TextBlock>
<TextBlock Name="LapsText" Grid.Column="1" Grid.Row="2"></TextBlock>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Time in Stint: "></TextBlock>
<TextBlock Name="TimeInStintText" Grid.Column="1" Grid.Row="2"></TextBlock>

<TextBlock Grid.Column="0" Grid.Row="3" Text="Laps in Tank: "></TextBlock>
<TextBlock Name="LapsText" Grid.Column="1" Grid.Row="3"></TextBlock>

<TextBlock Grid.Column="0" Grid.Row="4" Text="Time in Tank: "></TextBlock>
<TextBlock Name="TimeLeftText" Grid.Column="1" Grid.Row="4"></TextBlock>


</Grid>
Expand Down
39 changes: 36 additions & 3 deletions RaceOverlay/Overlays/FuelCalculator/FuelCalculator.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public partial class FuelCalculator : Overlay
private float _currentFuel;
private iRacingData _data;
private int _lap;
private TimeSpan _lastTimeEnteredTrack;
private bool _isOnTrack = false;

// Calculated values
private float _fuelPerLap;
Expand All @@ -33,10 +35,11 @@ public partial class FuelCalculator : Overlay
public FuelCalculator() : base("Fuel Calculator","This Overlay calculates the fuel needed to finish")
{
InitializeComponent();
_setWindowSize(160, 60);
_setWindowSize(190, 100);

_getConfig();

_lastTimeEnteredTrack = TimeSpan.Zero;
_lastLapFuel = new List<float>();
_lastLapTimes = new List<float>();

Expand Down Expand Up @@ -74,8 +77,19 @@ public override void _updateWindow()
FuelNeededText.Background = Brushes.Red;
FuelNeededText.Text = _fuelToFinish.ToString("F2");
}
var fuelLaps = CalcFuelLaps();
TimeInStintText.Text = (new TimeSpan(DateTime.Now.Ticks) - _lastTimeEnteredTrack).ToString(@"hh\:mm\:ss");
FuelInTank.Text = _currentFuel.ToString("F2");
LapsText.Text = CalcFuelLaps().ToString("F1");
LapsText.Text = fuelLaps.ToString("F1");
try
{
TimeLeftText.Text = "~" + TimeSpan.FromSeconds(fuelLaps * _avgLapTime).ToString(@"hh\:mm\:ss");
}
catch (Exception)
{
TimeLeftText.Text = "NaN";
}

}

public override void _getData()
Expand All @@ -84,7 +98,8 @@ public override void _getData()

_currentFuel = _data.LocalCarTelemetry.FuelLevel;
Lap = _data.LocalCarTelemetry.Lap;

OnTrack = !_data.Pitstop.InPit || _data.InGarage;

}

public override void UpdateThreadMethod()
Expand Down Expand Up @@ -138,6 +153,24 @@ public int Lap
}
}
}

public bool OnTrack
{
get => _isOnTrack;
set
{
if (_isOnTrack != value)
{
_isOnTrack = value;
OnPropertyChanged();
if (_isOnTrack)
{
_lastTimeEnteredTrack = new TimeSpan(DateTime.Now.Ticks);
}
}
}
}


private void OnLapChanged()
{
Expand Down
Loading