Skip to content

Commit 402c1bc

Browse files
authored
1.0.0 (#8)
* Map attribution background * Readme * Separated Flight details view into a custom user control (so format can change in the view, and the translation of airport codes is moved away from the data type. * Improvement to fuel quantity logic at the beginning of a flight * Better support for helicopters * Separate Aircraft data (once per flight) from Flight Data (continuous) * Rounded listview corner * Remove tray menu image space
1 parent b2d4fe4 commit 402c1bc

38 files changed

+1106
-675
lines changed

FSTRaK/DataTypes/SimConnectDataTypes.cs

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Runtime.InteropServices;
5+
using FSTRaK.Models;
56

67
namespace FSTRaK.DataTypes
78
{
@@ -19,12 +20,12 @@ public enum CameraState
1920
GamePlay = 8,
2021
Showcase = 9,
2122
DroneAircraft = 10,
22-
Waiting = 11,
23+
Waiting = 11, // Loading flight
2324
WorldMap = 12,
2425
HangarRtc = 13,
2526
HangarCustom = 14,
26-
MenuRtc = 15,
27-
InGameRtc = 16,
27+
MenuRtc = 15, // Main menu
28+
InGameRtc = 16, // "Ready to fly"
2829
Replay = 17,
2930
DroneTopDown = 19,
3031
Hangar = 21,
@@ -60,14 +61,15 @@ public enum Requests
6061
{
6162
FlightDataRequest,
6263
NearbyAirportsRequest,
63-
FlightLoaded
64+
FlightLoaded,
65+
AircraftLoaded,
66+
AircraftDataRequest
6467
}
6568

6669
public enum DataDefinitions
6770
{
68-
FlightMetaData,
71+
AircraftData,
6972
FlightData,
70-
NearbyAirports
7173
}
7274

7375
public enum Events
@@ -79,12 +81,8 @@ public enum Events
7981
}
8082

8183
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
82-
public struct AircraftFlightData
84+
public struct AircraftData
8385
{
84-
public int zuluYear;
85-
public int zuluMonth;
86-
public int zuluDay;
87-
public int zuluTime;
8886
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
8987
public string title;
9088
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
@@ -95,27 +93,37 @@ public struct AircraftFlightData
9593
public string atcType;
9694
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
9795
public string AtcId;
96+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
97+
public string Category;
9898

9999
public EngineType EngineType;
100100
public int NumberOfEngines;
101+
}
101102

103+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
104+
public struct FlightData
105+
{
106+
public int zuluYear;
107+
public int zuluMonth;
108+
public int zuluDay;
109+
public int zuluTime;
102110

103111
public int SimOnGround;
104112
public double Latitude;
105113
public double Longitude;
106114
public double TrueHeading;
107115
public double Altitude;
108116
public double TrueAirspeed;
109-
public double IndicatedAirpeed;
117+
public double IndicatedAirspeed;
110118
public double GroundVelocity;
111119
public double GroundAltitude;
112120
public double PlaneAltAboveGround;
113121
public double PlaneAltAboveGroundMinusCg;
114122
public double VerticalSpeed;
115-
public int CameraState;
123+
public CameraState CameraState;
116124
public int FlapSpeedExceeded;
117125
public int GearSpeedExceeded;
118-
public int Overspeed;
126+
public int OverSpeed;
119127
public int StallWarning;
120128
public double FlapPosition;
121129
public double FuelWeightLbs;
@@ -145,12 +153,12 @@ public double MaxThorttlePosition()
145153
return new double[] { Throttle1Position, Throttle2Position, Throttle3Position, Throttle3Position }.Max();
146154
}
147155

148-
public double MinThrottlePosition()
156+
public double MinThrottlePosition(int numberOfEngines)
149157
{
150158
var thorttlePositionArray = new List<double>( new double[] { Throttle1Position, Throttle1Position, Throttle2Position, Throttle3Position });
151-
if (NumberOfEngines == 0)
159+
if (numberOfEngines == 0)
152160
return 0;
153-
return thorttlePositionArray.GetRange(0,NumberOfEngines).Min();
161+
return thorttlePositionArray.GetRange(0, numberOfEngines).Min();
154162
}
155163

156164
}

FSTRaK/FSTRaK.csproj

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<DefineConstants>DEBUG;TRACE</DefineConstants>
4141
<DebugType>full</DebugType>
4242
<PlatformTarget>x64</PlatformTarget>
43-
<LangVersion>7.3</LangVersion>
43+
<LangVersion>latest</LangVersion>
4444
<ErrorReport>prompt</ErrorReport>
4545
<Prefer32Bit>true</Prefer32Bit>
4646
<Optimize>false</Optimize>
@@ -53,7 +53,7 @@
5353
<Optimize>true</Optimize>
5454
<DebugType>pdbonly</DebugType>
5555
<PlatformTarget>x64</PlatformTarget>
56-
<LangVersion>7.3</LangVersion>
56+
<LangVersion>latest</LangVersion>
5757
<ErrorReport>prompt</ErrorReport>
5858
<Prefer32Bit>true</Prefer32Bit>
5959
</PropertyGroup>
@@ -154,9 +154,13 @@
154154
<Compile Include="Utils\MathUtils.cs" />
155155
<Compile Include="Utils\PathUtil.cs" />
156156
<Compile Include="Utils\ResourceUtils.cs" />
157+
<Compile Include="ViewModels\FlightDetailsParamsViewModel.cs" />
157158
<Compile Include="ViewModels\FlightDetailsViewModel.cs" />
158159
<Compile Include="ViewModels\LogbookViewModel.cs" />
159160
<Compile Include="ViewModels\SettingsViewModel.cs" />
161+
<Compile Include="Views\FlightDetailsParamsView.xaml.cs">
162+
<DependentUpon>FlightDetailsParamsView.xaml</DependentUpon>
163+
</Compile>
160164
<Compile Include="Views\LiveView.xaml.cs">
161165
<DependentUpon>LiveView.xaml</DependentUpon>
162166
</Compile>
@@ -196,6 +200,10 @@
196200
<SubType>Designer</SubType>
197201
<Generator>MSBuild:Compile</Generator>
198202
</Page>
203+
<Page Include="Views\FlightDetailsParamsView.xaml">
204+
<SubType>Designer</SubType>
205+
<Generator>MSBuild:Compile</Generator>
206+
</Page>
199207
<Page Include="Views\LiveView.xaml">
200208
<SubType>Designer</SubType>
201209
<Generator>MSBuild:Compile</Generator>
@@ -269,6 +277,8 @@
269277
<None Include="App.config" />
270278
</ItemGroup>
271279
<ItemGroup>
280+
<Content Include="lib\x64\SQLite.Interop.dll" />
281+
<Content Include="lib\x86\SQLite.Interop.dll" />
272282
<Content Include="System.Buffers.dll">
273283
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
274284
</Content>

FSTRaK/FSTrAk.csproj

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<DefineConstants>DEBUG;TRACE</DefineConstants>
4141
<DebugType>full</DebugType>
4242
<PlatformTarget>x64</PlatformTarget>
43-
<LangVersion>7.3</LangVersion>
43+
<LangVersion>latest</LangVersion>
4444
<ErrorReport>prompt</ErrorReport>
4545
<Prefer32Bit>true</Prefer32Bit>
4646
<Optimize>false</Optimize>
@@ -53,7 +53,7 @@
5353
<Optimize>true</Optimize>
5454
<DebugType>pdbonly</DebugType>
5555
<PlatformTarget>x64</PlatformTarget>
56-
<LangVersion>7.3</LangVersion>
56+
<LangVersion>latest</LangVersion>
5757
<ErrorReport>prompt</ErrorReport>
5858
<Prefer32Bit>true</Prefer32Bit>
5959
</PropertyGroup>
@@ -154,9 +154,13 @@
154154
<Compile Include="Utils\MathUtils.cs" />
155155
<Compile Include="Utils\PathUtil.cs" />
156156
<Compile Include="Utils\ResourceUtils.cs" />
157+
<Compile Include="ViewModels\FlightDetailsParamsViewModel.cs" />
157158
<Compile Include="ViewModels\FlightDetailsViewModel.cs" />
158159
<Compile Include="ViewModels\LogbookViewModel.cs" />
159160
<Compile Include="ViewModels\SettingsViewModel.cs" />
161+
<Compile Include="Views\FlightDetailsParamsView.xaml.cs">
162+
<DependentUpon>FlightDetailsParamsView.xaml</DependentUpon>
163+
</Compile>
160164
<Compile Include="Views\LiveView.xaml.cs">
161165
<DependentUpon>LiveView.xaml</DependentUpon>
162166
</Compile>
@@ -196,6 +200,10 @@
196200
<SubType>Designer</SubType>
197201
<Generator>MSBuild:Compile</Generator>
198202
</Page>
203+
<Page Include="Views\FlightDetailsParamsView.xaml">
204+
<SubType>Designer</SubType>
205+
<Generator>MSBuild:Compile</Generator>
206+
</Page>
199207
<Page Include="Views\LiveView.xaml">
200208
<SubType>Designer</SubType>
201209
<Generator>MSBuild:Compile</Generator>
@@ -269,6 +277,8 @@
269277
<None Include="App.config" />
270278
</ItemGroup>
271279
<ItemGroup>
280+
<Content Include="lib\x64\SQLite.Interop.dll" />
281+
<Content Include="lib\x86\SQLite.Interop.dll" />
272282
<Content Include="System.Buffers.dll">
273283
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
274284
</Content>

FSTRaK/Models/AirportResolver.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ private async void LoadAirportsJson()
2727
Log.Information($"{AirportsDictionary.Count} airports loaded.");
2828
}
2929

30+
public Airport GetAirportByIcaoCode(string code)
31+
{
32+
try
33+
{
34+
return AirportsDictionary[code];
35+
}
36+
catch
37+
{
38+
return new Airport()
39+
{
40+
icao = code
41+
};
42+
}
43+
}
44+
3045

3146
public static AirportResolver Instance
3247
{

FSTRaK/Models/BaseModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace FSTRaK.Models
1010
{
11-
internal abstract class BaseModel : INotifyPropertyChanged
11+
public abstract class BaseModel : INotifyPropertyChanged
1212
{
1313
public event PropertyChangedEventHandler PropertyChanged;
1414

FSTRaK/Models/Entity/Aircraft.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,25 @@
66

77
namespace FSTRaK.Models
88
{
9-
internal class Aircraft : BaseModel
9+
public class Aircraft : BaseModel
1010
{
1111
[Column("ID")]
1212
public int Id { get; set; }
1313

1414
[Index(nameof(Title), IsUnique = true)]
1515
public string Title { get; set; }
16-
1716
public String AircraftType { get; set; }
1817

18+
public String Category { get; set; }
1919
public String Manufacturer { get; set; }
20-
21-
2220
public String Airline { get; set; }
2321
public String Model { get; set; }
2422
public String TailNumber { get; set; }
25-
2623
public int NumberOfEngines { get; set; }
27-
2824
public EngineType EngineType { get; set; }
29-
3025
public override bool Equals(Object obj)
3126
{
32-
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
27+
if ((obj == null) || this.GetType() != obj.GetType())
3328
{
3429
return false;
3530
}

FSTRaK/Models/Entity/Flight.cs

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public TimeSpan FlightTime
4343
public FlightOutcome FlightOutcome { get; set; }
4444
public double Score { get; set; }
4545

46-
public string ScoreDetails { get; set; }
47-
4846
public ObservableCollection<BaseFlightEvent> FlightEvents { get; }
4947

5048
private Airport _departureAirportDetails;
@@ -109,38 +107,15 @@ public Flight()
109107
public override string ToString()
110108
{
111109
var sb = new StringBuilder();
112-
sb.AppendLine($"Departed From: {this.DepartureAirportDetails}");
113-
114-
if (this.FlightOutcome == FlightOutcome.Crashed)
115-
{
116-
sb.AppendLine(($"Crashed Near {this.ArrivalAirportDetails}"));
117-
}
118-
else
119-
{
120-
sb.AppendLine(($"Arrived At: {this.ArrivalAirportDetails}"));
121-
}
122-
123-
sb.AppendLine($"Start Time: {this.StartTime}")
124-
.AppendLine($"End Time: {this.EndTime}")
125-
.AppendLine($"Block Time: {this.FlightTime}");
126-
127-
if (Properties.Settings.Default.Units == (int)Units.Metric)
128-
sb.AppendLine($"Fuel Used: {(TotalFuelUsed * Consts.LbsToKgs):F1} Kg");
129-
else
130-
sb.AppendLine($"Fuel Used: {TotalFuelUsed:F1} Lbs");
131-
132-
133-
134-
sb.AppendLine($"Flown Distance: {FlightDistanceNm:F0} NM");
135-
136-
var landingEvent = (LandingEvent)this.FlightEvents.FirstOrDefault(e => e is LandingEvent);
137-
if (landingEvent != null)
138-
{
139-
sb.AppendLine($"Lnading VS: {landingEvent.VerticalSpeed:F0} ft/m");
140-
}
141-
142-
143-
sb.Append($"Score: {this.Score}");
110+
sb.AppendLine($"{this.FlightOutcome}")
111+
.AppendLine($"Departed From: {this.DepartureAirportDetails}")
112+
.AppendLine(($"Arrived At: {this.ArrivalAirportDetails}"))
113+
.AppendLine($"Start Time: {this.StartTime}")
114+
.AppendLine($"End Time: {this.EndTime}")
115+
.AppendLine($"Block Time: {this.FlightTime}")
116+
.AppendLine($"Fuel Used: {TotalFuelUsed:F1} Lbs")
117+
.AppendLine($"Flown Distance: {FlightDistanceNm:F0} NM")
118+
.Append($"Score: {this.Score}");
144119
return sb.ToString();
145120
}
146121

0 commit comments

Comments
 (0)