Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Descent Profile Settings from VAB/SPH #135

Open
DBooots opened this issue Mar 7, 2018 · 9 comments
Open

Set Descent Profile Settings from VAB/SPH #135

DBooots opened this issue Mar 7, 2018 · 9 comments

Comments

@DBooots
Copy link

DBooots commented Mar 7, 2018

The TrajectoriesVesselSettings part module could be made to have a context menu button when in the editor that would allow setting the descent profile from the editor that would then persist into launched vessels of that type.

This could even be done on a per-command part basis (for example, a dreamchaser-type vessel where the top re-enters prograde and the reusable booster re-enters retrograde). Since the Descent Profile fetcher looks for FirstOrDefault it would find the appropriate one on each of the two component vessels after stage separation. *Note that any changes afterwards to the descent profile in the flight settings window would overwrite all of these in the DescentProfile.Save() method.

@DBooots
Copy link
Author

DBooots commented Mar 7, 2018

Recommend adding the 'Enhancement' label.

I'll give this a shot and hopefully have a pull request ready in time for the inevitable 1.4.1 compatibility update. ;)

@PiezPiedPy PiezPiedPy self-assigned this Mar 7, 2018
@neuoy
Copy link
Owner

neuoy commented Mar 8, 2018

You are welcome to give this a shot, but I'm not sure it will work to set different settings on each command module. If I remember correctly (but it's been a long time now), settings are written on all command modules of the current vessel while in flight, so that when parts are detached, they keep a copy of the last used settings. But if it causes issues with what you want to do, this behavior can be changed of course.

@PiezPiedPy
Copy link
Contributor

neuoy is correct, if settings are to be set in the VAB/SPH they will apply to all control modules on a craft.

@DBooots
Copy link
Author

DBooots commented Mar 8, 2018

I'd say only sort of correct. The values in all TrajectoriesVesselSettings are currently only set when DescentProfile.Save() is called. From what I can tell, this is only called when the current DescentProfile is modified. So the settings set in the editor would persist until the user modified something in the GUI in flight. Reading through the initialization process, it looks like it pulls the settings from .FirstOrDefault() and doesn't then re-Save them. So the window will have the primary one and the rest would have their values from the editor unless the current settings are changed. So when parts are detached they'll keep a copy of the last used settings unless they have a command source with saved settings AND the main settings have not been changed since launch.
I'm working on this right now, so I'll keep you posted. If I'm wrong, there could also be an option to tell it to resist changes in flight once it's set in the editor unless it is the primary module.

@PiezPiedPy
Copy link
Contributor

I was assuming in my reply that you would be using DescentProfile.Save() to store the settings.

If you are going to save the settings in a different manner then what you say will be correct.

May I suggest you start a branch for your commits in your fork so we can be nosey parkers and watch the development 😜

@DBooots
Copy link
Author

DBooots commented Mar 9, 2018

I made a branch and threw in a commit. The GUI doesn't show up like I thought it should, but I'm sure that's just a minor bug. Also, my GUI code is super ugly and could certainly be made better (I was trying to hack something together from what you already had).

I'm just saving the settings directly in the PartModule of the part whose context button was clicked. This will then save through the stock persistence ConfigNode saving system. I'm also setting the Initialized field to true so that it doesn't get set to defaults when first seen by the plugin in flight.

@PiezPiedPy
Copy link
Contributor

Sweet, I'll have a look later tomorrow, 12:30am here in the UK, time for bed ⏲

KSP's popup dialog system is a pain to work with, many a time I wanted to wring its neck lol, have fun.

@DBooots
Copy link
Author

DBooots commented Mar 9, 2018

DBooots@e90c383 works. Sort of. The Localization in the Editor GUI doesn't work for some reason and I can't drag the windows around, but the changed settings do persist into flight.

For testing, I added a probe core to the first stage of the KerbalX stock craft, set it to re-enter prograde and the capsule to re-enter retrograde. Sitting on the launchpad, the GUI shows the retrograde setting (makes sense, since the capsule is the root part and thus, first found). After staging, the capsule still shows retrograde but the first stage shows prograde.

In the update to 1.4, we should see if we can select the settings in the same order as the naming/icon priority order that they added.

@DBooots
Copy link
Author

DBooots commented Dec 22, 2018

Just following up on this. If you're putting out a new release for 1.6, might I suggest this as a relatively easy enhancement to roll into that?

PiezPiedPy added a commit that referenced this issue Jun 25, 2020
Trajectories consisted of multiple KSPAddon classes which gave no control over startup, update order etc.
Trajectories now consists of the separate KSPAddon classes becoming static non MonoBehaviour classes managed by a single KSPScenario ScenarioModule class contained in Trajectories.cs.
I have made these changes in preparation for an attempt at moving the simulation into a separate thread away from the single main Unity thread. See issue #123
Could also be helpfull with things like issue #135
cbase2 pushed a commit to cbase2/KSPTrajectories that referenced this issue Jul 16, 2020
Trajectories consisted of multiple KSPAddon classes which gave no control over startup, update order etc.
Trajectories now consists of the separate KSPAddon classes becoming static non MonoBehaviour classes managed by a single KSPScenario ScenarioModule class contained in Trajectories.cs.
I have made these changes in preparation for an attempt at moving the simulation into a separate thread away from the single main Unity thread. See issue neuoy#123
Could also be helpfull with things like issue neuoy#135
@PiezPiedPy PiezPiedPy removed their assignment Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants