dkavolis / Ferram-Aerospace-Research

Aerodynamics model for Kerbal Space Program
Other
80 stars 32 forks source link

SpeedUnitAnnex compatibility #32

Closed yalov closed 5 years ago

yalov commented 5 years ago

SpeedUnitAnnex (SUA) changes lines on the navball panel, so in the Surface Mode it looks like this:

both FAR and SUA make this, but FAR somehow wins:

https://github.com/dkavolis/Ferram-Aerospace-Research/blob/0a49305d18bcf19f38c33d25887a3e66a22d014c/FerramAerospaceResearch/FARGUI/FARFlightGUI/AirspeedSettingsGUI.cs#L201-L202

Anyway, looks like all this navball-panel-speed-units-feature can be passed to SUA. SUA for the planes has main speedometer (m/s), secondary speedometer (mach or knots or km/h or mph) and disabled by default IAS (m/s)

I have found the feature settings in the FAR: FAR toolbar - Fit Settings - Air Spd. All these units and IAS already in the SUA. (does EAS makes sense without FAR?)

left panel on that image (surface speed: 915.9 m/s, Mach 3.0, IAS: 12.5 m/s, AGL 23.2 km):

So possibility1: deleting some code in the AirspeedSettingsGUI and making FAR suggesting SUA possibility2: I could make SUA overriding FAR (without any changes in the FAR) on the Navball panel, any idea how?

UPD. possibility3: FAR detects SUA and disables FAR's navball-panel-text

dkavolis commented 5 years ago

I could expose a method to toggle FAR speed display to FARAPI. You would then have to look for if FAR has been loaded and disable its speed display.

yalov commented 5 years ago

Will I need to copy FARAPI.cs to my repo, similar to KAC_Wrapper ?

dkavolis commented 5 years ago

No, you load the method by reflection. Check how MechJeb does it https://github.com/MuMech/MechJeb2/blob/0d49eac5f938aabe5271de98b73b9563b802ff78/MechJeb2/VesselState.cs

yalov commented 5 years ago

ok, I will figure this out

dkavolis commented 5 years ago

You can try out #33 https://github.com/dkavolis/Ferram-Aerospace-Research/blob/fd5d28c14fab240161ff2e9c52879f615655de44/FerramAerospaceResearch/FARAPI.cs#L89-L115

yalov commented 5 years ago

I created FARReflection in the Start() of KSPAddon and was trying to call ToggleAirspeedDisplay right after that in the Start(), but it was returning failure of toggling. Same thing happens for FARReflection placed in the constructor of KSPAddon and ToggleAirspeedDisplay placed in the start.

Then I called ToggleAirspeedDisplay() in some later GameEvents like OnGameUnpause() and OnSetSpeedMode(), and it works ok, after manual un-pausing or SpeedMode changes.

Is there some near-start-time Method or GameEvent, where it will be working?

dkavolis commented 5 years ago

The airspeed display is attached to FlightGUI which is a vessel module so you will need to toggle it at the start of every flight scene/vessel load. I've added a global option to make things easier

https://github.com/dkavolis/Ferram-Aerospace-Research/blob/f4488e1c8e5c91849fb9c65febb478cad1d1ad83/FerramAerospaceResearch/FARAPI.cs#L89-L129

yalov commented 5 years ago

global version doesn't use Vessel, so maybe ToggleAirspeedDisplay(Vessel? v = null, bool? enabled = null) and v == null means globally?

dkavolis commented 5 years ago

Done, Vessel is already nullable so no need for ?. I've switched v and enabled around since global change by default might be more useful. https://github.com/dkavolis/Ferram-Aerospace-Research/blob/256bf7ee4df26b69596b9056f47a2493284558f9/FerramAerospaceResearch/FARAPI.cs#L89-L128

yalov commented 5 years ago

ok, I think it works

dkavolis commented 5 years ago

Merged #33

yalov commented 5 years ago

Another one, looks like FlightGlobals.ActiveVessel.indicatedAirSpeed doesn't shows right value with FAR. Could you also add IAS for the current vessel? And maybe also EAS... for the future.

dkavolis commented 5 years ago

FAR calculates IAS and EAS in AirspeedSettingsGUI. I can expose them in FARAPI.

dkavolis commented 5 years ago

Try out #34

https://github.com/dkavolis/Ferram-Aerospace-Research/blob/82b77ed8e3b0ea3f4a1bf1a9b220893e4fbb733b/FerramAerospaceResearch/FARAPI.cs#L135-L153

yalov commented 5 years ago

thanks, it works.

when are you planning on making full release?

dkavolis commented 5 years ago

Merged #34

I don't know about a full release. If I changed the versioning to incrementing revision number without changing the name I could do more frequent releases if there were any changes.

yalov commented 5 years ago

that would be good