Changes to support the Trajectories v2.0.0 to v2.2.0 API#2220
Changes to support the Trajectories v2.0.0 to v2.2.0 API#2220Dunbaratu merged 13 commits intoKSP-KOS:developfrom
Conversation
Changes to Trajectories addon classes to support the v2.0.0 release of Trajectories. Added the new Trajectories:API method HasTarget.
|
Issue #2214 should also be fixed with the Trajectories v2.0.0 release |
|
Will these proposed changes only work with Trajectories v2.0.0, or will they also work with the current Trajectories release? (i.e. if we merge this PR, does that mean we should wait for Trajectories v2.0.0 before we let the public see this PR?) |
|
@Dunbaratu The changes in this PR will only work with Trajectories v2 which I'm going to release later Today. Also regrettably Trajectories v2 will not work with the current release of kOS due to the API method name changes that where made 😞 |
|
I can confirm that Trajectories is working. I've got this PR locally merged into master 06ef52a, and I correctly see |
| trGetImpactPosition = trajectoriesAPIType.GetMethod("getImpactPosition"); | ||
| trGetImpactPosition = trajectoriesAPIType.GetMethod("GetImpactPosition"); | ||
| if (trGetImpactPosition == null) | ||
| { |
There was a problem hiding this comment.
I'd like to attempt to make this work regardless of which version of Trajectories is installed.
Would it be a bad thing if I changed this to look for both spellings and use whichever one it finds?
That will make life easier for me later if I choose to make a back-port for RO compatibility.
There was a problem hiding this comment.
Sounds like a good idea, only bad thing although not a big issue is anyone using an older Trajectories version will not gain the error checking in the newer API.
With the new method HasTarget you could just return a message stating something like, 'This function only available in Trajectories v2.x.x'
On a side note I've also created a branch of Trajectoriesv2.x.x for KSP1.3 (not built a release yet but tests have been positive so a release is imminent).
Thinking about it I am going to add a new method to the Trajectories API which returns its version number.
I can make the changes later today if you wish and add them to this PR.
There was a problem hiding this comment.
I don't think older users will get the error checking, but at least it would still work as well as it did before before the error checking was present, i.e. using new kOS with old Trajectories wouldn't break. By the way I was looking at this myself overnight and was going to send a PR back to you on top of your PR.
There was a problem hiding this comment.
I'll wait till you send your PR. 😉
you could use the new API method to check the version if you wish, I've called it GetVersion returns a string i.e. 2.1.0
Also now going to add GetVersionMajor , GetVersionMinor and GetVersionPatch that return an integer value.
Obviously a check for a version earlier than v2.x.x will be just to find if the Trajectories addon is available and if GetVersion exists.
Commit will be later today on Trajectories/master I'll let you know when I commit so you can have a look at the code.
There was a problem hiding this comment.
I had a few questions about the API but it's probably faster to PR back to you what I have and let you handle it than keep asking questions and doing it myself. Let me make the PR. It's not big.
There was a problem hiding this comment.
So HasTarget didn't exist in older Trajectories versions? That answers one of the questions I had (did you just happen to add the suffix to kOS it because it was forgotten before, or because it truly was new).
There was a problem hiding this comment.
HasTarget is new to v2.x.x and does not exist in the older versions.
There was a problem hiding this comment.
Is your branch "Trajectories-v2.0.0-API-update" based on an older version of our develop? When I try to PR back to you I see a very big list of diffs, far more than the few I made. It makes sense why it would be (I let this PR sit for a bit). But I think you'd be best off first updating your branch to the most recent develop before looking at my PR to you, that way you'll only see the relevant diffs I just made.
There was a problem hiding this comment.
The PR to your branch has been made.
There was a problem hiding this comment.
Thanks, will have a look soon 😉
…te' into trajectories_both_versions
This probably still needs more changes - giving it back to PiezPiedPy.
Trajectories both versions
|
@Dunbaratu Hi |
|
@PiezPiedPy |
|
@PiezPiedPy, basically in all these sorts of |
|
Is there any way to simulate a C# property { get; set; } with a single Suffix rather than having to define two Suffixes. This is what I have done for the new API property set is allways true, does not need an input arg Also done the same for |
* Changes to Trajectories addon classes to support the v2.2.0 release of Trajectories. * New API functions added `TimeTillImpact`. * For the Descent Profile `IsPrograde` `IsRetrograde` `SetPrograde` `SetRetrograde`. * And some for version checking `GetVersion` `IsVerTwo` `IsVerTwoTwo`.
|
I'm all done here, also added what was needed for the v2.2.0 API additions.
I also checked that all versions of Trajectories will work with this merge. 😉 https://github.com/neuoy/KSPTrajectories/blob/master/Plugin/API.cs if you need/want to have a nose about. |
|
@PiezPiedPy - Look for places in our code where the phrase " The constructor typically looks like this: SetSuffix( getter delegate, setter delegate, "text description") (There's also a Would you like to use this to combine On another note, this does make me feel a lack in kerboscript is the lack of an enum type. Because obviously you don't want both retrograde and prograde to be true at the same time, so having two independent Booleans for them seems wrong, but I admit there isn't really a good way around it without adding enums to kerboscript. |
|
@Dunbaratu Thanks for the help, I will have a play and see what happens, hopefully with the info I can successfully combine |
`IsPrograde` and `SetPrograde` are now `Prograde`. `IsRetrograde` and `SetRetrograde` are now `Retrograde`.
|
Finally done, you can merge whenever you feel the urge 😉 |
Dunbaratu
left a comment
There was a problem hiding this comment.
I will be adding the user documentation changes to go with this before I merge it. I don't want to ask you to go learning the doc subsystem too, so I'll do that part on my own before I merge it.
(i.e. I'll be editing the file doc/source/addons/Trajectories.rst and adding that edit to my branch before I merge this to develop.)
To help manage the user docs and keep them updated, I made this rule a couple of years ago: All merges into develop must combine both the code changes and user doc changes together so they form a single atomic merge. In other words, in develop, the *.cs files and the *.rst files are not allowed to temporarily disagree with each other.
This went a long way to cleaning up the docs. The docs used to have a lot of disagreement with reality back when we were manually updating them just before each release rather than editing them piecemeal along with the code changes.
| public static bool IsVerTwo { get; private set; } = false; | ||
|
|
||
| public static bool IsVerTwoTwo { get; private set; } = false; | ||
|
|
There was a problem hiding this comment.
The Monodevelop that ships with Unity 2017.1.3 (the Unity version KSP 1.4.2 is officially built with) doesn't understand this C# syntax (having an initializer for a property). It's stuck on a slightly older version of the C# language spec from before this was a thing. To make it work, I'll edit these lines to have the property backed by a field, and initialize the field.
Making sure things compile with the older C# supported by the Monodevelop that Unity comes with is important to me because that's the only option people developing on Linux have at the moment. Eventually, Unity says they will move to a system where they use VSCode and the commandline compiler of Mono as the official Linux developer solution, but in the current version KSP is using, that hasn't happened yet.
| IsVerTwo = true; | ||
| IsVerTwoTwo = true; | ||
| SafeHouse.Logger.Log("Checking Trajectories version: API.GetVersion returned version: v" + GetVersion); | ||
| } |
There was a problem hiding this comment.
This looks like a good way to solve the version check problem where there wasn't a version API beforehand.
|
@PiezPiedPy - As I was writing the docs for this I realized there seems to be a lack of an important feature in the API: Once a script calls I was just going to add a suffix myself to this PR that does it. But when I looked at the Trajectories code on Github, I can't find anything in Of course, I could bypass |
|
There's a new PR to your branch you can look at. Sorry, for constantly throwing this back - I swear I'm ready to merge it now, if you approve of the edits I did to the user docs and verify that I didn't say anything wrong in them. |
PR review changes.
|
@Dunbaratu Checked your PR and the docs look fine so I've merged your PR. Re: The clearing of the Target, well spotted I missed that one 🙄. I will add it onto my To-do list and include it when I code the methods for setting the Descent Profile via the API, I wont be including them in this PR though but I will create a new one when the time comes. |
|
@PiezPiedPy - There's a few things to add to maybe the next update to the API, but they shouldn't prevent the merging of this PR, so I made a separate issue for them, #2263. |
|
Also fixes #2254 which is a duplicate issue. |
Hi, I'm a Collaborator for the Trajectories mod and we have made changes to the API which will be included in the soon to be released v2.2.0
https://github.com/neuoy/KSPTrajectories/blob/master/Plugin/API.cs
I thought it would be wise to provide you with a pull-request, with changes needed to help stop any problems arising in future releases of kOS, when used with Trajectories.
Changes for v2.0.0 are:
HasTarget.Changes for v2.2.0 are:
TimeTillImpact.ProgradeandRetrograde.GetVersionIsVerTwoIsVerTwoTwo.There are also some changes that you need to make regarding Trajectories that are not correct in the kOS Documentation:
SetTargetcan be used regardless of a predicted trajectory calculated or not and thus a check forHasImpactis not required but an active vessel check is still required.PlannedVectorandCorrectedVectorrequire a valid target to be set before calling otherwise they will throw an exception, the Trajectories:API methodsPlannedDirectionandCorrectedDirectionwill return a null in such cases.